comefrom: <doocs>0188.Best Time to Buy and Sell Stock IV_1.py
code: def maxProfit( k: int, prices: List[int]) -> int:
      n = len(prices)
      if n < 2:
          return 0
      dp = [[[0] * 2 for _ in range(k + 1)] for _ in range(n)]
      for i in range(1, k + 1):
          dp[0][i][1] = -prices[0]
      for i in range(1, n):
          for j in range(1, k + 1):
              dp[i][j][0] = max(dp[i - 1][j][1] + prices[i], dp[i - 1][j][0])
              dp[i][j][1] = max(dp[i - 1][j - 1][0] - prices[i], dp[i - 1][j][1])
      return dp[-1][k][0]
masked: def sample_funcname ( var_0 : int , var_2 : List [ int ] ) -> int :
      var_5 = len ( var_2 )
      if var_5 < 2 :
          return 0
      var_11 = [ [ [ 0 ] * 2 for var_8 in range ( var_0 + 1 ) ] for var_8 in range ( var_5 ) ]
      for var_12 in range ( 1 , var_0 + 1 ) :
          var_11 [ 0 ] [ var_12 ] [ 1 ] = - var_2 [ 0 ]
      for var_12 in range ( 1 , var_5 ) :
          for var_13 in range ( 1 , var_0 + 1 ) :
              var_11 [ var_12 ] [ var_13 ] [ 0 ] = max ( var_11 [ var_12 - 1 ] [ var_13 ] [ 1 ] + var_2 [ var_12 ] , var_11 [ var_12 - 1 ] [ var_13 ] [ 0 ] )
              var_11 [ var_12 ] [ var_13 ] [ 1 ] = max ( var_11 [ var_12 - 1 ] [ var_13 - 1 ] [ 0 ] - var_2 [ var_12 ] , var_11 [ var_12 - 1 ] [ var_13 ] [ 1 ] )
      return var_11 [ - 1 ] [ var_0 ] [ 0 ]
  