ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

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

#define ll long long
#define ld long double
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vll vector<long long>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pii pair<int,int>
#define el '\n'
#define value(x) cout<<x<<"\n";

void  solve(){
    ll n; 
    cin>>n;
    vll v(n); 
    rep(i,0,n) cin>>v[i];

    if(n==1){
        cout<<v[0]<<endl;
        return;
    }

    ll maxsum  = 0;
    rep(i,0,n) maxsum += v[i];
    ll index = n-1;
    

    rep(k,0,n){
        ll sumnew = 0;
        
        rep(j,0,index+1) sumnew += v[j];
        
        maxsum = max(maxsum,abs(sumnew));

        rep(j,0,index) v[j] -= v[j+1];

        index--;
    }
    cout<<maxsum<<endl;
    return;
}

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

return 0;
}

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

#define ll long long
#define ld long double
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vll vector<long long>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pii pair<int,int>
#define el '\n'
#define value(x) cout<<x<<"\n";

void  solve(){
    int n; 
    cin>>n;
    vll v(n); 
    rep(i,0,n) cin>>v[i];

    if(n==1){
        cout<<v[0]<<endl;
        return;
    }

    ll maxsum  = LLONG_MIN;
    
    ll index = n-1;
    

    rep(k,0,n){
        ll sumnew = 0;
        
        rep(j,0,index+1) sumnew += v[j];
        
        if(k==0) maxsum = max(maxsum,sumnew);

        else maxsum = max(maxsum,abs(sumnew));

        rep(j,0,index) v[j] -= v[j+1];

        index--;
    }
    cout<<maxsum<<endl;
    return;
}

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

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


Submission (verdict: Wrong answer on test 2):



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

#define ll long long
#define ld long double
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vll vector<long long>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pii pair<int,int>
#define el '\n'
#define value(x) cout<<x<<"\n";

void  solve(){
    ll n;
    cin>>n;
    vll a(n);
    rep(i,0,n) cin>>a[i];

    if(n==1){
        cout<<a[0]<<endl;
        return ;
    }

    ll sumin = accumulate(a.begin(),a.end(),0);
    ll sumnew = 0, maxsum = 0;
    ll i = 0, j = i+1;
    
rep(k,1,n){
        vll temp;
        sumnew = 0;
    while(j < a.size()){
        temp.push_back(a[j]-a[i]);
        i++;
        j = i+1;
    }

    rep(i,0,temp.size()){
        a[i] = temp[i];
        sumnew += abs(temp[i]);
    }
    maxsum = max(maxsum,sumnew);
    if(k==n-1) break;
    a.pop_back();
    
    i = 0;
    j = i+1;

}
if(maxsum >= sumin) cout<<maxsum<<endl;
else cout<<sumin<<endl;
return;

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--){
        solve();
    }

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

Previous submission (verdict: Wrong answer on test 2):



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

#define ll long long
#define ld long double
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vll vector<long long>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pii pair<int,int>
#define el '\n'
#define value(x) cout<<x<<"\n";

void  solve(){
    ll n;
    cin>>n;
    vll a(n);
    rep(i,0,n) cin>>a[i];

    if(n==1){
        cout<<a[0]<<endl;
        return ;
    }

    ll sumin = accumulate(a.begin(),a.end(),0);
    ll sumnew = 0, maxsum = 0;
    ll start = 0, end = start+1;
    
    rep(k,1,n){
        vll temp;
        sumnew = 0;
        while(end < a.size()){
            temp.push_back(a[end]-a[start]);
            start++;
            end = start+1;
        }

        rep(i,0,temp.size()){
            a[i] = temp[i];
            sumnew += abs(temp[i]);
        }
        maxsum = max(maxsum,sumnew);
        a.pop_back();
        
        start = 0;
        end = start+1;

    }
    if(maxsum >= sumin) cout<<maxsum<<endl;
    else cout<<sumin<<endl;
    return;

}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--){
        solve();
    }

return 0;
}




Submission (verdict: Wrong answer on test 2):



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

#define ll long long
#define ld long double
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vll vector<long long>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pii pair<int,int>
#define el '\n'
#define value(x) cout<<x<<"\n";

void  solve(){
    ll n;
    cin>>n;
    vll a(n);
    rep(i,0,n) cin>>a[i];

    if(n==1){
        cout<<a[0]<<endl;
        return ;
    }

    ll maxsum = accumulate(a.begin(),a.end(),0);

    ll start = 0, end = start+1;
    
    rep(k,1,n){
        
        ll sumnew = 0;
        while(end < a.size()){
            a[start] = a[end] - a[start];
            start++;
            end = start+1;
        }
        a.pop_back();
        rep(i,0,a.size()){
            sumnew += abs(a[i]);
        }
        maxsum = max(maxsum,sumnew);
        
        start = 0;
        end = start+1;

    }
    cout<<maxsum<<endl;
    return;

}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--){
        solve();
    }

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


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

using namespace std;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define srt(x) sort(x.begin(),x.end())

#define pb(x) push_back(x)

#define prll(x) for(auto it: x)cout<<it<<" ";cout<<endl

#define ll long long

#define endl '\n'

void solve(){

     ll n,l,r;cin>>n>>l>>r;

     ll arr[n];

     for(auto &it:arr)cin>>it;

     sort(arr,arr+n);

     ll tm=r-l+1;

     ll s=0;

     for(ll i=0;i<tm;i++)s+=arr[i];

     cout<<s<<endl;

}

int main(){

    fast;

    ll t=1;

    cin>>t;

    while(t--){

       solve();

    }

    return 0;

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

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

using namespace std;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define srt(x) sort(x.begin(),x.end())

#define pb(x) push_back(x)

#define prll(x) for(auto it: x)cout<<it<<" ";cout<<endl

#define ll long long

#define endl '\n'

void solve(){

     ll n,l,r;cin>>n>>l>>r;

     ll arr[n];

     for(auto &it:arr)cin>>it;

     sort(arr,arr+n);

     ll tm=r-l+1;

     ll s=0;

     for(ll i=0;i<tm;i++)s+=arr[i];

     cout<<s<<endl;

}

int main(){

    fast;

    ll t=1;

    cin>>t;

    while(t--){

       solve();

    }

    return 0;

}







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

using namespace std;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define srt(x) sort(x.begin(),x.end())

#define pb(x) push_back(x)

#define print(x) for(auto it: x)cout<<it<<" ";cout<<endl

#define ll long long

//#define endl '\n'

void solve(){

     ll n,l,r;cin>>n>>l>>r;

     ll arr[n+1],brr[n+1];

     for(int i=0;i<n;i++)cin>>arr[i];

     for(int i=0;i<n;i++)brr[i]=arr[i];



     sort(arr+1,arr+r+1);

     sort(brr+l,brr+n);

     print(arr);print(brr);

     ll s1=0,s2=0;

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

        s1+=arr[i];

        s2+=brr[i];

     }

     cout<<min(s1,s2)<<endl;

}

int main(){

    fast;

    ll t=1;

    cin>>t;

    while(t--){

       solve();

    }

    return 0;

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

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

using namespace std;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define srt(x) sort(x.begin(),x.end())

#define pb(x) push_back(x)

#define print(x) for(auto it: x)cout<<it<<" ";cout<<endl

#define ll long long

//#define endl '\n'

void solve(){

     ll n,l,r;cin>>n>>l>>r;

     ll arr[n+1],brr[n+1];

     for(int i=0;i<n;i++)cin>>arr[i];

     for(int i=0;i<n;i++)brr[i]=arr[i];



     sort(arr+1,arr+r+1);

     sort(brr+l,brr+n);

     print(arr);print(brr);

     ll s1=0,s2=0;

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

        s1+=arr[i];

        s2+=brr[i];

     }

     cout<<min(s1,s2)<<endl;

}

int main(){

    fast;

    ll t=1;

    cin>>t;

    while(t--){

       solve();

    }

    return 0;

}







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

using namespace std;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define srt(x) sort(x.begin(),x.end())

#define pb(x) push_back(x)

#define print(x) for(auto it: x)cout<<it<<" ";cout<<endl

#define ll long long

#define endl '\n'

void solve(){

     ll n,l,r;cin>>n>>l>>r;

     ll arr[n],brr[n];

     for(int i=0;i<n;i++)cin>>arr[i];

     for(int i=0;i<n;i++)brr[i]=arr[i];



     sort(arr,arr+r);

     sort(brr+l-1,brr+n);

     //print(arr);print(brr);

     ll s1=0,s2=0;

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

        s1+=arr[i];

     }

     for(int i=l-1;i<r;i++)s2+=brr[i];

     cout<<min(s1,s2)<<endl;

}

int main(){

    fast;

    ll t=1;

    cin>>t;

    while(t--){

       solve();

    }

    return 0;

}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

typedef long long int ll;

#define MOD 1000000007

#define test int t;cin>>t;while(t--)

#define pb push_back

#define vi vector<int>

#define vl vector<ll>

#define F first

#define S second

#define yes cout<<"Yes"<<'\n';

#define no cout<<"No"<<'\n';

#define endl "\n"

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

#define print(v) for(auto it:v) cout<<it<<" "; cout<<endl;

#define print2(pr) for(int i=pr.size()-1;i>=0;i--)cout<<pr[i];cout<<endl;

#define srt(v) sort(v.begin(),v.end());

#define rsrt(v) sort(v.rbegin(),v.rend());

#define rvs(v) reverse(v.begin(),v.end());

#define cinv(v) for(auto &it:v)cin>>it;

#define rall(v) v.rbegin(),v.rend()

#define gcd(a,b) __gcd(a,b)

#define lcm(a,b) (a*b)/gcd(a,b)

#define PI 2*acos(0.0)

#define pr pair<int,int>

#define Tasrik ios_base::sync_with_stdio(0);  cin.tie(0); cout.tie(0);



void abrakadabra()

{

string s;

cin>>s;

ll n=s.size();



for(int j=0; j<n; j++)

for(int i=1; i<min(i+10ll,n); i++)

{

ll a=s[i-1]-'0';

ll b=s[i]-'0'-1;



if(b>a)

{

s[i]--;

swap(s[i],s[i-1]);

}



}



cout<<s<<endl;





}



int main ()

{

Tasrik;

int cs=1;

test

{

//        cout << "Case " <<cs << ": ";

//        cs++;

abrakadabra();

}



return 0;

}







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

using namespace std;

typedef long long int ll;

#define MOD 1000000007

#define test int t;cin>>t;while(t--)

#define pb push_back

#define vi vector<int>

#define vl vector<ll>

#define F first

#define S second

#define yes cout<<"Yes"<<'\n';

#define no cout<<"No"<<'\n';

#define endl "\n"

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

#define print(v) for(auto it:v) cout<<it<<" "; cout<<endl;

#define print2(pr) for(int i=pr.size()-1;i>=0;i--)cout<<pr[i];cout<<endl;

#define srt(v) sort(v.begin(),v.end());

#define rsrt(v) sort(v.rbegin(),v.rend());

#define rvs(v) reverse(v.begin(),v.end());

#define cinv(v) for(auto &it:v)cin>>it;

#define rall(v) v.rbegin(),v.rend()

#define gcd(a,b) __gcd(a,b)

#define lcm(a,b) (a*b)/gcd(a,b)

#define PI 2*acos(0.0)

#define pr pair<int,int>

#define Tasrik ios_base::sync_with_stdio(0);  cin.tie(0); cout.tie(0);



void abrakadabra()

{

string s;

cin>>s;

ll n=s.size();



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

for(int i=j; i>0 && s[i]>=s[i-1]+2; i--)

{

s[i]--;

swap(s[i],s[i-1]);

}





cout<<s<<endl;





}



int main ()

{

Tasrik;

int cs=1;

test

{

//        cout << "Case " <<cs << ": ";

//        cs++;

abrakadabra();

}



return 0;

}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

typedef long long int ll;

#define MOD 1000000007

#define test int t;cin>>t;while(t--)

#define pb push_back

#define vi vector<int>

#define vl vector<ll>

#define F first

#define S second

#define yes cout<<"Yes"<<'\n';

#define no cout<<"No"<<'\n';

#define endl "\n"

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

#define print(v) for(auto it:v) cout<<it<<" "; cout<<endl;

#define print2(pr) for(int i=pr.size()-1;i>=0;i--)cout<<pr[i];cout<<endl;

#define srt(v) sort(v.begin(),v.end());

#define rsrt(v) sort(v.rbegin(),v.rend());

#define rvs(v) reverse(v.begin(),v.end());

#define cinv(v) for(auto &it:v)cin>>it;

#define rall(v) v.rbegin(),v.rend()

#define gcd(a,b) __gcd(a,b)

#define lcm(a,b) (a*b)/gcd(a,b)

#define PI 2*acos(0.0)

#define pr pair<int,int>

#define Tasrik ios_base::sync_with_stdio(0);  cin.tie(0); cout.tie(0);



void abrakadabra()

{

string s;

cin>>s;

ll n=s.size();



for(int j=0; j<9; j++)

for(int i=1; i<min(10ll,n); i++)

{

ll a=s[i-1]-'0';

ll b=s[i]-'0'-1;



if(b>a)

{

s[i]--;

swap(s[i],s[i-1]);

}



}



cout<<s<<endl;





}



int main ()

{

Tasrik;

int cs=1;

test

{

//        cout << "Case " <<cs << ": ";

//        cs++;

abrakadabra();

}



return 0;

}







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

using namespace std;

typedef long long int ll;

#define MOD 1000000007

#define test int t;cin>>t;while(t--)

#define pb push_back

#define vi vector<int>

#define vl vector<ll>

#define F first

#define S second

#define yes cout<<"Yes"<<'\n';

#define no cout<<"No"<<'\n';

#define endl "\n"

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

#define print(v) for(auto it:v) cout<<it<<" "; cout<<endl;

#define print2(pr) for(int i=pr.size()-1;i>=0;i--)cout<<pr[i];cout<<endl;

#define srt(v) sort(v.begin(),v.end());

#define rsrt(v) sort(v.rbegin(),v.rend());

#define rvs(v) reverse(v.begin(),v.end());

#define cinv(v) for(auto &it:v)cin>>it;

#define rall(v) v.rbegin(),v.rend()

#define gcd(a,b) __gcd(a,b)

#define lcm(a,b) (a*b)/gcd(a,b)

#define PI 2*acos(0.0)

#define pr pair<int,int>

#define Tasrik ios_base::sync_with_stdio(0);  cin.tie(0); cout.tie(0);



void abrakadabra()

{

string s;

cin>>s;

ll n=s.size();



for(int j=0; j<n; j++)

for(int i=1; i<min(i+10ll,n); i++)

{

ll a=s[i-1]-'0';

ll b=s[i]-'0'-1;



if(b>a)

{

s[i]--;

swap(s[i],s[i-1]);

}



}



cout<<s<<endl;





}



int main ()

{

Tasrik;

int cs=1;

test

{

//        cout << "Case " <<cs << ": ";

//        cs++;

abrakadabra();

}



return 0;

}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)


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

using namespace std;

typedef long long int ll;

#define MOD 1000000007

#define test int t;cin>>t;while(t--)

#define pb push_back

#define vi vector<int>

#define vl vector<ll>

#define F first

#define S second

#define yes cout<<"Yes"<<'\n';

#define no cout<<"No"<<'\n';

#define endl "\n"

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

#define print(v) for(auto it:v) cout<<it<<" "; cout<<endl;

#define print2(pr) for(int i=pr.size()-1;i>=0;i--)cout<<pr[i];cout<<endl;

#define srt(v) sort(v.begin(),v.end());

#define rsrt(v) sort(v.rbegin(),v.rend());

#define rvs(v) reverse(v.begin(),v.end());

#define cinv(v) for(auto &it:v)cin>>it;

#define rall(v) v.rbegin(),v.rend()

#define gcd(a,b) __gcd(a,b)

#define lcm(a,b) (a*b)/gcd(a,b)

#define PI 2*acos(0.0)

#define pr pair<int,int>

#define Tasrik ios_base::sync_with_stdio(0);  cin.tie(0); cout.tie(0);



void abrakadabra()

{

string s;

cin>>s;

ll n=s.size();



for(int j=0; j<9; j++)

for(int i=1; i<min(10ll,n); i++)

{

ll a=s[i-1]-'0';

ll b=s[i]-'0'-1;



if(b>a)

{

s[i]--;

swap(s[i],s[i-1]);

}



}



cout<<s<<endl;





}



int main ()

{

Tasrik;

int cs=1;

test

{

//        cout << "Case " <<cs << ": ";

//        cs++;

abrakadabra();

}



return 0;

}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


Submission (verdict: Runtime error on test 2):
//Jai Shree Ram

//Author : Meet Upadhyay

#include<bits/stdc++.h>

#include<unordered_set>

#define lli long long int

const lli MOD=1e9+7 ;

const lli MOD2= 998244353; 

const lli inf=1e18; 

bool sortbysec(const std::pair<int,int> &a,const std::pair<int,int> &b) { return (a.second < b.second); } 

lli power(lli n,lli a){ lli res=1; while(a){ if(a%2) res*=n,a--; else   n*=n,a/=2;} return res;}

lli modpower(lli n,lli a,lli p){ lli res=1; while(a){ if(a%2) res= ((res*n)%p) ,a--; else n=((n*n)%p),a/=2;} return res;}

lli fastprime(lli a){ if (a != 2 && a % 2 == 0 || a < 2) return 0;  for(lli i = 3; i * i <= a; i += 2) if(a % i == 0) return 0; return 1;}  

lli mod_mul_inverse(lli a,lli b) {return modpower(a , b-2, b);}

using namespace std;



template <unsigned int MOD>

struct ModInt {

using uint = unsigned int;

using ull = unsigned long long;

using M = ModInt;

uint v;

ModInt(lli _v = 0) { set_norm(_v % MOD + MOD); }

M& set_norm(uint _v) {  //[0, MOD * 2)->[0, MOD)

v = (_v < MOD) ? _v : _v - MOD;

return *this;

}

explicit operator bool() const { return v != 0; }

M operator+(const M& a) const { return M().set_norm(v + a.v); }

M operator-(const M& a) const { return M().set_norm(v + MOD - a.v); }

M operator*(const M& a) const { return M().set_norm(ull(v) * a.v % MOD); }

M operator/(const M& a) const { return *this * a.inv(); }

M& operator+=(const M& a) { return *this = *this + a; }

M& operator-=(const M& a) { return *this = *this - a; }

M& operator*=(const M& a) { return *this = *this * a; }

M& operator/=(const M& a) { return *this = *this / a; }

M operator-() const { return M() - *this; }

M& operator++(int) { return *this = *this + 1; }

M& operator--(int) { return *this = *this - 1; }

M pow(lli n) const {

if (n < 0) return inv().pow(-n);

M x = *this, res = 1;

while (n) {

if (n & 1) res *= x;

x *= x;

n >>= 1;

}

return res;

}

M inv() const {

lli a = v, b = MOD, p = 1, q = 0, t;

while (b != 0) {

t = a / b;

swap(a -= t * b, b);

swap(p -= t * q, q);

}

return M(p);

}

bool operator==(const M& a) const { return v == a.v; }

bool operator!=(const M& a) const { return v != a.v; }

friend ostream& operator<<(ostream& os, const M& a) { return os << a.v; }

static uint get_mod() { return MOD; }

};

;

using Mint = ModInt<1000000007>;

void solve()

{

    string a;

    cin>>a;

    string b;

    cin>>b;

    string c;

    cin>>c;

    lli n = a.size();

    lli m = b.size();

    vector<vector<lli>>dp(n+1, vector<lli>(m+1,1e14));

    dp[0][0] = 0;

    for(lli i=0;i<n;i++)

    {

        dp[i+1][0] = dp[i][0] + (a[i]!=c[i]);

    }



    for(lli i=0;i<n;i++)

    {

        dp[0][i+1] = dp[0][i] + (b[i]!=c[i]);

    }



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

    {

        for(lli j=1;j<=m;j++)

        {

            dp[i][j] = min(dp[i-1][j] + (a[i-1]!=c[i+j-1]), dp[i][j-1] + (b[j-1]!=c[i+j-1]));

        }

    }



    cout<<dp[n][m]<<endl;



}

int main()

{

    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int t;

    cin>>t;

    while(t--)

    {

        solve();

    }

    return 0;

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

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

int main() {
    int t;
    cin >> t;
    while (t--) {
        ll n;
        cin >> n;

        vector<int> digits;
        ll sum = 0;

        while (n > 0) {
            ll temp = n % 10;
            digits.push_back(temp);
            sum += temp;
            n /= 10;
        }
        ll count2 = 0, count3 = 0;
        for (int digit : digits) {
            if (digit == 2) count2++;
            if (digit == 3) count3++;
        }
        bool possible = false;
        for (ll i = 0; i <= count2; i++) { 
            for (ll j = 0; j <= count3; j++) { 
                ll newSum = sum + i * 2 + j * 6;
                if (newSum % 9 == 0) {
                    possible = true;
                    break;  
                }
                }
            if (possible) break;  
        }

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


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

int main() {
    int t;
    cin >> t;
    while (t--) {
        string n;
        cin >> n;
        vector<int> digits;
        int sum = 0;
        for (char c : n) {
            int digit = c - '0';  
            digits.push_back(digit);
            sum += digit;  
        }
        if (sum % 9 == 0) {
            cout << "YES" << endl;
            continue;
        }
        int count2 = 0, count3 = 0;
        for (int digit : digits) {
            if (digit == 2) count2++;
            if (digit == 3) count3++;
        }
        bool possible = false;
        for (int i = 0; i <= count2 && !possible; i++) { 
            for (int j = 0; j <= count3 && !possible; j++) { 
                int newSum = sum + i * 2 + j * 6;
                if (newSum % 9 == 0) {
                    possible = true;
                    break;
                }
            }
        }
        if (possible) {
            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 3):
#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
    int t;
    cin >> t;
    while (t--) {
        ll n;
        cin >> n;

        vector<int> digits;
        ll sum = 0;

        while (n > 0) {
            ll temp = n % 10;
            digits.push_back(temp);
            sum += temp;
            n /= 10;
        }

        if (sum % 9 == 0) {
            cout << "YES" << endl;
            continue;
        }

        ll count2 = 0, count3 = 0;
        for (int digit : digits) {
            if (digit == 2) count2++;
            if (digit == 3) count3++;
        }
        bool possible = false;
        for (ll i = 0; i <= count2 && !possible; i++) { 
            for (ll j = 0; j <= count3 && !possible; j++) { 
                ll newSum = sum + i * 2 + j * 6;
                if (newSum % 9 == 0) {
                    possible = true;
                    break;
                }
            }
            if(possible){break;}
        }

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


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

int main() {
    int t;
    cin >> t;
    while (t--) {
        ll n;
        cin >> n;

        vector<int> digits;
        ll sum = 0;

        while (n > 0) {
            ll temp = n % 10;
            digits.push_back(temp);
            sum += temp;
            n /= 10;
        }
        ll count2 = 0, count3 = 0;
        for (int digit : digits) {
            if (digit == 2) count2++;
            if (digit == 3) count3++;
        }
        bool possible = false;
        for (ll i = 0; i <= count2; i++) { 
            for (ll j = 0; j <= count3; j++) { 
                ll newSum = sum + i * 2 + j * 6;
                if (newSum % 9 == 0) {
                    possible = true;
                    break;  
                }
                }
            if (possible) break;  
        }

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