Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>

using namespace std;

#define ll long long

#define f(i,n) for(ll i=0;i<n;i++)



void solve(){

    ll n;

    cin>>n;

    ll sum=0;

    ll x=n;

    ll cnt2=0,cnt3=0;

    while(x>0){

        if(x%10==2) cnt2++;

        if(x%10==3) cnt3++;

        sum+=(x%10);

        x/=10;

    }

    if(sum%9==0){

        cout<<"YES\n";

        return;

    }

    else if(sum%9==1){

        // if(cnt2==0){

        //     cout<<"NO\n";

        //     return;

        // }else{

        //     // if(cnt3==0){

        //     //     if(cnt2>=4){

        //     //         cout<<"YES\n";

        //     //         return;

        //     //     }else{

        //     //         cout<<"NO\n";

        //     //         return;

        //     //     }

        //     // }else{

        //     //     cout<<"YES\n";

        //     //     return;

        //     // }

        //     if(cnt2>=4 || (cnt2>=1 && cnt3>=1)){

        //         cout<<"YES\n";

        //         return;

        //     }

        // }

        if(cnt2>=4 || (cnt2>=1 && cnt3>=1)) cout<<"YES\n";

        else cout<<"NO\n";

    }else if(sum%9==2){

        if((cnt2>=8) || (cnt2>=5 && cnt3>=1) || (cnt2>=2 && cnt3>=2)){

            cout<<"YES\n";

            return;

        }else{

            cout<<"NO\n";

        }

    }else if(sum%9==3){

        if(cnt2>=3 || cnt3>=1) cout<<"YES\n";

        else cout<<"NO\n";

    }else if(sum%9==4){

        if(cnt2>=7 || (cnt2>=4 && cnt3>=1) || (cnt2>=1 && cnt3>=2)) cout<<"YES\n";

        else cout<<"NO\n";

    }else if(sum%9==5){

        if(cnt2>=2) cout<<"YES\n";

        else cout<<"NO\n";

    }else if(sum%9==6){

        if(cnt2>=6 || (cnt2>=3 && cnt3>=1) || (cnt3>=2)) cout<<"YES\n";

        else cout<<"NO\n";

    }else if(sum%9==7){

        if(cnt2>=1) cout<<"YES\n";

        else cout<<"NO\n";

    }else if(sum%9==8){

        if(cnt2>=5 || (cnt2>=2 && cnt3>=1)) cout<<"YES\n";

        else cout<<"NO\n";

    }

}

int main(){

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);

    int t;

    cin >> t;

    while (t--){

        solve();

    }

    return 0;

}

Submission (verdict: Accepted):
#include<bits/stdc++.h>

using namespace std;

#define ll long long

#define f(i,n) for(ll i=0;i<n;i++)



void solve(){

    string s;

    cin>>s;

    ll sum=0;

    ll cnt2=0,cnt3=0;

    for(ll i=0;i<s.size();i++){

        sum+=(ll) (s[i]-48);

        if(s[i]=='2') cnt2++;

        if(s[i]=='3') cnt3++;

    }

    if(sum%9==0){

        cout<<"YES\n";

        return;

    }

    else if(sum%9==1){

        if(cnt2>=4 || (cnt2>=1 && cnt3>=1)) cout<<"YES\n";

        else cout<<"NO\n";

    }else if(sum%9==2){

        if((cnt2>=8) || (cnt2>=5 && cnt3>=1) || (cnt2>=2 && cnt3>=2))cout<<"YES\n";

        else cout<<"NO\n";

    }else if(sum%9==3){

        if(cnt2>=3 || cnt3>=1) cout<<"YES\n";

        else cout<<"NO\n";

    }else if(sum%9==4){

        if(cnt2>=7 || (cnt2>=4 && cnt3>=1) || (cnt2>=1 && cnt3>=2)) cout<<"YES\n";

        else cout<<"NO\n";

    }else if(sum%9==5){

        if(cnt2>=2) cout<<"YES\n";

        else cout<<"NO\n";

    }else if(sum%9==6){

        if(cnt2>=6 || (cnt2>=3 && cnt3>=1) || (cnt3>=2)) cout<<"YES\n";

        else cout<<"NO\n";

    }else if(sum%9==7){

        if(cnt2>=1) cout<<"YES\n";

        else cout<<"NO\n";

    }else if(sum%9==8){

        if(cnt2>=5 || (cnt2>=2 && cnt3>=1)) cout<<"YES\n";

        else cout<<"NO\n";

    }

}

int main(){

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);

    int t;

    cin >> t;

    while (t--){

        solve();

    }

    return 0;

}