ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define fast {ios_base::sync_with_stdio(false); cin.tie(0);}
typedef long long ll;
#define int long long
#define float long double
int cs;
void solve()
{
    int l,r;
    cin >> l >> r;
    int ll=l,rr=r;
    if(r-l<=10)
    {
        for(int i=l;i<r;i++)
        {

        }
    }
    int k=0;
    for(int i=30;i>=0;i--)
    {
        int x=(1ll<<i);
        if((x&l)==(r&x)) l^=(x&l), k|=(x&r), r^=(x&r);
        else 
        {
            cout << (r|k) << ' ' << ((r-1)|k) << ' ' << ((r-2)|k) << '\n';
            break;
        }
    }
}
signed main()
{
    fast
    int t=1;
    cin >> t;
    for(cs=1;cs<=t;cs++)
    {
        //cout << "Case " << cs << ": "; 
        solve();
    }
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define fast {ios_base::sync_with_stdio(false); cin.tie(0);}
typedef long long ll;
#define int long long
#define float long double
int cs;
void solve()
{
    int l,r;
    cin >> l >> r;
    int ll=l,rr=r;
    int k=0;
    for(int i=30;i>=0;i--)
    {
        int x=(1ll<<i);
        if((x&l)==(r&x)) l^=(x&l), k|=(x&r), r^=(x&r);
        else 
        {
            cout << (x|k) << ' ' << ((x-1)|k) << ' ';
            if(((x-2)|k)<l) cout << ((x+1)|k) << '\n';
            else cout << ((x-2)|k) << '\n';
            break;
        }
    }
}
signed main()
{
    fast
    int t=1;
    cin >> t;
    for(cs=1;cs<=t;cs++)
    {
        //cout << "Case " << cs << ": "; 
        solve();
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Runtime error on test 1):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void solve(){
	//Value taken
	ll n,k,arr[n];
	cin>>n>>k;
	for(ll i=0;i<n;i++) cin>>arr[i];
	if(n==k){
		cout<<"1"<<"\n";
		return;
	}

	// map the array
	map< ll,ll >m;
	for(ll i=0;i<n;i++) m[arr[i]]++;
	vector<int>v;
	map<ll,ll>::iterator it;
	for(it=m.begin();it!=m.end();it++){
		v.push_back((*it).second);
	}
	// sort the vector
	sort(v.begin(),v.end(),greater<>());
	ll count = 0;
    for(ll i = 0; i < v.size(); i++){
        if(k <= 0) break;
        if(v[i] <= k){
            k -= v[i];
            v[i] = 0;
        } else {
            v[i] -= k;
            k = 0;
        }
    }
	ll count1=0;
	for(ll i=0;i<v.size();i++){
		if(v[i]!=0) count1++;
	}
	cout<<count1<<"\n";
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
	int t;
	cin>>t;
	while(t--){
		solve();
	}
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void solve(){
	//Value taken
	ll n,k;
	cin>>n>>k;
	ll arr[n];
	for(ll i=0;i<n;i++) cin>>arr[i];
	if(n==k){
		cout<<"1"<<"\n";
		return;
	}

	// map the array
	map< ll,ll >m;
	for(ll i=0;i<n;i++) m[arr[i]]++;
	vector<int>v;
	map<ll,ll>::iterator it;
	for(it=m.begin();it!=m.end();it++){
		v.push_back((*it).second);
	}
	// sort the vector
	sort(v.begin(),v.end());
	ll count = 0;
	for(ll i=0;i<v.size();i++) cout<<v[i];
    for(ll i = 0; i < v.size(); i++){
        if(k <= 0) break;
        if(v[i] <= k){
            k -= v[i];
            v[i] = 0;
        } else {
            v[i] -= k;
            k = 0;
        }
    }
	ll count1=0;
	for(ll i=0;i<v.size();i++){
		if(v[i]!=0) count1++;
	}
	cout<<count1<<"\n";
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
	int t;
	cin>>t;
	while(t--){
		solve();
	}
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void solve(){
	//Value taken
	ll n,k;
	cin>>n>>k;
	ll arr[n];
	for(ll i=0;i<n;i++) cin>>arr[i];
	if(n==k){
		cout<<"1"<<"\n";
		return;
	}

	// map the array
	map< ll,ll >m;
	for(ll i=0;i<n;i++) m[arr[i]]++;
	vector<int>v;
	map<ll,ll>::iterator it;
	for(it=m.begin();it!=m.end();it++){
		v.push_back((*it).second);
	}
	// sort the vector
	sort(v.begin(),v.end());
	ll count = 0;
	for(ll i=0;i<v.size();i++) cout<<v[i];
    for(ll i = 0; i < v.size(); i++){
        if(k <= 0) break;
        if(v[i] <= k){
            k -= v[i];
            v[i] = 0;
        } else {
            v[i] -= k;
            k = 0;
        }
    }
	ll count1=0;
	for(ll i=0;i<v.size();i++){
		if(v[i]!=0) count1++;
	}
	cout<<count1<<"\n";
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
	int t;
	cin>>t;
	while(t--){
		solve();
	}
}

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

int main() {
    // ios::sync_with_stdio(false);
    // cin.tie(0);
	int t;
	cin>>t;
	while(t--){
		//Value taken
	ll n,k;
	cin>>n>>k;
	ll arr[n];
	for(ll i=0;i<n;i++) cin>>arr[i];

	// map the array
	map< ll,ll >m;
	for(ll i=0;i<n;i++) m[arr[i]]++;
	vector<int>v;
	map<ll,ll>::iterator it;
	for(it=m.begin();it!=m.end();it++){
		v.push_back((*it).second);
	}
	// sort the vector
	sort(v.begin(),v.end());
	ll count = 0;
    for(ll i = 0; i < v.size(); i++){
        if(k <= 0) break;
        if(v[i] <= k){
            k -= v[i];
            v[i] = 0;
        } else {
            v[i] -= k;
            k = 0;
        }
    }
	ll count1=0;
	for(ll i=0;i<v.size();i++){
		if(v[i]!=0) count1++;
	}
	if(count1>0){
		cout<<count1<<endl;
	}else{
		cout<<"1"<<endl;
	}
	}
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Runtime error on test 1):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void solve(){
	//Value taken
	ll n,k,arr[n];
	cin>>n>>k;
	for(ll i=0;i<n;i++) cin>>arr[i];
	if(n==k){
		cout<<"1"<<"\n";
		return;
	}

	// map the array
	map< ll,ll >m;
	for(ll i=0;i<n;i++) m[arr[i]]++;
	vector<int>v;
	map<ll,ll>::iterator it;
	for(it=m.begin();it!=m.end();it++){
		v.push_back((*it).second);
	}
	// sort the vector
	sort(v.begin(),v.end(),greater<>());
	ll count = 0;
    for(ll i = 0; i < v.size(); i++){
        if(k <= 0) break;
        if(v[i] <= k){
            k -= v[i];
            v[i] = 0;
        } else {
            v[i] -= k;
            k = 0;
        }
    }
	ll count1=0;
	for(ll i=0;i<v.size();i++){
		if(v[i]!=0) count1++;
	}
	cout<<count1<<"\n";
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
	int t;
	cin>>t;
	while(t--){
		solve();
	}
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int>v;
        for(int i = 0; i < n; i++){
            int x;
            cin >>x;
            v.push_back(x);
        }
        bool flag = true;
        for(int i=0;i<n;i++){
            if(v[i]>=0 && i<n-1){
                v[i+1]=v[i+1]-v[i];
                v[i]=0;
            }
            else if(i==n-1){
                if(v[i]<0) flag = false;
                else flag=true;
            }
            else{
                cout<<"no"<<endl;
                flag=false;
                break;
            }
        }
        if(flag==true){
            cout<<"yes"<<endl;
        }
    }
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int>v;
        for(int i = 0; i < n; i++){
            int x;
            cin >>x;
            v.push_back(x);
        }
        bool flag = true;
        for(int i=0;i<n;i++){
            if(v[i]>=0 && i<n-1){
                v[i+1]=v[i+1]-v[i];
                v[i]=v[i]-v[i];
            }
            else if(i==n-1){
                if(v[i]<0) flag = false;
                else flag=true;
            }
            else{
                flag=false;
                break;
            }
        }
        if(flag==true){
            cout<<"yes"<<endl;
        }else{
            cout<<"no"<<endl;
        }
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Compilation error):
#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int>v;
        for(int i = 0; i < n; i++){
            int x;
            cin >>x;
            v.push_back(x);
        }
        bool flag = true;
        for(int i=0;i<n;i++){
            if(v[i]>=0){
                v[i+1]=v[i+1]-v[i];
                v[i]=v[i]-v[i];
            }else{
                cout<<"no"<<endl;
                flag=false;
                break;
            }
        }
        if(flag==true){
            cout<<"yes"<<endl;
        }
    }
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Runtime error on test 3):
#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int>v;
        for(int i = 0; i < n; i++){
            int x;
            cin >>x;
            v.push_back(x);
        }
        bool flag = true;
        for(int i=0;i<n;i++){
            if(v[i]>=0){
                v[i+1]=v[i+1]-v[i];
                v[i]=v[i]-v[i];
            }else{
                cout<<"no"<<endl;
                flag=false;
                break;
            }
        }
        if(flag==true){
            cout<<"yes"<<endl;
        }
    }
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int>v;
        for(int i = 0; i < n; i++){
            int x;
            cin >>x;
            v.push_back(x);
        }
        bool flag = true;
        for(int i=0;i<n-1;i++){
            if(v[i]>=0){
                v[i+1]=v[i+1]-v[i];
                v[i]=v[i]-v[i];
            }else{
                cout<<"no"<<endl;
                flag=false;
                break;
            }
        }
        if(flag==true){
            cout<<"yes"<<endl;
        }
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int>v;
        for(int i = 0; i < n; i++){
            int x;
            cin >>x;
            v.push_back(x);
        }
        bool flag = true;
        for(int i=0;i<n-1;i++){
            if(v[i]>=0){
                v[i+1]=v[i+1]-v[i];
                v[i]=v[i]-v[i];
            }else{
                cout<<"no"<<endl;
                flag=false;
                break;
            }
        }
        if(flag==true){
            cout<<"yes"<<endl;
        }
    }
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int>v;
        for(int i = 0; i < n; i++){
            int x;
            cin >>x;
            v.push_back(x);
        }
        bool flag = true;
        for(int i=0;i<n;i++){
            if(v[i]>=0 && i<n-1){
                v[i+1]=v[i+1]-v[i];
                v[i]=0;
            }
            else if(i==n-1){
                if(v[i]<0) flag = false;
                else flag=true;
            }
            else{
                cout<<"no"<<endl;
                flag=false;
                break;
            }
        }
        if(flag==true){
            cout<<"yes"<<endl;
        }
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Compilation error):
#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int>v;
        for(int i = 0; i < n; i++){
            int x;
            cin >>x;
            v.push_back(x);
        }
        bool flag = true;
        for(int i=0;i<n;i++){
            if(v[i]>=0){
                v[i+1]=v[i+1]-v[i];
                v[i]=v[i]-v[i];
            }else{
                cout<<"no"<<endl;
                flag=false;
                break;
            }
        }
        if(flag==true){
            cout<<"yes"<<endl;
        }
    }


Submission (verdict: Runtime error on test 3):
#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int>v;
        for(int i = 0; i < n; i++){
            int x;
            cin >>x;
            v.push_back(x);
        }
        bool flag = true;
        for(int i=0;i<n;i++){
            if(v[i]>=0){
                v[i+1]=v[i+1]-v[i];
                v[i]=v[i]-v[i];
            }else{
                cout<<"no"<<endl;
                flag=false;
                break;
            }
        }
        if(flag==true){
            cout<<"yes"<<endl;
        }
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

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

int main() {
	int t;cin>>t;
	while(t--)
	{
	   long long int l,r;
	   long long int a,b,c=0;
	   cin>>l>>r;
	   long long int diff=r-l;
	   long long int exponent=log2(diff)+1;
	   long long int maxkaaadha=pow(2,exponent)-1;
	   long long int bakwaas=(maxkaaadha+1)/2;
	   a=(r/bakwaas)*bakwaas;
/*
	   for(int i=r;i>=l;i--)
	   {
	       if(i%bakwaas==0 && i!=0){
	       a=i;break;}
	   }
	   */
	   b=a-1;
	   for(int i=r;i>=l;i--)
	   {
	       if(i!=a && i!=b)
	       {
	           c=i;break;
	       }
	   }
	   cout<<a<<" "<<b<<" "<<c<<endl;
	}

}

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

string dectobin(long long int n)
{
    string s="";
    while(n>0)
    {
        if(n%2==1)
        {
            s+='1';
        }
        else if(n%2==0)
        {
            s+='0';
        }
        n=n/2;
    }
    int cnt=s.size();
    while(cnt<=31){
    s+='0';cnt++;}
reverse(s.begin(),s.end());
    return s;
}

int bintodec(string s)
{
    int num=0;
    int len=s.length();
    for(int i=0;i<=len-1;i++)
    {
        if(s[i]=='1')
        num+=pow(2,len-1-i);
    }
    return num;
}

int main() {
	int t;cin>>t;
	while(t--)
	{
	    long long int l,r;cin>>l>>r;
	    string lstr=dectobin(l);
	    string rstr=dectobin(r);
	    string temp=lstr;
	    //cout<<rstr<<endl;
	    for(int i=0;i<32;i++)
	    {
	        if(lstr[i]!=rstr[i])
	        {
	            for(int j=i+1;j<32;j++)
	            {
	                rstr[j]='0';
	                lstr[j]='1';
	            }
	            break;
	        }
	    }
	    long long int a=bintodec(rstr);
	    long long int b=bintodec(lstr);
	    if(temp==lstr)
	    {
	        cout<<a<<" "<<b<<" "<<a+1<<endl;
	    }
	    else
	    cout<<a<<" "<<b<<" "<<l<<endl;
	    
	    
	    
	}

}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


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

int main() {
	int t;cin>>t;
	while(t--)
	{
	   long long int l,r;
	   long long int a,b,c=0;
	   cin>>l>>r;
	   long long int diff=r-l;
	   long long int exponent=log2(diff)+1;
	   long long int maxkaaadha=pow(2,exponent)-1;
	   long long int bakwaas=(maxkaaadha+1)/2;
	   for(int i=l;i<=r;i++)
	   {
	       if(i%bakwaas==0 && i!=0){
	       a=i;break;}
	   }
	   b=a-1;
	   for(int i=l;i<=r;i++)
	   {
	       if(i!=a && i!=b)
	       {
	           c=i;break;
	       }
	   }
	   cout<<a<<" "<<b<<" "<<c<<endl;
	}

}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

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

int main() {
	int t;cin>>t;
	while(t--)
	{
	   long long int l,r;
	   long long int a,b,c=0;
	   cin>>l>>r;
	   long long int diff=r-l;
	   long long int exponent=log2(diff)+1;
	   long long int maxkaaadha=pow(2,exponent)-1;
	   long long int bakwaas=(maxkaaadha+1)/2;
	   for(int i=r;i>=l;i--)
	   {
	       if(i%bakwaas==0 && i!=0){
	       a=i;break;}
	   }
	   b=a-1;
	   for(int i=l;i<=r;i++)
	   {
	       if(i!=a && i!=b)
	       {
	           c=i;break;
	       }
	   }
	   cout<<a<<" "<<b<<" "<<c<<endl;
	}

}


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

int main() {
	int t;cin>>t;
	while(t--)
	{
	   long long int l,r;
	   long long int a,b,c=0;
	   cin>>l>>r;
	   long long int diff=r-l;
	   long long int exponent=log2(diff)+1;
	   long long int maxkaaadha=pow(2,exponent)-1;
	   long long int bakwaas=(maxkaaadha+1)/2;
	   for(int i=r;i>=l;i--)
	   {
	       if(i%bakwaas==0 && i!=0){
	       a=i;break;}
	   }
	   b=a-1;
	   for(int i=r;i>=l;i--)
	   {
	       if(i!=a && i!=b)
	       {
	           c=i;break;
	       }
	   }
	   cout<<a<<" "<<b<<" "<<c<<endl;
	}

}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

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

int main() {
	int t;cin>>t;
	while(t--)
	{
	   long long int l,r;
	   long long int a,b,c=0;
	   cin>>l>>r;
	   long long int diff=r-l;
	   long long int exponent=log2(diff)+1;
	   long long int maxkaaadha=pow(2,exponent)-1;
	   long long int bakwaas=(maxkaaadha+1)/2;
	   for(int i=l;i<=r;i++)
	   {
	       if(i%bakwaas==0 && i!=0){
	       a=i;break;}
	   }
	   b=a-1;
	   for(int i=l;i<=r;i++)
	   {
	       if(i!=a && i!=b)
	       {
	           c=i;break;
	       }
	   }
	   cout<<a<<" "<<b<<" "<<c<<endl;
	}

}


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

int main() {
	int t;cin>>t;
	while(t--)
	{
	   long long int l,r;
	   long long int a,b,c=0;
	   cin>>l>>r;
	   long long int diff=r-l;
	   long long int exponent=log2(diff)+1;
	   long long int maxkaaadha=pow(2,exponent)-1;
	   long long int bakwaas=(maxkaaadha+1)/2;
	   for(int i=r;i>=l;i--)
	   {
	       if(i%bakwaas==0 && i!=0){
	       a=i;break;}
	   }
	   b=a-1;
	   for(int i=l;i<=r;i++)
	   {
	       if(i!=a && i!=b)
	       {
	           c=i;break;
	       }
	   }
	   cout<<a<<" "<<b<<" "<<c<<endl;
	}

}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

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

int main() {
	int t;cin>>t;
	while(t--)
	{
	   long long int l,r;
	   long long int a,b,c=0;
	   cin>>l>>r;
	   long long int diff=r-l;
	   long long int exponent=log2(diff)+1;
	   long long int maxkaaadha=pow(2,exponent)-1;
	   long long int bakwaas=(maxkaaadha+1)/2;
	   for(int i=r;i>=l;i--)
	   {
	       if(i%bakwaas==0 && i!=0){
	       a=i;break;}
	   }
	   b=a-1;
	   for(int i=r;i>=l;i--)
	   {
	       if(i!=a && i!=b)
	       {
	           c=i;break;
	       }
	   }
	   cout<<a<<" "<<b<<" "<<c<<endl;
	}

}


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

int main() {
	int t;cin>>t;
	while(t--)
	{
	   long long int l,r;
	   long long int a,b,c=0;
	   cin>>l>>r;
	   long long int diff=r-l;
	   long long int exponent=log2(diff)+1;
	   long long int maxkaaadha=pow(2,exponent)-1;
	   long long int bakwaas=(maxkaaadha+1)/2;
	   a=(r/bakwaas)*bakwaas;
/*
	   for(int i=r;i>=l;i--)
	   {
	       if(i%bakwaas==0 && i!=0){
	       a=i;break;}
	   }
	   */
	   b=a-1;
	   for(int i=r;i>=l;i--)
	   {
	       if(i!=a && i!=b)
	       {
	           c=i;break;
	       }
	   }
	   cout<<a<<" "<<b<<" "<<c<<endl;
	}

}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
string s;
int a[100100];
int b[100100];
void hs()
{
	long long ans=0;
	int x=0,y=0;
	a[0]=0,b[0]=0;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		ans+=s[i]-'0';
		if(s[i]=='2') x++;
		else if(s[i]=='3') y++;
	}
	if(ans%9==0) 
	{
		cout<<"YES"<<endl;
		return;
	}
	ans%=9;
	
	int tmp=0;
	for(int i=1;i<=x;i++)
	{
		tmp+=2;
		tmp%=9;
		a[i]=tmp;
	}
	tmp=0;
	for(int i=1;i<=y;i++)
	{
		tmp+=6;
		tmp%=9;
		b[i]=tmp;
	}
	for(int i=0;i<=y;i++)
	{
		for(int j=0;j<=x;j++) 
		if(a[j]+b[i]==9-ans)
		{
			cout<<"YES"<<endl;
			return;
		}
	}
	cout<<"NO"<<endl;
}
int main()	
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int __;
	cin>>__;
	while(__--)
	hs();
	return 0;
 } 

Submission (verdict: Accepted):
#include<bits/stdc++.h>  
using namespace std;  
#define int long long  
 
int t;  
int n, k;  
int a[200005];
string s;  
 
void solve() {  
    cin >> s;  
    int sum = 0;  
    int cnt2 = 0, cnt3 = 0; 
 
    for (char c : s) 
	{  
        sum += c - '0';  
        if (c == '2') 
		cnt2++;  
        if (c == '3') 
		cnt3++;  
    }  
    if (sum % 9 == 0) 
	{  
        cout << "YES\n";  
        return;  
    }  
    int mod = sum % 9;  
    
    vector<int> v3, v2;  
    int flag = 0;  
    v2.push_back(0);
    v3.push_back(0);
    for (int i = 1; i <= cnt3; i++) {  
        flag += 6;  
        flag %= 9;  
        v3.push_back(flag);  
    }  
 
    flag = 0; 
   
    for (int i = 1; i <= cnt2; i++) {  
        flag += 2;  
        flag %= 9;  
        v2.push_back(flag);  
    }  
 
    for (auto i : v2) {  
        for (auto j : v3) {  
            if ((i + j)%9 == 9 - mod) 
			{  
                cout << "YES\n";  
                return;  
            }  
        }  
    }  
    cout << "NO\n";  
}  
 
signed main() {  
    ios::sync_with_stdio(0);   
    cin.tie(0);   
    cout.tie(0);  
    cin >> t; 
    while (t--) solve();  
    return 0;  
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
string s;
void hs()
{
	int ans=0;
	int x=0,y=0;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		ans+=s[i]-'0';
		if(s[i]=='2') x++;
		else if(s[i]=='3') y++;
	}
	if(ans%9==0) cout<<"YES"<<endl;
	else if(ans%9==8&&(x>=5||(y>=1&&x>=2))) cout<<"YES"<<endl;
	else if(ans%9==7&&x>=1) cout<<"YES"<<endl;
	else if(ans%9==6&&(y>=2||x>=6||(x>=3&&y>=1))) cout<<"YES"<<endl;
	else if(ans%9==5) 
	{
		if(x>=11)
		cout<<"YES"<<endl;
		else if(y>=1&&x>=8)
		cout<<"YES"<<endl;
		else if(y>=2&&x>=5)
		cout<<"YES"<<endl;
		else if(y>=3&&x>=2)
		cout<<"YES"<<endl;
		else
	    cout<<"NO"<<endl;
	}
	else if(ans%9==4)
	{
		if(x>=7)
		cout<<"YES"<<endl;
		else if(y>=1&&x>=4)
		cout<<"YES"<<endl;
		else if(y>=2&&x>=1)
		cout<<"YES"<<endl;
		else 
		cout<<"NO"<<endl;
	 } 
	else if(ans%9==3&&(y>=1||x>=3)) cout<<"YES"<<endl;
	else if(ans%9==2) 
	{
		if(x>=8)
		cout<<"YES"<<endl;
		else if(y>=1&&x>=5)
		cout<<"YES"<<endl;
		else if(y>=2&&x>=2)
		cout<<"YES"<<endl;
		else 
		cout<<"NO"<<endl;
	}
	else if(ans%9==1&&(x>=4||(x>=1&&y>=1))) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int __;
	cin>>__;
	while(__--)
	hs();
	return 0;
 }