PRGIFT - Editorial

is_even = lambda x: x%2==0

def gift_segment(a, k, counter=0):
    for i in a:
        if is_even(i):
            counter+=1
        else:
            counter=0
        if counter == k:
            return "YES"
        if k==0 and counter==0:
            return "NO"
    return "NO"

for i in range(int(input())):
    n, k = [int(i) for i in input().split()]
    a = [int(i) for i in input().split()]
    print(gift_segment(a, k))

Someone tell me where I’m going wrong?

#include
using namespace std;

int main() {
int t;
cin >>t ;
while(t–){
int n,k,count;
bool flag=false;
count=0;
cin>>n>>k;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
for(int i=0;i<n;i++){
if(a[i]%2==0){
count++;
if(count==k){
flag=true;
break;
}
}
else{
count=0;
}
if(count==k){
flag=true;
break;
}
}
if(flag){
cout<<“YES\n”;
}else{
cout<<“NO\n”;
}
}
return 0;
}

If anyone can please tell me, which test case did I fail.