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

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

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>



using namespace std;

using namespace __gnu_pbds;



#define int long long 

#define float long double

#define pb push_back

#define vi vector<int>

#define pii pair<int,int>

#define si set<int>

#define usi unordered_set<int>

#define msi multiset<int>

#define mii map<int,int>

#define umii unordered_map<int,int>

#define mp make_pair

#define ff first

#define ss second

#define vii vector<pii>

#define all(x) (x).begin(),(x).end()

#define MAX(x) *max_element(all(x))

#define MIN(x) *min_element(all(x))

#define SUM(x) accumulate(all(x),0ll)

#define rep(i,a,b) for(int i=(a);i<(b);i++)

#define bck(i,a,b) for(int i=(a)-1;i>=(b);i--)



typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key



const int MOD = 1e9 + 7;



int mod(int a, int m) {

    return (a % m + m) % m;

}



void solve() {

    int n;

    cin >> n;



    string s;

    s = to_string(n);



    int sum = 0;

    int c2 = 0;

    int c3 = 0;



    rep(i,0,s.size()){

        sum+=s[i]-'0';

        if(s[i]=='2')c2++;

        if(s[i]=='3')c3++;

    }



    int l1 = min(8ll,c2);

    int l2 = min(8ll,c3);



    rep(i,0,l1+1){

        rep(j,0,l2+1){

            int k = sum+(2*i+6*j);

            if(k%9==0){

                cout<<"YES"<<endl;

                return;

            }

        }

    }



    cout<<"NO"<<endl;



    



}



int32_t main() {

    ios::sync_with_stdio(0);

    cin.tie(0);

    int t;

    cin >> t;



    while (t--) {

        solve();

    }



    return 0;

}



Submission (verdict: Accepted):
#include<bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>



using namespace std;

using namespace __gnu_pbds;



#define int long long 

#define float long double

#define pb push_back

#define vi vector<int>

#define pii pair<int,int>

#define si set<int>

#define usi unordered_set<int>

#define msi multiset<int>

#define mii map<int,int>

#define umii unordered_map<int,int>

#define mp make_pair

#define ff first

#define ss second

#define vii vector<pii>

#define all(x) (x).begin(),(x).end()

#define MAX(x) *max_element(all(x))

#define MIN(x) *min_element(all(x))

#define SUM(x) accumulate(all(x),0ll)

#define rep(i,a,b) for(int i=(a);i<(b);i++)

#define bck(i,a,b) for(int i=(a)-1;i>=(b);i--)



typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key



const int MOD = 1e9 + 7;



int mod(int a, int m) {

    return (a % m + m) % m;

}



void solve() {

    



    string s;

    cin>>s;



    int sum = 0;

    int c2 = 0;

    int c3 = 0;



    rep(i,0,s.size()){

        sum+=s[i]-'0';

        if(s[i]=='2')c2++;

        if(s[i]=='3')c3++;

    }



    int l1 = min(8ll,c2);

    int l2 = min(2ll,c3);



    rep(i,0,l1+1){

        rep(j,0,l2+1){

            int k = sum+(2*i+6*j);

            if(k%9==0){

                cout<<"YES"<<endl;

                return;

            }

        }

    }



    cout<<"NO"<<endl;



    



}



int32_t main() {

    ios::sync_with_stdio(0);

    cin.tie(0);

    int t;

    cin >> t;



    while (t--) {

        solve();

    }



    return 0;

}