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>
    #include<limits.h>
    using namespace std;
    // using namespace __gnu_pbds;

    typedef long long ll;
    typedef vector<int> vi;
    typedef vector<vi> vvi;
    typedef vector<ll> vll;
    typedef pair<int, int> pi;

    int mod = int(1e9 + 7);

    // Operator overloads
    template<typename T1, typename T2> // cin >> pair<T1, T2>
    istream& operator>>(istream &istream, pair<T1, T2> &p) { return (istream >> p.first >> p.second); }
    template<typename T> // cin >> vector<T>
    istream& operator>>(istream &istream, vector<T> &v){for (auto &it : v)cin >> it;return istream;}
    template<typename T1, typename T2> // cout << pair<T1, T2>
    ostream& operator<<(ostream &ostream, const pair<T1, T2> &p) { return (ostream << p.first << " " << p.second); }
    template<typename T> // cout << vector<T>
    ostream& operator<<(ostream &ostream, const vector<T> &c) { for (auto &it : c) cout << it << " "; return ostream; }

    // tree ordered set
    // template<typename T>
    // using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

    void fast() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
    }
    // intersect part of two strings

    // !! ॐ !!
    ll sum(ll n, int &cnt2, int &cnt3) {
        ll sum = 0;
        cnt2 = 0;  // Reset counters
        cnt3 = 0;
        while (n > 0) {
            int digit = n % 10;
            if (digit == 2) cnt2++;
            if (digit == 3) cnt3++;
            sum += digit;
            n /= 10;
        }
        return sum;
    }

    void solve() {
        ll n;
        cin >> n;

        int cnt2 = 0, cnt3 = 0;
        int val = sum(n, cnt2, cnt3);

        if (val % 9 == 0) {
            cout << "YES\n";
            return;
        }

        int c2 = 2, c3 = 6;
        for (int i = 0; i <= min(10, cnt2); i++) {
            for (int j = 0; j <= min(10, cnt3); j++) {
                int k = c2 * i + c3 * j;
                if ((val + k) % 9 == 0) {
                    cout << "YES\n";
                    return;
                }
            }
        }
        cout << "NO\n";
    }


    int main() {
        fast();
        // pre();
        int T=1;
        cin >> T;
        while(T--){
            solve();
        }
        return 0;
    }

Submission (verdict: Accepted):
    #include <bits/stdc++.h>
    // #include<ext/pb_ds/assoc_container.hpp>
    // #include<ext/pb_ds/tree_policy.hpp>
    #include<limits.h>
    using namespace std;
    // using namespace __gnu_pbds;

    typedef long long ll;
    typedef vector<int> vi;
    typedef vector<vi> vvi;
    typedef vector<ll> vll;
    typedef pair<int, int> pi;

    int mod = int(1e9 + 7);

    // Operator overloads
    template<typename T1, typename T2> // cin >> pair<T1, T2>
    istream& operator>>(istream &istream, pair<T1, T2> &p) { return (istream >> p.first >> p.second); }
    template<typename T> // cin >> vector<T>
    istream& operator>>(istream &istream, vector<T> &v){for (auto &it : v)cin >> it;return istream;}
    template<typename T1, typename T2> // cout << pair<T1, T2>
    ostream& operator<<(ostream &ostream, const pair<T1, T2> &p) { return (ostream << p.first << " " << p.second); }
    template<typename T> // cout << vector<T>
    ostream& operator<<(ostream &ostream, const vector<T> &c) { for (auto &it : c) cout << it << " "; return ostream; }

    // tree ordered set
    // template<typename T>
    // using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

    void fast() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
    }
    // intersect part of two strings

    // !! ॐ !!
    ll sum(string n, int &cnt2, int &cnt3) {
        ll sum = 0;
        cnt2 = 0;
        cnt3 = 0;
        for(char c:n){
            int digit = c - '0';
            sum += digit;
            if(digit == 2) cnt2++;
            if(digit == 3) cnt3++;
        }
        return sum;
    }

    void solve() {
        string n;
        cin >> n;

        int cnt2 = 0, cnt3 = 0;
        int val = sum(n, cnt2, cnt3);

        if (val % 9 == 0) {
            cout << "YES\n";
            return;
        }

        int c2 = 2, c3 = 6;
        for (int i = 0; i <= min(10, cnt2); i++) {
            for (int j = 0; j <= min(10, cnt3); j++) {
                int k = c2 * i + c3 * j;
                if ((val + k) % 9 == 0) {
                    cout << "YES\n";
                    return;
                }
            }
        }
        cout << "NO\n";
    }


    int main() {
        fast();
        // pre();
        int T=1;
        cin >> T;
        while(T--){
            solve();
        }
        return 0;
    }