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

Solution 1 (runtime: 421 ms):
#ifndef __MINGW32__
#define __MINGW32__
#endif

#include <bits/stdc++.h>
using namespace std;
#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr),cout.tie(nullptr)
// #pragma GCC optimize("O3,unroll-loops,Ofast")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
/*----------------------------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------------------------*/
template<typename... T>
void see(T&... args) { ((cin >> args), ...);}
template<typename... T>
void put(T&&... args) { ((cout << args << " "), ...);}
template<typename... T>
void putl(T&&... args) { ((cout << args << " "), ...); cout<<'\n';}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {cerr << *it << "=" << a << ", "; err(++it, args...);}
/*----------------------------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------------------------*/
#define int long long
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define dbV(arr) cout << #arr << "=[ "; \
for(auto i:arr) cout << i << " "; cout << "]\n";
// #define fo(i, n) for (int i = 0; i < int(n); i++)
// #define fi(i, n, x) for (int i = x; i < int(n); i++)
// #define rep(i,n) for(int i = 0; i < (n); ++i)
// #define repF(i,a,n) for(int i = (a); i <= (n); ++i)
// #define repB(i,a,n) for(int i = (a); i >= (n); --i)
#define pii pair<int,int>
#define tiii tuple<int,int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vp vector<pii>
#define vs vector<string>
#define vb vector<bool>
#define vvi vector<vector<int>>
#define vd vector<double>
#define umii unordered_map<int,int>
#define umll unordered_map<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define seti set<int>
#define setl set<ll>
#define pb push_back
#define F first
#define S second
#define all(z) z.begin(),z.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(a) (int)a.size()
using ll = long long;

const int N = 1e5+1;
const int MOD= 1e9+7;
const int INF = 1e18;

/*----------------------------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------------------------*/

void solve() {
    int n, m; see(n,m);
    map<int,int> a;
    queue<int> b;
    int remain = n;
    for(int i = 0; i < n; i++) {
        int x; see(x);
        a[x]++;
    }
    for(int i = 0; i < m; i++) {
        int x; see(x);
        b.push(x);
    }
    
    while(!b.empty()) {
        if(sz(b) > remain) {
            putl("No");
            return;
        }
        
        int curr = b.front();
        b.pop();
        if(a[curr] > 0) {
            a[curr]--;
            remain--;
        }
        else if(curr == 1) {
            putl("No");
            return;
        }
        else {
            b.push(curr/2);
            b.push((curr/2) + (curr&1));
        }
    }
    
    putl(remain == 0 ? "Yes" : "No");
}

int32_t main(){
    FAST_IO;
    // freopen("cowtip.in","r",stdin);
    // freopen("cowtip.out","w",stdout);
    int t=1;
    cin>>t;
    // cout<<t<<'\n';
    // int c=1;

    while(t--) {
        // cout<<"Case "<<c<<": ";
        solve();
        // c++;
    }
    #ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}

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


#define int long long

signed main() {
    int t;
    cin >> t;
    while (t--) {
        int n,m;
        cin >> n >> m ;
        
    vector<int>a(n);
    vector<int>b(m);

    map<int,int>mp;
    multiset<int>st;
    for(int i=0;i<n;i++){
        cin >> a[i];
        mp[a[i]]++;
        st.insert(a[i]);
    }
    for(int i=0;i<m;i++){
        cin >> b[i];
    }
    queue<int>q;
    
    for(int i=0;i<m;i++){
        q.push(b[i]);
    }

    bool ok = true;
       
    while(!q.empty()){
        int x = q.front();
        q.pop();
        // cout << x << " ";
        // if(x == 1){
        //   continue;
        // }
        if(q.size()>st.size() || st.size()==0){
            ok = false;
            break;
        }

        if(mp[x]>0){
            mp[x]--;
            st.erase(st.find(x));
        }

        else{
            
            if(x>1){
                q.push(x/2);
                q.push((x+1)/2);
            }
            
        }
    }

    for(auto i:mp){
        if(i.second>0){
            ok = false;
            break;
        }
    }
    
    

    if(ok){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
            
    }
       
    return 0;
}