ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=57;
int a[N],t,n,sum,ans;
signed main(){
	scanf("%lld",&t);
	while(t--){
		scanf("%lld",&n);
		for(int i=1;i<=n;i++) scanf("%lld",&a[i]),sum+=a[i];
		if(n==1){
			printf("%lld\n",a[1]);
			continue;
		}
		ans=max(ans,sum),sum=0;
		while(n>1){
			for(int i=1;i<n;i++) a[i]-=a[i+1],sum+=a[i];
			n--,ans=max(ans,abs(sum)),sum=0;
		}
		printf("%lld\n",ans);
	}
	return 0;
}


Submission (verdict: Wrong answer on test 10):
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=57;
int a[N],t,n,sum,ans;
signed main(){
	scanf("%lld",&t);
	while(t--){
		scanf("%lld",&n),ans=0;
		for(int i=1;i<=n;i++) scanf("%lld",&a[i]),sum+=a[i];
		if(n==1){
			printf("%lld\n",a[1]);
			continue;
		}
		ans=max(ans,sum),sum=0;
		while(n>1){
			for(int i=1;i<n;i++) a[i]-=a[i+1],sum+=a[i];
			n--,ans=max(ans,abs(sum)),sum=0;
		}
		printf("%lld\n",ans);
	}
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 10):
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=57;
int a[N],t,n,sum,ans;
signed main(){
	scanf("%lld",&t);
	while(t--){
		scanf("%lld",&n),ans=0;
		for(int i=1;i<=n;i++) scanf("%lld",&a[i]),sum+=a[i];
		if(n==1){
			printf("%lld\n",a[1]);
			continue;
		}
		ans=max(ans,sum),sum=0;
		while(n>1){
			for(int i=1;i<n;i++) a[i]-=a[i+1],sum+=a[i];
			n--,ans=max(ans,abs(sum)),sum=0;
		}
		printf("%lld\n",ans);
	}
	return 0;
}


Submission (verdict: Accepted):
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=57,INF=1e18+7;
int a[N],t,n,sum,ans;
signed main(){
	scanf("%lld",&t);
	while(t--){
		scanf("%lld",&n),ans=-INF;
		for(int i=1;i<=n;i++) scanf("%lld",&a[i]),sum+=a[i];
		ans=max(ans,sum),sum=0;
		while(n>1){
			for(int i=1;i<n;i++) a[i]-=a[i+1],sum+=a[i];
			n--,ans=max(ans,abs(sum)),sum=0;
		}
		ans=max(ans,a[1]),printf("%lld\n",ans);
	}
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=57;
int a[N],t,n,sum,ans;
signed main(){
	scanf("%lld",&t);
	while(t--){
		scanf("%lld",&n);
		for(int i=1;i<=n;i++) scanf("%lld",&a[i]),sum+=a[i];
		if(n==1){
			printf("%lld\n",a[1]);
			continue;
		}
		ans=max(ans,sum),sum=0;
		while(n>1){
			for(int i=1;i<n;i++) a[i]-=a[i+1],sum+=a[i];
			n--,ans=max(ans,abs(sum)),sum=0;
		}
		printf("%lld\n",ans);
	}
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>

using namespace std;

typedef long long ll;
const int N = 1010;

int T, n;
ll a[N];

ll getSum(int num) {
    ll sum = 0;
    for (int i = 1; i <= num; i++)
        sum += a[i];
    return abs(sum);
}

int main() {
    ios::sync_with_stdio(false);
    cin >> T;
    while(T--) {
        cin >> n;
        for (int i = 1; i <= n; i++)
            cin >> a[i];
        if (n == 1) {
            cout << a[1] << endl;
            continue;
        }
        ll ans = 0;
        for (int i = 1; i <= n; i++) {
            int num = n - i + 1;
            ans = max(ans, getSum(num));
            for (int j = 1; j < num; j++)
                a[j] -= a[j + 1];
        }
        cout << ans << endl;
    }
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <iostream>

using namespace std;

typedef long long ll;
const int N = 1010;

int T, n;
ll a[N];

ll getSum(int num) {
    ll sum = 0;
    for (int i = 1; i <= num; i++)
        sum += a[i];
    return abs(sum);
}

int main() {
    ios::sync_with_stdio(false);
    cin >> T;
    while(T--) {
        cin >> n;
        for (int i = 1; i <= n; i++)
            cin >> a[i];
        if (n == 1) {
            cout << a[1] << endl;
            continue;
        }
        ll ans = -1e18;
        for (int i = 1; i <= n; i++) {
            int num = n - i;
            for (int j = 1; j <= num; j++)
                a[j] -= a[j + 1];
            ans = max(ans, getSum(num));
        }
        cout << ans << endl;
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>

using namespace std;

typedef long long ll;
const int N = 1010;

int T, n;
ll a[N];

ll getSum(int num) {
    ll sum = 0;
    for (int i = 1; i <= num; i++)
        sum += a[i];
    return abs(sum);
}

int main() {
    ios::sync_with_stdio(false);
    cin >> T;
    while(T--) {
        cin >> n;
        for (int i = 1; i <= n; i++)
            cin >> a[i];
        if (n == 1) {
            cout << a[1] << endl;
            continue;
        }
        ll ans = -1e18;
        for (int i = 1; i <= n; i++) {
            int num = n - i;
            for (int j = 1; j <= num; j++)
                a[j] -= a[j + 1];
            ans = max(ans, getSum(num));
        }
        cout << ans << endl;
    }
    return 0;
}

Submission (verdict: Accepted):
#include <iostream>

using namespace std;

typedef long long ll;
const int N = 1010;

int T, n;
ll a[N];

ll getSum(int num) {
    ll sum = 0;
    for (int i = 1; i <= num; i++)
        sum += a[i];
    return abs(sum);
}

int main() {
    ios::sync_with_stdio(false);
    cin >> T;
    while(T--) {
        cin >> n;
        for (int i = 1; i <= n; i++)
            cin >> a[i];
        if (n == 1) {
            cout << a[1] << endl;
            continue;
        }
        ll ans = -1e18, sum = 0;
        for (int i = 1; i <= n; i++)
            sum += a[i];
        ans = max(ans, sum);
        for (int i = 1; i <= n; i++) {
            int num = n - i;
            for (int j = 1; j <= num; j++)
                a[j] -= a[j + 1];
            ans = max(ans, getSum(num));
        }
        cout << ans << endl;
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <iostream>

using namespace std;

typedef long long ll;
const int N = 1010;

int T, n;
ll a[N];

ll getSum(int num) {
    ll sum = 0;
    for (int i = 1; i <= num; i++)
        sum += a[i];
    return abs(sum);
}

int main() {
    ios::sync_with_stdio(false);
    cin >> T;
    while(T--) {
        cin >> n;
        for (int i = 1; i <= n; i++)
            cin >> a[i];
        if (n == 1) {
            cout << a[1] << endl;
            continue;
        }
        ll ans = 0;
        for (int i = 1; i <= n; i++) {
            int num = n - i + 1;
            ans = max(ans, getSum(num));
            for (int j = 1; j < num; j++)
                a[j] -= a[j + 1];
        }
        cout << ans << endl;
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 14):
#include <iostream>
#include <unordered_map>
#include <vector>
#include <algorithm>

using namespace std;

const int N = 100010;

int f[N];

unordered_map<int, int> mp;

int main() {
    int T; cin >> T;
    while (T --) {
        mp.clear();
        int n, k; scanf("%d %d", &n, &k);
        for (int i = 1; i <= n; i ++) {
            scanf("%d", &f[i]);
            mp[f[i]] ++;
        }

        vector<int> res;
        for (auto [x, y] : mp) res.push_back(y);
        sort(res.begin(), res.end());
        int ans = 0;
        for (auto x : res) {
            if (k >= x) {
                k -= x;
            } else ans ++;
        } 

        if (ans == 0) ans ++;
        cout << ans << endl;
    }
}

Submission (verdict: Accepted):
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

const int N = 100010;

int f[N];

map<int, int> mp;

int main() {
    int T; cin >> T;
    while (T --) {
        mp.clear();
        int n, k; scanf("%d %d", &n, &k);
        for (int i = 1; i <= n; i ++) {
            scanf("%d", &f[i]);
            mp[f[i]] ++;
        }

        vector<int> res;
        for (auto [x, y] : mp) res.push_back(y);
        sort(res.begin(), res.end());
        int ans = 0;
        for (auto x : res) {
            if (k >= x) {
                k -= x;
            } else ans ++;
        } 

        if (ans == 0) ans ++;
        cout << ans << endl;
    }
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 14):
#include <iostream>
#include <unordered_map>
#include <vector>
#include <algorithm>

using namespace std;

const int N = 100010;

int f[N];

unordered_map<int, int> mp;

int main() {
    int T; cin >> T;
    while (T --) {
        mp.clear();
        int n, k; cin >> n >> k;
        for (int i = 1; i <= n; i ++) {
            cin >> f[i];
            mp[f[i]] ++;
        }

        vector<int> res;
        for (auto [x, y] : mp) res.push_back(y);
        sort(res.begin(), res.end());
        int ans = 0;
        for (auto x : res) {
            if (k >= x) {
                k -= x;
            } else ans ++;
        } 

        if (ans == 0) ans ++;
        cout << ans << endl;
    }
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 14):
#include <iostream>
#include <unordered_map>
#include <vector>
#include <algorithm>

using namespace std;

const int N = 100010;

int f[N];

unordered_map<int, int> mp;

int main() {
    int T; cin >> T;
    while (T --) {
        mp.clear();
        int n, k; cin >> n >> k;
        for (int i = 1; i <= n; i ++) {
            cin >> f[i];
            mp[f[i]] ++;
        }

        vector<int> res;
        for (auto [x, y] : mp) res.push_back(y);
        sort(res.begin(), res.end());
        int ans = 0;
        for (auto x : res) {
            if (k >= x) {
                k -= x;
            } else ans ++;
        } 

        if (ans == 0) ans ++;
        cout << ans << endl;
    }
}

Submission (verdict: Time limit exceeded on test 14):
#include <iostream>
#include <unordered_map>
#include <vector>
#include <algorithm>

using namespace std;

const int N = 100010;

int f[N];

unordered_map<int, int> mp;

int main() {
    int T; cin >> T;
    while (T --) {
        mp.clear();
        int n, k; scanf("%d %d", &n, &k);
        for (int i = 1; i <= n; i ++) {
            scanf("%d", &f[i]);
            mp[f[i]] ++;
        }

        vector<int> res;
        for (auto [x, y] : mp) res.push_back(y);
        sort(res.begin(), res.end());
        int ans = 0;
        for (auto x : res) {
            if (k >= x) {
                k -= x;
            } else ans ++;
        } 

        if (ans == 0) ans ++;
        cout << ans << endl;
    }
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

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

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

#define endl '\n'

#define int long long

using namespace std;

const int N=4e2+10;

typedef long long ll;

int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

int n,m;

int a[N][N];

int d[N];

queue<char> q;

string s;



void solved()

{

	string s;

	cin>>s;

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

	{

		int r=i,l=i-1;

		//cout<<r<<' '<<l<<endl;

		char x=s[r],y=s[l];

		//cout<<x--<<' '<<y<<endl;

		while((x)>y&&l>=0)

		{

			//cout<<s[r]--<<' '<<s[l]<<endl;

			s[r]--;

			x=s[r];

			swap(s[r],s[l]);

			r--;

			l--;

			y=s[l];

			x--;

			//cout<<s<<endl;

			//cout<<x--<<' '<<y<<' '<<l<<endl;

		}

	}

	cout<<s<<endl;

}

signed main()

{

    IOS;

    int t=1;

    cin>>t;

    

    //cout<<t<<endl;

    while(t--)

    {

        solved();

        //cout<<endl;

    }

    //cout<<endl;

}

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

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

#define endl '\n'

#define int long long

using namespace std;

const int N=4e2+10;

typedef long long ll;

int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

int n,m;

int a[N][N];

int d[N];

queue<char> q;

string s;

void solved()

{

	string s;

	cin>>s;

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

	{

		int r=i,l=i-1;

		//cout<<r<<' '<<l<<endl;

		char x=s[r],y=s[l];

		//cout<<x--<<' '<<y<<endl;

		while((x)>y+1&&l>=0)

		{

			//cout<<s[r]--<<' '<<s[l]<<endl;

			s[r]--;

			x=s[r];

			swap(s[r],s[l]);

			r--;

			l--;

			y=s[l];

			x--;

			//cout<<s<<endl;

			//cout<<x--<<' '<<y<<' '<<l<<endl;

		}

	}

	cout<<s<<endl;

}

signed main()

{

    IOS;

    int t=1;

    cin>>t;

    

    //cout<<t<<endl;

    while(t--)

    {

        solved();

        //cout<<endl;

    }

    //cout<<endl;

}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)


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

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

#define endl '\n'

#define int long long

using namespace std;

const int N=4e2+10;

typedef long long ll;

int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

int n,m;

int a[N][N];

int d[N];

queue<char> q;

string s;



void solved()

{

	string s;

	cin>>s;

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

	{

		int r=i,l=i-1;

		//cout<<r<<' '<<l<<endl;

		char x=s[r],y=s[l];

		//cout<<x--<<' '<<y<<endl;

		while((x)>y&&l>=0)

		{

			//cout<<s[r]--<<' '<<s[l]<<endl;

			s[r]--;

			x=s[r];

			swap(s[r],s[l]);

			r--;

			l--;

			y=s[l];

			x--;

			//cout<<s<<endl;

			//cout<<x--<<' '<<y<<' '<<l<<endl;

		}

	}

	cout<<s<<endl;

}

signed main()

{

    IOS;

    int t=1;

    cin>>t;

    

    //cout<<t<<endl;

    while(t--)

    {

        solved();

        //cout<<endl;

    }

    //cout<<endl;

}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

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

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

#define endl '\n'

#define int long long

using namespace std;

const int N=4e2+10;

typedef long long ll;

int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

int n,m;

int a[N][N];

int d[N];

queue<char> q;

string s;

void solved()

{

	string s;

	cin>>s;

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

	{

		int r=i,l=i-1;

		//cout<<r<<' '<<l<<endl;

		char x=s[r],y=s[l];

		//cout<<x--<<' '<<y<<endl;

		while((x)>y+1&&l>=0)

		{

			//cout<<s[r]--<<' '<<s[l]<<endl;

			s[r]--;

			x=s[r];

			swap(s[r],s[l]);

			r--;

			l--;

			y=s[l];

			x--;

			//cout<<s<<endl;

			//cout<<x--<<' '<<y<<' '<<l<<endl;

		}

	}

	cout<<s<<endl;

}

signed main()

{

    IOS;

    int t=1;

    cin>>t;

    

    //cout<<t<<endl;

    while(t--)

    {

        solved();

        //cout<<endl;

    }

    //cout<<endl;

}

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

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

#define endl '\n'

#define int long long

using namespace std;

const int N=4e2+10;

typedef long long ll;

int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

int n,m;

int a[N][N];

int d[N];

queue<char> q;

string s;

void solved()

{

	string s;

	cin>>s;

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

	{

		int r=i,l=i-1;

		//cout<<r<<' '<<l<<endl;

		char x=s[r],y=s[l];

		//cout<<x--<<' '<<y<<endl;

		while((x)>y+1&&l>=0)

		{

			//cout<<s[r]--<<' '<<s[l]<<endl;

			s[r]--;

			x=s[r];

			swap(s[r],s[l]);

			r--;

			l--;

			y=s[l];

			//x--;

			//cout<<s<<endl;

			//cout<<x--<<' '<<y<<' '<<l<<endl;

		}

	}

	cout<<s<<endl;

}

signed main()

{

    IOS;

    int t=1;

    cin>>t;

    

    //cout<<t<<endl;

    while(t--)

    {

        solved();

        //cout<<endl;

    }

    //cout<<endl;

}
Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
// || =================================================================== ||

// ||                                                                     ||

// ||                   Reach Expert by May 2025                          ||

// ||                                                                     ||

// || =================================================================== ||

#include <bits/stdc++.h>

#define int long long

#define endl "\n";

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

#define ONLINE_JUDGE  

using namespace std;

long long mod_exp(long long base, long long exp, long long mod) {

    long long result = 1;

    while (exp > 0) {

        if (exp % 2 == 1) {

            result = (result * base) % mod;     

        }

        base = (base * base) % mod; 

        exp /= 2; 

    }

    return result;

}

void solve() {

    int n, x, y;

	cin >> n >> x >> y;

	vector<int> ans(n + 1);

	for(int i = 1 ; i <= n; i++){

		if(i & 1){

			ans[i] = 1;

		}else ans[i] = 0;

	}

	if((x == 1 && y == n) || (x == n && y == 1) || min(x, y) + 1 == max(x, y)){

		//nothing happens

		for(int i = 1; i <= n; i++){

			cout << ans[i] << " ";

		}

		cout << endl;

		return;

	}

	if(((x % 2 == 0) && (y % 2 == 0)) || ((x % 2 == 1) && (y % 2 == 1))){

		// // here also nothing happens

		for(int i = 1; i <= n; i++){

			cout << ans[i] << " ";

		}

		cout << endl;

		return;

	}

	ans[(int)max(x, y)] = 2;

	for(int i = 1; i <= n; i++){

		cout << ans[i] << " ";

	}

	cout << endl;

}





signed main(){

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    #ifndef ONLINE_JUDGE 

        freopen("input.txt", "r", stdin);  

        freopen("output.txt", "w", stdout); 

    #endif  

    int t;

    cin >> t;

    while(t--)

        solve();

   

} 



/*

void solve() {

    int n, k;

    cin >> n >> k;

    int r = n, l  =1;

	stack<pair<int,int>> st;

	st.push({l, r});

	int ans =0LL;

	while(st.size()){

		auto p = st.top();

		st.pop();

		int curL = p.first;

		int curR = p.second;

		if(curR - curL + 1 < k){

			// do nothing

		}else{

			int sz = curR - curL + 1;

			if(sz & 1){

				int m = (curL + curR) / 2LL;

				ans += m;

				cout << "{" << curL << " , " << curR << "} : " << m << endl;

				st.push({curL, m - 1LL});

				st.push({m + 1LL , curR});

			}else{

				int m = (curL + curR) / 2LL;

				st.push({curL, m});

				st.push({m + 1LL , curR});

			}

		}

	}

	cout << ans << endl;

}

 */
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


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

using namespace std;

typedef long long ll;

const ll MAX = 1e7 + 7;

vector<ll> sp(MAX);  // Smallest prime factor array

vector<bool> v(MAX); // Boolean array to mark composite numbers



ll power(ll x, ll y, ll p)

{

	ll res = 1; // Initialize result

	x = x % p;



	while (y > 0) 

	{

		if (y & 1)

			res = (res * x) % p;

		y = y >> 1; 

		x = (x * x) % p;

	}

	return res;

}



ll modInverse(ll n, ll p)

{

	return power(n, p - 2, p);

}



ll nCr(ll n, ll r, ll p)

{

	if (n < r)

		return 0;

	if (r == 0)

		return 1;



	vector<ll> fac(n + 1);

	fac[0] = 1;

	for (int i = 1; i <= n; i++)

		fac[i] = (fac[i - 1] * i) % p;



	return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p;

}





void Sieve(){

	for (int i = 2; i < MAX; i += 2)	sp[i] = 2;//even numbers have smallest prime factor 2

	for (ll i = 3; i < MAX; i += 2){

		if (!v[i]){

			sp[i] = i;

			for (ll j = i; (j*i) < MAX; j += 2){

				if (!v[j*i])	v[j*i] = true, sp[j*i] = i;

			}

		}

	}

}

int main()

{ int t;

cin>>t;

while(t--){

  int n;

  cin>>n;

  int arr[n];

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

    cin>>arr[i];

  }

  if(arr[0]>arr[1]){

    cout<<"NO"<<endl;

  }

  else{

    int z=-1;

    for(int i=n-2; i>=0; i++){

      if(arr[i]>arr[i+1]){

        z=i;

        break;

      }

    }

    if(z==-1){

      cout<<"YES"<<endl;

      continue;

    }

    //ll sm=arr[0];

    

    

    arr[1]=arr[1]-arr[0];

    arr[0]=0;

    for(int i=1; i<=z; i++){

      if(arr[i]>arr[i+1]&&i!=z){

        arr[i]=arr[i]-arr[i+1];

        arr[i+1]=0;

      }

      else{

        arr[i+1]=arr[i+1]-arr[i];

        arr[i]=0;

      }

    }

    int z2=1;

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

      if(arr[i]<arr[i+1]){

        z2=0;

        break;

      }

    }

    if(z2){

      cout<<"YES"<<endl;

    }

    else{

      cout<<"NO"<<endl;

    }

  }

}

	return 0;

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

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

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

	int cnt=0;
	int cnt2=0;

	for(auto x:s)
	{
		cnt+=x-'0';
		if(x=='2')
			cnt2++;
	}

	bool chk=0;
	cnt=cnt%9;
	cnt2=min(cnt2,10);

	set<int> ss;
	for(int i=0;i<=cnt2;i++)
	{
		ss.insert(cnt+2*i);
	}

	for(auto x:ss)
		if(x%9==0)
			chk=1;

	if(chk)
		cout<<"YES";
	else
		cout<<"NO\n";
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int t=1;
	cin>>t;

	while(t--){
		solve();
	}
}

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

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

	int cnt=0;
	int cnt2=0;
	int cnt3=0;

	for(auto x:s)
	{
		cnt+=x-'0';
		if(x=='2')
			cnt2++;
		if(x=='3')
			cnt3++;
	}

	bool chk=0;
	cnt=cnt%9;
	cnt2=min(cnt2,10);
	cnt3=min(cnt3,3);

	set<int> ss;
	for(int i=0;i<=cnt2;i++)
	{
		for(int j=0;j<=cnt3;j++)
		{
			ss.insert(cnt+2*i+3*j);
		}
	}

	for(auto x:ss)
		if(x%9==0)
			chk=1;

	if(chk)
		cout<<"YES";
	else
		cout<<"NO\n";
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int t=1;
	cin>>t;

	while(t--){
		solve();
	}
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

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

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

	int cnt=0;
	int cnt2=0;

	for(auto x:s)
	{
		cnt+=x-'0';
		if(x=='2')
			cnt2++;
	}

	bool chk=0;
	x=x%9;
	cnt2=min(cnt2,10);

	set<int> ss;
	for(int i=0;i<=cnt2;i++)
	{
		ss.insert(x+2*i);
	}

	for(auto x:ss)
		if(x%9==0)
			chk=1;

	if(chk)
		cout<<"YES";
	else
		cout<<"NO\n";
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int t=1;
	cin>>t;

	while(t--){
		solve();
	}
}

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

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

	int cnt=0;
	int cnt2=0;

	for(auto x:s)
	{
		cnt+=x-'0';
		if(x=='2')
			cnt2++;
	}

	bool chk=0;
	cnt=cnt%9;
	cnt2=min(cnt2,10);

	set<int> ss;
	for(int i=0;i<=cnt2;i++)
	{
		ss.insert(cnt+2*i);
	}

	for(auto x:ss)
		if(x%9==0)
			chk=1;

	if(chk)
		cout<<"YES";
	else
		cout<<"NO\n";
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int t=1;
	cin>>t;

	while(t--){
		solve();
	}
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

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

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

	int cnt=0;
	int cnt2=0;

	for(auto x:s)
	{
		cnt+=x-'0';
		if(x=='2')
			cnt2++;
	}

	bool chk=0;
	x=x%9;
	cnt2=min(cnt2,10);

	set<int> s;
	for(int i=0;i<=cnt2;i++)
	{
		s.insert(x+2*i);
	}

	for(auto x:s)
		if(x%9==0)
			chk=1;

	if(chk)
		cout<<"YES";
	else
		cout<<"NO\n";
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int t=1;
	cin>>t;

	while(t--){
		solve();
	}
}

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

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

	int cnt=0;
	int cnt2=0;

	for(auto x:s)
	{
		cnt+=x-'0';
		if(x=='2')
			cnt2++;
	}

	bool chk=0;
	x=x%9;
	cnt2=min(cnt2,10);

	set<int> ss;
	for(int i=0;i<=cnt2;i++)
	{
		ss.insert(x+2*i);
	}

	for(auto x:ss)
		if(x%9==0)
			chk=1;

	if(chk)
		cout<<"YES";
	else
		cout<<"NO\n";
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int t=1;
	cin>>t;

	while(t--){
		solve();
	}
}