Help me in solving PRGIFT problem

My issue

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];
for(int i=0;i<n;i++){
cin>>a[i];
}

  int count =0;
  for(int i=0;i<n;i++){
    if(a[i]%2==0){
      count+=1;
    }
  }
  if(count==k){
    cout<<"YES"<<endl;
  }
  else cout<<"NO"<<endl;
}

} what wrong in my code

My 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];
	  for(int i=0;i<n;i++){
	    cin>>a[i];
	  }
	  
	  int count =0;
	  for(int i=0;i<n;i++){
	    if(a[i]%2==0){
	      count+=1;
	    }
	  }
	  if(count==k){
	    cout<<"YES"<<endl;
	  }
	  else cout<<"NO"<<endl;
	}

}

Problem Link: Chef and Gift Practice Coding Problem

@pratik70
your logic is not complete.
plzz refer my c++ code for better understanding

#include <iostream>
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 k1=k;
	    for(int  i=0;i<n;i++)
	    {
	        cin>>a[i];
	        if(a[i]%2==0)
	        k--;
	    }
	    if(k1==0)
	    {
	        if(abs(k)!=n)
	        cout<<"YES";
	        else
	        cout<<"NO";
	    }
	    else
	    {
    	    if(k<=0)
    	    cout<<"YES";
    	    else
    	    cout<<"NO";
	    }
	    cout<<endl;
	}
	return 0;
}