Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

void solve() {
    string s;
    cin >> s;
    map<char,int> mp;
    mp['1']=0;
    mp['2']=0;
    mp['3']=0;
    mp['4']=0;
    mp['5']=0;
    mp['6']=0;
    mp['7']=0;
    mp['8']=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='1'){
            if(mp['8']>0) mp['8']--;
            else mp['1']++;
        }
        if(s[i]=='2'){
            mp['2']++;
        }if(s[i]=='4'){
            if(mp['5']>0) mp['5']--;
            else mp['4']++;
        }if(s[i]=='5'){
            if(mp['4']>0) mp['4']--;
            else mp['5']++;
        }if(s[i]=='7'){
            mp['7']++;
        }
        if(s[i]=='8'){
            if(mp['1']>0) mp['1']--;
            else mp['8']++;
        }
        if(s[i]=='6') mp['6']++;
        if(s[i]=='3') mp['3']++;
    }
    ll sum=0;
    sum += 9 - (mp['1'] % 9);
    sum += 9 - ((3*mp['3']) % 9);
    sum += 9 - ((8*mp['8']) % 9);
    sum += 9 - ((7*mp['7']) % 9);
    sum += 9 - ((4*mp['4']) % 9);
    sum += 9 - ((5*mp['5']) % 9);
    sum += 9 - ((2*mp['2']) % 9);
    if(mp['6']%3 != 0) sum += 9 - ((6*mp['6']) % 9);
    int ans = (sum%9);
    if(ans==0 || ans==9){
        cout << "YES\n";
    }
    if(ans==1){
        if(mp['2']>=5){
            cout << "YES\n";
        }
        else cout << "NO\n";
    }
    if(ans==2){
        if(mp['2']>=1) cout << "YES\n";
        else cout << "NO\n";
    }
    if(ans==3){
        if(mp['2']>=6 || mp['3']>=2) cout << "YES\n";
        else cout << "NO\n";
    }
    if(ans==4){
        if(mp['2']>=2) cout << "YES\n";
        else cout << "NO\n";
    }
    if(ans==5){
        if((mp['2']>=4 && mp['3']>=1) || (mp['2']>=1 && mp['3']>=2) || (mp['2']>=7)) cout << "YES\n";
        else cout << "NO\n";
    }
    if(ans==6){
        if(mp['3']>=1 || mp['2']>=3) cout << "YES\n";
        else cout << "NO\n";
    }
    if(ans==7){
        if((mp['2']>=5 && mp['3']>=1) || (mp['2']>=1 && mp['3']>=2) || (mp['2']>=8)) cout << "YES\n";
        else cout << "NO\n";
    }
    if(ans==8){
        if(mp['2']>=4) cout << "YES\n";
        else cout << "NO\n";
    }
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

void solve() {
    string s;
    cin >> s;
    map<char,int> mp;
    mp['2']=0;
    mp['3']=0;
    ll sum=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='2') mp['2']++;
        if(s[i]=='3') mp['3']++;
        sum += (s[i]-'0');
        sum %= 9;
    }
    sum = (9-sum);
    if(sum==0 || sum==9) cout << "YES\n";
    else if(sum==1){
        if(mp['2']>=5 || (mp['2']>=2 && mp['3']>=1)){
            cout << "YES\n";
        }
        else cout << "NO\n";
    }
    else if(sum==2){
        if(mp['2']>=1) cout << "YES\n";
        else cout << "NO\n";
    }
    else if(sum==6){
        if(mp['2']>=3 || mp['3']>=1) cout << "YES\n";
        else cout << "NO\n";
    }
    else if(sum==3){
        if(mp['2']>=6 || (mp['3']>=2) || (mp['3']>=1 && mp['2']>=3)) cout << "Yes\n";
        else cout << "no\n";
    }
    else if(sum==4){
        if(mp['2']>=2) cout << "yes\n";
        else cout << "no\n";
    }
    else if(sum==5){
        if(mp['2']>=7 || (mp['2']>=1 && mp['3']>=2) || (mp['2']>=4 && mp['3']>=1)) cout << "yes\n";
        else cout << "no\n";
    }
    else if(sum==7){
        if(mp['2']>=8 || (mp['2']>=5 && mp['3']>=1) || (mp['2']>=2 && mp['3']>=2)) cout << "yes\n";
        else cout << "no\n";
    }
    else if(sum==8){
        if(mp['2']>=4) cout << "yes\n";
        else cout << "no\n";
    }
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}