Help me in solving EZSPEAK problem

My issue

output is coming
yes
no
yes
yes
yes

instead of
yes
no
yes
no
yes

My code

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int T,i,N,j,count=0,k=0,flag =0;
    string S;
    vector<int>D;
    cin>>T;
    for(i=0;i<T;i++)
    {
        cin>>N;
        D.resize(N);
        cin>>S;
        for(j=0;j<N;j++)
        {
            
            if(S[j]!='a'&&S[j]!='e'&&S[j]!='i'&&S[j]!='o'&&S[j]!='u')
            {
                count+=1;
            }
            else
            {
                D[k] = count;
                count = 0;
                k=k+1;
            }
        }
        if(count == N && N>=4)
            {
                flag = 1;
                goto label;
            }
        for(j=0;j<=k+1;j++)
        {
            if(D[j]>=4)
            {
                flag = 1;
            }
        }
    label:
        if(flag == 1)
        {
            cout<<"NO"<<endl;
        }
        else
        {
            cout<<"YES"<<endl;
        }
        flag=0;
        k=0;
    }
    return 0;
}

Problem Link: EZSPEAK Problem - CodeChef

Don’t initialise your count ,k,and flag outside of while loop, otherwise it will effect both of your global and local variable

you can refer this , discuss link to understand what i mean by
LOCAL AND GLOBAL INITIALISATION abhaypandey114 & amnkhxn - CodeChef Discuss

May be this will help you

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

int main() {
    int t;
    cin >> t;

    while(t--) { 
        int n;
        cin >> n;
        string s;
        cin >> s;
        int count = 0;
        int notor_easy = 0;

        for(int i = 0; i < n; i++) {
            if(s[i] != 'a' && s[i] != 'e' && s[i] != 'i' && s[i] != 'o' && s[i] != 'u') {
                count++;
            }

            if(s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u') {
                count = 0;
            }

            if(count >= 4) {
                notor_easy++;
                break;
            }
        }

        if(notor_easy != 0) {
            cout << "NO" << endl;
        }
        else {
            cout << "YES" << endl;
        }
    }

    return 0;
}