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

Solution 1 (runtime: 358 ms):
#include <bits/stdc++.h>
using namespace std;
#define int long long

void sol() {
    int n, m; cin >> n >> m;
    map<int, int>mp;
    for(int i = 1; i <= n; ++i) {
        int x; cin >> x;
        mp[x]++;
    }
    priority_queue<int> pq;
    for(int i = 1; i <= m; ++i) {
        int x; cin >> x;
        pq.push(x);
    }
    for(int i = 1; i <= 2 * n - m; ++i) {
        if(pq.empty()) return void(cout << "NO\n");
        int x = pq.top();
        pq.pop();
        if(!mp[x]) {
            pq.push(x / 2);
            pq.push((x + 1) / 2);
        } else
            --mp[x];
    }
    cout << (pq.empty() ? "YES\n" : "NO\n");

}

int32_t main() {
    ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
    int T = 1; cin >> T;
    while (T--) sol();
}

Solution 2 (runtime: 343 ms):
# include<bits/stdc++.h>



using namespace std;



#define endl "\n"

#define ll long long int

#define pb push_back

#define rvec_sort(v) sort(v.begin(), v.end(), greater<int>());

#define vec_sort(v) sort(v.begin(),v.end());

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)

#define vec_sum(v) accumulate(v.begin(),v.end(),0ll)

#define PI 3.1415926535897932384626433832795

#define yes {cout<<"Yes"<<endl; return;} 

#define no {cout<<"No"<<endl; return;} 

const ll M=1e9+7;



// ordered_set(pbds) : 1)finding kth element :*A.find_by_order(k)  , 2)finding number of elements smaller than X: A.order_of_key(X)

//#include<ext/pb_ds/assoc_container.hpp>

//#include<ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;



// Binary exponentiation : (a^b)%m

long long binpow(long long a, long long b,long long m) {

    long long result = 1;

    while(b) {

         if (b & 1)

         result = (result * a)%m;

         a = (a * a)%m;

         b >>= 1;

    }

    return result;

}



// Modulo Multiplicative inverse (MMI) : A^-1 = A^(m-2)%m, where gcd(a,m)=1

long long modinverse(long long a,long long m){

    return binpow(a,m-2,m);

}



void solve(){

    int n,m;

    cin>>n>>m;

    multiset<ll,greater<ll>> a,b;

    ll suma = 0ll, sumb = 0ll;

    rep(i,n){

        ll x;

        cin>>x;

        suma += x;

        a.insert(x);

    }

    rep(i,m){

        ll x;

        cin>>x;

        sumb += x;

        b.insert(x);

    }

    if(suma != sumb) no

    //int ct = 0;

    while(true){

        //ct++;

        if(a.empty() && b.empty()) yes

        if(a.empty() || b.empty()) no

        if(*a.begin() == *b.begin()){

            a.erase(a.begin());

            b.erase(b.begin());

        }

        else if(*a.begin() < *b.begin()){

            ll fl = *b.begin()/2;

            ll cl = (*b.begin() + 1)/2;

            b.erase(b.begin());

            b.insert(fl);

            b.insert(cl);

            //cout<<fl<<endl;

            //if(ct == 1000) break;

        }

        else no        

    }

}



int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL); cout.tie(NULL);

    int t;

    cin>>t;

    while(t--){

    solve();

    }

    return 0;

}