Rectangle Counting

Author: QuwsarOhi

Problem Setter: Md Farid Miah

Intake 32, Department of CSE

In the initial version or v1.0.0, you are given an N*M grid. Then count the number of rectangles in this grid by using the simple equation In the next version v1.1.0, you are given N points then calculate how many rectangles are formed by these points. It is guaranteed that all rectangles are parallel to the axis.

Example: (0,0), (0,1), (1,1), (1,0), (2,0) and (2,1) number of rectangles are 3. Left rectangle (0,0), (0,1), (1,1), (1,0) right rectangle (1,0), (1,1), (2,1), (2,0) and big rectangle (0,0), (0,1), (2,1), (2,0).

Input Format

The first line contains one integer N (1 <= N <= 1000) -  the number of points. Then next N lines contain X and Y (-109X, Y10- coordinates of the X and Y-axis.

Output Format

Calculate the number of rectangles is forme d/shaped by these N points.

Samples

Input
6 0 0 0 1 1 1 1 0 2 0 2 1
Output
3
Input
4 0 0 0 1 1 0 1 2
Output
0
Limits
Language Time Memory
GNU C 11 1s 512MB
GNU C++ 14 1s 512MB
GNU C++ 11 1s 512MB
PHP 7 1s 1024MB
Java (OpenJDK 8) 1s 4096MB
Statistics
Login To Submit