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

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

using ll = long long;
using db = long double;
using str = string;

using pi = pair<int,int>;
using pl = pair<ll, ll>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;

#define f first
#define s second

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<db> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<bool> vb;

#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ins insert

#define rep(i,b) for(int i=0; i<(b); i++)
#define each(a,x) for(auto& a:x)

template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

const char nl = '\n';
const ll MOD = 1e9 + 7;
const ll tam = 2*1e5 + 1;

bool possible(int x, multiset<int> & a) {
    auto it = a.find(x);
    if(it != a.end()) {
        a.erase(it);
        return true;
    }
    if(x == 1) return false;
    if(x & 1) return (possible(x/2,a) && possible(x/2+1,a));
    else return (possible(x/2,a) && possible(x/2,a));
}

void solve() {
    int tt;
    cin >> tt;
    while(tt--) {
        int n,m;
        cin >> n >> m;
        multiset<int> a;
        vi b(m);
        for(int i=0; i<n; i++) {
            int x;
            cin >> x;
            a.insert(x);
        }
        each(x,b) cin >> x;

        bool isPossible = 1;
        for(int i=0; i<m; i++) {
            isPossible &= possible(b[i],a); 
        }
        isPossible &= (sz(a) == 0);

        cout << (isPossible ? "Yes" : "No") << nl;
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

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

#define pb push_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll INF = (ll)1<<62;
const ll MOD = 1e9+7;
const int iINF = 1<<30;
const double PI = 3.14159265359;

void solve(){
	int m, n;
	cin >> m >> n;
	
	multiset<int> a;
	multiset<int> b;

	int tmp;
	for(int i=0;i<m;i++){
		cin >> tmp;
		a.insert(tmp);
	}
	for(int i=0;i<n;i++){
		cin >> tmp;
		b.insert(tmp);
	}

	while(!a.empty() && !b.empty()){
		int x = *b.begin();
		if(x < *a.begin()) break;
		
		b.erase(b.begin());

		multiset<int>::iterator it = a.find(x);
		if(it == a.end()){
			int y = x/2;
			int z = (x+1)/2;

			b.insert(y);
			b.insert(z);
		} else {
			a.erase(it);
		}
	}

	if(a.empty() && b.empty()) cout << "Yes\n";
	else cout << "No\n";
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	#ifdef ONLINEJUDGE
       clock_t tStart = clock();
       freopen("input.txt","r",stdin); //can need to change file . this one for taking input
       freopen("output.txt","w",stdout); // this one for output
  	#endif

       //Your Code
       int t; cin >> t;
       while(t--){
       	solve();
       }

  	#ifdef ONLINEJUDGE
     	fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC); // this line gives your code runtime
  	#endif

    return 0;
}