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

Solution 1 (runtime: 46 ms):
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type, less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
template<typename T>
void pl(const T& m) {
    cout << m << endl;
}
template<typename T>
void ps(const T& m) {
    cout << m <<" ";
}
template<typename T>
void p(const T& m) {
    cout << m;
}
//Aliases
using ll= long long;
using lld= long double;
using ull= unsigned long long;

//Constants
const lld pi= 3.141592653589793238;
const ll INF= LONG_LONG_MAX;
const ll mod=1e9+7;

//TypeDEf
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef unordered_map<ll,ll> umll;
typedef map<ll,ll> mll;
typedef __gnu_pbds::tree<int, __gnu_pbds::null_type, 
less<int>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update> ordered_set;
// Macros
#define nl cout<<endl
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define fl(i,n) for(int i=0;i<n;i++)
#define fll(i,m,n) for(int i=m;i<=n;i++)
#define rl(i,n,m) for(int i=n;i>=m;i--)
#define py cout<<"YES\n"
#define pm cout<<"-1\n"
#define pn cout<<"NO\n"
#define pimp cout<<"IMPOSSIBLE\n";
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define rv(v) v.end(),v.begin()

ll modAdd(ll a, ll b, ll m) {
    return ((a % m) + (b % m)) % m;
}

ll modSub(ll a, ll b, ll m) {
    return ((a % m) - (b % m) + m) % m;
}

ll modMul(ll a, ll b, ll m) {
    return ((a % m) * (b % m)) % m;
}

ll modpow(ll x, ll y, ll p) {
    ll res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0) {
        if (y & 1) res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

ll modInverse(ll a, ll m) {
    return modpow(a, m - 2, m);
}

ll modDiv(ll a, ll b, ll m) {
    a = a % m;
    ll inv = modInverse(b, m);
    return (inv * a) % m;
}
void testcase()
{
    string n;
    cin>>n;
    // ps(n);
    ll sum=0, n2=0,n3=0;
    for(auto x:n)
    {
        ll num=x-'0';
        sum+=num;
        sum%=9;
        if(num==2) n2++;
        else if(num==3) n3++;
    }
    // ps(n2); ps(n3); ps(sum);
    if(sum==0) py;
    else if(sum==1)
    {
        if(n2 && n3 || n2>=4) py;
        else pn;
    }
    else if(sum==2)
    {
        if((n2>=2 && n3>=2) || (n2>=5 && n3) || (n2>=8) ) py;
        else pn;
    }
    else if(sum==3)
    {
        if(n3 || n2>=3) py;
        else pn;
    } 
    else if(sum==4)
    {
        if((n3>=2 && n2 ) || (n3 && n2>=4) || (n2>=7)) py;
        else pn;
    }
    else if(sum==5)
    {
        if(n2>=2) py;
        else pn;
    }
    else if(sum==6)
    {
        if(n3>=2 || (n3 && n2>=3) || (n2>=6)) py;
        else pn;
    }
    else if(sum==7)
    {
        if(n2) py;
        else pn;
    }
    else if(sum==8)
    {
        if((n3 && n2>=2) || n2>=5) py;
        else pn;
    }
    
    
}
    
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin>>t;
    fl(i,t)
    testcase();
    return 0;
}

Solution 2 (runtime: 46 ms):
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define nline '\n'
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define pr_vec(vec) for(auto &num: vec){cout<<num<<" ";}cout<<endl;
#define pr_vecPair(vec) for(auto &num: vec){cout<<num.first<<" "<<num.second<<'\n';}cout<<endl;
#define inp_vec1(vec) for(auto &ele: vec){cin>>ele;} 
#define inp_vec2(vec,n)for(long long int i=1;i<=n;++i){cin>>vec[i];}
bool odd(ll num) { return ((num & 1)  ); }
bool even(ll num) { return (!(num & 1)); }
void solve(ll tc)
{
    string s;
    cin>>s;
    ll sum = 0;
    ll  two =0,three=0;
   for(ll i=0;i<s.length();++i)
   {
       sum+=s[i]-'0';
       if(s[i]=='2')two++;
       if(s[i]=='3')three++; 
   }
    if(sum%9==0)
    {
        yes;return;
    }
    ll found = false;
    // cout<<two<<" "<<three<<nline;
    for(ll i=0;i<=two;++i)
    {//cout<<i<<nline;
        for(ll j=0;j<=three;++j)
        {
            ll new_sum = sum + (i*2) + (j* 6);
            // cout<<j<<" "<<sum<<nline;
            if(new_sum%9==0) 
            {
               yes;
               return;
            }
        }
    }
    no;
    // cout<<n<<nline;
    // cout<<sum<<nline;

}

int main()
{
    fast
    ll t;
    cin>>t;
    ll i=1;

    while(i<=t)
    {
        solve(i);
        i++;
    }
    return 0;
}