ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2061D - Kevin and Numbers
Language: c++17 

Code 1:
#include<iostream>
#include<queue>
using namespace std;
int main(){
	int t;
	cin>>t;
	while(t--){
		priority_queue<int> q;
		priority_queue<int> Q;	
		int n,m;
		cin>>n>>m;
		for(int i=0;i<n;i++){
			int a;
			cin>>a;
			q.push(a);	
		}
		for(int i=0;i<m;i++){
			int b;
			cin>>b;
			Q.push(b);
		}
		while(1){
			if(m>n){
				cout<<"No"<<'\n';
				break;
			}
			if(Q.empty() and !q.empty()){
				cout<<"No"<<'\n';
				break;
			}
			if(q.empty() and Q.empty()){
				cout<<"Yes"<<'\n';
				break;
			}
			int a = q.top();
			int b = Q.top();
			cout<<a<<' '<<b<<'\n';
			if(a==b){
				q.pop();
				Q.pop();
				n--;
				m--;
			}
			if(b>a){
				Q.pop();
				Q.push(b/2);
				Q.push(b-b/2);
				m--;
				m+=2;
			}
			if(b<a){
				cout<<"No"<<'\n';
				break;
			}
		}
	}
} 

Code 2:
#include<iostream>
#include<queue>
using namespace std;
int main(){
	int t;
	cin>>t;
	while(t--){
		priority_queue<int> q;
		priority_queue<int> Q;	
		int n,m;
		cin>>n>>m;
		for(int i=0;i<n;i++){
			int a;
			cin>>a;
			q.push(a);	
		}
		for(int i=0;i<m;i++){
			int b;
			cin>>b;
			Q.push(b);
		}
		while(1){
			if(m>n){
				cout<<"No"<<'\n';
				break;
			}
			if(Q.empty() and !q.empty()){
				cout<<"No"<<'\n';
				break;
			}
			if(q.empty() and Q.empty()){
				cout<<"Yes"<<'\n';
				break;
			}
			int a = q.top();
			int b = Q.top();
			//cout<<a<<' '<<b<<'\n';
			if(a==b){
				q.pop();
				Q.pop();
				n--;
				m--;
			}
			if(b>a){
				Q.pop();
				Q.push(b/2);
				Q.push(b-b/2);
				m--;
				m+=2;
			}
			if(b<a){
				cout<<"No"<<'\n';
				break;
			}
		}
	}
} 

Answer: 2
Problem: 2061D - Kevin and Numbers
Language: c++23 

Code 1:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 998244353;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	cin >> t;
	while(t--){
		int n, m;
		cin >> n >> m;
		multiset<ll, greater<ll>> a, b;
		for(int i{0}; i<n; i++){
			ll k;
			cin >> k;
			a.insert(k);
		}
		for(int i{0}; i<m; i++){
			ll k;
			cin >> k;
			b.insert(k);
		}
        int c=0;
        while(!b.empty() && !a.empty()){
            auto eb=*b.begin();
            if(a.find(eb)!=a.end()){
                b.erase(b.begin());
                a.erase(a.find(eb));
            }else{
                if(++c>n-m)
                break;
                b.erase(b.begin());
                b.insert(eb/2);
                b.insert((eb+1)/2);
            }
        }
        if(a.empty() && b.empty())
        cout << "YES\n";
        else
        cout << "NO\n";
	}
}

Code 2:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 998244353;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	cin >> t;
	while(t--){
		int n, m;
		cin >> n >> m;
		multiset<ll> a, b;
		for(int i{0}; i<n; i++){
			ll k;
			cin >> k;
			a.insert(k);
		}
		for(int i{0}; i<m; i++){
			ll k;
			cin >> k;
			b.insert(k);
		}
		int c=0;
		while(!a.empty() && !b.empty()){
			auto it2=a.begin(), it1=a.begin();
			it2++;
			auto bit1=b.find(*it1);
			if(bit1!=b.end()){
				b.erase(bit1);
				a.erase(it1);
			}else if(it2!=a.end()){
				if(*it2-*it1<=1){
					ll el=*it2+*it1;
					a.erase(it1);
					a.erase(it2);
					a.insert(el);
				}else{
					a.erase(it1);
					c++;
				}
			}else{
				a.erase(it1);
				c++;
			}
		}
		if(b.empty() && a.empty() && c==0)
		cout << "YES\n";
		else
		cout << "NO\n";
	}
}

Answer: 1
Problem: 2061D - Kevin and Numbers
Language: c++20 

Code 1:
#include <bits/stdc++.h>
#include <iostream>
#include <set>
#include <map>
#include <vector>
using namespace std;
int tci = 0;

bool rec(int x, multiset<int> &values) {
	int h1 = x / 2, h2 = x - x / 2;
	int c1 = values.count(h1);
	int c2 = values.count(h2);

	// if (tci == 6)
	// 	cout << x << " " << h1 << " " << h2 << " " << c1 << " " << c2 << " " << values.count(x) << "\n";
	if (values.count(x)) {
		values.erase(values.find(x));
		return true;
	} else if (x == 1) {
		return false;
	} else if (c1 && c2) {
		return (h1 == h2 ? c1 >= 2: true) && rec(h1, values) && rec(h2, values);
	} else {
		return rec(h1, values) && rec(h2, values);
	}

	return false;
}

void solve()
{
	int n, m, x;
	cin >> n >> m;
	multiset<int> values;
	for (int i = 0; i < n; i++) {
		cin >> x;
		values.insert(x);
	}

	bool ans = true;
	for (int i = 0; i < m; i++) {
		cin >> x;
		if (!rec(x, values)) {
			ans = false;
		}
	}

	cout << (ans && !values.size() ? "Yes\n": "No\n");
}

int main()
{
	int tc;
	cin >> tc;

	for(tci = 0; tci < tc; tci++) {
		// cout << "Case #" << tci + 1 << ": ";
		solve();
	}

	return 0;
}

Code 2:
#include <bits/stdc++.h>
#include <iostream>
#include <set>
#include <map>
#include <vector>
using namespace std;
int tci = 1;

bool rec(int x, multiset<int> &values) {
	if (values.count(x)) {
		values.erase(values.find(x));
		return true;
	} else if (x == 1) {
		return false;
	} else {
		return rec(x / 2, values) && rec(x - x / 2, values);
	}

	return false;
}

void solve()
{
	int n, m, x;
	cin >> n >> m;
	multiset<int> values;
	for (int i = 0; i < n; i++) {
		cin >> x;
		values.insert(x);
	}

	bool ans = true;
	for (int i = 0; i < m; i++) {
		cin >> x;
		if (!rec(x, values)) {
			ans = false;
		}
	}

	cout << (ans && !values.size() ? "Yes\n": "No\n");
}

int main()
{
	int tc;
	cin >> tc;

	for(tci = 1; tci <= tc; tci++) {
		// cout << "Case #" << tci + 1 << ": ";
		solve();
	}

	return 0;
}

Answer: 2
Problem: 2061D - Kevin and Numbers
Language: c++20 

Code 1:
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,m,a[N],b[N];
map<int,int> mp;
void process() {
    cin>>n>>m;
    mp.clear();
    for (int i=1; i<=n; ++i) { cin>>a[i]; mp[a[i]]++; }
    priority_queue<int> q;
    for (int i=1; i<=m; ++i) { cin>>b[i]; q.push(b[i]); }
    while (m<n && !q.empty()) {
        int u=q.top();
        if (u==1) break;
        q.pop();
        if (mp[u]) mp[u]--;
        else { q.push(u/2); q.push((u+1)/2); ++m; }
    }
    while (!q.empty()) {
        int u=q.top(); q.pop();
        if (mp[u]) mp[u]--;
    }
    for (int i=1; i<=n; ++i) if (mp[a[i]]!=0) { cout<<"No\n"; return; }
    cout<<"Yes\n";
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int t;
    cin>>t;
    while (t--) {
        process();
    }
}


Code 2:
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,m,a[N],b[N];
map<int,int> mp;
void process() {
    cin>>n>>m;
    mp.clear();
    for (int i=1; i<=n; ++i) { cin>>a[i]; mp[a[i]]++; }
    priority_queue<int> q;
    for (int i=1; i<=m; ++i) { cin>>b[i]; q.push(b[i]); }
    while (m<n) {
        int u=q.top();
        if (u==1) break;
        q.pop();
        if (mp[u]) mp[u]--;
        else { q.push(u/2); q.push((u+1)/2); ++m; }
    }
    while (!q.empty()) {
        int u=q.top(); q.pop();
        if (mp[u]) mp[u]--;
    }
    for (int i=1; i<=n; ++i) if (mp[a[i]]!=0) { cout<<"No\n"; return; }
    cout<<"Yes\n";
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int t;
    cin>>t;
    while (t--) {
        process();
    }
}


Answer: 1
Problem: 2061D - Kevin and Numbers
Language: c++17 

Code 1:
#include<iostream>
#include<vector>
#include<algorithm>
void solve(){
	int n,m;
	std::cin>>n>>m;
	std::vector<int> a(n),b(m);
	for(int i=0;i<n;i++){
		int x;
		std::cin>>x;
		a.push_back(x);
	}
	std::sort(a.rbegin(),a.rend());       //sort降序排列，从大到小 
	for(int i=0;i<m;i++){
		int x;
		std::cin>>x;
		b.push_back(x);
	}
	std::sort(b.rbegin(),b.rend());       //sort降序排列，从大到小 
	long long sum=n-m;
	while(sum>=0&&a.size()&&b.size()){
		if(a.front()==b.front()){
			a.pop_back();          //最大值相同 匹配则弹出，继续匹配 
			b.pop_back();
		}else if(sum>0){        //需要操作 
			int t=b.front();
			b.pop_back();
			b.push_back(t/2);
			b.push_back(t-t/2);
			;
		}else{
			break;
		}
	}
	if(a.empty()&&b.empty()){      //都匹配且弹出 
		std::cout<<"YES\n";
	}else{
		std::cout<<"NO\n";
	}
}
int main(){
	int t;
	std::cin>>t;
	while(t--){
		solve();
	} 
	return 0;
}

Code 2:
#include<iostream>
#include<vector>
#include<queue>
void solve() {
    int n, m;
    std::cin >> n >> m;
    std::priority_queue<int> a, b;
    for (int i = 0; i < n; ++ i) {
    	int x;
    	std::cin >> x;
        a.push(x);
    }

    for (int i = 0; i < m; ++ i) {
    	int x;
    	std::cin >> x;
        b.push(x);
    }

    long long sum = n - m;

    while (sum >= 0 && a.size() && b.size()) {
    	if (a.top() == b.top()) {
            a.pop();
            b.pop();
        } else if (sum > 0) {
            int u = b.top(); b.pop();
            b.push(u / 2);
            b.push(u - u / 2);
            -- sum;
        } else {
            break;
        }
    }

    if (a.empty() && b.empty()) {
    	std::cout << "YES\n";
    } else {
    	std::cout << "NO\n";
    }
}
int main(){
	int t;
	std::cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


Answer: 2
Problem: 2061D - Kevin and Numbers
Language: c++20 

Code 1:
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define ld long double
#define pii pair<int,int>
#define M 1000000007
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main() {
    IOS;
    ll t;
    cin>>t;

    while(t--){
	    ll n,m;
		cin>>n>>m;

		map<ll,ll> a;

		for(ll i =0;i<n;i++){
			ll k;
			cin>>k;

			a[k]++;
		}

		map<ll,ll> b;

		for(ll i =0;i<m;i++){
			ll k;
			cin>>k;

			b[k]++;
		}

		ll ct = 0;

		bool k = 0;

		while(b.size() && ct<=n-m){
			auto it = b.rbegin();

			ll x = it->first;
			if(b[x]<a[x]){
				k = 1;
				cout<<"No\n";
				break;
			}
			else if(b[x]>a[x]){
				if(x == 1){
					k = 1;
					cout<<"No\n";
					break;
				}
				b[x]--;
				b[x/2]++;
				b[(x+1)/2]++;
				ct++;
			}
			else{
				b[x] = 0;
				a[x] = 0;
				a.erase(x);
				b.erase(x);
			}
		}

		if(k == 0 && (a.size() || b.size())) cout<<"No\n";
		else if(k == 0) cout<<"Yes\n";


	}
}


Code 2:
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define ld long double
#define pii pair<int,int>
#define M 1000000007
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main() {
    IOS;
    ll t;
    cin>>t;

    while(t--){
	    ll n,m;
		cin>>n>>m;

		map<ll,ll> a;

		for(ll i =0;i<n;i++){
			ll k;
			cin>>k;

			a[k]++;
		}

		map<ll,ll> b;

		for(ll i =0;i<m;i++){
			ll k;
			cin>>k;

			b[k]++;
		}

		ll ct = 0;

		while(b.size() && ct<=n-m){
			auto it = b.rbegin();

			ll x = it->first;
			if(b[x]<a[x]){
				cout<<"No\n";
				break;
			}
			else if(b[x]>a[x]){
				if(x == 1){
					cout<<"No\n";
					break;
				}
				b[x]--;
				b[x/2]++;
				b[(x+1)/2]++;
				ct++;
			}
			else{
				b[x] = 0;
				a[x] = 0;
				a.erase(x);
				b.erase(x);
			}
		}

		if(a.size() || b.size()) cout<<"No\n";
		else cout<<"Yes\n";


	}
}


Answer: 1
Problem: 2061D - Kevin and Numbers
Language: c++23 

Code 1:
// #define ONLINE_JUDGE 1
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long; using pll = pair<ll, ll>;
#define all(a) (a).begin(),(a).end()
#define LL(...) ll __VA_ARGS__; input(__VA_ARGS__)
const ll N = 2e6 + 10;
#ifdef LOCAL
#include <dbg.h>
#else
#define dbg(...) (__VA_ARGS__)
#endif
template<class... T> void input(T &...a) { (cin >> ... >> a); }
template<class T,class U> bool chmax(T &a, const U b) {return a<b?a=b,true:false; }
template<class T,class U> bool chmin(T &a, const U b) {return a>b?a=b,true:false; }
// clang-format on

void solve()
{
    LL(n, m);
    dbg(n, m);
    map<ll, ll> mp;
    for (ll i = 0; i < n; i++)
    {
        LL(x);
        mp[x]++;
    }
    ll cnt = 0;
    priority_queue<ll> qu;
    for (ll i = 0; i < m; i++)
    {
        LL(x);
        qu.push(x);
    }
    while (!qu.empty() && cnt < n)
    {
        if((ll)qu.size() > n-cnt)return void(cout << "No\n");
        ll x = qu.top();
        qu.pop();
        if (mp[x])
        {
            mp[x]--;
            cnt++;
        }
        else
        {
            if(x == 1)return void(cout << "No\n");
            qu.push(x / 2);
            qu.push((x + 1) / 2);
        }
    }
    cout << (cnt == n ? "Yes\n" : "No\n");
}

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

Code 2:
// #define ONLINE_JUDGE 1
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long; using pll = pair<ll, ll>;
#define all(a) (a).begin(),(a).end()
#define LL(...) ll __VA_ARGS__; input(__VA_ARGS__)
const ll N = 2e6 + 10;
#ifdef LOCAL
#include <dbg.h>
#else
#define dbg(...) (__VA_ARGS__)
#endif
template<class... T> void input(T &...a) { (cin >> ... >> a); }
template<class T,class U> bool chmax(T &a, const U b) {return a<b?a=b,true:false; }
template<class T,class U> bool chmin(T &a, const U b) {return a>b?a=b,true:false; }
// clang-format on

void solve()
{
    LL(n, m);
    map<ll, ll> mp;
    for (ll i = 0; i < n; i++)
    {
        LL(x);
        mp[x]++;
    }
    ll cnt = 0;
    function<ll(ll)> dfs = [&](ll x) -> ll
    {
        dbg(x);
        if (mp[x]) return mp[x]--, cnt++, 0;
        if (cnt >= n || x == 1) return 1;
        if (dfs(x / 2)) return 1;
        return dfs((x + 1) / 2);
    };
    for (ll i = 1; i <= m; i++)
    {
        LL(x);
        if (dfs(x)) return cout << "No\n", void();
    }
    cout << (cnt == n ? "Yes\n" : "No\n");
}

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

Answer: 1
Problem: 2061D - Kevin and Numbers
Language: c++17 

Code 1:
#include <iostream>

#include <algorithm>

#include <cstring>

#include <map>

#include <vector>

#include <queue>

using namespace std;

#define int long long

const int MAXN=1000010,inf=0x3f3f3f3f;



int n,m;

int a[MAXN],b[MAXN];

map<int,int>mp;

int check(int x){

	if (mp[x]){

		mp[x]--;

		return 1;

	}

	if (x==0)return 0;

	if (x&1)return check(x/2)&&check((x+1)/2);

	return check(x/2)&&check(x/2);

}

void solve(){

	cin>>n>>m;

	

	int sum=0;

	for (int i=1;i<=n;i++)cin>>a[i],mp[a[i]]++,sum+=a[i];

	for (int i=1;i<=m;i++){

		cin>>b[i];

		sum-=b[i];

	}

	if (sum!=0){

		cout<<"No"<<endl;

		return;

	}

	sort(b+1,b+1+m);

	int flag=1;

	for (int i=1;i<=m;i++){

		if (!check(b[i])){

			flag=0;

			break;

		}

	}

	if (flag){

		cout<<"Yes"<<endl;

	}

	else{

		cout<<"No"<<endl;

	}

}



signed main(){

	ios::sync_with_stdio(0);

	cin.tie(0);

	int t=1;

	cin>>t;

	while(t--)

	{

		solve();

	}

	return 0;

}



Code 2:
#include <iostream>

#include <algorithm>

#include <cstring>

#include <map>

#include <vector>

#include <queue>

using namespace std;

#define int long long

const int MAXN=1000010,inf=0x3f3f3f3f;



int n,m;

int a[MAXN],b[MAXN];

map<int,int>mp;

int check(int x){

	if (mp[x]){

		mp[x]--;

		return 1;

	}

	if (x==0)return 0;

	if (x&1)return check(x/2)&&check(x/2+1);

	return (check(x/2)&&check(x/2));

}

void solve(){

	cin>>n>>m;

	mp.clear();

	int sum=0;

	for (int i=1;i<=n;i++)cin>>a[i],mp[a[i]]++,sum+=a[i];

	for (int i=1;i<=m;i++){

		cin>>b[i];

		sum-=b[i];

	}

	if (sum!=0){

		cout<<"No"<<endl;

		return;

	}

	sort(b+1,b+1+m);

	int flag=1;

	for (int i=1;i<=m;i++){

		if (!check(b[i])){

			flag=0;

			break;

		}

	}

	if (flag){

		cout<<"Yes"<<endl;

	}

	else{

		cout<<"No"<<endl;

	}

}



signed main(){

	ios::sync_with_stdio(0);

	cin.tie(0);

	int t=1;

	cin>>t;

	while(t--)

	{

		solve();

	}

	return 0;

}



Answer: 2
Problem: 2061D - Kevin and Numbers
Language: c++17 

Code 1:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
#define ll long long
#define N 200005
using namespace std;
ll i,j,k,m,n,o,p,l,s,t,sum1,sum2,ans,times,bz;
multiset<ll> f,g;
ll a[N],b[N];
int main()
{
    freopen("a.in","r",stdin);
    freopen("a.out","w",stdout);
    scanf("%lld",&times);
    while (times--)
    {
        scanf("%lld%lld",&n,&m);
        if (n==4&m==2)
        {
            int sdfgwse=0;
        }
        f.clear(),g.clear();
        sum1=sum2=0;
        for (i=1;i<=n;i++) scanf("%lld",&a[i]),sum1+=a[i],f.insert(a[i]);
        for (i=1;i<=m;i++) scanf("%lld",&b[i]),sum2+=b[i],g.insert(b[i]);
        if (sum1!=sum2)
        {
            puts("No");
            continue;
        }
        bz=1;
        while ((!f.empty())||(!g.empty()))
        {
            ll x=*f.rbegin(),y=*g.rbegin();
            auto posx=f.find(x),posy=g.find(y);
            if (x==y) 
            {
                f.erase(posx),g.erase(posy);
            }
            else if (x>y)
            {
                bz=0;puts("No");break;
            } else {
                g.erase(posy);
                g.insert(y/2),g.insert((y+1)/2);
            }
        }
        if (bz) puts("Yes");
        else puts("No");
    }
    return 0;
}

Code 2:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
#define ll long long
#define N 200005
using namespace std;
ll i,j,k,m,n,o,p,l,s,t,sum1,sum2,ans,times,bz;
multiset<ll> f,g;
ll a[N],b[N];
int main()
{
   // freopen("a.in","r",stdin);
 //   freopen("a.out","w",stdout);
    scanf("%lld",&times);
    while (times--)
    {
        scanf("%lld%lld",&n,&m);
        bz=1;
        f.clear(),g.clear();
        sum1=sum2=0;
        for (i=1;i<=n;i++) scanf("%lld",&a[i]),sum1+=a[i],f.insert(a[i]);
        for (i=1;i<=m;i++) scanf("%lld",&b[i]),sum2+=b[i],g.insert(b[i]);
        if (sum1!=sum2)
        {
            puts("No");
            continue;
        }
        while ((!f.empty())||(!g.empty()))
        {
            ll x=*f.rbegin(),y=*g.rbegin();
            auto posx=f.find(x),posy=g.find(y);
            if (x==y) 
            {
                f.erase(posx),g.erase(posy);
            }
            else if (x>y)
            {
                bz=0;break;
            } else {
                g.erase(posy);
                g.insert(y/2),g.insert((y+1)/2);
            }
        }
        if (bz) puts("Yes");
        else puts("No");
    }
    return 0;
}

Answer: 2
Problem: 2061D - Kevin and Numbers
Language: c++17 

Code 1:
#include<bits/stdc++.h>
#define int long long
using namespace std;
map<int,int> ma;
int n,m;
bool cal(int x)
{
if(ma[x]>0)
{
	ma[x]--;
	n--;
	return 1;
}
if(x==1)
	return 0;
return cal(x/2)&&cal(x/2+x%2);
}
void solve()
{

	cin>>n>>m;
	ma.clear();
	for(int i=1;i<=n;i++)
	{
		int temp;cin>>temp;
		ma[temp]++;
	}
	for(int i=1;i<=m;i++)
	{
		int temp;cin>>temp;
		if(cal(temp)==0)
		{
			cout<<"NO\n";
			for(int j=i+1;j<=m;j++)
				cin>>temp;
			return ;
		}
	}
	if(n==0)
	cout<<"YES\n";
else cout<<"NO\n";
	return;
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int T;
	cin>>T;
	while(T--)
	solve();
}

Code 2:
#include<bits/stdc++.h>
#define int long long
using namespace std;
map<int,int> ma;
int n,m;
bool cal(int x)
{
if(ma[x]>0)
{
	ma[x]--;
	n--;
	return 1;
}
if(x==1)
	return 0;
return cal(x/2)&&cal(x/2+x%2);
}
void solve()
{

	cin>>n>>m;
	ma.clear();
	for(int i=1;i<=n;i++)
	{
		int temp;cin>>temp;
		ma[temp]++;
	}
	for(int i=1;i<=m;i++)
	{
		int temp;cin>>temp;
		if(cal(temp)==0)
		{
			cout<<"NO\n";
			return ;
		}
	}
	if(n==0)
	cout<<"YES\n";
else cout<<"NO\n";
	return;
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int T;
	cin>>T;
	while(T--)
	solve();
}

Answer: 1
Problem: 2061D - Kevin and Numbers
Language: c++23 

Code 1:
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define x first
#define y second
using namespace std;
int a[300005],b[300005];
map<int,int>gs;
multiset<pii>s;
int dfs(){
	while(!s.empty()){
		pii o;
		while(s.size()>1){
			auto e=--s.end();
			o=*e;
			e--;
			pii t=*e;
			if(o.x==t.x)
				o.y+=t.y,s.erase(--s.end()),s.erase(--s.end()),s.insert(o);
			else
				break;
		}
		o=*--s.end();
		s.erase(--s.end());
		if(gs[o.x]>=o.y)
			gs[o.x]-=o.y;
		else{
			s.insert({o.x/2,o.y-gs[o.x]});
			s.insert({o.x-o.x/2,o.y-gs[o.x]});
			gs[o.x]=0;
			if(o.x==1)
				break;
		}
	}
	if(s.size()==0)
		return 1;
	else
		return 0;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T;
	cin>>T;
	while(T--){
		s.clear();
		int n,m,sum=0;
		cin>>n>>m;
		for(int i=1;i<=n;i++)
			cin>>a[i],gs[a[i]]++,sum+=a[i];
		for(int i=1;i<=m;i++){
			cin>>b[i];
			sum-=b[i];
			s.insert({b[i],1});
		}
		if(dfs()&&sum==0)
			cout<<"Yes\n";
		else
			cout<<"No\n";
		for(int i=1;i<=n;i++)
			gs[a[i]]=0;
	}
	return 0;
}
/*

*/

Code 2:
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define x first
#define y second
using namespace std;
int a[300005],b[300005];
map<int,int>gs;
multiset<pii>s;
int dfs(){
	while(!s.empty()){
		pii o=*s.begin();
		while(s.size()>1){
			auto e=s.begin();
			o=*e;
			e++;
			pii t=*e;
			if(o.x==t.x)
				o.y+=t.y,s.erase(s.begin()),s.erase(s.begin()),s.insert(o);
			else
				break;
		}
		o=*s.begin();
		s.erase(s.begin());
		if(gs[o.x]>=o.y)
			gs[o.x]-=o.y;
		else{
			if(o.y>gs[o.x])
			s.insert({o.x/2,o.y-gs[o.x]});
			s.insert({o.x-o.x/2,o.y-max(0ll,gs[o.x]-o.y)});
			gs[o.x]=0;
			if(o.x==1)
				break;
			if(o.x==0)
				break;
		}
	}
	if(s.size()==0)
		return 1;
	else
		return 0;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T;
	cin>>T;
	while(T--){
		s.clear();
		int n,m,sum=0;
		cin>>n>>m;
		for(int i=1;i<=n;i++)
			cin>>a[i],gs[a[i]]++,sum+=a[i];
		for(int i=1;i<=m;i++){
			cin>>b[i];
			sum-=b[i];
			s.insert({b[i],1});
		}
		if(dfs()&&sum==0)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
	return 0;
}

Answer: 1