Free For All


Submit solution

Points: 1
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
C++, Java, Python

As it is the final round of competition for the 2025 AUCPL season, the ACPC committee has decided to host a free for all competition alongside the main event. In this competition, all participants will compete against each other, and the Exec committee wants to know how many people can attack each other.

To make this game more interesting and fair as there is a large prize, the committee has decided that each participant can only attack another participant if they lie on the same diagonal within a grid. The committee has asked you to help them determine the maximum number of participants that can attack each other.

Because the space is constrained in the IW basement, we have had to limit the size of the area people can stand on to a grid size of 10,000 x 10,000. The rows are numbered from top to bottom and the columns are numbered from left to right.

Input

The first line contains an integer n\ (1 \leq n \leq 1,000,000), the number of participants.

Each of next n lines contains two space separated integers x[i] and y[i] (1 \leq x[i], y[i] \leq 10,000) -- the number of row and the number of column where i-th participant is positioned. It's guaranteed that no two participants share the same position.

Output

Output a single integer, the maximum pairs of people that can attack each other. Solution is guaranteed to fit in a 32-bit signed integer.

Example

Input 1

4
1 1
2 2
3 3
4 5

Output 1

3

The first three participants can attack each other as they lie on the same diagonal. The fourth participant cannot attack or be attacked by any other participant.

The following image illustrates the positions of the participants, with the participants that can attack each other highlighted in red. Please not not all 10000 x 10000 grid is shown.

alt text

input 2

5
1 1
2 2
3 3
1 3
3 1

Output 2

6

The first three participants can attack each other as they lie on the same diagonal. The fourth participant can attack the second participant as they are on the same diagonal

The following image illustrates the positions of the participants, with the participants that can attack each other highlighted in red. Please not not all 10000 x 10000 grid is shown.

alt text


Comments

There are no comments at the moment.