ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rev(i, a, b) for (int i = a; i >= (b); i--)
#define fr first
#define sc second
#define pb push_back
#define endl "\n"

template<class T, class U> inline void chmin(T& a, U b) { if (a > b) a = b; }
template<class T, class U> inline void chmax(T& a, U b) { if (a < b) a = b; }

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

//void reset() {}

void solve_task() {
    int n,k;cin >> n >> k;
    vector<ll> a(n);
    map<ll,ll> cnt;

    rep(i,0,n) {
        cin >> a[i];
        cnt[a[i]]++;
    }

    sort(all(a),[&](int x,int y) {
        return cnt[x] <= cnt[y];
    });

    rep(i,0,k) {
        cnt[a[i]]--;
        a[i] = a[n - 1];
        cnt[a[i]]++;
    }

    sort(all(a));
    int ans = 1;
    rep(i,1,n) ans += (a[i] != a[i - 1]);
    cout << ans << endl;
}

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

    int tc = 1;cin >> tc;
    while(tc--) solve_task();

    return 0;
}

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

#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rev(i, a, b) for (int i = a; i >= (b); i--)
#define fr first
#define sc second
#define pb push_back
#define endl "\n"

template<class T, class U> inline void chmin(T& a, U b) { if (a > b) a = b; }
template<class T, class U> inline void chmax(T& a, U b) { if (a < b) a = b; }

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

//void reset() {}

void solve_task() {
    int n,k;cin >> n >> k;
    vector<ll> a(n);
    map<ll,ll> cnt;

    rep(i,0,n) {
        cin >> a[i];
        cnt[a[i]]++;
    }

    sort(all(a),[&](int x,int y) {
        if(cnt[x] == cnt[y]) return x < y;
        return cnt[x] < cnt[y];
    });

    rep(i,0,k) a[i] = a[n - 1];

    sort(all(a));
    int ans = 1;
    rep(i,1,n) ans += (a[i] != a[i - 1]);
    cout << ans << endl;
}

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

    int tc = 1;cin >> tc;
    while(tc--) solve_task();

    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rev(i, a, b) for (int i = a; i >= (b); i--)
#define fr first
#define sc second
#define pb push_back
#define endl "\n"

template<class T, class U> inline void chmin(T& a, U b) { if (a > b) a = b; }
template<class T, class U> inline void chmax(T& a, U b) { if (a < b) a = b; }

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

//void reset() {}

void solve_task() {
    int n,k;cin >> n >> k;
    vector<ll> a(n);
    map<ll,ll> cnt;

    rep(i,0,n) {
        cin >> a[i];
        cnt[a[i]]++;
    }

    sort(all(a),[&](int x,int y) {
        return cnt[x] <= cnt[y];
    });

    rep(i,0,k) {
        cnt[a[i]]--;
        a[i] = a[n - 1];
        cnt[a[i]]++;
    }

    int ans = 0;
    for(auto [c,f] : cnt) if(f) ans++;

    cout << ans << endl;
}

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

    int tc = 1;cin >> tc;
    while(tc--) solve_task();

    return 0;
}

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

#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rev(i, a, b) for (int i = a; i >= (b); i--)
#define fr first
#define sc second
#define pb push_back
#define endl "\n"

template<class T, class U> inline void chmin(T& a, U b) { if (a > b) a = b; }
template<class T, class U> inline void chmax(T& a, U b) { if (a < b) a = b; }

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

//void reset() {}

void solve_task() {
    int n,k;cin >> n >> k;
    vector<ll> a(n);
    map<ll,ll> cnt;

    rep(i,0,n) {
        cin >> a[i];
        cnt[a[i]]++;
    }

    sort(all(a),[&](int x,int y) {
        return cnt[x] <= cnt[y];
    });

    rep(i,0,k) {
        cnt[a[i]]--;
        a[i] = a[n - 1];
        cnt[a[i]]++;
    }

    sort(all(a));
    int ans = 1;
    rep(i,1,n) ans += (a[i] != a[i - 1]);
    cout << ans << endl;
}

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

    int tc = 1;cin >> tc;
    while(tc--) solve_task();

    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)


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

#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rev(i, a, b) for (int i = a; i >= (b); i--)
#define fr first
#define sc second
#define pb push_back
#define endl "\n"

template<class T, class U> inline void chmin(T& a, U b) { if (a > b) a = b; }
template<class T, class U> inline void chmax(T& a, U b) { if (a < b) a = b; }

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

//void reset() {}

void solve_task() {
    int n,k;cin >> n >> k;
    vector<int> a(n);
    map<int,int> cnt;

    rep(i,0,n) {
        cin >> a[i];
        cnt[a[i]]++;
    }

    sort(all(a),[&](int x,int y) {
        return cnt[x] < cnt[y];
    });

    rep(i,0,min(k,n)) {
        cnt[a[i]]--;
        a[i] = a[n - 1];
        cnt[a[i]]++;
    }

    int ans = 0;
    for(auto [c,f] : cnt) if(f) ans++;

    cout << ans << endl;
}

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

    int tc = 1;cin >> tc;
    while(tc--) solve_task();

    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rev(i, a, b) for (int i = a; i >= (b); i--)
#define fr first
#define sc second
#define pb push_back
#define endl "\n"

template<class T, class U> inline void chmin(T& a, U b) { if (a > b) a = b; }
template<class T, class U> inline void chmax(T& a, U b) { if (a < b) a = b; }

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

//void reset() {}

void solve_task() {
    int n,k;cin >> n >> k;
    vector<int> a(n);
    map<int,int> cnt;

    rep(i,0,n) {
        cin >> a[i];
        cnt[a[i]]++;
    }

    sort(all(a),[&](int x,int y) {
        return cnt[x] < cnt[y];
    });

    rep(i,0,min(k,n)) {
        cnt[a[i]]--;
        a[i] = a[n - 1];
        cnt[a[i]]++;
    }

    int ans = 0;
    for(auto [c,f] : cnt) if(f) ans++;

    cout << ans << endl;
}

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

    int tc = 1;cin >> tc;
    while(tc--) solve_task();

    return 0;
}

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

#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rev(i, a, b) for (int i = a; i >= (b); i--)
#define fr first
#define sc second
#define pb push_back
#define endl "\n"

template<class T, class U> inline void chmin(T& a, U b) { if (a > b) a = b; }
template<class T, class U> inline void chmax(T& a, U b) { if (a < b) a = b; }

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

//void reset() {}

void solve_task() {
    int n,k;cin >> n >> k;
    vector<ll> a(n);
    map<ll,ll> cnt;

    rep(i,0,n) {
        cin >> a[i];
        cnt[a[i]]++;
    }

    sort(all(a),[&](int x,int y) {
        return cnt[x] <= cnt[y];
    });

    rep(i,0,k) {
        cnt[a[i]]--;
        a[i] = a[n - 1];
        cnt[a[i]]++;
    }

    int ans = 0;
    for(auto [c,f] : cnt) if(f) ans++;

    cout << ans << endl;
}

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

    int tc = 1;cin >> tc;
    while(tc--) solve_task();

    return 0;
}
Problem: 2049B - pspspsps
Language: C++23 (GCC 14-64, msys2)


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

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

using namespace std;



#define int long long

#define rep(i, x, n) for (int i = x; i < n; i++)

#define rrep(i, x, n) for (int i = n; i >= x; i--)

#define all(x) (x).begin(), (x).end()

#define fi first

#define se second

#define endl "\n"

#define pb push_back

#define pii pair<int, int>

#define vi vector<int>

#define vii vector<pair<int,int>>

#define vvi vector<vector<int>>

#define inf (int)1e18



mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());

typedef __gnu_pbds::tree<int, __gnu_pbds::null_type, less<int>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update> ordered_set;



const int M=1e9+7;



// Binary Exponentiation

int binExp(int a, int b) { int x = 1; while (b) { if (b & 1) x = (x * 1ll * a) % M; a = (a * 1ll * a) % M; b >>= 1; } return x; }



void Solve()

{

    int n,m,k,q;

    string s;

    cin>>n>>s;

    int prevp=0;

    rep(i,0,n){

        if(s[i]=='p') prevp=1;

        else if(prevp){

            cout<<"NO\n";

            return;

        }

    }

    rep(i,1,n-2){

        if(s[i]=='s' && s[i+1]=='p'){

            cout<<"NO\n";

            return;

        }

    }

    cout<<"YES\n";

}



int32_t main()

{

    auto begin = std::chrono::high_resolution_clock::now();

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    int t = 1;

    // freopen("in",  "r", stdin);

    // freopen("out", "w", stdout);

    

    cin >> t;

    while(t--)

    {

        //cout << "Case #" << i << ": ";

        Solve();

    }

    auto end = std::chrono::high_resolution_clock::now();

    auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);

    // cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n"; 

    return 0;

}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
/* 
    Author : Hossain Ahmed Siam
    Date   : 2025-02-02
    Time   : 15:36:30
*/


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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define ld long double
#define int64 int64_t

#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long>

#define fill_arr(x) for(auto &n:x) {cin>> n;}

#define all(vec) begin(vec), end(vec)
#define pb push_back
#define fi first
#define se second

#define MOD 1000000007
#define INF 1e9
#define nline "\n"
#define  print(x) cout<<x<<"\n"

#define debugCode(x) cout<<"Debug : "<< x<< nline;

int solve(int n, vi& nums,int dp[]){
    
    if(n == 1) return nums[0];
    if(dp[n]) return dp[n];
    int ans = INT_MIN;
    
    int sum1 = 0;
    int sum2 = 0;
    for(auto num: nums) sum1 += num;
    reverse(all(nums));
    for(auto num: nums) sum2+= num;

    ans =  max({ans, sum1, sum2});
    
    vi temp;
    
    for(int i =0; i< n-1; i++){
        
        temp.pb(nums[i+1] - nums[i]);

    }

    int left = solve(n-1, temp, dp);
    
    reverse(all(nums));
    
    vi temp2 ;
    for(int i = 0; i< n-1; i++){
        temp2.pb(nums[i+1]- nums[i]);
    }

    int right = solve(n-1, temp2,dp);

    return dp[n] = max({ans, left , right}) ;

    


}





int main() {

    fast_io;

    int t;
    cin>>t;

    while(t--){
        
        int n ;
        cin>>n;
        
        vi nums(n);
        fill_arr(nums);
        int dp[51] = {0};
        
        int ans =solve(n, nums, dp); 
        print(ans);

    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
/* 
    Author : Hossain Ahmed Siam
    Date   : 2025-02-02
    Time   : 15:36:30
*/


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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define ld long double
#define int64 int64_t

#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long>

#define fill_arr(x) for(auto &n:x) {cin>> n;}

#define all(vec) begin(vec), end(vec)
#define pb push_back
#define fi first
#define se second

#define MOD 1000000007
#define INF 1e9
#define nline "\n"
#define  print(x) cout<<x<<"\n"

#define debugCode(x) cout<<"Debug : "<< x<< nline;

ll solve(int n, vll& nums,ll dp[]){
    
    if(n == 1) return nums[0];
    if(dp[n]) return dp[n];
    ll ans = LLONG_MIN;
    
    ll sum1 = 0;
   
    for(auto num: nums) sum1 += num;

    ans =  max({ans, sum1});
    
    vll temp;
    
    for(int i =0; i< n-1; i++){
        
        temp.pb(nums[i+1] - nums[i]);

    }

    ll left = solve(n-1, temp, dp);
    
    reverse(all(nums));
    
    vll temp2 ;
    for(int i = 0; i< n-1; i++){
        temp2.pb(nums[i+1]- nums[i]);
    }

    ll right = solve(n-1, temp2,dp);

    return dp[n] = max({ans, left , right}) ;

    


}





int main() {

    fast_io;

    int t;
    cin>>t;

    while(t--){
        
        int n ;
        cin>>n;
        
        vll nums(n);
        fill_arr(nums);
        ll dp[51] = {0};
        
        ll ans =solve(n, nums, dp); 
        print(ans);

    }
    return 0;
}









Submission (verdict: Accepted):
/* 
    Author : Hossain Ahmed Siam
    Date   : 2025-02-02
    Time   : 15:36:30
*/


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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define ld long double
#define int64 int64_t

#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long>

#define fill_arr(x) for(auto &n:x) {cin>> n;}

#define all(vec) begin(vec), end(vec)
#define pb push_back
#define fi first
#define se second

#define MOD 1000000007
#define INF 1e9
#define nline "\n"
#define  print(x) cout<<x<<"\n"

#define debugCode(x) cout<<"Debug : "<< x<< nline;


   



int main() {

    fast_io;

    int t;
    cin>>t;

    while(t--){
        
        int n ;
        cin>>n;
        
        vll nums(n);
        fill_arr(nums);
        ll ans = 0;
        for(auto num: nums ) ans += num;
        int l = n-1;

        while(l>0){
        
            ll sum1 = 0;
            
    
            for(int i =0; i< l ; i++){
        
                nums[i] = nums[i+1] - nums[i];

            }
            for(int i =0; i< l; i++) sum1+= nums[i];
            
            l --;
            ans  = max({ans, sum1, -sum1});


        }


        print(ans);

    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define ull unsigned long long
using namespace std;
ll mll= LLONG_MAX;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll numx[105];
ll numy[105];
ll numz[105];
int main()
{
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    ll t;
    cin>>t;
    while(t--)
    {
        ll x,y,xx,yy;
        cin>>x>>y;
        xx=x;
        yy=y;
        ll len=0;
        while(yy!=0)
        {
            len++;
            numy[len]=yy%2;
            yy/=2;
        }
        ll cur=0;
        while(xx!=0)
        {
            cur++;
            numx[cur]=xx%2;
            xx/=2;
        }
        ll sum=0;
        for(ll i=len;i>=1;i--)
        {
            if(numx[i]==1&&numy[i]==1)
            {
                numz[i]=1;
            }
            else if(numy[i]==1&&numx[i]==0)
            {
                sum++;
                numz[i]=0;
            }
            else if(numx[i]==0&&numy[i]==0)
            {
                if(sum>=1)
                {
                    sum--;
                    numz[i]=1;
                }
                else
                {
                    numz[i]=0;
                }
            }
            else
            {
                numz[i]=1;
            }
        }
        ll z=0;
        ll ans=1;
        for(ll i=1;i<=len;i++)
        {
            z+=(numz[i])*ans;
            ans*=2;
        }
        cout<<x<<" "<<y<<" "<<z<<"\n";
    }
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;

#define endl "\n"
#define read(arr) for (auto &x : arr) cin >> x;
#define print(arr) for (auto &x : arr) cout << x << ' '; cout << endl;
#define sortv(arr) sort(arr.begin(), arr.end())
#define sorta(arr) sort(arr.begin(), arr.end())
#define revers(arr) reverse(arr.begin(), arr.end())
#define ll long long
#define vi vector<int>
#define fastread() (ios_base::sync_with_stdio(false), cin.tie(NULL))

void solve() {
    ll n;
    cin>>n;
    int c2=0,c3=0;
    int sum=0;
    while(n){
        int l =n%10;
        if(l==2){
            c2++;
        }
        if(l==3){
            c3++;
        }
        sum+=l;
        n/=10;
    }
   
    for(int i =0;i<=c2;i++){
       for(int j =0;j<=c3;j++){
        ll x =sum + i*2 + j*6;
        if(x%9==0){
            cout<<"YES"<<endl;
            return;
        }
       }
    }
    cout<<"NO"<<endl;
    return ;
}

int main() {
    fastread(); // Enable fast input/output
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;

#define endl "\n"
#define read(arr) for (auto &x : arr) cin >> x;
#define print(arr) for (auto &x : arr) cout << x << ' '; cout << endl;
#define sortv(arr) sort(arr.begin(), arr.end())
#define sorta(arr) sort(arr.begin(), arr.end())
#define revers(arr) reverse(arr.begin(), arr.end())
#define ll long long
#define vi vector<int>
#define fastread() (ios_base::sync_with_stdio(false), cin.tie(NULL))

void solve() {
    ll n;
    cin>>n;
    ll c2=0,c3=0;
    ll sum=0;
    while(n){
        int l =n%10;
        if(l==2){
            c2++;
        }
        if(l==3){
            c3++;
        }
        sum+=l;
        n/=10;
    }
    if(c2>10) c2=10;
    if(c3>10) c3=10;
    for(int i =0;i<=c2;i++){
       for(int j =0;j<=c3;j++){
        ll x =sum + i*2 + j*6;
        if(x%9==0){
            cout<<"YES"<<endl;
            return;
        }
       }
    }
    cout<<"NO"<<endl;
    return ;
}

int main() {
    fastread(); // Enable fast input/output
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

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

#define endl "\n"
#define read(arr) for (auto &x : arr) cin >> x;
#define print(arr) for (auto &x : arr) cout << x << ' '; cout << endl;
#define sortv(arr) sort(arr.begin(), arr.end())
#define sorta(arr) sort(arr.begin(), arr.end())
#define revers(arr) reverse(arr.begin(), arr.end())
#define ll long long
#define vi vector<int>
#define fastread() (ios_base::sync_with_stdio(false), cin.tie(NULL))

void solve() {
    string s;
    cin>>s;
    ll c2=0,c3=0;
    ll sum=0;
    for(auto &i:s){
        if(i=='2') c2++;
        if(i=='3') c3++;
        sum+=i-'0';
    }
    if(c2>10) c2=10;
    if(c3>10) c3=10;
    for(int i =0;i<=c2;i++){
       for(int j =0;j<=c3;j++){
        ll x =sum + i*2 + j*6;
        if(x%9==0){
            cout<<"YES"<<endl;
            return;
        }
       }
    }
    cout<<"NO"<<endl;
    return ;
}

int main() {
    fastread(); // Enable fast input/output
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;

#define endl "\n"
#define read(arr) for (auto &x : arr) cin >> x;
#define print(arr) for (auto &x : arr) cout << x << ' '; cout << endl;
#define sortv(arr) sort(arr.begin(), arr.end())
#define sorta(arr) sort(arr.begin(), arr.end())
#define revers(arr) reverse(arr.begin(), arr.end())
#define ll long long
#define vi vector<int>
#define fastread() (ios_base::sync_with_stdio(false), cin.tie(NULL))

void solve() {
    ll n;
    cin>>n;
    int c2=0,c3=0;
    int sum=0;
    while(n){
        int l =n%10;
        if(l==2){
            c2++;
        }
        if(l==3){
            c3++;
        }
        sum+=l;
        n/=10;
    }
   
    for(int i =0;i<=c2;i++){
       for(int j =0;j<=c3;j++){
        ll x =sum + i*2 + j*6;
        if(x%9==0){
            cout<<"YES"<<endl;
            return;
        }
       }
    }
    cout<<"NO"<<endl;
    return ;
}

int main() {
    fastread(); // Enable fast input/output
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;

#define endl "\n"
#define read(arr) for (auto &x : arr) cin >> x;
#define print(arr) for (auto &x : arr) cout << x << ' '; cout << endl;
#define sortv(arr) sort(arr.begin(), arr.end())
#define sorta(arr) sort(arr.begin(), arr.end())
#define revers(arr) reverse(arr.begin(), arr.end())
#define ll long long
#define vi vector<int>
#define fastread() (ios_base::sync_with_stdio(false), cin.tie(NULL))

void solve() {
    ll n;
    cin>>n;
    ll c2=0,c3=0;
    ll sum=0;
    while(n){
        int l =n%10;
        if(l==2){
            c2++;
        }
        if(l==3){
            c3++;
        }
        sum+=l;
        n/=10;
    }
    if(c2>10) c2=10;
    if(c3>10) c3=10;
    for(int i =0;i<=c2;i++){
       for(int j =0;j<=c3;j++){
        ll x =sum + i*2 + j*6;
        if(x%9==0){
            cout<<"YES"<<endl;
            return;
        }
       }
    }
    cout<<"NO"<<endl;
    return ;
}

int main() {
    fastread(); // Enable fast input/output
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}