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_1 : List [ int ] ) -> int :
      var_2 = len ( var_1 )
      if var_2 < 2 :
          return 0
      var_4 = [ [ [ 0 ] * 2 for var_3 in range ( var_0 + 1 ) ] for var_3 in range ( var_2 ) ]
      for var_5 in range ( 1 , var_0 + 1 ) :
          var_4 [ 0 ] [ var_5 ] [ 1 ] = - var_1 [ 0 ]
      for var_5 in range ( 1 , var_2 ) :
          for var_6 in range ( 1 , var_0 + 1 ) :
              var_4 [ var_5 ] [ var_6 ] [ 0 ] = max ( var_4 [ var_5 - 1 ] [ var_6 ] [ 1 ] + var_1 [ var_5 ] , var_4 [ var_5 - 1 ] [ var_6 ] [ 0 ] )
              var_4 [ var_5 ] [ var_6 ] [ 1 ] = max ( var_4 [ var_5 - 1 ] [ var_6 - 1 ] [ 0 ] - var_1 [ var_5 ] , var_4 [ var_5 - 1 ] [ var_6 ] [ 1 ] )
      return var_4 [ - 1 ] [ var_0 ] [ 0 ]
  