#K83282. Count Unique Pairs with Given Sum
Count Unique Pairs with Given Sum
Count Unique Pairs with Given Sum
You are given an array of integers and a target integer \(T\). Your task is to count the number of unique pairs of elements in the array that sum up to \(T\). A pair is considered unique if the pair of numbers does not appear in any other order. In other words, the pair \((a, b)\) is the same as \((b, a)\).
Input Format: The input is given via standard input (stdin) and consists of two lines. The first line contains two integers: \(n\) (the number of elements in the array) and \(T\) (the target sum). The second line contains \(n\) space-separated integers representing the array.
Output Format: Output a single integer representing the number of unique pairs that sum to \(T\).
Note: Each pair is counted only once no matter how many times the components may appear in the array.
inputFormat
The first line contains two integers \(n\) and \(T\) separated by a space.
The second line contains \(n\) space-separated integers representing the elements of the array.
outputFormat
Output a single integer - the number of unique pairs of elements whose sum is equal to \(T\). The output should be printed to stdout.
## sample5 9
2 7 11 15 -2
2