LogiQuest

66. Count Pairs with Sum

MediumHash MapCounting

Count pairs of positions (i < j) with a[i] + a[j] = k.

Input format

Line 1: n k Line 2: n integers

Output format

The number of pairs.

Example 1

Input

4 6
1 5 7 1

Output

2

Example 2

Input

4 2
1 1 1 1

Output

6

Constraints

1 ≤ n ≤ 10⁵

Read input from standard input and print the answer to standard output. Your code is judged against 6 test cases, most of them hidden.

Loading the MyLoginn IDE…