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

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define ld long double
#define pll pair<ll,ll>
#define pllv pair<ll,vector<ll>>
#define all(a) a.begin(),a.end()
#define ump unordered_map
#define  deb1(a)        cout<<a<<endl;
#define  deb2(a,b)      cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());
#define DEATH_NOTE ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(15);
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define rep(a,b) for(ll i=a;i<b;i++)
//const ll sz=1001;
const ll mod=1e9+7;
const ll INF=1e18+10;

void solve()
{
    ll n;
    cin>>n;
    vector<int> cnt(2,0);
    ll sumOfDigits = 0;
    while(n) {
        ll curDigit = n%10;
        sumOfDigits+= curDigit;
        if (curDigit == 2 || curDigit == 3) {
            cnt[curDigit-2]++;
        }
        n/=10;
    }
    for(ll nof2 = 0 ; nof2<min(10,cnt[0]+1); nof2++) {
            for(ll nof3 = 0 ; nof3<min(10,cnt[1]+1) && nof3<9; nof3++) {
                ll addSum = 2*nof2 + 6*nof3;
                if ((addSum + sumOfDigits) % 9 ==0) {
                    cout<<"Yes"<<endl;
                    return;
                }
            }
    }
    cout<<"NO"<<endl;
}
int main()
{
    DEATH_NOTE

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


Submission (verdict: Accepted):
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define ld long double
#define pll pair<ll,ll>
#define pllv pair<ll,vector<ll>>
#define all(a) a.begin(),a.end()
#define ump unordered_map
#define  deb1(a)        cout<<a<<endl;
#define  deb2(a,b)      cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());
#define DEATH_NOTE ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(15);
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define rep(a,b) for(ll i=a;i<b;i++)
//const ll sz=1001;
const ll mod=1e9+7;
const ll INF=1e18+10;

void solve()
{
    string n;
    cin>>n;
    ll cnt2 = 0;
    ll cnt3 = 0;
    ll sumOfDigits = 0;
    for(auto x:n) {
        ll num = x-'0';
        sumOfDigits+= num;
        if (num == 2) cnt2++;
        if( num == 3) cnt3++;
    }
    ll limit = 10;
    //cout<<"Cnt2"<<cnt2<<" and  cnt3"<<cnt3<<endl;
    for(ll nof2 = 0 ; nof2<min(limit,cnt2+1); nof2++) {
            for(ll nof3 = 0 ; nof3<min(limit,cnt3+1) && nof3<9; nof3++) {
                ll addSum = 2*nof2 + 6*nof3;
                if ((addSum + sumOfDigits) % 9 ==0) {
                    cout<<"Yes"<<endl;
                    return;
                }
            }
    }
    cout<<"NO"<<endl;
}
int main()
{
    DEATH_NOTE

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