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

Solution 1 (runtime: 77 ms):
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
int main(){
   ll t,ans=0;
   cin>>t;
   string n;
   for(ll i=0; i<t; i++){
      cin>>n;
      ll m=n.size();
      ans=0;
      map<char, ll> map;
      for(ll i=0; i<m; i++){
         ans+=(n[i]-48);
         if(n[i]=='2'){
            map['2']++;
         }
         else if(n[i]=='3'){
            map['3']++;
         }
      }
      ans=ans%9;
      if(ans==0 ){
         cout<<"YES"<<"\n";
         continue;         
      }
      else if(ans==1){
         if(map['2']>=4){
            cout<<"YES"<<"\n";
            continue;
         }
         if(map['3']>=1 && map['2']>=1){
            cout<<"YES"<<"\n";
            continue;
         }
      }
      else if(ans==2){
         if(map['3']>=2 && map['2']>=2){
            cout<<"YES"<<"\n";
            continue;
         }
         if(map['2']>=8){
            cout<<"YES"<<"\n";
            continue;
         }
         if(map['3']>=1 && map['2']>=5){
            cout<<"YES"<<"\n";
            continue;            
         }
      }
      else if(ans==3){
         if(map['3']>=1){
            cout<<"YES"<<"\n";
            continue;            
         }
         if(map['2']>=3){
            cout<<"YES"<<"\n";
            continue;            
         }
      }
      else if(ans==4){
         if(map['3']>=2 && map['2']>=1){
            cout<<"YES"<<"\n";
            continue;            
         }
         if(map['2']>=7){
            cout<<"YES"<<"\n";
            continue;
         }
         if(map['3']>=1 && map['2']>=4){
            cout<<"YES"<<"\n";
            continue;            
         }
      }
      else if(ans==5){
         if(map['2']>=2){
            cout<<"YES"<<"\n";
            continue;
         }
      }
      else if(ans==6){
         if(map['3']>=2 ||map['2']>=6 ){
            cout<<"YES"<<"\n";
            continue;
         }
         if(map['3']>=1 && map['2']>=3){
            cout<<"YES"<<"\n";
            continue;
         }
      }
      else if(ans==7){
         if(map['2']>=1){
            cout<<"YES"<<"\n";
            continue;
         }
      }
      else if(ans==8){
         if(map['2']>=5){
            cout<<"YES"<<"\n";
            continue;
         }
         if(map['3']>=1 && map['2']>=2){
            cout<<"YES"<<"\n";
            continue;
         }
      }
      cout<<"NO"<<"\n";
   }
   return 0;
}

Solution 2 (runtime: 77 ms):
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long long t;
    cin>>t;
    while(t--){
        long long s=0,tw=1,th=1;
        string m;
        cin>>m;
        for(int i=0;i<m.size();i++){
            if(m[i]=='2')
                tw++;
            if(m[i]=='3')
                th++;
            s+=(m[i]-'0');
            // s=s%9;
        }
        long long f=0,l=10;
        for(int i=0;i<tw;i++){
            for(int j=0;j<th;j++){
                if((s+i*2+j*6)%9==0){
                    f=1;
                    break;
                }
            }
            if(f==1)
                break;
        }
        if(f==1)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;   
    }
    return 0;
}