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

Solution 1 (runtime: 374 ms):
#include "bits/stdc++.h"

using namespace std;

int n, m;
multiset < int > a, b;

int main() {
    int t;
    scanf("%d", &t);
    while ( t-- ) {
        scanf("%d %d", &n, &m);
        a.clear();
        b.clear();
        for(int i = 1 ; i <= n ; i++) {
            int ai;
            scanf("%d", &ai);
            a.insert(ai);
        }
        for(int i = 1 ; i <= m ; i++) {
            int bi;
            scanf("%d", &bi);
            b.insert(bi);
        }
        bool poss = true;
        int msplit = 0;
        while(!b.empty() && !a.empty()) {
            int ma = *a.rbegin();
            int mb = *b.rbegin();
            if(ma > mb) {
                poss = false;
                break;
            }
            else if(ma == mb) {
                a.erase(a.find(ma));
                b.erase(b.find(mb));
            }
            else {
                if(msplit > (n - m)) {
                    poss = false;
                    break;
                }
                int u = mb / 2;
                int v = mb - u;
                b.erase(b.find(mb));
                b.insert(u);
                b.insert(v);
                msplit++;
            }
        }
        if(!a.empty() || !b.empty()) {
            poss = false;
        }
        if(poss) {
            printf("Yes\n");
        }
        else {
            printf("No\n");
        }
    }
    return 0;
}

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

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wc++11-extensions"

using namespace std;

#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define endl "\n"

#define see(statement) cout << statement << endl

#define YY see("YES")

#define NN see("NO")

#define yy see("Yes")

#define nn see("No")

#define is ==

#define isnt !=

#define None nullptr

#define fi first

#define sc second

#define Aa see("Alice")

#define AA see("ALICE")

#define Bb see("Bob")

#define BB see("BOB")

#define pb(value) push_back(value)

#define pf(value) push_front(value)

#define rb() pop_back()

#define rf() pop_front()

#define MANY {int t; cin >> t; while(t--)testcase();}

#define SINGLE {testcase();}

#define this (*this)

#define sz() size()

#define vt(type) vector<type>

#define ins(element) insert(element)

#define bg() begin()

#define bk() back()

#define fr() front()

#define ed() end()

#define mp(value1,value2) make_pair(value1,value2)

#define br() cout << endl

#define cast(element,type) static_cast<type>(element)

#define ll long long

#define cd complex<double>

#define ld long double

#define vi vector<int>

#define vll vector<ll>

#define vvi vector<vi>

#define vvll vector<vll>

#define vb vector<bool>

#define vvb vector<vb>

#define vld vector<ld>

#define pair(t1,t2) pair<t1,t2>

#define pii pair(int,int)

#define pll pair(ll,ll)

#define pld pair(ll,ld)

#define vpii vector<pii>

#define vpll vector<pll>

#define debug(statement) cerr<<"**************Debug: "<<statement<<" **************"<<endl;

#define pi 2*acos(0.0)

#define max_heap(tmp) priority_queue<tmp>

#define min_heap(tmp) priority_queue<tmp,vector<tmp>,greater<tmp> >

#define map(type1,type2) map<type1,type2>

#define umap(type1,type2) unordered_map<type1,type2>

#define mmap(type1,type2) multimap<type1,type2>

#define ummap(type1,type2) unordered_multimap<type1,type2>

#define set(type) set<type>

#define uset(type) unordered_set<type>

#define mset(type) multiset<type>

#define umset(type) unordered_multiset<type>

#define all(x) x.begin(),x.end()

#define rall(x) x.rbegin(),x.rend()

#define elif else if

#define contains(container,value) container.find(value) isnt container.end()

#define loop(type,it,init,condition,update) for(type it = init;condition;update)

#define list(first,second,container) for(auto &[first,second]: container)

#define enumerate(first,second,container) list(first,second,enumerated(container))

#define zip(first,second,container1,container2) list(first,second,zipped(container1,container2))

#define enum_sub_type(type,submask,mask,equal) loop(type,submask,mask,(equal ? submask >= 0 : submask > 0),submask = (submask - 1) & mask)

#define enum_sub(submask,mask,equal) enum_sub_type(int,submask,mask,equal)

#define rng_la(type,i,start,end,step,buffer) loop(type,i,start,i + buffer < end,i += step)

#define inc_la(i,start,end,buffer) rng_la(int,i,start,end,1,buffer)

#define slid_win(left,right,size,end) for(int left = 1, right = size; right < end; left++,right++)

#define rng_type(type,i,start,end,step) loop(type,i,start,(step > 0 ? i < end : i >= end),i += step)

#define rng(i,start,end,step) rng_type(int,i,start,end,step)

#define inc(i,start,end) rng(i,start,end,1)

#define dec(i,start,end) rng(i,start,end,-1)

#define inc_type(type,i,start,end) rng_type(type,i,start,end,1)

#define dec_type(type,i,start,end) rng_type(type,i,start,end,-1)

#define inc_la_type(type,i,start,end,buffer) rng_la(type,i,start,end,1,buffer)

#define each_key(element,container) for(const auto &element:container)

#define each(element,container) for(auto &element:container)

#define iter_for(it,container) for(auto it = container.begin();it != container.end();it++)

#define iter_rev(it,container) for(auto it = container.rbegin();it != container.rend();it++)

#define until(condition) while(!(condition))

#define slice(start,end) substr(start,end - (start) + 1)

#define char_index(c) (c >= 'A' and c <= 'Z' ? c - 'A' : c - 'a')

inline ll llmax(ll a,ll b){

    return a > b ? a : b;

}

inline ll llmin(ll a,ll b){

    return a<b?a:b;

}

template<typename tmp> inline void sorted(vt(tmp)&arr){

    sort(all(arr));

};

template <typename tmp> inline bool isSorted(vt(tmp)&arr){

    return is_sorted(all(arr));

};

template <typename tmp> inline void rsort(vt(tmp)&arr){

    sort(rall(arr));

};

template<typename tmp> inline void rev(vt(tmp)&arr){

    reverse(all(arr));

};

template <typename tmp> inline int cnt(vt(tmp)&arr,tmp value){

    return count(all(arr),value);

};

template<typename tmp1,typename tmp2>

vector<pair<tmp1,tmp2> >zipped(vector<tmp1>&arr1,vector<tmp2>&arr2){

    vector<pair<tmp1,tmp2> >ans;

    inc(i,0,arr1.sz()){

        ans.pb(make_pair(arr1[i],arr2[i]));

    }

    return ans;

}

template<typename tmp>

vt(tmp)uniqueConsec(vector<tmp>&arr){

    vt(tmp)ans;

    inc(i,0,arr.sz()){

        if(ans.sz() is 0 or ans.back() isnt arr[i]){

            ans.pb(arr[i]);

        }

    }

    return ans;

}

template<typename tmp>

vector<pair<int,tmp> >enumerated(vt(tmp)&arr){

    vector<pair<int,tmp> >ans;

    inc(i,0,arr.sz()){

        ans.pb(make_pair(i,arr[i]));

    }

    return ans;

}

template<typename tmp>

inline void readArray(vt(tmp)&arr,int start = 0){

    inc(i,start,arr.size()){

        cin >> arr[i];

    }

}

template<typename tmp>

inline void readMatrix(vt(tmp)&matrix,int r = 0,int c = 0){

    inc(i,r,matrix.size()){

        inc(j,c,matrix[i].size()){

            cin >> matrix[i][j];

        }

    }

}

template<typename tmp>

inline void writeArray(vt(tmp)&arr,int start = 0){

    inc(i,start,arr.size()){

        cout << arr[i] << " ";

    }

    br();

}

template<typename tmp>

inline tmp findMaxIndex(vt(tmp)&arr,int start = 0){

    tmp ans = start;

    inc(i,start,arr.sz()){

        ans = (arr[ans] >= arr[i] ? ans : i);

    }

    return ans;

}

template<typename tmp>

inline tmp findMinIndex(vt(tmp)&arr,int start = 0){

    tmp ans = start;

    inc(i,start,arr.sz()){

        ans = (arr[ans] <= arr[i] ? ans : i);

    }

    return ans;

}

template<typename tmp>

inline void writeMatrix(vt(vt(tmp))&matrix,int r = 0,int c = 0){

    inc(i,r,matrix.size()){

        inc(j,c,matrix[i].size()){

            cout << matrix[i][j] << " ";

        }

        br();

    }

}

template<typename tmp> tmp mod(tmp number,tmp base){

    tmp ans = number % base;

    while(ans < 0){

      ans += base;

    }

    return ans;

}

template <typename tmp> tmp modMult(tmp a,tmp b,tmp md){

    tmp ans = 0;

    while(b){

        if(b & 1){

            ans = mod(ans + a,md);

        }

        a = mod(a + a,md);

        b >>= 1;

    }

    return ans;

}

template<typename tmp> tmp powm(tmp base,tmp exponent,tmp md){

    tmp ans = 1;

    while(exponent){

        if(exponent & 1){

            ans = mod(ans * base,md);

        }

        base = mod(base * base,md);

        exponent >>= 1;

    }

    return ans;

}

template<typename tmp> tmp moduloInv4Prime(tmp base,tmp md){

    return powm(base,md - 2,md);

}

template<typename tmp>

void coordinateCompressInplace(vt(tmp)&arr){

    map(tmp,int)pos;

    inc(i,0,arr.sz()){

        pos[arr[i]] = 0;

    }

    int index = 0;

    each(entry,pos){

        entry.sc = index++;

    }

    inc(i,0,arr.sz()){

        arr[i] = pos[arr[i]];

    }

}

template<typename tmp>

vt(tmp) coordinateCompress(vt(tmp)&arr){

    vt(tmp)ans = arr;

    map(tmp,int)pos;

    inc(i,0,ans.sz()){

        pos[ans[i]] = i;

    }

    int index = 0;

    each(entry,pos){

        entry.sc = index++;

    }

    inc(i,0,ans.sz()){

        ans[i] = pos[ans[i]];

    }

    return ans;

}

template<typename tmp> inline tmp manhattanDist(pair(tmp,tmp) &first,pair(tmp,tmp) &second){

    return abs(first.fi - second.fi) + abs(first.sc - second.sc);

}

template<typename tmp> tmp gcd(tmp a, tmp b){

    if (a is 0)

        return b;

    return gcd(b % a, a);

}

template<typename tmp> tmp lcm(tmp a,tmp b){

    return (a * b) / gcd(a,b);

}

template<typename tmp> tmp ceil(tmp num,tmp den){

    return (num / den) + (mod(num,den) != 0);

}

template<typename tmp>

inline bool inBetween(tmp left,tmp mid,tmp right,bool incLeft = true,bool incRight = true){

    return (incLeft ? mid >= left : mid > left) and (incRight ? mid <= right : mid < right);

}

template<typename tmp>

vt(tmp) eratosthenesSieve(tmp upperBound){

    vt(tmp)primes;

    vb isPrime(upperBound + 1,true);

    inc_type(tmp,curr,2,upperBound + 1){

        if(isPrime[curr] is true){

            for(tmp nxt = curr * curr; nxt <= upperBound; nxt += curr){

                isPrime[nxt] = false;

            }

            primes.pb(curr);

        }

    }

    return primes;

}

const int inf = 2e9;

const ll linf = 8e18;

void testcase();

int main(){

    ios;

    MANY;

    return 0;

}

void testcase(){

    int n,m;

    cin >> n >> m;

    mset(int)a;

    max_heap(int)b;

    inc(i,0,n){

        int value;

        cin >> value;

        a.ins(value);

    }

    inc(i,0,m){

        int value;

        cin >> value;

        b.push(value);

    }

    int count =  n - m;

    while(a.empty() is false and b.empty() is false and count > 0){

        if(b.top() < *a.begin() or count is 0){

            break;

        }

        int curr = b.top(); b.pop();

        if(a.find(curr) isnt a.end()){

            a.erase(a.find(curr));

            continue;

        }

        count--;

        int first = curr / 2,second = ceil(curr,2);

        if(a.find(first) is a.end()){

            if(first > 1){

                b.push(first);

            }

        } else {

            a.erase(a.find(first));

        }

        if(a.find(second) is a.end()){

            if(second > 1){

                b.push(second);

            }

        } else {

            a.erase(a.find(second));

        }

    }

    while(b.empty() is false and a.find(b.top()) isnt a.end()){

        a.erase(a.find(b.top()));

        b.pop();

    }

    if(a.empty() is true and b.empty() is true){

        yy;

    } else {

        nn;

    }

    return;

}

#pragma GCC diagnostic pop