Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

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

/*
 *
 *@author - pred695
 *
 */
/*弱い も
خاک سے آیا ہوں، خاک بنوں گا۔*/
/*-------------------------------------------****************-------------------------------------------------------****************----------------------------------------------------------------------*/
#include <bits/stdc++.h>
using namespace std;
#define vi                          vector<int>
#define vvi                         vector<vector<int>> 
#define pb                          push_back
#define eb                          emplace_back
#define pii                         pair<int, int>
#define vp                          vector<pii>
#define ppb                         pop_back
#define pf                          push_front
#define ppf                         pop_front
#define int                         long long
#define ull                         unsigned long long
#define lld                         long double
#define all(x)                      x.begin(),x.end()
#define rep(i, a, b)                for(int i = a; i < b; i++)
#define repr(i, a, b)               for(int i = a; i >= b; i--)
#define read(a, n)                  rep(i, 0, n)    cin >> a[i]
#define readx(a, n, m)              rep(i, 0, n){rep(j, 0, m) cin >> a[i][j];}
#define print(a, n)                 rep(i, 0, n)    cout << a[i] << " "; cout << endl
#define printx(a, n, m)             rep(i, 0, n){rep(j, 0, m) cout << a[i][j] << " "; cout << endl;}
#define endl                        "\n"
#define ff                          first
#define ss                          second
#define yes                         cout << "YES" << endl
#define no                          cout << "NO" << endl
#define M                           1000000007
#define prec(x)                     cout << fixed << setprecision(x)
#define bpc(x)                      __builtin_popcountll(x)
#define sz(x)                       (int)(x.size())
#define bpl(x)                      __builtin_clzll(x)
#define bpt(x)                      __builtin_ctzll(x)
#define lg(x)                      __lg(x)

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<": "; deb(x); cerr << endl;
#else
#define debug(x)
#endif
 
void deb(int t) {cerr << t;}
void deb(string t) {cerr << t;}
void deb(char t) {cerr << t;}
void deb(double t) {cerr << t;}
void deb(ull t) {cerr << t;}

template <class T, class V> void deb(pair <T, V> p) {cerr << "{"; deb(p.ff); cerr << ","; deb(p.ss); cerr << "}";}
template <class T> void deb(vector <T> v) {cerr << "[ "; for (T i : v) {deb(i); cerr << " ";} cerr << "]";}
template <class T> void deb(set <T> v) {cerr << "[ "; for (T i : v) {deb(i); cerr << " ";} cerr << "]";}
template <class T> void deb(multiset <T> v) {cerr << "[ "; for (T i : v) {deb(i); cerr << " ";} cerr << "]";}
template <class T, class V> void deb(map <T, V> v) {cerr << "[ "; for (auto i : v) {deb(i); cerr << " ";} cerr << "]";}
template <class T, class V> void deb(map<T, vector<V>> v) {cerr << "{ "; for (auto i : v) {cerr  << i.first << ": ";deb(i.second);cerr << " ";}cerr << "}";}
template <class T> void deb(priority_queue<T> pq) {cerr << "[ "; while (!pq.empty()) {deb(pq.top()); cerr << " "; pq.pop();} cerr << "]";} 
template <class T> void deb(deque<T> dq) {cerr << "[ "; for (T i : dq) {deb(i); cerr << " ";} cerr << "]";} 
template <class T> void deb(list<T> lst) {cerr << "[ "; for (T i : lst) {deb(i); cerr << " ";} cerr << "]";} 
template <class T, class V> void deb(unordered_map<T, V> um) {cerr << "{ "; for (auto i : um) {cerr << i.first << ": "; deb(i.second); cerr << " ";} cerr << "}";}

void fast(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
int ipow(int a, int b){
   int ans = 1;
   while(b)
   {
    if(b & 1)
    ans = (ans*a)%M;
    a = (a*a)%M;
    b>>=1;
   }
   return ans;
}
clock_t start;
void exectime(){
    clock_t end=clock();
    double time_taken = double(end - start) / double(CLOCKS_PER_SEC);
    #ifndef ONLINE_JUDGE
    cout << endl;
    cout << endl;
    cout << "Executed in "<< fixed << time_taken << setprecision(10);
    cout << " secs " << endl;
    #endif
}
const int d4x[4]={-1, 0, 1, 0}, d4y[4]={0, 1, 0, -1};
const int d8x[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8y[8]={0, 1, 1, 1, 0, -1, -1, -1};
const int c8x[8]={-2, -1, 1, 2, 2, 1, -1, -2}, c8y[8]={1, 2, 2, 1, -1, -2, -2, -1};
vector<int> custom_c8x(8, 0), custom_c8y(8, 0);
void make_custom_movements(int a, int b){
    custom_c8x={b, -b, b, -b, a, -a, a, -a};
    custom_c8y={a, a, -a, -a, b, b, -b, -b};
}

struct custom_priority{
    bool operator() (pii &a, pii &b){
        if(a.ff == b.ff){
            return a.ss < b.ss;
        }
      return a.ff > b.ff;
    }
};

const int N = 1e7 + 10;

/*----------------------------------------------------------------------MAIN CODE------------------------------------------------------------------------------------------------------------------------*/
void solve(){
    int n;
    cin >> n;
    int s = 0;
    unordered_map<int, int> mp;
    mp[2] = 0;
    mp[3] = 0;
    while(n > 0) {
        s += n % 10;
        mp[n % 10]++;
        n /= 10;
    }
    // only two and three needs to be considered.
    if(s % 9 == 0) {
        yes;
        return;
    }
    int temp = s;
    debug(s)
    debug(mp[2])
    debug(mp[3])
    for(int i = 0; i <= min(mp[2], 8LL); i++) {
        s += i * 2; 
        for(int j = 0; j <= min(mp[3], 8LL); j++) {
            debug(j)
            debug(i)
            debug(s + 6 * j)
            if((s + (j * 6)) % 9 == 0) {
                yes;
                return;
            }
        }
        s = temp;
    }
    no;

    
}
/*----------------------------------------------------------------------ありがと-------------------------------------------------------------------------------------------------------------------------*/
signed main(){
fast();
int t = 1;
cin >> t;
start = clock();
for(int i = 0; i < t; i++){
    // cout << "Case #" << i + 1 << ": ";
    solve();
}
exectime();
return 0;
}

Submission (verdict: Wrong answer on test 3):

/*
 *
 *@author - pred695
 *
 */
/*弱い も
خاک سے آیا ہوں، خاک بنوں گا۔*/
/*-------------------------------------------****************-------------------------------------------------------****************----------------------------------------------------------------------*/
#include <bits/stdc++.h>
using namespace std;
#define vi                          vector<int>
#define vvi                         vector<vector<int>> 
#define pb                          push_back
#define eb                          emplace_back
#define pii                         pair<int, int>
#define vp                          vector<pii>
#define ppb                         pop_back
#define pf                          push_front
#define ppf                         pop_front
#define int                         long long
#define ull                         unsigned long long
#define lld                         long double
#define all(x)                      x.begin(),x.end()
#define rep(i, a, b)                for(int i = a; i < b; i++)
#define repr(i, a, b)               for(int i = a; i >= b; i--)
#define read(a, n)                  rep(i, 0, n)    cin >> a[i]
#define readx(a, n, m)              rep(i, 0, n){rep(j, 0, m) cin >> a[i][j];}
#define print(a, n)                 rep(i, 0, n)    cout << a[i] << " "; cout << endl
#define printx(a, n, m)             rep(i, 0, n){rep(j, 0, m) cout << a[i][j] << " "; cout << endl;}
#define endl                        "\n"
#define ff                          first
#define ss                          second
#define yes                         cout << "YES" << endl
#define no                          cout << "NO" << endl
#define M                           1000000007
#define prec(x)                     cout << fixed << setprecision(x)
#define bpc(x)                      __builtin_popcountll(x)
#define sz(x)                       (int)(x.size())
#define bpl(x)                      __builtin_clzll(x)
#define bpt(x)                      __builtin_ctzll(x)
#define lg(x)                      __lg(x)

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<": "; deb(x); cerr << endl;
#else
#define debug(x)
#endif
 
void deb(int t) {cerr << t;}
void deb(string t) {cerr << t;}
void deb(char t) {cerr << t;}
void deb(double t) {cerr << t;}
void deb(ull t) {cerr << t;}

template <class T, class V> void deb(pair <T, V> p) {cerr << "{"; deb(p.ff); cerr << ","; deb(p.ss); cerr << "}";}
template <class T> void deb(vector <T> v) {cerr << "[ "; for (T i : v) {deb(i); cerr << " ";} cerr << "]";}
template <class T> void deb(set <T> v) {cerr << "[ "; for (T i : v) {deb(i); cerr << " ";} cerr << "]";}
template <class T> void deb(multiset <T> v) {cerr << "[ "; for (T i : v) {deb(i); cerr << " ";} cerr << "]";}
template <class T, class V> void deb(map <T, V> v) {cerr << "[ "; for (auto i : v) {deb(i); cerr << " ";} cerr << "]";}
template <class T, class V> void deb(map<T, vector<V>> v) {cerr << "{ "; for (auto i : v) {cerr  << i.first << ": ";deb(i.second);cerr << " ";}cerr << "}";}
template <class T> void deb(priority_queue<T> pq) {cerr << "[ "; while (!pq.empty()) {deb(pq.top()); cerr << " "; pq.pop();} cerr << "]";} 
template <class T> void deb(deque<T> dq) {cerr << "[ "; for (T i : dq) {deb(i); cerr << " ";} cerr << "]";} 
template <class T> void deb(list<T> lst) {cerr << "[ "; for (T i : lst) {deb(i); cerr << " ";} cerr << "]";} 
template <class T, class V> void deb(unordered_map<T, V> um) {cerr << "{ "; for (auto i : um) {cerr << i.first << ": "; deb(i.second); cerr << " ";} cerr << "}";}

void fast(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
int ipow(int a, int b){
   int ans = 1;
   while(b)
   {
    if(b & 1)
    ans = (ans*a)%M;
    a = (a*a)%M;
    b>>=1;
   }
   return ans;
}
clock_t start;
void exectime(){
    clock_t end=clock();
    double time_taken = double(end - start) / double(CLOCKS_PER_SEC);
    #ifndef ONLINE_JUDGE
    cout << endl;
    cout << endl;
    cout << "Executed in "<< fixed << time_taken << setprecision(10);
    cout << " secs " << endl;
    #endif
}
const int d4x[4]={-1, 0, 1, 0}, d4y[4]={0, 1, 0, -1};
const int d8x[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8y[8]={0, 1, 1, 1, 0, -1, -1, -1};
const int c8x[8]={-2, -1, 1, 2, 2, 1, -1, -2}, c8y[8]={1, 2, 2, 1, -1, -2, -2, -1};
vector<int> custom_c8x(8, 0), custom_c8y(8, 0);
void make_custom_movements(int a, int b){
    custom_c8x={b, -b, b, -b, a, -a, a, -a};
    custom_c8y={a, a, -a, -a, b, b, -b, -b};
}

struct custom_priority{
    bool operator() (pii &a, pii &b){
        if(a.ff == b.ff){
            return a.ss < b.ss;
        }
      return a.ff > b.ff;
    }
};

const int N = 1e7 + 10;

/*----------------------------------------------------------------------MAIN CODE------------------------------------------------------------------------------------------------------------------------*/
void solve(){
    int n;
    cin >> n;
    int s = 0;
    unordered_map<int, int> mp;
    mp[2] = 0;
    mp[3] = 0;
    while(n > 0) {
        s += n % 10;
        mp[n % 10]++;
        n /= 10;
    }
    // only two and three needs to be considered.
    if(s % 9 == 0) {
        yes;
        return;
    }
    int temp = s;
    debug(s)
    debug(mp[2])
    debug(mp[3])
    for(int i = 0; i <= min(mp[2], 10LL); i++) {
        s += i * 2; 
        for(int j = 0; j <= min(mp[3], 10LL); j++) {
            debug(j)
            debug(i)
            debug(s + 6 * j)
            if((s + (j * 6)) % 9 == 0) {
                yes;
                return;
            }
        }
        s = temp;
    }
    no;

    
}
/*----------------------------------------------------------------------ありがと-------------------------------------------------------------------------------------------------------------------------*/
signed main(){
fast();
int t = 1;
cin >> t;
start = clock();
for(int i = 0; i < t; i++){
    // cout << "Case #" << i + 1 << ": ";
    solve();
}
exectime();
return 0;
}