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

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



using namespace std;



#define endl '\n'

#define int long long



const int MOD = 1e9 + 7;

const int INF = LLONG_MAX >> 1;



signed main() {

    ios::sync_with_stdio(false);

    cin.tie(NULL);

    int t;

    cin >> t;

    while (t--)

    {

        string s;

        cin>>s;

 

        unordered_map<int,int> mpp;

        int sum=0;

        for(int i=0;i<s.size();i++)

        {

            int x=s[i]-'0';

            sum=sum+x;

            mpp[x]++;

        }

        bool b=0;

        if(sum%9==0)

        {

            cout<<"YES"<<endl;

            continue;

        }

        else

        {

            int a=sum%9;

            if(a==2 && (mpp[2]>7 || (mpp[2]>4 && mpp[3]>0) || (mpp[3]>1)&& mpp[2>1]))

            {

                b=1;

            }

            else if(a==4 && (mpp[2]>6 || (mpp[2]>3 && mpp[3]>0) || (mpp[3]>1)&& mpp[2]>0))

            {

                b=1;

            }

            else if(a==6 && (mpp[2]>5 || (mpp[2]>2 && mpp[3]>0) || (mpp[3]>1)) )

            {

                b=1;

            }

            else if(a==8 && (mpp[2]>4 || (mpp[2]>1 && mpp[3]>0)))

            {

                b=1;

            }

            else if(a==1 && (mpp[2]>0 && mpp[3]>0 || mpp[2]>3))

            {

                b=1;

            }

            else if(a==3 && (mpp[3]>0 || mpp[2]>2))

            {

                b=1;

            }

            else if(a==5 && mpp[2]>1)

            {

                b=1;

            }

            else if(a==7 && mpp[2]>0)

            {

                b=1;

            }

        }

        

        if(b)

        {

            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;

const int INF = LLONG_MAX >> 1;



signed main() {

    ios::sync_with_stdio(false);

    cin.tie(NULL);

    int t;

    cin >> t;

    while (t--)

    {

        string s;

        cin>>s;

 

        unordered_map<int,int> mpp;

        int sum=0;

        for(int i=0;i<s.size();i++)

        {

            int x=s[i]-'0';

            sum=sum+x;

            mpp[x]++;

        }

        bool b=0;

        if(sum%9==0)

        {

            cout<<"YES"<<endl;

            continue;

        }

        else

        {

            int a=sum%9;

            if(a==2 && (mpp[2]>7 || (mpp[2]>4 && mpp[3]>0) || (mpp[3]>1 && mpp[2]>1)))

            {

                b=1;

            }

            else if(a==4 && (mpp[2]>6 || (mpp[2]>3 && mpp[3]>0) || (mpp[3]>1&& mpp[2]>0)))

            {

                b=1;

            }

            else if(a==6 && (mpp[2]>5 || (mpp[2]>2 && mpp[3]>0) || (mpp[3]>1)) )

            {

                b=1;

            }

            else if(a==8 && (mpp[2]>4 || (mpp[2]>1 && mpp[3]>0)))

            {

                b=1;

            }

            else if(a==1 && (mpp[2]>0 && mpp[3]>0 || mpp[2]>3))

            {

                b=1;

            }

            else if(a==3 && (mpp[3]>0 || mpp[2]>2))

            {

                b=1;

            }

            else if(a==5 && mpp[2]>1)

            {

                b=1;

            }

            else if(a==7 && mpp[2]>0)

            {

                b=1;

            }

        }

        

        if(b)

        {

            cout<<"YES"<<endl;

        }

        else

        {

            cout<<"NO"<<endl;

        }

    }

}