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

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

using namespace std;

#define ll long long 

const ll int INF = 0xFFFFFFFFFFFFFFFLL;



int main() {

    int t = 1;

    cin >> t;

    while(t--)

    {

        ll n;

        cin >> n;

        int sum = 0;

        int ct2 = 0;

        int ct3 = 0;

        while(n){

            sum += n%10;

            if(n%10 == 2) ct2++;

            if(n%10 == 3) ct3++;

            n/=10;

        }



        // cout << sum%9 << '\n';



        if(sum%9 == 0){

            cout << "Yes" << '\n';

        }else{

            int y = sum;

            bool ok = false;

            ll add = 0;

            while(ct2){

                // add += 2;

                y += 2;

                if((y)%9 == 0){

                    cout << "Yes" << '\n';

                    ok = true;

                    break;

                }

                // y += add;

                ct2--;

                // cout << add << '\n';

            }

            if(!ok){

                // add = 3;

                while(ct3){

                    // ll add = 3;

                    // add += 6;

                    y += 6;

                        if((y)%9 == 0){

                        cout << "Yes" << '\n';

                        ok = true;

                        break;

                    }

                    // y += add;

                    ct3--;

                    // cout << add << '\n';

                }

            }

            if(!ok){

                cout << "No" << '\n';

            }

        }

    }

}



Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

using namespace std;

#define ll long long 

const ll int INF = 0xFFFFFFFFFFFFFFFLL;



int main() {

    int t = 1;

    cin >> t;

    while(t--)

    {

        ll n;

        cin >> n;

        int sum = 0;

        int ct2 = 0;

        int ct3 = 0;

        while(n){

            sum += n%10;

            if(n%10 == 2) ct2++;

            if(n%10 == 3) ct3++;

            n/=10;

        }



        if(sum%9 == 0){

            cout << "Yes" << '\n';

        }else if(((sum%9)&1) == 0){

            int y = sum;

            bool ok = false;

            ll add = 0;

            while(ct2){

                y += 2;

                if(y%9 == 0){

                    cout << "Yes" << '\n';

                    ok = true;

                    break;

                }

                ct2--;

            }

            if(!ok){

                while(ct3){

                    y += 6;

                    if(y%9 == 0){

                        cout << "Yes" << '\n';

                        ok = true;

                        break;

                    }

                    ct3--;

                }

            }

            if(!ok){

                cout << "No" << '\n';

            }

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

            if(ct2 >= 4 || (ct2>=1 && ct3 >= 1)){

                cout << "Yes" << '\n';

            }else{

                cout << "No" << '\n';

            }

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

            if(ct2 >= 3 || ct3 >=1){

                cout << "Yes" << '\n';

            }else{

                cout << "No" << '\n';

            }

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

            if(ct2 >= 2){

                cout << "Yes" << '\n';

            }else{

                cout << "No" << '\n';

            }

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

            if(ct2 >= 1){

                cout << "Yes" << '\n';

            }else{

                cout << "No" << '\n';

            }

        }

    }

}