这也许是最简单的hash
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <cstdio>
const int MOD = 1e7+9 ;
using namespace std;
const int maxn = 16000011 ;
int hash[maxn],cnt[maxn];
int maze[4010][5];
void ori(){
memset(hash,0,sizeof(hash));
memset(cnt,0,sizeof(cnt));
}
void Insert(int x){
int key=(x%MOD+MOD)%MOD;
while((hash[key]!=x)&&(cnt[key]>0))key=(key+1)%MOD;
hash[key]=x;
cnt[key]++;
}
int Get(int x){
int key=(x%MOD+MOD)%MOD;
while((hash[key]!=x)&&(cnt[key]>0))key=(key+1)%MOD;
return cnt[key];
}
int main(){
int n;
int re;
ori();
scanf("%d",&n);
for(int i=1;i<=n;i++)
for(int j=1;j<=4;j++)scanf("%d",&maze[i][j]);
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
re = maze[i][1]+maze[j][2];
Insert(re);
}
}
int ans=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
int re = -1*(maze[i][3]+maze[j][4]);
ans+=Get(re);
}
}
printf("%d\n",ans);
}