p02130 Combine Two Elements_36606
Problem

Given $ N $ a pair of non-negative integers $ (a_i, b_i) $ and non-negative integers $ A $, $ B $.
I want to do as many of the following operations as possible.


* $ | a_i --b_i | \ leq A $ or $ B \ leq | a_i --b_i | \ leq Take out and delete the element $ i $ that satisfies 2A $
* $ | (a_i + a_j)-(b_i + b_j) | \ leq A $ or $ B \ leq | (a_i + a_j)-(b_i + b_j) | Extract and delete the pair of j $ ($ i \ neq j $)

Find the maximum number of operations.

Constraints

The input satisfies the following conditions.

* $ 1 \ leq N \ leq 800 $
* $ 0 \ leq A, B \ leq 10 ^ 5 $
* $ 0 \ leq a_i, b_i \ leq 10 ^ 5 $
* $ A \ leq B $ and $ B \ leq 2A $

Input

The input is given in the following format.


$ N $ $ A $ $ B $
$ a_1 $ $ b_1 $
$ a_2 $ $ b_2 $
...
$ a_N $ $ b_N $


All inputs are given as integers.
$ N $, $ A $, $ B $ are given on the first line, separated by blanks.
The $ i $ th pair $ a_i $ and $ b_i $ ($ 1 \ leq i \ leq N $) are given in the second and subsequent $ N $ lines, separated by blanks.

Output

Output the maximum number of operations on one line.

Examples

Input

5 3 5
7 2
13 1
1 1
2 9
2 4


Output

4


Input

10 7 12
34 70
36 0
12 50
76 46
33 45
61 21
0 1
24 3
98 41
23 84


Output

5
N, A, B = map(int, input().split())
P = []
Q = []
ans = 0
for i in range(N):
    a, b = map(int, input().split())
    v = abs(a-b)
    if v <= A or B <= v <= 2*A:
        ans += 1
        continue
    if a > b:
        P.append(a-b)
    else:
        Q.append(a-b)

import collections
class Dinic:
    def __init__(self, n):
        self.n = n
        self.g = [[] for i in range(n)]
    def add_edge(self, fr, to, cap):
        self.g[fr].append([to, cap, len(self.g[to])])
        self.g[to].append([fr, 0, len(self.g[fr])-1])
    def add_multi_edge(self, v1, v2, cap1, cap2):
        self.g[v1].append([v2, cap1, len(self.g[v2])])
        self.g[v2].append([v1, cap2, len(self.g[v1])-1])
    def bfs(self, s):
        level = [-1]*self.n
        deq = collections.deque()
        level[s] = 0
        deq.append(s)
        while deq:
            v = deq.popleft()
            for e in self.g[v]:
                if e[1]>0 and level[e[0]]<0:
                    level[e[0]] = level[v] + 1
                    deq.append(e[0])
        self.level = level
    def dfs(self, v, t, f):
        if v==t: return f
        es = self.g[v]
        level = self.level
        for i in range(self.it[v], len(self.g[v])):
            e = es[i]
            if e[1]>0 and level[v]<level[e[0]]:
                d = self.dfs(e[0], t, min(f, e[1]))
                if d>0:
                    e[1] -= d
                    self.g[e[0]][e[2]][1] += d
                    self.it[v] = i
                    return d
        self.it[v] = len(self.g[v])
        return 0
    def max_flow(self, s, t):
        flow = 0
        while True:
            self.bfs(s)
            if self.level[t]<0: break
            self.it = [0]*self.n
            while True:
                f = self.dfs(s, t, 10**9+7)
                if f>0:
                    flow += f
                else:
                    break
        return flow

dinic = Dinic(2+len(P)+len(Q))
LP = len(P)
for i in range(len(P)):
    dinic.add_edge(0, 2+i, 1)
for j in range(len(Q)):
    dinic.add_edge(2+LP+j, 1, 1)
for i, p in enumerate(P):
    for j, q in enumerate(Q):
        v = abs(p+q)
        if v <= A or B <= v <= 2*A:
            dinic.add_edge(2+i, 2+LP+j, 1)
ans += dinic.max_flow(0, 1)
print(ans)

10 7 12
34 70
36 0
12 50
76 46
33 45
61 21
0 1
24 3
98 41
23 84 5 3 5
7 2
13 1
1 1
2 9
2 4 10 7 12
34 70
36 0
12 50
76 46
33 45
61 21
0 0
24 3
98 41
23 84 5 3 4
7 2
13 1
1 1
2 9
2 4 10 7 12
34 70
36 0
12 50
19 46
33 45
61 21
0 0
24 3
98 41
23 84 2 3 4
7 3
13 1
1 1
2 9
2 4 2 3 5
7 3
13 1
1 1
2 9
2 4 10 1 12
34 70
36 0
12 50
19 46
33 45
61 21
0 0
24 3
98 73
23 84 6 1 0
18 9
90 -3
2 11
1 0
2 1
23 31
-14 1
1 12
36 24
4 11 5 3 4
7 3
13 1
1 1
2 9
2 4 10 7 12
34 70
36 0
12 50
19 46
33 45
61 21
0 0
24 3
98 73
23 84 10 5 12
34 70
36 0
12 50
19 46
33 45
61 21
0 0
24 3
98 73
23 84 2 3 5
7 3
13 1
1 1
2 7
2 4 10 1 12
34 70
36 0
12 50
19 46
33 45
61 21
0 0
24 5
98 73
23 84 2 3 5
7 3
13 1
1 2
2 7
2 4 10 1 12
34 70
36 0
12 29
19 46
33 45
61 21
0 0
24 5
98 73
23 84 2 3 5
7 3
13 1
1 2
1 7
2 4 10 1 12
34 70
36 0
12 29
19 46
33 45
61 21
0 0
42 5
98 73
23 84 2 3 5
7 3
13 1
1 4
1 7
2 4 10 1 12
34 70
36 0
12 29
19 46
33 20
61 21
0 0
42 5
98 73
23 84 2 3 7
7 3
13 1
1 4
1 7
2 4 10 1 12
34 70
36 0
12 29
26 46
33 20
61 21
0 0
42 5
98 73
23 84 1 3 7
7 3
13 1
1 4
1 7
2 4 10 1 12
34 70
36 0
12 29
26 46
33 20
61 10
0 0
42 5
98 73
23 84 1 3 7
7 3
13 1
1 4
1 7
2 3 10 1 12
34 70
36 0
12 29
26 46
33 20
58 10
0 0
42 5
98 73
23 84 1 3 7
7 3
13 1
1 4
0 7
2 3 10 1 12
22 70
36 0
12 29
26 46
33 20
58 10
0 0
42 5
98 73
23 84 1 3 7
7 0
13 1
1 4
0 7
2 3 10 1 12
22 70
36 0
12 29
26 46
33 20
58 15
0 0
42 5
98 73
23 84 1 3 7
0 0
13 1
1 4
0 7
2 3 10 1 12
22 70
36 0
12 29
26 46
33 20
58 15
0 0
42 5
98 44
23 84 1 3 7
0 0
13 2
1 4
0 7
2 3 10 1 12
22 70
36 0
12 43
26 46
33 20
58 15
0 0
42 5
98 44
23 84 1 6 7
0 0
13 2
1 4
0 7
2 3 10 1 12
22 70
36 0
12 43
26 46
33 20
58 10
0 0
42 5
98 44
23 84 1 6 7
0 0
13 2
1 6
0 7
2 3 10 1 12
22 70
36 -1
12 43
26 46
33 20
58 10
0 0
42 5
98 44
23 84 2 6 7
0 0
13 2
1 6
0 7
2 3 10 1 12
22 70
36 -1
12 43
26 46
33 20
58 10
0 0
80 5
98 44
23 84 2 6 7
0 0
13 2
1 6
0 8
2 3 10 1 12
22 70
36 -1
12 43
26 46
33 20
58 10
0 0
80 5
98 32
23 84 2 6 7
1 0
13 2
1 6
0 8
2 3 10 1 12
15 70
36 -1
12 43
26 46
33 20
58 10
0 0
80 5
98 32
23 84 2 6 7
1 0
13 2
1 6
0 14
2 3 10 1 12
15 70
36 -1
18 43
26 46
33 20
58 10
0 0
80 5
98 32
23 84 2 6 0
1 0
13 2
1 6
0 14
2 3 10 1 12
15 70
36 -1
18 43
26 46
33 20
58 10
0 -1
80 5
98 32
23 84 2 6 0
1 0
13 2
1 8
0 14
2 3 10 1 12
15 70
36 -1
18 43
26 46
33 20
58 10
0 -1
80 5
98 32
23 30 2 6 0
1 0
16 2
1 8
0 14
2 3 10 1 12
15 70
58 -1
18 43
26 46
33 20
58 10
0 -1
80 5
98 32
23 30 2 6 0
0 0
16 2
1 8
0 14
2 3 10 1 12
15 70
58 -1
18 43
26 84
33 20
58 10
0 -1
80 5
98 32
23 30 2 6 0
0 0
16 2
1 8
0 13
2 3 10 1 12
15 70
58 -1
18 43
26 84
33 20
58 10
0 -1
80 5
98 35
23 30 2 6 0
0 0
16 2
2 8
0 13
2 3 10 1 12
15 70
58 -1
18 43
26 40
33 20
58 10
0 -1
80 5
98 35
23 30 2 6 0
0 0
16 2
2 8
1 13
2 3 10 1 12
15 70
58 -1
18 43
26 40
33 20
58 10
0 -1
80 5
98 35
23 10 2 6 0
0 0
16 2
4 8
1 13
2 3 10 1 12
15 70
58 -1
18 43
26 40
33 20
58 10
0 -1
80 5
29 35
23 10 2 6 0
0 0
16 2
4 12
1 13
2 3 10 1 3
15 70
58 -1
18 43
26 40
33 20
58 10
0 -1
80 5
29 35
23 10 2 7 0
0 0
16 2
4 12
1 13
2 3 10 1 3
14 70
58 -1
18 43
26 40
33 20
58 10
0 -1
80 5
29 35
23 10 2 7 0
0 0
16 0
4 12
1 13
2 3 10 1 3
14 70
58 -1
18 43
26 40
3 20
58 10
0 -1
80 5
29 35
23 10 2 4 0
0 0
16 0
4 12
1 13
2 3 10 1 3
14 70
58 -1
18 43
26 40
3 1
58 10
0 -1
80 5
29 35
23 10 2 4 0
0 0
16 0
0 12
1 13
2 3 6 1 3
14 70
58 -1
18 43
26 40
3 1
58 10
0 -1
80 5
29 35
23 10 2 4 0
0 0
16 0
0 12
0 13
2 3 6 1 3
14 70
58 -1
6 43
26 40
3 1
58 10
0 -1
80 5
29 35
23 10 2 4 0
0 0
16 0
-1 12
0 13
2 3 6 1 3
14 70
58 -1
6 26
26 40
3 1
58 10
0 -1
80 5
29 35
23 10 2 4 0
-1 0
16 0
-1 12
0 13
2 3 6 1 3
14 70
58 -1
6 26
26 40
3 1
58 10
0 -1
80 5
44 35
23 10 2 4 0
-1 0
16 0
-1 12
1 13
2 3 6 1 3
14 70
58 -1
6 26
26 40
3 1
58 20
0 -1
80 5
44 35
23 10 2 4 0
-1 0
16 0
-1 12
1 13
2 5 6 1 3
14 70
108 -1
6 26
26 40
3 1
58 20
0 -1
80 5
44 35
23 10 2 4 0
-1 0
7 0
-1 12
1 13
2 5 6 1 3
14 70
108 -1
6 26
26 40
3 1
58 20
0 -1
50 5
44 35
23 10 2 4 0
-1 0
7 0
0 12
1 13
2 5 6 1 3
14 70
108 -1
9 26
26 40
3 1
58 20
0 -1
50 5
44 35
23 10 2 4 0
-1 1
7 0
0 12
1 13
2 5 6 1 3
14 70
108 -1
9 26
26 40
3 1
58 30
0 -1
50 5
44 35
23 10 2 4 1
-1 1
7 0
0 12
1 13
2 5 6 1 3
14 70
108 -1
9 26
26 40
3 1
58 31
0 -1
50 5
44 35
23 10 2 4 1
-1 1
7 0
0 9
1 13
2 5 6 1 3
14 70
108 -1
9 26
26 40
3 1
58 31
0 -1
50 5
44 58
23 10 2 4 1
-1 1
7 0
0 9
0 13
2 5 6 1 3
14 70
108 -1
9 26
26 40
3 1
58 31
0 -1
50 5
47 58
23 10 2 4 0
-1 1
7 0
0 9
1 13
2 5 6 1 3
14 70
108 -1
9 26
26 40
3 1
58 31
0 -1
50 5
92 58
23 10 2 4 0
-1 1
7 0
0 9
1 5
2 5 6 1 3
14 70
108 -1
9 12
26 40
3 1
58 31
0 -1
50 5
92 58
23 10 2 4 0
-1 1
7 1
0 9
1 5
2 5 6 1 3
14 70
108 -1
9 12
26 40
3 1
58 31
-1 -1
50 5
92 58
23 10 2 4 0
-1 1
7 2
0 9
1 5
2 5 6 1 3
14 70
108 -1
9 12
26 40
3 1
58 31
-1 -1
22 5
92 58
23 10
5 4 5
 4
 6
 1
 0
 2
 3
 4
 5
 4
 0
 2
 0
 2
 0
 2
 0
 2
 0
 2
 0
 2
 0
 2
 0
 2
 0
 1
 1
 1
 1
 1
 1
 2
 1
 2
 2
 2
 2
 2
 2
 1
 2
 1
 2
 1
 2
 1
 1
 1
 1
 2
 1
 2
 1
 2
 1
 2
 1
 2
 1
 2
 2
 2
 1
 2
 1
 2
 1
 0
 1
 0
 1
 0
 1
 0
 1
 0
 1
 0
 2
 0
 2
 0
 2
 0
 2
 0
 2
 0
 2
 0
 2
 0
 2
 1
 2
 1
 2
 1
