input: def count_pairs(numbers, x):
      """ Count the number of pairs in the list 'numbers' whose sum equals 'x'.
      >>> count_pairs([1, 5, 7, -1], 6)
      2
      >>> count_pairs([1, 5, 7, -1, 5], 10)
      1
      """
      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
output:     
      count = 0
      seen = {}
      for num in numbers:
          if x - num in seen:
              count += seen[x - num]
          if num in seen:
              seen[num] += 1
          else:
              seen[num] = 1
      return count
  