Store the maximum of popping j elements up to the current stack by popping k elements from current stack and j - k elements from all previous stacks combined
dp [ i + 1 ] [ j ] = max ( dp [ i + 1 ] [ j ] , stacks [ i ] [ k ] + dp [ i ] [ j - k ] ) NEW_LINE