1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<string> 5 #include<algorithm> 6 #define MAXN 1111 7 using namespace std; 8 class Point{ 9 public: 10 int x,y; 11 bool operator < (const Point &p) const{ 12 if(x == p.x) return y < p.y; 13 return x < p.x; 14 } 15 bool operator == (const Point &p) const{ 16 return x == p.x && y == p.y; 17 } 18 }; 19 Point P[MAXN]; 20 bool Binary_Search(const Point target,int len){ 21 int l = 0,r = len,mid; 22 while(l <= r){ 23 mid = (l+r) >> 1; 24 if(target == P[mid]) return true; 25 else if(target < P[mid]) r = mid-1; 26 else l = mid+1; 27 } 28 return false; 29 } 30 int main(){ 31 int n,ans; 32 freopen("in.c","r",stdin); 33 while(~scanf("%d",&n) && n){ 34 for(int i = 0;i < n;i ++) scanf("%d%d",&P[i].x,&P[i].y); 35 sort(P,P+n); 36 ans = 0; 37 for(int i = 0;i < n;i ++){ 38 for(int j = i+1;j < n;j ++){ 39 Point tmp1,tmp2; 40 tmp1.x = P[i].x+P[i].y-P[j].y,tmp1.y = P[i].y-P[i].x+P[j].x; 41 tmp2.x = P[j].x+P[i].y-P[j].y,tmp2.y = P[j].y-P[i].x+P[j].x; 42 if(Binary_Search(tmp1,n) && Binary_Search(tmp2,n)) ans++; 43 } 44 } 45 printf("%d ",ans >> 1); 46 } 47 return 0; 48 }