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

Previous submission (verdict: Compilation error):
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define vi vector<int>
#define vs vector<string>
#define vvi vector<vector<int>>
#define pii pair<int, int>
#define vpii vector<pair<int, int>>
#define mii map<int, int>
#define umii unordered_map<int, int>

#define ff first
#define ss second
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define pb push_back
#define aint(x) x.begin(),x.end()

#define pyes cout << "YES\n"
#define pno cout << "NO\n"
#define pm1 cout << -1 << endl
#define p0 cout << 0 << endl
#define p1 cout << 1 << endl
#define out(x) cout<<x<<endl
#define nl cout<<endl
const int oo = 1e18;
const int mod = 1e9 + 7;

void solve() {
	string s;	cin >> s;
	int n = s.size(), sum = 0;

	int cnt2 = 0, cnt3 = 0;
	rep(i, n) {
		sum += s[i] - '0';
		if (s[i] - '0' == 2)	cnt2++;
		if (s[i] - '0' == 3)	cnt3++;
	}

	sum %= 9;
	int flag = 0;

	for (int i = 0; i <= min(cnt2, 1int * 20); i++) {
		for (int j = 0; j <= min(cnt3, 1int * 20); j++) {
			int temp = sum;
			temp += i * 2 + j * 6;
			if (temp % 9 == 0) {
				cout << "YES\n";
				return;
			}
		}
	}
	for (int i = 0; i < min(cnt2, 1int * 20); i++) {
		int temp = sum;
		if ((temp + i * 2) % 9 == 0) {
			pyes;
			return;
		}
	}
	for (int i = 0; i < min(cnt3, 1int * 20); i++) {
		int temp = sum;
		if ((temp + i * 3) % 9 == 0) {
			pyes;
			return;
		}
	}
	pno;
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int t = 1;
	cin >> t;
	// out(t);
	while (t--)	solve();
}

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

#define int long long
#define vi vector<int>
#define vs vector<string>
#define vvi vector<vector<int>>
#define pii pair<int, int>
#define vpii vector<pair<int, int>>
#define mii map<int, int>
#define umii unordered_map<int, int>

#define ff first
#define ss second
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define pb push_back
#define aint(x) x.begin(),x.end()

#define pyes cout << "YES\n"
#define pno cout << "NO\n"
#define pm1 cout << -1 << endl
#define p0 cout << 0 << endl
#define p1 cout << 1 << endl
#define out(x) cout<<x<<endl
#define nl cout<<endl
const int oo = 1e18;
const int mod = 1e9 + 7;

void solve() {
	string s;	cin >> s;
	int n = s.size(), sum = 0;

	int cnt2 = 0, cnt3 = 0;
	rep(i, n) {
		sum += s[i] - '0';
		if (s[i] - '0' == 2)	cnt2++;
		if (s[i] - '0' == 3)	cnt3++;
	}

	sum %= 9;
	int flag = 0;

	for (int i = 0; i <= min(cnt2, 1LL * 20); i++) {
		for (int j = 0; j <= min(cnt3, 1LL * 20); j++) {
			int temp = sum;
			temp += i * 2 + j * 6;
			if (temp % 9 == 0) {
				cout << "YES\n";
				return;
			}
		}
	}
	for (int i = 0; i < min(cnt2, 1LL * 20); i++) {
		int temp = sum;
		if ((temp + i * 2) % 9 == 0) {
			pyes;
			return;
		}
	}
	for (int i = 0; i < min(cnt3, 1LL * 20); i++) {
		int temp = sum;
		if ((temp + i * 3) % 9 == 0) {
			pyes;
			return;
		}
	}
	pno;
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int t = 1;
	cin >> t;
	// out(t);
	while (t--)	solve();
}