cswork / OAOpen practice workspace

The D. E. Shaw GroupOA #5

Find Number of Interesting Pairs

Estimated MediumJudge-ready

Topics (AI-labelled)HashingBits & Math

Given an integer array and sumVal, an unordered pair (i,j) of distinct indices is called an interesting pair when |arr[i]-arr[j]|+|arr[i]+arr[j]| equals sumVal. Count such pairs.

The standard input/output, the ranges added by this site, and the examples follow this problem's description.

Input

The first line contains n and sumVal, and the second line contains n integers. 1≤n≤100000, −10^9≤arr[i]≤10^9, −2×10^9≤sumVal≤2×10^9; the result uses a 64-bit integer.

Output

Output the number of unordered index pairs that satisfy the condition.

Example 1

Input:

4 4
1 4 -1 2

Output:

2

Example 2

Input:

3 0
0 0 3

Output:

1

Example 3

Input:

3 4
2 -2 4

Output:

1

Editorial

Loading solution…