9493: ABC218 —— D - Rectangles
[Creator : ]
Description
We have $N$ distinct points on a two-dimensional plane, numbered $1,2,\ldots,N$. Point $i$ $(1 \leq i \leq N)$ has the coordinates $(x_i,y_i)$.
How many rectangles are there whose vertices are among the given points and whose edges are parallel to the $x$- or $y$-axis?
How many rectangles are there whose vertices are among the given points and whose edges are parallel to the $x$- or $y$-axis?
Input
Input is given from Standard Input in the following format:
```
$N$
$x_1$ $y_1$
$x_2$ $y_2$
$ \vdots $
$x_N$ $y_N$
```
```
$N$
$x_1$ $y_1$
$x_2$ $y_2$
$ \vdots $
$x_N$ $y_N$
```
Output
Print the answer.
Constraints
- $4 \leq N \leq 2000$
- $0 \leq x_i, y_i \leq 10^9$
- $(x_i,y_i) \neq (x_j,y_j)$ $(i \neq j)$
- All values in input are integers.
- $0 \leq x_i, y_i \leq 10^9$
- $(x_i,y_i) \neq (x_j,y_j)$ $(i \neq j)$
- All values in input are integers.
Sample 1 Input
6
0 0
0 1
1 0
1 1
2 0
2 1
Sample 1 Output
3
There are three such rectangles:
the rectangle whose vertices are Points 1, 2, 3, 4,
the rectangle whose vertices are Points 1, 2, 5, 6,
and the rectangle whose vertices are Points 3, 4, 5, 6.
the rectangle whose vertices are Points 1, 2, 3, 4,
the rectangle whose vertices are Points 1, 2, 5, 6,
and the rectangle whose vertices are Points 3, 4, 5, 6.
Sample 2 Input
4
0 1
1 2
2 3
3 4
Sample 2 Output
0
Sample 3 Input
7
0 1
1 0
2 0
2 1
2 2
3 0
3 2
Sample 3 Output
1