why my code is having runtime error

my code in c is
#include<stdio.h>
int main()
{
int a[1000][2],i,j,leader=1,lead=0,tleader=1,tlead=0,n;
scanf("%d",&n);
for(i=0;i<n;i++)
{for(j=0;j<2;j++)
scanf("%d",&a[i][j]);
}
for(i=0;i<n;i++)
{j=0;
if((a[i][j])>(a[i][j+1]))
{tleader=1;tlead=(a[i][j])-(a[i][j+1]);}
else if((a[i][j+1])>(a[i][j]))
{tleader=2;tlead=(a[i][j+1])-(a[i][j]);}
if(tlead>lead)
{leader=tleader;lead=tlead;}}
printf("%d %d",leader,lead);
return 0;
}

I can’t read this code. But I have seen your code from submissions of that problem.

You are taking an array of size a[1000][2]. Look at the constraints N, it could be up to 10000. For any value N > 1000, your array goes out of bounds resulting in SIGSEGV.