[BOJ 11830] Star triangles

View as PDF

Submit solution

Points: 3
Time limit: 2.0s
Memory limit: 256M

Problem types
Allowed languages
Assembly, Awk, C, C++, Java, Pascal, Perl, Python, Sed, Text

Zhomart likes watching the stars and construct a variety of geometric shapes from them. The sky is represented in the form of the Cartesian coordinate system, and the stars are represented by points on it. At this moment Zhomart interested in the question: how many different right triangles whose legs are parallel to the axes, you can create with the help of stars in the sky.

입력 형식

In the first line of the input line you are given N –– the number of stars on the sky (3 ≤ N ≤ 300000). Each of the next N lines contains integer X and Y (|X, Y| ≤ 109) –– coordinates of the appropriate star.

출력 형식

Print one number – the answer to the question.

예제 입력 1

3
0 0
1 0
0 1

예제 출력 1

1

예제 입력 2

4
0 0
1 0
0 1
1 1

예제 출력 2

4

Comments

There are no comments at the moment.