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

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <string>
using namespace std;

int main() {
    int t;
    cin >> t;
    while (t--)
    {

    
    string s;
    cin >> s;
    int a[10];
    for (int i = 0; i < 10; i++) {
        a[i] = 0;  // Initialize the count array to 0
    }
    for (int i = 0; i < s.length(); i++) {
        if (s[i] >= '0' && s[i] <= '9') {
            a[s[i] - '0']++; 
        }
    }
    long long sum = 0;
    for (int i = 0; i < 10; i++)
    {
        sum += a[i]*i;
    }
    int brea = 0;
    sum = sum % 9;
    if (sum % 9 == 0)
    {
        cout << "YES" << endl;
        continue;
    }
    if (sum % 3 == 1)
    {
        
        if (a[2] >= 1)
        {
            sum += 2;
            a[2]--;
        }
        else

        {
            cout << "NO" << endl;
            continue;
        }
        
    }
    if (sum % 3 == 2)
    {

        if (a[2] >= 2)
        {
            sum += 4;
            a[2]-= 2;
        }
        else
        {
            cout << "NO" << endl;
            continue;
        }
    }
    if (sum % 9 == 0)
    {
        cout << "YES" << endl;
        continue;
    }
    if (sum % 9 == 6)
    {
        if (a[2] >= 3)
        {
            sum += 6;
            
        }
    }
    if (sum % 9 == 6)
    {
        if (a[3] >= 2)
        {
            cout << "YES" << endl;
            continue;
        }
        else
        {
            cout << "NO" << endl;
            continue;
        }
    }
    if (sum % 3 == 0)
    {
        if (a[3] >= 1)
        {
            cout << "YES" << endl;
            continue;
        }
        else
        {
            cout << "NO" << endl;
            continue;
        }
    }
    cout << "NO" << endl;
    }

    return 0;
}


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <string>
using namespace std;

int main() {
    int t;
    cin >> t;
    while (t--)
    {

    
    string s;
    cin >> s;
    int a[10];
    for (int i = 0; i < 10; i++) {
        a[i] = 0;  // Initialize the count array to 0
    }
    for (int i = 0; i < s.length(); i++) {
        if (s[i] >= '0' && s[i] <= '9') {
            a[s[i] - '0']++; 
        }
    }
    long long sum = 0;
    for (int i = 0; i < 10; i++)
    {
        sum += a[i]*i;
    }
    int brea = 0;
    sum = sum % 9;
    if (sum % 9 == 0)
    {
        cout << "YES" << endl;
        continue;
    }
    if (sum % 3 == 1)
    {
        
        if (a[2] >= 1)
        {
            sum += 2;
            a[2]--;
        }
        else

        {
            cout << "NO" << endl;
            continue;
        }
        
    }
    if (sum % 3 == 2)
    {

        if (a[2] >= 2)
        {
            sum += 4;
            a[2]-= 2;
        }
        else
        {
            cout << "NO" << endl;
            continue;
        }
    }
    if (sum % 9 == 0)
    {
        cout << "YES" << endl;
        continue;
    }
    if (sum % 9 == 6)
    {
        if (a[2] >= 3)
        {
            sum += 6;     
        }
    }
    if (sum % 9 == 6)
    {
        if (a[3] >= 2)
        {
            cout << "YES" << endl;
            continue;
        }
        else
        {
            cout << "NO" << endl;
            continue;
        }
    }
    if (sum % 9 == 3)
    {
        if (a[3] >= 1)
        {
            cout << "YES" << endl;
            continue;
        }
        else
        {
            cout << "NO" << endl;
            continue;
        }
    }
    cout << "NO" << endl;
    }
}