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

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

// JAY SHREE KRISHNA
// AUTHOR:- Solanki Nirmal Bhikhabhai

// ------------------------------------------------------------------------------------------------------------
#define hello ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long
#define ld long double
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define pb push_back
#define pp pop_back
#define endl "\n"
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
// ------------------------------------------------------------------------------------------------------------

vector<ll> llToBin(ll n){
    vector<ll> ans;
    while(n!=0){
        ans.pb(n%2);
        n/=2;
    }
    reverse(all(ans));
    return ans;
}

vector<ll> isprime(1e6+1,1);
void sieve(int n){
    isprime[1]=0;
    for(ll i=2;i*i<1000000;i++){
        if(isprime[i]!=0){
            for(ll j=i*i;j<1000000;j+=i) isprime[j]=0;
        }
    }
}

void printvec(vector<ll> temp){
    for(ll i=0;i<temp.size();i++) cout<<temp[i]<<" ";
    cout<<endl;
}

void printmap(map<ll,ll> temp){
    for(auto it=temp.begin();it!=temp.end();it++) cout<<it->fi<<" "<<it->se<<endl;
}

ll ncr(ll n,ll r){
    ld sum=1;
    for(ll i=0;i<=r;i++) sum=sum*(n-r+i)/i;
    return (ll)sum;
}


// ------------------------------------------------------------------------------------------------------------

void solve(){
    ll n,m;		cin>>n>>m;
    vector<ll> a(n),b(m);
    for(ll i=0;i<n;i++) cin>>a[i];
    for(ll i=0;i<m;i++) cin>>b[i];

    priority_queue<ll,vector<ll>,greater<ll>>pqa (a.begin(),a.end());
    priority_queue<ll,vector<ll>,greater<ll>>pqb (b.begin(),b.end());
    bool flag=true;
    while(!pqa.empty() && !pqb.empty())
    {
        ll a1=pqa.top();
        ll b1=pqb.top();
        //cout<<a1<<" "<<b1<<" "<<endl;
        if(a1>b1)
        {
            flag=false;
            break;
        }
        pqa.pop();
        pqb.pop();
        if(a1==b1)
        {
            //cout<<"Hii"<<endl;
            continue;
        }
        if(pqa.empty())
        {
            flag=false;
            break;
        }
        ll a2=pqa.top();
        pqa.pop();
        //cout<<a2<<endl;
        if(a2==b1)
        {
            pqa.push(a1);
            continue;
        }
        if(a1+a2<b1)
        {
            pqa.push(a1+a2);
            pqb.push(b1);
        }
        else if( a2-a1<=1 && a1+a2==b1) continue;
        else
        {
            flag=false;
            break;
        }
    }
    if(pqa.size()>0 || pqb.size()>0 || !flag) no;
    else yes;
    //cout<<"f "<<flag<<endl;
}

int32_t main(){
    hello;
    int t;			cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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

// JAY SHREE KRISHNA
// AUTHOR:- Solanki Nirmal Bhikhabhai

// ------------------------------------------------------------------------------------------------------------
#define hello ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long
#define ld long double
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define pb push_back
#define pp pop_back
#define endl "\n"
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
// ------------------------------------------------------------------------------------------------------------

vector<ll> llToBin(ll n){
    vector<ll> ans;
    while(n!=0){
        ans.pb(n%2);
        n/=2;
    }
    reverse(all(ans));
    return ans;
}

vector<ll> isprime(1e6+1,1);
void sieve(int n){
    isprime[1]=0;
    for(ll i=2;i*i<1000000;i++){
        if(isprime[i]!=0){
            for(ll j=i*i;j<1000000;j+=i) isprime[j]=0;
        }
    }
}

void printvec(vector<ll> temp){
    for(ll i=0;i<temp.size();i++) cout<<temp[i]<<" ";
    cout<<endl;
}

void printmap(map<ll,ll> temp){
    for(auto it=temp.begin();it!=temp.end();it++) cout<<it->fi<<" "<<it->se<<endl;
}

ll ncr(ll n,ll r){
    ld sum=1;
    for(ll i=0;i<=r;i++) sum=sum*(n-r+i)/i;
    return (ll)sum;
}


// ------------------------------------------------------------------------------------------------------------
bool f(ll val, map<ll,ll>&mp)
{
    //cout<<val<<endl;
    if(mp[val]>0) 
    {
        mp[val]--;
        return true;
    }
    if(val==1) return false;
    ll v1=val/2,v2=val/2;
    if(val%2!=0) v2++;
    if(!f(v1,mp)) return false;
    if(!f(v2,mp)) return false;
    return true;
}
void solve(){
    ll n,m;		cin>>n>>m;
    vector<ll> a(n),b(m);
    for(ll i=0;i<n;i++) cin>>a[i];
    for(ll i=0;i<m;i++) cin>>b[i];

    map<ll,ll>mp;
    for(auto it:a) mp[it]++;
    bool flag=true;
    for(auto it:b)
    {
        if(!f(it,mp))
        {
            flag=false;
            break;
        }
    }
    for(auto it:mp) 
    {
        if(it.second>0)
        {
            flag=false;
            break;
        }
    }
    if(flag) yes;
    else no;
}

int32_t main(){
    hello;
    int t;			cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Answer: 2