题目描述
Problem Description
Given $n$ points on a plane, calculate how many distinct right-angled triangles can be formed such that their vertices are among the given points and the legs of the right angle are parallel to the coordinate axes.
Two right-angled triangles are considered different if and only if they have at least one different vertex.
Input Format
The first line of input contains an integer $n$, representing the number of points.
The next $n$ lines each contain two integers, representing the coordinates of a point.
Output Format
Output the number of right-angled triangles.
Sample Input and Output
Sample Input #1
3
4 2
2 1
1 3
Sample Output #1
0
Sample Input #2
5
1 2
2 1
2 2
2 3
3 2
Sample Output #2
4
Sample Input #3
6
10 10
20 10
10 20
20 20
30 20
30 30
Sample Output #3
8
Notes
Data Size and Constraints
- For $40\%$ of the data, $n < 100$;
- For $70\%$ of the data, $n < 10^4$;
- For $100\%$ of the data, $3 \le n \le 10^5$, and the coordinates are between $1$ and $10^5$, with no two points having the same coordinates.
Notes
This problem is translated from COCI2007-2008 CONTEST #3 T4 DEJAVU.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分
样例输入
3
4 2
2 1
1 3
样例输出
0