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

Solution 1 (runtime: 858 ms):
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

bool f(multiset<int>& st, int num) {
    if (num < *st.begin() ||st.empty()) return false; 
    if (st.find(num) != st.end()) {      
        st.erase(st.find(num));          
        return true;
    }
    int num1 = num / 2, num2 = num - num1;
    if (f(st, num1) && f(st, num2)) {
        return true;
    }

    return false;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        int n, m;
        cin >> n >> m;
        vector<int> a(n), b(m);
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        for (int j = 0; j < m; j++) {
            cin >> b[j];
        }

        sort(b.begin(), b.end());       
        multiset<int> st(a.begin(), a.end()); 

        bool isPossible = true;
        for (int i = 0; i < m; i++) {
            if (!f(st, b[i])) { 
                isPossible = false;
                break;
            }
        }

        if (isPossible && st.empty()) { 
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}


Solution 2 (runtime: 218 ms):
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//#define  ordered_set  tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define dipto ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define nl '\n'
#define yes             cout<<"YES"<<'\n';
#define no              cout<<"NO"<<'\n';
#define gcd(x,y)        __gcd(x,y)
#define lcm(x,y)        y*x/__gcd(x,y)
#define pb              push_back
#define nextp(x)        next_permutation(x.begin(),x.end())
#define all(ar)         ar.begin(), ar.end()
#define rall(ar)        ar.rbegin(), ar.rend()
#define Unique(x)       x.erase(unique(all(x)), x.end());
#define MAX(x)          *max_element(all(x));
#define MIN(x)          *min_element(all(x));
#define SUM(a)          accumulate(all(a),0LL);
#define fixpoint(x)     cout<<fixed<<setprecision(x)
#define clz(x)          __builtin_clz(x) // count leading zeros of 32 bits.
                                         //like 4=00000000....100(leading 29 ta)
#define ctz(x)          __builtin_ctz(x) //count trailing zeros                                         
#define popcount(x)     __builtin_popcount(x)    //count number of ones's(bits)

#define vll             vector<ll>
#define F               first
#define S               second
#define cinv(v)         for(auto& i:v)cin>>i;
#define coutv(v)        for(auto& i:v)cout<<i<<' ';

//.....BIT_MASKING...........
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}

//int dx[]={-1,+1,0,0}; //[Grid move's]
//int dy[]={0,0,-1,+1};
typedef long long ll;
//ll big_mod(ll a,ll b,ll m){if(b==0) return 1;ll x=big_mod(a,b/2,m);x=(x*x)%m;if(b%2)x=(x*a)%m;return x;}

void solve()
{
   ll n,m; cin>>n>>m;
   priority_queue<ll>p,pq;
   for(ll i=0;i<n;i++){
    ll a; cin>>a;
    p.push(a);
   }
   for(ll i=0;i<m;i++){
    ll a; cin>>a;
    pq.push(a);
   }
   while(!pq.empty()){
    ll x=pq.top(); pq.pop();
    ll y=p.top();
     if(pq.size()>p.size()){
      no
      return;
    }
    if(x==y){
      p.pop(); 
    }
    if(x>y){
       pq.push(x/2); pq.push((x+1)/2);
    }
     if(x<y){
        no
        return;
    }
   }
   if(!p.empty())  no
   else  yes

}
int main()
{
    dipto
    ll test=1;cin>>test;
    while(test--)
    {
      solve();
    }
}