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

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
std::set<ll> generateSums(int count2, int count3) {
    std::set<ll> sums;

    // Iterate through all possible numbers of 2s (0 to count2)
    for (int i = 0; i <= count2; ++i) {
        // Iterate through all possible numbers of 3s (0 to count3)
        for (int j = 0; j <= count3; ++j) {
            // Calculate the sum for the current combination
            ll sum =(ll)i * 2 + (ll)j * 6;
            sums.insert(sum);
        }
    }

    return sums;
}
int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin.exceptions(cin.failbit);
    // Log output to console
    int t;
         cin >> t;

 while(t--){
    string s;
    cin >> s;
    int c2=0;
    int c3=0;
    rep(i,0,s.size()){
       if(s[i]=='2') c2++;
       if(s[i]=='3') c3++;
    }
    auto x = generateSums(min(9,c2),min(2,c3));
    ll os=0;
    rep(i,0,s.size()){
        int y=s[i]-'0';
        os+=y;
    }
    // cout << os << endl;
    bool f=false;  
    if(os%9==0){
     cout << "YES" << endl;
     f=true;
    }
    for(auto sum: x){
        if((sum+os)%9==0 && sum!=0){
            // cout << os <<" " << sum;
            cout << "YES" << endl;
            f=true;
            break;
        }
    }
    if(not f){
        cout << "NO" << endl;
    }
     

 }
    return (ll)0;
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
std::set<ll> generateSums(int count2, int count3) {
    std::set<ll> sums;

    // Iterate through all possible numbers of 2s (0 to count2)
    for (int i = 0; i <= count2; ++i) {
        // Iterate through all possible numbers of 3s (0 to count3)
        for (int j = 0; j <= count3; ++j) {
            // Calculate the sum for the current combination
            ll sum =(ll)i * 2 + (ll)j * 6;
            sums.insert(sum);
        }
    }

    return sums;
}
int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin.exceptions(cin.failbit);
    // Log output to console
    int t;
         cin >> t;

 while(t--){
    string s;
    cin >> s;
    if(t==(3600-401)) cout << s << endl;
    int c2=0;
    int c3=0;
    rep(i,0,s.size()){
       if(s[i]=='2') c2++;
       if(s[i]=='3') c3++;
    }
    auto x = generateSums(min(9,c2),min(2,c3));
    ll os=0;
    rep(i,0,s.size()){
        int y=s[i]-'0';
        os+=y;
    }
    // cout << os << endl;
    bool f=false;  
    if(os%9==0){
     cout << "YES" << endl;
     f=true;
    }
    for(auto sum: x){
        if((sum+os)%9==0 && sum!=0){
            // cout << os <<" " << sum;
            cout << "YES" << endl;
            f=true;
            break;
        }
    }
    if(not f){
        cout << "NO" << endl;
    }
     

 }
    return (ll)0;
}