시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 212 83 69 43.949%

문제

좌표 평면에 점 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+XHJcblx0XHVjNzc0IFx1YjU0YywgXHViZTU3XHViY2MwXHVjNzQ0IFx1YzgxY1x1YzY3OFx1ZDU1YyBcdWIwOThcdWJhMzhcdWM5YzAgXHViNDUwIFx1YmNjMFx1Yzc3NCBcdWM4OGNcdWQ0NWNcdWNkOTVcdWM1ZDAgXHVkM2M5XHVkNTg5XHVkNTVjIFx1YzljMVx1YWMwMVx1YzBiY1x1YWMwMVx1ZDYxNVx1Yzc0NCBcdWM3NzRcdWI4ZThcdWIyOTQgXHVjODEwIDNcdWFjMWNcdWI5N2MgXHVhY2UwXHViOTc0XHViMjk0IFx1YmMyOVx1YmM5NVx1Yzc0NCBcdWMyMThcdWI5N2MgXHVhZDZjXHVkNTU4XHViMjk0IFx1ZDUwNFx1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