#K8971. Count Pairs With Given Sum

    ID: 37591 Type: Default 1000ms 256MiB

Count Pairs With Given Sum

Count Pairs With Given Sum

Given a list of (n) integers and a target integer (x), your task is to count the number of pairs of integers from the list that add up to (x). Each element from the list can be used at most once in forming a pair.

For example, if the list is [1, 5, 7, -1, 5] and (x = 6), there are exactly two pairs: (1, 5) using the first 5 and (7, -1).

inputFormat

The input is read from standard input (stdin). The first line contains two space-separated integers (n) and (x), where (n) is the number of integers in the list and (x) is the target sum. The second line contains (n) space-separated integers representing the array.

outputFormat

Output a single integer to standard output (stdout) which is the number of pairs whose sum equals (x).## sample

5 6
1 5 7 -1 5
2