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

Code 1:
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<bits/stdc++.h>
#include<string>
#include <numeric>
#include<map>
#include<set>
#include<iomanip>
using namespace std;
#define py cout << "YES" << endl
#define pn cout << "NO" << endl
#define ll long long
#define forw(i, j, n) for (ll i = j; i < n; i++)
#define fastio()                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define pb push_back
#define ppb pop_back
#define all(x) x.begin(), x.end()
bool fun(ll x,unordered_map<ll,ll>&mp1,unordered_map<ll,bool>&mp2){
    if(x<=0)return false;
    if(mp2.count(x) && mp2[x]==false)return mp2[x];
    bool ans=true;
    if(mp1[x]>0){
        mp1[x]--;
        return true;
    }
    ll l,r;
    if(x%2){
        l=x/2;
        r=l+1;
    }
    else{
        l=x/2;
        r=x/2;
    }
        if(l==1){
            if(mp1[1]>0){
                mp1[1]--;
            }
            else ans=false;
            
        }
        else if(l==0){ans=false;}
        
       else ans&=fun(l,mp1,mp2);
    if(r==1){
         if(mp1[1]>0){
                mp1[1]--;
            }
            else ans=false;
    }
    else if(r==0){ans=false;}
    
    
        else ans&=fun(r,mp1,mp2);
    mp2[x]=ans;
    return ans;
}
int main() {
	int t; cin>>t;
	while(t--){
	    ll n,m; cin>>n>>m;
	    vector<ll> a(n),b(m);
	    unordered_map<ll,ll>mp1;
	    unordered_map<ll,bool>mp2;
	    forw(i,0,n){
	        cin>>a[i];
	  mp1[a[i]]++;
	    }
	     forw(i,0,m){
	        cin>>b[i];
	        
	    }
	   bool ans=true;
	   forw(i,0,m){
	       ans&=fun(b[i],mp1,mp2);
	       if(ans==false)break;
	   }
	for(auto it:mp1){
	    if(it.second>0){ans=false; break;}
	}
	    
	    
	               
	    if(ans)py;
	    else pn;
	}
	return 0;
}
// 1 1 1 1 1 2 2 2 2 2 3 3 3 3

Code 2:
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<bits/stdc++.h>
#include<string>
#include <numeric>
#include<map>
#include<set>
#include<iomanip>
using namespace std;
#define py cout << "YES" << endl
#define pn cout << "NO" << endl
#define ll long long
#define forw(i, j, n) for (ll i = j; i < n; i++)
#define fastio()                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define pb push_back
#define ppb pop_back
#define all(x) x.begin(), x.end()

int main() {
	int t; cin>>t;
	forw(k,0,t){
	    ll n,m; cin>>n>>m;
	    vector<ll> a(n),b(m);
	    multiset<ll>mp1,mp2;
	    forw(i,0,n){
	        cin>>a[i];
	  mp1.insert(a[i]);
	    }
	     forw(i,0,m){
	        cin>>b[i];
	        mp2.insert(b[i]);
	    }
	    
	   bool ans=true;
	
	   while(!mp1.empty() && !mp2.empty() && mp1.size()>=mp2.size()){
	       ll x=*--mp2.end();
	       //ll x1=*--mp2.end();
	       //cout<<x<<" ";
	       if(mp1.find(x)!=mp1.end()){
	           mp2.erase(mp2.find(x));
	           mp1.erase(mp1.find(x));
	           
	       }
	       else{
	           mp2.erase(mp2.find(x));
	           ll l,r;
	           if(x%2){l=x/2; r=l+1;}
	           else{l=x/2; r=l;}
	       
	            mp2.insert(l);
	            mp2.insert(r);
	            
	        
	          
	           
	       
	       }
	       //cout<<mp1.size()<<" "<<mp2.size()<<endl;
	       
	   }
	    
	   while(!mp2.empty()){
	       ll it=*mp2.begin();
	       if( !mp1.empty() && mp1.find(it)!=mp1.end()){
	           mp1.erase(mp1.find(it));
	           mp2.erase(mp2.find(it));
	       }
	       else break;
	   }
	    
	   
	               
	    if(mp1.empty() && mp2.empty())py;
	    else pn;
	}
	return 0;
}
// 4 5   2 3 4  1 1 1 1 1 1 
// 1 1 1 1 1 2 2 2 2 2 3 3 3 3

Answer: 2