ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
// Just a good programmer with great habits :)
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define endl '\n'
#define M 1000000007
typedef vector<int> vi;
typedef pair<int, int> pii;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bpc(x) __builtin_popcountll(x)
#define read(a) fori(i,0,n) cin >> a[i];
#define print(a) fori(i,0,n) cout << a[i] << " "; cout << endl;
#ifdef DEBUG
#define debug(x) cerr << #x << ' = ' << x << endl
#else
#define debug(x)
#endif

#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0);

#define fori(i, a, b) for (int i = (a); i < (b); ++i)
#define pyy cout << "YES" << endl
#define pnn cout << "NO" << endl

// Modular Operations
int madd(int a, int b) {
    return (a + b) % M;
}

int msub(int a, int b) {
    return (((a - b) % M) + M) % M;
}

int mmul(int a, int b) {
    return ((a % M) * (b % M)) % M;
}

int exp(int base, int exponent) {
    if(exponent == 0) {
        return 1;
    }
    if(exponent % 2 == 0) {
        int half = exp(base, exponent / 2);
        return half * half;
    } else {
        return base * exp(base, exponent - 1);
    }
}

// Conversion & Prime Checking
string dectobin(int num);
int bintodec(string n);
vector<bool> sieve(int n);
bool is_prime(int n);

vector<bool> sieve(int n) {
    vector<bool> is_prime(n, 1);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i < n; i++) {
        if (is_prime[i]) {
            for (int j = 2 * i; j < n; j += i) {
                is_prime[j] = false;
            }
        }
    }
    return is_prime;
}

bool is_prime(int n) {
    if (n < 2) return false;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return true;
}

int bintodec(string n) {
    int dec_value = 0, base = 1, len = n.length();
    for (int i = len - 1; i >= 0; i--) {
        if (n[i] == '1') dec_value += base;
        base *= 2;
    }
    return dec_value;
}

string dectobin(int num) {
    string str1;
    while (num) {
        str1 += (num & 1) ? '1' : '0';
        num >>= 1;
    }
    reverse(str1.begin(), str1.end());
    return str1;
}

void solve() {
    int l,r;
    cin >> l >> r;
    int ans = 0;
    int a,b,c;
    for(int i=30; i>=0; i--) {
        int b1 = 0;
        int b2 = 0;
        if(l & (1ll << i)) {
            b1 = 1;
        }
        if(r & (1ll << i)) {
            b2 = 1;
        }
        if(b1 == b2) {
            ans += b1* (1ll << i);
        }
        else {
            a = ans + (1ll << i);
            b = a-1;
        }
    }
    fori(i,l,r+1) {
        if(i!=a && i!=b) {
            c = i;
            break;
        }
    }
    cout << a << " " << b << " " << c << endl;
}

int32_t main() {
    fast_cin();
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 14):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,b) for(auto i=a; i<b;++i)
#define rrep(i,a,b) for(auto i=a;i>=b;--i)
#define len(x) ((int)x.size())
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define pi pair<int, int>
#define pip pair<int,pi>
#define pl pair<ll,ll>
#define plp pair<ll,pl>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define nl "\n"
#define mod 1000000007


void solve()
{
    int n,k;cin>>n>>k;
    unordered_map<int,int> mp;
    rep(i,0,n) {
      int a;cin>>a;
        mp[a]++;
    }

    vector<pi> v;
    for(auto i:mp) {
        v.pb({i.second,i.first});
    }
    sort(all(v));
    int cnt=v.size();
    for(auto i:v) {
        if(i.first<=k){
            k-=i.first;
            cnt--;
        }    
    }
    cout<<max(1,cnt)<<nl;
}


int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif*/

    ll test=1;
    cin>>test;
    while(test--)
    {
        solve();
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

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

inline void solve() {
    int n, k;
    cin >> n >> k;
    
    // Use array instead of unordered_map for faster access
    vector<int> freq(200001, 0);  // Since 1 ≤ ai ≤ 10^9, we'll count frequencies
    int distinct = 0;
    
    // Count frequencies and distinct elements in one pass
    for(int i = 0, x; i < n; ++i) {
        cin >> x;
        if(freq[x]++ == 0) distinct++;
    }
    
    // If k is large enough to remove all elements, return 1
    if(k >= n) {
        cout << "1\n";
        return;
    }
    
    // Sort frequencies in ascending order for greedy approach
    vector<int> counts;
    counts.reserve(distinct);  // Preallocate memory
    
    for(int i = 0; i <= 200000; ++i) {
        if(freq[i]) counts.push_back(freq[i]);
    }
    
    sort(counts.begin(), counts.end());
    
    // Greedily remove smallest frequency groups
    int remaining = distinct;
    for(int f : counts) {
        if(f <= k) {
            k -= f;
            --remaining;
        } else break;
    }
    
    cout << max(1, remaining) << '\n';
}

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

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,b) for(auto i=a; i<b;++i)
#define rrep(i,a,b) for(auto i=a;i>=b;--i)
#define len(x) ((int)x.size())
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define pi pair<int, int>
#define pip pair<int,pi>
#define pl pair<ll,ll>
#define plp pair<ll,pl>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define nl "\n"
#define mod 1000000007


void solve()
{
    int n,k;cin>>n>>k;
    map<int,int> mp;
    rep(i,0,n) {
      int a;cin>>a;
        mp[a]++;
    }

    vector<pi> v;
    for(auto i:mp) {
        v.pb({i.second,i.first});
    }
    sort(all(v));
    int cnt=v.size();
    for(auto i:v) {
        if(i.first<=k){
            k-=i.first;
            cnt--;
        }    
    }
    cout<<max(1,cnt)<<nl;
}


int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif*/

    ll test=1;
    cin>>test;
    while(test--)
    {
        solve();
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 14):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,b) for(auto i=a; i<b;++i)
#define rrep(i,a,b) for(auto i=a;i>=b;--i)
#define len(x) ((int)x.size())
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define pi pair<int, int>
#define pip pair<int,pi>
#define pl pair<ll,ll>
#define plp pair<ll,pl>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define nl "\n"
#define mod 1000000007


void solve()
{
    int n,k;cin>>n>>k;
    unordered_map<int,int> mp;
    rep(i,0,n) {
      int a;cin>>a;
        mp[a]++;
    }

    vector<pi> v;
    for(auto i:mp) {
        v.pb({i.second,i.first});
    }
    sort(all(v));
    int cnt=v.size();
    for(auto i:v) {
        if(i.first<=k){
            k-=i.first;
            cnt--;
        }    
    }
    cout<<max(1,cnt)<<nl;
}


int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif*/

    ll test=1;
    cin>>test;
    while(test--)
    {
        solve();
    }
    return 0;
}


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

inline void solve() {
    int n, k;
    cin >> n >> k;
    
    // Use array instead of unordered_map for faster access
    vector<int> freq(200001, 0);  // Since 1 ≤ ai ≤ 10^9, we'll count frequencies
    int distinct = 0;
    
    // Count frequencies and distinct elements in one pass
    for(int i = 0, x; i < n; ++i) {
        cin >> x;
        if(freq[x]++ == 0) distinct++;
    }
    
    // If k is large enough to remove all elements, return 1
    if(k >= n) {
        cout << "1\n";
        return;
    }
    
    // Sort frequencies in ascending order for greedy approach
    vector<int> counts;
    counts.reserve(distinct);  // Preallocate memory
    
    for(int i = 0; i <= 200000; ++i) {
        if(freq[i]) counts.push_back(freq[i]);
    }
    
    sort(counts.begin(), counts.end());
    
    // Greedily remove smallest frequency groups
    int remaining = distinct;
    for(int f : counts) {
        if(f <= k) {
            k -= f;
            --remaining;
        } else break;
    }
    
    cout << max(1, remaining) << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t = 1;
    cin >> t;
    
    while(t--) solve();
    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)

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

int t,n,u,v,res;
vector<int> e[N];
multiset<int> ms;

void dfs(int u,int f){
	if(f!=0) res = max(res,int(e[u].size()+e[f].size())-1);
	ms.erase(e[u].size());
	for(auto v:e[u]){
		ms.erase(e[v].size());
	}
	if(ms.size()>0){
		res = max(res,int(e[u].size()+*ms.rbegin()));
	}
	ms.insert(e[u].size());
	for(auto v:e[u]){
		ms.insert(e[v].size());
	}
	for(auto v:e[u]){
		if(v!=f) dfs(v,u);
	}
}

int main(){
	cin>>t;
	while(t--){
		cin>>n;
		for(int i=1;i<=n-1;i++){
			cin>>u>>v;
			e[u].push_back(v);
			e[v].push_back(u);
		}
		if(n==2){
			cout<<0<<endl;
			continue;
		}
		for(int i=1;i<=n;i++) ms.insert(e[i].size());
		dfs(1,0);
		cout<<res-3<<endl;
		res = 0;
		for(int i=1;i<=n;i++) e[i].clear();
	}
	return 0;
}

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

int t,n,u,v,res;
vector<int> e[N];
multiset<int> ms;

void dfs(int u,int f){
	if(f!=0) res = max(res,int(e[u].size()+e[f].size())-2);
	ms.erase(e[u].size());
	for(auto v:e[u]){
		ms.erase(e[v].size());
	}
	if(ms.size()>0){
		res = max(res,int(e[u].size()+*ms.rbegin())-1);
	}
	ms.insert(e[u].size());
	for(auto v:e[u]){
		ms.insert(e[v].size());
	}
	for(auto v:e[u]){
		if(v!=f) dfs(v,u);
	}
}

int main(){
	cin>>t;
	while(t--){
		res = 0;
		for(int i=1;i<=n;i++) e[i].clear();
		ms.clear();
		cin>>n;
		for(int i=1;i<=n-1;i++){
			cin>>u>>v;
			e[u].push_back(v);
			e[v].push_back(u);
		}
		if(n==2){
			cout<<0<<endl;
			continue;
		}
		for(int i=1;i<=n;i++) ms.insert(e[i].size());
		dfs(1,0);
		cout<<res<<endl;
	}
	return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)

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

int t,n,u,v,res;
vector<int> e[N];
multiset<int> ms;

void dfs(int u,int f){
	if(f!=0) res = max(res,int(e[u].size()+e[f].size())-2);
	ms.erase(e[u].size());
	for(auto v:e[u]){
		ms.erase(e[v].size());
	}
	if(ms.size()>0){
		res = max(res,int(e[u].size()+*ms.rbegin())-1);
	}
	ms.insert(e[u].size());
	for(auto v:e[u]){
		ms.insert(e[v].size());
	}
	for(auto v:e[u]){
		if(v!=f) dfs(v,u);
	}
}

int main(){
	cin>>t;
	while(t--){
		res = 0;
		for(int i=1;i<=n;i++) e[i].clear();
		ms.clear();
		cin>>n;
		for(int i=1;i<=n-1;i++){
			cin>>u>>v;
			e[u].push_back(v);
			e[v].push_back(u);
		}
		if(n==2){
			cout<<0<<endl;
			continue;
		}
		for(int i=1;i<=n;i++) ms.insert(e[i].size());
		dfs(1,0);
		cout<<res<<endl;
	}
	return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+5;

int t,n,u,v,res;
vector<int> e[N];
multiset<int> ms;

void dfs(int u,int f){
	if(f!=0) res = max(res,int(e[u].size()+e[f].size())-2);
	ms.erase(ms.find(e[u].size()));
	for(auto v:e[u]){
		//cout<<u<<" "<<ms.size()<<"aaaaaaaaaaa"<<endl;
		ms.erase(ms.find(e[v].size()));
	}
	if(ms.size()>0){
		res = max(res,int(e[u].size()+*ms.rbegin())-1);
	}
	ms.insert(e[u].size());
	for(auto v:e[u]){
		ms.insert(e[v].size());
	}
	for(auto v:e[u]){
		//cout<<"aaaaaaaaaaaaa"<<endl;
		if(v!=f) dfs(v,u);
	}
}

int main(){
	cin>>t;
	while(t--){
		res = 0;
		for(int i=1;i<=n;i++) e[i].clear();
		ms.clear();
		cin>>n;
		for(int i=1;i<=n-1;i++){
			cin>>u>>v;
			e[u].push_back(v);
			e[v].push_back(u);
		}
		if(n==2){
			cout<<0<<endl;
			continue;
		}
		for(int i=1;i<=n;i++) ms.insert(e[i].size());
		dfs(1,0);
		cout<<res<<endl;
	}
	return 0;
}
/*
1
5
1 2
1 3
2 4
3 5
*/
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)


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

int t,n,u,v,res;
vector<int> e[N];
multiset<int> ms;

void dfs(int u,int f){
	if(f!=0) res = max(res,int(e[u].size()+e[f].size())-1);
	ms.erase(e[u].size());
	for(auto v:e[u]){
		ms.erase(e[v].size());
	}
	if(ms.size()>0){
		res = max(res,int(e[u].size()+*ms.rbegin()));
	}
	ms.insert(e[u].size());
	for(auto v:e[u]){
		ms.insert(e[v].size());
	}
	for(auto v:e[u]){
		if(v!=f) dfs(v,u);
	}
}

int main(){
	cin>>t;
	while(t--){
		cin>>n;
		for(int i=1;i<=n-1;i++){
			cin>>u>>v;
			e[u].push_back(v);
			e[v].push_back(u);
		}
		if(n==2){
			cout<<0<<endl;
			continue;
		}
		for(int i=1;i<=n;i++) ms.insert(e[i].size());
		dfs(1,0);
		cout<<res-3<<endl;
		res = 0;
		for(int i=1;i<=n;i++) e[i].clear();
	}
	return 0;
}
Problem: 2050C - Uninteresting Number
Language: Python 3

Previous submission (verdict: Wrong answer on test 1):
def SumOfDigits(number):
    num = list(map(int,str(number)))
    sum = 0
    for z in num:
        sum += z
    return sum
t = int(input())
answer = []
for l in range(t):
    n = int(input())
    number = list(map(int,str(n)))
    currSum = SumOfDigits(n)
    if currSum % 9 == 0:
        answer.append("YES")
    else:
        made = False
        Twos = number.count(2)
        Threes = number.count(3)
        for i in range(0,Twos + 1):
            for h in range(0,Threes + 1):
                if (currSum + 2 * i + 6 * h) % 9 == 0:
                    answer.append("YES")
                    made = True
        if not made:
            answer.append("NO")
print(answer)


Submission (verdict: Wrong answer on test 2):
def SumOfDigits(number):
    num = list(map(int,str(number)))
    sum = 0
    for z in num:
        sum += z
    return sum
t = int(input())
answer = []
for l in range(t):
    n = int(input())
    number = list(map(int,str(n)))
    currSum = SumOfDigits(n)
    if currSum % 9 == 0:
        answer.append("YES")
    else:
        made = False
        Twos = number.count(2)
        Threes = number.count(3)
        for i in range(0,Twos + 1):
            for h in range(0,Threes + 1):
                if (currSum + 2 * i + 6 * h) % 9 == 0:
                    answer.append("YES")
                    made = True
        if not made:
            answer.append("NO")
for h in answer:
    print(h)
Problem: 2050C - Uninteresting Number
Language: Python 3


Submission (verdict: Wrong answer on test 1):
def SumOfDigits(number):
    num = list(map(int,str(number)))
    sum = 0
    for z in num:
        sum += z
    return sum
t = int(input())
answer = []
for l in range(t):
    n = int(input())
    number = list(map(int,str(n)))
    currSum = SumOfDigits(n)
    if currSum % 9 == 0:
        answer.append("YES")
    else:
        made = False
        Twos = number.count(2)
        Threes = number.count(3)
        for i in range(0,Twos + 1):
            for h in range(0,Threes + 1):
                if (currSum + 2 * i + 6 * h) % 9 == 0:
                    answer.append("YES")
                    made = True
        if not made:
            answer.append("NO")
print(answer)
Problem: 2050C - Uninteresting Number
Language: Python 3

Previous submission (verdict: Wrong answer on test 2):
def SumOfDigits(number):
    num = list(map(int,str(number)))
    sum = 0
    for z in num:
        sum += z
    return sum
t = int(input())
answer = []
for l in range(t):
    n = int(input())
    number = list(map(int,str(n)))
    currSum = SumOfDigits(n)
    if currSum % 9 == 0:
        answer.append("YES")
    else:
        made = False
        Twos = number.count(2)
        Threes = number.count(3)
        for i in range(0,Twos + 1):
            for h in range(0,Threes + 1):
                if (currSum + 2 * i + 6 * h) % 9 == 0:
                    answer.append("YES")
                    made = True
        if not made:
            answer.append("NO")
for h in answer:
    print(h)

Submission (verdict: Accepted):
def SumOfDigits(number):
    num = list(map(int,str(number)))
    sum = 0
    for z in num:
        sum += z
    return sum
t = int(input())
answer = []
for l in range(t):
    n = int(input())
    number = list(map(int,str(n)))
    currSum = SumOfDigits(n)
    if currSum % 9 == 0:
        answer.append("YES")
    else:
        made = False
        Twos = number.count(2)
        Threes = number.count(3)
        for i in range(0,Twos + 1):
            for h in range(0,Threes + 1):
                if (currSum + 2 * i + 6 * h) % 9 == 0:
                    answer.append("YES")
                    made = True
                    break
            if made:
                break
        if not made:
            answer.append("NO")
for h in answer:
    print(h)
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


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

#define ll long long

#define ld long double

#define vi vector<int>

#define t(ok) ok?cout<< YES<<endl:cout<<NO<<endl;

#define vll vector<long long>

#define vpll vector <pair<ll,ll>>

#define mll map<long long, long long>

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

#define forn(i,n) for(int i = 0; i < n; i++)

#define mii map<int, int>

#define f(i,a,b) for(ll i = a;i<b;i++)

#define vc vector<char>

#define py cout << "YES" << endl

#define pn cout << "NO" << endl

#define vb vector<bool>

#define invec for (int i=0;i<n;i++) {cin>>v[i];} 

#define print_arr(vec, sz) for(int zwzq = 0; zwzq < sz ; zwzq++){cout << vec[zwzq] << ' ';}cout << endl;

#define fori(i, a, c) for(int i = a ; i < c ; i++)

#define ford(i, n, a) for (int i = n ; i >= a ; i--)

#define print(vec) for(int zwzq = 0; zwzq < vec.size() ; zwzq++){cout << vec[zwzq] << ' ';}cout << endl;

#define print_pair(vec) for(int zwzq = 0; zwzq < vec.size() ; zwzq++){cout << '[' <<vec[zwzq].first << ',' << vec[zwzq].second << ']' << ' ';}cout << endl;

const ll mod = 998244353;

using namespace std;

long long mod_sub(long long a, long long b, long long m){a = a % m; b = b % m;return (((a - b) % m) + m) % m;}

long long powermod(long long x, long long y, long long p){

    long long res = 1;

    x = x % p;

    if (x == 0){return 0;}

    while (y > 0){

        if (y & 1)

            res = (res * x) % p;

        y = y >> 1;

        x = (x * x) % p;

    }

   return res;

}





//for first see soln,for second try reverse or smaller optimal method, BIT question write one or two example in bit then solve

// FIND BRUTE FORCE FIRST 

int main(){



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



    ll t;

    cin >> t;

    while (t--){

ll n,l,r;

    cin  >> n >> l>> r;

    vll v(n);

     for (int i=0;i<n;i++) {cin>>v[i];}

    multiset<int>a,b,c;

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

        a.insert(v[i]);

    }

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

        c.insert(v[i]);

    }

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

        b.insert(v[i]);

    }

    int size = r-l+1;

    auto it = c.begin();

    while (size--){

        a.insert(*it);

        it++;

    }

    auto kt = a.begin();

    int rr = r-l+1;

    while (rr--){

        b.insert(*kt);

        kt++;

    }

    ll a1 =0LL,a2 =0LL;

    int t = r-l+1;

    auto aaa = a.begin();

    auto bbb = b.begin();

    while (t--){

        a1 += *aaa;

        aaa++;

        a2 += *bbb;

        bbb++;

    }

    // cout<<a1<<" "<<a2<<endl;

    cout<<min(a1,a2)<<endl;





    }

    return 0;

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

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=3e5+5,mod=1e9+7,inf=1e18;
int _t,n,c[5]; string s; bool ans;
signed main(){
    ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin>>_t;
	while (_t--){
		cin>>s; n=0; c[2]=c[3]=0; ans=0;
		for (int i=0; i<(int)s.size(); i++){
			if (s[i]=='2') c[2]++;
			else if (s[i]=='3') c[3]++;
			else n+=s[i]-'0';
			n%=9; c[2]%=9; c[3]%=9;
		}
		for (int i=0; i<=c[2]; i++)
			for (int j=0; j<=c[3]; j++){
				if ((n+i*4+(c[2]-i)*2+j*3+(c[3]-j)*9)%9==0) ans=1;
			}
		cout<<(ans?"YES\n":"NO\n");
	}
}

Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=3e5+5,mod=1e9+7,inf=1e18;
int _t,n,c[5]; string s; bool ans;
signed main(){
    ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin>>_t;
	while (_t--){
		cin>>s; n=0; c[2]=c[3]=0; ans=0;
		for (int i=0; i<(int)s.size(); i++){
			if (s[i]=='2') c[2]++;
			else if (s[i]=='3') c[3]++;
			n+=s[i]-'0';
			n%=9; c[2]%=9; c[3]%=9;
		}
		for (int i=0; i<=c[2]; i++)
			for (int j=0; j<=c[3]; j++){
				if ((n+i*2+j*6)%9==0) ans=1;
			}
		cout<<(ans?"YES\n":"NO\n");
	}
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=3e5+5,mod=1e9+7,inf=1e18;
int _t,n,c[5]; string s; bool ans;
signed main(){
    ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin>>_t;
	while (_t--){
		cin>>s; n=0; c[2]=c[3]=0; ans=0;
		for (int i=0; i<(int)s.size(); i++){
			if (s[i]=='2') c[2]++;
			else if (s[i]=='3') c[3]++;
			else n+=s[i]-'0';
			n%=9; c[2]%=9; c[3]%=9;
		}
		for (int i=0; i<=c[2]; i++)
			for (int j=0; j<=c[3]; j++){
				if ((n+i*4+(c[2]-i)*2+j*3+(c[3]-j)*9)%9==0) ans=1;
			}
		cout<<(ans?"YES\n":"NO\n");
	}
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=3e5+5,mod=1e9+7,inf=1e18;
int _t,n,c[5]; string s; bool ans;
signed main(){
    ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin>>_t;
	while (_t--){
		cin>>s; n=0; c[2]=c[3]=0; ans=0;
		for (int i=0; i<(int)s.size(); i++){
			if (s[i]=='2') c[2]++;
			else if (s[i]=='3') c[3]++;
			n+=s[i]-'0';
			n%=9; c[2]%=9; c[3]%=9;
		}
		for (int i=0; i<=c[2]; i++)
			for (int j=0; j<=c[3]; j++){
				if ((n+i*2+j*6)%9==0) ans=1;
			}
		cout<<(ans?"YES\n":"NO\n");
	}
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=3e5+5,mod=1e9+7,inf=1e18;
int _t,n,c[5]; string s; bool ans;
signed main(){
    ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin>>_t;
	while (_t--){
		cin>>s; n=0; c[2]=c[3]=0; ans=0;
		for (int i=0; i<(int)s.size(); i++){
			if (s[i]=='2') c[2]++;
			else if (s[i]=='3') c[3]++;
			n+=s[i]-'0';
		}
		for (int i=0; i<=c[2]; i++)
			for (int j=0; j<=c[3]; j++){
				if ((n+i*2+j*6)%9==0) ans=1;
			}
		cout<<(ans?"YES\n":"NO\n");
	}
}