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

Code 1:
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <queue>
#include <bits/stdc++.h>
#define ll long long
#define int long long
#define pb push_back
#define ppb pop_back
#define mp make_pair
using namespace std;
using vpi = vector<pair<int, int>>;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
const int inf = 9e18;
const int mod = 1e9 + 7;
const int NUM = 1000030;
const int N = 10000000;
#define DEBUG(x) cerr << #x << ": " << x << '\n'
template <typename T, typename Y>
void solve()
{
    ll n, m;
    cin >> n >> m;
    vi a(n);
    vi b(m);
    cin >> a >> b;
    map<ll, ll> fa, fb;
    set<ll, greater<ll>> pa, pb;
    for (auto &&i : a)
    {
        fa[i]++;
        pa.insert(i);
    }
    for (auto &&i : b)
    {
        fb[i]++;
        pb.insert(i);
    }
    while (true)
    {
        if (pa.empty() && pb.empty())
        {
            cout << "YES" << endl;
            return;
        }
        if (pa.empty() || pb.empty())
        {
            cout << "NO" << endl;
            return;
        }
        ll mxb = *pb.begin();
        ll mxa = *pa.begin();
        if (mxa > mxb)
        {
            cout << "NO" << endl;
            return;
        }
        if (fa[mxb])
        {
            ll mn = min(fa[mxb], fb[mxb]);
            fa[mxb] -= mn;
            fb[mxb] -= mn;
            if (fa[mxb] == 0)
            {
                pa.erase(mxb);
            }
            if (fb[mxb] == 0)
            {
                pb.erase(mxb);
            }
        }
        else
        {
            ll sb = mxb / 2;
            ll lb = (mxb + 1) / 2;
            fb[sb] += fb[mxb];
            fb[lb] += fb[mxb];
            fb[mxb] = 0;
            pb.insert(sb);
            pb.insert(lb);
            if (fb[mxb] == 0)
            {
                pb.erase(mxb);
            }
        }
    }
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    cin >> t;
    while (t--)
        solve();
    return 0;
}


Code 2:
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <queue>
#include <bits/stdc++.h>
#define ll long long
#define int long long
#define pb push_back
#define ppb pop_back
#define mp make_pair
using namespace std;
using vpi = vector<pair<int, int>>;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
const int inf = 9e18;
const int mod = 1e9 + 7;
const int NUM = 1000030;
const int N = 10000000;
#define DEBUG(x) cerr << #x << ": " << x << '\n'
template <typename T, typename Y>
istream &operator>>(istream &is, pair<T, Y> &p)
{
    is >> p.first >> p.second;
    return is;
}
template <typename T, typename Y>
ostream &operator<<(ostream &os, pair<T, Y> p)
{
    os << p.first << ' ' << p.second << ' ';
    return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (auto &i : v)
        is >> i;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v)
{
    for (auto &i : v)
        os << i << ' ';
    return os;
}

void solve()
{
    ll n, m;
    cin >> n >> m;
    vi a(n);
    vi b(m);
    cin >> a >> b;
    map<ll, ll> fa, fb;
    set<ll, greater<ll>> pa, pb;
    for (auto &&i : a)
    {
        fa[i]++;
        pa.insert(i);
    }
    for (auto &&i : b)
    {
        fb[i]++;
        pb.insert(i);
    }
    while (true)
    {
        if (pa.empty() && pb.empty())
        {
            cout << "YES" << endl;
            return;
        }
        if (pa.empty() || pb.empty())
        {
            cout << "NO" << endl;
            return;
        }
        ll mxb = *pb.begin();
        ll mxa = *pa.begin();
        if (mxa > mxb)
        {
            cout << "NO" << endl;
            return;
        }
        if (fa[mxb])
        {
            ll mn = min(fa[mxb], fb[mxb]);
            fa[mxb] -= mn;
            fb[mxb] -= mn;
            if (fa[mxb] == 0)
            {
                pa.erase(mxb);
            }
            if (fb[mxb] == 0)
            {
                pb.erase(mxb);
            }
        }
        else
        {
            ll sb = mxb / 2;
            ll lb = (mxb + 1) / 2;
            fb[sb] += fb[mxb];
            fb[lb] += fb[mxb];
            fb[mxb] = 0;
            pb.insert(sb);
            pb.insert(lb);
            if (fb[mxb] == 0)
            {
                pb.erase(mxb);
            }
        }
    }
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    cin >> t;
    while (t--)
        solve();
    return 0;
}

Answer: 2