#t545. 统计差值数对

统计差值数对

Counting Pairs with a Given Difference

Problem Description

Given a sequence of positive integers and a positive integer CC, count the number of pairs satisfying A−B=CA - B = C. Pairs whose values are the same but whose positions differ count as different pairs.

Input Format

The input has two lines.

The first line: two positive integers N,CN, C.

The second line: NN positive integers a1,a2,…,aNa_1, a_2, \ldots, a_N separated by spaces, the sequence to process.

Output Format

One line with an integer: the number of pairs satisfying A−B=CA - B = C.

Sample Input

4 1
1 1 2 3

Sample Output

3

Sample Explanation

For the sample input, N=4N=4, C=1C=1, and the sequence is 1,1,2,31,1,2,3. When A=2A=2, the two B=1B=1 values correspond to two pairs respectively; when A=3A=3, B=2B=2 corresponds to one pair. So there are 33 pairs in total, and the output is 33.

Constraints

For 75%75\% of the data, 1≤N≤20001 \le N \le 2000.

For 100%100\% of the data, 1≤N≤2×1051 \le N \le 2 \times 10^5, 0≤ai<2300 \le a_i < 2^{30}, 1≤C<2301 \le C < 2^{30}.