시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 234 92 77 43.503%

문제

좌표 평면에 점 N개가 있다.

이때, 빗변을 제외한 나머지 두 변이 좌표축에 평행한 직각삼각형을 이루는 점 3개를 고르는 방법을 수를 구하는 프로그램을 작성하시오.

직각삼각형은 한각이 직각인 삼각형이며, 직각의 대변을 빗변이라고 한다.

입력

첫째 줄에 점의 개수 N(3 ≤ N ≤ 100,000)이 주어진다. 둘째 줄부터 N개의 줄에는 점의 좌표가 X Y 순서대로 주어진다. (1 ≤ X,Y ≤ 100,000) 겹치는 점은 없다.

출력

첫째 줄에 직각삼각형의 개수를 출력한다.

예제 입력 1

5
1 2
2 1
2 2
2 3
3 2

예제 출력 1

4
W3sicHJvYmxlbV9pZCI6IjMwMDAiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWM5YzFcdWFjMDEgXHVjMGJjXHVhYzAxXHVkNjE1IiwiZGVzY3JpcHRpb24iOiI8cD5cclxuXHRcdWM4OGNcdWQ0NWMgXHVkM2M5XHViYTc0XHVjNWQwIFx1YzgxMCBOXHVhYzFjXHVhYzAwIFx1Yzc4OFx1YjJlNC48XC9wPlxyXG5cclxuPHA+XHJcblx0XHVjNzc0XHViNTRjLCBcdWJlNTdcdWJjYzBcdWM3NDQgXHVjODFjXHVjNjc4XHVkNTVjIFx1YjA5OFx1YmEzOFx1YzljMCBcdWI0NTAgXHViY2MwXHVjNzc0IFx1Yzg4Y1x1ZDQ1Y1x1Y2Q5NVx1YzVkMCBcdWQzYzlcdWQ1ODlcdWQ1NWMgXHVjOWMxXHVhYzAxXHVjMGJjXHVhYzAxXHVkNjE1XHVjNzQ0IFx1Yzc3NFx1YjhlOFx1YjI5NCBcdWM4MTAgM1x1YWMxY1x1Yjk3YyBcdWFjZTBcdWI5NzRcdWIyOTQgXHViYzI5XHViYzk1XHVjNzQ0IFx1YzIxOFx1Yjk3YyBcdWFkNmNcdWQ1NThcdWIyOTQgXHVkNTA0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