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

Code 1:
#include<bits/stdc++.h>
using namespace std;
using i64 = long long;
using i128 = __int128;

int n,m;
void solve(){
    cin>>n>>m;
    vector<int> a(n),b(m);
    multiset<int> se1,se2;
    for(auto &i:a) cin>>i,se1.insert(i);
    for(auto &i:b) cin>>i,se2.insert(i);
        //int now = 0;
    while(!se2.empty()&&se2.size()<se1.size()){
        //cout<<now<<"\n";
        multiset<int> tmp;
        for(auto i:se2){
            if(se1.find(i)==se1.end()){
                if(i/2<=0) continue;
                tmp.insert(i/2);
                tmp.insert((i+1)/2);
            }else se1.erase(se1.find(i));
        }
        se2.swap(tmp);
    }
    if(se1.size()==se2.size()){
        for(auto i:se2){
            if(se1.find(i)==se1.end()){
                cout<<"No\n";
                return;
            }
        }
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
}

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




Code 2:
#include<bits/stdc++.h>
using namespace std;
using i64 = long long;
using i128 = __int128;

int n,m;
void solve(){
    cin>>n>>m;
    vector<int> a(n),b(m);
    priority_queue<int> q;
    i64 sa=0,sb=0;
    for(auto &i:a) cin>>i,sa+=i;
    for(auto &i:b) cin>>i,sb+=i;
    if(sa!=sb){
        cout<<"No\n";
        return;
    }
    for(auto i:b) q.push(i);
    sort(a.begin(),a.end(),greater<int>());
    int idx = 0;
    //cout<<"check 1\n";
    while(!q.empty()){
       // cout<<idx<<"\n";
        if(q.top()<a[idx]){
            cout<<"No\n";
            return;
        }else if(q.top()==a[idx]){
            idx++;
            q.pop();
        }else{
            int x = q.top();
            q.pop();
            q.push(x/2);
            q.push((x+1)/2);
        }
    }
    cout<<"Yes\n";
}

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






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

Code 1:
#include<bits/stdc++.h>



using namespace std;

typedef long long ll;

typedef long double ld;

#define pb push_back

#define dbg(x) //cerr<<#x<<": "<<x<<"\n";



void code(){

    int n,m;

    cin>>n>>m;

    ll a[n], b[m];

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

        cin>>a[i];

    }

    multiset<ll>ms;

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

        cin>>b[i];

        ms.insert(b[i]);

    }

    sort(a,a+n);

    sort(b,b+m);

    ll sum=0;

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

        sum+=a[i];

        if(ms.count(sum)){

            ms.erase(ms.find(sum));

            sum=0;

        }

        else if(i<n && a[i+1]-sum>1){

            cout<<"No\n";

            return;

        }

    }

    if(ms.empty()){

        cout<<"Yes\n";

    }

    else{

        cout<<"No\n";

    }

}

int main(){

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    //cout.tie(NULL);

    cout.precision(10);

    cout<<fixed;

    int t=1;

    cin>>t;

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

        dbg("case"+to_string(i));

        //cout<<"Case "<<i<<":\n";

        code();

    }

}



Code 2:
#include<bits/stdc++.h>



using namespace std;

typedef long long ll;

typedef long double ld;

#define pb push_back

#define dbg(x) //cerr<<#x<<": "<<x<<"\n";

map<ll,int>mp;

bool ok(ll x){

    if(mp.count(x) && mp[x]>0){

        mp[x]--;

        return true;

    }

    if(x==1){

        return false;

    }

    if(ok(x/2)&&ok((x+1)/2)){

        return true;

    }

    return false;

}

void code(){

    mp.clear();

    int n,m;

    cin>>n>>m;

    ll a[n],b[m];

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

        cin>>a[i];

        mp[a[i]]++;

    }

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

        cin>>b[i];

    }

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

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

            cout<<"No\n";

            mp.clear();

            return;

        }

    }

    for(auto it:mp){

        if(it.second>0){

            cout<<"No\n";

            mp.clear();

            return;

        }

    }

    cout<<"Yes\n";

    mp.clear();

}

int main(){

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    //cout.tie(NULL);

    cout.precision(10);

    cout<<fixed;

    int t=1;

    cin>>t;

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

        dbg("case"+to_string(i));

        //cout<<"Case "<<i<<":\n";

        code();

    }

}



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

Code 1:
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	long long t,n,m,i,x;
	cin>>t;
	while(t--){
		cin>>n>>m;
		multiset<long long> a;
		stack<long long> b;
		for(i=0;i<n;i++){
			cin>>x;
			a.insert(x);
		}
		for(i=0;i<m;i++){
			cin>>x;
			b.push(x);
		}
		while(!b.empty()){
			x=b.top();
			b.pop();
			if(a.find(x)!=a.end())
				a.erase(a.find(x));
			else if(x==1){
				b.push(x);
				break;
			}
			else{
				b.push(x/2);
				b.push((x+1)/2);
			}
		}
		cout<<(b.empty()&&a.empty()?"Yes\n":"No\n");
	}
	return 0;
}


Code 2:
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	long long t,n,m,i,x,y;
	cin>>t;
	while(t--){
		cin>>n>>m;
		priority_queue<long long,vector<long long>,greater<long long>> a;
		vector<long long> b;
		for(i=0;i<n;i++){
			cin>>x;
			a.push(x);
		}
		for(i=0;i<m;i++){
			cin>>x;
			b.push_back(x);
		}
		sort(b.begin(),b.end());
		i=0;
		while(!a.empty()){
			x=a.top();
			a.pop();
			if(i>=m)
				break;
			else if(x==b[i])
				i++;
			else{
				if(a.empty())
					break;
				else{
					y=a.top();
					a.pop();
					if(y-x>1)
						break;
					else
						a.push(x+y);
				}
			}
		}
		if(i==m&&a.empty())
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
	return 0;
}


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

Code 1:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e5+10;
const ll INF=1e17+10;
const ll MOD=1e9+7;
ll n,m;
ll a[N],b[N];

void solve(void){
	cin>>n>>m;
	multiset<ll,greater<ll>>st1,st2;
	ll sum1=0,sum2=0;
	for(ll i=1;i<=n;++i){
		cin>>a[i];
		sum1+=a[i];
		st2.insert(a[i]);
	}
	for(ll i=1;i<=m;++i){
		cin>>b[i];
		sum2+=b[i];
		if(st2.count(b[i])){
			st2.erase(st2.find(b[i]));
		}
		else st1.insert(b[i]);
	}
	if(sum1!=sum2){
		cout<<"No\n";
		return;
	}
	ll f=1;
	while(st2.size()&&st1.size()&&st2.size()>=st1.size()){
		auto it=st1.begin();
		ll tmp=*it;
		ll x=tmp/2;
		ll y=tmp-x;
		ll mmax=*st2.begin();
		if(x>mmax||y>mmax){
			break;
		}
		st1.erase(it);
		if(st2.count(x)){
			st2.erase(st2.find(x));
		}else{
			st1.insert(x);
		}
		if(st2.count(y)){
			st2.erase(st2.find(y));
		}else{
			st1.insert(y);
		}
	}
	if(st1.size()==0&&st2.size()==0)cout<<"Yes\n";
	else cout<<"No\n";


}
int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	ll times=1;
	cin>>times;
	while(times--)solve();
	return 0;
}

Code 2:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e5+10;
const ll INF=1e17+10;
const ll MOD=1e9+7;
ll n,m;
ll a[N],b[N];

void solve(void){
	cin>>n>>m;
	multiset<ll>st1,st2;
	ll sum1=0,sum2=0;
	for(ll i=1;i<=n;++i){
		cin>>a[i];
		sum1+=a[i];
		st1.insert(a[i]);
	}
	for(ll i=1;i<=m;++i){
		cin>>b[i];
		sum2+=b[i];
		if(st1.count(b[i])){
			st1.erase(st1.find(b[i]));
		}
		else st2.insert(b[i]);
	}
	if(sum1!=sum2){
		cout<<"No\n";
		return;
	}
	ll f=1;
	while(st1.size()&&st2.size()){
		ll x=*st1.rbegin(),y=*st2.rbegin();
		if(x>y)break;
		if(x==y){
			st1.erase(st1.find(x));
			st2.erase(st2.find(y));
		}else {
			st2.erase(st2.find(y));
			st2.insert(y/2);
			st2.insert((y+1)/2);
		}
	}
	if(st1.size()==0&&st2.size()==0)cout<<"Yes\n";
	else cout<<"No\n";


}
int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	ll times=1;
	cin>>times;
	while(times--)solve();
	return 0;
}

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

Code 1:
/*
CF2061D
30.1.25.
*/

#include <bits/stdc++.h>
using namespace std;

#define _line << "\n"
#define _space << " " <<
#define ll long long


int main(){

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

    int t; cin >> t;

    while (t--){
        priority_queue<int> a,b;
        int n,m; cin >> n >> m;
        for (int i=0; i<n; i++){
            int x; cin >> x;
            a.push(x);
        }
        for (int j=0; j<m; j++){
            int x; cin >> x;
            b.push(x);
        }

        if (m>n){
            cout << "no" _line; continue;
        }

        int z=1;
        while (!a.empty() || !b.empty()){
            if (a.empty() || b.empty() || b.size()>a.size()) {
                z=0;
                cout << "no" _line; break;
            }
            if (a.top()==b.top()){
                a.pop(); b.pop();
            }
            else {
                int x=b.top(); b.pop();
                //cout << x _space b.size() _line;
                if (x==1){
                    z=0;
                    cout << "no" _line; break;
                }
                if (x%2){
                    b.push(x/2);
                    b.push(x/2+1);
                }
                else {
                    b.push(x/2);
                    b.push(x/2);
                }
            }
        }

        if (z) cout << "yes" _line;

    }

}


Code 2:
/*
CF2061D
30.1.25.
*/

#include <bits/stdc++.h>
using namespace std;

#define _line << "\n"
#define _space << " " <<
#define ll long long


int main(){

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

    int t; cin >> t;

    while (t--){
        priority_queue<int> a,b;
        int n,m; cin >> n >> m;
        for (int i=0; i<n; i++){
            int x; cin >> x;
            a.push(x);
        }
        for (int j=0; j<m; j++){
            int x; cin >> x;
            b.push(x);
        }

        if (m>n){
            cout << "no" _line; continue;
        }

        int z=1;
        while (!a.empty() || !b.empty()){
            if (a.empty() || b.empty()) {
                z=0;
                cout << "no" _line; break;
            }
            if (a.top()==b.top()){
                a.pop(); b.pop();
            }
            else {
                int x=b.top(); b.pop();
                if (x==1){
                    z=0;
                    cout << "no" _line; break;
                }
                if (x%2){
                    b.push(x/2);
                    b.push(x/2+1);
                }
                else {
                    b.push(x/2);
                    b.push(x/2);
                }
            }
        }

        if (z) cout << "yes" _line;

    }

}


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

Code 1:
#include <bits/stdc++.h>
#define pii pair<int, int> 
#define lowbit(x) (x&-x) 
#define ll long long  
#define ull unsigned long long
#define endl "\n"
const int mod = 998244353;
const int inf = 1e9;
const ll llf = 1e18;
using namespace std;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int i, j;
	int n, m;
	int tt;
	cin >> tt;
	while (tt--)
	{
		int x;
		map<int, int>mymap;
		bool flag = 1;
		cin >> n >> m;
		while (n--)
		{
			cin >> x;
			mymap[x]--;
		}
		while (m--)
		{
			cin >> x;
			mymap[x]++;
		}
		for (auto it =mymap.rbegin();it != mymap.rend();)
		{
			if (it->first== 1)
			{
				if (it->second)
					flag = 0;
			}
			if (it->second < 0)
			{
				flag = 0;
				break;
			}
			mymap[it->first / 2] += it->second;
			mymap[it->first - it->first / 2] += it->second;
			mymap.erase(it->first);
		}
		int flag1 = 1;
		for (auto x : mymap)
		{
			if (x.second)
				flag1 = 0;
		}
		if (flag && flag1)
			cout << "YeS" << endl;
		else
			cout << "nO" << endl;
	}
}

Code 2:
#include <bits/stdc++.h>
#define pii pair<int, int> 
#define lowbit(x) (x&-x) 
#define ll long long  
#define ull unsigned long long
#define endl "\n"
const int mod = 998244353;
const int inf = 1e9;
const ll llf = 1e18;
using namespace std;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int i, j;
	int n, m;
	int tt;
	cin >> tt;
	while (tt--)
	{
		int x;
		map<int, int>mapa;
		map<int, int>mapb;
		bool flag = 1;
		cin >> n >> m;
		while (n--)
		{
			cin >> x;
			mapa[x]++;
		}
		while (m--)
		{
			cin >> x;
			mapb[x]++;
		}
		int cnt = 0;
		for (auto it = mapb.rbegin();it != mapb.rend();it++)
		{
			//if (cnt == 2)
			//	it--;
			if (it->first == 1)
			{
				if (mapa[1] == mapb[1])
				{
					mapa.erase(1);
					mapb.erase(1);
				}
				else
					flag = 0;
				break;
			}
			if (mapa[it->first] > it->second)
			{
				flag = 0;
				break;
			}

			cnt = 0;
			if (mapb.find(it->first / 2) == mapb.end())cnt++;
			if (mapb.find(it->first / 2) == mapb.end())cnt++;

			mapb[it->first/2] += it->second - mapa[it->first];
			mapb[it->first - it->first / 2] += it->second - mapa[it->first];
			
			mapb[it->first] = mapa[it->first] = 0;
		}
		int flag1 = 1, flag2 = 1;
		for (auto x : mapa)
			if (x.second)
				flag1 = 0;
		for (auto x : mapb)
			if (x.second)
				flag2 = 0;
		if (flag && flag1 && flag2)
			cout << "YeS" << endl;
		else
			cout << "nO" << endl;
	}
}

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

Code 1:
#include<bits/stdc++.h>

#define ll long long int

#define pb push_back



using namespace std;



const int MAXN = 2e5 + 10;



int main(){

		

	ll t;

	scanf("%lld", &t);



	while(t--){

		ll n, m, x;

		scanf("%lld %lld", &n, &m);



		multiset<ll> a;

		vector<ll> b;

		ll suma_a = 0;

		ll suma_b = 0;



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

			scanf("%lld", &x);

			suma_a += x;

			a.insert(x);

		}



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

			scanf("%lld", &x);

			suma_b += x;

			b.pb(x);

		}



		if(suma_a != suma_b){

			printf("No\n");

		}

		else{

			ll k = 0;

			while(b.size() > 0 && k <= n + m){

				k++; 

				if(a.count(b[b.size() - 1]) > 0){

					a.erase(a.find(b[b.size() - 1]));

					b.pop_back();

				}

				else{

					ll x1 = b[b.size() - 1]/2;

					ll x2 = b[b.size() - 1]/2;

					if(b[b.size() - 1] % 2 == 1){

						x2++;

					}

					b.pop_back();

					if(a.count(x1) > 0){

						a.erase(a.find(x1));

					}

					else{

						b.push_back(x1);

					}

					if(a.count(x2) > 0){

						a.erase(a.find(x2));

					}

					else{

						b.push_back(x2);

					}

				}

			}

			if(b.size() == 0){

				printf("Yes\n");

			}

			else{

				printf("No\n");

			}

		}

	}	

	

	return 0;

}

Code 2:
#include<bits/stdc++.h>

#define ll long long int

#define pb push_back



using namespace std;



const int MAXN = 2e5 + 10;



int main(){

		

	ll t;

	scanf("%lld", &t);



	while(t--){

		ll n, m, x;

		scanf("%lld %lld", &n, &m);



		multiset<ll> a;

		vector<ll> b;

		ll suma_a = 0;

		ll suma_b = 0;



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

			scanf("%lld", &x);

			suma_a += x;

			a.insert(x);

		}



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

			scanf("%lld", &x);

			suma_b += x;

			b.pb(x);

		}



		if(suma_a != suma_b){

			printf("No\n");

		}

		else{

			ll k = 0;

			while(b.size() > 0 && k <= n + 2){

				k++; 

				if(a.find(b[b.size() - 1]) != a.end()){

					a.erase(a.find(b[b.size() - 1]));

					b.pop_back();

				}

				else{

					ll x1 = b[b.size() - 1]/2;

					ll x2 = b[b.size() - 1]/2;

					if(b[b.size() - 1] % 2 == 1){

						x2++;

					}

					b.pop_back();

					if(a.find(x1) != a.end()){

						a.erase(a.find(x1));

					}

					else{

						b.push_back(x1);

					}

					if(a.find(x2) != a.end()){

						a.erase(a.find(x2));

					}

					else{

						b.push_back(x2);

					}

				}

			}

			if(b.size() == 0){

				printf("Yes\n");

			}

			else{

				printf("No\n");

			}

		}

	}	

	

	return 0;

}

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

Code 1:
#include <bits/stdc++.h>
using namespace std;

int main() {
	int T;
	scanf("%d", &T);
	
	while (T--) {
		int n, m;
		scanf("%d%d", &n, &m);
		
		priority_queue<int> a, b;
		for (int i = 0; i < n; i++) {
			int x;
			scanf("%d", &x);
			a.push(x);
		}
		for (int i = 0; i < m; i++) {
			int x;
			scanf("%d", &x);
			b.push(x);
		}
		
		bool ok = true;
		while (!a.empty()) {
			if (b.empty() || b.size() > a.size()) {
				ok = false;
				break;
			}
			
			int x = b.top();
			b.pop();
			
			if (x < a.top()) {
				ok = false;
				break;
			}
			if (x == a.top()) {
				a.pop();
			} else {
				b.push(x / 2);
				b.push((x + 1) / 2);
			}
		}
		
		if (!b.empty()) {
			ok = false;
		}
		
		if (ok) {
			puts("Yes");
		} else {
			puts("No");
		}
	}
	
    return 0;
}


Code 2:
#include <bits/stdc++.h>
using namespace std;

int main() {
	int T;
	scanf("%d", &T);
	
	while (T--) {
		int n, m;
		scanf("%d%d", &n, &m);
		
		priority_queue<int> a, b;
		for (int i = 0; i < n; i++) {
			int x;
			scanf("%d", &x);
			a.push(x);
		}
		for (int i = 0; i < m; i++) {
			int x;
			scanf("%d", &x);
			b.push(x);
		}
		
		bool ok = true;
		while (!a.empty()) {
			if (b.empty() || b.size() > a.size()) {
				ok = false;
				break;
			}
			
			int x = b.top();
			b.pop();
			
			if (x < a.top()) {
				ok = false;
				break;
			}
			if (x == a.top()) {
				a.pop();
			} else {
				b.push(x / 2);
				b.push(x / 2 + 1);
			}
		}
		
		if (!b.empty()) {
			ok = false;
		}
		
		if (ok) {
			puts("Yes");
		} else {
			puts("No");
		}
	}
	
    return 0;
}


Answer: 1
Problem: 2061D - Kevin and Numbers
Language: java

Code 1:
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int T = sc.nextInt();
        while (T-- > 0) {
            int n = sc.nextInt();
            int m = sc.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = sc.nextInt();
            int[] b = new int[m];
            for (int i = 0; i < m; i++) b[i] = sc.nextInt();

            PriorityQueue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder());
            for (int val : b) pq.offer(val);

            Map<Integer, Integer> freqMap = new HashMap<>();
            for (int val : a) freqMap.put(val, freqMap.getOrDefault(val, 0) + 1);

            boolean isValid = true;

            for (int i = 0; i < n - m + n; i++) {
                if (pq.isEmpty()) {
                    isValid = false;
                    break;
                }

                int val = pq.poll();
                if (freqMap.getOrDefault(val, 0) == 0) {
                    pq.offer(val / 2);
                    pq.offer((val + 1) / 2);
                } else {
                    freqMap.put(val, freqMap.get(val) - 1);
                }
            }

            System.out.println(isValid && pq.isEmpty() ? "Yes" : "No");
        }
        sc.close();
    }
}

Code 2:
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int T = scanner.nextInt();
        while (T-- > 0) {
            int n = scanner.nextInt();
            int m = scanner.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = scanner.nextInt();
            int[] b = new int[m];
            for (int i = 0; i < m; i++) b[i] = scanner.nextInt();
            System.out.println(canDistribute(a, b) ? "Yes" : "No");
        }
        scanner.close();
    }

    private static boolean canDistribute(int[] a, int[] b) {
        PriorityQueue<Integer> maxHeap = new PriorityQueue<>(Collections.reverseOrder());
        for (int val : b) maxHeap.offer(val);

        Map<Integer, Integer> freqMap = new HashMap<>();
        for (int val : a) freqMap.put(val, freqMap.getOrDefault(val, 0) + 1);

        while (!maxHeap.isEmpty()) {
            int current = maxHeap.poll();
            if (freqMap.getOrDefault(current, 0) > 0) {
                freqMap.put(current, freqMap.get(current) - 1);
            } else {
                if (current == 1) return false;
                maxHeap.offer(current / 2);
                maxHeap.offer((current + 1) / 2);
            }
        }

        for (int count : freqMap.values()) {
            if (count > 0) return false;
        }
        return true;
    }
}

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

Code 1:
#include<bits/stdc++.h>
#define int long long
using namespace std;
priority_queue<int,vector<int>,greater<int> >a,b;
map<int,int> ma;
int n,m;
bool cal(int x)
{
if(x==0)return 0;
if(ma[x]>0)
{
	ma[x]--;
	n--;
	return 1;
}
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();
}

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";
			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();
}

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

Code 1:
#ifndef ONLINE_JUDGE
#include "debugger.h"
#else
#define dbg(...)
#endif
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define pii pair<ll, ll>
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define minus cout << -1 << endl
#define fastread()                \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
using namespace std;
const int mod = 1e9 + 7;
void solve()
{
    int n, m;
    cin >> n >> m;
    multiset<int> m1, m2;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        m1.insert(x);
    }

    for (int i = 0; i < m; i++)
    {
        int x;
        cin >> x;
        m2.insert(x);
    }
    // multiset<int> m3;
    int times = 2*(n+m);
    while (times--)
    {
        if (m1.size() == 0 || m2.size() == 0)
            break;
        int num = *m2.rbegin();
        if (m1.find(num) != m1.end())
        {
            m2.erase(m2.find(num));
            m1.erase(m1.find(num));
            continue;
        }
        int num1 = num / 2;
        int num2 = (num / 2) + (num % 2);
        m2.erase(m2.find(num));
        m2.insert(num1);
        m2.insert(num2);
    }

    if (m1 == m2)
        cyes;
    else
        cno;
}

int32_t main()
{
    fastread();
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }

    return 0;
}

Code 2:
#ifndef ONLINE_JUDGE
#include "debugger.h"
#else
#define dbg(...)
#endif
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define pii pair<ll, ll>
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define minus cout << -1 << endl
#define fastread()                \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
using namespace std;
const int mod = 1e9 + 7;
void solve()
{
    int n, m;
    cin >> n >> m;
    multiset<int> m1, m2;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        m1.insert(x);
    }

    for (int i = 0; i < m; i++)
    {
        int x;
        cin >> x;
        m2.insert(x);
    }
    // multiset<int> m3;
    int times = n + m;
    while (times--)
    {
        if (m1.size() == 0 || m2.size() == 0)
            break;
        int num = *m2.rbegin();
        if (m1.find(num) != m1.end())
        {
            m2.erase(m2.find(num));
            m1.erase(m1.find(num));
            continue;
        }
        int num1 = num / 2;
        int num2 = (num / 2) + (num % 2);
        m2.erase(m2.find(num));
        m2.insert(num1);
        m2.insert(num2);
    }

    if (m1 == m2)
        cyes;
    else
        cno;
}

int32_t main()
{
    fastread();
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }

    return 0;
}

Answer: 1