#K42767. Unique Pairs Sum Count

    ID: 27161 Type: Default 1000ms 256MiB

Unique Pairs Sum Count

Unique Pairs Sum Count

Given an array of integers and a target sum (T), your task is to count the number of unique pairs ((a, b)) such that (a + b = T). Note that each pair is considered unordered (i.e., ((a, b)) is the same as ((b, a))).

For example, if the array is [1, 5, 7, -1, 5] and (T = 6), the unique pairs are ((1, 5)) and ((7, -1)), so the answer is 2.

inputFormat

The first line contains two integers (n) and (T), where (n) denotes the number of elements in the array and (T) is the target sum. The second line contains (n) space-separated integers representing the elements of the array.

outputFormat

Output a single integer — the number of unique pairs that add up to (T).## sample

5 6
1 5 7 -1 5
2