RIGHTTRI - Right Triangle Counting

N points are placed in the coordinate plane. Write a program which calculates in how many ways a right triangle can be formed by three of the given points. A right triangle is one in which one of the angles is 90 degrees.

Input

The first line of input contains an integer N (3 <= N <= 1500), the number of points. Each of the following N lines contains the coordinates of one point, two integers separated by a space. The coordinates will be between -10^9 and 10^9. No two points will be located at the same coordinates.

Output

Output the number of right triangles.

Sample

input
5
-1 1
-1 0
0 0
1 0
1 1

output
7
input
4
5 0
2 6
8 6
5 7

output
0

Added by:psetter
Date:2009-02-28
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:COI 07 Open

hide comments
2017-06-09 13:53:37
very nice problem, required concepts of coordinate Geometry.
2017-02-13 18:34:34
@roukaya_zaki @anonymous
check these three points
( 0 , 0 ) & ( 0 , 1 ) & ( -1 , 0 )
2017-02-06 14:45:17
can anyone explain test case 1 ... I think it must be 6 not 7
2013-06-20 12:30:15 anonymous
how is answer for 1st test case is 7? can anyone explain?
2009-07-19 20:54:40 majid
I'm pretty shure that my algorithm must be accepted. But time limit for java is very strict :( . plz check my answer and increase time limit ...
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.