Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>

#include <string>

using namespace std;



int main() {

    int t;

    cin >> t;

    while (t--) {

        string s;

        cin >> s;

        int n = s.size();

        int sum=0;

        int twos=0;

        int threes=0;

        for (int i=0; i<n; i++) {

            sum =(sum+ (s[i] - '0'))%9;

            if((s[i] - '0')%9==2){

                twos++;

            }

            if((s[i] - '0')%9==3){

                threes++;

            }

        }

        if(sum%9==0){

            cout<<"YES"<<endl;

            continue;

        }

        else if(sum%9==1){

            if(twos>0 && threes>1){

                cout<<"YES"<<endl;

                continue;

            }

        }    

        else if(sum%9==2){

            if(twos>=8 || (twos>=5 && threes>=1) || (twos>=2 && threes>=2)){

                cout<<"YES"<<endl;

                continue;

            }

        }

        else if(sum%9==3){

            if(threes>0 || twos>=3){

                cout<<"YES"<<endl;

                continue;

            }

        }

        else if(sum%9==4){

            if(twos>=7 || (twos>=4 && threes>=1) || (twos>=1 && threes>=2)){

                cout<<"YES"<<endl;

                continue;

            }

        }

        else if(sum%9==5){

            if(twos>=2){

                cout<<"YES"<<endl;

                continue;

            }

        }

        else if(sum%9==6){

            if(twos>=6 || (twos>=3 && threes>=1) || (twos>=0 && threes>=2)){

                cout<<"YES"<<endl;

                continue;

            }

        }

        else if(sum%9==7){

            if(twos>0){

                cout<<"YES"<<endl;

                continue;

            }

        }

        else if(sum%9==8){

            if(twos>=5 || (twos>=2 && threes>=1)){

                cout<<"YES"<<endl;

                continue;

            }

        }

        cout<<"NO"<<endl;   

    }

}



Submission (verdict: Wrong answer on test 2):
#include <iostream>

#include <string>

using namespace std;



int main() {

    int t;

    cin >> t;

    while (t--) {

        string s;

        cin >> s;

        int n = s.size();

        int sum=0;

        int twos=0;

        int threes=0;

        for (int i=0; i<n; i++) {

            sum =(sum+ (s[i] - '0'))%9;

            if((s[i] - '0')%9==2){

                twos++;}

            if((s[i] - '0')%9==3){

                threes++;

            }

        }

        if(sum%9==0){

            cout<<"YES"<<endl;

            continue;

        }

        else if(sum%9==1){

            if(( twos>=1 && threes>=1) || (twos>=4)){

                cout<<"YES"<<endl;

                continue;

            }

        }    

        else if(sum%9==2){

            if(twos>=8 || (twos>=5 && threes>=1) || (twos>=2 && threes>=2)){

                cout<<"YES"<<endl;

                continue;

            }

        }

        else if(sum%9==3){

            if(threes>=0 || twos>=3){

                cout<<"YES"<<endl;

                continue;

            }

        }

        else if(sum%9==4){

            if(twos>=7 || (twos>=4 && threes>=1) || (twos>=1 && threes>=2)){

                cout<<"YES"<<endl;

                continue;

            }

        }

        else if(sum%9==5){

            if(twos>=2){

                cout<<"YES"<<endl;

                continue;

            }

        }

        else if(sum%9==6){

            if(twos>=6 || (twos>=3 && threes>=1) || (threes>=2)){

                cout<<"YES"<<endl;

                continue;

            }

        }

        else if(sum%9==7){

            if(twos>=1){

                cout<<"YES"<<endl;

                continue;

            }

        }

        else if(sum%9==8){

            if(twos>=5 || (twos>=2 && threes>=1)){

                cout<<"YES"<<endl;

                continue;

            }

        }

        cout<<"NO"<<endl;   

    }

}