int main(void) {
// your code goes here
int t,k;
scanf("%d",&t);
for(k=0;k<t;k++)
{
long long int i,j,n,a[20000],b[20000],p=0;
scanf("%ld",&n);
for(i=0;i<n;i++)
scanf("%ld",&a[i]);
for(i=0;i<n;i++)
scanf("%ld",&b[i]);
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if((a[i]^a[j])==(b[i]^b[j]))
p++;
}
}
printf("%ld\n",p);
}
return 0;
}
is surely going to get TLE verdict when N is large. If you are using C++, you can use the STL map container to compute the answer. Otherwise, you should implement your own map data structure in C.
Check the following solution for AVL tree based solution in C.