SIGFPE Runtime Error

My code runs fine in the vs code and it gives the correct answer but when i submit it gives this error
this question is from august long challenge
Chef and Wedding Arrangements
i am solving it for 20 marks when k=1
heres my code

#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int t;
cin>>t;
for(long long int i=0;i<t;i++)
{
long long int n,k,x=0,y=1,z=0;
cin>>n>>k;
long long int a[n];
for(int j=0;j<n;j++)
{
cin>>a[j];
}
int b[n];
for(int j=0;j<n;j++)
{
b[z]=a[j];
for(int k=0;k<=z;k++)
{
if(b[z]==b[k])
{
x++;
if(x>1)
{
y++;
z=0;
j–;
}
}
}
x=0;
z++;
}
cout<<y<<"\n";
}
return 0;
}