input: Write a function to count the number of pairs in a given array that sum up to a specified value x. The function should take two parameters: an array of integers 'numbers' and an integer 'x'. If the sum of any pair of elements in the array equals x, increment the count. 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([5, 5, 5, 5], 10) == 2
  assert count_pairs([1, 9, 2, 8, 3, 7, 4, 6, 5, 5], 10) == 5
  assert count_pairs([1, 2, 3, 4, 5], 10) == 0
  assert count_pairs([1, 3, 4, 5], 7) == 1
  assert count_pairs([], 5) == 0
output: def count_pairs(numbers, x):
      count = 0
      seen = set()
      for num in numbers:
          complement = x - num
          if complement in seen:
              count += 1
          seen.add(num)
      return count