Orthogonal Pairs
Tag(s):

## Basic Math, Easy-Medium, Math, Math Basic

Problem
Editorial
Analytics

You are given a 2D plane containing $N$ distinct integral points in the form of $(X,Y)$. Now a line segment is drawn between each pair of points. Your task is to determine the number of unordered pairs of these line segments that are orthogonal to each other.

Input format

• First line: $N$
• Next $N$ lines: Two space-separated integers $X$ and $Y$ denoting a point on the plane

Output format

Print a single integer that represents the number of quadruples as described in the problem statement

Constraints

$1 \le N \le 2*10^3$

$-2*10^3 \le X,Y \le 2*10^3$

• For 20 points: $1 \le N \le 100$
• For 80 points: Implement the original constraints
SAMPLE INPUT
5
1 1
2 2
0 0
1 -1
-1 1

SAMPLE OUTPUT
10

Explanation

Let the points be labelled $P_1, P_2, P_3, P_4, P_5$ respectively according to the order in the sample input. One of the possible quadruple is $P_2, P_3, P_4, P_5$ because the angle between the line segments $P_2, P_3$ and $P_4, P_5$ is $90^o$. There are $9$ more such quadruples. Hence the answer to this sample case is $10$.

Time Limit: 2.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

## CODE EDITOR

Initializing Code Editor...

## This Problem was Asked in

Challenge Name

HourStorm #7

OTHER PROBLEMS OF THIS CHALLENGE
• Algorithms > Graphs
• Math > Linear Algebra