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

Code 1:
#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;
}

Code 2:
#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; }

multiset<int> f(int target, multiset<int> &s)
{
    // cout << target << endl;
    if (s.find(target) != s.end())
    {
        s.erase(s.find(target));
        return {target};
    }
    if (s.empty() || target < *s.begin())
        return {-1};
    // cout << target / 2 << endl;
    multiset<int> temp = f(target / 2, s);
    if (temp.find(-1) != temp.end())
        return {-1};
    // cout << (target + 1) / 2 << endl;
    multiset<int> temp2 = f((target + 1) / 2, s);
    if (temp2.find(-1) != temp2.end())
        return {-1};
    temp.insert(all(temp2));
    return temp;
}

void solve()
{
    int n, m;
    cin >> n >> m;
    multiset<int> s1, s2, s;
    for (int i = 0; i < n; i++)
    {
        ll x;
        cin >> x;
        s1.insert(x);
    }
    for (int i = 0; i < m; i++)
    {
        ll x;
        cin >> x;
        if (s1.find(x) != s1.end())
            s1.erase(s1.find(x));
        else
            s2.insert(x);
    }
    if (m > n || (s2.size() == 0 && s1.size() > 0))
    {
        cout << "NO" << endl;
        return;
    }
    if (s1.size() == 0)
    {
        cout << "YES" << endl;
        return;
    }
    for (auto rit = s2.rbegin(); rit != s2.rend(); rit++)
    {
        s = s1;
        multiset<int> ans = f(*rit, s);
        if (ans.find(-1) != ans.end())
        {
            cout << "NO" << endl;
            return;
        }
        s1.swap(s);
    }
    // cout << s1.size() << endl;
    if (s1.size() == 0)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}

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

Answer: 1