#K85602. Distinct Pair Sums
Distinct Pair Sums
Distinct Pair Sums
Given an array of integers and a target integer \( k \), your task is to determine the number of unique pairs in the array whose sum is exactly \( k \). A pair \((a, b)\) is considered the same as \((b, a)\) and should only be counted once even if there are multiple occurrences in the array.
Note: The pair must consist of two distinct elements from the array. If no valid pairs exist, the answer should be 0.
inputFormat
The input begins with an integer \( T \) denoting the number of test cases. Each test case is described as follows:
- The first line contains two space-separated integers \( n \) and \( k \), where \( n \) is the number of elements in the array and \( k \) is the target sum.
- The second line contains \( n \) space-separated integers representing the elements of the array.
All input is read from standard input (stdin).
outputFormat
For each test case, print a single line with one integer representing the count of unique pairs in the array that add up to \( k \). All output should be written to standard output (stdout).
## sample1
5 10
4 3 5 7 8
1
</p>