ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050C - Uninteresting Number
Language: c++17 

Code 1:
#include <bits/stdc++.h>

using namespace std;

int main()

{

    int t;

    cin >> t;

    while (t--)

    {

       long long n,x=0,sum=0,c2=0,c3=0,num=0,diff=0,i,f=0,j,temp=0;

       string s;

       cin>>s;

       for(i=0;i<s.length();i++){

        sum+=s[i]-'0';

        if(s[i]=='2'){

            c2++;

        }

        else if(s[i]=='3'){

            c3++;

        }

       }

       if(sum%9==0){

           cout<<"YES"<<endl;

           continue;

       }

       else if(c3==s.length()){

           cout<<"YES"<<endl;

           continue;

       }

       else{

          x=sum/9;

          num=(x+1)*9;

          diff=abs(num-sum);

        for(i=0;i<=c2;i++){

            temp=0;

            for(j=0;j<=c3;j++){

                temp=i*2+j*6+sum;

                if(temp%9==0){

                    f=1;

                    break;

                 }

             }

        }



        if(f==0){

            cout<<"NO"<<endl;

        }

        else{

            cout<<"YES"<<endl;

        }



       

    }

  }  



    return 0;

}

Code 2:
#include <bits/stdc++.h>

using namespace std;

int main()

{

    int t;

    cin >> t;

    while (t--)

    {

       long long n,x=0,sum=0,c2=0,c3=0,num=0,diff=0,i,f=0,j,temp=0;

       string s;

       cin>>s;

       for(i=0;i<s.length();i++){

        sum+=s[i]-'0';

        if(s[i]=='2'){

            c2++;

        }

        else if(s[i]=='3'){

            c3++;

        }

       }

       if(sum%9==0){

           cout<<"YES"<<endl;

           continue;

       }

       else if(c3==s.length()){

           cout<<"YES"<<endl;

           continue;

       }

       else{

          x=sum/9;

          num=(x+1)*9;

          diff=abs(num-sum);

        for(i=0;i<=c2;i++){

            temp=0;

            if(i*2>99){

                break;

            }

            else{

            for(j=0;j<=c3;j++){

                temp=i*2+j*6;

                if(temp>99){

                    break;

                }

                else if((temp+sum)%9==0){

                    f=1;

                    break;

                 }

             }

             if(f==1){

                 break;

             }

            }

             

        }



        if(f==0){

            cout<<"NO"<<endl;

        }

        else{

            cout<<"YES"<<endl;

        }



       

    }

  }  



    return 0;

}

Answer: 2
Problem: 2050C - Uninteresting Number
Language: c++17 

Code 1:
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;cin>>t;
    while (t--)
    {
        int n;cin>>n;
        int n_2=0,n_3=0;
        string s=to_string(n);
        // cout<<s;
        int sum=0;
        // int x=stoi(s[1]);
        for(int i=0;i<s.size();i++){
            sum+=s[i]-'0';
            if(s[i]=='2') n_2++;
            if(s[i]=='3') n_3++;
        }
        // cout<<sum;
        // cout<<n_2<<" "<<n_3;
        int flag=0; 
        for(int i=0;i<=min(n_3,2);i++){
            for(int j=0;j<=min(n_2,8);j++){
                if((sum+6*i + 2*j)%9 == 0){
                    flag=1;
                }
            }
        }
        if(flag==1) cout<<"Yes"<<endl;
        if(flag==0) cout<<"No"<<endl;
    }
    
}

Code 2:
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;cin>>t;
    while (t--)
    {
        string n;cin>>n;
        int n_2=0,n_3=0;
        // string s=to_string(n);
        // cout<<s<<endl;
        int sum=0;
        // int x=stoi(s[1]);
        // cout<<s.size();
        for(int i=0;i<n.size();i++){
            sum+=n[i]-'0';
            if(n[i]=='2') n_2++;
            if(n[i]=='3') n_3++;
        }
        // cout<<n_2<<" "<<n_3<<endl;
        if(n_2 == 0 && n_3 == 0){
            if(sum%9==0) cout<<"Yes"<<endl; 
            else cout<<"No"<<endl;
        }
        else{
            int flag=0; 
            for(int i=0;i<=min(n_3,2);i++){
                for(int j=0;j<=min(n_2,8);j++){
                    if((sum+ 6*i + 2*j)%9 == 0){
                        flag=1;
                    }
                }
            }
            if(flag==1) cout<<"Yes"<<endl;
            if(flag==0) cout<<"No"<<endl;
        }
    }
    
}

Answer: 2
Problem: 2050C - Uninteresting Number
Language: c++17 

Code 1:
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
using namespace std;
int calculateX(int m, int n) {
    
    int k = static_cast<int>(ceil(static_cast<double>(m) / n));
    
    int x = (k * n) - m;
    
    return x;
}
int main() {
    int t;
    cin>>t;
    vector<string>v;
    while(t--){
        long long int number;
        int sum = 0;
    
    cin >> number;
    int m=0,n=0;
    while (number > 0) {
        if(number%10==2){
            m++;
        }
        if(number%10==3){
            n++;
        }
        sum += number % 10; 
        number /= 10;       
    }
    
    int remi=sum%9;
    if(m==0 && n==0){
        if(remi==0){
            v.push_back("YES");
        }
        else{
            v.push_back("NO");
        }

    } 
    else{
        int rem=calculateX(remi,9);
        int check=0;
        for(int i=0;i<=m;i++){
            for(int j=0;j<=n;j++){
                if((sum+2*i+6*j) % 9 ==0){
                    check=1;
                    break;
                }

            }
        }
        if(check){
            v.push_back("YES");
        }
        else{
            v.push_back("NO");
        }
  
   

    }
    
    

    }
    
    for(auto i:v){
        cout<<i<<endl;
    }
    return 0;
}


Code 2:
#include <iostream>
#include <vector>
#include <string>
using namespace std;

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

    vector<int> s;
    for (char c : input) {
        s.push_back(c - '0'); // Convert char to int and store in vector
    }

    int sm = 0;
    int twos = 0, threes = 0;

    for (int digit : s) {
        sm += digit;
        if (digit == 2) twos++;
        if (digit == 3) threes++;
    }

    for (int i = 0; i <= min(10, twos); i++) {
        for (int j = 0; j <= min(10, threes); j++) {
            if ((sm + i * 2 + j * 6) % 9 == 0) {
                cout << "YES" << endl;
                return;
            }
        }
    }

    cout << "NO" << endl;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}


Answer: 2
Problem: 2050C - Uninteresting Number
Language: c++23 

Code 1:
#include <iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include <string>
#include<math.h>
#include<iomanip>
using namespace std;
void solve(){
    long long sum=0;
    long long two=0,three=0;
    string s;
    cin>>s;
    int len=s.length();
    for(int i=0;i<len;i++){
        sum+=s[i]-'0';
        if(s[i]=='2')two++;
        if(s[i]=='3')three++;
    }
    int mod=sum%9;
    if(mod==0){
        cout<<"YES"<<"\n";
        return;
    }
    if(mod==1&&((two>=4)||(three>=1&&two>=1))){
        cout<<"YES"<<"\n";
        return;
    }
    if(mod==2&&two>=1&&three>=1){
        cout<<"YES"<<"\n";
        return;
    }
    if(mod==3&&three>=1){
        cout<<"YES"<<"\n";
        return;
    }
    if(mod==4&&((two>=7)||(three>=1&&two>=4)||(three>=2&&two>=1))){
        cout<<"YES"<<"\n";
        return;
    }
    if(mod==5&&two>=2){
        cout<<"YES"<<"\n";
        return;
    }
    if(mod==6&&((two>=6)||(three>=1&&two>=3)||(three>=2))){
        cout<<"YES"<<"\n";
        return;
    }
    if(mod==7&&two>=1){
        cout<<"YES"<<"\n";
        return;
    }
    if(mod==8&&((two>=5)||(three>=1&&two>=2))){
        cout<<"YES"<<"\n";
        return;
    }

    cout<<"NO\n";
}
int main() {
	std::ios::sync_with_stdio(false);
	cin.tie(0); 
	cout.tie(0);
    int t;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Code 2:
#include <iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include <string>
#include<math.h>
#include<iomanip>
using namespace std;
void solve(){
    long long sum=0;
    long long two=0,three=0;
    string s;
    cin>>s;
    int len=s.length();
    for(int i=0;i<len;i++){
        sum+=s[i]-'0';
        if(s[i]=='2')two++;
        if(s[i]=='3')three++;
    }
    int mod=sum%9;
    if(mod==0){
        cout<<"YES"<<"\n";
        return;
    }
    if(mod==1&&((two>=4)||(three>=1&&two>=1))){
        cout<<"YES"<<"\n";
        return;
    }
    if(mod==2&&(two>=8||(three>=1&&two>=5)||(three>=2&&two>=2))){
        cout<<"YES"<<"\n";
        return;
    }
    if(mod==3&&(three>=1||two>=3)){
        cout<<"YES"<<"\n";
        return;
    }
    if(mod==4&&((two>=7)||(three>=1&&two>=4)||(three>=2&&two>=1))){
        cout<<"YES"<<"\n";
        return;
    }
    if(mod==5&&two>=2){
        cout<<"YES"<<"\n";
        return;
    }
    if(mod==6&&((two>=6)||(three>=1&&two>=3)||(three>=2))){
        cout<<"YES"<<"\n";
        return;
    }
    if(mod==7&&two>=1){
        cout<<"YES"<<"\n";
        return;
    }
    if(mod==8&&((two>=5)||(three>=1&&two>=2))){
        cout<<"YES"<<"\n";
        return;
    }

    cout<<"NO\n";
}
int main() {
	std::ios::sync_with_stdio(false);
	cin.tie(0); 
	cout.tie(0);
    int t;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Answer: 2
Problem: 2050C - Uninteresting Number
Language: c++17 

Code 1:
#include <fstream>
#include <iostream>
using namespace std;



int main() {
    istream& fin = cin;
    ostream& fout = cout;

    int t;
    fin >> t;
    int two, three;
    long long sum;
    string number;
    int temp;
    int offset = int('0');
    for (int i=0; i<t; i++) {
        two = three = 0;
        sum = 0;
        fin >> number;
        for (char ch: number) {
            if (ch == '\n') break;
            temp = int(ch) - offset;
            if (temp == 2) two++;
            if (temp == 3) three++;
            sum += temp;
        }
        bool possible = sum % 9 == 0;
        sum %= 9;
        // fout << (sum % 9) << " " << two << " " << three << " " << endl;
        for (int j=0; j<=two; j++) {
            if (possible) break;
            if (j == 9) {possible = true; break;}
            for (int k=0; k<=three; k++) {
                if (possible) break;
                if (k == 9) {possible = true; break;}
                if ((sum + 2*j + 6*k) % 9 == 0) possible = true;
            }
        }
        fout << (possible ? "YES" : "NO") << "\n";
    }
}

Code 2:
#include <fstream>
#include <iostream>
using namespace std;



int main() {
    istream& fin = cin;
    ostream& fout = cout;

    int t;
    fin >> t;
    int two, three;
    long long sum;
    string number;
    int temp;
    int offset = int('0');
    for (int i=0; i<t; i++) {
        two = three = 0;
        sum = 0;
        fin >> number;
        for (char ch: number) {
            if (ch == '\n') break;
            temp = int(ch) - offset;
            if (temp == 2) two++;
            if (temp == 3) three++;
            sum += temp;
        }
        bool possible = sum % 9 == 0;
        sum %= 9;
        // fout << (sum % 9) << " " << two << " " << three << " " << endl;
        for (int j=0; j<=two; j++) {
            if (possible) break;
            if (j == 9) break;
            for (int k=0; k<=three; k++) {
                if (possible) break;
                if (k == 9) break;
                if ((sum + 2*j + 6*k) % 9 == 0) possible = true;
            }
        }
        fout << (possible ? "YES" : "NO") << "\n";
    }
}

Answer: 2
Problem: 2050C - Uninteresting Number
Language: c++23 

Code 1:
#include<bits/stdc++.h>
using namespace std;

#define int long long

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

    int sum = 0;
    int find2 = 0;
    int find3 = 0;
    
    
    for(auto it:n){
        sum += (it-'0');
        if((it-'0') == 2) find2++;
        if((it-'0') == 3) find3++;
    }

    for(int i=0;i<=find2;i++){
        for(int j=0;j<=find3;j++){
            if((sum + 6*j + 2*i)%9 == 0){
                cout<<"YES\n";
                return;
            }
        }
    }
        cout<<"NO\n";
    
    
    
    
    
}


signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int t;
    cin >> t;
    while (t--){
       solve();
    }
}

Code 2:
#include<bits/stdc++.h>
using namespace std;

#define int long long


int get_sum(int n){
    int sum = 0;
    while(n>0){
        sum += (n%10);
        n=n/10;
    }
    return sum;
}


int get_two(int n){
    int a = 0;
    while(n>0){
        if(n%10 == 2) a++;
        n=n/10;
    }
    return a;
}

int get_three(int n){
    int a = 0;
    while(n>0){
        if(n%10 == 3) a++;
        n=n/10;
    }
    return a;
}


void solve(){
    int n;
    cin>>n;
    int sum = get_sum(n);
    int left = (((sum+8)/9)*9)  - sum;
    
    
    // cout<<"LEFT IS: "<<left<<endl;
    
    int find2 = get_two(n);
    int find3 = get_three(n);

    if(left == 0){
        cout<<"YES\n";
        return;
    }else if(left == 1){
        if(find2>=5 || (find3>=1 && find2>=2)){
            cout<<"YES\n";
            return;
        }
    }
    else if(left == 2 && find2>=1){
        cout<<"YES\n";
        return;
    }
    else if(left == 3){
        if(find3>=2 || (find2>=6) || (find3>=1 && find2>=3)){
            cout<<"YES\n";
            return;
        }
    }
    else if(left == 4 &&  find2>=2){
        cout<<"YES\n";
        return;
        
    }else if(left == 5){
        //make 14
        if(find2>=7 || (find3>=2 && find2>=1) || (find3>=1 && find2>=4)){
            cout<<"YES\n";
            return;
        }
    }
    else if(left == 6 && (find2>=3 || find3>=1)   ){
        cout<<"YES\n";
        return;
        
    }
    else if(left == 7){
        if(find2>=8 || (find3>=2 && find2>=2) || (find2>=1 && find2>=5)){
            cout<<"YES\n";
            return;
        }
    }
    
    else if(left == 8 && ( find2>=4  || (find3>=1 && find2>=1)) ){
        cout<<"YES\n";
        return;
        
    }
        cout<<"NO\n";
    
    
    
    
    
}


signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int t;
    cin >> t;
    while (t--){
       solve();
    }
}

Answer: 1
Problem: 2050C - Uninteresting Number
Language: c++20 

Code 1:
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define endl "\n"

void slove()
{
    string s;
    int a = 0,b = 0;
    int sum = 0;
    cin >> s;
    for(int i = 0;i < s.size();i++)
    {
        sum += s[i] - '0';
        if(s[i] == '2') a++;
        else if(s[i] == '3') b++;
    }
  
    for(int i = 0; i <= min(5,a);i++)
    {
        for(int j = 0; j <= min(5,b); j++)
        {
            int k = i*2 + 6*j;
            if((sum + k)%9 == 0)
            {
                cout << "YES" << endl;
                return ;
            }
        }
    }
    cout << "NO" << endl;
}

signed main()
{
    int T = 1;
    cin >> T;
    while(T--) slove();
    return 0;
}

Code 2:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"

void slove()
{
    string s;
    int a = 0,b = 0;
    int sum = 0;
    cin >> s;
    for(int i = 0;i < s.size();i++)
    {
        sum += s[i] - '0';
        if(s[i] == '2') a++;
        else if(s[i] == '3') b++;
    }
  
    for(int i = 0; i <= min(8ll,a);i++)
    {
        for(int j = 0; j <= min(8ll,b); j++)
        {
            int k = i*2 + 6*j;
            if((sum + k)%9 == 0)
            {
                cout << "YES" << endl;
                return ;
            }
        }
    }
    cout << "NO" << endl;
}

signed main()
{
    int T = 1;
    cin >> T;
    while(T--) slove();
    return 0;
}

Answer: 2
Problem: 2050C - Uninteresting Number
Language: c++17 

Code 1:
#include <bits/stdc++.h>
using namespace std;

void accelerate()
{
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}

void solve() {
    string n;
    cin >> n;
    int sum = 0;
    int two = 0;
    int three = 0;
    for (auto c : n) {
        int d = c - '0';
        sum = (sum + d) % 9;
        if (d == 2) two++;
        else if (d == 3) three++;
    }
    int dp[9] = {0};
    dp[sum] = 1;
    for (int i = 0; i < two || i < 8; i++) {
        sum = (sum + 2) % 9;
        dp[sum] = 1;
    }
    if (dp[0] || (dp[3] && three >= 1) || (dp[6] && three >= 2)) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

signed main() {
    // accelerate();
    int tc = 1;
    cin >> tc;
    while (tc--) {
        solve();
    }
    return 0;
}


Code 2:
#include <bits/stdc++.h>
using namespace std;

void accelerate()
{
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}

void solve() {
    string n;
    cin >> n;
    int sum = 0;
    int two = 0;
    int three = 0;
    for (auto c : n) {
        int d = c - '0';
        sum = (sum + d) % 9;
        if (d == 2) two++;
        else if (d == 3) three++;
    }
    int dp[9] = {0};
    dp[sum] = 1;
    for (int i = 0; i < two && i < 8; i++) {
        sum = (sum + 2) % 9;
        dp[sum] = 1;
    }
    if (dp[0] || (dp[3] && three >= 1) || (dp[6] && three >= 2)) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

signed main() {
    // accelerate();
    int tc = 1;
    cin >> tc;
    while (tc--) {
        solve();
    }
    return 0;
}


Answer: 2
Problem: 2050C - Uninteresting Number
Language: c++17 

Code 1:
#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();
}

Code 2:
#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();
}

Answer: 1
Problem: 2050C - Uninteresting Number
Language: c++17 

Code 1:
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define pii pair<int,int>
const int maxn = 100005, MOD = 1e9 + 7;

void fast_io(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);   
}

// bool prime[1001];

// void SieveOfEratosthenes(int n)
// {
//     memset(prime, true, sizeof(prime));
//     for (int p = 2; p * p <= n; p++) {
//         if (prime[p] == true) {
//             for (int i = p * p; i <= n; i += p)prime[i] = false;
//         }
//     }
// }


void solve(){
    string n; cin >> n; 
    int twos = 0, threes = 0, md = 0;
    int x = n.size();
    bool ans = 0;
    for(int i = 0; i<x ; ++i){
        int temp = (int)(n[i]) - 48;
        md += temp; 
        md = (md % 9);
        // cout << temp << " ";
        if(temp == 2) twos++;
        if(temp == 3) threes++;

    }
    twos = (twos%9);
    threes = (threes%3);
    for(int i = 0; i<=twos; ++i){
        for(int j = 0; j<=threes; ++j){
            int temp = (2*i) + (6*j);
            if((md+temp) % 9 == 0) {
                ans = 1;
                break;
            }
        }
        if(ans) break;
    }
    if(ans) cout << "YES";
    else cout << "NO";
    
}

signed main() {
    fast_io();
    int t = 1;
    cin >> t;
    while(t--){
        solve();
        cout << endl;
    }
}



Code 2:
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define pii pair<int,int>
const int maxn = 100005, MOD = 1e9 + 7;

void fast_io(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);   
}

// bool prime[1001];

// void SieveOfEratosthenes(int n)
// {
//     memset(prime, true, sizeof(prime));
//     for (int p = 2; p * p <= n; p++) {
//         if (prime[p] == true) {
//             for (int i = p * p; i <= n; i += p)prime[i] = false;
//         }
//     }
// }


void solve(){
    string n; cin >> n; 
    int twos = 0, threes = 0, md = 0;
    int x = n.size();
    bool ans = 0;
    for(int i = 0; i<x ; ++i){
        int temp = (int)(n[i]) - 48;
        md += temp; 
        md = (md % 9);
        // cout << temp << " ";
        if(temp == 2) twos++;
        if(temp == 3) threes++;

    }
    twos = min((int)8, twos);
    threes = min((int)2, threes);
    for(int i = 0; i<=twos; ++i){
        for(int j = 0; j<=threes; ++j){
            int temp = (2*i) + (6*j);
            if((md+temp) % 9 == 0) {
                ans = 1;
                break;
            }
        }
        if(ans) break;
    }
    if(ans) cout << "YES";
    else cout << "NO";
    
}

signed main() {
    fast_io();
    int t = 1;
    cin >> t;
    while(t--){
        solve();
        cout << endl;
    }
}



Answer: 2