跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F2048. Sereja and Squares

    ID: 2054 传统题 2000ms 256MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>二分数据结构哈希算法思想挑战难度共享题库Codeforces英文题面题目来源题面语言

Sereja and Squares

题目描述

D. Sereja and Squares
time limit per test
2 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output

Sereja has painted n distinct points on the plane. The coordinates of each point are integers. Now he is wondering: how many squares are there with sides parallel to the coordinate axes and with points painted in all its four vertexes? Help him, calculate this number.

Input

The first line contains integer n (1≤n≤105). Each of the next n lines contains two integers xi,yi (0≤xi,yi≤105), the integers represent the coordinates of the i-th point. It is guaranteed that all the given points are distinct.

Output

In a single line print the required number of squares.

Examples
Input
5
0 0
0 2
2 0
2 2
1 1
Output
1
Input
9
0 0
1 1
2 2
0 1
1 0
0 2
2 0
1 2
2 1
Output
5

题目来源:fps-www.educg.net-codeforce-1-2833.xml.zip;FPS 共享题包,题包内第 1639 题。保留原作者与原赛事署名。