E - ペアの選定 解説 /

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 466 点

問題文

ある部活動には、1 から N までの番号が付けられた N 人の部員が所属しています。部員 i (1 \le i \le N) の技術力は A_i、体力は B_i です。

高橋君は、今度開催される大会に向けて部員の中から 2 人のペアを 1 組選ぼうとしています。

大会で勝ち抜くためには、選んだ 2 人の技術力の合計が X 以上、かつ体力の合計が Y 以上である必要があります。

1 \le i < j \le N を満たす整数の組 (i, j) のうち、部員 i と部員 j を選んだときにこの条件を満たす(すなわち A_i + A_j \ge X かつ B_i + B_j \ge Y を満たす)ものの個数を求めてください。

制約

  • 2 \le N \le 10^5
  • 1 \le X, Y \le 2 \times 10^9
  • 1 \le A_i, B_i \le 10^9 (1 \le i \le N)
  • 入力はすべて整数

入力

入力は以下の形式で標準入力から与えられる。

N X Y
A_1 B_1
A_2 B_2
\vdots
A_N B_N

出力

条件を満たす組 (i, j) の個数を 1 行に出力してください。


入力例 1

4 10 10
3 8
7 4
8 2
5 6

出力例 1

3

入力例 2

3 100 100
10 20
20 30
30 10

出力例 2

0

入力例 3

10 50 50
20 35
30 25
15 40
40 10
25 30
35 35
10 50
50 20
22 38
18 22

出力例 3

17

入力例 4

20 100000 100000
45000 55000
62000 39000
21000 84000
78000 23000
35000 69000
51000 50000
89000 12000
14000 91000
68000 42000
41000 64000
66000 35000
31000 76000
54000 47000
83000 19000
27000 81000
49000 52000
72000 30000
18000 88000
60000 43000
33000 71000

出力例 4

15

入力例 5

2 2000000000 2000000000
1000000000 1000000000
1000000000 1000000000

出力例 5

1

Score : 466 pts

Problem Statement

A club has N members, numbered 1 to N. Member i (1 \le i \le N) has a technical skill of A_i and a physical strength of B_i.

Takahashi wants to select a pair of 2 members from the club for an upcoming tournament.

To win in the tournament, the sum of the technical skills of the chosen 2 members must be at least X, and the sum of their physical strengths must be at least Y.

Find the number of pairs of integers (i, j) satisfying 1 \le i < j \le N such that choosing member i and member j satisfies this condition (that is, A_i + A_j \ge X and B_i + B_j \ge Y).

Constraints

  • 2 \le N \le 10^5
  • 1 \le X, Y \le 2 \times 10^9
  • 1 \le A_i, B_i \le 10^9 (1 \le i \le N)
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

N X Y
A_1 B_1
A_2 B_2
\vdots
A_N B_N

Output

Print the number of pairs (i, j) satisfying the condition in a single line.


Sample Input 1

4 10 10
3 8
7 4
8 2
5 6

Sample Output 1

3

Sample Input 2

3 100 100
10 20
20 30
30 10

Sample Output 2

0

Sample Input 3

10 50 50
20 35
30 25
15 40
40 10
25 30
35 35
10 50
50 20
22 38
18 22

Sample Output 3

17

Sample Input 4

20 100000 100000
45000 55000
62000 39000
21000 84000
78000 23000
35000 69000
51000 50000
89000 12000
14000 91000
68000 42000
41000 64000
66000 35000
31000 76000
54000 47000
83000 19000
27000 81000
49000 52000
72000 30000
18000 88000
60000 43000
33000 71000

Sample Output 4

15

Sample Input 5

2 2000000000 2000000000
1000000000 1000000000
1000000000 1000000000

Sample Output 5

1