James' Rectangles

View as PDF

Submit solution

Points: 10 (partial)
Time limit: 1.0s
Memory limit: 128M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

James loves rectangles, so he wants to exterminate everyone that dislikes rectangles. In order to convince James that you like rectangles, you are to answer the following question.

Given N points on a 2-D coordinate plane, count the number of rectangles that can be formed by using four points as vertices.

Input Specification

The first line of input contains integer N.

The following N lines of input each contain x_i, y_i, representing points on the coordinate plane.

It's guaranteed that the points are distinct.

Output Specification

Output one integer, the number of rectangles that can be formed with the points given.

NOTE: rectangles may not be axis-aligned.


1 \le N \le 1\,000

-10^6 \le x_i, y_i \le 10^6

Subtask 1 [20%]

1 \le N \le 50

-10^3 \le x_i, y_i \le 10^3

Subtask 2 [80%]

No further constraints.

Sample Input

1 1
1 2
2 1
2 2
2 3
3 2
3 3

Sample Output



There are no comments at the moment.