input: Write a python function to solve the knapsack problem using dynamic programming.
  assert knapsack([1, 2, 3], [10, 15, 40], 6) == 65
  assert knapsack([10, 20, 30], [60, 100, 120], 50) == 220
  assert knapsack([1, 4, 3], [1500, 3000, 2000], 4) == 3000
output: def knapsack(weights, values, capacity):
      n = len(weights)
      dp = [[0 for _ in range(capacity + 1)] for _ in range(n + 1)]
      
      for i in range(1, n + 1):
          for w in range(1, capacity + 1):
              if weights[i-1] <= w:
                  dp[i][w] = max(dp[i-1][w], dp[i-1][w-weights[i-1]] + values[i-1])
              else:
                  dp[i][w] = dp[i-1][w]
      
      return dp[n][capacity]