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

Previous submission (verdict: Wrong answer on test 3):
// Author: Youssef ben youssef
// Template for Competitive Programming

#include<utility>
#include<map>
#include<unordered_map>
#include<vector>
#include<set>
#include<ios>
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<long long>;
using pi = pair<int, int>;
using pll = pair<long long, long long>;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;
const ld EPS = 1e-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) ((int)(x).size())
ll mod_exp(ll base, ll exp, ll mod = MOD) {
    ll res = 1;
    while (exp) {
        if (exp & 1) res = (res * base) % mod;
        base = (base * base) % mod;
        exp >>= 1;
    }
    return res;
}
ll min(ll a,int b) { if (a<b) return a; return b; }
ll min(int a,ll b) { if (a<b) return a; return b; }
ll max(ll a,int b) { if (a>b) return a; return b; }
ll max(int a,ll b) { if (a>b) return a; return b; }
ll gcd(ll a,ll b) { if (b==0) return a; return gcd(b, a%b); }
ll exgcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = exgcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
string to_upper(string a) { for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A'; return a; }
string to_lower(string a) { for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A'; return a; }
bool prime(ll a) { if (a==1) return 0; for (int i=2;i<=round(sqrt(a));++i) if (a%i==0) return 0; return 1; }
void yes() { cout<<"YES\n"; }
void no() { cout<<"NO\n"; }
template <typename T>
void read(vector<T>& v) {
    for (auto& x : v) cin >> x;
}

template <typename T>
void print(const vector<T>& v) {
    for (const auto& x : v) cout << x << ' ';
    cout << '\n';
}
void solve() {
    
}

int main() {
    fastio;
    int t;
    cin >> t;
    while (t--)
    {
        string s;cin >> s;
        ll sum=0,twos=0,threes=0;
        for (ll i = 0; i < s.size(); i++)
        {
            sum+= s[i]-'0';
            if(s[i]-'0'==2)twos++;
            if(s[i]-'0'==3)threes++;
        }
        int f=0;
        for (ll i = 0; i <min(10,twos+1); i++)
        {
            for (ll j = 0; j < min(10,threes+1); j++)
            {
                if((sum+i*2+6*j)%9==0){yes();f=1;break;}
                if(f)break;
            }
        }
        if(!f)no();
        
        

    }
    
    return 0;
}


Submission (verdict: Wrong answer on test 3):
// Author: Youssef ben youssef
// Template for Competitive Programming

#include<utility>
#include<map>
#include<unordered_map>
#include<vector>
#include<set>
#include<ios>
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<long long>;
using pi = pair<int, int>;
using pll = pair<long long, long long>;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;
const ld EPS = 1e-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) ((int)(x).size())
ll mod_exp(ll base, ll exp, ll mod = MOD) {
    ll res = 1;
    while (exp) {
        if (exp & 1) res = (res * base) % mod;
        base = (base * base) % mod;
        exp >>= 1;
    }
    return res;
}
ll min(ll a,int b) { if (a<b) return a; return b; }
ll min(int a,ll b) { if (a<b) return a; return b; }
ll max(ll a,int b) { if (a>b) return a; return b; }
ll max(int a,ll b) { if (a>b) return a; return b; }
ll gcd(ll a,ll b) { if (b==0) return a; return gcd(b, a%b); }
ll exgcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = exgcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
string to_upper(string a) { for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A'; return a; }
string to_lower(string a) { for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A'; return a; }
bool prime(ll a) { if (a==1) return 0; for (int i=2;i<=round(sqrt(a));++i) if (a%i==0) return 0; return 1; }
void yes() { cout<<"YES\n"; }
void no() { cout<<"NO\n"; }
template <typename T>
void read(vector<T>& v) {
    for (auto& x : v) cin >> x;
}

template <typename T>
void print(const vector<T>& v) {
    for (const auto& x : v) cout << x << ' ';
    cout << '\n';
}
void solve() {
    
}

int main() {
    fastio;
    int t;
    cin >> t;
    while (t--)
    {
        string s;cin >> s;
        ll x1 ,x2;
        
        ll sum=0,twos=0,threes=0;
        for (ll i = 0; i < s.size(); i++)
        {
            sum+= s[i]-'0';
            if(s[i]-'0'==2)twos++;
            if(s[i]-'0'==3)threes++;
            sum%=9;
        }
        int f=0;
        for (ll i = 0; i <=min(10,twos); i++)
        {
            for (ll j = 0; j <= min(10,threes); j++)
            {
                ll tsum =sum+i*2+6*j;
                if(tsum%9==0){yes();f=1;break;}
                if(f)break;
            }
        }
        if(!f)no();
        
        

    }
    
    return 0;
}