Help me in solving ADVITIYA3 problem

My issue

runtime error

My code

#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int T;
	cin>>T;
	int mini=INT_MAX;
	while(T--){
	    int N,K;
	    cin>>N>>K;
	    vector<int> A;
	    for(int i=0;i<N;i++){
	        cin>>A[i];
	    }
	    
	    for(int i=0;i<N;i++){
	        int a=A[i]%K;
	        mini=min(mini,a);
	        
	        
	    }
	    
	}
	cout<<mini;

}

Problem Link: Cookie Day Practice Coding Problem - CodeChef

@sanya_711
heyy plzz refer my c++ code

#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--)
	{
	    int n,k;
	    cin>>n>>k;
	    int a[n];
	    int ans=INT_MAX;
	    for(int i=0;i<n;i++)
	    {
	        cin>>a[i];
	        if(a[i]>=k)
	        {
	            ans=min(ans,a[i]%k);
	        }
	    }
	    if(ans==INT_MAX)
	    cout<<-1;
	    else
	    cout<<ans;
	    cout<<endl;
	}

}