i don’t know what is causing this error as the constraints range is not too large . can anyone tell me what is causing that error?

```
#include<algorithm>
using namespace std;
int main()
{
int T;
//cout<<"enter number of test cases ";
cin>>T;
while(T--)
{
int N,M;
//cout<<"enter value of N";
cin>>N>>M;
int A[M],i,j;
for(i=0;i<M;++i)
{
cin>>A[i];
}
int c=0;
for(i=0;i<M;i+=N)
{
sort(A+i,A+(i+N));
for(j=i+1;j<N+i;++j)
{
if(A[j-1]==A[j])
{
c++;
}
}
}
if(c==0)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return 0;
}```
```