nt** rangeAddQueries(int n, int** queries, int queriesSize, int* queriesColSize, int* returnSize, int** returnColumnSizes) {
int diff=malloc(sizeof(int)n),i,a=malloc(sizeof(int)n),j;
returnSize=n;
returnColumnSizes=malloc(sizeof(int)n);
for(i=0;i<n;i++)
{
a[i]=malloc(sizeof(int)n);
diff[i]=malloc(sizeof(int)n);
memset(a[i],0,sizeof(int)n);
memset(diff[i],0,sizeof(int)n);
(returnColumnSizes)[i]=n;
}
for(i=0;i<queriesSize;i++)
{
diff[queries[i][0]][queries[i][1]]++;
if(queries[i][2]!=n-1)
diff[queries[i][2]+1][queries[i][1]]--;
if(queries[i][3]!=n-1)
diff[queries[i][0]][queries[i][3]+1]--;
if(queries[i][2]!=n-1&&queries[i][3]!=n-1)
diff[queries[i][2]+1][queries[i][3]+1]++;
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(i0&&j0)
diff[i][j];
else if(i0)
diff[i][j]+=diff[i][j-1];
else if(j0)
diff[i][j]+=diff[i-1][j];
else
diff[i][j]+=diff[i-1][j]+diff[i][j-1]-diff[i-1][j-1];
a[i][j]=diff[i][j];
}
}
return a;
}