Getting runtime error not able to understand?

#include<stdio.h>
#define max 100002
long int start[max],end[max],k[max],n,tmp[max],temp1[max],temp2[max],temp3[max];
long int mergesort(long int arr1[],long int arr2[],long int arr3[],long int low,long int high);
long int merge2(long int arr1[],long int arr2[],long int arr3[],long int low,long int mid,long int high);
int main()
{
int t;
scanf("%d",&t);
while(t–)
{
long int i,k1;
scanf("%ld%ld",&n,&k1);
for(i=0;i<n;i++)
scanf("%ld%ld%ld",&start[i],&end[i],&k[i]);
mergesort(k,start,end,0,n-1); //short on the basis of compartment
long int w=0,q,count=1;
q=k[0];
for(i=1;i<n;i++) // count frequency on the basis of compartment
{
if(k[i]==q)
count++;
else
{
tmp[w]=count;
w++;
count=1;
q=k[i];
}
}
tmp[w]=count;
for(i=1;i<=w;i++)
tmp[i]+=tmp[i-1];
mergesort(end,start,k,0,tmp[0]-1);
for(i=1;i<=w;i++) // short the compartment according to ending time
{
mergesort(end,start,k,tmp[i-1],tmp[i]-1);
}
count=1;
for(i=1;i<n;i++)
{
if(k[i]==k[i-1])
{
if(start[i]>=end[i-1])
count++;
else
end[i]=end[i-1];
}
else
count++;
}
if(n==0)
printf(“0\n”);
else
printf("%ld\n",count);
}
return 0;
}

long int mergesort(long int arr1[],long int arr2[],long int arr3[],long int low,long int high)
{
long int mid;
if(low<high)
{
mid=(low+high)/2;
 
mergesort(arr1,arr2,arr3,low,mid);
mergesort(arr1,arr2,arr3,mid+1,high);
 
merge2(arr1,arr2,arr3,low,mid,high);
}
return 0;
 
}
 
long int merge2(long int arr1[],long int arr2[],long int arr3[],long int low,long int mid,long int high)
{
long int ac=low, bc=mid+1, cc=0,i;
while(ac<=mid && bc<=high)
{
if(arr1[ac]<=arr1[bc])
{
temp1[cc]=arr1[ac];
temp2[cc]=arr2[ac];
temp3[cc]=arr3[ac];
cc++,ac++;
}
else
{
temp1[cc]=arr1[bc];
temp2[cc]=arr2[bc];
temp3[cc]=arr3[bc];
cc++,bc++;
}
}
 
while(ac<=mid)
{
temp1[cc]=arr1[ac];
temp2[cc]=arr2[ac];
temp3[cc]=arr3[ac];
cc++,ac++;
}
while(bc<=high)
{
temp1[cc]=arr1[bc];
temp2[cc]=arr2[bc];
temp3[cc]=arr3[bc];
cc++,bc++;
}
cc--;
while(cc>=0)
{
arr1[low+cc]=temp1[cc];
arr2[low+cc]=temp2[cc];
arr3[low+cc]=temp3[cc];
cc--;
}
return 0;
}

HI cbgiri_001, we’d suggest you to post your query on the editorial page of the problem. It will help you get over the query sooner.