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;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> pil;
typedef pair<int, int> pii;
typedef vector<ll>  vll;
typedef vector<int> vi;
#define f(i,c,n) for(int i=c;i<n;i++)
#define all(x) x.begin(),x.end()
#define pb push_back

void solve(){
    int n;cin>>n;
    vector<int> vec(n);
    f(i,0,n) {cin>>vec[i];}

        int temp=n;
        int64_t res = INT_MIN;
        for(int i = 0;i < n; i++){
            int64_t sum = 0;
            f(i,0,temp) sum+=vec[i];
            if(i==0) res = max (res,sum);
            else res = max(res,max(sum,(-sum)));
            f(i,0,temp-1){
                vec[i] = vec[i+1] - vec[i];
            }
            temp--;
        }
        cout << res << endl;

}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> pil;
typedef pair<int, int> pii;
typedef vector<ll>  vll;
typedef vector<int> vi;
#define f(i,c,n) for(int i=c;i<n;i++)
#define all(x) x.begin(),x.end()
#define pb push_back
int a[1010] ;

void solve(){
    int n;
		cin >> n;
		for (int i = 1; i <= n; i++) cin >> a[i];
		int now = n;
		long long ans = -1e18;
		for (int i = 1; i <= n; i++){
			long long sum = 0;
			for (int i = 1; i <= now; i++) sum = (sum + a[i]) ;
			if (i == 1) ans = max(ans, sum);
			else ans = max(ans, max(sum, ( - sum) ));
			for (int i = 1; i < now; i++) a[i] = (a[i + 1] - a[i]) ;
			now--;
		}
		cout << ans << endl; 

}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    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;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> pil;
typedef pair<int, int> pii;
typedef vector<ll>  vll;
typedef vector<int> vi;
#define f(i,c,n) for(int i=c;i<n;i++)
#define all(x) x.begin(),x.end()
#define pb push_back
int a[1010] ;

void solve(){
    int n;
		cin >> n;
		for (int i = 1; i <= n; i++) cin >> a[i];
		int now = n;
		long long ans = -1e18 * 1LL;
		for (int i = 1; i <= n; i++){
			long long sum = 0 * 1LL;
			for (int i = 1; i <= now; i++) sum = (sum + a[i]) ;
			if (i == 1) ans = max(ans, sum);
			else ans = max(ans, max(sum, ( - sum) ));
			for (int i = 1; i < now; i++) a[i] = (a[i + 1] - a[i]) ;
			now--;
		}
		cout << ans * 1LL << endl; 

}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> pil;
typedef pair<int, int> pii;
typedef vector<ll>  vll;
typedef vector<int> vi;
#define f(i,c,n) for(int i=c;i<n;i++)
#define all(x) x.begin(),x.end()
#define pb push_back

void solve(){
    int n;cin>>n;
    vector<int64_t> vec(n);
    f(i,0,n) {cin>>vec[i];}

        int temp=n;
        int64_t res = INT_MIN;
        for(int i = 0;i < n; i++){
            int64_t sum = 0;
            f(i,0,temp) sum+=vec[i];
            if(i==0) res = max (res,sum);
            else res = max(res,max(sum,(-sum)));
            f(i,0,temp-1){
                vec[i] = vec[i+1] - vec[i];
            }
            temp--;
        }
        cout << res << endl;

}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_multiset;
const long long int mod=1e9+7;
const long long int mod2=998244353;
#define ll long long int
#define str string
#define vll __int128
#define nl "\n" 
#define pii pair<int,int>
#define vi vector<int>
// long long exp(long long a, long long b){
//     if(b==0) return 1;
//     if(b==1) return a;
//     long long temp=exp(a,b/2)%mod;
//     long long result=(1LL*temp*temp)%mod;
//     if(b%2==1) result=(result*a)%mod;
//     return result;
// }
// vector<bool> notprime(2e6+5);
// vector<int> primes;
// void sieve(){
//     for(int i=2;i*i<2e6+5;i++){
//         if(!notprime[i]){
//             for(int j=i*i;j<2e6+5;j+=i){
//                 notprime[j]=true;
//             }
//         }
//     }
// }
// bool cmp(pair<int,int> &a,pair<int,int> &b){
//     if(a.second==b.second){
//         return a.first>b.first;
//     }
//     return a.second<b.second;
// }
// ll inv(ll a, ll p){
//     return exp(a, p-2);
// }
// ll nCk(ll n, ll k, ll p){
//     return ((fact[n] * inv(fact[k], p) % p) * inv(fact[n-k], p)) % p;
// }
// ll lcm(ll a,ll b){
//     return 1LL*a*b/__gcd(a,b);
// }
void solve(){
    str s;
    cin>>s;
    vector<vector<int>> arr(10);
    for(int i=s.size()-1;i>=0;i--){
        arr[s[i]-'0'].push_back(i);
    }
    sort(s.begin(),s.end(),greater<char>());
    for(auto &i:s){
        i-=arr[i-'0'].back();
        arr[i-'0'].pop_back();
    }
    cout<<s<<nl;

}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1,tt=1;
    cin>>t;
    while(t--){
        // cout<<"Case #"<<tt++<<": ";
        solve();
        
    }    
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Time limit exceeded on test 6):
// Jai Ho mere Gurudev Bhagwan Ki

// Jai Jai Shree Radhey Shyam

#include<bits/stdc++.h>

#define int long long int

#define ll long long int

#define pb push_back

#define debug(...) __f (#__VA_ARGS__, __VA_ARGS__)

using namespace std;



/*B U G*/

template <typename Arg1>

void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }

template <typename Arg1, typename... Args>

void __f (const char* names, Arg1&& arg1, Args&&... args){

    const char* comma = strchr (names + 1, ',');

    cout.write (names, comma - names) << " : " << arg1 << " | ";

    __f (comma + 1, args...);

}

/*B U G*/

unordered_map<string, bool> dp;

bool sol(int index, int sum, int n, vector<int> &vec){

    if(index == n) return (sum%9 == 0);

    string key = to_string(index)+'_'+to_string(sum);

    if(dp.find(key) != dp.end()) return dp[key];

    if(sol(index+1, sum, n, vec)) return dp[key] = true;



    if(vec[index] < 4){

        int value = vec[index];

        sum+=(vec[index]*(vec[index]-1));

        vec[index]*=vec[index];

        if(sum%9 == 0) return dp[key] = true;

        if(sol(index+1, sum, n, vec)) return dp[key] = true;

        vec[index] = value;

    }

    return dp[key] = false;

}

void solve() {

    string s; cin>>s; int n = s.size(), sum = 0; 

    vector<int> vec(n);

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

        vec[i] = s[i] - '0';

        sum+=vec[i];

    }

    dp.clear();

    if(sol(0, sum, n, vec)) cout<<"YES\n";

    else cout<<"NO\n";

}



int32_t main(){

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

    #ifndef ONLINE_JUDGE

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

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

    #endif

    int t = 1;

    cin >> t;

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

        solve();

    }

    return 0;

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

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
int main() 
{
    int t;
    cin >> t;
    while(t--)
    {
        ll l, r, dummy;
        cin >> l >> r;
        ll z = log2(r);
        dummy = 0;
        if(l < pow(2, z) && r >= pow(2, z))
        {
            //if(l == pow(2, z)) cout << l << " " << r << " " << l + 1;
            if(l == pow(2, z) - 1) cout << l << " " << pow(2, z) << " " << r;
            else if(l != pow(2, z)) cout << pow(2, z) << " "  << pow(2, z) - 1 << " " <<  l;
        }
        else
        {
            ll a = l; 
            ll c = r;
            z = pow(2, z);
            //cout << z << endl;
            while(z <= a && z < c)
            {
                dummy += z;
                a -= z;
                c -= z;
                z = log2(c);
                z = pow(2, z);
            }
            //cout << z << endl;
            //if(z == a) cout << z + dummy << " " << z + dummy - 1 << " " << a + ;
            if(z == c) cout << z + dummy << " " << z - 1 + dummy << " " << a + dummy;
            else cout << z + dummy << " " << z - 1 + dummy<< " " << a + dummy;
        }
        cout << endl;
    }
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
int main() 
{
    int t;
    cin >> t;
    while(t--)
    {
        ll l, r, dummy;
        cin >> l >> r;
        ll z = log2(r);
        dummy = 0;
        if(l < pow(2, z) && r >= pow(2, z))
        {
            //if(l == pow(2, z)) cout << l << " " << r << " " << l + 1;
            if(l == pow(2, z) - 1) cout << (ll) l << " " << (ll) pow(2, z) << " " << (ll) r;
            else if(l != pow(2, z)) cout << (ll) pow(2, z) << " "  << (ll)(pow(2, z) - 1) << " " <<  (ll) l;
        }
        else
        {
            ll a = l; 
            ll c = r;
            z = pow(2, z);
            //cout << z << endl;
            while(z <= a && z < c)
            {
                dummy += z;
                a -= z;
                c -= z;
                z = log2(c);
                z = pow(2, z);
            }
            //cout << z << endl;
            //if(z == a) cout << z + dummy << " " << z + dummy - 1 << " " << a + ;
            if(z == c) cout << z + dummy << " " << z - 1 + dummy << " " << a + dummy;
            else cout << z + dummy << " " << z - 1 + dummy<< " " << a + dummy;
        }
        cout << endl;
    }
    return 0;
}
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;
using ll = long long;
 
int main() 
{
    int t;
    cin >> t;
    while(t--)
    {
        ll l, r, dummy;
        cin >> l >> r;
        ll z = log2(r);
        dummy = 0;
        if(l < pow(2, z) && r >= pow(2, z))
        {
            //if(l == pow(2, z)) cout << l << " " << r << " " << l + 1;
            if(l == pow(2, z) - 1) cout << (ll) l << " " << (ll) pow(2, z) << " " << (ll) r;
            else if(l != pow(2, z)) cout << (ll) pow(2, z) << " "  << (ll)(pow(2, z) - 1) << " " <<  (ll) l;
        }
        else
        {
            ll a = l; 
            ll c = r;
            z = pow(2, z);
            //cout << z << endl;
            while(z <= a && z < c)
            {
                dummy += z;
                a -= z;
                c -= z;
                z = log2(c);
                z = pow(2, z);
            }
            //cout << z << endl;
            //if(z == a) cout << z + dummy << " " << z + dummy - 1 << " " << a + ;
            if(z == c) cout << z + dummy << " " << z - 1 + dummy << " " << a + dummy;
            else cout << z + dummy << " " << z - 1 + dummy<< " " << a + dummy;
        }
        cout << endl;
    }
    return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
int main() 
{
    int t;
    cin >> t;
    while(t--)
    {
        ll l, r, dummy;
        cin >> l >> r;
        ll z = log2(r);
        dummy = 0;
        if(l < pow(2, z) && r >= pow(2, z))
        {
            //if(l == pow(2, z)) cout << l << " " << r << " " << l + 1;
            if(l == pow(2, z) - 1) cout << (ll) l << " " << (ll) pow(2, z) << " " << (ll) r;
            else if(l != pow(2, z)) cout << (ll) pow(2, z) << " "  << (ll)(pow(2, z) - 1) << " " <<  (ll) l;
        }
        else
        {
            ll a = l; 
            ll c = r;
            z = pow(2, z);
            //cout << z << endl;
            while(z <= a && z < c)
            {
                dummy += z;
                a -= z;
                c -= z;
                z = log2(c);
                z = pow(2, z);
            }
            //cout << z << endl;
            //if(z == a) cout << z + dummy << " " << z + dummy - 1 << " " << a + ;
            if(z == c) cout << z + dummy << " " << z - 1 + dummy << " " << a + dummy;
            else
            {
                if(z - 1 == a) cout << z + dummy << " " << z - 1 + dummy<< " " << c + dummy;
                else cout << z + dummy << " " << z - 1 + dummy<< " " << a + dummy;
            }
        }
        cout << endl;
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
int main() 
{
    int t;
    cin >> t;
    while(t--)
    {
        ll l, r, dummy;
        cin >> l >> r;
        ll z = log2(r);
        if(l <= pow(2, z) && r >= pow(2, z))
        {
            if(l == pow(2, z)) cout << l << " " << r << " " << l + 1;
            else if(l == pow(2, z) - 1) cout << l << " " << pow(2, z) << " " << r;
            else cout << pow(2, z) << " "  << pow(2, z) - 1 << " " <<  l;
        }
        else cout << r << " " << l << " " << l + 1;
        cout << endl;
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
int main() 
{
    int t;
    cin >> t;
    while(t--)
    {
        ll l, r, dummy;
        cin >> l >> r;
        ll z = log2(r);
        if(l <= pow(2, z) && r >= pow(2, z))
        {
            if(l == pow(2, z)) cout << l << " " << r << " " << l + 1;
            else if(l == pow(2, z) - 1) cout << l << " " << pow(2, z) << " " << r;
            else cout << pow(2, z) << " "  << pow(2, z) - 1 << " " <<  l;
        }
        else cout << r << " " << l << " " << l + 1;
        cout << endl;
    }
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
int main() 
{
    int t;
    cin >> t;
    while(t--)
    {
        ll l, r, dummy;
        cin >> l >> r;
        ll z = log2(r);
        dummy = 0;
        if(l < pow(2, z) && r >= pow(2, z))
        {
            //if(l == pow(2, z)) cout << l << " " << r << " " << l + 1;
            if(l == pow(2, z) - 1) cout << l << " " << pow(2, z) << " " << r;
            else if(l != pow(2, z)) cout << pow(2, z) << " "  << pow(2, z) - 1 << " " <<  l;
        }
        else
        {
            ll a = l; 
            ll c = r;
            z = pow(2, z);
            //cout << z << endl;
            while(z <= a && z < c)
            {
                dummy += z;
                a -= z;
                c -= z;
                z = log2(c);
                z = pow(2, z);
            }
            //cout << z << endl;
            //if(z == a) cout << z + dummy << " " << z + dummy - 1 << " " << a + ;
            if(z == c) cout << z + dummy << " " << z - 1 + dummy << " " << a + dummy;
            else cout << z + dummy << " " << z - 1 + dummy<< " " << a + dummy;
        }
        cout << endl;
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
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--){
        string s; cin>>s;
        int c_2=0,c_3=0,sum=0;

        for(int i=0; i<s.size(); i++){
            if(s[i]=='2') c_2++;
            else if(s[i]=='3') c_3++;
            sum+=(s[i]-'0');
        }
        // cout<<sum<<" ";
        sum=sum%9;
        if(sum) sum=9-sum;
        // cout<<sum<<" "<<s.size()<<" "<<c_2<<" "<<c_3<<endl;

        if(sum==0) cout<<"YES"<<endl;
        else if(sum==1 && ((c_2>=2 && c_3>=1) || (c_2>=5))) cout<<"YES"<<endl;
        else if(sum==2 && c_2) cout<<"YES"<<endl;
        else if(sum==3 && c_3>=2) cout<<"YES"<<endl;
        else if(sum==4 && c_2>=2) cout<<"YES"<<endl;
        else if(sum==5 && c_2 && c_3>=2) cout<<"YES"<<endl;
        else if(sum==6 && (c_2>=3 || c_3)) cout<<"YES"<<endl;
        else if(sum==7 && ((c_3>=2 && c_2) || (c_2>=7)) || (c_3 && c_2>=4)) cout<<"YES"<<endl;
        else if(sum==8 && (c_2>=4 || (c_2 && c_3))) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}

Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t; cin>>t;
    while(t--){
        string s; cin>>s;
        int c_2=0,c_3=0,sum=0;

        for(int i=0; i<s.size(); i++){
            if(s[i]=='2') c_2++;
            else if(s[i]=='3') c_3++;
            sum+=(s[i]-'0');
        }
        // cout<<sum<<" ";
        sum=sum%9;
        if(sum) sum=9-sum;
        // cout<<sum<<" "<<s.size()<<" "<<c_2<<" "<<c_3<<endl;

        if(sum==0) cout<<"YES"<<endl;
        else if(sum==1 && ((c_2>=2 && c_3>=1) || (c_2>=5))) cout<<"YES"<<endl;
        else if(sum==2 && c_2) cout<<"YES"<<endl;
        else if(sum==3 && c_3>=2) cout<<"YES"<<endl;
        else if(sum==4 && c_2>=2) cout<<"YES"<<endl;
        else if(sum==5 && c_2 && c_3>=2) cout<<"YES"<<endl;
        else if(sum==6 && (c_2>=3 || c_3)) cout<<"YES"<<endl;
        else if(sum==7 && ((c_3>=2 && c_2>=2) || (c_2>=8) || (c_3 && c_2>=5))) cout<<"YES"<<endl;
        else if(sum==8 && (c_2>=4 || (c_2 && c_3))) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}
Problem: 2050C - Uninteresting Number
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--){
        string s; cin>>s;
        int c_2=0,c_3=0,sum=0;

        for(int i=0; i<s.size(); i++){
            if(s[i]=='2') c_2++;
            else if(s[i]=='3') c_3++;
            sum+=(s[i]-'0');
        }
        // cout<<sum<<" ";
        sum=sum%9;
        if(sum) sum=9-sum;
        // cout<<sum<<" "<<s.size()<<" "<<c_2<<" "<<c_3<<endl;

        if(sum==0) cout<<"YES"<<endl;
        else if(sum==1 && (c_2>=2 && c_3>=1)) cout<<"YES"<<endl;
        else if(sum==2 && c_2) cout<<"YES"<<endl;
        else if(sum==3 && c_3>=2) cout<<"YES"<<endl;
        else if(sum==4 && c_2>=2) cout<<"YES"<<endl;
        else if(sum==5 && c_2 && c_3>=2) cout<<"YES"<<endl;
        else if(sum==6 && (c_2>=3 || c_3)) cout<<"YES"<<endl;
        else if(sum==7 && ((c_3>=2 && c_2) || (c_2>=7)) || (c_3 && c_2>=4)) cout<<"YES"<<endl;
        else if(sum==8 && (c_2>=4 || (c_2 && c_3))) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t; cin>>t;
    while(t--){
        string s; cin>>s;
        int c_2=0,c_3=0,sum=0;

        for(int i=0; i<s.size(); i++){
            if(s[i]=='2') c_2++;
            else if(s[i]=='3') c_3++;
            sum+=(s[i]-'0');
        }
        // cout<<sum<<" ";
        sum=sum%9;
        if(sum) sum=9-sum;
        // cout<<sum<<" "<<s.size()<<" "<<c_2<<" "<<c_3<<endl;

        if(sum==0) cout<<"YES"<<endl;
        else if(sum==1 && ((c_2>=2 && c_3>=1) || (c_2>=5))) cout<<"YES"<<endl;
        else if(sum==2 && c_2) cout<<"YES"<<endl;
        else if(sum==3 && c_3>=2) cout<<"YES"<<endl;
        else if(sum==4 && c_2>=2) cout<<"YES"<<endl;
        else if(sum==5 && c_2 && c_3>=2) cout<<"YES"<<endl;
        else if(sum==6 && (c_2>=3 || c_3)) cout<<"YES"<<endl;
        else if(sum==7 && ((c_3>=2 && c_2) || (c_2>=7)) || (c_3 && c_2>=4)) cout<<"YES"<<endl;
        else if(sum==8 && (c_2>=4 || (c_2 && c_3))) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t; cin>>t;
    while(t--){
        string s; cin>>s;
        int c_2=0,c_3=0,sum=0;

        for(int i=0; i<s.size(); i++){
            if(s[i]=='2') c_2++;
            else if(s[i]=='3') c_3++;
            sum+=(s[i]-'0');
        }
        // cout<<sum<<" ";
        sum=sum%9;
        if(sum) sum=9-sum;
        // cout<<sum<<" "<<s.size()<<" "<<c_2<<" "<<c_3<<endl;

        if(sum==0) cout<<"YES"<<endl;
        else if(sum==1 && ((c_2>=2 && c_3>=1) || (c_2>=5))) cout<<"YES"<<endl;
        else if(sum==2 && c_2) cout<<"YES"<<endl;
        else if(sum==3 && c_3>=2) cout<<"YES"<<endl;
        else if(sum==4 && c_2>=2) cout<<"YES"<<endl;
        else if(sum==5 && c_2 && c_3>=2) cout<<"YES"<<endl;
        else if(sum==6 && (c_2>=3 || c_3)) cout<<"YES"<<endl;
        else if(sum==7 && ((c_3>=2 && c_2>=2) || (c_2>=8) || (c_3 && c_2>=5))) cout<<"YES"<<endl;
        else if(sum==8 && (c_2>=4 || (c_2 && c_3))) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t; cin>>t;
    while(t--){
        string s; cin>>s;
        int c_2=0,c_3=0,sum=0;

        for(int i=0; i<s.size(); i++){
            if(s[i]=='2') c_2++;
            else if(s[i]=='3') c_3++;
            sum+=(s[i]-'0');
        }
        // cout<<sum<<" ";
        sum=sum%9;
        if(sum) sum=9-sum;
        // cout<<sum<<" "<<s.size()<<" "<<c_2<<" "<<c_3<<endl;
        int f=0;
        if(!sum) f=1;

        for(int i=0; i<=c_2; i++){
            for (int j=0; j<=c_3; j++){
                int temp=(i*2+j*6)%9;
                if(temp==sum){f=1; break;}
            }
            if(f) break;
        }

        if(f) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t; cin>>t;
    while(t--){
        string s; cin>>s;
        int c_2=0,c_3=0,sum=0;

        for(int i=0; i<s.size(); i++){
            if(s[i]=='2') c_2++;
            else if(s[i]=='3') c_3++;
            sum+=(s[i]-'0');
        }
        // cout<<sum<<" ";
        sum=sum%9;
        if(sum) sum=9-sum;
        // cout<<sum<<" "<<s.size()<<" "<<c_2<<" "<<c_3<<endl;

        if(sum==0) cout<<"YES"<<endl;
        else if(sum==1 && (c_2>=2 && c_3>=1)) cout<<"YES"<<endl;
        else if(sum==2 && c_2) cout<<"YES"<<endl;
        else if(sum==3 && c_3>=2) cout<<"YES"<<endl;
        else if(sum==4 && c_2>=2) cout<<"YES"<<endl;
        else if(sum==5 && c_2 && c_3>=2) cout<<"YES"<<endl;
        else if(sum==6 && (c_2>=3 || c_3)) cout<<"YES"<<endl;
        else if(sum==7 && ((c_3>=2 && c_2) || (c_2>=7)) || (c_3 && c_2>=4)) cout<<"YES"<<endl;
        else if(sum==8 && (c_2>=4 || (c_2 && c_3))) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}