Given is an array $A$ of size $N$ and an integer $K$. An pair $(i, j)$ is called good if only $i \lt j$ and $A_i + A_j = K$. Find the number of good pairs.
Input
The first line of the input contains two integers $N$ and $K$.
The second line of input contains $ N $ integers $A_1, A_2, \ldots, A_N$.
Output
Print one integer, the number of good pairs.
Constraints
In all cases, $0 \le A_i \le 10^9$
Subtask 1 (20%): $2 \le N \le 10^3, 0 \le K \le 10^3$
Subtask 2 (80%): $2 \le N \le 10^6, 0 \le K \le 10^6$
Sample Test Cases
Input | Output | |
---|---|---|
5 5 1 2 3 4 5 |
2 | |
2 10 5 5 |
1 |
Scoring: Per Subtask
Authored by s17r28