ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
﻿#include<iostream>
#include<vector>
#include<queue>
#include<set>
#include<bitset>
#include<stack>
#include<algorithm>
#include<cmath>
#include<map>
#include<string>
#include<assert.h>
#include <random>
using namespace std;
typedef long long ll;
ll N = 2e5 + 1, mod = 998244353, MOD = 1e9 + 7;
ll solve() {
    ll l, r; std::cin >> l >> r;
    ll a = 0, b = 0, c = 0;
    for (int i = 29; i >= 0; i++) {
        ll t = 1 << i;
        if ((l ^ r) & t) {
            a = t;
            b = t - 1;
            break;
        }
        else {
            a += t;
            b += t;
        }
    }
    c = l;
    while (c == a || c == b) {
        c++;
    }
    cout << a << ' ' << b << ' ' << c << ' ' << endl;
    return 0;
}
int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(0); cout.tie(0);
    int t = 1; cin >> t;
    while (t--) {
        //int t1 = clock();
        ll ans = solve();
        //int t2 = clock();
        //cout << "t:" << t2 - t1 << endl;
        //cout << ans << endl;
    }
    return 0;
}
Problem: 2050B - Transfusion
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Runtime error on test 1):
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t,num;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        int a[2]{};
        for(int i=0;i<n;++i){
            cin>>num;
            a[i&1]+=num;
        }
        if((a[0]+a[1])%n==0&&(a[0]%(n/2))==0&&(a[1]%(n/2-(n%2)))==0&&(a[0]/(n/2))==(a[1]/(n/2-(n%2)))){
            cout<<"yes"<<endl;        
        }else{
            cout<<"no"<<endl;
        }
    }
}
Problem: 2050B - Transfusion
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t,num;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        int a[2]{};
        for(int i=0;i<n;++i){
            cin>>num;
            a[i&1]+=num;
        }
        if((a[0]+a[1])%n==0&&(a[0]%((n+1)/2))==0&&(a[1]%(n/2))==0&&(a[0]/((n+1)/2))==((a[0]+a[1])/n)){
            cout<<"yes"<<endl;        
        }else{
            cout<<"no"<<endl;
        }
    }
}

Submission (verdict: Accepted):

#include<bits/stdc++.h>
using namespace std;
int main(){
    int t,num;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        long long a[2]{};
        for(int i=0;i<n;++i){
            cin>>num;
            a[i&1]+=num;
        }
        if((a[0]+a[1])%n==0&&(a[0]%((n+1)/2))==0&&(a[1]%(n/2))==0&&(a[0]/((n+1)/2))==((a[0]+a[1])/n)){
            cout<<"yes"<<endl;        
        }else{
            cout<<"no"<<endl;
        }
    }
}
Problem: 2050B - Transfusion
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Runtime error on test 1):
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t,num;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        int a[2]{};
        for(int i=0;i<n;++i){
            cin>>num;
            a[i&1]+=num;
        }
        if((a[0]+a[1])%n==0&&(a[0]%(n/2))==0&&(a[1]%(n/2-(n%2)))==0&&(a[0]/(n/2))==(a[1]/(n/2-(n%2)))){
            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,num;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        int a[2]{};
        for(int i=0;i<n;++i){
            cin>>num;
            a[i&1]+=num;
        }
        if((a[0]+a[1])%n==0&&(a[0]%((n+1)/2))==0&&(a[1]%(n/2))==0&&(a[0]/((n+1)/2))==((a[0]+a[1])/n)){
            cout<<"yes"<<endl;        
        }else{
            cout<<"no"<<endl;
        }
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

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

signed main() {
	int t;
	cin >> t;
	while (t--) {
		int x, y;
		cin >> x >> y;
		int i = 35;
		int aa = 0, bb = 0;
		for (; i >= 0; i--) {
			int a = (x >> i) & 1, b = (y >> i) & 1;
			if (a != b)
				break;
			else
				aa += a * (1ll << i), bb += b * (1ll << i);
		}
		aa += (1ll << i) - 1, bb += (1ll << i);
		cout << aa << " " << bb << " " ;
		if (x != aa || bb != y)
			cout << x << endl;
		else
			cout << x + 1 << endl;
	}
	return 0;
}

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

signed main() {
	int t;
	cin >> t;
	while (t--) {
		int x, y;
		cin >> x >> y;
		int i = 35;
		int aa = 0, bb = 0;
		for (; i >= 0; i--) {
			int a = (x >> i) & 1, b = (y >> i) & 1;
			if (a != b)
				break;
			else
				aa += a * (1ll << i), bb += b * (1ll << i);
		}
		aa += (1ll << i) - 1, bb += (1ll << i);
		cout << aa << " " << bb << " " ;
		if (x != aa && bb != y)
			cout << x << endl;
		else
			cout << x + 1 << endl;
	}
	return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

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

signed main() {
	int t;
	cin >> t;
	while (t--) {
		int x, y;
		cin >> x >> y;
		int i = 35;
		int aa = 0, bb = 0;
		for (; i >= 0; i--) {
			int a = (x >> i) & 1, b = (y >> i) & 1;
			if (a != b)
				break;
			else
				aa += a * (1ll << i), bb += b * (1ll << i);
		}
		aa += (1ll << i) - 1, bb += (1ll << i);
		cout << aa << " " << bb << " " ;
		if (x != aa && bb != y)
			cout << x << endl;
		else
			cout << x + 1 << endl;
	}
	return 0;
}

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

signed main() {
	int t;
	cin >> t;
	while (t--) {
		int x, y;
		cin >> x >> y;
		int i = 35;
		int aa = 0, bb = 0;
		for (; i >= 0; i--) {
			int a = (x >> i) & 1, b = (y >> i) & 1;
			if (a != b)
				break;
			else
				aa += a * (1ll << i), bb += b * (1ll << i);
		}
		aa += (1ll << i) - 1, bb += (1ll << i);
		cout << aa << " " << bb << " " ;
		if (aa == x) {
			if (bb == x + 1)
				cout << x + 2;
			else
				cout << x + 1;
		} else
			cout << x;
		cout << endl;
	}
	return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)


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

signed main() {
	int t;
	cin >> t;
	while (t--) {
		int x, y;
		cin >> x >> y;
		int i = 35;
		int aa = 0, bb = 0;
		for (; i >= 0; i--) {
			int a = (x >> i) & 1, b = (y >> i) & 1;
			if (a != b)
				break;
			else
				aa += a * (1ll << i), bb += b * (1ll << i);
		}
		aa += (1ll << i) - 1, bb += (1ll << i);
		cout << aa << " " << bb << " " ;
		if (x != aa || bb != y)
			cout << x << endl;
		else
			cout << x + 1 << 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>
//#pragma GCC optimize("O0")
using namespace std;
#define F first
#define S second
#define int long long
#define pii pair<int,int>
#define endl '\n'
#define pause system("pause")
#define inf 0x3f3f3f3f3f3f3f3f
const int maxn = 2e6+10;
const int mod = 1e9+7;
int arr[maxn];
int d[maxn];
int n,m,k,x,y,z,N=1;
char c;string s;

vector<int>vec[maxn];
vector<pii>ans;

bool cmp1(pii a,pii b){
    return a.F>b.F;
}
bool cmp2(pii a,pii b){
    return a.S<b.S;
}

void work(){
    cin>>n;
    ans.clear();
    for(int i=1;i<=n;i++)vec[i].clear(),d[i]=0;
    for(int i=1;i<n;i++){
        cin>>x>>y;
        vec[x].push_back(y),vec[y].push_back(x);
        d[x]++;d[y]++;
    }
    for(int i=1;i<=n;i++){
        ans.push_back({d[i],i});
    }
    int res=1;
    sort(ans.begin(),ans.end(),cmp1);
    res=ans[0].F;
    x=ans[0].S;
    ans[0].F=-inf;
    sort(ans.begin(),ans.end(),cmp2);
    for(auto xx : vec[x]){
        ans[xx-1].F--;
    }
    sort(ans.begin(),ans.end(),cmp1);
    res+=ans[0].F-1;
    cout<<res<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    cin>>N;
    while (N--) {
        work();
    }
}

Submission (verdict: Time limit exceeded on test 3):
#include<bits/stdc++.h>
//#pragma GCC optimize("O0")
using namespace std;
#define F first
#define S second
#define int long long
#define pii pair<int,int>
#define endl '\n'
#define pause system("pause")
#define inf 0x3f3f3f3f3f3f3f3f
const int maxn = 2e6+10;
const int mod = 1e9+7;
int arr[maxn];
int d[maxn];
int n,m,k,x,y,z,N=1;
char c;string s;

vector<int>vec[maxn];
vector<pii>ans;

bool cmp1(pii a,pii b){
    return a.F>b.F;
}
bool cmp2(pii a,pii b){
    return a.S<b.S;
}

void work(){
    cin>>n;
    ans.clear();
    for(int i=1;i<=n;i++)vec[i].clear(),d[i]=0;
    for(int i=1;i<n;i++){
        cin>>x>>y;
        vec[x].push_back(y),vec[y].push_back(x);
        d[x]++;d[y]++;
    }
    for(int i=1;i<=n;i++){
        ans.push_back({d[i],i});
    }
    int res=0;
    for(int i=1;i<=n;i++){
        int tem=ans[i-1].F;y=ans[i-1].F;ans[i-1].F=-1;
        for(auto xx : vec[i]){
            ans[xx-1].F--;
        }
        sort(ans.begin(),ans.end(),cmp1);
        tem+=ans[0].F-1;
        res=max(res,tem);
        sort(ans.begin(),ans.end(),cmp2);
        for(auto xx : vec[i]){
            ans[xx-1].F++;
        }
        ans[i-1].F=y;
    }
    cout<<res<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    cin>>N;
    while (N--) {
        work();
    }
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
//#pragma GCC optimize("O0")
using namespace std;
#define F first
#define S second
#define int long long
#define pii pair<int,int>
#define endl '\n'
#define pause system("pause")
#define inf 0x3f3f3f3f3f3f3f3f
const int maxn = 2e6+10;
const int mod = 1e9+7;
int arr[maxn];
int d[maxn];
int n,m,k,x,y,z,N=1;
char c;string s;

vector<int>vec[maxn];
vector<pii>ans;

bool cmp1(pii a,pii b){
    return a.F>b.F;
}
bool cmp2(pii a,pii b){
    return a.S<b.S;
}

void work(){
    cin>>n;
    ans.clear();
    for(int i=1;i<=n;i++)vec[i].clear(),d[i]=0;
    for(int i=1;i<n;i++){
        cin>>x>>y;
        vec[x].push_back(y),vec[y].push_back(x);
        d[x]++;d[y]++;
    }
    for(int i=1;i<=n;i++){
        ans.push_back({d[i],i});
    }
    int res=1;
    sort(ans.begin(),ans.end(),cmp1);
    res=ans[0].F;
    x=ans[0].S;
    ans[0].F=-inf;
    sort(ans.begin(),ans.end(),cmp2);
    for(auto xx : vec[x]){
        ans[xx-1].F--;
    }
    sort(ans.begin(),ans.end(),cmp1);
    res+=ans[0].F-1;
    cout<<res<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    cin>>N;
    while (N--) {
        work();
    }
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 3):
#include<bits/stdc++.h>
//#pragma GCC optimize("O0")
using namespace std;
#define F first
#define S second
#define int long long
#define pii pair<int,int>
#define endl '\n'
#define pause system("pause")
#define inf 0x3f3f3f3f3f3f3f3f
const int maxn = 2e6+10;
const int mod = 1e9+7;
int arr[maxn];
int d[maxn];
int n,m,k,x,y,z,N=1;
char c;string s;

vector<int>vec[maxn];
vector<pii>ans;

bool cmp1(pii a,pii b){
    return a.F>b.F;
}
bool cmp2(pii a,pii b){
    return a.S<b.S;
}

void work(){
    cin>>n;
    ans.clear();
    for(int i=1;i<=n;i++)vec[i].clear(),d[i]=0;
    for(int i=1;i<n;i++){
        cin>>x>>y;
        vec[x].push_back(y),vec[y].push_back(x);
        d[x]++;d[y]++;
    }
    for(int i=1;i<=n;i++){
        ans.push_back({d[i],i});
    }
    int res=0;
    for(int i=1;i<=n;i++){
        int tem=ans[i-1].F;y=ans[i-1].F;ans[i-1].F=-1;
        for(auto xx : vec[i]){
            ans[xx-1].F--;
        }
        sort(ans.begin(),ans.end(),cmp1);
        tem+=ans[0].F-1;
        res=max(res,tem);
        sort(ans.begin(),ans.end(),cmp2);
        for(auto xx : vec[i]){
            ans[xx-1].F++;
        }
        ans[i-1].F=y;
    }
    cout<<res<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    cin>>N;
    while (N--) {
        work();
    }
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
//#pragma GCC optimize("O0")
using namespace std;
#define F first
#define S second
#define int long long
#define pii pair<int,int>
#define endl '\n'
#define pause system("pause")
#define inf 0x3f3f3f3f3f3f3f3f
const int maxn = 2e6+10;
const int mod = 1e9+7;
int arr[maxn];
int d[maxn];
int n,m,k,x,y,z,N=1;
char c;string s;

vector<int>vec[maxn];

void work(){
    cin>>n;
    for(int i=1;i<=n;i++)vec[i].clear(),d[i]=0,arr[i]=0;
    for(int i=1;i<n;i++){
        cin>>x>>y;
        vec[x].push_back(y),vec[y].push_back(x);
        d[x]++;d[y]++;
    }
    int x1=0,y1=0;
    for(int i=1;i<=n;i++){
        if(d[i]>=x1){
            y1=x1;x1=d[i];
        }else if(d[i]>y1)y1=d[i];
        arr[d[i]]++;
    }
    // cout<<x1<<' '<<y1<<endl;
    int res=0;
    // cout<<arr[1]<<endl;
    for(int i=1;i<=n;i++){
        int tem=d[i];
        arr[d[i]]--;
        for(auto xx : vec[i]){
            arr[d[xx]]--;
        }
        // cout<<arr[1]<<endl;
        if(arr[y1]==0)tem+=y1-2;
        else tem+=y1-1;
        res=max(res,tem);
        arr[d[i]]++;
        for(auto xx : vec[i]){
            arr[d[xx]]++;
        }
    }
    cout<<res<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    cin>>N;
    while (N--) {
        work();
    }
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
priority_queue <int> a;
priority_queue <int> b;
int main(){
	int t,n,m;
	scanf("%d",&t);
	for(int tt=0;tt<t;tt++){
		scanf("%d %d",&n,&m);
		long long suma=0,sumb=0;
		while(!a.empty())a.pop();
		while(!b.empty())b.pop();
		for(int i=0;i<n;i++){
			int tmp;
			scanf("%d",&tmp);
			a.push(tmp);suma+=tmp;
		}
		for(int i=0;i<m;i++){
			int tmp;
			scanf("%d",&tmp);
			b.push(tmp);sumb+=tmp;
		}
		if(suma!=sumb){
			printf("No\n");
			continue;
		}
		int flag=1;
		while(!a.empty()){
			if(n<m){
				printf("No\n");
				flag=0;
				break;
			}
			int aa=a.top(),bb=b.top();
			//cout<<"aa:"<<aa<<" bb:"<<bb<<endl;
			if(aa>bb){
				printf("No\n");
				flag=0;
				break;
			}
			if(aa==bb){
				a.pop();b.pop();
				n--;m--;
				break;
			}
			int x=bb/2,y=bb/2;
			if(bb%2==1)x++;
			b.pop();
			m--;
			b.push(x);
			b.push(y);
			m+=2;
		}
		if(flag)printf("Yes\n");
	}
	return 0;
}


Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
priority_queue <int> a;
priority_queue <int> b;
int main(){
	int t,n,m;
	scanf("%d",&t);
	for(int tt=0;tt<t;tt++){
		scanf("%d %d",&n,&m);
		long long suma=0,sumb=0;
		while(!a.empty())a.pop();
		while(!b.empty())b.pop();
		for(int i=0;i<n;i++){
			int tmp;
			scanf("%d",&tmp);
			a.push(tmp);suma+=tmp;
		}
		for(int i=0;i<m;i++){
			int tmp;
			scanf("%d",&tmp);
			b.push(tmp);sumb+=tmp;
		}
		if(suma!=sumb){
			printf("No\n");
			continue;
		}
		int flag=1;
		while(!a.empty()){
			if(n<m){
				printf("No\n");
				flag=0;
				break;
			}
			int aa=a.top(),bb=b.top();
			//cout<<"aa:"<<aa<<" bb:"<<bb<<endl;
			if(aa>bb){
				printf("No\n");
				flag=0;
				break;
			}
			if(aa==bb){
				a.pop();b.pop();
				n--;m--;
				continue;
			}
			int x=bb/2,y=bb-x;
			b.pop();
			m--;
			b.push(x);
			b.push(y);
			m+=2;
		}
		if(flag)printf("Yes\n");
	}
	return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
priority_queue <int> a;
priority_queue <int> b;
int main(){
	int t,n,m;
	scanf("%d",&t);
	for(int tt=0;tt<t;tt++){
		scanf("%d %d",&n,&m);
		long long suma=0,sumb=0;
		while(!a.empty())a.pop();
		while(!b.empty())b.pop();
		for(int i=0;i<n;i++){
			int tmp;
			scanf("%d",&tmp);
			a.push(tmp);suma+=tmp;
		}
		for(int i=0;i<m;i++){
			int tmp;
			scanf("%d",&tmp);
			b.push(tmp);sumb+=tmp;
		}
		if(suma!=sumb){
			printf("No\n");
			continue;
		}
		int flag=1;
		while(!a.empty()){
			if(n<m){
				printf("No\n");
				flag=0;
				break;
			}
			int aa=a.top(),bb=b.top();
			//cout<<"aa:"<<aa<<" bb:"<<bb<<endl;
			if(aa>bb){
				printf("No\n");
				flag=0;
				break;
			}
			if(aa==bb){
				a.pop();b.pop();
				n--;m--;
				break;
			}
			int x=bb/2,y=bb/2;
			if(bb%2==1)x++;
			b.pop();
			m--;
			b.push(x);
			b.push(y);
		}
		if(flag)printf("Yes\n");
	}
	return 0;
}


Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
priority_queue <int> a;
priority_queue <int> b;
int main(){
	int t,n,m;
	scanf("%d",&t);
	for(int tt=0;tt<t;tt++){
		scanf("%d %d",&n,&m);
		long long suma=0,sumb=0;
		while(!a.empty())a.pop();
		while(!b.empty())b.pop();
		for(int i=0;i<n;i++){
			int tmp;
			scanf("%d",&tmp);
			a.push(tmp);suma+=tmp;
		}
		for(int i=0;i<m;i++){
			int tmp;
			scanf("%d",&tmp);
			b.push(tmp);sumb+=tmp;
		}
		if(suma!=sumb){
			printf("No\n");
			continue;
		}
		int flag=1;
		while(!a.empty()){
			if(n<m){
				printf("No\n");
				flag=0;
				break;
			}
			int aa=a.top(),bb=b.top();
			//cout<<"aa:"<<aa<<" bb:"<<bb<<endl;
			if(aa>bb){
				printf("No\n");
				flag=0;
				break;
			}
			if(aa==bb){
				a.pop();b.pop();
				n--;m--;
				break;
			}
			int x=bb/2,y=bb/2;
			if(bb%2==1)x++;
			b.pop();
			m--;
			b.push(x);
			b.push(y);
			m+=2;
		}
		if(flag)printf("Yes\n");
	}
	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;
priority_queue <int> a;
priority_queue <int> b;
int main(){
	int t,n,m;
	scanf("%d",&t);
	for(int tt=0;tt<t;tt++){
		scanf("%d %d",&n,&m);
		long long suma=0,sumb=0;
		while(!a.empty())a.pop();
		while(!b.empty())b.pop();
		for(int i=0;i<n;i++){
			int tmp;
			scanf("%d",&tmp);
			a.push(tmp);suma+=tmp;
		}
		for(int i=0;i<m;i++){
			int tmp;
			scanf("%d",&tmp);
			b.push(tmp);sumb+=tmp;
		}
		if(suma!=sumb){
			printf("No\n");
			continue;
		}
		int flag=1;
		while(!a.empty()){
			int aa=a.top(),bb=b.top();
			//cout<<"aa:"<<aa<<" bb:"<<bb<<endl;
			if(aa>bb){
				printf("No\n");
				flag=0;
				break;
			}
			if(aa==bb){
				a.pop();b.pop();
				break;
			}
			int x=bb/2,y=bb/2;
			if(bb%2==1)x++;
			b.pop();
			b.push(x);
			b.push(y);
		}
		if(flag)printf("Yes\n");
	}
	return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
priority_queue <int> a;
priority_queue <int> b;
int main(){
	int t,n,m;
	scanf("%d",&t);
	for(int tt=0;tt<t;tt++){
		scanf("%d %d",&n,&m);
		long long suma=0,sumb=0;
		while(!a.empty())a.pop();
		while(!b.empty())b.pop();
		for(int i=0;i<n;i++){
			int tmp;
			scanf("%d",&tmp);
			a.push(tmp);suma+=tmp;
		}
		for(int i=0;i<m;i++){
			int tmp;
			scanf("%d",&tmp);
			b.push(tmp);sumb+=tmp;
		}
		if(suma!=sumb){
			printf("No\n");
			continue;
		}
		int flag=1;
		while(!a.empty()){
			int aa=a.top(),bb=b.top();
			//cout<<"aa:"<<aa<<" bb:"<<bb<<endl;
			if(aa>bb){
				printf("No\n");
				flag=0;
				break;
			}
			if(aa==bb){
				a.pop();b.pop();
				break;
			}
			int x=bb/2,y=bb/2;
			if(bb%2==1)x++;
			b.pop();
			b.push(x);
			b.push(y);
		}
		if(flag)printf("Yes\n");
	}
	return 0;
}


Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
priority_queue <int> a;
priority_queue <int> b;
int main(){
	int t,n,m;
	scanf("%d",&t);
	for(int tt=0;tt<t;tt++){
		scanf("%d %d",&n,&m);
		long long suma=0,sumb=0;
		while(!a.empty())a.pop();
		while(!b.empty())b.pop();
		for(int i=0;i<n;i++){
			int tmp;
			scanf("%d",&tmp);
			a.push(tmp);suma+=tmp;
		}
		for(int i=0;i<m;i++){
			int tmp;
			scanf("%d",&tmp);
			b.push(tmp);sumb+=tmp;
		}
		if(suma!=sumb){
			printf("No\n");
			continue;
		}
		int flag=1;
		while(!a.empty()){
			if(n<m){
				printf("No\n");
				flag=0;
				break;
			}
			int aa=a.top(),bb=b.top();
			//cout<<"aa:"<<aa<<" bb:"<<bb<<endl;
			if(aa>bb){
				printf("No\n");
				flag=0;
				break;
			}
			if(aa==bb){
				a.pop();b.pop();
				n--;m--;
				break;
			}
			int x=bb/2,y=bb/2;
			if(bb%2==1)x++;
			b.pop();
			m--;
			b.push(x);
			b.push(y);
		}
		if(flag)printf("Yes\n");
	}
	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;
#define MAX 200005
struct node{
	int neicnt,id;
	vector <int> neis;
	bool operator < (const node &a) const{
		if(neicnt>a.neicnt)return 1;
		else return 0;
	}
};
node nodes[MAX];
node empt;
int main(){
	int t;
	scanf("%d",&t);
	for(int tt=0;tt<t;tt++){
		int n;
		scanf("%d",&n);
		for(int i=1;i<=n;i++){
			nodes[i]=empt;
			nodes[i].id=i;
		}
		for(int i=1;i<n;i++){
			int a,b;
			scanf("%d %d",&a,&b);
			nodes[a].neicnt++;
			nodes[a].neis.push_back(b);
			nodes[b].neicnt++;
			nodes[b].neis.push_back(a);
		}
		sort(nodes+1,nodes+n+1);
		int a=nodes[1].neicnt,b=nodes[2].neicnt,c=nodes[3].neicnt;
		int flag=0;
		for(int i=0;i<nodes[1].neicnt;i++){
			if(nodes[1].neis[i]==nodes[2].id){
				flag=1;break;
			}
		}
		int ans=a+b-1;
		if(flag){
			ans--;
			if(a==b&&b==c)ans++;
		}
		printf("%d\n",ans);
	}
	return 0;
}


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define MAX 200005
struct node{
	int neicnt,id;
	vector <int> neis;
	bool operator < (const node &a) const{
		if(neicnt>a.neicnt)return 1;
		else return 0;
	}
};
node nodes[MAX];
node empt;
int senodes[MAX],neinodes[MAX];
int main(){
	int t;
	scanf("%d",&t);
	for(int tt=0;tt<t;tt++){
		int n;
		scanf("%d",&n);
		for(int i=1;i<=n;i++){
			nodes[i]=empt;
			nodes[i].id=i;
		}
		for(int i=1;i<n;i++){
			int a,b;
			scanf("%d %d",&a,&b);
			nodes[a].neicnt++;
			nodes[a].neis.push_back(b);
			nodes[b].neicnt++;
			nodes[b].neis.push_back(a);
		}
		/*cout<<"nodes:"<<endl;
		for(int i=1;i<=n;i++){
			cout<<"node id:"<<nodes[i].id<<" ";
			cout<<"neicnt:"<<nodes[i].neicnt<<endl;
			cout<<"neis:";
			for(int j=0;j<nodes[i].neicnt;j++){
				cout<<nodes[i].neis[j]<<" ";
			}cout<<endl;
		}*/
		sort(nodes+1,nodes+n+1);
		/*cout<<"nodes:"<<endl;
		for(int i=1;i<=n;i++){
			cout<<"node id:"<<nodes[i].id<<" ";
			cout<<"neicnt:"<<nodes[i].neicnt<<endl;
			cout<<"neis:";
			for(int j=0;j<nodes[i].neicnt;j++){
				cout<<nodes[i].neis[j]<<" ";
			}cout<<endl;
		}*/
		int a=nodes[1].neicnt,b=nodes[2].neicnt,c=nodes[3].neicnt;
		//cout<<"flag:"<<flag<<endl;
		int ans=a+b-1;
		if(a==b&&b==c){
			ans=a+b-1;
		}else if(a==b&&b!=c){
			ans--;
		}else if(a!=b){
			int now=2,cnt=0;
			while(nodes[now].neicnt==b){
				senodes[cnt++]=nodes[now].id;
				now++;
			}
			sort(senodes,senodes+cnt);
			//cout<<"cnt:"<<cnt<<endl;
			int ncnt=nodes[1].neicnt;
			for(int i=0;i<ncnt;i++){
				neinodes[i]=nodes[1].neis[i];
			}
			sort(neinodes,neinodes+ncnt);
			int flag=1,flag2=1;
			now=0;
			for(int i=0;i<cnt;i++){
				flag=1;
				for(int j=now;j<ncnt;j++){
					if(senodes[i]==neinodes[j]){
						flag=0;break;
					}
				}
				if(flag){
					flag2=0;break;
				}
			}
			if(flag2==0){
				ans=a+b-1;
			}else{
				ans=a+b-2;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}
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;
#define MAX 200005
struct node{
	int neicnt,id;
	vector <int> neis;
	bool operator < (const node &a) const{
		if(neicnt>a.neicnt)return 1;
		else return 0;
	}
};
node nodes[MAX];
node empt;
int main(){
	int t;
	scanf("%d",&t);
	for(int tt=0;tt<t;tt++){
		int n;
		scanf("%d",&n);
		for(int i=1;i<=n;i++){
			nodes[i]=empt;
			nodes[i].id=i;
		}
		for(int i=1;i<n;i++){
			int a,b;
			scanf("%d %d",&a,&b);
			nodes[a].neicnt++;
			nodes[a].neis.push_back(b);
			nodes[b].neicnt++;
			nodes[b].neis.push_back(a);
		}
		sort(nodes+1,nodes+n+1);
		int a=nodes[1].neicnt,b=nodes[2].neicnt,c=nodes[3].neicnt;
		int flag=0;
		for(int i=0;i<nodes[1].neicnt;i++){
			if(nodes[1].neis[i]==nodes[2].id){
				flag=1;break;
			}
		}
		int ans=a+b-1;
		if(flag){
			ans--;
			if(a==b&&b==c)ans++;
		}
		printf("%d\n",ans);
	}
	return 0;
}