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

Solution 1 (runtime: 62 ms):
#include <bits/stdc++.h>

using namespace std;



#define int long long



inline void solve() {

    string s;

    cin>>s;

    int sum=0,x=0,y=0;

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

        if(s[i]=='2')x++;

        if(s[i]=='3')y++;

        sum+=s[i]-'0';

    }

    // sum%=9;

    for(int i=0;i<=min(8ll,x);i++){

        for(int j=0;j<=min(8ll,y);j++){

            if((sum+2*i+6*j)%9==0) {

                cout<<"YES\n";

                return;

            }

        }

    }

    cout<<"NO\n";

}



signed main() {

    ios::sync_with_stdio(0);

    cin.tie(0), cout.tie(0);

    int T;

    cin >> T;

    while (T--) solve();

}

/*

1

11 4

3 2 1 4 4 3 4 2 1 3 3



*/

Solution 2 (runtime: 187 ms):
#include <iostream>

#include <cmath>

#include <list>

#include <vector>

#include <algorithm>

#include <bitset>

#include <string>

#include <set>

#include <map>

#include <queue>

#define ll int64_t

#define int int64_t

#define VI vector<ll>

#define rep(i,a,b) for (int i=a;i<=b;i++)

#define per(i,a,b) for (int i=a;i>=b;i--)

#define load(a) for (auto& x : a) cin >> x

#define unload(a) for(auto x: a) cout << x << " "



using namespace std;

const int N = 2e5+20; ll dp[N], n;

const int mod = 1e9+7;



ll pw(ll a, ll b) {

    if(b == 0) return 1;

    if(b % 2 == 0){

        ll p = pw(a,b/2);

        return p*p%mod;

    }

    if(b%2 == 1){

        ll p = pw(a,b/2);

        return p*p%mod%mod;

    }

}



ll gcd(ll a, ll b){

    if(b == 0) return a;

    else return gcd(b, a%b);

}



void solve(){

    cin >> n;

    ll notPrime[N];

    notPrime[0] = notPrime[1] = true;

    for(int i = 2; i*i <= N; i++){

        if(notPrime[i] == true) continue;

        for(int j = i*2; j < N; j+=i){

            notPrime[j] = true;

        }

    }





    ll ans = 0;

    rep(i,1,n){

        ll a; cin >> a;

        ll res = 1;

        vector<ll> primes;

        for(int j = 1; j * j <= a; j++){

            if(a % j == 0 && !notPrime[j]) primes.push_back(j);

            if(a % j == 0 && !notPrime[a/j] && j != a/j) primes.push_back(a/j);

        }





        if(!primes.empty()){

            rep(j, 0 , primes.size()- 1){

                res = max(res, dp[primes[j]] + 1);

            }

            rep(j, 0, primes.size() - 1){

                dp[primes[j]] = max(dp[primes[j]], res);

            }



            primes.clear();

        }

        ans = max(ans, res);

    }

    cout << ans;

}



int32_t main() {

    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    ll t;

    cin >> t;

    while(t--){

        string s;

        cin >> s;

        set<ll> modulo;

        ll sum = 0;

        rep(i,0,s.length()-1){

            sum += s[i] - '0';

        }

        modulo.insert(sum%9);

        rep(i,0,s.length()-1){

            ll cur = s[i]- '0';

            if(cur == 2){

                set<ll> modCopy;

                for(auto e : modulo){

                    modCopy.insert(e);

                }

                for(auto e:modCopy){

                    modulo.insert((e+2)%9);

                }

            }

            if(cur == 3){

                set<ll> modCopy;

                for(auto e : modulo){

                    modCopy.insert(e);

                }

                for(auto e:modCopy){

                    modulo.insert((e+6)%9);

                }

            }

        }

        if(modulo.find(0) != modulo.end()) cout << "yes" << endl;

        else cout << "no" << endl;

    }

    return 0;

}