#C3949. Count Pairs with Target Sum
Count Pairs with Target Sum
Count Pairs with Target Sum
Given an integer array A of length n and an integer target T, count the number of pairs of indices (i, j) such that i < j and A[i] + A[j] = T.
Mathematically, you are required to find the number of pairs satisfying:
$$A[i] + A[j] = T, \quad \text{for } 0 \leq i < j < n.$$An efficient solution is expected to pass all test cases.
inputFormat
The input is read from standard input (stdin). The first line contains two integers n and T, where n is 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 A.
outputFormat
Output a single integer to standard output (stdout) representing the number of pairs (i, j) with i < j such that A[i] + A[j] equals T.## sample
5 6
1 5 7 -1 5
3