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

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

using namespace std;

typedef long long ll;

int main()

{

    int t;

    cin >> t;

    while(t--) {

        ll n;

        cin >> n;

        

        unordered_map<int, int> m; 

        vector<int> v;

        ll sum = 0;

        while(n != 0) {

            int x = n % 10;

            v.push_back(x);

            sum += x;

            m[x]++;

            n /= 10; 

        }

        

        ll p = sum % 9;

        

        if(p == 1) {

            if((m[2] >= 1 && m[3] >= 1) || (m[2] >= 4)) {

                cout << "YES" << endl;

            } else {

                cout << "NO" << endl;

            }

        } else if(p == 2) {

            if((m[3] >= 2 && m[2] >= 2) || (m[3] >= 1 && m[2] >= 5) || m[2] >= 8) {

                cout << "YES" << endl;

            } else {

                cout << "NO" << endl;

            }

        } else if(p == 4) {

            if((m[3] >= 2 && m[2] >= 1) || (m[3] >= 1 && m[2] >= 4) || m[2] >= 7) {

                cout << "YES" << endl;

            } else {

                cout << "NO" << endl;

            }

        } else if(p == 6) {

            if(m[3] >= 2 || (m[3] >= 1 && m[2] >= 3) || m[2] >= 6) {

                cout << "YES" << endl;

            } else {

                cout << "NO" << endl;

            }

        } else if(p == 8) {

            if((m[3] >= 1 && m[2] >= 2) || m[2] >= 5) {

                cout << "YES" << endl;

            } else {

                cout << "NO" << endl;

            }

        } else if(p == 3) {

            if(m[3] >= 1 || m[2] >= 3) {

                cout << "YES" << endl;

            } else {

                cout << "NO" << endl;

            }

        } else if(p == 5) {

            if(m[2] >= 2) {

                cout << "YES" << endl;

            } else {

                cout << "NO" << endl;

            }

        } else if(p == 7) {

            if(m[2] >= 1) {

                cout << "YES" << endl;

            } else {

                cout << "NO" << endl;

            }

        } else {

            cout << "YES" << endl;

        }

    }



    return 0;

}



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

using namespace std;

typedef long long ll;

 

int main(){

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    

    int t;

    cin >> t;

    while(t--){

        string s;

        cin >> s;

        ll sum = 0;

        int freq[10] = {0};

        for (char c : s) {

            int d = c - '0';

            sum += d;

            freq[d]++;

        }

        

       ll p = sum % 9;

        

        int count2 = freq[2], count3 = freq[3];

        bool possible = false;

        for (int i = 0; i <= count2 && !possible; i++){

            for (int j = 0; j <= count3; j++){

                if ((p + 2 * i + 6 * j) % 9 == 0) {

                    possible = true;

                    break;

                }

            }

        }

        

        cout << (possible ? "YES" : "NO") << "\n";

    }

    

    return 0;

}



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

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

using namespace std;



int main() {

	// your code goes here

	long long t;

	cin>>t;

	while(t--){

	    string n;

	    cin>>n;

	    int k=n.size();

	    int a[10]={0};

	    long long sum=0;

	    for(int i=0;i<k;i++){

	        a[n[i]-'0']++;

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

	    }   

	    int flag=0;

	    if(sum%9==0){

	        cout<<"Yes"<<endl;

	        flag=1;

	    }

	    else{

	        for(int i=0;i<=a[2];i++){

	            for(int j=0;j<=a[3];j++){

	                if((sum+i*2+j*6)%9==0){

	                    cout<<"Yes"<<endl;

	                    flag=1;

	                    break;

	                }

	            }

	        }

	    }

	    if(flag==0){

	        cout<<"No"<<endl;

	    }

	}

}



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

using namespace std;



int main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);



    long long t;

    cin >> t;

    while(t--){

        string n;

        cin >> n;

        int k = n.size();

        // Use long long for the frequency array as well

        long long a[10] = {0};

        long long sum = 0;

        for (int i = 0; i < k; i++){

            int digit = n[i] - '0';

            a[digit]++;

            sum += digit;

        }   

        

        bool possible = false;

        // Check if sum is already divisible by 9

        if(sum % 9 == 0){

            cout << "Yes" << "\n";

            possible = true;

        }

        else {

            // Try to adjust the sum using available 2's (value 2) and 3's (value 6)

            for(long long i = 0; i <= a[2] && !possible; i++){

                for(long long j = 0; j <= a[3]; j++){

                    if((sum + i * 2 + j * 6) % 9 == 0){

                        cout << "Yes" << "\n";

                        possible = true;

                        break;

                    }

                }

            }

        }

        if(!possible){

            cout << "No" << "\n";

        }

    }

    return 0;

}



Answer: 2
Problem: 2050C - Uninteresting Number
Language: python

Code 1:
import sys
import math
import collections
import statistics
import bisect

input = sys.stdin.readline

############ ---- Input Functions ---- ############
##---1) inp — For taking integer inputs.
def inp():
    return (int(input()))

##2) inlt — For taking List inputs.
def inlt():
    return (list(map(int, input().split())))

#3) insr — For taking string inputs. Actually it returns a List of Characters,
# instead of a string, which is easier to use in Python, because in Python,
# Strings are Immutable.
def insr():
    s = input()
    return (list(s[:len(s) - 1]))

#4) invr — For taking space seperated integer variable inputs.
def invr():
    return list(map(int, input().split()))

for iii in range(int(input())):
    a = insr()
    sum = 0
    num2 = 0
    num3 = 0
    for i in a:
        sum += int(i)
        if i == '2':
            num2 += 1
        elif i == '3':
            num3 += 1
    if sum % 9 == 0:
        print("yes")
        continue
    res = 0
    for x in range(min(num2+1, 10)):
        if res == 0:
            for y in range(min(num3+1, 10)):
                if (sum + 2*x + 6*y) % 9 == 0:
                    print("yes")
                    res = 1
                    break
        else:
            break
    if res == 0:
        print("no")

Code 2:
import sys
import math
import collections
import statistics
import bisect

input = sys.stdin.readline

############ ---- Input Functions ---- ############
##---1) inp — For taking integer inputs.
def inp():
    return (int(input()))

##2) inlt — For taking List inputs.
def inlt():
    return (list(map(int, input().split())))

#3) insr — For taking string inputs. Actually it returns a List of Characters,
# instead of a string, which is easier to use in Python, because in Python,
# Strings are Immutable.
def insr():
    s = input()
    return (list(s[:len(s) - 1]))

#4) invr — For taking space seperated integer variable inputs.
def invr():
    return list(map(int, input().split()))

for iii in range(int(input())):
    a = inlt()
    sum = 0
    num2 = 0
    num3 = 0
    for i in str(a):
        sum += int(i)
        if i == '2':
            num2 += 1
        elif i == '3':
            num3 += 1
    if sum % 9 == 0:
        print("yes")
        continue
    res = 0
    for x in range(min(num2+1, 10)):
        if res == 0:
            for y in range(min(num3+1, 10)):
                if (sum + 2*x + 6*y) % 9 == 0:
                    print("yes")
                    res = 1
                    break
        else:
            break
    if res == 0:
        print("no")

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

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

int main() {
    int t;
    cin >> t;
    while (t--) {
        string n;
        cin >> n;
        
        int rem = 0;
        int tcount = 0, threecount = 0;

        // Calculate the remainder and count digits '2' and '3'
        for (char c : n) {
            int digit = c - '0';
            rem = (rem + digit) % 9;
            if (digit == 2) tcount++;
            else if (digit == 3) threecount++;
        }

        bool flag = false;

        // Check if adding multiples of 2 and 3 makes (rem) divisible by 9
        for (int i = 0; (i <= 9) && (i <= tcount) && (!flag); i++) {
            for (int j = 0; (j <= 9) && (j <= threecount) && (!flag); j++) {
                if ((rem + (2 * i) + (6 * j)) % 9 == 0) {
                    flag = true;
                }
            }
        }

        cout << (flag ? "YES\n" : "NO\n");
    }

    return 0;
}


Code 2:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin >> t;
    while(t--)
    {
         
        long long int n;
        cin >> n;
        long long int rem=n%9;
        long long int tcount=0,threecount=0;
        while(n!=0){
            if(n%10 == 2)
            {
                tcount++;
            }
            else if(n%10==3)
            {
                threecount++;
            }
            n = n/10;
        }
        int flag=0;
        for(long long int i=0;(i<=9)&&(i<=tcount)&&(!flag);i++){
            for(long long int j=0;(j<=9)&&(j<=threecount)&&(!flag);j++)
            {
                if((rem+ (2*i) + (6*j))%9==0)
                {
                    flag =1;
                }
            }
        }
        if(flag){
            cout << "YES\n";
        }
        else cout << "NO\n";
    }

    return 0;
}

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

Code 1:
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=3e5+5,mod=1e9+7,inf=1e18;
int _t,n,c[5]; string s; bool ans;
signed main(){
    ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin>>_t;
	while (_t--){
		cin>>s; n=0; c[2]=c[3]=0; ans=0;
		for (int i=0; i<(int)s.size(); i++){
			if (s[i]=='2') c[2]++;
			else if (s[i]=='3') c[3]++;
			else n+=s[i]-'0';
			n%=9; c[2]%=9; c[3]%=9;
		}
		for (int i=0; i<=c[2]; i++)
			for (int j=0; j<=c[3]; j++){
				if ((n+i*4+(c[2]-i)*2+j*3+(c[3]-j)*9)%9==0) ans=1;
			}
		cout<<(ans?"YES\n":"NO\n");
	}
}

Code 2:
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=3e5+5,mod=1e9+7,inf=1e18;
int _t,n,c[5]; string s; bool ans;
signed main(){
    ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin>>_t;
	while (_t--){
		cin>>s; n=0; c[2]=c[3]=0; ans=0;
		for (int i=0; i<(int)s.size(); i++){
			if (s[i]=='2') c[2]++;
			else if (s[i]=='3') c[3]++;
			n+=s[i]-'0';
		}
		for (int i=0; i<=c[2]; i++)
			for (int j=0; j<=c[3]; j++){
				if ((n+i*2+j*6)%9==0) ans=1;
			}
		cout<<(ans?"YES\n":"NO\n");
	}
}

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

Code 1:
#include <bits/stdc++.h>
using namespace std;
int main()
{
	//NOI;
	//freopen("road.in","r",stdin);
	//freopen("road.out","w",stdout);
	int T;
	cin>>T;
	while(T--)
	{
		string N;
		cin>>N;
		int n=N.length();
		int sum=0;
		int ssum=0,tsum=0;
		for(int i=0;i<n;i++)
		{
			sum+=N[i]-'0';
			if(N[i]-'0'==2)tsum++;
			else if(N[i]-'0'==3)ssum++;
		}
		sum%=9;
//		cout<<sum;
		if(sum==0){
			cout<<"YES"<<endl;
			continue;
		}
		bool check=0;
		for(int i=0;i<=tsum;i++)
		{
			for(int j=0;j<=ssum;j++)
			{
				if((sum+i*2+j*6)%9==0){
				
				cout<<"YES";
				check=1;}
			}
		}
		if(check==0)cout<<"NO";
		cout<<endl;
	}
	//fclose(stdin);
	//fclose(stdout);
	return 0;
}


Code 2:
#include <bits/stdc++.h>
using namespace std;
int main()
{
	//NOI;
	//freopen("road.in","r",stdin);
	//freopen("road.out","w",stdout);
	long long T;
	cin>>T;
	while(T--)
	{
		string N;
		cin>>N;
		long long n=N.size();
		long long sum=0;
		long long ssum=0,tsum=0;
		for(long long i=0;i<n;i++)
		{
			sum+=N[i]-'0';
			if(N[i]-'0'==2)tsum++;
			else if(N[i]-'0'==3)ssum++;
		}
		sum%=9;
		if(sum==0){
			cout<<"YES"<<endl;
			continue;
		}
		bool check=0;
		for(long long i=0;i<=tsum;i++)
		{
			for(long long j=0;j<=ssum;j++)
			{
				if((sum+i*2+j*6)%9==0){
				
					cout<<"YES";
					check=1;
					break;
				}
				
			}if(check==1)break;
		}
		if(check==0)cout<<"NO";
		cout<<endl;
	}
	//fclose(stdin);
	//fclose(stdout);
	return 0;
}


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

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
    int t;
    cin >> t;
    while(t--)
    {
        string n;
        cin >> n;
        int twocount  = 0;
        int threecount = 0;
        ll sum = 0;
        bool flag = false;
        for(int i =0; i < n.size(); i++)
        {
            if(n[i] == '2')
            twocount++;
            else if(n[i] == '3')
            threecount++;
            sum += n[i] - '0';
        }
        for(int i = 0 ; i < min(10, twocount+1); i++)
        {
            for(int j = 0; j < min(10,threecount+1); j++)
            {
                if((sum + 2 * i + 6 * j) % 9 == 0)
                {
                    flag = true;
                }
            }
        }
        if(flag)
        cout << "YES" << endl;
        else
        cout << "NO" << endl;

    }
}

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
    int t;
    cin >> t;
    while(t--)
    {
        string n;
        cin >> n;
        int twocount  = 0;
        int threecount = 0;
        ll sum = 0;
        bool flag = false;
        for(int i =0; i < n.size(); i++)
        {
            if(n[i] == '2')
            twocount++;
            else if(n[i] == '3')
            threecount++;
            sum += n[i] - '0';
        }
        for(int i = 0 ; i < min(8, twocount+1); i++)
        {
            for(int j = 0; j < min(8,threecount+1); j++)
            {
                if((sum + 2 * i + 6 * j) % 9 == 0)
                {
                    flag = true;
                }
            }
        }
        if(flag)
        cout << "YES" << endl;
        else
        cout << "NO" << endl;

    }
}

Answer: 1
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>=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;
}

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==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;
}

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

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

using namespace std;

void solve()
{
    string s;
    cin >> s;
    int sum = 0;
    int two_sum = 0;
    int three_sum = 0;
    for (int i = 0; i < s.length(); i++)
    {
        sum += s[i] - '0';
        if (s[i] - '0' == 2)
        {
            two_sum += 2;
        }
        if (s[i] - '0' == 3)
        {
            three_sum += 6;
        }
    }
    if (sum % 9 == 0)
    {
        cout << "YES" << endl;
        return;
    }
    int fire = 9 - (sum % 9);
    while (fire <= two_sum + three_sum)
    {
        if (fire % 2 != 0)
        {
            fire += 9;
            continue;
        }
        int temp_fire = fire;
        int temp_two = two_sum;
        int temp_three = three_sum;
        while (temp_three >= 6 && temp_fire >= 6)
        {
            temp_fire -= 6;
            temp_three -= 6;
        }
        while (temp_two >= 2 && temp_fire >= 2)
        {
            temp_fire -= 2;
            temp_two -= 2;
        }
        if (temp_fire == 0)
        {
            cout << "YES" << endl;
            return;
        }
        fire += 18;
    }
    cout << "NO" << endl;
    return;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int INP;
    cin >> INP;
    while (INP--)
    {
        solve();
    }
    return 0;
}

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

using namespace std;

void solve()
{
    string s;
    cin >> s;
    int sum;
    int two_sum = 0;
    int three_sum = 0;
    for (int i = 0; i < s.length(); i++)
    {
        sum += s[i] - '0';
        if (s[i] - '0' == 2)
        {
            two_sum += 2;
        }
        if (s[i] - '0' == 3)
        {
            three_sum += 6;
        }
    }
    if (sum % 9 == 0)
    {
        cout << "YES" << endl;
        return;
    }
    int fire = 9 - (sum % 9);
    while (fire < two_sum + three_sum)
    {
        if (fire % 2 != 0)
        {
            fire += 9;
            continue;
        }
        int temp_fire = fire;
        int temp_two = two_sum;
        int temp_three = three_sum;
        while (temp_three && temp_fire)
        {
            temp_fire -= 6;
            temp_three -= 6;
        }
        while (temp_two && temp_fire)
        {
            temp_fire -= 2;
            temp_two -= 2;
        }
        if (temp_fire == 0)
        {
            cout << "YES" << endl;
            return;
        }
        fire += 18;
    }
    cout << "NO" << endl;
    return;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int INP;
    cin >> INP;
    while (INP--)
    {
        solve();
    }
    return 0;
}

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

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

using namespace std;

#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

using ll=long long;

#define int long long

signed main()

{

    IOS;

    int t=0;

    cin>>t;

    while(t--)

    {

        string s;

        cin>>s;

        int cnt2=0,cnt3=0,fg=0,ans=0;

        for(int i=0;i<s.size();i++)

        {

            ans+=(s[i]-'0');

            if(s[i]-'0'==2)

            cnt2++;

            if(s[i]-'0'==3)

            cnt3++;

        }

        for(int i=0;i<=cnt2;i++)

        {

            for(int j=0;j<=cnt3;j++)

            {

                if((ans+2*i+6*j)%9==0)

                {

                    fg=1;

                    break;

                }

            }

        }

        if(fg==1) cout<<"YES\n";

        else cout<<"NO\n";

    }

    return 0;

}

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

using namespace std;

#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

using ll=long long;

#define int long long

int res[100010];

signed main()

{

    IOS;

    int t=0;

    cin>>t;

    while(t--)

    {

        string s;

        cin>>s;

        int ans=0,fg=0;

        for(int i=0;i<s.size();i++)

        {

            res[i]=s[i]-'0';

            ans+=res[i];

        }

        sort(res,res+s.size());

        for(int i=0;i<s.size();i++)

        {

            if(res[i]<=3)

            {

                ans+=res[i]*res[i]-res[i];

            }

            if(ans%9==0)

            {

                fg=1;

            }

        }

        if(fg==1)

        {

            cout<<"YES\n";

        }

        else cout<<"NO\n";

    }

    return 0;

}

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

Code 1:
#include <bits/stdc++.h>
const char nl = '\n';
using ll = long long;
using namespace std;

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

    int t;
    cin >> t;
    while (t--)
    {
        string s;
        cin >> s;
        ll sum = 0;
        ll cnt2 = 0; ll cnt3 = 0;
        for (int i=0; i<s.size(); i++)
        {
            int digit = s[i]-'0';
            sum += digit;
            if (digit == 2)
                cnt2 += 1;
            else if (digit == 3)
                cnt3 += 1;
        }
        cnt2 = min(cnt2,(ll)8);
        cnt3 = min(cnt3,(ll)8);
        int validate = 0;
        for(int i=0; i<=cnt2; i++)
        {
            if (i>0)
                sum += 2;
            for (int j=0; j<=cnt3; j++)
            {
                if (j>0)
                    sum += 6;
                if (sum%9 == 0)
                {
                    cout << "YES" << nl;
                    validate = 1;
                    break;
                }
            }
            sum -= 6*cnt3;
        }
        if (validate == 0)
            cout << "NO" << nl;
    }
    return 0;
}


Code 2:
#include <bits/stdc++.h>
const char nl = '\n';
using ll = long long;
using namespace std;

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

    int t;
    cin >> t;
    while (t--)
    {
        string s;
        cin >> s;
        ll sum = 0;
        ll cnt2 = 0; ll cnt3 = 0;
        for (int i=0; i<s.size(); i++)
        {
            int digit = s[i]-'0';
            sum += digit;
            if (digit == 2)
                cnt2 += 1;
            else if (digit == 3)
                cnt3 += 1;
        }
        cnt2 = min(cnt2,(ll)8);
        cnt3 = min(cnt3,(ll)8);
        int validate = 0;
        for(int i=0; i<=cnt2 ; i++)
        {
            if (i>0)
                sum += 2;
            for (int j=0; j<=cnt3; j++)
            {
                if (j>0)
                    sum += 6;
                if (sum%9 == 0)
                {
                    cout << "YES" << nl;
                    validate = 1;
                    break;
                }
            }
            sum -= 6*cnt3;
            if (validate == 1)
                break;
        }
        if (validate == 0)
            cout << "NO" << nl;
    }
    return 0;
}


Answer: 2