Help me in solving CHEALG problem

My issue

why my code is not working ig the logic is correct and same as the other submitted by other solution can anyone please figure what the fault ?

My code

#include <iostream>
#include <string>
#include <map>
using namespace std;

int main() {
    int t;
    cin >> t;
    while (t--) {
        string s;
        cin >> s;
        int length = s.size(), count = 0;
        map<char, int> freq;
        for (int i = 0; i < s.size(); i++) {
            freq[s[i]]++;
        }
        map<char, int>::iterator itr;
        for (itr = freq.begin(); itr != freq.end(); itr++) {
            string numberString = to_string(itr->second);
            int digitCount = numberString.size();
            count += digitCount + 1;
        }

        if (count < length) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}

Problem Link: CHEALG Problem - CodeChef

@ravimeena0009
i guess your logic is not right like u have to print the consecutive count of the characters in the string like aabbaa is not a4b2 its a2b2a2.
This is my code hope it helps;
include
using namespace std;

int main() {
// your code goes here
int t;
cin>>t;
while(t–)
{
string s,s2,an;
char ch;
cin>>s;
int cnt=0;
for(int i=0;i<s.size();i++)
{
if(i==0)
{
cnt++;
ch=s[i];
}
else
{
if(s[i]==ch)
cnt++;
else
{
s2=to_string(cnt);
an+=ch;
an+=s2;
ch=s[i];
cnt=1;
}
}
}
s2=to_string(cnt);
an+=ch;
an+=s2;
if(an.size()<s.size())
cout<<“YES”;
else
cout<<“NO”;
cout<<endl;
}
return 0;
}