Skip to main content
LIVE CONTEST: ALGOR Contest: Round #4 (Special Challenge) is live now!

~/algor $ cat problems/massiv-yigindisi-x-juftliklar

Pairs with sum x

Medium 1000 ms 64 MB 45%
Share

An array of $n$ integers and an integer $x$ are given. How many pairs $(i, j)$ are there with $i \lt j$ and $a_{i} + a_{j} = x$?

The array in cells; pairs with sum x are joined by arcs

Input

The first line contains two integers: $n$ and $x$.
The second line contains $n$ integers — the elements of the array.

Output

One integer — the number of pairs.

Note

$1 \le n \le 2000$
$-2000 \le x \le 2000$
the elements are from $-1000$ to $1000$

Examples

Input #1
6 7
3 4 2 5 4 3
Output #1
5
Input #2
4 2
1 1 1 1
Output #2
6

Sign in to submit a solution

Signing up is free and takes a minute.