ARRAYTRM problem

hi guys im already check the test case and its good answer but i got WA i don’t know why please help me.

     #include<stdio.h>
#include<string.h>

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
              int a[1001],n,K;int c[1001];
              memset(a,0,sizeof(a));memset(c,0,sizeof(c));
              scanf("%d %d",&n,&K);
              for(int x=1;x<=n;x++)
              {
                      scanf("%d",&a[x]);        
              }
              for(int x=1;x<=n;x++)
              {
                      a[x]%=(K+1);        
              }                   
              
                for(int x=1;x<=n;x++)
              {
                      c[a[x]]++;        
              }   bool cek(1);
              for(int x=0;x<(K+1);x++)if(c[x]==n-1){cek=1;break;}
              else {cek=0;}
               for(int x=0;x<(K+1);x++)printf("%d\n",c[x]);
              if(cek || n<=2)printf("YES\n");
              else printf("NO\n");
    }  
}

sory i answer it my self at line

> for(int x=0;x<(K+1);x++)printf("%d\n",c[x]);

there should be commented and also
here at this line

for(int x=0;x<(K+1);x++)if(c[x]==n-1){cek=1;break;}

the if should (c[x]>=n-1) because its fail when the case is

3 2

0 3 6

it should be yes but its no because its 4 and 4 not the same as 3.

//