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

Previous submission (verdict: Wrong answer on test 3):
#include<iostream>
using namespace std;
int main(){
    int t;
    cin>>t;
    while (t>0){
        t--;
        string s;
        cin>>s;
        int sum=0;
        int n=s.length();
        int two=0,three=0;
        for (int i=0;i<n;i++){
            sum=sum + (int)s[i]-48;
            if (s[i]=='2'){
                two+=1;
            }else if(s[i]=='3'){
                three+=1;
            }
        }
        if (sum%9==0){
            cout<<"YES"<<endl;
        }
        else{
            int b=9-sum%9;
            if (b%2==0){
                if (b==8 &&( (two>=1 && three>=1) || two>=4)){
                    cout<<"YES"<<endl;
                }else if (b==6 && (three>=1||two>=3)){
                    cout<<"YES"<<endl;
                }else if (b==4 && two>=2){
                    cout<<"YES"<<endl;
                }else if (b==2 && two>=1){
                    cout<<"YES"<<endl;
                }else{
                    cout<<"NO"<<endl;
                }
            }else{
                b=b+9;
                if (b==16 && two>=2){
                    if ((three==1 && two>=5)|| (three>1)){
                        cout<<"YES"<<endl;
                    }else{
                        cout<<"NO"<<endl;
                    }
                }else if (b==14 && two>=1){
                    if ((three==1 && two>=4)|| (three>=2)){
                        cout<<"YES"<<endl;
                    }else{
                        cout<<"NO"<<endl;
                    }
                }else if (b==12){
                    if ((three==1 && two>=3) || (three>=2)){
                        cout<<"YES"<<endl;
                    }else{
                        cout<<"NO"<<endl;
                    }
                }else if (b==10 && two>=2){
                    if ((three==1)|| (two>=5)){
                        cout<<"YES"<<endl;
                    }else{
                        cout<<"NO"<<endl;
                    }
                }else {
                    cout<<"NO"<<endl;
                }
            }
        }
    }
    return 0;
}

Submission (verdict: Wrong answer on test 3):
#include<iostream>
using namespace std;
int main(){
    int t;
    cin>>t;
    while (t>0){
        t--;
        string s;
        cin>>s;
        int sum=0;
        int n=s.length();
        int two=0,three=0;
        for (int i=0;i<n;i++){
            sum=sum + (int)s[i]-48;
            if (s[i]=='2'){
                two+=1;
            }else if(s[i]=='3'){
                three+=1;
            }
        }
        if (sum%9==0){
            cout<<"YES"<<endl;
        }
        else{
            int b=9-sum%9;
            if (b%2==0){
                if (b==8 &&((two>=1 && three>=1) || (two>=4))){
                    cout<<"YES"<<endl;
                }else if (b==6 && ((three>=1)||(two>=3))){
                    cout<<"YES"<<endl;
                }else if (b==4 && two>=2){
                    cout<<"YES"<<endl;
                }else if (b==2 && two>=1){
                    cout<<"YES"<<endl;
                }else{
                    cout<<"NO"<<endl;
                }
            }else{
                b=b+9;
                if (b==16 && two>=2){
                    if ((three==1 && two>=5)|| (three>1)){
                        cout<<"YES"<<endl;
                    }else{
                        cout<<"NO"<<endl;
                    }
                }else if (b==14 && two>=1){
                    if ((three==1 && two>=4)|| (three>=2)){
                        cout<<"YES"<<endl;
                    }else{
                        cout<<"NO"<<endl;
                    }
                }else if (b==12){
                    if ((three==1 && two>=3) || (three>=2)){
                        cout<<"YES"<<endl;
                    }else{
                        cout<<"NO"<<endl;
                    }
                }else if (b==10 && two>=2){
                    if ((three==1)|| (two>=5)){
                        cout<<"YES"<<endl;
                    }else{
                        cout<<"NO"<<endl;
                    }
                }else {
                    cout<<"NO"<<endl;
                }
            }
        }
    }
    return 0;
}