ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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


#define endl '\n'
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	cin>>t;

	while(t-- >0){
	

		ll s,l,r;
		cin>>s>>l>>r;
		vector<ll> vec(s);
		for(auto &x: vec){cin>>x;}	
		vector<ll> pref = vec;
		ll prefix=0;
		sort(pref.begin(),pref.begin()+r);

		reverse(pref.begin(),pref.begin()+r);
		prefix= accumulate(pref.begin()+l-1,pref.begin()+r,0);
		
		vector<ll> suffix = vec;
		ll suff=0;
		sort(suffix.begin()+l-1,suffix.end());

		suff=accumulate(suffix.begin()+l-1,suffix.begin()+r,0);
		cout<<min(prefix,suff)<<endl;

	}


// 9 2 3 4 5 2 5 1 5









	return 0;
}


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


#define endl '\n'
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	cin>>t;

	while(t-- >0){
	

		ll s,l,r;
		cin>>s>>l>>r;
		vector<ll> vec(s);
		for(auto &x: vec){cin>>x;}	
		vector<ll> pref = vec;
		ll prefix=0;
		sort(pref.begin(),pref.begin()+r);

		reverse(pref.begin(),pref.begin()+r);
		for(int i = l-1;i<r;i++){
			prefix+=pref[i];
		}
		vector<ll> suffix = vec;
		ll suff=0;
		sort(suffix.begin()+l-1,suffix.end());

		for(int i = l-1;i<r;i++){
			suff+=suffix[i];
		}
		cout<<min(prefix,suff)<<endl;

	}


	return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

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

void solve(){
    string s; cin >> s;
    string st=s;
    int j=0,cnt=0;
    while(1){
        for(int i=0;s[i+1]!='\0';i++){
            if((s[i+1]-1)>s[i] && s[i+1]!='0'){
                char t=s[i+1]-1;
                s[i+1]=s[i];
                s[i]=t;
            }
            else{
                cnt++;
            }
        }
        if(st>s){
            cout << st <<'\n';
            return ;
        }
        else{
            st=s;
        }
        if(cnt==s.size()-1){
            cout << s <<"2\n";
            return;
        }
        else{
            cnt=0;
        }
    }
    cout << s <<'\n';
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t=1;
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

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

void solve(){
    string s; cin >> s;
    string st=s;
    int j=0,cnt=0;
    while(1){
        for(int i=0;s[i+1]!='\0';i++){
            if((s[i+1]-1)>s[i] && s[i+1]!='0'){
                char t=s[i+1]-1;
                s[i+1]=s[i];
                s[i]=t;
            }
            else{
                cnt++;
            }
        }
        if(st>s){
            cout << st <<'\n';
            return ;
        }
        else{
            st=s;
        }
        if(cnt==s.size()-1){
            cout << s <<"\n";
            return;
        }
        else{
            cnt=0;
        }
    }
    cout << s <<'\n';
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t=1;
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)


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

void solve(){
    string s; cin >> s;
    string st=s;
    int j=0;
    while(j<s.size()){
        for(int i=0;s[i+1]!='\0';i++){
            if((s[i+1]-1)>s[i] && s[i+1]!='0'){
                char t=s[i+1]-1;
                s[i+1]=s[i];
                s[i]=t;
            }
        }
        if(st>s){
            cout << st <<'\n';
            return ;
        }
        else{
            st=s;
        }
        j++;
    }
    cout << s <<'\n';
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t=1;
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

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

void solve(){
    string s; cin >> s;
    string st=s;
    int j=0;
    while(j<s.size()){
        for(int i=0;s[i+1]!='\0';i++){
            if((s[i+1]-1)>s[i] && s[i+1]!='0'){
                char t=s[i+1]-1;
                s[i+1]=s[i];
                s[i]=t;
            }
        }
        if(st>s){
            cout << st <<'\n';
            return ;
        }
        else{
            st=s;
        }
        j++;
    }
    cout << s <<'\n';
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t=1;
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

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

void solve(){
    string s; cin >> s;
    string st=s;
    int j=0,cnt=0;
    while(1){
        for(int i=0;s[i+1]!='\0';i++){
            if((s[i+1]-1)>s[i] && s[i+1]!='0'){
                char t=s[i+1]-1;
                s[i+1]=s[i];
                s[i]=t;
            }
            else{
                cnt++;
            }
        }
        if(st>s){
            cout << st <<'\n';
            return ;
        }
        else{
            st=s;
        }
        if(cnt==s.size()-1){
            cout << s <<"2\n";
            return;
        }
        else{
            cnt=0;
        }
    }
    cout << s <<'\n';
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t=1;
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<typename T>
using ordered_set= tree< T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr); cout.tie(nullptr); 
#define endl "\n" 
#define int long long

signed main() {
    fastio
    int t;
    // t=1;
    cin>>t;
    while(t--){
        int n,m;cin>>n>>m;
        if(m > n){cout<<"no"<<endl; continue;}
        vector<int>v(n),w(m);
        map<int,int>mp1,mp2;
        for(int i=0;i<n;i++){
            cin>>v[i];
            mp1[v[i]]++;
        }
        for(int i=0;i<m;i++){
            cin>>w[i];
            mp2[w[i]]++;
        }

        if(mp2[1] > mp1[1]){cout<<"no"<<endl; continue;}

        int test = 1;
        for(auto it = mp2.rbegin(); it != mp2.rend(); it++){
            int num = (*it).first, fre = (*it).second;
            if(num == 1 and mp1[1] < fre){test = 0; cout<<"NO"<<endl;}
            if(mp1[num] >= fre) continue;
            int dif = fre - mp1[num];
            mp1[num/2] -= dif;
            mp1[num/2 + (num%2)] -= dif;
            mp1[num] = fre;
        }

        for(auto &it: mp1){
            if(it.second < 0){
                mp1[it.first/2] += it.second;
                mp1[it.first/2 + (it.first%2)] += it.second;
                it.second = 0;
            }
        }

        for(auto it: mp1){
            if(it.second < 0){cout<<"no"<<endl; test = 0; break;}
            if(it.second and it.second != mp2[it.first]){test = 0; cout<<"no"<<endl;break;}
        }
        if(test) cout<<"yes"<<endl;

    }

}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

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

#define ll long long

using namespace std;



int func(){

 ll n,l,r;

 cin>>n>>l>>r;

 vector<ll>v(n);

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

     cin>>v[i];

 }

 vector<ll>s(n);

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

     s[i]=v[i];

 }

sort(v.begin(),v.begin()+r-1);

sort(s.begin()+l-1,s.end());



ll sum1=0,sum2=0;

for(int i=0;i<r-l+1;i++){

    sum1+=v[i];

    }

    for(int i=l-1;i<r;i++){

        sum2+=s[i];

    }

    return min(sum1,sum2);

}



int main(){

    ll t;cin>>t;

    while(t--){

        cout<<func()<<endl;

    }

}

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

#define ll long long

using namespace std;



int func(){

 ll n,l,r;

 cin>>n>>l>>r;

 vector<ll>v(n);

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

     cin>>v[i];

 }

 vector<ll>s(n);

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

     s[i]=v[i];

 }

sort(v.begin(),v.begin()+r);

sort(s.begin()+l-1,s.end());



ll sum1=0,sum2=0;

for(int i=0;i<r-l+1;i++){

    sum1+=v[i];

    }

    for(int i=l-1;i<r;i++){

        sum2+=s[i];

    }

    return min(sum1,sum2);

}



int main(){

    ll t;cin>>t;

    while(t--){

        cout<<func()<<endl;

    }

}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

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

#define ll long long

using namespace std;



int func(){

 ll n,l,r;

 cin>>n>>l>>r;

 vector<ll>v(n);

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

     cin>>v[i];

 }

 vector<ll>s(n);

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

     s[i]=v[i];

 }

sort(v.begin(),v.begin()+r);

sort(s.begin()+l-1,s.end());



ll sum1=0,sum2=0;

for(int i=0;i<r-l+1;i++){

    sum1+=v[i];

    }

    for(int i=l-1;i<r;i++){

        sum2+=s[i];

    }

    return min(sum1,sum2);

}



int main(){

    ll t;cin>>t;

    while(t--){

        cout<<func()<<endl;

    }

}

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

#define ll long long

using namespace std;



int func(){

 ll n,l,r;

 cin>>n>>l>>r;

 vector<ll>v(n);

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

     cin>>v[i];

 }

 vector<ll>s(n);

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

     s[i]=v[i];

 }

sort(v.begin(),v.begin()+r);

sort(s.begin()+l-1LL,s.end());



ll sum1=0,sum2=0;

for(ll i=0;i<r-l+1;i++){

    sum1+=v[i];

    }

    for(ll i=l-1;i<r;i++){

        sum2+=s[i];

    }

    return min(sum1,sum2);

}



int main(){

    ll t;cin>>t;

    while(t--){

        cout<<func()<<endl;

    }

}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)


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

#define ll long long

using namespace std;



int func(){

 ll n,l,r;

 cin>>n>>l>>r;

 vector<ll>v(n);

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

     cin>>v[i];

 }

 vector<ll>s(n);

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

     s[i]=v[i];

 }

sort(v.begin(),v.begin()+r-1);

sort(s.begin()+l-1,s.end());



ll sum1=0,sum2=0;

for(int i=0;i<r-l+1;i++){

    sum1+=v[i];

    }

    for(int i=l-1;i<r;i++){

        sum2+=s[i];

    }

    return min(sum1,sum2);

}



int main(){

    ll t;cin>>t;

    while(t--){

        cout<<func()<<endl;

    }

}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

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

#define ll long long

using namespace std;



int func(){

 ll n,l,r;

 cin>>n>>l>>r;

 vector<ll>v(n);

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

     cin>>v[i];

 }

 vector<ll>s(n);

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

     s[i]=v[i];

 }

sort(v.begin(),v.begin()+r);

sort(s.begin()+l-1LL,s.end());



ll sum1=0,sum2=0;

for(ll i=0;i<r-l+1;i++){

    sum1+=v[i];

    }

    for(ll i=l-1;i<r;i++){

        sum2+=s[i];

    }

    return min(sum1,sum2);

}



int main(){

    ll t;cin>>t;

    while(t--){

        cout<<func()<<endl;

    }

}

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

#define ll long long

using namespace std;



ll func(){

 ll n,l,r;

 cin>>n>>l>>r;

 vector<ll>v(n);

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

     cin>>v[i];

 }

 vector<ll>s(n);

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

     s[i]=v[i];

 }

sort(v.begin(),v.begin()+r);

sort(s.begin()+l-1LL,s.end());



ll sum1=0,sum2=0;

for(ll i=0;i<r-l+1;i++){

    sum1+=v[i];

    }

    for(ll i=l-1;i<r;i++){

        sum2+=s[i];

    }

    return min(sum1,sum2);

}



int main(){

    ll t;cin>>t;

    while(t--){

        cout<<func()<<endl;

    }

}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)


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

void sol1(){
    int a,b,c, ans=0, i=0; cin>>a>>b;
    vector<pair<int, int>>vp;
    unordered_map<int,int>mp;
    while(a--){cin>>c; mp[c]++;}
    for(auto &b: mp){vp.push_back({b.second, b.first});}
    sort(vp.begin(), vp.end());
    while(b>0 and i<vp.size()){
        int minn=min(b, vp[i].first);
        vp[i].first-=minn; b-=minn; i++;
    }
    for(auto &b: vp){
        if(b.first>0){ans++;}
    }
    cout<<max(1LL,ans)<<"\n";
}
void sol2(){
    int a,b,aa,bb,cc,ans=0; cin>>a>>b;
    for(int i=32; i>=0; i++){
       int a1=0,a2=0;
       if(a&(1<<i)){a1=1;}
       if(b&(1<<i)){a2=1;}
       if(a1==a2){
          ans+=a1*(1<<i);
       }
       else{
        aa=ans+(1<<i);
        bb=aa-1;
        break;
       }
    }
    for(int i=a; i<=b; i++){
        if(i!=aa and i!=bb){
            cc=i; break;
        }
    }
    cout<<aa<<" "<<bb<<" "<<cc<<"\n";
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int t; cin>>t;
    while(t--){
    //   sol1();
        sol2();
    }
     
    return 0;
}
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 int long long int

void sol1(){
    int a,b,c, ans=0, i=0; cin>>a>>b;
    vector<pair<int, int>>vp;
    unordered_map<int,int>mp;
    while(a--){cin>>c; mp[c]++;}
    for(auto &b: mp){vp.push_back({b.second, b.first});}
    sort(vp.begin(), vp.end());
    while(b>0 and i<vp.size()){
        int minn=min(b, vp[i].first);
        vp[i].first-=minn; b-=minn; i++;
    }
    for(auto &b: vp){
        if(b.first>0){ans++;}
    }
    cout<<max(1LL,ans)<<"\n";
}
void sol2(){
    int a,b,aa,bb,cc,ans=0; cin>>a>>b;
    for(int i=30; i>=0; i++){
       int a1=0,a2=0;
       if(a&(1ll<<i)){a1=1;}
       if(b&(1ll<<i)){a2=1;}
       if(a1==a2){
          ans+=a1*(1ll<<i);
       }
       else{
        aa=ans+(1ll<<i);
        bb=aa-1;
        break;
       }
    }
    for(int i=a; i<=b; i++){
        if(i!=aa and i!=bb){
            cc=i; break;
        }
    }
    cout<<aa<<" "<<bb<<" "<<cc<<"\n";
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int t; cin>>t;
    while(t--){
    //   sol1();
        sol2();
    }
     
    return 0;
}

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

void sol1(){
    int a,b,c, ans=0, i=0; cin>>a>>b;
    vector<pair<int, int>>vp;
    unordered_map<int,int>mp;
    while(a--){cin>>c; mp[c]++;}
    for(auto &b: mp){vp.push_back({b.second, b.first});}
    sort(vp.begin(), vp.end());
    while(b>0 and i<vp.size()){
        int minn=min(b, vp[i].first);
        vp[i].first-=minn; b-=minn; i++;
    }
    for(auto &b: vp){
        if(b.first>0){ans++;}
    }
    cout<<max(1LL,ans)<<"\n";
}
void sol2(){
    int a,b,aa,bb,cc,ans=0; cin>>a>>b;
    for(int i=30; i>=0; i--){
       int a1=0,a2=0;
       if(a&(1ll<<i)){a1=1;}
       if(b&(1ll<<i)){a2=1;}
       if(a1==a2){
          ans+=a1*(1ll<<i);
       }
       else{
        aa=ans+(1ll<<i);
        bb=aa-1;
        break;
       }
    }
    for(int i=a; i<=b; i++){
        if(i!=aa and i!=bb){
            cc=i; break;
        }
    }
    cout<<aa<<" "<<bb<<" "<<cc<<"\n";
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int t; cin>>t;
    while(t--){
    //   sol1();
        sol2();
    }
     
    return 0;
}
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 int long long int

void sol1(){
    int a,b,c, ans=0, i=0; cin>>a>>b;
    vector<pair<int, int>>vp;
    unordered_map<int,int>mp;
    while(a--){cin>>c; mp[c]++;}
    for(auto &b: mp){vp.push_back({b.second, b.first});}
    sort(vp.begin(), vp.end());
    while(b>0 and i<vp.size()){
        int minn=min(b, vp[i].first);
        vp[i].first-=minn; b-=minn; i++;
    }
    for(auto &b: vp){
        if(b.first>0){ans++;}
    }
    cout<<max(1LL,ans)<<"\n";
}
void sol2(){
    int a,b,aa,bb,cc,ans=0; cin>>a>>b;
    for(int i=32; i>=0; i++){
       int a1=0,a2=0;
       if(a&(1<<i)){a1=1;}
       if(b&(1<<i)){a2=1;}
       if(a1==a2){
          ans+=a1*(1<<i);
       }
       else{
        aa=ans+(1<<i);
        bb=aa-1;
        break;
       }
    }
    for(int i=a; i<=b; i++){
        if(i!=aa and i!=bb){
            cc=i; break;
        }
    }
    cout<<aa<<" "<<bb<<" "<<cc<<"\n";
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int t; cin>>t;
    while(t--){
    //   sol1();
        sol2();
    }
     
    return 0;
}

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

void sol1(){
    int a,b,c, ans=0, i=0; cin>>a>>b;
    vector<pair<int, int>>vp;
    unordered_map<int,int>mp;
    while(a--){cin>>c; mp[c]++;}
    for(auto &b: mp){vp.push_back({b.second, b.first});}
    sort(vp.begin(), vp.end());
    while(b>0 and i<vp.size()){
        int minn=min(b, vp[i].first);
        vp[i].first-=minn; b-=minn; i++;
    }
    for(auto &b: vp){
        if(b.first>0){ans++;}
    }
    cout<<max(1LL,ans)<<"\n";
}
void sol2(){
    int a,b,aa,bb,cc,ans=0; cin>>a>>b;
    for(int i=30; i>=0; i++){
       int a1=0,a2=0;
       if(a&(1ll<<i)){a1=1;}
       if(b&(1ll<<i)){a2=1;}
       if(a1==a2){
          ans+=a1*(1ll<<i);
       }
       else{
        aa=ans+(1ll<<i);
        bb=aa-1;
        break;
       }
    }
    for(int i=a; i<=b; i++){
        if(i!=aa and i!=bb){
            cc=i; break;
        }
    }
    cout<<aa<<" "<<bb<<" "<<cc<<"\n";
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int t; cin>>t;
    while(t--){
    //   sol1();
        sol2();
    }
     
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

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

#include <vector>

using namespace std;

int main() {

    int t;cin>>t;

    while(t--){

        string s;cin>>s;

        int sum=0;

        int count=0;

        int three=0;

        for(char ch:s){

            if(ch=='2') count++;

            if(ch=='3') three++;

            else sum=sum+ch-48;

        } 

        three%=3;

        bool found=false;

        int a=sum;

        int b=sum;

        if(three==0 && sum%9==0) found=true;

        if(three==1){

            if(sum%9==0 || sum%9==6) found=true;

            a+=3;

        }

        if(three==2){

            if(sum%9==0 || sum%9==3) found=true;

            a+=6;

        }

        while(count--){

            sum+=2;

            a+=2;

            b+=2;

            if(sum%9==0 || a%9==0 || b%9==0) found=true;

        }

        if(found) cout<<"YES"<<endl;

        else cout<<"NO"<<endl;

    }

    return 0;

}

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

#include <vector>

using namespace std;

int main() {

    int t;cin>>t;

    while(t--){

        string s;cin>>s;

        int sum=0;

        int count=0;

        int three=0;

        for(char ch:s){

            if(ch=='2') count++;

            if(ch=='3') three++;

            else sum=sum+ch-48;

        } 

        three%=3;

        bool found=false;

        int a=sum;

        int b=sum;

        if(sum%9==0) found=true;

        if(three==1){

            if(sum%9==6) found=true;

            a+=3;

        }

        if(three==2){

            if(sum%9==3 || sum%9==6) found=true;

            a+=6;

        }

        while(count--){

            sum+=2;

            a+=2;

            b+=2;

            if(sum%9==0 || a%9==0 || b%9==0) found=true;

        }

        if(found) cout<<"YES"<<endl;

        else cout<<"NO"<<endl;

    }

    return 0;

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

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

#include <vector>

using namespace std;

int main() {

    int t;cin>>t;

    while(t--){

        string s;cin>>s;

        int sum=0;

        int count=0;

        int three=0;

        for(char ch:s){

            if(ch=='2') count++;

            if(ch=='3') three++;

            else sum=sum+ch-48;

        } 

        three%=3;

        bool found=false;

        int a=sum;

        int b=sum;

        int c=sum;

        if(sum%9==0) found=true;

        if(three==1){

            if(sum%9==6) found=true;

            a+=3;

        }

        if(three==2){

            if(sum%9==3 || sum%9==6) found=true;

            a+=6;

            c+=3;

        }

        while(count--){

            sum+=2;

            a+=2;

            b+=2;

            c+=2;

            if(sum%9==0 || a%9==0 || b%9==0 || c%9==0) found=true;

        }

        if(found) cout<<"YES"<<endl;

        else cout<<"NO"<<endl;

    }

    return 0;

}

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

#include <vector>

using namespace std;

int main() {

    int t;cin>>t;

    while(t--){

        string s;cin>>s;

        int sum=0;

        int two=0;

        int three=0;

        for(char ch:s){

            if(ch=='2') two++;

            if(ch=='3') three++;

            sum=sum+ch-48;

        } 

        bool found=false;

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

            int temp=sum+(2*i);

            if(temp%9==0) found=true;

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

                int temp1=temp+(6*j);

                if(temp1%9==0) found=true;

            }

        }

        if(found) cout<<"YES"<<endl;

        else cout<<"NO"<<endl;

    }

    return 0;

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


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

#include <vector>

using namespace std;

int main() {

    int t;cin>>t;

    while(t--){

        string s;cin>>s;

        int sum=0;

        int count=0;

        int three=0;

        for(char ch:s){

            if(ch=='2') count++;

            if(ch=='3') three++;

            else sum=sum+ch-48;

        } 

        three%=3;

        bool found=false;

        int a=sum;

        int b=sum;

        if(three==0 && sum%9==0) found=true;

        if(three==1){

            if(sum%9==0 || sum%9==6) found=true;

            a+=3;

        }

        if(three==2){

            if(sum%9==0 || sum%9==3) found=true;

            a+=6;

        }

        while(count--){

            sum+=2;

            a+=2;

            b+=2;

            if(sum%9==0 || a%9==0 || b%9==0) found=true;

        }

        if(found) cout<<"YES"<<endl;

        else cout<<"NO"<<endl;

    }

    return 0;

}