eolymp
bolt
Try our new interface for solving problems

Pairs

Array of unique integers and a target value $k$ are given. Determine the number of pairs of array elements that have a difference equal to a target value $k$. \InputFile First line contains integers $n~(2 \le n \le 10^5)$ and $k~(0 < k < 10^9)$. Second line contains $n$ unique integers in the range from $0$ to $2^{31} - 1$. \OutputFile Print the number of pairs of array integers with difference $k$. \Example In the sample there are two pairs of numbers with difference $3: (5, 2)$ and $(10, 7)$.
Time limit 1 second
Memory limit 128 MiB
Input example #1
6 3
7 3 5 1 10 2
Output example #1
2