Problem: 2050C - Uninteresting Number
Language: c++17 

Solution 1 (runtime: 77 ms):
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long u;
    cin>>u;
    while (u--)
    {
        string str;
        cin>>str;
        long long n;
        n=str.length();
        vector<long long>v;
        long long sum=0;
        long long count2=0;
        long long count3=0;
        for (long long i = 0; i < n; i++)
        {
            v.push_back(int(str[i])-48);
            if (v[i]==2)
            {
                count2++;
            }
            else if (v[i]==3)
            {
                count3++;
            }
            sum+=v[i];
        }
        bool flag=false;
        if (sum%9==0)
        {
            cout<<"YES"<<endl;
        }
        // else if ((sum%9)%2!=0)
        // {
        //     cout<<"NO"<<endl;
        // }
        else if (sum%9==2)
        {
            if (count2>=8 || (count2>=5 && count3>=1) || (count2>=2 && count3>=2))
            {
                cout<<"YES"<<endl;
            }
            else
            {
                cout<<"NO"<<endl;
            }
            
        }
        else if (sum%9==4)
        {
            if (count2>=7 || (count2>=4 && count3>=1) || (count3>=2 && count2>=1))
            {
                cout<<"YES"<<endl;
            }
            else
            {
                cout<<"NO"<<endl;
            }
            
        }
        else if (sum%9==6)
        {
            if (count3>=2 || (count3>=1 && count2>=3) || (count2>=6))
            {
                cout<<"YES"<<endl;
            }
            else{
                cout<<"NO"<<endl;
            }
        }
        else if (sum%9==8)
        {
            if (count2>=5 || (count3>=1 && count2>=2))
            {
                cout<<"YES"<<endl;
            }
            else
            {
                cout<<"NO"<<endl;
            }
            
        }
        else if (sum%9==1)
        {
            if (count2>=4 || (count3>=1 && count2>=1))
            {
                cout<<"YES"<<endl;
            }
            else
            {
                cout<<"NO"<<endl;
            }
            
        }
        else if (sum%9==3)
        {
            if (count2>=3 || (count3>=1))
            {
                cout<<"YES"<<endl;
            }
            else
            {
                cout<<"NO"<<endl;
            }
            
        }
        else if (sum%9==5)
        {
            if (count2>=2)
            {
                cout<<"YES"<<endl;
            }
            else{
                cout<<"NO"<<endl;
            }
        }
        else if (sum%9==7)
        {
            if (count2>=1)
            {
                cout<<"YES"<<endl;
            }
            else
            {
                cout<<"NO"<<endl;
            }
            
        }
        
                
        
        // cout<<sum%9<<endl;
        
    }
    
}

Solution 2 (runtime: 46 ms):
#include <bits/stdc++.h>
using namespace std;

void solve() {
    string s;
    cin >> s;

    int sum = 0, twos = 0, threes = 0;

    // Calculate sum of digits and count of '2' and '3'
    for (char c : s) {
        int digit = c - '0';
        sum += digit;
        if (digit == 2) twos++;
        if (digit == 3) threes++;
    }

    // Iterate through possible transformations
    for (int i = 0; i <= min(10, twos); i++) {
        for (int j = 0; j <= min(10, threes); j++) {
            if ((sum + i * 2 + j * 6) % 9 == 0) {
                cout << "YES" << endl;
                return;
            }
        }
    }
    cout << "NO" << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

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

    return 0;
}