Oh, yes, I figured that out. I need to take the count of number of times a particular value of 'a[i]+b[j]' occurs. Thanks for the reply !!
aah, now tle, strict time limit. Okay, need to optimize !!
err TLE for O(n^n) ... are maps so slow ??
#include<iostream>
#include<map>
using namespace std;
map<int, int> m1, m2;
map<int, int>::iterator it;
int a[4001], b[4001], c[4001], d[4001];
int main()
{
int n, i, j, count;
scanf("%d", &n);
for(i=0; i<n; i++)
scanf("%d %d %d %d", &a[i], &b[i], &c[i], &d[i]);
m1.clear();
m2.clear();
for(i=0; i<n; i++)
for(j=0; j<n; j++)
{
m1[a[i]+b[j]]++;
m2[c[i]+d[j]]++;
}
count=0;
for(it=m2.begin();it!=m2.end();it++)
count+=(*it).second*m1[-(*it).first];
printf("%d\n", count);
return 0;
}