시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 1024 MB68353350.769%

문제

You are given $n$ distinct points on the two dimensional plane.

We define the distance between two points $P=(x_1, y_1)$ and $Q=(x_2, y_2)$ as $d(P, Q)=|x_1-x_2|+|y_1-y_2|$.

Let's say that three distinct points $U, V, W$ form a good triangle if there exists a point $T$ such that $d(U, T)=d(V, T)=d(W, T)$. Note that $T$ does not have to be a lattice point.

Find the number of good triangles that can be formed by the given points.

입력

The first line of input contains $N$.

The $i$-th line of the next $N$ lines contains two space-separated integers $x_i, y_i$, meaning that the coordinate of the $i$-th point is $(x_i, y_i)$.

출력

Print one integer, the number of good triangles that can be formed by the given points.

제한

  • $3 \leq N \leq 500\,000$
  • $-10^9 \leq x_i, y_i \leq 10^9$ ($1 \leq i \leq N$)
  • $(x_i, y_i) \neq (x_j, y_j)$ if $i\ne j$ ($1 \leq i, j \leq N$)
  • All values in the input are integers.

예제 입력 1

5
1 -1
1 5
5 7
1 3
4 2

예제 출력 1

9

예제 입력 2

10
-2 -1
-2 2
-1 -2
-1 -1
-1 1
0 1
1 -1
1 2
2 -1
2 1

예제 출력 2

108