ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)

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

#include <iostream>

#include <set>

#include <unordered_map>

#include <vector>

#include <algorithm>

#include <string>

#include <map>

#include <cmath>

#include <iomanip>

#include <optional>





using namespace std;



typedef long long int ll;

typedef long double ld;



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

#define IOS                                                                  \

    ios_base::sync_with_stdio(false);                                            \

    cin.tie(0);                                                                  \

    cout.tie(0);cout<<fixed<<setprecision(16);

#define pb push_back

#define mp make_pair





void solve() {



    ll n,x,y;

    cin>>n>>x>>y;



    vector<ll> v(n+1);

    ll counter = x, flip = 0;



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



        if(i == n && i%2 != 0) v[counter] = 2;

        else {

            v[counter] = flip;

            flip = !flip;

        }

        counter = (counter%n) + 1;

    }



    if(v[0] == 0) v[y] = 2;



    for(ll i=1; i<n+1; i++) cout<<v[i]<<" ";

    cout<<endl;



}







int main() {

    IOS

    int t;

    cin >> t;



    while(t--) solve();



    return 0;

}



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

#include <iostream>

#include <set>

#include <unordered_map>

#include <vector>

#include <algorithm>

#include <string>

#include <map>

#include <cmath>

#include <iomanip>

#include <optional>





using namespace std;



typedef long long int ll;

typedef long double ld;



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

#define IOS                                                                  \

    ios_base::sync_with_stdio(false);                                            \

    cin.tie(0);                                                                  \

    cout.tie(0);cout<<fixed<<setprecision(16);

#define pb push_back

#define mp make_pair





void solve() {



    ll n,x,y;

    cin>>n>>x>>y;



    vector<ll> v(n+1);

    ll counter = x, flip = 0;



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



        if(i == n && i%2 != 0) v[counter] = 2;

        else {

            v[counter] = flip;

            flip = !flip;

        }

        counter = (counter%n) + 1;

    }



    if(v[y] == 0) v[y] = 2;



    for(ll i=1; i<n+1; i++) cout<<v[i]<<" ";

    cout<<endl;



}







int main() {

    IOS

    int t;

    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;

#define all(x) (x).begin(), (x).end()
#define repeat(x) for(int taramtam = 0;taramtam<(x);taramtam++)
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
template<typename S, typename T> void semax(S &a, const T &b) {if (a<b) a = b;}
template<typename S, typename T> void semin(S &a, const T &b) {if (a>b) a = b;}

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) { cerr << ' ' << H;dbg_out(T...);}
#define debug(...) cerr << "(" #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)

const int INF = 1e9+100;
const int MOD = 1e9+7;
const int MOD9 = 998244353;
#define int long long
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename S>
void displayvec(vector<S> a){
    for (S thing:a){
        cout << thing << ' ';
    }
    cout << '\n';
}
template <typename S> 
void readvec(vector<S>& a){
    for (S& thing:a){
        cin>>thing;
    }
} 


int re(vector<int>& a,int i, vector<int>& memo){
    
    if (i<0)return 0;
    if (i==0)return (int) a[0]==0;
    if (memo[i]!=-1)return memo[i];
    int res =0;
    if (a[i-1]==a[i]-1)res+=re(a, i-1, memo);
    if (i!=1 && a[i-2] == a[i]-1)res+=re(a, i-2, memo);
    if (i==1 && a[i]==0)res++;
    memo[i]=res%MOD9;
    return res%MOD9;
}

void solve(){
    map<int, int> fra, frb;
    int n, m;cin>>n>>m;
    for(int i = 0;i<n;i++){
        int x;cin>>x;fra[x]++;
    }
    for(int i = 0;i<m;i++){
        int x;cin>>x;
        frb[x]++;
    }
    auto th = fra.begin();
    while (th!=--fra.end()){
        if ((*th).second>frb[(*th).first] && fra[(*th).first+1]>frb[(*th).first+1]){
            int s = (*th).second-frb[(*th).first];
            fra[(*th).first]-=s;
            fra[(*th).first+1]-=s;
            fra[(*th).first*2+1]+=s;
            if (fra[(*th).first+1]<0)break;
        }
        while ((*th).second>frb[(*th).first]){
            fra[(*th).first]-=2;
            fra[2*(*th).first]++;
        }
        th++;
    }
    cout << (fra==frb ? "Yes" : "No") << '\n';
}







signed main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    //freopen("compin.txt", "r", stdin);
	//freopen("compout.txt", "w", stdout);
    int TestCase = 1;
    cin >> TestCase;
    while(TestCase--) solve();
}
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 2):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, l, r) for (int i = l; i <= r; i ++)
#define pb push_back
#define pii pair <int, int >
const int N = 2e5 + 10;
int d[N];
void solve() {
	vector <int > eg[N];
	int n;
	cin >> n;
	rep(i, 1, n) d[i] = 0;
	rep(i, 1, n-1) {
		int u ,v;
		cin >> u >> v;
		eg[u].pb(v);
		eg[v].pb(u);
		d[u]++;
		d[v]++;
	}
	vector <int> a;
	set <pii > s;
	rep(i, 1, n) s.insert({d[i], i});
	int ans = 0;
	rep(u, 1, n) {
		for (auto v : eg[u]) {
			if (v == u) continue;
			s.erase(s.find({d[v], v}));
			s.insert({d[v]-1, v});
		}
		s.erase(s.find({d[u], u}));
		auto [x, y] = *(--s.end());
		ans = max(ans, d[u] + x - 1);
		s.insert({d[u], u});
		for (auto v : eg[u]) {
			if (v == u) continue;
			s.erase(s.find({d[v]-1, v}));
			s.insert({d[v], v});
		}
	} 
	cout << ans << '\n';
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int T;
	cin >> T;
	while (T --) {
		solve();
	} 
}


Submission (verdict: Time limit exceeded on test 2):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, l, r) for (int i = l; i <= r; i ++)
#define pb push_back
#define pii pair <int, int >
const int N = 2e5 + 10;
int d[N];
void solve() {
	vector <int > eg[N];
	int n;
	cin >> n;
	rep(i, 1, n) d[i] = 0;
	rep(i, 1, n-1) {
		int u ,v;
		cin >> u >> v;
		eg[u].pb(v);
		eg[v].pb(u);
		d[u]++;
		d[v]++;
	}
	set <pii > s;
	rep(i, 1, n) s.insert({d[i], i});
	int ans = 0;
	rep(u, 1, n) {
		for (auto v : eg[u]) {
			s.erase(s.find({d[v], v}));
			s.insert({d[v]-1, v});
		}
		s.erase(s.find({d[u], u}));
		auto [x, y] = *(--s.end());
		ans = max(ans, d[u] + x - 1);
		s.insert({d[u], u});
		for (auto v : eg[u]) {
			s.erase(s.find({d[v]-1, v}));
			s.insert({d[v], v});
		}
	} 
	cout << ans << '\n';
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int T;
	cin >> T;
	while (T --) {
		solve();
	} 
}
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 2):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, l, r) for (int i = l; i <= r; i ++)
#define pb push_back
#define pii pair <int, int >
const int N = 2e5 + 10;
int d[N];
void solve() {
	vector <int > eg[N];
	int n;
	cin >> n;
	rep(i, 1, n) d[i] = 0;
	rep(i, 1, n-1) {
		int u ,v;
		cin >> u >> v;
		eg[u].pb(v);
		eg[v].pb(u);
		d[u]++;
		d[v]++;
	}
	set <pii > s;
	rep(i, 1, n) s.insert({d[i], i});
	int ans = 0;
	rep(u, 1, n) {
		for (auto v : eg[u]) {
			s.erase(s.find({d[v], v}));
			s.insert({d[v]-1, v});
		}
		s.erase(s.find({d[u], u}));
		auto [x, y] = *(--s.end());
		ans = max(ans, d[u] + x - 1);
		s.insert({d[u], u});
		for (auto v : eg[u]) {
			s.erase(s.find({d[v]-1, v}));
			s.insert({d[v], v});
		}
	} 
	cout << ans << '\n';
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int T;
	cin >> T;
	while (T --) {
		solve();
	} 
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, l, r) for (int i = l; i <= r; i ++)
#define pb push_back
#define pii pair <int, int >
const int N = 2e5 + 10;
int d[N];
void solve() {
	int n;
	cin >> n;
	vector <int > eg[n+10];
	rep(i, 1, n) d[i] = 0;
	rep(i, 1, n-1) {
		int u ,v;
		cin >> u >> v;
		eg[u].pb(v);
		eg[v].pb(u);
		d[u]++;
		d[v]++;
	}
	set <pii > s;
	rep(i, 1, n) s.insert({d[i], i});
	int ans = 0;
	rep(u, 1, n) {
		for (auto v : eg[u]) {
			s.erase(s.find({d[v], v}));
			s.insert({d[v]-1, v});
		}
		s.erase(s.find({d[u], u}));
		auto [x, y] = *(--s.end());
		ans = max(ans, d[u] + x - 1);
		s.insert({d[u], u});
		for (auto v : eg[u]) {
			s.erase(s.find({d[v]-1, v}));
			s.insert({d[v], v});
		}
	} 
	cout << ans << '\n';
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int T;
	cin >> T;
	while (T --) {
		solve();
	} 
}
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Time limit exceeded on test 2):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, l, r) for (int i = l; i <= r; i ++)
#define pb push_back
#define pii pair <int, int >
const int N = 2e5 + 10;
int d[N];
void solve() {
	vector <int > eg[N];
	int n;
	cin >> n;
	rep(i, 1, n) d[i] = 0;
	rep(i, 1, n-1) {
		int u ,v;
		cin >> u >> v;
		eg[u].pb(v);
		eg[v].pb(u);
		d[u]++;
		d[v]++;
	}
	vector <int> a;
	set <pii > s;
	rep(i, 1, n) s.insert({d[i], i});
	int ans = 0;
	rep(u, 1, n) {
		for (auto v : eg[u]) {
			if (v == u) continue;
			s.erase(s.find({d[v], v}));
			s.insert({d[v]-1, v});
		}
		s.erase(s.find({d[u], u}));
		auto [x, y] = *(--s.end());
		ans = max(ans, d[u] + x - 1);
		s.insert({d[u], u});
		for (auto v : eg[u]) {
			if (v == u) continue;
			s.erase(s.find({d[v]-1, v}));
			s.insert({d[v], v});
		}
	} 
	cout << ans << '\n';
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int T;
	cin >> T;
	while (T --) {
		solve();
	} 
}
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 first x
#define second y

typedef long long ll;
typedef pair<int,int> PII;

const int N=2e4+10,inf=0x3f3f3f3f;

bool cmp(ll a,ll b)
{
	return a>b;
}

void solve()
{
	ll n,l,r;
	cin>>n>>l>>r;
	ll sum1=0,sum2=0,ans=0x3f3f3f3f;
	vector<ll> a,b,c;
	for(ll i=1;i<=n;i++)
	{
		ll t;
		cin>>t;
		if(i>=l&&i<=r) sum1+=t,sum2+=t,a.push_back(t);
		else if(i>r) b.push_back(t);
		else c.push_back(t);
	}

	if(a.size()==n){
		cout<<sum1<<endl;
		return;
	}
	else if(b.size()+c.size()==n){
		cout<<0<<endl;
		return;
	}
	
	sort(a.begin(),a.end(),cmp);
	if(b.size()!=0) sort(b.begin(),b.end());
	if(c.size()!=0) sort(c.begin(),c.end());
	
	ll i1=0,i2=0,i3=0;
	while(i1<a.size()&&i2<b.size())
	{
		if(a[i1]>b[i2]) sum1-=a[i1++],sum1+=b[i2++]; 
		else break; 
	}

	i1=0;
	while(i1<a.size()&&i3<c.size())
	{
		if(a[i1]>c[i3]) sum2-=a[i1++],sum2+=c[i3++];
		else break;
	}
	ans=min(ans,sum1);
	ans=min(sum2,ans);
	cout<<ans<<endl;
}

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

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

using namespace std;



#define first x

#define second y



typedef long long ll;

typedef pair<int,int> PII;



const int N=2e4+10,inf=0x3f3f3f3f;



bool cmp(ll a,ll b)

{

	return a>b;

}



void solve()

{

	ll n,l,r;

	cin>>n>>l>>r;

	ll sum1=0,sum2=0,ans=1e18;

	vector<ll> a,b,c;

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

	{

		ll t;

		cin>>t;

		if(i>=l&&i<=r) sum1+=t,sum2+=t,a.push_back(t);

		else if(i>r) b.push_back(t);

		else c.push_back(t);

	}



	if(a.size()==n){

		cout<<sum1<<endl;

		return;

	}

	else if(b.size()+c.size()==n){

		cout<<0<<endl;

		return;

	}

	

	sort(a.begin(),a.end(),cmp);

	if(b.size()!=0) sort(b.begin(),b.end());

	if(c.size()!=0) sort(c.begin(),c.end());

	

	ll i1=0,i2=0,i3=0;

	while(i1<a.size()&&i2<b.size())

	{

		if(a[i1]>b[i2]) sum1-=a[i1++],sum1+=b[i2++]; 

		else break; 

	}



	i1=0;

	while(i1<a.size()&&i3<c.size())

	{

		if(a[i1]>c[i3]) sum2-=a[i1++],sum2+=c[i3++];

		else break;

	}

	ans=min(ans,sum1);

	ans=min(sum2,ans);

	cout<<ans<<endl;

}



int main()

{

	ios::sync_with_stdio(false);

	cin.tie(0);

	cout.tie(0);

	

	int T=1;

	cin>>T;

	

	while(T--)

	{

		solve();

	}

}
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 first x
#define second y

typedef long long ll;
typedef pair<int,int> PII;

const int N=2e4+10,inf=0x3f3f3f3f;

bool cmp(int a,int b)
{
	return a>b;
}

void solve()
{
	int n,l,r;
	cin>>n>>l>>r;
	int sum1=0,sum2=0,ans=0x3f3f3f3f;
	vector<int> a,b,c;
	for(int i=1;i<=n;i++)
	{
		int t;
		cin>>t;
		if(i>=l&&i<=r) sum1+=t,sum2+=t,a.push_back(t);
		else if(i>r) b.push_back(t);
		else c.push_back(t);
	}

	if(a.size()==n){
		cout<<sum1<<endl;
		return;
	}
	else if(b.size()+c.size()==n){
		cout<<0<<endl;
		return;
	}
	
	sort(a.begin(),a.end(),cmp);
	if(b.size()!=0) sort(b.begin(),b.end());
	if(c.size()!=0) sort(c.begin(),c.end());
	
	int i1=0,i2=0,i3=0;
	while(i1<a.size()&&i2<b.size())
	{
		if(a[i1]>b[i2]) sum1-=a[i1++],sum1+=b[i2++]; 
		else break; 
	}

	i1=0;
	while(i1<a.size()&&i3<c.size())
	{
		if(a[i1]>c[i3]) sum2-=a[i1++],sum2+=c[i3++];
		else break;
	}
	ans=min(ans,sum1);
	ans=min(sum2,ans);
	cout<<ans<<endl;
}

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

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

using namespace std;



#define first x

#define second y



typedef long long ll;

typedef pair<int,int> PII;



const int N=2e4+10,inf=0x3f3f3f3f;



bool cmp(int a,int b)

{

	return a>b;

}



void solve()

{

	int n,l,r;

	cin>>n>>l>>r;

	ll sum1=0,sum2=0,ans=0x3f3f3f3f;

	vector<int> a,b,c;

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

	{

		int t;

		cin>>t;

		if(i>=l&&i<=r) sum1+=t,sum2+=t,a.push_back(t);

		else if(i>r) b.push_back(t);

		else c.push_back(t);

	}



	if(a.size()==n){

		cout<<sum1<<endl;

		return;

	}

	else if(b.size()+c.size()==n){

		cout<<0<<endl;

		return;

	}

	

	sort(a.begin(),a.end(),cmp);

	if(b.size()!=0) sort(b.begin(),b.end());

	if(c.size()!=0) sort(c.begin(),c.end());

	

	int i1=0,i2=0,i3=0;

	while(i1<a.size()&&i2<b.size())

	{

		if(a[i1]>b[i2]) sum1-=a[i1++],sum1+=b[i2++]; 

		else break; 

	}



	i1=0;

	while(i1<a.size()&&i3<c.size())

	{

		if(a[i1]>c[i3]) sum2-=a[i1++],sum2+=c[i3++];

		else break;

	}

	ans=min(ans,sum1);

	ans=min(sum2,ans);

	cout<<ans<<endl;

}



int main()

{

	ios::sync_with_stdio(false);

	cin.tie(0);

	cout.tie(0);

	

	int T=1;

	cin>>T;

	

	while(T--)

	{

		solve();

	}

}
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 first x

#define second y



typedef long long ll;

typedef pair<int,int> PII;



const int N=2e4+10,inf=0x3f3f3f3f;



bool cmp(int a,int b)

{

	return a>b;

}



void solve()

{

	int n,l,r;

	cin>>n>>l>>r;

	ll sum1=0,sum2=0,ans=0x3f3f3f3f;

	vector<int> a,b,c;

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

	{

		int t;

		cin>>t;

		if(i>=l&&i<=r) sum1+=t,sum2+=t,a.push_back(t);

		else if(i>r) b.push_back(t);

		else c.push_back(t);

	}



	if(a.size()==n){

		cout<<sum1<<endl;

		return;

	}

	else if(b.size()+c.size()==n){

		cout<<0<<endl;

		return;

	}

	

	sort(a.begin(),a.end(),cmp);

	if(b.size()!=0) sort(b.begin(),b.end());

	if(c.size()!=0) sort(c.begin(),c.end());

	

	int i1=0,i2=0,i3=0;

	while(i1<a.size()&&i2<b.size())

	{

		if(a[i1]>b[i2]) sum1-=a[i1++],sum1+=b[i2++]; 

		else break; 

	}



	i1=0;

	while(i1<a.size()&&i3<c.size())

	{

		if(a[i1]>c[i3]) sum2-=a[i1++],sum2+=c[i3++];

		else break;

	}

	ans=min(ans,sum1);

	ans=min(sum2,ans);

	cout<<ans<<endl;

}



int main()

{

	ios::sync_with_stdio(false);

	cin.tie(0);

	cout.tie(0);

	

	int T=1;

	cin>>T;

	

	while(T--)

	{

		solve();

	}

}

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

#define first x
#define second y

typedef long long ll;
typedef pair<int,int> PII;

const int N=2e4+10,inf=0x3f3f3f3f;

bool cmp(ll a,ll b)
{
	return a>b;
}

void solve()
{
	ll n,l,r;
	cin>>n>>l>>r;
	ll sum1=0,sum2=0,ans=0x3f3f3f3f;
	vector<ll> a,b,c;
	for(ll i=1;i<=n;i++)
	{
		ll t;
		cin>>t;
		if(i>=l&&i<=r) sum1+=t,sum2+=t,a.push_back(t);
		else if(i>r) b.push_back(t);
		else c.push_back(t);
	}

	if(a.size()==n){
		cout<<sum1<<endl;
		return;
	}
	else if(b.size()+c.size()==n){
		cout<<0<<endl;
		return;
	}
	
	sort(a.begin(),a.end(),cmp);
	if(b.size()!=0) sort(b.begin(),b.end());
	if(c.size()!=0) sort(c.begin(),c.end());
	
	ll i1=0,i2=0,i3=0;
	while(i1<a.size()&&i2<b.size())
	{
		if(a[i1]>b[i2]) sum1-=a[i1++],sum1+=b[i2++]; 
		else break; 
	}

	i1=0;
	while(i1<a.size()&&i3<c.size())
	{
		if(a[i1]>c[i3]) sum2-=a[i1++],sum2+=c[i3++];
		else break;
	}
	ans=min(ans,sum1);
	ans=min(sum2,ans);
	cout<<ans<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	int T=1;
	cin>>T;
	
	while(T--)
	{
		solve();
	}
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


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

#define first x
#define second y

typedef long long ll;
typedef pair<int,int> PII;

const int N=2e4+10,inf=0x3f3f3f3f;

bool cmp(int a,int b)
{
	return a>b;
}

void solve()
{
	int n,l,r;
	cin>>n>>l>>r;
	int sum1=0,sum2=0,ans=0x3f3f3f3f;
	vector<int> a,b,c;
	for(int i=1;i<=n;i++)
	{
		int t;
		cin>>t;
		if(i>=l&&i<=r) sum1+=t,sum2+=t,a.push_back(t);
		else if(i>r) b.push_back(t);
		else c.push_back(t);
	}

	if(a.size()==n){
		cout<<sum1<<endl;
		return;
	}
	else if(b.size()+c.size()==n){
		cout<<0<<endl;
		return;
	}
	
	sort(a.begin(),a.end(),cmp);
	if(b.size()!=0) sort(b.begin(),b.end());
	if(c.size()!=0) sort(c.begin(),c.end());
	
	int i1=0,i2=0,i3=0;
	while(i1<a.size()&&i2<b.size())
	{
		if(a[i1]>b[i2]) sum1-=a[i1++],sum1+=b[i2++]; 
		else break; 
	}

	i1=0;
	while(i1<a.size()&&i3<c.size())
	{
		if(a[i1]>c[i3]) sum2-=a[i1++],sum2+=c[i3++];
		else break;
	}
	ans=min(ans,sum1);
	ans=min(sum2,ans);
	cout<<ans<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	int T=1;
	cin>>T;
	
	while(T--)
	{
		solve();
	}
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)


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

#include <vector>

#include <algorithm>

#include <cstdint>

#include <map>

#include <string>

#include <set>



#ifdef ONLINE_JUDGE

#define default_file(...)

#define dbg(...)

#else

#include "../local/debug.h"

#endif 



void run_program(){

     std::string s;

     std::cin >> s;

     int sum = 0, cnt_two = 0, cnt_three = 0;

     for(auto& c : s)

          sum += int(c - '0'),     

          cnt_two += (c == '2'),

          cnt_three += (c == '3');

     

     int mod = sum % 9; 

     if(mod == 0 || (mod % 2 == 1 && cnt_two >= (9 - mod) / 2)

                 ||  (mod == 3 && cnt_three >= 1) 

                 ||  (mod == 6 && cnt_three >= 2)

                 || ((mod == 4 || mod == 2) && cnt_three >= 1 && cnt_two >= (6 - mod) / 2))

          std::cout << "YES\n";

     else 

          std::cout << "NO\n";

} 

int main() {

     default_file("");

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

     int t; 

     std::cin >> t;

     while(t--)

     run_program();

     return 0;

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

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

#include <vector>

#include <algorithm>

#include <cstdint>

#include <map>

#include <string>

#include <set>



#ifdef ONLINE_JUDGE

#define default_file(...)

#define dbg(...)

#else

#include "../local/debug.h"

#endif 



void run_program(){

     std::string s;

     std::cin >> s;

     int sum = 0, cnt_two = 0, cnt_three = 0;

     for(auto& c : s)

          sum += int(c - '0'),     

          cnt_two += (c == '2'),

          cnt_three += (c == '3');

     

     int mod = sum % 9; 

     if(mod == 0 || (mod % 2 == 1 && cnt_two >= (9 - mod) / 2)

                 ||  (mod == 3 && cnt_three >= 1) 

                 ||  (mod == 6 && cnt_three >= 2)

                 || ((mod == 4 || mod == 2) && cnt_three >= 1 && cnt_two >= (6 - mod) / 2))

          std::cout << "YES\n";

     else 

          std::cout << "NO\n";

} 

int main() {

     default_file("");

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

     int t; 

     std::cin >> t;

     while(t--)

     run_program();

     return 0;

}



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

#include <vector>

#include <algorithm>

#include <cstdint>

#include <map>

#include <string>

#include <set>



#ifdef ONLINE_JUDGE

#define default_file(...)

#define dbg(...)

#else

#include "../local/debug.h"

#endif 



void run_program(){

     std::string s;

     std::cin >> s;

     int sum = 0, cnt_two = 0, cnt_three = 0;

     for(auto& c : s)

          sum += int(c - '0'),     

          cnt_two += (c == '2'),

          cnt_three += (c == '3');

     

     int mod = sum % 9; 

     if(mod == 0 || (mod % 2 == 1 && cnt_two >= (9 - mod) / 2)

                 ||  (mod == 3 && cnt_three >= 1) 

                 ||  (mod == 6 && cnt_three >= 2)

                 || ((mod == 4 || mod == 2) && cnt_three >= 1 && cnt_two >= (6 - mod) / 2)

                 || (mod == 1 && cnt_three >= 2 && cnt_two >= 1))

          std::cout << "YES\n";

     else 

          std::cout << "NO\n";

} 

int main() {

     default_file("");

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

     int t; 

     std::cin >> t;

     while(t--)

     run_program();

     return 0;

}