Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):

// ॐ
//---------------------------------------------------------------------------------------------------------------------------------------------------------------

#include <bits/stdc++.h>
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define endll '\n'
#define print(x) cout << x << endll
#define py cout << "YES\n"
#define pn cout << "NO\n"
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define fer(i, a, b) for (ll i = a; i <= b; i++)
#define frr(i, a, b) for (ll i = a; i >= b; i--)
#define pb push_back
#define ff first
#define ss second
#define sz size()
#define int int64_t
#define all(v) v.begin(), v.end()
#define all_rev(v) v.rbegin(), v.rend()
#define vecp(v)           \
    for (auto i : v)      \
        cout << i << ' '; \
    cout << endll
#define vecpp(v)     \
    for (auto i : v) \
    cout << i.ff << ' ' << i.ss << endl
#define take(x) \
    int x;      \
    cin >> x
#define popcnt(n) __builtin_popcountll(n)
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define debug(x) cout << #x << ' ' << x << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvll = vector<vll>;
using stll = set<ll>;
using mpll = map<ll, ll>;
using mpvll = map<ll, vll>;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const ll N = 2e5 + 10;

// priority_queue <int, vector<int>, greater<int> > p;
//  __builtin_clz(x): the number of zeros at the beginning of the number
//  __builtin_ctz(x): the number of zeros at the end of the number
//  __builtin_popcountll(x): the number of ones in the number
//  __builtin_parity(x): the parity (even or odd) of the number of ones
//  __builtin_ffs(int) finds the index of the first (most right) set bit
void init_code()
{
    fast_io;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
#ifndef ONLINE_JUDGE
    freopen("error.txt", "w", stderr);
#endif
}
bool isPrime(const ll n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 or n % 3 == 0)
        return false;
    for (ll i = 5; i * i <= n; i += 6)
        if (n % i == 0 or n % (i + 2) == 0)
            return false;
    return true;
}
ull power(ll x, ll y)
{
    ull res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % MOD;
        x = (x * x) % MOD;
        y >>= 1;
    }
    return res;
}
ull modInvPow(const ll n)
{
    return power(n, MOD - 2);
}
bool sortByCond(const pair<ll, ll> &a, const pair<ll, ll> &b)
{
    /*
        if (a.ff == b.ff)
            return a.ss < b.ss;
        else
            return a.ff < b.ff;
    */
    return a.ss < b.ss;
}

void ramram()
{
    string s;
    cin >> s;
    int sum = 0;
    int cnt2 = 0, cnt3 = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == '2')
            cnt2++;
        if (s[i] == '3')
            cnt3++;
        sum += s[i] - '0';
    }
    int rem = sum % 9;
    rem = 9 - rem;
    // cout << cnt2 << " " << cnt3 << " " << rem << endl;
    if (sum % 9 == 0)
    {
        py;
        return;
    }
    if (cnt2 == 0 && cnt3 == 0)
    {
        pn;
        return;
    }
    if (cnt2 >= 2 && cnt3 >= 2)
    {
        py;
        return;
    }
    if (cnt2 == 1 && cnt3 >= 2)
    {
        int tt = sum;
        for (int i = 0; i < cnt3; i++)
        {
            tt += 6;
            if (tt % 9 == 0 || (tt + 2) % 9 == 0)
            {
                py;
                return;
            }
        }
        pn;
        return;
    }
    if (cnt2 >= 2 && cnt3 == 1)
    {
        int tt = sum;
        for (int i = 0; i < cnt2; i++)
        {
            tt += 2;
            if (tt % 9 == 0 || (tt + 6) % 9 == 0)
            {
                py;
                return;
            }
        }
        pn;
        return;
    }
    if (cnt2 == 1 && cnt3 == 1)
    {
        if (rem == 2 || rem == 6 || rem == 8)
        {
            py;
            return;
        }
        else
        {
            pn;
            return;
        }
    }
    if (cnt2 == 0)
    {
        int tt = sum;
        for (int i = 0; i < cnt3; i++)
        {
            tt += 6;
            if (tt % 9 == 0)
            {
                py;
                return;
            }
        }
        pn;
        return;
    }
    if (cnt3 == 0)
    {
        int tt = sum;
        for (int i = 0; i < cnt2; i++)
        {
            tt += 2;
            if (tt % 9 == 0)
            {
                py;
                return;
            }
        }
        pn;
        return;
    }
    pn;
    return;
}

int32_t main()
{
    init_code();
    fast_io;
    ll t = 1;
    cin >> t;
    while (t--)
        ramram();
    return 0;
}

Submission (verdict: Wrong answer on test 2):

// ॐ
//---------------------------------------------------------------------------------------------------------------------------------------------------------------

#include <bits/stdc++.h>
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define endll '\n'
#define print(x) cout << x << endll
#define py cout << "YES\n"
#define pn cout << "NO\n"
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define fer(i, a, b) for (ll i = a; i <= b; i++)
#define frr(i, a, b) for (ll i = a; i >= b; i--)
#define pb push_back
#define ff first
#define ss second
#define sz size()
#define int int64_t
#define all(v) v.begin(), v.end()
#define all_rev(v) v.rbegin(), v.rend()
#define vecp(v)           \
    for (auto i : v)      \
        cout << i << ' '; \
    cout << endll
#define vecpp(v)     \
    for (auto i : v) \
    cout << i.ff << ' ' << i.ss << endl
#define take(x) \
    int x;      \
    cin >> x
#define popcnt(n) __builtin_popcountll(n)
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define debug(x) cout << #x << ' ' << x << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvll = vector<vll>;
using stll = set<ll>;
using mpll = map<ll, ll>;
using mpvll = map<ll, vll>;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const ll N = 2e5 + 10;

// priority_queue <int, vector<int>, greater<int> > p;
//  __builtin_clz(x): the number of zeros at the beginning of the number
//  __builtin_ctz(x): the number of zeros at the end of the number
//  __builtin_popcountll(x): the number of ones in the number
//  __builtin_parity(x): the parity (even or odd) of the number of ones
//  __builtin_ffs(int) finds the index of the first (most right) set bit
void init_code()
{
    fast_io;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
#ifndef ONLINE_JUDGE
    freopen("error.txt", "w", stderr);
#endif
}
bool isPrime(const ll n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 or n % 3 == 0)
        return false;
    for (ll i = 5; i * i <= n; i += 6)
        if (n % i == 0 or n % (i + 2) == 0)
            return false;
    return true;
}
ull power(ll x, ll y)
{
    ull res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % MOD;
        x = (x * x) % MOD;
        y >>= 1;
    }
    return res;
}
ull modInvPow(const ll n)
{
    return power(n, MOD - 2);
}
bool sortByCond(const pair<ll, ll> &a, const pair<ll, ll> &b)
{
    /*
        if (a.ff == b.ff)
            return a.ss < b.ss;
        else
            return a.ff < b.ff;
    */
    return a.ss < b.ss;
}

void ramram()
{
    string s;
    cin >> s;
    int sum = 0;
    int cnt2 = 0, cnt3 = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == '2')
            cnt2++;
        if (s[i] == '3')
            cnt3++;
        sum += s[i] - '0';
    }
    int rem = sum % 9;
    rem = 9 - rem;
    // cout << cnt2 << " " << cnt3 << " " << rem << endl;
    if (sum % 9 == 0)
    {
        py;
        return;
    }
    if (cnt2 == 0 && cnt3 == 0)
    {
        pn;
        return;
    }
    if (cnt2 >= 2 && cnt3 >= 2)
    {
        py;
        return;
    }
    if (cnt2 == 1 && cnt3 >= 2)
    {
        int tt = sum;
        for (int i = 0; i < cnt3; i++)
        {
            tt += 6;
            if (tt % 9 == 0 || (tt + 2) % 9 == 0)
            {
                py;
                return;
            }
        }
        pn;
        return;
    }
    if (cnt2 >= 2 && cnt3 == 1)
    {
        int tt = sum;
        for (int i = 0; i < cnt2; i++)
        {
            tt += 2;
            if (tt % 9 == 0 || (tt + 6) % 9 == 0)
            {
                py;
                return;
            }
        }
        pn;
        return;
    }
    if (cnt2 == 1 && cnt3 == 1)
    {
        if (rem == 2 || rem == 6 || rem == 8)
        {
            py;
            return;
        }
        else
        {
            pn;
            return;
        }
    }
    if (cnt2 == 0)
    {
        int tt = sum;
        for (int i = 0; i < cnt3; i++)
        {
            tt += 6;
            if (tt % 9 == 0)
            {
                py;
                return;
            }
        }
        pn;
        return;
    }
    if (cnt3 == 0)
    {
        int tt = sum;
        for (int i = 0; i < cnt2; i++)
        {
            tt += 2;
            if (tt % 9 == 0)
            {
                py;
                return;
            }
        }
        pn;
        return;
    }
    cout<<"hii"<<endl;
    return;
}

int32_t main()
{
    init_code();
    fast_io;
    ll t = 1;
    cin >> t;
    while (t--)
        ramram();
    return 0;
}