Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
//#define int long long
using namespace std;
typedef long long ll;
const int N = 3e6 + 10, p = 2;
int T = 1;
int n, m;
int a[N], b[N];
void solve() {
    cin >> n >> m;
    map<int, int> mp;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        mp[a[i]]++;
    }
    priority_queue<int,vector<int>,greater<int>> q;
    for (int i = 1; i <= m; i++) {
        cin >> b[i];
        q.push(b[i]);
    }
    while (!q.empty()) {
        int x = q.top();
        //cout << x << endl;
        int y1 = x / 2, y2 = x - x / 2;
        if (mp[x] > 0) {
            mp[x]--;
            q.pop();
        }
        else if (mp[y1] > 0 && mp[y2] > 0 && y1 != y2) {
            mp[y1]--;
            mp[y2]--;
            q.pop();
        }
        else if (mp[y1] >= 2 && y1 == y2) {
            mp[y1] -= 2;
            q.pop();
        }
        else if (mp[y1] > 0) {
            mp[y1]--;
            q.pop();
            if(y2 > 0) q.push(y2);
        }
        else if (mp[y2] > 0) {
            mp[y2]--;
            q.pop();
            if(y1 > 0) q.push(y1);
        }
        else {
            cout << "NO" << endl;
            return;
        }
    }
    for (auto x : mp) {
        if (x.second > 0) {
            cout << "NO" << endl;
            return;
        }
    }
    cout << "YES" << endl;
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin >> T;
    while (T--) {
        solve();
        //cout << endl;
    }
    return 0;
}

Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
//#define int long long
using namespace std;
typedef long long ll;
const int N = 3e6 + 10, p = 2;
int T = 1;
int n, m;
int a[N], b[N];
void solve() {
    cin >> n >> m;
    map<int, int> mp;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        mp[a[i]]++;
    }
    priority_queue<int,vector<int>,greater<int>> q;
    for (int i = 1; i <= m; i++) {
        cin >> b[i];
        q.push(b[i]);
    }
    int cnt = 0;
    while (!q.empty()) {
        int x = q.top();
        //cout << x << endl;
        int y1 = x / 2, y2 = x - x / 2;
        if (mp[x] > 0) {
            mp[x]--;
            q.pop();
        }
        else if (mp[y1] > 0 && mp[y2] > 0 && y1 != y2) {
            mp[y1]--;
            mp[y2]--;
            q.pop();
        }
        else if (mp[y1] >= 2 && y1 == y2) {
            mp[y1] -= 2;
            q.pop();
        }
        else if (mp[y1] > 0) {
            mp[y1]--;
            q.pop();
            if(y2 > 0) q.push(y2);
        }
        else if (mp[y2] > 0) {
            mp[y2]--;
            q.pop();
            if(y1 > 0) q.push(y1);
        }
        else if(x==1) {
            cout << "NO" << endl;
            return;
        }
        else {
            if (y1) q.push(y1);
            if (y2) q.push(y2);
        }
    }
    for (auto x : mp) {
        if (x.second > 0) {
            cout << "NO" << endl;
            return;
        }
    }
    cout << "YES" << endl;
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin >> T;
    while (T--) {
        solve();
        //cout << endl;
    }
    return 0;
}