Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 3):
#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 int long long int
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define ld long double
#define nl cout << "\n";
#define getunique(v)                                  \
    {                                                 \
        sort(v.begin(), v.end());                     \
        v.erase(unique(v.begin(), v.end()), v.end()); \
    }
#define forn(a, b) for (int i = a; i < b; i++)
#define __builtin_popcountll __builtin_popcountll
#define __builtin_clzll __builtin_clzll
#define __builtin_ctzll __builtin_ctzll
#define yesno(b) cout << ((b) ? "Yes" : "No");
#define pii pair<int, int>
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define all(a) a.begin(), a.end()
#define vi vector<int>
#define hhh cout << "here" << endl;
#define mod1 1000000007
#define mod2 998244353
const int inf = 1e17 + 1;
void solve()
{
    int n, m;
    cin >> n >> m;
    vi a(n), b(m);
    forn(0, n) cin >> a[i];
    forn(0, m) cin >> b[i];
    map<int, int> mp;
    forn(0, m) mp[b[i]]++;
    if (accumulate(all(a), 0ll) != accumulate(all(b), 0ll))
    {
        yesno(0);
        return;
    }

    priority_queue<int, vi, greater<int>> q(all(a));

    while (q.size() > 1)
    {
        int f = q.top();
        q.pop();
        int s = q.top();
        q.pop();
        if (mp.count(f))
        {
            mp[f]--;
            if (mp[f] == 0)
            {
                mp.erase(f);
            }
            q.push(s);
            continue;
        }
        if (abs(f - s) > 1)
        {
            yesno(0);
            return;
        }
        q.push(f + s);
    }
    int x = q.top();
    if (mp.count(x))
    {
        mp[x]--;
        if (mp[x] == 0){
            mp.erase(x);
        }
    }
    // for (auto it :mp)cout<<it.first<<" "<<it.second<<endl;
    yesno(mp.empty());
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
        nl;
    }
    return 0;
}

Submission (verdict: Accepted):
#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 int long long int
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define ld long double
#define nl cout << "\n";
#define getunique(v)                                  \
    {                                                 \
        sort(v.begin(), v.end());                     \
        v.erase(unique(v.begin(), v.end()), v.end()); \
    }
#define forn(a, b) for (int i = a; i < b; i++)
#define __builtin_popcountll __builtin_popcountll
#define __builtin_clzll __builtin_clzll
#define __builtin_ctzll __builtin_ctzll
#define yesno(b) cout << ((b) ? "Yes" : "No");
#define pii pair<int, int>
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define all(a) a.begin(), a.end()
#define vi vector<int>
#define hhh cout << "here" << endl;
#define mod1 1000000007
#define mod2 998244353
const int inf = 1e17 + 1;
void solve()
{
    int n, m;
    cin >> n >> m;
    vi a(n), b(m);
    forn(0, n) cin >> a[i];
    forn(0, m) cin >> b[i];
    if (accumulate(all(a), 0ll) != accumulate(all(b), 0ll))
    {
        yesno(0);
        return;
    }
    map<int, int> mp;
    forn(0, n) mp[a[i]]++;

    priority_queue<int> q(all(b));
    int cnt = 0;

    while (!q.empty())
    {
        if (cnt > n - m)
        {
            yesno(0);
            return;
        }
        int x = q.top();
        q.pop();
        if (mp.count(x))
        {
            mp[x]--;
            if (mp[x] == 0)
            {
                mp.erase(x);
            }
        }
        else
        {
            int l = x / 2;
            int r = (x + 1) / 2;
            q.push(l);
            q.push(r);
            cnt++;
        }
    }
    yesno(mp.empty());
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
        nl;
    }
    return 0;
}