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

Code 1:
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <random>
#include <iomanip>
#include <stack>
#include <set>
#include <map>
#include <queue>
#include <numeric>

using namespace std;

#define LF '\n';
typedef long long lli;
typedef long double ld;

map<lli,lli> a;
map<lli, lli> b;
set<lli> s;

void solve()
{
    a.clear();
    b.clear();
    s.clear();
    lli n,m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        lli x;
        cin >> x;
        a[x]++;
    }
    for (int i = 1; i <= m; i++) {
        lli x;
        cin >> x;
        b[x]++;
        s.insert(x);
    }
    lli new_m=m;
    while (!s.empty()) {
        lli curr = *s.rbegin();
        s.erase(curr);
        if (a[curr] > b[curr]) {
            cout << "NO" << LF;
            return;
        }
        lli d = (b[curr]-a[curr]);
        if (d && curr == 1) {
            cout << "NO" << LF;
            return;
        }
        if (!d)continue;
        new_m += d;
        if (new_m > n) {
            cout << "NO" << LF;
            return;
        }
        b[curr] = a[curr];
        s.insert((curr / 2));
        s.insert(((curr+1) / 2));
        b[curr / 2]+=d;
        b[(curr+1) / 2]+=d;
    }
    for (auto to : a) {
        if (b[to.first] != to.second) {
            cout << "NO" << LF;
        }
    }
    for (auto to : b) {
        if (a[to.first] != to.second) {
            cout << "NO" << LF;
        }
    }
    cout << "YES" << LF;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif 

    lli t;
    cin >> t;
    while (t--)solve();
}



Code 2:
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <random>
#include <iomanip>
#include <stack>
#include <set>
#include <map>
#include <queue>
#include <numeric>

using namespace std;

#define LF '\n';
typedef long long lli;
typedef long double ld;

map<lli,lli> a;
map<lli, lli> b;
set<lli> s;

void solve()
{
    a.clear();
    b.clear();
    s.clear();
    lli n,m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        lli x;
        cin >> x;
        a[x]++;
    }
    for (int i = 1; i <= m; i++) {
        lli x;
        cin >> x;
        b[x]++;
        s.insert(x);
    }
    lli new_m=m;
    while (!s.empty()) {
        lli curr = *s.rbegin();
        s.erase(curr);
        if (a[curr] > b[curr]) {
            cout << "NO" << LF;
            return;
        }
        lli d = (b[curr]-a[curr]);
        if (d && curr == 1) {
            cout << "NO" << LF;
            return;
        }
        if (!d)continue;
        new_m += d;
        if (new_m > n) {
            cout << "NO" << LF;
            return;
        }
        b[curr] = a[curr];
        s.insert((curr / 2));
        s.insert(((curr+1) / 2));
        b[curr / 2]+=d;
        b[(curr+1) / 2]+=d;
    }
    for (auto to : a) {
        if (b[to.first] != to.second) {
            cout << "NO" << LF;
            return;
        }
    }
    for (auto to : b) {
        if (a[to.first] != to.second) {
            cout << "NO" << LF;
            return;
        }
    }
    cout << "YES" << LF;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif 

    lli t;
    cin >> t;
    while (t--)solve();
}



Answer: 2