input: def count_pairs(numbers: list, x: int) -> int:
      """
      Counts the number of pairs in the list of numbers that add up to a given sum x.
      The list is assumed to be sorted in non-decreasing order.
      >>> count_pairs([1, 2, 3, 4, 5, 6], 7)
      3
      >>> count_pairs([1, 2, 3, 4, 5, 6], 8)
      2
      """
output:     count = 0
      left, right = 0, len(numbers) - 1
      while left < right:
          if numbers[left] + numbers[right] == x:
              count += 1
              left += 1
              right -= 1
          elif numbers[left] + numbers[right] < x:
              left += 1
          else:
              right -= 1
      return count