Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

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

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
 #define int long long
const int MOD = 1e9 + 7;


#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define debug(x)
#endif

//void _print(long long t) {cerr << t;}
void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(long  double t) {cerr << t;}
void _print(double t) {cerr << t;}
void _print(unsigned long long t) {cerr << t;}

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, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}


signed main(){
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
 #ifndef ONLINE_JUDGE
  freopen("Error.txt", "w", stderr);
#endif


  int t;
  cin>>t;
  while(t--){
     string s; cin>>s;
    debug("STTTTTTTTTTTTTTTT")
    map<char,int> mp;
    debug(s)
    int sum =0;
    for(char c : s){
        debug(c)
        mp[c]++;
        sum = (sum + ( c- '0'))%9;
        debug(sum)
    }   
    if(sum%9 ==0){
        cout<<"YES"<<endl;
    }
    else {
        debug(sum)
        int a= mp['3'],b = mp['2'];
        debug(a)
        debug(mp)
        int rem = 9 - (sum % 9);
    debug(rem)
      map<int,int> av,bv;
      for(int i =0;i<=a;i++){
        av[((i*6)%9)]++;
      }
      debug(av)
      for(int i =0;i<=b;i++){
        int ss= (i*2)%9;
        bv[(i*2)%9]++;
        if(av[rem - ss+9] >0){
            rem =0; break;
        }

      }
      for(int i=0;i<=a;i++){
        int ss= (i*6)%9;
        if(bv[rem - ss+9] > 0){
            rem =0; break;
        }
      }
        if(rem ==0)cout<<"YES"<<endl; else cout<<"NO"<<endl;

    }
    
}
}





Submission (verdict: Accepted):

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
 #define int long long
const int MOD = 1e9 + 7;


#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define debug(x)
#endif

//void _print(long long t) {cerr << t;}
void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(long  double t) {cerr << t;}
void _print(double t) {cerr << t;}
void _print(unsigned long long t) {cerr << t;}

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, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}


signed main(){
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
 #ifndef ONLINE_JUDGE
  freopen("Error.txt", "w", stderr);
#endif


  int t;
  cin>>t;
  while(t--){
     string s; cin>>s;
    debug("STTTTTTTTTTTTTTTT")
    map<char,int> mp;
    debug(s)
    int sum =0;
    for(char c : s){
        debug(c)
        mp[c]++;
        sum = (sum + ( c- '0'))%9;
        debug(sum)
    }   
    if(sum%9 ==0){
        cout<<"YES"<<endl;
    }
    else {
        debug(sum)
        int a= mp['3'],b = mp['2'];
        debug(a)
        debug(mp)
        int rem = 9 - (sum % 9);
    debug(rem)
      map<int,int> av,bv;
      for(int i =0;i<=a;i++){
        av[((i*6)%9)]++;
      }
      debug(av)
      for(int i =0;i<=b;i++){
        int ss= (i*2)%9;
        bv[(i*2)%9]++;
        if(av[(rem - ss+9)%9] >0){
            rem =0; break;
        }

      }
      for(int i=0;i<=a;i++){
        int ss= (i*6)%9;
        if(bv[(rem - ss+9)%9] > 0){
            rem =0; break;
        }
      }
        if(rem ==0)cout<<"YES"<<endl; else cout<<"NO"<<endl;

    }
    
}
}