Watchmen | 프로그래밍의 벗 PivotOJ
PivotOJ

Watchmen

시간 제한: 2000ms메모리 제한: 1024MB출처: MOOI 2015-16 finalBOJ 30814

문제

Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn them as soon as possible. There are nn watchmen on a plane, the ii-th watchman is located at point (xi,yi)(x_i, y_i).

They need to arrange a plan, but there are some difficulties on their way. As you know, Doctor Manhattan considers the distance between watchmen ii and jj to be xixj+yiyj|x_i - x_j| + |y_i - y_j|. Daniel, as an ordinary person, calculates the distance using the formula (xixj)2+(yiyj)2\sqrt{(x_i - x_j)^2 + (y_i - y_j)^2}.

The success of the operation relies on the number of pairs (i,j)(i, j) (1i<jn1 \leq i < j \leq n), such that the distance between watchman ii and watchmen jj calculated by Doctor Manhattan is equal to the distance between them calculated by Daniel. You were asked to compute the number of such pairs.

입력

The first line of the input contains the single integer nn (1n2000001 \leq n \leq 200\,000) --- the number of watchmen.

Each of the following nn lines contains two integers xix_i and yiy_i (xi,yi109|x_i|, |y_i| \leq 10^9).

출력

Print the number of pairs of watchmen such that the distance between them calculated by Doctor Manhattan is equal to the distance calculated by Daniel.

힌트

In the first sample, the distance between watchman 11 and watchman 22 is equal to 17+15=10|1 - 7| + |1 - 5| = 10 for Doctor Manhattan and (17)2+(15)2=213\sqrt{(1 - 7)^2 + (1 - 5)^2} = 2 \cdot \sqrt{13} for Daniel. For pairs (1,1)(1, 1), (1,5)(1, 5) and (7,5)(7, 5), (1,5)(1, 5) Doctor Manhattan and Daniel will calculate the same distances.

예제

예제 1

입력
3
1 1
7 5
1 5
출력
2

예제 2

입력
6
0 0
0 1
0 2
-1 1
0 1
1 1
출력
11
이 문제는 채점 준비 중입니다. 테스트 데이터가 확보되면 제출이 가능합니다.