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

Code 1:
#include <bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;

void solve() {
    int n, m; cin >> n >> m;
    vll a(n), b(m);
    for (auto& i: a) cin >> i;
    for (auto& i: b) cin >> i;

    sort(all(a));
    sort(all(b));

    priority_queue<ll, vll> pq(all(b));

    while (pq.size() != a.size()) {
        if (pq.top() == a.back()) {
            pq.pop();
            a.pop_back();
        } else if (pq.top() > a.back()) {
            ll temp = pq.top();
            pq.pop();
            pq.push(temp / 2);
            pq.push((temp / 2) + (temp % 2));
        } else if (pq.top() < a.back()) {
            cout << "No" << endl;
            return;
        }
    }

    while (pq.top() == a.back()) {
        a.pop_back();
        pq.pop();
    }
    
    if (pq.size() || a.size()) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

int main() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
   #endif
   ll t;
   cin >> t;
   while(t--) {
      solve();
   }
   return 0;
}

Code 2:
#include <bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;

void solve() {
    int n, m; cin >> n >> m;
    vll a(n), b(m);
    for (auto& i: a) cin >> i;
    for (auto& i: b) cin >> i;

    sort(all(a));
    sort(all(b));

    priority_queue<ll, vll> pq(all(b));

    while (pq.size() < a.size() && pq.size()) {
        if (pq.top() == a.back()) {
            pq.pop();
            a.pop_back();
        } else if (pq.top() > a.back()) {
            ll temp = pq.top();
            pq.pop();
            pq.push(temp / 2);
            pq.push((temp / 2) + (temp % 2));
        } else if (pq.top() < a.back()) {
            cout << "No" << endl;
            return;
        }
    }

    if (!pq.size()) {
        cout << "No" << endl;
        return;
    }

    while (pq.top() == a.back()) {
        a.pop_back();
        pq.pop();
    }
    
    if (pq.size() || a.size()) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

int main() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
   #endif
   ll t;
   cin >> t;
   while(t--) {
      solve();
   }
   return 0;
}

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

Code 1:
#include<bits/stdc++.h>
using namespace std;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("inp.in", "r", stdin), freopen("oup.out", "w", stdout);
    #endif
    int t; cin >> t;
    while (t--) {
        int n, m; cin >> n >> m;
        map<int, int> a, b;
        int atot = 0, btot = 0;
        for (int i = 0, j; i < n; ++i) cin >> j, a[j]++, atot += j;
        for (int i = 0, j; i < m; ++i) cin >> j, b[j]++, btot += j;
        if (atot != btot) goto fail;
        atot = n, btot = m;
        while (b.size()) {
            auto [key, val] = *b.begin();
            btot -= val;
            if (a.count(key)) {
                if (a[key] >= val) a[key] -= val, atot -= val, val = 0;
                else btot -= a[key], val -= a[key], a.erase(key);
                if (a[key] == 0) a.erase(key);
            }
            if (val != 0) b[key / 2] += val, b[key - key / 2] += val, btot += 2 * val; 
            b.erase(key);
            if (btot > atot) goto fail;
        }
        if (a.size() || b.size()) goto fail;
        cout << "YES" << endl; continue;
        fail: cout << "NO" << endl;
    }
}

Code 2:
#include<bits/stdc++.h>
using namespace std;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("inp.in", "r", stdin), freopen("oup.out", "w", stdout);
    #endif
    #define int long long
    int t; cin >> t;
    while (t--) {
        int n, m; cin >> n >> m;
        string ans = "YES";
        map<int, int> a, b;
        int atot = 0, btot = 0;
        for (int i = 0, j; i < n; ++i) cin >> j, a[j]++, atot += j;
        for (int i = 0, j; i < m; ++i) cin >> j, b[j]++, btot += j;
        if (atot != btot) goto fail;
        atot = n, btot = m;
        while (b.size()) {
            auto [key, val] = *b.begin();
            btot -= val;
            if (a.count(key)) {
                if (a[key] >= val) a[key] -= val, atot -= val, val = 0;
                else btot -= a[key], val -= a[key];
                if (a[key] == 0) a.erase(key);
            }
            if (val != 0) b[key / 2] += val, b[key - key / 2] += val, btot += 2 * val; 
            b.erase(key);
            if (btot > atot) goto fail;
        }
        cout << "YES" << endl; continue;
        fail: cout << "NO" << endl;
    }
}

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

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

using ll = long long;
#define lowbit(x) x & (-x)
#define fix(x) fixed << setprecision(x)
ll n, m;
map<ll, ll> ma;
bool dfs(ll x) {
    if (x == 0)
        return 0;
    if (ma[x] > 0) {
        ma[x]--;
        return 1;
    }
    return dfs(x / 2) && dfs(x - x / 2);
}
void sp() {
    cin >> n >> m;
    vector<ll> a(n);
    ma.clear();
    ll f=0;
    for (ll i = 0; i < n; i++)
        cin >> a[i], ma[a[i]]++;
    for (ll i = 0; i < m; i++) {
        ll x;
        cin >> x;
        if (!dfs(x)) {
            f=1;
        }
    }
    for (auto i : ma) {
        if (i.second > 0) {
            f=1;
            break;
        }
    }
    if(f){
        cout<<"No"<<endl;
        return ;
    }
    cout << "Yes" << endl;
}
int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    ll __ = 1;
    cin >> __;
    while (__--)
        sp();
}

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

using ll = long long;
#define lowbit(x) x & (-x)
#define fix(x) fixed << setprecision(x)
ll n, m; 
map<ll, ll> ma;
bool dfs(ll x){
    if(x==0) return 0;
        if(ma[x]>0){
            ma[x]--;
            return 1;
        }
    return dfs(x/2)&&dfs(x-x/2);
}
void sp() {
    cin >> n >> m;
    vector<ll> a(n);
    ma.clear();
    for (ll i = 0; i < n; i++)
        cin >> a[i], ma[a[i]]++;
    for (ll i = 0; i < m; i++) {
        ll x;
        cin >> x;
        if(!dfs(x)){
            cout << "No" << endl;
            return;
        }
    }
    for(auto i:ma){
        if(i.second>0){
            cout<<"No"<<endl;
            return ;
        }
    }
    cout << "Yes" << endl;
}
int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    ll __ = 1;
    cin >> __;
    while (__--)
        sp();
}

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

Code 1:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define nl "\n"
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pair<ll,ll>>vpll;
#define pb                push_back 
#define fori(n)           for (ll i=0; i<n; i++) 
#define forj(n)           for (ll j=0; j<n; j++) 
#define isort(v)          sort(v.begin(),v.end())
#define dsort(v)          sort(v.rbegin(),v.rend())
#define all(x)            (x).begin(), (x).end()

const ll M = 1e9+7;

void solve(){
	ll n,m;
	cin>>n>>m;
	vll v(n);
	fori(n){
		cin>>v[i];
	}
	isort(v);
	priority_queue<ll>pq;
    fori(m){
		ll a;cin>>a;
        pq.push(a);
	}
	ll p = n-1;
	while(p>=0){
		if(pq.size()>p+1 || pq.empty()){
			cout<<"No"<<nl;
			return;
		}
		if(pq.top()>v[p]){
			ll element = pq.top();
			pq.pop();
			pq.push(element/2);
			pq.push(element/2+element%2);
		}else if(pq.top()<v[p]){
			cout<<"No"<<nl;
			return;
		}else{
			pq.pop();
			p--;
		}
	}
	cout<<"Yes"<<nl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int tt;cin >> tt;for (int i=1; i<=tt; i++){solve();}
    // solve();
}

Code 2:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define nl "\n"
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pair<ll,ll>>vpll;
#define pb                push_back 
#define fori(n)           for (ll i=0; i<n; i++) 
#define forj(n)           for (ll j=0; j<n; j++) 
#define isort(v)          sort(v.begin(),v.end())
#define dsort(v)          sort(v.rbegin(),v.rend())
#define all(x)            (x).begin(), (x).end()

const ll M = 1e9+7;

bool f(int n,map<ll,ll>&mp){
	// cout<<n<<nl;
	if(mp.find(n)!=mp.end()){
		mp[n]--;
		if(mp[n]==0){
			mp.erase(n);
		}
		return true;
	}
	if(n<=1 || mp.empty())return false;
	if(n%2){
        if(!(f(n/2,mp)&f(n/2+1,mp)))return false;
	}else{
		if(!(f(n/2,mp)&f(n/2,mp)))return false;
	}
	return true;
}

void solve(){
	ll n,m;
	cin>>n>>m;
	map<ll,ll>mp;
	fori(n){
		ll a;
		cin>>a;
		mp[a]++;
	}
	vll v(m);
	fori(m){
		cin>>v[i];
	}
	ll ans = true;
    for(int i=0; i<m; i++){
		if(mp.size()==0){
			cout<<"No"<<nl;
			return;
		}
		if((!(f(v[i],mp)))){
			cout<<"No"<<nl;
			return;
		}
	}
	if(mp.size()!=0){
		cout<<"No"<<nl;
		return;
	}
	cout<<"Yes"<<nl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int tt;cin >> tt;for (int i=1; i<=tt; i++){solve();}
    // solve();
}

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

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

void solve () {
  int n, m;
  cin >> n >> m;
  multiset<int> a, b;
  for (int i = 0; i < n; i++) {
     int x;
     cin >> x;
     a.insert(x); 
   } 
  for (int i = 0; i < m; i++) {
      int x;
      cin >> x;
      b.insert(x);
   } 
  for (int i = 0; i < n; i++) {
    if (a.size() <= b.size()) {
      // cout << "No\n";
      break;
    }     
    int x , y;
    x = *a.begin();  a.erase(a.find(x));
    if (a.size() > 0) y = *a.begin(), a.erase(a.find(y));
   
    if (x == *b.begin()) {
      a.insert(y);
      b.erase(b.find(x));
    } else {
      if (abs(x - y) <= 1) a.insert(x + y);
      else break;
    }
  } 
  if (a.size() == 0 || b.size() == 0 || a.size() < b.size()) {
    cout << "No\n";
  } else {
    while (1) {
     if (a.size() == 0 || b.size() == 0) break; 
     int x = *a.begin(), y = *b.begin();
      if (x != y) {
        cout <<"No\n";
        return;
      } else {
        a.erase(a.find(x));
        b.erase(b.find(y));
      }
    }
    cout << "Yes\n";
  }
}

int main() {
  auto begin = std::chrono::high_resolution_clock::now();
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  //freopen("in",  "r", stdin);
  //freopen("out", "w", stdout);
  int T = 1;
  cin >> T;
  for(int i = 1; i <= T; i++) {
     // cout << "Case #" << i << ": ";
      solve();
  }
  auto end = std::chrono::high_resolution_clock::now();
  auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
  cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n"; 
  return 0;
}

Code 2:
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define endl "\n"
const int N = 3e5 + 10, M = 110, mod = 998244353;
const long long INF = 2e18;
typedef pair<int, int> pt;
typedef long long ll;



void solve() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n + 1), b(m + 1);
	map<int, int> cnt, cnt2;
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
		if (cnt[a[i]] == 1) sum++;
	}
	map<int, int> mp;
	for (int i = 1; i <= m; i++) {
		cin >> b[i];
		mp[b[i]]++;
	}
	while (!mp.empty()) {
		auto [x, t] = *mp.rbegin();
		mp.erase(mp.rbegin()->first);
		if (cnt[x] >= t) {
			cnt[x] -= t;
			if (cnt[x] == 0) sum--;
			continue;
		}
		else if (cnt[x] > 0) {
			t -= cnt[x];
			cnt[x] = 0;
			sum--;
		}
		if (x == 1) {
			cout << "No" << endl;
			return;
		}
		if (x & 1) {
			mp[x / 2] += t, mp[x / 2 + 1] += t;
		}
		else {
			mp[x / 2] += 2 * t;
		}
	}
	if (sum == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

signed main() {
    //freopen("data.in", "r", stdin);
    //freopen("std.txt", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

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

Code 1:
#include<iostream>

#include<unordered_map>

using namespace std;

#define INF 2147483647

int t,n,m,a;

unordered_map<int,int>mp;

bool solve(int x)

{

    if(mp[x])

    {

        mp[x]--;

        return true;

    }

    else if(!x)return false;

    else return solve(x/2)&&solve((x+1)/2);

}

int main()

{

    scanf("%d",&t);

    while(t--)

    {

        mp.clear();

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

        long long cnt=0;

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

        {

            scanf("%d",&a);

            mp[a]++;

            cnt+=a;

        }

        bool flag=true;

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

        {

            scanf("%d",&a);

            cnt-=a;

            if(flag&&!solve(a))flag=false;

        }

        if(flag&&!cnt)printf("Yes\n");

        else printf("No\n");

    }

    return 0;

}

Code 2:
#include<iostream>

#include<map>

using namespace std;

int t,n,m,a;

map<int,int>mp;

bool solve(int x)

{

    if(mp[x])

    {

        mp[x]--;

        return true;

    }

    else if(!x)return false;

    else return solve(x/2)&&solve((x+1)/2);

}

int main()

{

    scanf("%d",&t);

    while(t--)

    {

        mp.clear();

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

        long long cnt=0;

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

        {

            scanf("%d",&a);

            mp[a]++;

            cnt+=a;

        }

        bool flag=true;

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

        {

            scanf("%d",&a);

            cnt-=a;

            if(flag&&!solve(a))flag=false;

        }

        if(flag&&!cnt)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;
#define int long long
map<int, int> mpa;
int cf(int x,int con)  
{
	if(x==0)return 1;
	if (con>mpa[x])
	{
		con -= mpa[x];
		mpa[x] = 0;
		if (x % 2 == 0)
		{
			if (cf(x / 2, 2 * con))return 1;
		}
		else
		{
			if (cf(x/2, con))return 1;
			if (cf(x/2+1,con))return 1;
		}
	}
	else
	{
		mpa[x] -= con;
	}
	return 0;
}
int solve()
{
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	vector<int> b(m);
	mpa.clear();
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		mpa[a[i]]++;
	}
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	int ans = 0;
	for (int i = 0; i < m; i++)
	{
		if (cf(b[i], 1))
		{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	for (auto i : mpa)
	{
		if (i.second > 0)
		{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 1;
}
signed main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin >> t;
	while (t--)
	{
		solve();
	}
}

Code 2:
#include<bits/stdc++.h>
using namespace std;
#define int long long
map<int, int> mpa;
int cf(int x,int con)  
{
	if(x==0)return 1;
	if (con>mpa[x])
	{
		con -= mpa[x];
		mpa[x] = 0;
		if (x % 2 == 0)
		{
			if (cf(x / 2, 2 * con))return 1;
		}
		else
		{
			if (cf(x/2, con))return 1;
			if (cf(x/2+1,con))return 1;
		}
	}
	else
	{
		mpa[x] -= con;
	}
	return 0;
}
int solve()
{
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	vector<int> b(m);
	mpa.clear();
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		mpa[a[i]]++;
	}
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	int ans = 0;
	for (int i = 0; i < m; i++)
	{
		if (cf(b[i], 1))
		{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	for (auto i : mpa)
	{
		if (i.second > 0)
		{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
}
signed main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin >> t;
	while (t--)
	{
		solve();
	}
}

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

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

// #define int long long
#define PII pair<int, int>
#define ll long long

using namespace std;

int T, n, m;

void solve()
{
    cin >> n >> m;
    priority_queue<int, vector<int>, greater<int>> qa, qb;
    ll sa = 0, sb = 0;
    for(int i = 0, x;i < n;i ++){
        cin >> x;
        sa += x;
        qa.push(x);
    }
    for(int i = 0, x;i < m;i ++){
        cin >> x;
        sb += x;
        qb.push(x);
    }
    if(sa != sb){
        cout << "NO" << endl;
        return;
    }
    while(!qa.empty() && !qb.empty())
    {
        auto a = qa.top(), b = qb.top();
        // cout << a << " " << b << endl;
        qa.pop(), qb.pop();
        if(a < b){
            qa.push(a);
            while(!qa.empty())
            {
                auto t1 = qa.top();
                qa.pop();

                if(t1 == b) break;

                auto t2 = qa.top();
                qa.pop();
                if(t2 - t1 > 1){
                    cout << "NO" << endl;
                    return;
                }
                qa.push(t1 + t2);
            }
        }else if(a > b){
            qb.push(b);
            while(!qb.empty())
            {
                auto t1 = qb.top();
                qb.pop();

                if(t1 == a) break;

                auto t2 = qb.top();
                qb.pop();
                if(t2 - t1 > 1){
                    cout << "NO" << endl;
                    return;
                }
                qb.push(t1 + t2);
            }
        }
    }
    if(qa.empty() && qb.empty()) cout << "YES" << endl;
    else cout << "NO" << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> T;
    while(T --){
        solve();
    }
    return 0;
}

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

// #define int long long
#define PII pair<int, int>
#define ll long long

using namespace std;

int T, n, m;

void solve()
{
    cin >> n >> m;
    priority_queue<int> qa, qb;
    ll sa = 0, sb = 0;
    for(int i = 0, x;i < n;i ++){
        cin >> x;
        sa += x;
        qa.push(x);
    }
    for(int i = 0, x;i < m;i ++){
        cin >> x;
        sb += x;
        qb.push(x);
    }
    if(sa != sb){
        cout << "NO" << endl;
        return;
    }
    while(!qa.empty())
    {
        if(qb.empty()) break;

        auto a = qa.top(), b = qb.top();
        // cout << a << " " << b << endl;
        qb.pop();

        if(b < a){
            cout << "NO" << endl;
            return;
        }
        if(b == a) qa.pop();
        else{
            qb.push(b / 2);
            qb.push((b + 1) / 2);
        }
    }
    if(qa.empty() && qb.empty()) cout << "YES" << endl;
    else cout << "NO" << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> T;
    while(T --){
        solve();
    }
    return 0;
}

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

Code 1:
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
const int N=200005;

int a[N],b[N];
void solve(){
    int n,m;cin>>n>>m;
    priority_queue<int>qe1,qe2;
    int sum=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum+=a[i];
        qe1.push(a[i]);
    }
    for(int i=1;i<=m;i++){
        cin>>b[i];
        sum-=b[i];
        qe2.push(b[i]);
    }
    if(sum){
        cout<<"NO"<<endl;
        return;
    }
    while(!qe1.empty()&&!qe2.empty()){
        int x=q1.top();
        int y=q2.top();
        if(y==x){
            q1.pop();
            q2.pop();
        }
        if(y>x){
            q2.pop();
            q2.push((y+1)/2);
            q2.push(y/2);
        }
        if(y<x){
            cout<<"NO"<<endl;
            return;
        }
    }
    if(q1.empty()&&q2.empty())cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

int main(){
    std::ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int _=1;cin>>_;
    while(_--){
        solve();
    }
    return 0;
}

Code 2:
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
const int N=200005;

int a[N],b[N];
void solve(){
    int n,m;cin>>n>>m;
    priority_queue<int>qe1,qe2;
    int sum=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum+=a[i];
        qe1.push(a[i]);
    }
    for(int i=1;i<=m;i++){
        cin>>b[i];
        sum-=b[i];
        qe2.push(b[i]);
    }
    if(sum){
        cout<<"NO"<<endl;
        return;
    }
    while(!qe1.empty()&&!qe2.empty()){
        int x=qe1.top();
        int y=qe2.top();
        if(y==x){
            qe1.pop();
            qe2.pop();
        }
        if(y>x){
            qe2.pop();
            qe2.push((y+1)/2);
            qe2.push(y/2);
        }
        if(y<x){
            cout<<"NO"<<endl;
            return;
        }
    }
    if(qe1.empty()&&qe2.empty())cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

int main(){
    std::ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int _=1;cin>>_;
    while(_--){
        solve();
    }
    return 0;
}

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

Code 1:
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 5e5 + 6;

int n, m;
int a[N], b[N];

void solve()
{
    cin >> n >> m;
    multiset<int> s;
    for(int i = 1; i <= n; i ++) cin >> a[i], s.insert(a[i]);
    for(int i = 1; i <= m; i ++) cin >> b[i];

    auto dfs = [&](auto self, int u) -> bool
    {
        if(u == 0) return false;
        if(s.count(u))
        {
            s.erase(s.find(u));
            return true;
        }
        return (self(self, u / 2) && self(self, u - u / 2));
    };
    for(int i = 1; i <= m; i ++)
        if(!dfs(dfs, b[i])) {cout << "No\n"; return;}
    if(s.empty()) cout << "Yes\n";
    else cout << "No\n";
}

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

Code 2:
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 5e5 + 6;

int n, m;
int a[N], b[N];

void solve()
{
    cin >> n >> m;
    multiset<int> s;
    for(int i = 1; i <= n; i ++) cin >> a[i], s.insert(a[i]);
    for(int i = 1; i <= m; i ++) cin >> b[i];

    auto dfs = [&](auto self, int u) -> bool
    {
        if(u == 0) return false;
        if(s.contains(u))
        {
            s.erase(s.find(u));
            return true;
        }
        return (self(self, u / 2) && self(self, u - u / 2));
    };
    for(int i = 1; i <= m; i ++)
        if(!dfs(dfs, b[i])) {cout << "No\n"; return;}
    if(s.empty()) cout << "Yes\n";
    else cout << "No\n";
}

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

Answer: 2