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

Solution 1 (runtime: 390 ms):
/*
    Author: Mit Beladiya
    date: 22/01/2025
    Time : 16:30:47
*/

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define Bhai_Tu_Kya_Kar_Raha_Hai ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define lcm(a, b) ((a * b) / (__gcd(a, b)))
#define MOD 1000000007
#define int long long int
#define min3(a, b, c) min(a, min(b, c))
#define gcd2 __gcd(a, b)
#define pi 3.1415926536
#define all(v) (v).begin(), (v).end()
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define f(i, a, b) for (int i = a; i < b; i++)
#define endl "\n"
#define revstr(s1) reverse(s1.begin(), s1.end())
// to remove duplicate string return iterator
// s.erase(unique(s.begin(), s.end()), s.end())

// call prime for primality test
// call gcd for gcd
// call pow for binpow
//--------------------------------------------------------
//---------------------- primality Seive Syenthesis------------------------
// vector<int> lp(1e7+10,0),hp(1e7+10,0);void Seive(int a){bool is_prime[a + 1];memset(is_prime, true, sizeof(is_prime));is_prime[0] = is_prime[1] = false;for (int i = 2;  i <= a; i++){if (is_prime[i] == true){lp[i] = hp[i] = i ;for (int j = (2 * i); j <= a; j += i){is_prime[j] = false;hp[j] = i ;if(lp[j]==0){lp[j] = i ;}}}}vector<int> prime_factor;unordered_map<int,int> m;while(a > 1){int prime_fact = hp[a];while(a%prime_fact==0){a /= prime_fact ;prime_factor.pb(prime_fact);m[prime_fact]++;}}for(auto &c : m){cout<<c.first<<' '<<c.second<<endl;}cout<<endl;for(int i=1;i<=a;i++){cout<<lp[i]<<' '<<hp[i]<<endl;}}
const auto start_time = std::chrono::high_resolution_clock::now();
void mit()
{
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time - start_time;
    cerr << "Time Taken : " << diff.count() * 1000 << "\n";
}

// void fun(multiset<int> &s, int x)
// {
//     if (s.count(x))
//     {
//         s.erase(s.find(x));
//     }
//     if (x == 1 || s.empty())
//     {
//         return;
//     }
//     fun(s, x / 2);
//     fun(s, ((x + 1) / 2));
// }

void solve()
{
    int n, m;
    cin >> n >> m;
    multiset<int> s, s1;
    f(i, 0, n)
    {
        int x;
        cin >> x;
        s.insert(x);
    }
    f(i, 0, m)
    {
        int x;
        cin >> x;
        s1.insert(x);
    }

    while (!s1.empty() && s1.size() <= s.size())
    {
        int x = (*s1.rbegin());
        auto it = s.find(x);
        if (it != s.end())
        {
            s.erase(it);
            s1.erase(s1.find(x));
            continue;
        }
        s1.erase(s1.find(x));
        s1.insert(x / 2);
        s1.insert((x + 1) / 2);
    }
    if (!s1.empty() || !s.empty())
    {
        cout << "NO" << endl;
    }
    else
    {
        cout << "YES" << endl;
    }
}

signed main()
{
    Bhai_Tu_Kya_Kar_Raha_Hai;
    int t = 1;
    cin >> t;
    while (t--)
    {
        mit();
        solve();
    }
    return 0;
}

Solution 2 (runtime: 327 ms):
#include <iostream>

#include <algorithm>

#include <cstring>

#include <map>

#include <vector>

#include <queue>

using namespace std;

#define int long long

const int MAXN=1000010,inf=0x3f3f3f3f;



int n,m;

int a[MAXN],b[MAXN];

map<int,int>mp;

int check(int x){

	if (mp[x]){

		mp[x]--;

		return 1;

	}

	if (x==0)return 0;

	if (x&1)return check(x/2)&&check(x/2+1);

	return (check(x/2)&&check(x/2));

}

void solve(){

	cin>>n>>m;

	mp.clear();

	int sum=0;

	for (int i=1;i<=n;i++)cin>>a[i],mp[a[i]]++,sum+=a[i];

	for (int i=1;i<=m;i++){

		cin>>b[i];

		sum-=b[i];

	}

	if (sum!=0){

		cout<<"No"<<endl;

		return;

	}

	sort(b+1,b+1+m);

	int flag=1;

	for (int i=1;i<=m;i++){

		if (!check(b[i])){

			flag=0;

			break;

		}

	}

	if (flag){

		cout<<"Yes"<<endl;

	}

	else{

		cout<<"No"<<endl;

	}

}



signed main(){

	ios::sync_with_stdio(0);

	cin.tie(0);

	int t=1;

	cin>>t;

	while(t--)

	{

		solve();

	}

	return 0;

}