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

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define all(a) a.begin(), a.end()
#define pii pair<ll, ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;

void solve(ll n)
{
    string num = to_string(n);
    ll num2 = 0, num3 = 0;
    ll sum = 0;
    for (auto i : num)
    {
        sum += i;
        if (i == '2')
        {
            num2++;
        }
        else if (i == '3')
        {
            num3++;
        }
    }

    ll remain = 9 - (sum % 9);
    // cout << remain << ' ' << num3 << ' ' << num2 << endl;
    if (sum % 9 == 0)
    {
        if (num3 >= 3)
        {
            yes;
        }
        else
        {
            no;
        }
    }
    if (remain == 1)
    {
        if (num2 >= 5 || num3 >= 1 && num2 >= 2)
        {
            yes;
        }
        else
        {
            no;
        }
    }
    if (remain == 2)
    {
        if (num2 >= 1)
        {
            yes;
        }
        else
        {
            no;
        }
    }
    if (remain == 3)
    {
        if (num3 >= 2 || num3 >= 1 && num2 >= 3 || num2 >= 6)
        {
            yes;
        }
        else
        {
            no;
        }
    }
    if (remain == 4)
    {
        if (num2 >= 2)
        {
            yes;
        }
        else
        {
            no;
        }
    }
    if (remain == 5)
    {
        if (num3 >= 2 && num2 >= 1 || num3 >= 1 && num2 >= 4 || num2 >= 7)
        {
            yes;
        }
        else
        {
            no;
        }
    }
    if (remain == 6)
    {
        if (num2 >= 3 || num3 >= 1)
        {
            yes;
        }
        else
        {
            no;
        }
    }
    if (remain == 7)
    {
        if (num3 >= 2 && num2 >= 2 || num3 >= 1 && num2 >= 4 || num2 >= 8)
        {
            yes;
        }
        else
        {
            no;
        }
    }
    if (remain == 8)
    {
        if (num2 >= 4 || num3 >= 1 && num2 >= 1)
        {
            yes;
        }
        else
        {
            no;
        }
    }
}
int main()
{

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

    return 0;
}

Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define all(a) a.begin(), a.end()
#define pii pair<ll, ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;

void solve(ll n)
{
    string num = to_string(n);
    ll num2 = 0, num3 = 0;
    ll sum = 0;
    for (auto i : num)
    {
        sum += i - '0';
        if (i == '2')
        {
            num2++;
        }
        else if (i == '3')
        {
            num3++;
        }
        sum = sum % 9;
    }
    if (sum % 9 == 0)
    {
        yes;
        return;
    }
    for (int i = 0; i <= num2; i++)
    {
        for (int j = 0; j <= num3; j++)
        {
            ll xx = sum + (6 * j) + (2 * i);
            if (xx % 9 == 0)
            {
                yes;
                return;
            }
        }
    }
    no;
}
int main()
{

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

    return 0;
}