comefrom: <doocs>0276.Paint Fence_1.py
code: def numWays( n: int, k: int) -> int:
      dp = [[0] * 2 for _ in range(n)]
      dp[0][0] = k
      for i in range(1, n):
          dp[i][0] = (dp[i - 1][0] + dp[i - 1][1]) * (k - 1)
          dp[i][1] = dp[i - 1][0]
      return sum(dp[-1])
masked: def sample_funcname ( var_0 : int , var_2 : int ) -> int :
      var_7 = [ [ 0 ] * 2 for var_5 in range ( var_0 ) ]
      var_7 [ 0 ] [ 0 ] = var_2
      for var_9 in range ( 1 , var_0 ) :
          var_7 [ var_9 ] [ 0 ] = ( var_7 [ var_9 - 1 ] [ 0 ] + var_7 [ var_9 - 1 ] [ 1 ] ) * ( var_2 - 1 )
          var_7 [ var_9 ] [ 1 ] = var_7 [ var_9 - 1 ] [ 0 ]
      return sum ( var_7 [ - 1 ] )
  