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

Solution 1 (runtime: 156 ms):
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
// #pragma GCC target("avx2,sse4.2,bmi,bmi2,popcnt,lzcnt")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define ll long long int
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define vi vector <int>
#define vl vector <long long int>
#define all(a) a.begin(),a.end()
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define rev(i, a, b) for (ll i = a; i >= b; i--)
#define pi 3.141592653589793238462643383279
#define TEMP_SIZE 1000005
using namespace std;
using namespace __gnu_pbds;

const long long INF = (long long)1e15;
long double eps = 1e-6;
const ll MOD = 998244353;

// orderedset

template<class T> using ordered_set =tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update> ;

// vector <int> ad[TEMP_SIZE], newgraph[TEMP_SIZE];
// ll vis[TEMP_SIZE];


vector<ll> fact;
vector<ll> inv;

long long pow(long long a, long long b)
{

    long long res = 1;
    while (b > 0)
    {
        if (b & 1)
            res = res * a;
    }
    return res;
}

void factinit(ll MOD)
{
    fact.assign(TEMP_SIZE, 0);
    fact[0] = 1;
    for (ll i = 1; i < TEMP_SIZE; i++)
    {
        fact[i] = (fact[i - 1] * i) % MOD;
    }
}

long long powm(long long a, long long b, long long m)
{

    a %= m;

    long long res = 1;
    while (b > 0)
    {

        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b /= 2;
    }

    return res;
}

void invinit()
{
    inv.assign(TEMP_SIZE, 0);
    inv[1] = 1;
    for (ll i = 2; i < TEMP_SIZE; i++)
    {
        inv[i] = powm(i, MOD - 2, MOD);
    }
}

ll nCr(ll n, ll r)
{
    return ((fact[n] * powm(fact[r], MOD - 2, MOD)) % MOD * powm(fact[n - r], MOD - 2, MOD)) % MOD;
}

bool compare(const pair<ll, ll> &i, const pair<ll, ll> &j)
{
    return i.second < j.second;
}

ll mex(vector<ll> &arr, ll N)
{
    sort(arr.begin(),arr.end());
    int mex = 0;
    for (int idx = 0; idx < N; idx++)
    {
        if (arr[idx] == mex)
        {
            mex += 1;
        }
    }

    return mex;
}

ll sod(ll n)
{
    ll sum = 0;
    while (n)
    {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

ll poss(ll a[], ll n, ll k, ll mid)
{
    map<ll, ll> f;
    rep(i, 0, n)
    {
        f[a[i]]++;
    }
    ll sum = 0, need = mid * k;
    for (auto i : f)
    {
        sum += min(mid, i.second);
    }
    if (sum >= need)
        return 1;
    else
        return 0;
}

double nthRoot(ll A, ll n)
{
    double val = round(exp(log(A) / n) * 1e9) / 1e9; 
    return val;
}

vector <bool> vis;
vector <ll> ans;
int component_index = 0;

void dfs(vector <vector <int> > &g, int node)
{
  
    vis[node] = true;
    for (auto p: g[node])
    {
        if (!vis[p])
        {
            dfs(g, p);
        }
    }
    return;
}



void solve()
{
    int n, m;
    cin>>n>>m;
    vi a(n), b(m);
    rep(i,0,n) cin>>a[i];
    rep(i,0,m) cin>>b[i];

    sort(all(a));

    priority_queue<int> pq;
    rep(i,0,m) pq.push(b[i]);

    int cnt = n-m;

    int i = n-1;
    while (!pq.empty() && i>=0)
    {
        
        int val = pq.top();
        pq.pop();

        if (val == a[i])
        {
            i--;
        }
        else if (val < a[i])
        {
            cout<<"No"<<endl;
            return;
        }
        else
        {
            if (cnt <= 0)
            {
                cout<<"No"<<endl;
                return;
            }
            else
            {
                cnt--;
            }
            pq.push(val/2);
            pq.push((val+1)/2);
        }
    }
    

    if (!pq.empty() || i>=0)
    {
        cout<<"No"<<endl;
        return;
    }

    cout<<"Yes"<<endl;
    return;
}

int main()
{
    // factinit(MOD);
    // invinit();

    #ifndef ONLINE_JUDGE
                // freopen("Input.txt", "r", stdin);
                // freopen("Output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t = 1;
    cin>>t;

    while (t--)
    {
        solve();
    }
}


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

#define int long long

#define lfor(i,num,n) for(int (i)=(num);(i)<=(n);(i)++)

#define rfor(i,n,num) for(int (i)=(n);(i)>=(num);(i)--)

#define pb push_back

#define pii pair<int,int>

#define fst first

#define sec second

#define read(a,n) vector<int> a(n+1); lfor(i,1,n) cin>>a[i];

using namespace std;

const int maxn = 2e5 + 10,mod = 1e9 + 7,INF = 1e18;





void solve(){

    int n,m;

    cin >> n >> m;

    int sum1 = 0,sum2 = 0;

    priority_queue<int> q1,q2;

    lfor(i,1,n){

        int x;

        cin >> x;

        q1.push(x);

        sum1 += x;

    }

    lfor(i,1,m){

        int x;

        cin >> x;

        q2.push(x);

        sum2 += x;

    }

    if(sum1!=sum2){

        cout <<"No\n";

        return ;

    }

    while(q2.size() < q1.size()){

        int x = q2.top();

        int y = q1.top();

        q1.pop();

        q2.pop();

        if(x == y){

            continue;

        }

        else if(x > y){

            q2.push((x + 1) / 2),q2.push(x / 2);

            q1.push(y);

        }

        else break;

    }

    int ok = 1;

    if(q2.size() != q1.size()) ok = 0;

    while(q1.size()){

        int x = q2.top();

        int y = q1.top();

        q1.pop();

        q2.pop();

        if(x != y){

            ok = 0;

            break;

        }

    }

    cout << (ok ? "Yes\n" : "No\n");

}



signed main(){

    ios::sync_with_stdio(false);

    int T;cin >> T;

    while(T--) solve();

    return 0;

}