input: Write a function to generate a Python program that counts the number of pairs with a given sum \( x \) in a list of numbers. The function should iterate through the list using two pointers, starting from the beginning and the end of the list. If the sum of the two numbers pointed by the pointers matches \( x \), it increments the count and moves the left pointer to the right. If the sum is less than \( x \), it moves the left pointer to the right. If the sum is greater than \( x \), it moves the right pointer to the left. The function should return the total count of such pairs.
  
  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, 6], 7) == 3
  assert count_pairs([1, 3, 3, 5], 6) == 2
  assert count_pairs([10, 20, 30], 10) == 0
  assert count_pairs([], 5) == 0
  assert count_pairs([2, 2, 2, 2], 4) == 2
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