input: Write a function to calculate the maximum possible revenue from items with given weights and values using a knapsack algorithm. The function should return the maximum value that can be obtained with a given total weight limit.
  assert knapsack([2, 1, 3], [4, 2, 3], 3, 5) == 7
  assert knapsack([1, 3, 4, 5], [1, 4, 5, 7], 4, 7) == 9
  assert knapsack([1, 2, 3], [1, 2, 3], 3, 4) == 4
  assert knapsack([], [], 0, 0) == 0
  assert knapsack([1, 1, 2], [5, 5, 10], 3, 2) == 10
output: def knapsack(weights, values, n, max_weight):
      dp = [0] * (max_weight + 1)
      for i in range(n):
          for w in range(max_weight, weights[i] - 1, -1):
              dp[w] = max(dp[w], dp[w - weights[i]] + values[i])
      return dp[max_weight]