loj#P3488. 「JOISC 2021 Day1」IOI 热病

「JOISC 2021 Day1」IOI 热病

Description

Original problem at JOISC 2021 Day1 T2 IOI Fever

JOI Kingdom is represented by a xy-plane. There are NN houses in JOI Kingdom numbered from 11 to NN. The coordinate of the house ii (1iN)(1 \leq i \leq N) is (Xi,Yi)(X_i, Y_i). Different houses have different coordinates. A citizen lives in each house. The citizen in the house ii is called the citizen ii. A long holiday season begins in JOI Kingdom. At time 00, every citizen leaves the house, and starts traveling.

In the beginning, every citizen chooses one of east, west, south, north, which is the direction for traveling.

The citizens will travel in the following way.

  • If the citizen ii chooses east, the citizen moves along the xx-axis toward the positive direction with speed 11. In other words, at time tt (t0)(t \geq 0), the coordinates of the citizen ii becomes (Xi+t,Yi)(X_i + t, Y_i).
  • If the citizen ii chooses west, the citizen moves along the xx-axis toward the negative direction with speed 11. In other words, at time tt (t0)(t \geq 0), the coordinates of the citizen ii becomes (Xit,Yi)(X_i − t, Y_i).
  • If the citizen ii chooses south, the citizen moves along the yy-axis toward the negative direction with speed 11. In other words, at time tt (t0)(t \geq 0), the coordinates of the citizen ii becomes (Xi,Yit)(X_i, Y_i − t).
  • If the citizen ii chooses north, the citizen moves along the yy-axis toward the positive direction with speed 11. In other words, at time tt (t0)(t \geq 0), the coordinates of the citizen ii becomes (Xi,Yi+t)(X_i, Y_i + t).

Unfortunately, at time 00, the citizen 11 is infected with IOI fever, which is a newly discovered infectious disease. At time 00, there are no infected people other than the citizen 11. The IOI fever is transmitted among citizens in the following way.

  • Assume that, at a certain time, the citizen aa (1aN)(1 \leq a \leq N) and the citizen bb (1bN)(1 \leq b \leq N) have the same coordinates, the citizen aa is infected with IOI fever, and the citizen b is not infected with IOI fever. Then, the citizen bb becomes infected with IOI fever.

The IOI fever is not transmitted by other methods. Moreover, since IOI fever is an incurable disease, infected citizen will not be recovered.

As a minister of JOI Kingdom, you need to estimate how many citizens will be infected with IOI fever if the citizens make the worst possible choice.

Write a program which, given the number of houses and the coordinate of each house, calculates the largest possible number of infected citizens at time 1010010^100.

Input Format

In the first line, there is a only integer NN.

In the following NN lines, there are two integers XiX_i and YiY_i in each line.

Output Format

Write one line to the standard output. Output the largest possible number of infected citizens at time 1010010^100.

2
0 0
4 3

1

3
1 2
2 1
4 3

3

15
5 6
2 9
12 0
4 11
3 12
6 5
0 8
9 10
11 13
8 7
13 2
1 1
7 14
10 4
14 3

9

2
20 20
20 21

2

30
275810186 246609547
122805872 99671769
243507947 220373844
281305347 252104708
237805644 214671541
172469077 149334974
222589229 229887956
160653451 208404690
241378966 211098219
144302355 224755786
186392385 163258282
199129390 169928751
294937491 265736852
196096122 172962019
314342944 285142305
202720470 166337671
157037485 133903382
263858979 240724876
210720220 181519581
296402036 267201397
186021287 183036854
195081930 173976211
328293029 299092390
261195361 238061258
323595085 294394446
299933764 270733125
240976723 128081418
188501753 165367650
277832422 248631783
119896220 96762117
11

Constraints

For all test data, it is guaranteed that 1N105,1 \le N \le {10}^5, 1Xi,Yi5×108,1 \le X_i, Y_i \le 5 \times {10}^8, (Xi,Yi)(Xj,Yj) (1i<jN)(X_i, Y_i) \ne (X_j, Y_j)~(1\le i < j\le N).

Subtask Score Additional Constraints
11 55 N7,N \le 7, XiXj,X_i \ne X_j, YiYjY_i \ne Y_j
22 88 N15,N \le 15, XiXj,X_i \ne X_j, YiYjY_i \ne Y_j
33 66 N100,N \le 100, XiXj,X_i \ne X_j, YiYj,Y_i \ne Y_j, X1=0,X_1 = 0, Y1=0Y_1 = 0
44 N100,N \le 100, XiXj,X_i \ne X_j, YiYjY_i \ne Y_j
55 1212 N3000N \le 3000
66 3232 XiXj,X_i \ne X_j, YiYjY_i \ne Y_j
77 3131 No additional constraints