Problem: 2050C - Uninteresting Number
Language: c++17 

Solution 1 (runtime: 46 ms):
#pragma GCC optimize("O3,unroll-loops") // To reduce execution time
// #define ONLINE_JUDGE

// Header files
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp> // PBDS
// #include<ext/pb_ds/tree_policy.hpp> // PBDS

// Namespace
using namespace std;
// using namespace __gnu_pbds; // PBDS

// Define shortcuts for common types
typedef long long ll;
// typedef __int128 ell; // 128 bit integer
typedef unsigned long long ull;
typedef long double lld;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<pll> vpll;
typedef vector<string> vs;
// typedef tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update > pbds; // find_by_order, order_of_key
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define umap unordered_map
#define uset unordered_set

// Fast input/output
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

// Debugging stuff
#ifndef ONLINE_JUDGE
#define debug_level(x, lvl) if (DEBUG_LEVEL >= lvl) cout << "[DEBUG] " << ":" << __LINE__ << " " << #x << " = ", _print(x), cout << endl;
#define debug(x) debug_level(x, 1)
#else
#define debug_level(x, lvl);
#define debug(x);
#endif

const int DEBUG_LEVEL = 3; // Set your debug level (1 = minimal, 3 = verbose)

void _print(ll t) {cout << t;}
void _print(int t) {cout << t;}
void _print(string t) {cout << '"' << t << '"';}
void _print(char t) { cout << "'" << t << "'"; }
void _print(lld t) {cout << t;}
void _print(double t) {cout << t;}
void _print(ull t) {cout << t;}
// For nested or complex data types
template <class T, class V> void _print(pair<T, V> p);
template <class T> void _print(vector<T> v);
template <class T> void _print(set<T> v);
template <class T> void _print(unordered_set<T> v);
template <class T, class V> void _print(map<T, V> v);
template <class T, class V> void _print(unordered_map<T, V> v);
template <class T> void _print(multiset<T> v);
// Definitions for printing complex data types
template <class T, class V> void _print(pair<T, V> p) {cout << "{"; _print(p.first); cout << ", "; _print(p.second); cout << "}";}
template <class T> void _print(vector<T> v) {cout << "[ "; for (T i : v) {_print(i); cout << " ";} cout << "]";}
template <class T> void _print(set<T> v) {cout << "{ "; for (T i : v) {_print(i); cout << " ";} cout << "}";}
template <class T> void _print(unordered_set<T> v) {cout << "{ "; for (T i : v) {_print(i); cout << " ";} cout << "}";}
template <class T, class V> void _print(map<T, V> v) {cout << "{ "; for (auto i : v) {_print(i.first); cout << ": "; _print(i.second); cout << ", ";} cout << "}";}
template <class T, class V> void _print(unordered_map<T, V> v) {cout << "{ "; for (auto i : v) {_print(i.first); cout << ": "; _print(i.second); cout << ", ";} cout << "}";}
template <class T> void _print(multiset<T> v) {cout << "[ "; for (T i : v) {_print(i); cout << " ";} cout << "]";}
// void _print(pbds v) {cout << "[ "; for (auto i : v) {_print(i); cout << " ";} cout << "]";}

// Timer
struct Timer {
#ifndef ONLINE_JUDGE
    chrono::high_resolution_clock::time_point start{chrono::high_resolution_clock::now()};
    ~Timer() {auto end = chrono::high_resolution_clock::now();
        cout << "Execution Time: " << chrono::duration_cast<chrono::milliseconds>(end - start).count() << " ms" << endl;}
#endif
};

void solve()
{
    string n;
    cin >> n;
    ll count2s =0;
    ll count3s = 0;
    ll sum = 0;
    for( int i = 0; i < n.length(); i ++ )
    {
        ll digit = n[i] - '0';
        if( digit == 2 )
            count2s++;
        else if( digit == 3 )
            count3s++;
        sum = (sum+digit)%9;
    }
    for( int i = 0; i <= count2s; i ++ )
    {
        ll temp = sum;
        for( int j = 0; j <= count3s; j ++ )
        {
            if( temp% 9 == 0 )
            {
                cout<<"YES\n";
                return;
            }
            temp+=6;
        }
        sum+=2;
    }
    cout<<"NO\n";

}

int main()
{
    {
        Timer timer;
        FAST_IO

        int t;
        cin >> t;
        while (t--)
            solve();
    }
}

Solution 2 (runtime: 77 ms):
// Online C++ compiler to run C++ program online

#include <bits/stdc++.h>

#define ll long long

using namespace std;



// 3 4 4 5 6 9

// k + x % 9



int main() {

    ll t;cin >> t;



    while(t--){

        string str;

        cin >> str;

        long long sum =0;

        ll two=0;

        ll three =0;

        for(int i=0;i<str.size();i++){

            sum += (str[i]-'0');

            if(str[i]=='2'){

                two++;

            }else if(str[i]=='3'){

                three++;

            }

        }

        // cout << sum << "sum "<<endl;

        int flag = 0;

        if(sum%9==0){

            cout << "YES";

        }else{

            for(int i=9;i<=sum + two*2 + three*6;i+=9){

                if(i>=sum){

                    ll req = i-sum;

                    

                    ll sixReq = req/6;

                    req -= min(sixReq,three)*6;

                    ll tworew = req/2;

                    req -= min(tworew,two)*2;

                    // cout << req <<" " << i<< endl;

                    if(req == 0 ){

                        cout << "YES";

                        flag = 1;

                        break;

                    }

                    // if(tworew >= two){



                    // }

                }

            }

            if(flag==0){

                cout << "NO";

            }

        }

        cout << endl;

    }   

}