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;
#define pb push_back
#define ppb pop_back
#define ff first
#define ss second
#define f(i,a,b)        for(ll i=a;i<b;i++)
#define fm(i,a,b)       for(ll i=a;i>=b;i--)
#define fc(i,a,b,c)      for(ll i=a;i<b;i=i+c)
#define fmc(i,a,b,c)     for(ll i=a;i>=b;i=i-c)
#define fi(n)           f(i,0,n)
#define fj(n)           f(j,0,n)
#define fastfast()                      ios_base::sync_with_stdio(false); cin.tie(NULL);                    cout.tie(NULL)
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<vector<ll>> vvll;
void yes(){cout << "YES" << endl;}
void no(){cout << "NO" << endl;}
void print(ll t) {cout << t << endl;}
void print(int t) {cout << t << endl;}
void print(string t) {cout << t << endl;}
void print(char t) {cout << t << endl;}
void print(lld t) {cout << t << endl;}
void print(double t) {cout << t << endl;}
void print(ull t) {cout << t << endl;}
void prn(ll n)
{
    fi(n)
    {
        cout<<i+1<<" ";
    }
    cout<<endl;
}
ll insqrt(ll n)
{
    ll s=0;
    ll e=1e10+1;
    ll ans=0;
    if(n<=0) return 0;
    while(s<=e)
    {
        ll mid=(s+e)/2;
        if(mid*mid<=n) {s=mid+1; ans=mid;}
        else e=mid-1;
    }
    return ans;
}
 
ll orar[100001][20];
void buildorar(ll arr[],ll n)
{
    fi(n) orar[i][0]=arr[i];
    fj(20)
    {
        for(int i=0;i+(1<<j)<=n;i++)
        {
            orar[i][j+1]=orar[i][j]|orar[i+(1<<(j))][j];
        }
    }
}
 
ll calculate(ll l,ll r)
{
    ll ans=0;
    fm(i,20,0)
    {
        if((1<<i) <= r-l+1)
        {
            ans=ans|orar[l][i];
            l=l+(1<<i);
        }
    }
    return ans;
}
 
ll gcd(ll a,ll b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
 
ll lcm(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}
 
ll fastex(ll a,ll n)
{
    ll p=1;
    ll ld;
    while(n>0)
    {
        ld=n&1;
        if(ld==1) p=p*a;
        a=a*a;
        n=n>>1;
    }
    return p;
}
 
class DisjointSet
{
public:
    vll size,parent;
    DisjointSet(ll n)
    {
        size.resize(n+1,1);
        parent.resize(n+1,0);
        for(int i=0;i<n+1;i++) parent[i]=i;
    }
    ll findPar(ll u)
    {
        if(parent[u]==u) return u;
        else return parent[u]=findPar(parent[u]);
    }
    void unionbysize(ll u,ll v)
    {
        ll pu=findPar(u);
        ll pv=findPar(v);
        if(pu==pv) return;
        if(size[pu]<size[pv])
        {
            parent[pu]=pv;
            size[pv]+=size[pu];
        }
        else
        {
            parent[pv]=pu;
            size[pu]+=size[pv];
        }
    }
    ll findsize(ll u)
    {
        ll pu=findPar(u);
        return size[pu];
    }
};
 
// Jai Bajrangbali
 
int main()
{
    fastfast();
    
    ll t;
    cin >> t;

    while(t--){
        ll n;
        cin >> n;

        ll two = 0;
        ll three = 0;
        ll s=0;

        while (n > 0) {
            ll d = n%10;
            n /= 10;
            if(d==2) two++;
            if(d==3) three++;
            s+=d;
        }

        if(s%9==0){
            cout << "YES" << endl;
            continue;
        }

        ll want = 9-(s%9);
        if(want%2!=0) want+=9;

        want /=2;
        ll sum=0;
        int flag = 0;
        for (int i=0;i<=two;i++) {
            for (int j=0;j<=three;j++) {
                if ((sum+i+j*3) == want) {
                    flag=1;
                    break;
                }
            }
            if(flag==1)break;
        }
        if(flag==1){
            print("YES");
            continue;
        }
        print("NO");
    }


 
    return 0;
}

Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ppb pop_back
#define ff first
#define ss second
#define f(i,a,b)        for(ll i=a;i<b;i++)
#define fm(i,a,b)       for(ll i=a;i>=b;i--)
#define fc(i,a,b,c)      for(ll i=a;i<b;i=i+c)
#define fmc(i,a,b,c)     for(ll i=a;i>=b;i=i-c)
#define fi(n)           f(i,0,n)
#define fj(n)           f(j,0,n)
#define fastfast()                      ios_base::sync_with_stdio(false); cin.tie(NULL);                    cout.tie(NULL)
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<vector<ll>> vvll;
void yes(){cout << "YES" << endl;}
void no(){cout << "NO" << endl;}
void print(ll t) {cout << t << endl;}
void print(int t) {cout << t << endl;}
void print(string t) {cout << t << endl;}
void print(char t) {cout << t << endl;}
void print(lld t) {cout << t << endl;}
void print(double t) {cout << t << endl;}
void print(ull t) {cout << t << endl;}
void prn(ll n)
{
    fi(n)
    {
        cout<<i+1<<" ";
    }
    cout<<endl;
}
ll insqrt(ll n)
{
    ll s=0;
    ll e=1e10+1;
    ll ans=0;
    if(n<=0) return 0;
    while(s<=e)
    {
        ll mid=(s+e)/2;
        if(mid*mid<=n) {s=mid+1; ans=mid;}
        else e=mid-1;
    }
    return ans;
}
 
ll orar[100001][20];
void buildorar(ll arr[],ll n)
{
    fi(n) orar[i][0]=arr[i];
    fj(20)
    {
        for(int i=0;i+(1<<j)<=n;i++)
        {
            orar[i][j+1]=orar[i][j]|orar[i+(1<<(j))][j];
        }
    }
}
 
ll calculate(ll l,ll r)
{
    ll ans=0;
    fm(i,20,0)
    {
        if((1<<i) <= r-l+1)
        {
            ans=ans|orar[l][i];
            l=l+(1<<i);
        }
    }
    return ans;
}
 
ll gcd(ll a,ll b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
 
ll lcm(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}
 
ll fastex(ll a,ll n)
{
    ll p=1;
    ll ld;
    while(n>0)
    {
        ld=n&1;
        if(ld==1) p=p*a;
        a=a*a;
        n=n>>1;
    }
    return p;
}
 
class DisjointSet
{
public:
    vll size,parent;
    DisjointSet(ll n)
    {
        size.resize(n+1,1);
        parent.resize(n+1,0);
        for(int i=0;i<n+1;i++) parent[i]=i;
    }
    ll findPar(ll u)
    {
        if(parent[u]==u) return u;
        else return parent[u]=findPar(parent[u]);
    }
    void unionbysize(ll u,ll v)
    {
        ll pu=findPar(u);
        ll pv=findPar(v);
        if(pu==pv) return;
        if(size[pu]<size[pv])
        {
            parent[pu]=pv;
            size[pv]+=size[pu];
        }
        else
        {
            parent[pv]=pu;
            size[pu]+=size[pv];
        }
    }
    ll findsize(ll u)
    {
        ll pu=findPar(u);
        return size[pu];
    }
};
 
// Jai Bajrangbali
 
int main()
{
    fastfast();
    
    ll t;
    cin >> t;

    while(t--){
        ll n;
        cin >> n;

        int two = 0;
        int three = 0;
        int s=0;

        while (n > 0) {
            ll d = n%10;
            n /= 10;
            if(d==2) two++;
            if(d==3) three++;
            s+=d;
        }

        if(s%9==0){
            cout << "YES" << endl;
            continue;
        }

        ll want = 9-(s%9);
        if(want%2!=0) want+=9;

        int flag = 0;
        for (int i=0;i<=min(10,two);i++) {
            for (int j=0;j<=min(10,three);j++) {
                if ((2*i+j*6) == want) {
                    flag=1;
                    break;
                }
            }
            if(flag==1)break;
        }
        if(flag==1){
            print("YES");
            continue;
        }
        print("NO");
    }


 
    return 0;
}