<doocs>0552.Student Attendance Record II_1.py
def checkRecord( n: int) -> int:
    mod = int(1e9 + 7)
    dp = [[[0, 0, 0], [0, 0, 0]] for _ in range(n)]
    
    dp[0][0][0] = dp[0][0][1] = dp[0][1][0] = 1
    
    for i in range(1, n):
        dp[i][1][0] = (dp[i - 1][0][0] + dp[i - 1][0][1] + dp[i - 1][0][2]) % mod
        dp[i][0][1] = dp[i - 1][0][0]
        dp[i][0][2] = dp[i - 1][0][1]
        dp[i][1][1] = dp[i - 1][1][0]
        dp[i][1][2] = dp[i - 1][1][1]
        dp[i][0][0] = (dp[i - 1][0][0] + dp[i - 1][0][1] + dp[i - 1][0][2]) % mod
        dp[i][1][0] = (
            dp[i][1][0] + dp[i - 1][1][0] + dp[i - 1][1][1] + dp[i - 1][1][2]
        ) % mod
    
    ans = 0
    for j in range(2):
        for k in range(3):
            ans = (ans + dp[n - 1][j][k]) % mod
    return ans
def sample_funcname ( var_0 : int ) -> int :
    var_4 = int ( 1e9 + 7 )
    var_8 = [ [ [ 0 , 0 , 0 ] , [ 0 , 0 , 0 ] ] for var_6 in range ( var_0 ) ]
    var_8 [ 0 ] [ 0 ] [ 0 ] = var_8 [ 0 ] [ 0 ] [ 1 ] = var_8 [ 0 ] [ 1 ] [ 0 ] = 1
    for var_10 in range ( 1 , var_0 ) :
        var_8 [ var_10 ] [ 1 ] [ 0 ] = ( var_8 [ var_10 - 1 ] [ 0 ] [ 0 ] + var_8 [ var_10 - 1 ] [ 0 ] [ 1 ] + var_8 [ var_10 - 1 ] [ 0 ] [ 2 ] ) % var_4
        var_8 [ var_10 ] [ 0 ] [ 1 ] = var_8 [ var_10 - 1 ] [ 0 ] [ 0 ]
        var_8 [ var_10 ] [ 0 ] [ 2 ] = var_8 [ var_10 - 1 ] [ 0 ] [ 1 ]
        var_8 [ var_10 ] [ 1 ] [ 1 ] = var_8 [ var_10 - 1 ] [ 1 ] [ 0 ]
        var_8 [ var_10 ] [ 1 ] [ 2 ] = var_8 [ var_10 - 1 ] [ 1 ] [ 1 ]
        var_8 [ var_10 ] [ 0 ] [ 0 ] = ( var_8 [ var_10 - 1 ] [ 0 ] [ 0 ] + var_8 [ var_10 - 1 ] [ 0 ] [ 1 ] + var_8 [ var_10 - 1 ] [ 0 ] [ 2 ] ) % var_4
        var_8 [ var_10 ] [ 1 ] [ 0 ] = ( var_8 [ var_10 ] [ 1 ] [ 0 ] + var_8 [ var_10 - 1 ] [ 1 ] [ 0 ] + var_8 [ var_10 - 1 ] [ 1 ] [ 1 ] + var_8 [ var_10 - 1 ] [ 1 ] [ 2 ] ) % var_4
    var_12 = 0
    for var_13 in range ( 2 ) :
        for var_15 in range ( 3 ) :
            var_12 = ( var_12 + var_8 [ var_0 - 1 ] [ var_13 ] [ var_15 ] ) % var_4
    return var_12
