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

Solution 1 (runtime: 343 ms):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fr(i, a, b) for (int i = a; i < b; i++)
#define vi vector<int>
#define vc vector<char>
#define pb push_back
#define ub(x, v) upper_bound(v.begin(), v.end(), x)
#define lb(x, v) lower_bound(v.begin(), v.end(), x)
#define lbi(x, v) lower_bound(v.begin(), v.end(), x) - v.begin()
#define ubi(x, v) upper_bound(v.begin(), v.end(), x) - v.begin()
#define all(a) (a).begin(), (a).end()
int power(int a, int b)
{
    int result = 1;
    while (b)
    {
        if (b & 1)
            result = result * a;
        a = a * a;
        b >>= 1;
    }
    return result;
}
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
signed main()
{
    fast;
    int t;
    cin >> t;
    while (t--)
    {
        int n, m;
        cin >> n >> m;
        multiset<int> v;
        multiset<int> a;
        fr(i, 0, n)
        {
            int x;
            cin >> x;
            v.insert(x);
        }
        fr(i, 0, m)
        {
            int x;
            cin >> x;
            a.insert(x);
        }

        auto it1 = v.rbegin();
        // while (it1 != v.end())
        // {
        //     cout << *it1 << " ";
        //     it1++;
        // }
        auto it2 = a.rbegin();
        int flag = 0;
        while (a.size() > 0 && v.size() > 0 && v.size() >= a.size())
        {
            int x = *it1;
            int y = *it2;
            if (x == y)
            {
                v.erase(v.find(x));
                a.erase(a.find(y));
            }
            else if (x > y)
            {
                flag = 1;
                break;
            }
            else
            {
                a.erase(a.find(y));
                a.insert(y/2);
                if(y%2==0){
                    a.insert(y/2);
                }
                else{
                    a.insert(y/2 + 1);
                }
            }
        }
        if(a.size()==v.size() && v.size()==0){
            flag=0;
        }
        else{
            flag=1;
        }
        // while (it1 != v.end() && it2 != a.end())
        // {
        //     if (*(it1) == *(it2))
        //     {
        //         it1++;
        //         it2++;
        //     }
        //     else
        //     {
        //         int l = *it1;
        //         it1++;
        //         int q = *it1;
        //         if ((q - l) <= 1)
        //         {
        //             l += q;
        //             v.insert(l);
        //         }
        //         else
        //         {
        //             flag = 1;
        //             break;
        //         }
        //         it1++;
        //     }
        // }
        // if (it2 == a.end() && it1 == v.end())
        // {
        //     flag = 1;
        // }

        if (!flag)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}


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

using namespace std;

#define fast_cin()                    \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define ll long long
#define vi vector<ll>
#define all(a) a.begin(), a.end()
#define fi first
#define se second

const ll MOD = 1000000007;
struct mint
{
    int v;
    explicit operator int() const { return v; }
    mint() : v(0) {}
    mint(ll _v) : v(int(_v % MOD)) { v += (v < 0) * MOD; }
};
mint &operator+=(mint &a, mint b)
{
    if ((a.v += b.v) >= MOD)
        a.v -= MOD;
    return a;
}
mint &operator-=(mint &a, mint b)
{
    if ((a.v -= b.v) < 0)
        a.v += MOD;
    return a;
}
mint operator+(mint a, mint b) { return a += b; }
mint operator-(mint a, mint b) { return a -= b; }
mint operator*(mint a, mint b) { return mint((ll)a.v * b.v); }
mint &operator*=(mint &a, mint b) { return a = a * b; }
mint pow(mint a, ll p)
{
    assert(p >= 0);
    return p == 0 ? 1 : pow(a * a, p / 2) * (p & 1 ? a : 1);
}
mint inv(mint a)
{
    assert(a.v != 0);
    return pow(a, MOD - 2);
}
mint operator/(mint a, mint b) { return a * inv(b); }
bool operator==(mint a, mint b) { return a.v == b.v; }

void solve()
{
    int n, m;
    cin >> n >> m;
    priority_queue<int> pq1, pq2;
    while (n--)
    {
        int x;
        cin >> x;
        pq1.push(x);
    }
    while (m--)
    {
        int x;
        cin >> x;
        pq2.push(x);
    }
    while (pq1.size() && pq2.size())
    {
        if (pq1.top() == pq2.top())
        {
            pq1.pop();
            pq2.pop();
        }
        else if (pq1.top() > pq2.top() || pq1.size() < pq2.size())
        {
            cout << "no" << endl;
            return;
        }
        else
        {
            int a = pq2.top();
            pq2.pop();
            pq2.push(a / 2);
            pq2.push((a + 1) / 2);
        }
    }
    if (pq1.size() || pq2.size())
    {
        cout << "no" << endl;
        return;
    }
    cout << "yes" << endl;
}

int main()
{
    fast_cin();
    ll t;
    cin >> t;
    for (int it = 1; it <= t; it++)
    {
        solve();
    }
    return 0;
}