input: def optimal_knapsack_solution(capacity: int, items: List[Tuple[int, int]]) -> int:
      """ Find the optimal solution to solve a knapsack problem using dynamic programming.
      Given a list of items with their values and weights, and a knapsack capacity, return the maximum
      value that can be achieved without exceeding the knapsack capacity.
      >>> optimal_knapsack_solution(50, [(60, 10), (100, 20), (120, 30)])
      220
      >>> optimal_knapsack_solution(60, [(50, 30), (60, 20), (140, 50)])
      200
      """
output:     dp = [0] * (capacity + 1)
      for value, weight in items:
          for w in range(capacity, weight - 1, -1):
              dp[w] = max(dp[w], dp[w - weight] + value)
      return dp[capacity]