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;

void solve() {
    string number;
    cin >> number;

    int digitSum = 0;
    for (const auto c : number) {
        digitSum += c - '0';
    }

    if (digitSum % 9 == 0) {
        cout << "YES" << endl;
        return;
    }
    // 0 => 0
    // 1 => 1
    // 2 => 4 +2
    // 3 => 9 +6
    int twos = 0, threes = 0;
    for (const auto c : number) {
        if (c == '2') {
            twos++;
        } else if (c == '3') {
            threes++;
        }
    }

    int originalDigitSum = digitSum;

    for (int i = 0; i < threes; i++) {
        digitSum += 6;
        if (digitSum % 9 == 0) {
            cout << "YES" << endl;
            return;
        }
    }

    if (twos == 0) {
        cout << "NO" << endl;
        return;
    }

    digitSum = originalDigitSum;

    digitSum += 2;
    for (int i = 0; i < threes; i++) {
        digitSum += 6;
        if (digitSum % 9 == 0) {
            cout << "YES" << endl;
            return;
        }
    }

    if (twos == 1) {
        cout << "NO" << endl;
        return;
    }

    digitSum = originalDigitSum;
    twos += (3*threes);

    for (int i = 0; i < twos; i++) {
        digitSum += 2;
        if (digitSum % 9 == 0) {
            cout << "YES" << endl;
            return;
        }
    }

    cout << "NO" << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t;
    cin >> t;
    for (int i = 0; i < t; i++) {
        solve();
    }

    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>

using namespace std;

void solve() {
    string number;
    cin >> number;

    int digitSum = 0;
    for (const auto c : number) {
        digitSum += c - '0';
    }

    if (digitSum % 9 == 0) {
        cout << "YES" << endl;
        return;
    }
    // 0 => 0
    // 1 => 1
    // 2 => 4 +2
    // 3 => 9 +6
    int twos = 0, threes = 0;
    for (const auto c : number) {
        if (c == '2') {
            twos++;
        } else if (c == '3') {
            threes++;
        }
    }

    int originalDigitSum = digitSum;

    for (int i = 0; i < threes; i++) {
        digitSum += 6;
        if (digitSum % 9 == 0) {
            cout << "YES" << endl;
            return;
        }
    }
    if (twos == 0) {
        cout << "NO" << endl;
        return;
    }

    digitSum = originalDigitSum;

    digitSum += 2;
    for (int i = 0; i < threes; i++) {
        digitSum += 6;
        if (digitSum % 9 == 0) {
            cout << "YES" << endl;
            return;
        }
    }

    if (twos == 1) {
        cout << "NO" << endl;
        return;
    }

    digitSum = originalDigitSum;

    digitSum += 4;
    for (int i = 0; i < threes; i++) {
        digitSum += 6;
        if (digitSum % 9 == 0) {
            cout << "YES" << endl;
            return;
        }
    }

    if (twos == 2) {
        cout << "NO" << endl;
        return;
    }

    digitSum = originalDigitSum;
    twos += (3*threes);

    for (int i = 0; i < twos; i++) {
        digitSum += 2;
        if (digitSum % 9 == 0) {
            cout << "YES" << endl;
            return;
        }
    }

    cout << "NO" << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t;
    cin >> t;
    for (int i = 0; i < t; i++) {
        solve();
    }

    return 0;
}