#K59632. Count Right-Angled Isosceles Triangles

    ID: 30908 Type: Default 1000ms 256MiB

Count Right-Angled Isosceles Triangles

Count Right-Angled Isosceles Triangles

You are given a set of points in the 2D coordinate plane. Your task is to count the number of distinct right-angled isosceles triangles whose right angle is located at the origin (0,0). A triangle satisfying these conditions is formed by the origin, a point on the x-axis (i.e. a point with y = 0) and a point on the y-axis (i.e. a point with x = 0). Note that the triangle is isosceles only if the lengths of the two legs (which lie along the coordinate axes) are equal. For the purpose of this problem, we count a triangle if and only if there exists a number a (which may be zero if provided in the input) such that both a point (a, 0) and a point (0, a) appear (possibly including a = 0 if explicitly provided in the input).

Input Format: The first line contains an integer n, denoting the number of points. Each of the following n lines contains two space-separated integers indicating the x and y coordinates of a point.

Note: Although a valid triangle is typically non-degenerate, this problem counts a triangle based on the provided definition using the points from the input.

inputFormat

The input is read from standard input (stdin). The first line contains an integer n (the number of points). Each of the next n lines contains two integers x and y representing the coordinates of a point.

outputFormat

Output a single integer — the number of distinct right-angled isosceles triangles with the right angle at the origin (0, 0) that can be formed.

## sample
5
2 0
0 2
2 2
3 0
0 3
2