why there is a RE(SIGSEGV) error in the code???

#include<stdio.h>
int a[105],b[105];
int main()
{

int i,j,n,q,m,cases,L,R,p,k=1,h;
int hcf(int,int);

scanf("%d",&cases);
while(cases--)
{

   scanf("%d %d",&n,&q);
   for(j=1;j<=n;j++)
        scanf("%d ",&a[j]);

        while(q--)
        {
            scanf("%d %d",&L,&R);
            p=1;

            while(p<=n)
            {
              if(p==L)
              {
                  p=p+R-L+1;
                  if(p<=n)
                  {
                  b[k]=a[p];
                  k++;
                  p++;
                  }
              }

              else
              {
                  b[k]=a[p];
                  k++;
                  p++;

              }
            }

            k--;


            for(m=1;m<k;m++)
            {

                 h=hcf(b[m],b[m+1]);
                 b[m+1]=h;

            }

             printf("%d\n",h);

        }


        }

        return 0;
 }

     int hcf(int a,int b)
     {
          if(a==0)
          {
              return b;
          }

          if(b==0)
          {
              return a;
          }

          if(a%b==0)
           {
                  return b;
           }
          else
          {
                  return(hcf(b,a%b));
          }
     }

it’s running contest man.
follow code of conduct.
@admin block/delete this asap.

You’re violating the rules of the contest by posting source code.

1 Like

Do not post code regarding any of the problems in a live contest during the contest.

Some one with enough karma or admin please close this question.