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

Solution 1 (runtime: 671 ms):

#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <cstring>
#include <bitset>
#include <random>
#include <tuple>
using namespace std;


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void print(const pair<T, V> &x) {cerr << '{'; print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define ll long long
#define fir first 
#define sec second 


template<typename T>
void printV(vector<T> &v){
    int n=v.size();
    for(int i=0;i<n;i++)
        cout<<v[i]<<" ";
    cout<<endl;
}

template<typename T,typename F>
void printP(vector<pair<T,F>> &v){
    int n = v.size();
    for(int i=0;i<n;i++)
        cout<<"{ "<<v[i].fir<<" , "<<v[i].sec<< " } ";
    cout<<endl;
}
template<typename T,typename F,typename H>
void printT(vector<tuple<T,F,H>> &v){
    int n = v.size();
    for(int i=0;i<n;i++)
        cout<<"{ "<<get<0>(v[i])<<" , "<<get<1>(v[i])<<" , "<<get<2>(v[i])<< " } ";
    cout<<endl;
}
template<typename T,typename F>
void printM(map<T,F> &mp){
    for(auto p:mp)
        cout<<"{ "<<p.fir<<" , "<<p.sec<< " } ";
    cout<<endl;
}
template<typename T>
void printSt(stack<T> stk){
     while(!stk.empty()){
     	cout<<stk.top()<<" ";
         stk.pop();
     }
     cout<<endl;
}

bool find(int x,map<int,int>& mp){
    if(mp[x]>=1){
        mp[x]--;
        if(mp[x]==0) mp.erase(x);
        return 1;
    }
    if(x==1) return 0;

    int c=x/2;
    int cc=ceil(x/2.0);

    if(find(c,mp)&&find(cc,mp))
        return 1;
    
    return 0;
}

void solve(){
    int n,m;
    cin>>n>>m;
    
    map<int,int> ma,mb;
    vector<int> temp(m);
    for(int i=0;i<n;i++){
    	int x;
    	cin>>x;
    	ma[x]++;
    }
    for(int i=0;i<m;i++){
    	int x;
    	cin>>x;
    	mb[x]++;
    	temp[i]=x;
    }
    
    for(int xx:temp){
    	int mn=min(mb[xx],ma[xx]);
    	ma[xx]-=mn;
    	mb[xx]-=mn;
    		
    	if(ma[xx]==0)ma.erase(xx);
    	if(mb[xx]==0)mb.erase(xx);
    }
    
    m=mb.size();
    n=ma.size();
    if(m==0&&n){
    	cout<<"no"<<endl;
    	return;
    }
    if(m==0&&n==0){
    	cout<<"yes"<<endl;
    	return;
    }
    
    vector<int> b;
    for(auto p:mb){
    	int lop=p.second;
    	while(lop--)b.push_back(p.first);
    }
   
    mb.clear();
    
    for(int x:b){
        bool f=find(x,ma);
        if(!f){
        	cout<<"no"<<endl;
        	return;
        }
    }
    
    for(auto p:ma){
    	if(p.sec){
    	  cout<<"no"<<endl;
    	  return;
    	}
    }
    cout<<"yes"<<endl;
}
int main(){    
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   int t=1;
   cin>>t;
   while(t--){
        solve();
    }
}


Solution 2 (runtime: 609 ms):
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
        int n, m;
        cin >> n >> m;
        vector<int> a(n);
        priority_queue<int> b;
        for (int i=0; i<n; i++)
        {
            cin >> a[i];
        }
        for (int j=0; j<m; j++)
        {
            int k;
            cin >> k;
            b.push(k);
        }
        sort(a.begin(), a.end(), greater<>());

        int i=0;
        bool f=true;
        int op=0;
        while(!b.empty())
        {
            int c = b.top();
            b.pop();
            if(i>=n)
            {
                f = false;
                break;
            }
            if (c ==a[i])
            {
                i++;
            }
            else if (a[i] > c)
            {
                f = false;
                break;
            }
            else
            {
                b.push(c/2);
                b.push((c+1)/2);
                op++;
                if (op>n-m)
                {
                    f = false;
                    break;
                }
            }

        }
        if (i<n) f = false;
        f? cout<< "Yes" << endl:cout << "No" << endl;
    }
}