This code gives a Segmentation Fault at the exact 5th line of input. If n<5 or in the debugger everything is fine.
scanf("%d %d",&n,&x);
m=(int**)malloc(n*sizeof(int));
for(i=0;i<n;i++)
{
m[i]=(int*)malloc(2*sizeof(int));
}
for(i=0;i<n;i++)
{
scanf("%d %d",&m[i][0],&m[i][1]);
}`