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

Solution 1 (runtime: 202 ms):
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;

#pragma GCC optimize("O3,unroll-loops")

using ll = long long;
using ld = long double;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

constexpr ll inf=2e18;
constexpr ld eps=1e-9;
constexpr ll mod=1e9+7;

#define F first
#define S second
#define int long long
#define pb push_back
#define all(x) x.begin(), x.end()

template<typename T>
istream& operator>>(istream &istream, vector<T> &v)
{
	for(auto &it : v)
		cin>>it;
	return istream;
}

template<typename T>
ostream& operator<<(ostream &ostream, const vector<T> &c)
{
	for(auto &it : c)
		cout<<it<<" ";
	return ostream;
}

vector<int> fact_dp(2e5+2,-1);

int binpow(int a, int b, int m=mod)
{
	if(b==0)
		return 1;

	int x = binpow(a,b/2);
	if(b&1)
		return ((x*x)%m*a)%m;
	return (x*x)%m;
}

int modinv(int x, int m=mod)
{
	return binpow(x,m-2,m);
}

int fact(int x){
	if(x<=1) return 1;
	if(fact_dp[x] != -1) return fact_dp[x];

	return fact_dp[x] = (x%mod * fact(x-1)%mod)%mod;
}

int nCr(int n, int r){
	int x = (modinv(fact(r)) * modinv(fact(n-r)))%mod;
	int y = fact(n);
	return (x*y)%mod;
}

void solve()
{
	int n, m;
	cin >> n >> m;
	priority_queue<int> a, b;
	for(int i = 0 ; i < n ; i++){
		int x ; cin >> x;
		a.push(x);
	}
	for(int i = 0 ; i < m ; i++){
		int x ; cin >> x;
		b.push(x);
	}

	while(!b.empty() && !a.empty()){

		if(a.size()<b.size()){
			cout << "NO\n";
			return;
		}

		int btop = b.top(), atop = a.top();
		b.pop();
		if(btop==atop){
			a.pop();
		}else{
			b.push(btop/2);
			b.push((btop+1)/2);
		}
	}



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

signed main()
{
#ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << setprecision(12) << fixed;

	int t=1;
	cin>>t;
	while(t--){
		solve();
	}

	return 0;
}

Solution 2 (runtime: 781 ms):
#include <bits/stdc++.h>
using namespace std;
//                                       Sk Najir
#ifndef ONLINE_JUDGE
#include "db.hpp"
#else
#define dbg(x)
#define dbg2(x, y)
#define dbg3(x, y, z)
#endif
#define IOS                      \
    ios::sync_with_stdio(false); \
    cin.tie(0);                  \
    cout.tie(0);

// pre_define
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

// shortcut type
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;

// Constants
const int MOD = 1e9 + 7;

void solve()
{
    int n, m;
    cin >> n >> m;
    multiset<ll> a, b;
    ll x;
    for (int i = 0; i < n; i++)
        cin >> x, a.insert(x);
    for (int i = 0; i < m; i++)
    {
        cin >> x;
        if (a.find(x) != a.end())
        {
            a.erase(a.find(x));
        }
        else
            b.insert(x);
    }
    if (a.size() == 0 and b.size() == 0)
    {
        cout << "YES" << endl;
        return;
    }
    ll y;
    // dbg(a);
    // dbg(b);
    while (a.size() > 1)
    {
        x = *a.begin();
        a.erase(a.begin());
        y = *a.begin();
        a.erase(a.begin());
        if (y - x > 1)
        {
            cout << "No" << endl;
            return;
        }
        if (b.find(y + x) != b.end())
        {
            b.erase(b.find(x + y));
        }
        else
            a.insert(x + y);
    }
    // dbg(a);
    // dbg(b);
    if (a.size() != 0)
    {
        cout << "No" << endl;
    }
    else if (!b.empty())
    {
        cout << "No" << endl;
    }
    else
        cout << "Yes" << endl;
}

int main()
{
    IOS;
    int tc = 1;
    cin >> tc;
    for (int t = 1; t <= tc; t++)
        solve();
}