IntermediateRating 1200
Count Pairs With Sum
Count the pairs i < j with aᵢ + aⱼ = k. n can be up to 10⁵, so check every pair is too slow.
Input
n and k, then n integers.
Output
One integer.
Sample 1
Input
4 6 1 5 7 1
Output
2
Sample 2
Input
4 2 1 1 1 1
Output
6
Output appears here