Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define inarr(arr, n) ll arr[n];for (ll i = 0; i < n; i++) cin>>arr[i]
#define in(n) ll n;cin>>n
#define inn(n,k) ll n,k;cin>>n>>k
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"
#define on(n) cout<<n<<endl
#define ff first
#define ss second
#define rr return

#define pb emplace_back
#define vll vector<ll>
#define vinp(x) for(auto &i:x) cin>>i
#define vpll vector<pair<ll,ll>>
#define mapll map<ll,ll>
#define sll set<ll, ll>
#define lb(c, x) distance((c).begin(),lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(),upper_bound(all(c), (x)))

#define mod ll(1000000007)
//#define mod ll(998244353)

#define all(x) x.begin(), x.end()
#define fi(l, r) for(ll i=l;i<r;i++)
#define fj(l, r) for(ll j=l;j<r;j++)
#define fir(r, l) for(ll i=r;i>=l;i--)
#define fjr(r, l) for(ll j=r;j>=l;j--)

bool sorta(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
bool sortd(const pair<int,int> &a,const pair<int,int> &b){return (a.second > b.second);}

ll power(ll n,ll a){ ll res=1; while(a){ if(a%2)res*=n,a--; else   n*=n,a/=2;} return res;}
ll modpower(ll n,ll a,ll p){ ll res=1; while(a){if(a%2) res= ((res*n)%p) ,a--; else n=((n*n)%p),a/=2;} return res;}
ll mod_mul_inverse(ll a,ll b){
    return modpower(a , b-2, b);
}
ll mod_add(ll a,ll b,ll m){
    return (a%m+b%m)%m;
}
ll mod_mult(ll a,ll b,ll m){
    return (a%m*b%m)%m;
}
ll mod_div(ll a,ll b,ll m){
    return mod_mult(a,mod_mul_inverse(b,m),m);
}

bool fastprime(ll a){ if (a != 2 && a % 2 == 0 || a < 2)return false;  for(ll i = 3; i * i <= a; i += 2) if(a % i== 0) return false; return true;}
bool isPowerOfTwo(int n){if(n==0)return false;return (ceil(log2(n)) == floor(log2(n)));}
bool isPerfectSquare(ll x){if (x >= 0) {ll sr = sqrt(x);return (sr * sr == x);}return false;}

bool sortbysec(const pair<ll,ll> a,const pair<ll,ll>b){if (a.second!=b.second){return a.second<b.second;}else{return a.first<b.first;}}

vll getBinary(ll k){vll ans; while(k){ll rem=k%2; ans.pb(rem); k/=2;} return ans;}

ll MSBPosition(ll N)
{
    ll msb_p = -1;
    while (N) {
        N = N >> 1;
        msb_p++;
    }
    return msb_p;
}
 
// Returns the Bitwise OR of all
// llegers between L and R
ll findBitwiseOR(ll L,ll R)
{
    ll res = 0;
 
    // Find the MSB position in L
    ll msb_p1 = MSBPosition(L);
 
    // Find the MSB position in R
    ll msb_p2 = MSBPosition(R);
 
    while (msb_p1 == msb_p2) {
        ll res_val = (1 << msb_p1);
 
        // Add this value until msb_p1 and
        // msb_p2 are same;
        res += res_val;
 
        L -= res_val;
        R -= res_val;
 
        // Calculate msb_p1 and msb_p2
        msb_p1 = MSBPosition(L);
        msb_p2 = MSBPosition(R);
    }
    // Find the max of msb_p1 and msb_p2
    msb_p1 = max(msb_p1, msb_p2);
 
    // Set all the bits from msb_p1 upto
    // 0th bit in the result
    for (ll i = msb_p1; i >= 0; i--) {
        ll res_val = (1 << i);
        res += res_val;
    }
    return res;
}

void SieveOfEratosthenes(ll n,vll &v)
{
    bool prime[n + 1];
    memset(prime, true, sizeof(prime));
 
    for (ll p = 2; p * p <= n; p++) {
        
        if (prime[p] == true) {
            
            for (ll i = p * p; i <= n; i += p)
                prime[i] = false;
        }
    }
 
    for (ll p = 2; p <= n; p++)
        if (prime[p])
            v.pb(p);
}

map<ll, set<ll> > mp;
void dfs(ll root)
{
    if(mp[root].size()==0){
        rr;
    }
    for(auto it:mp[root]){
        mp[it].erase(root);
        dfs(it);
    }
}

void bfs(ll root)
{
    queue<ll> q;
    q.push(root);
    while(!q.empty())
    {
        ll tmp=q.front();
        q.pop();
        for(auto it:mp[tmp])
        {
            q.push(it);
            mp[it].erase(tmp);
        }
    }
}

void solve()
{
    in(n);
    if(n%9==0){ yes; return;}
    ll sod=0;
    string str=to_string(n);
    ll twos=0,three=0;
    fi(0,str.size()){
        if(str[i]=='2') twos++;
        if(str[i]=='3') three++;
        sod+=str[i]-48;
    }
    twos=twos%9;
    three=three%9;
    ll flag=0;
    fi(0,twos+1){
        fj(0,three+1){
            if((i!=0 || j!=0) && (sod+ 2*i +6*j) % 9 ==0){
                yes;
                flag=1;
                break;
            }
        }
        if(flag) break;
    }
    if(!flag) no;
    }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);


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

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define inarr(arr, n) ll arr[n];for (ll i = 0; i < n; i++) cin>>arr[i]
#define in(n) ll n;cin>>n
#define inn(n,k) ll n,k;cin>>n>>k
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"
#define on(n) cout<<n<<endl
#define ff first
#define ss second
#define rr return

#define pb emplace_back
#define vll vector<ll>
#define vinp(x) for(auto &i:x) cin>>i
#define vpll vector<pair<ll,ll>>
#define mapll map<ll,ll>
#define sll set<ll, ll>
#define lb(c, x) distance((c).begin(),lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(),upper_bound(all(c), (x)))

#define mod ll(1000000007)
//#define mod ll(998244353)

#define all(x) x.begin(), x.end()
#define fi(l, r) for(ll i=l;i<r;i++)
#define fj(l, r) for(ll j=l;j<r;j++)
#define fir(r, l) for(ll i=r;i>=l;i--)
#define fjr(r, l) for(ll j=r;j>=l;j--)

bool sorta(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
bool sortd(const pair<int,int> &a,const pair<int,int> &b){return (a.second > b.second);}

ll power(ll n,ll a){ ll res=1; while(a){ if(a%2)res*=n,a--; else   n*=n,a/=2;} return res;}
ll modpower(ll n,ll a,ll p){ ll res=1; while(a){if(a%2) res= ((res*n)%p) ,a--; else n=((n*n)%p),a/=2;} return res;}
ll mod_mul_inverse(ll a,ll b){
    return modpower(a , b-2, b);
}
ll mod_add(ll a,ll b,ll m){
    return (a%m+b%m)%m;
}
ll mod_mult(ll a,ll b,ll m){
    return (a%m*b%m)%m;
}
ll mod_div(ll a,ll b,ll m){
    return mod_mult(a,mod_mul_inverse(b,m),m);
}

bool fastprime(ll a){ if (a != 2 && a % 2 == 0 || a < 2)return false;  for(ll i = 3; i * i <= a; i += 2) if(a % i== 0) return false; return true;}
bool isPowerOfTwo(int n){if(n==0)return false;return (ceil(log2(n)) == floor(log2(n)));}
bool isPerfectSquare(ll x){if (x >= 0) {ll sr = sqrt(x);return (sr * sr == x);}return false;}

bool sortbysec(const pair<ll,ll> a,const pair<ll,ll>b){if (a.second!=b.second){return a.second<b.second;}else{return a.first<b.first;}}

vll getBinary(ll k){vll ans; while(k){ll rem=k%2; ans.pb(rem); k/=2;} return ans;}

ll MSBPosition(ll N)
{
    ll msb_p = -1;
    while (N) {
        N = N >> 1;
        msb_p++;
    }
    return msb_p;
}
 
// Returns the Bitwise OR of all
// llegers between L and R
ll findBitwiseOR(ll L,ll R)
{
    ll res = 0;
 
    // Find the MSB position in L
    ll msb_p1 = MSBPosition(L);
 
    // Find the MSB position in R
    ll msb_p2 = MSBPosition(R);
 
    while (msb_p1 == msb_p2) {
        ll res_val = (1 << msb_p1);
 
        // Add this value until msb_p1 and
        // msb_p2 are same;
        res += res_val;
 
        L -= res_val;
        R -= res_val;
 
        // Calculate msb_p1 and msb_p2
        msb_p1 = MSBPosition(L);
        msb_p2 = MSBPosition(R);
    }
    // Find the max of msb_p1 and msb_p2
    msb_p1 = max(msb_p1, msb_p2);
 
    // Set all the bits from msb_p1 upto
    // 0th bit in the result
    for (ll i = msb_p1; i >= 0; i--) {
        ll res_val = (1 << i);
        res += res_val;
    }
    return res;
}

void SieveOfEratosthenes(ll n,vll &v)
{
    bool prime[n + 1];
    memset(prime, true, sizeof(prime));
 
    for (ll p = 2; p * p <= n; p++) {
        
        if (prime[p] == true) {
            
            for (ll i = p * p; i <= n; i += p)
                prime[i] = false;
        }
    }
 
    for (ll p = 2; p <= n; p++)
        if (prime[p])
            v.pb(p);
}

map<ll, set<ll> > mp;
void dfs(ll root)
{
    if(mp[root].size()==0){
        rr;
    }
    for(auto it:mp[root]){
        mp[it].erase(root);
        dfs(it);
    }
}

void bfs(ll root)
{
    queue<ll> q;
    q.push(root);
    while(!q.empty())
    {
        ll tmp=q.front();
        q.pop();
        for(auto it:mp[tmp])
        {
            q.push(it);
            mp[it].erase(tmp);
        }
    }
}

void solve()
{
    string str; cin>>str;
    ll sod=0;
    ll twos=0,three=0;
    fi(0,str.size()){
        if(str[i]=='2') twos++;
        if(str[i]=='3') three++;
        sod+=str[i]-'0';
    }
    if(sod%9==0){
        yes;
        return;
    }
    
    ll flag=0;
    fi(0,twos+1){
        fj(0,three+1){
            if((sod+ 2*i +6*j) % 9 ==0){
                yes;
                flag=1;
                break;
            }
        }
        if(flag) break;
    }
    if(!flag) no;
    }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);


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