P22419 [CodeChef] RECTCNT
提高-
题目描述

Given N separate integer points on the Cartesian plane satisfying: there is no any three of them sharing a same X-coordinate. Your task is to count the number of rectangles (whose edges parrallel to the axes) created from any four of given points.

------ Input ------

There are several test cases (ten at most), each formed as follows:
The first line contains a positive integer N (N ≤ 10^{5}).
N lines follow, each containing a pair of integers (each having an absolute value of 10^{9} at most) describing coordinates of a given point.

The input is ended with N = 0.

------ Output ------

For each test case, output on a line an integer which is the respective number of rectangles found.

----- Sample Input 1 ------
6
7 1
3 5
3 1
1 5
1 1
7 5
0
----- Sample Output 1 ------
3

输入格式

见题面

输出格式

见题面

样例输入
6 7 1 3 5 3 1 1 5 1 1 7 5 0
样例输出
3