input: Write a function to count the number of pairs with a given sum x in a list of numbers. The function should iterate through the list using two pointers, one starting from the beginning and the other from the end, checking the sum of the elements at each pointer's position. If the sum is equal to x, increment the count and move the first pointer forward. If the sum is less than x, move the first pointer forward. If the sum is more than x, move the second pointer backward.
  def count_pairs(numbers, x):
      count = 0
      i, j = 0, len(numbers) - 1
      while i < j: 
          sum = numbers[i] + numbers[j]
          if sum == x: 
              count += 1
              i += 1
          elif sum < x: 
              i += 1 
          else: 
              j -= 1
      return count
  
  assert count_pairs([1, 2, 3, 4, 5], 7) == 2
  assert count_pairs([5, 5, 5, 5], 10) == 2
  assert count_pairs([1, 2, 3, 4, 5], 8) == 1
  assert count_pairs([1, 2, 3, 4, 5], 2) == 0
  assert count_pairs([], 5) == 0
output: def count_pairs(numbers, x):
      count = 0
      i, j = 0, len(numbers) - 1
      while i < j: 
          sum = numbers[i] + numbers[j]
          if sum == x: 
              count += 1
              i += 1
          elif sum < x: 
              i += 1 
          else: 
              j -= 1
      return count