ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>
#include <algorithm>
using namespace std;
int main(){
    int t; cin>>t;
    while(t--){
        int n; cin>>n;
        int a[n];
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        for(int i=0;i<n ;i++){
            int x=min(a[i],a[i+1]);
            if(i!=n-1){
                a[i]=a[i]-x;
                a[i+1]=a[i+1]-x;
            }
        }
        bool check=0;
        for(int i=0;i<n;i++){
           if(a[i]<=a[i+1]){
            check=1;
           }
          else{
            check =0 ;
            break;
          }
        }
        if(check){
            cout<<"YES";
        }
        else cout <<"NO";
        if(t>0)
        cout <<"\n";
    }
    return 0;

}


Submission (verdict: Wrong answer on test 1):
#include<iostream>
#include <algorithm>
using namespace std;
int main(){
    int t; cin>>t;
    while(t--){
        int n; cin>>n;
        int a[n];
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        for(int i=0;i<n ;i++){
            if(i!=n-1){
                int x=min(a[i],a[i+1]);

                a[i]=a[i]-x;
                a[i+1]=a[i+1]-x;
            }

        }
        bool check=0;
        for(int i=0;i<n;i++){
           if(a[i]<=a[i+1]){
            check=1;
           }
          else{
            check =0 ;
            break;
          }
        }
        if(check){
            cout<<"YES";
        }
        else cout <<"NO";
        if(t>0)
        cout <<"\n";
    }
    return 0;

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

Previous submission (verdict: Wrong answer on test 2):
/*يارب افتح لي خير واختم لي بخير واجعل لي من لدنك سلطانا نصيرا*/
#include <iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include <vector>
#include <set>
#include<stack>
#include <iomanip>
#include<map>
using namespace std;
#define ll long long
#define el '\n'
#define MAX_VALUE (1LL << 32) - 1 // -> 2^32 - 1
#define all(v) v.begin(),v.end()
const int sizee = 10005;
int main() {
    cin.tie(0), ios::sync_with_stdio(0);
    int tt=1; cin >> tt;
    while (tt--) {
        int n; cin >> n;
        vector<int>v(n);
        for (auto& i : v)
            cin >> i;
        ll ans = 0;
        if (n == 1) {
            cout << v[0] << el;
            continue;
        }
        while (true) {
            bool cc = 0;
            for (int i = 0; i < n; i++) {
                if (v[i] <= 0) {
                    cc = 1;
                    break;
                }
            }
            if (n == 1)
                cc = 0;
            if (cc) {
                for (int i = 0; i < n - 1; i++)
                    v[i] = v[i + 1] - v[i];
                n--;
            }
            else {
                for (int i = 0; i < n; i++)
                    ans += v[i];
                break;
            }
        }
        cout << abs(ans) << el;
    }
    return 0;
}

Submission (verdict: Wrong answer on test 2):
/*يارب افتح لي خير واختم لي بخير واجعل لي من لدنك سلطانا نصيرا*/
#include <iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include <vector>
#include <set>
#include<stack>
#include <iomanip>
#include<map>
using namespace std;
#define ll long long
#define el '\n'
#define MAX_VALUE (1LL << 32) - 1 // -> 2^32 - 1
#define all(v) v.begin(),v.end()
const int sizee = 10005;
int main() {
    cin.tie(0), ios::sync_with_stdio(0);
    int tt=1; cin >> tt;
    while (tt--) {
        int n; cin >> n;
        vector<ll>v(n);
        for (auto& i : v)
            cin >> i;
        ll ans = 0;
        if (n == 1) {
            cout << v[0] << el;
            continue;
        }
        while (true) {
            bool cc = 0;
            for (int i = 0; i < n; i++) {
                if (v[i] <= 0) {
                    cc = 1;
                    break;
                }
            }
            if (n == 1)
                cc = 0;
            if (cc) {
                for (int i = 0; i < n - 1; i++)
                    v[i] = v[i + 1] - v[i];
                n--;
            }
            else {
                for (int i = 0; i < n; i++)
                    ans += v[i];
                break;
            }
        }
        cout << abs(ans) << el;
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
/*يارب افتح لي خير واختم لي بخير واجعل لي من لدنك سلطانا نصيرا*/
#include <iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include <vector>
#include <set>
#include<stack>
#include <iomanip>
#include<map>
using namespace std;
#define ll long long
#define el '\n'
#define MAX_VALUE (1LL << 32) - 1 // -> 2^32 - 1
#define all(v) v.begin(),v.end()
const int sizee = 10005;
int main() {
    cin.tie(0), ios::sync_with_stdio(0);
    int tt=1; cin >> tt;
    while (tt--) {
        int n; cin >> n;
        vector<ll>v(n);
        for (auto& i : v)
            cin >> i;
        ll ans = 0;
        if (n == 1) {
            cout << v[0] << el;
            continue;
        }
        while (true) {
            bool cc = 0;
            for (int i = 0; i < n; i++) {
                if (v[i] <= 0) {
                    cc = 1;
                    break;
                }
            }
            if (n == 1)
                cc = 0;
            if (cc) {
                for (int i = 0; i < n - 1; i++)
                    v[i] = v[i + 1] - v[i];
                n--;
            }
            else {
                for (int i = 0; i < n; i++)
                    ans += v[i];
                break;
            }
        }
        cout << abs(ans) << el;
    }
    return 0;
}

Submission (verdict: Accepted):
/*يارب افتح لي خير واختم لي بخير واجعل لي من لدنك سلطانا نصيرا*/
#include <iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include <vector>
#include <set>
#include<stack>
#include <iomanip>
#include<map>
#include<numeric>
using namespace std;
#define ll long long
#define el '\n'
#define MAX_VALUE (1LL << 32) - 1 // -> 2^32 - 1
#define all(v) v.begin(),v.end()
const int sizee = 10005;
int main() {
    cin.tie(0), ios::sync_with_stdio(0);
    int tt = 1; cin >> tt;
    while (tt--) {
        int n; cin >> n;
        vector<ll>v(n);
        for (auto& i : v)
            cin >> i;
        ll ans = 0;
        ans = accumulate(v.begin(), v.end(), 0ll);
        if (n == 1) {
            cout << v[0] << el;
            continue;
        }
        while (true) {
            ll sum = 0;
            if (n == 1) {
                sum = v[0];
                ans = max(ans, abs(sum));
                break;
            }
            for (int i = 0; i < n - 1; i++) {
                v[i] = v[i + 1] - v[i];
                sum += v[i];
            }
                n--;
                ans = max(ans, abs(sum));
        }
        cout << abs(ans) << el;
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
/*يارب افتح لي خير واختم لي بخير واجعل لي من لدنك سلطانا نصيرا*/
#include <iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include <vector>
#include <set>
#include<stack>
#include <iomanip>
#include<map>
using namespace std;
#define ll long long
#define el '\n'
#define MAX_VALUE (1LL << 32) - 1 // -> 2^32 - 1
#define all(v) v.begin(),v.end()
const int sizee = 10005;
int main() {
    cin.tie(0), ios::sync_with_stdio(0);
    int tt=1; cin >> tt;
    while (tt--) {
        int n; cin >> n;
        vector<int>v(n);
        for (auto& i : v)
            cin >> i;
        ll ans = 0;
        while (true) {
            bool cc = 0;
            for (int i = 0; i < n; i++) {
                if (v[i] <= 0) {
                    cc = 1;
                    break;
                }
            }
            if (n == 1)
                cc = 0;
            if (cc) {
                for (int i = 0; i < n - 1; i++)
                    v[i] = v[i + 1] - v[i];
                n--;
            }
            else {
                for (int i = 0; i < n; i++)
                    ans += v[i];
                break;
            }
        }
        cout << abs(ans) << el;
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
/*يارب افتح لي خير واختم لي بخير واجعل لي من لدنك سلطانا نصيرا*/
#include <iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include <vector>
#include <set>
#include<stack>
#include <iomanip>
#include<map>
using namespace std;
#define ll long long
#define el '\n'
#define MAX_VALUE (1LL << 32) - 1 // -> 2^32 - 1
#define all(v) v.begin(),v.end()
const int sizee = 10005;
int main() {
    cin.tie(0), ios::sync_with_stdio(0);
    int tt=1; cin >> tt;
    while (tt--) {
        int n; cin >> n;
        vector<int>v(n);
        for (auto& i : v)
            cin >> i;
        ll ans = 0;
        while (true) {
            bool cc = 0;
            for (int i = 0; i < n; i++) {
                if (v[i] <= 0) {
                    cc = 1;
                    break;
                }
            }
            if (n == 1)
                cc = 0;
            if (cc) {
                for (int i = 0; i < n - 1; i++)
                    v[i] = v[i + 1] - v[i];
                n--;
            }
            else {
                for (int i = 0; i < n; i++)
                    ans += v[i];
                break;
            }
        }
        cout << abs(ans) << el;
    }
    return 0;
}

Submission (verdict: Wrong answer on test 2):
/*يارب افتح لي خير واختم لي بخير واجعل لي من لدنك سلطانا نصيرا*/
#include <iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include <vector>
#include <set>
#include<stack>
#include <iomanip>
#include<map>
using namespace std;
#define ll long long
#define el '\n'
#define MAX_VALUE (1LL << 32) - 1 // -> 2^32 - 1
#define all(v) v.begin(),v.end()
const int sizee = 10005;
int main() {
    cin.tie(0), ios::sync_with_stdio(0);
    int tt=1; cin >> tt;
    while (tt--) {
        int n; cin >> n;
        vector<int>v(n);
        for (auto& i : v)
            cin >> i;
        ll ans = 0;
        if (n == 1) {
            cout << v[0] << el;
            continue;
        }
        while (true) {
            bool cc = 0;
            for (int i = 0; i < n; i++) {
                if (v[i] <= 0) {
                    cc = 1;
                    break;
                }
            }
            if (n == 1)
                cc = 0;
            if (cc) {
                for (int i = 0; i < n - 1; i++)
                    v[i] = v[i + 1] - v[i];
                n--;
            }
            else {
                for (int i = 0; i < n; i++)
                    ans += v[i];
                break;
            }
        }
        cout << abs(ans) << el;
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 7):
// Aitijhya Modak

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

struct custom_hash
{
	static uint64_t splitmix64(uint64_t x)
	{
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const
	{
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};

void solution()
{
	int n;
	cin >> n;

	vector<int> arr(n);
	unordered_set<int> st;

	for (auto &x : arr)
	{
		cin >> x;
		st.insert(x);
	}

	vector<vector<int>> output;
	for (int i : arr)
	{
		st.erase(i);

		for (int j = i - 1; j >= 1; j--)
		{
			if (st.find(j) != st.end())
				output.push_back({i, j});
		}
	}

	vector<int> mem(n, 1);

	for (int i = 1; i < n; i++)
	{
		if (arr[i] > arr[i - 1])
			mem[i] = mem[i - 1] + 1;
	}

	for (int i = 0; i < n; i++)
	{
		if (mem[i] > 1)
		{
			int x = mem[i] - 1;
			int k = i - 1;
			while (x--)
			{
				output.push_back({arr[i], arr[k--]});
			}
			x = mem[i] - 1;
			while (x--)
			{
				output.push_back({arr[++k], arr[i]});
			}
		}
	}

	cout << output.size() << endl;
	for (auto &v : output)
		cout << v[0] << " " << v[1] << endl;
	return;
}

int main()
{
	// int t;
	// cin >> t;
	// while (t--)
	solution();
}

Submission (verdict: Wrong answer on test 7):
// Aitijhya Modak

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

struct custom_hash
{
	static uint64_t splitmix64(uint64_t x)
	{
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const
	{
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};

void solution()
{
	int n;
	cin >> n;

	vector<int> arr(n);
	unordered_set<int> st;

	for (auto &x : arr)
	{
		cin >> x;
		st.insert(x);
	}

	vector<vector<int>> output;
	for (int i : arr)
	{
		st.erase(i);

		for (int j = i - 1; j >= 1; j--)
		{
			if (st.find(j) != st.end())
				output.push_back({i, j});
		}
	}

	vector<int> mem(n, 1);

	for (int i = 1; i < n; i++)
	{
		if (arr[i] > arr[i - 1])
			mem[i] = mem[i - 1] + 1;
	}

	for (int i = 0; i < n; i++)
	{
		if (mem[i] > 1)
		{
			int x = mem[i] - 1;
			int k = i - 1;
			while (x--)
				output.push_back({arr[i], arr[k--]});

			x = mem[i] - 1;

			while (x--)
				output.push_back({arr[++k], arr[i]});
		}
	}

	cout << output.size() << endl;
	for (auto &v : output)
		cout << v[0] << " " << v[1] << endl;
	return;
}

int main()
{
	// int t;
	// cin >> t;
	// while (t--)
	solution();
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 7):
// Aitijhya Modak

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

struct custom_hash
{
	static uint64_t splitmix64(uint64_t x)
	{
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const
	{
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};

void solution()
{
	int n;
	cin >> n;

	vector<int> arr(n);
	unordered_set<int> st;

	for (auto &x : arr)
	{
		cin >> x;
		st.insert(x);
	}

	vector<vector<int>> output;
	for (int i : arr)
	{
		st.erase(i);

		for (int j = i - 1; j >= 1; j--)
		{
			if (st.find(j) != st.end())
				output.push_back({i, j});
		}
	}

	vector<int> mem(n, 1);

	for (int i = 1; i < n; i++)
	{
		if (arr[i] > arr[i - 1])
			mem[i] = mem[i - 1] + 1;
	}

	for (int i = 0; i < n; i++)
	{
		if (mem[i] > 1)
		{
			int x = mem[i] - 1;
			int k = i - 1;
			while (x--)
			{
				output.push_back({arr[i], arr[k--]});
			}
			x = mem[i] - 1;
			while (x--)
			{
				output.push_back({arr[++k], arr[i]});
			}
		}
	}

	cout << output.size() << endl;
	for (auto &v : output)
		cout << v[0] << " " << v[1] << endl;
	return;
}

int main()
{
	// int t;
	// cin >> t;
	// while (t--)
	solution();
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 7):
// Aitijhya Modak

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

struct custom_hash
{
	static uint64_t splitmix64(uint64_t x)
	{
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const
	{
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};

void solution()
{
	int n;
	cin >> n;

	vector<int> arr(n);
	unordered_set<int> st;

	for (auto &x : arr)
	{
		cin >> x;
		st.insert(x);
	}

	vector<vector<int>> output;
	for (int i : arr)
	{
		st.erase(i);

		for (int j = i - 1; j >= 1; j--)
		{
			if (st.find(j) != st.end())
				output.push_back({i, j});
		}
	}

	vector<int> mem(n, 1);

	for (int i = 1; i < n; i++)
	{
		if (arr[i] > arr[i - 1])
			mem[i] = mem[i - 1] + 1;
	}

	for (int i = 0; i < n; i++)
	{
		if (mem[i] > 1)
		{
			int x = mem[i] - 1;
			int k = i - 1;
			while (x--)
				output.push_back({arr[i], arr[k--]});

			x = mem[i] - 1;

			while (x--)
				output.push_back({arr[++k], arr[i]});
		}
	}

	cout << output.size() << endl;
	for (auto &v : output)
		cout << v[0] << " " << v[1] << endl;
	return;
}

int main()
{
	// int t;
	// cin >> t;
	// while (t--)
	solution();
}

Submission (verdict: Accepted):
// Aitijhya Modak

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

struct custom_hash
{
	static uint64_t splitmix64(uint64_t x)
	{
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const
	{
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};

void solution()
{
	int n;
	cin >> n;

	vector<int> arr(n);
	unordered_set<int> st1, st2;
	vector<int> vec;

	for (int i = n; i >= 1; i--)
	{
		vec.push_back(i);
		st1.insert(i);
	}

	for (auto &x : arr)
	{
		cin >> x;
		st2.insert(x);
	}

	vector<vector<int>> output;
	for (int i : vec)
	{
		st1.erase(i);

		for (int j = i - 1; j >= 1; j--)
		{
			if (st1.find(j) != st1.end())
				output.push_back({i, j});
		}
	}

	for (int i : arr)
	{
		st2.erase(i);

		for (int j = i + 1; j <= n; j++)
		{
			if (st2.find(j) != st2.end())
				output.push_back({i, j});
		}
	}

	cout << output.size() << endl;
	for (auto &v : output)
		cout << v[0] << " " << v[1] << endl;
	return;
}

int main()
{
	// int t;
	// cin >> t;
	// while (t--)
	solution();
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define gcd(a, b) __gcd(a, b);
#define lcm(a, b) (a / (__gcd(a, b))) * b
#define all(v) v.begin(),v.end()
#define cin(v,n) for(int i=0;i<n;i++) cin>>v[i];
signed main()
{
    int tt;cin>>tt;
    while(tt--){
        int n;cin>>n;
        int sum=0;
        int ct2=0,ct3=0;
        while(n>0){
            sum+=n%10;
            if(n%10==2) ct2+=1;
            else if(n%10==3) ct3+=1;
            n/=10;
        }
        int temp=sum;
        bool f=false;
        for(int i=0;i<=ct2;i++){
            
            for (int j=0;j<=ct3;j++){
                temp=sum;
                temp+=(i*2)+(j*6);
                if(temp%9==0) {
                    
                    f=true;
                    break;
                }
            }
            if(f) break;

        }
        if(f) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;        
    }
return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define gcd(a, b) __gcd(a, b);
#define lcm(a, b) (a / (__gcd(a, b))) * b
#define all(v) v.begin(),v.end()
#define cin(v,n) for(int i=0;i<n;i++) cin>>v[i];
signed main()
{
    int tt;cin>>tt;
    while(tt--){
        int n;cin>>n;
        int sum=0;
        int ct2=0,ct3=0;
        while(n>0){
            sum+=n%10;
            if(n%10==2) ct2+=1;
            else if(n%10==3) ct3+=1;
            n/=10;
        }
        int temp=sum;
        bool f=false;
        for(int i=0;i<=ct2;i++){
            
            for (int j=0;j<=ct3;j++){
                temp=sum;
                temp+=(i*2)+(j*6);
                if(temp%9==0) {
                    
                    f=true;
                    break;
                }
            }
            if(f) break;

        }
        if(f) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;        
    }
return 0;
}

Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define int long long
signed main()
{
    int tt;cin>>tt;
    while(tt--){
        int n;cin>>n;
        int sum=0;
        int ct2=0,ct3=0;
        while(n>0){
            sum+=n%10;
            if(n%10==2) ct2+=1;
            else if(n%10==3) ct3+=1;
            n/=10;
        }
        int temp=sum;
        bool f=false;
        int p=10;
        for(int i=0;i<=min(p,ct2);i++){
            
            for (int j=0;j<=min(p,ct3);j++){
                temp=sum;
                temp+=(i*2)+(j*6);
                if(temp%9==0) {
                    
                    f=true;
                    break;
                }
            }
            if(f) break;

        }
        if(f) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;        
    }
return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define int long long
signed main()
{
    int tt;cin>>tt;
    while(tt--){
        int n;cin>>n;
        int sum=0;
        int ct2=0,ct3=0;
        while(n>0){
            sum+=n%10;
            if(n%10==2) ct2+=1;
            else if(n%10==3) ct3+=1;
            n/=10;
        }
        int temp=sum;
        bool f=false;
        int p=10;
        for(int i=0;i<=min(p,ct2);i++){
            
            for (int j=0;j<=min(p,ct3);j++){
                temp=sum;
                temp+=(i*2)+(j*6);
                if(temp%9==0) {
                    
                    f=true;
                    break;
                }
            }
            if(f) break;

        }
        if(f) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;        
    }
return 0;
}

Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define int long long
signed main()
{
    int tt;cin>>tt;
    while(tt--){
        int n;cin>>n;
        int sum=0;
        int ct2=0,ct3=0;
        while(n>0){
            sum+=n%10;
            if(n%10==2) ct2+=1;
            else if(n%10==3) ct3+=1;
            n/=10;
        }
        int temp=sum;
        bool f=false;
        for(int i=0;i<=min(10LL,ct2);i++){
            
            for (int j=0;j<=min(10LL,ct3);j++){
                temp=sum;
                temp+=(i*2)+(j*6);
                if(temp%9==0) {
                    
                    f=true;
                    break;
                }
            }
            if(f) break;

        }
        if(f) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;        
    }
return 0;
}