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

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        long long n;
        cin >> n;
        int two = 0;
        int three = 0;
        long long sum = 0;
        long long a = n;
        while (n > 0)
        {
            if ((n % 10) == 2)
                two++;
            if ((n % 10) == 3)
                three++;
            sum += (n % 10);
            n /= 10;
        }
        n = a;
        if (sum % 9 == 0)
        {
            cout << "YES" << endl;
        }
        else
        {
            bool f = false;
            long long val = sum;
            for (int i = 1; i <= three; i++)
            {   
                sum += a;
                if (sum % 9 == 0)
                {
                    f = true;
                    break;
                }
            }
            sum = val;
            if (!f)
            {
                for (int i = 1; i <= two; i++)
                {
                    sum += 2; 
                    if (sum % 9 == 0)
                    {
                        f = true;
                        break;
                    }
                }
            }
            sum = val;
            if (!f)
            {
                for (int i = 1; i <= two; i++)
                {   
                    sum+=2;
                    long long temp=sum;
                    for (int j = 1; j <= three; j++)
                    {
                        sum+=6;
                        if(sum%9==0){
                            f=true;
                            break;
                        }
                    }
                    sum=temp;
                }
            }
            if(f)cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
    }
    return 0;
}

Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        long long n;
        cin >> n;
        int two = 0;
        int three = 0;
        long long sum = 0;
        long long a = n;
        while (n > 0)
        {
            if ((n % 10) == 2)
                two++;
            if ((n % 10) == 3)
                three++;
            sum += (n % 10);
            n /= 10;
        }
        n = a;
        if (sum % 9 == 0)
        {
            cout << "YES" << endl;
        }
        else
        {
            bool f = false;
            long long val = sum;
            for (int i = 1; i <= three; i++)
            {   
                sum += 6;
                if (sum % 9 == 0)
                {
                    f = true;
                    break;
                }
            }
            sum = val;
            if (!f)
            {
                for (int i = 1; i <= two; i++)
                {
                    sum += 2; 
                    if (sum % 9 == 0)
                    {
                        f = true;
                        break;
                    }
                }
            }
            sum = val;
            if (!f)
            {
                for (int i = 1; i <= two; i++)
                {   
                    sum+=2;
                    long long temp=sum;
                    for (int j = 1; j <= three; j++)
                    {
                        sum+=6;
                        if(sum%9==0){
                            f=true;
                            break;
                        }
                    }
                    sum=temp;
                }
            }
            if(f)cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
    }
    return 0;
}