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

Solution 1 (runtime: 358 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;

#define endl '\n'
#define pb push_back
#define int long long int
#define deb(x) cerr << x << endl;
#define deb2(x, y) cerr << x << " " << y << endl;
#define deb3(x, y, z) cerr << x << " " << y << " " << z << endl;
#define f_(i, j, k) for (ll i = j; i < k; i++)
#define f__(i, j, k) for (ll i = j; i >= k; i--)

// order_of_key(k)   --> count of elements smaller than k (0 based index)
// find_by_order(k)  --> iterator to the kth element (k=0 for first element)
template <typename T> using maxpq = priority_queue<T, vector<T>>;
template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T> istream &operator>>(istream &in, vector<T> &v) { for (auto &x: v) cin >> x; return in; }
template <typename T> ostream &operator<<(ostream &out, vector<T> &v) { for (auto &x: v) cout << x << " "; return out; }
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pp;
typedef pair<int, pp> ppp;
const int INF = 1e18+5, MOD = 1e9+7;  // 998244353;
const int MAXN = 2e5+5;

int exp(int a, int b, int m) {
    if (!b) return 1LL;
    if (b%2 == 0) return exp((a*a)%m, b/2, m);
    else return (a * exp((a*a)%m, b/2, m)) % m;
}
 
int moiv(int n, int m) {
    return exp(n, m-2, m);
}

void solve()
{
    int n, m;
    cin >> n >> m;

    vector<int> a(n), b(m);
    cin >> a >> b;

    int sa = accumulate(a.begin(), a.end(), 0LL);
    int sb = accumulate(b.begin(), b.end(), 0LL);
    if (sa != sb) {
        cout << "No" << endl;
        return;
    }

    multiset<int> ma, mb;
    f_(i, 0, n) ma.insert(a[i]);
    f_(i, 0, m) mb.insert(b[i]);

    while (1) {
        if (mb.empty() || mb.size() > ma.size()) break;
        auto it = *mb.begin();
        if (ma.find(it) != ma.end()) ma.erase(ma.find(it));
        else {
            int x = it/2;
            mb.insert(x);
            if (it%2) x++;
            mb.insert(x);
        }
        mb.erase(mb.find(it));
    }

    if (mb.empty()) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int t = 1;
    cin >> t;

    while (t--)
        solve();

    return 0;
}

Solution 2 (runtime: 1031 ms):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define vi vector<int>
#define mod 1000000007
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int nn;
    cin >> nn;
    while (nn--)
    {
        int n, m;
        cin >> n >> m;

        multiset<int> a;
        for (int i = 0; i < n; i++)
        {
            int x;
            cin >> x;
            a.insert(x);
        }

        priority_queue<int> pq;
        for (int j = 0; j < m; j++)
        {
            int x;
            cin >> x;
            pq.push(x);
        }

        while (!pq.empty() && pq.size() <= a.size())
        {
            int x = pq.top();
            pq.pop();
            // cout << x << " ";
            auto it = a.lower_bound(x);
            if (it == a.end() || *it != x)
            {
                // cout << "breaking " << x << endl;
                if (x < 2)
                {
                    pq.push(-1);
                    break;
                }
                pq.push(x / 2);
                pq.push((x + 1) / 2);
            }
            else
            {
                // cout << "erasing " << x << endl;
                a.erase(it);
            }
        }

        cout << (a.empty() && pq.empty() ? "Yes\n" : "No\n");
    }
}