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

Previous submission (verdict: Wrong answer on test 3):
// 1

#include <bits/stdc++.h>
using namespace std;

const long long MOD = 1e9+7;
const int N = 1e6 + 10;
#define MIN_IN(A) *(std::min_element(A.begin(), A.end()))
#define MAX_IN(A) *(std::max_element(A.begin(), A.end()))
#define MAX_AT(A) (std::max_element(A.begin(), A.end()) - A.begin())
#define MIN_AT(A) (std::min_element(A.begin(), A.end()) - A.begin())
#define pb push_back
#define SORT(A) std::sort(A.begin(), A.end())
#define RSORT(A) std::sort(A.rbegin(), A.rend())
#define REVERSE(A) std::reverse(A.begin(), A.end())
#define VECIN(A,n) for(int i = 0; i < n; i++) { cin >> A[i]; }
#define VECIN1(A,n) for(int i = 1; i <=n; i++) { cin >> A[i]; }
#define VECOUT(A) for(int i = 0; i < A.size(); i++) { cout << A[i] << " "; } cout << endl;
#define COUT(A) cout << A << endl;
#define ll long long
#define ull unsigned long long
#define D double
#define UI unsigned int
#define Y1 cout<<"yes"<<endl
#define N1 cout<<"no"<<endl


ll power(ll x, ll y) {
    ll res = 1;
    x = x % MOD; 
    while (y > 0) {  
        if (y & 1) 
            res = (res * x) % MOD;  
        y = y >> 1;
        x = (x * x) % MOD;   
    } 
    return res; 
}

ll __gcd(ll a, ll b) { 
    if (b == 0) 
    { 
        return a; 
    } 
    return __gcd(b, a % b); 
}

ll __LCM(ll a, ll b){
    return (a * b) / __gcd(a, b);
}

ll xorn(int n){
    if(n % 4 == 0) return n;
    if(n % 4 == 3) return 0;
    if(n % 4 == 1) return 1;
    return n ^ 1;
}

bool ispalindrome(string s){
    int si = s.size();
    for(int i = 0; i < si / 2; i++){
        if(s[i] != s[si - 1 - i]) return false;
    }
    return true;
}

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

    ll no2=0,no3=0,sum=0;

    while(n!=0)
    {
        int a=n%10;
        if(a==2) no2++;
        else if(a==3) no3++;
        n/=10;
        sum+=a;
    }



    for(int i=0;i<=no2;i++)
    {
        for(int j=0;j<=no3;j++)
        {
            
            if((sum+2*i+6*j)%9==0) 
            {
                COUT("yes");
                return;
            }
        }
    }
    COUT("NO");

}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--) 
    {
        solve();
    }
    return 0;
}


Submission (verdict: Wrong answer on test 1):
// 1

#include <bits/stdc++.h>
using namespace std;

const long long MOD = 1e9+7;
const int N = 1e6 + 10;
#define MIN_IN(A) *(std::min_element(A.begin(), A.end()))
#define MAX_IN(A) *(std::max_element(A.begin(), A.end()))
#define MAX_AT(A) (std::max_element(A.begin(), A.end()) - A.begin())
#define MIN_AT(A) (std::min_element(A.begin(), A.end()) - A.begin())
#define pb push_back
#define SORT(A) std::sort(A.begin(), A.end())
#define RSORT(A) std::sort(A.rbegin(), A.rend())
#define REVERSE(A) std::reverse(A.begin(), A.end())
#define VECIN(A,n) for(int i = 0; i < n; i++) { cin >> A[i]; }
#define VECIN1(A,n) for(int i = 1; i <=n; i++) { cin >> A[i]; }
#define VECOUT(A) for(int i = 0; i < A.size(); i++) { cout << A[i] << " "; } cout << endl;
#define COUT(A) cout << A << endl;
#define ll long long
#define ull unsigned long long
#define D double
#define UI unsigned int
#define Y1 cout<<"yes"<<endl
#define N1 cout<<"no"<<endl


ll power(ll x, ll y) {
    ll res = 1;
    x = x % MOD; 
    while (y > 0) {  
        if (y & 1) 
            res = (res * x) % MOD;  
        y = y >> 1;
        x = (x * x) % MOD;   
    } 
    return res; 
}

ll __gcd(ll a, ll b) { 
    if (b == 0) 
    { 
        return a; 
    } 
    return __gcd(b, a % b); 
}

ll __LCM(ll a, ll b){
    return (a * b) / __gcd(a, b);
}

ll xorn(int n){
    if(n % 4 == 0) return n;
    if(n % 4 == 3) return 0;
    if(n % 4 == 1) return 1;
    return n ^ 1;
}

bool ispalindrome(string s){
    int si = s.size();
    for(int i = 0; i < si / 2; i++){
        if(s[i] != s[si - 1 - i]) return false;
    }
    return true;
}

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

    ll no2=0,no3=0,sum=0;

    for(auto e:n)
    {
        if(e=='2') no2++;
        else if(e=='3') no3++;
        sum+=int(e);
    }



    for(int i=0;i<=no2;i++)
    {
        for(int j=0;j<=no3;j++)
        {
            
            if((sum+2*i+6*j)%9==0) 
            {
                COUT("yes");
                return;
            }
        }
    }
    COUT("NO");

}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--) 
    {
        solve();
    }
    return 0;
}