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

Code 1:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

#define pb push_back
#define MOD 1000000007
#define vll vector<ll>
#define pll pair<ll, ll>
#define endl "\n" 
#define all(v) v.begin(), v.end()
#define mem(a,b) memset(a, b, sizeof(a))
#define co(n) cout << n << endl
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define fr(x, n) for (int i = x; i < n; ++i)
#define fraction(x) cout << fixed << setprecision(x)
#define Baba_Yaga ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
 
const double eps = 1e-9;
const int N = 2e5+123;

ll gcd(ll a,ll b) { return __gcd(a,b); }
ll lcm(ll a,ll b) { return (a*b)/__gcd(a,b); }

int dx[] = {0, 0, +1, -1, +1, +1, -1, -1};
int dy[] = {+1, -1, 0, 0, +1, -1, +1, -1};


void solve()
{
    ll n, m; cin >> n >> m;
    map<ll, ll> m1, m2;
    set<ll> s1, s2;
    vll v1(n); fr(0, n) cin >> v1[i], m1[v1[i]]++, s1.insert(v1[i]);
    vll v2(m); fr(0, m) cin >> v2[i], m2[v2[i]]++, s2.insert(v2[i]);
    
    while(1)
    {
        if(s1.empty() && s2.empty())
        {
            yes; return;
        }
        if( (s1.empty() && s2.size() >= 1) || (s2.empty() && s1.size() >= 1))
        {
            no; return;
        }

        ll mxs1 = *(--s1.end());
        ll mxs2 = *(--s2.end());
        
        if(mxs1 > mxs2)
        {
            no; return;
        }

        if(m1[mxs2] >= 1)
        {
            ll mini = min(m1[mxs1], m2[mxs1]);
            m1[mxs1] -= mini;
            m2[mxs1] -= mini;
            if(m1[mxs1] == 0)
            {
                s1.erase(mxs1);
            }
            if(m2[mxs1] == 0)
            {
                s2.erase(mxs1);
            }
        }
        else
        {
            ll val_1 = mxs2/2;
            ll val_2 = (mxs2 + 1)/2;
            
            m2[val_1] += m2[mxs2];
            m2[val_2] += m2[mxs2];
            m2[mxs2] = 0;

            s2.insert(val_1);
            s2.insert(val_2);
            
            if(m2[mxs2] == 0)
            {
                s2.erase(mxs2);
            }

        }
    }
}

// --- Think the problem backwards ---

int main()
{
    Baba_Yaga;
    ll tc = 1; cin >> tc;
    while(tc--) solve();
}

Code 2:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

#define pb push_back
#define MOD 1000000007
#define vll vector<ll>
#define pll pair<ll, ll>
#define endl "\n" 
#define all(v) v.begin(), v.end()
#define mem(a,b) memset(a, b, sizeof(a))
#define co(n) cout << n << endl
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define fr(x, n) for (int i = x; i < n; ++i)
#define fraction(x) cout << fixed << setprecision(x)
#define Baba_Yaga ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
 
const double eps = 1e-9;
const int N = 2e5+123;

ll gcd(ll a,ll b) { return __gcd(a,b); }
ll lcm(ll a,ll b) { return (a*b)/__gcd(a,b); }

int dx[] = {0, 0, +1, -1, +1, +1, -1, -1};
int dy[] = {+1, -1, 0, 0, +1, -1, +1, -1};


void solve()
{
    ll n, m; cin >> n >> m;
    map<ll, ll> m1, m2;
    set<ll> s1, s2;
    vll v1(n); fr(0, n) cin >> v1[i], m1[v1[i]]++, s1.insert(v1[i]);
    vll v2(m); fr(0, m) cin >> v2[i], m2[v2[i]]++, s2.insert(v2[i]);
    
    while(1)
    {
        if(s1.empty() && s2.empty())
        {
            yes; return;
        }
        if( (s1.empty() && s2.size() >= 1) || (s2.empty() && s1.size() >= 1))
        {
            no; return;
        }

        ll mxs1 = *(--s1.end());
        ll mxs2 = *(--s2.end());
        
        if(mxs1 > mxs2)
        {
            no; return;
        }

        if(mxs1 == mxs2)
        {
            ll mini = min(m1[mxs1], m2[mxs1]);
            m1[mxs1] -= mini;
            m2[mxs1] -= mini;
            if(m1[mxs1] == 0)
            {
                s1.erase(mxs1);
            }
            if(m2[mxs1] == 0)
            {
                s2.erase(mxs1);
            }
        }
        else if(mxs1 < mxs2)
        {
            ll val_1 = mxs2/2;
            ll val_2 = (mxs2 + 1)/2;
            
            ll koto_bar = m2[mxs2];

            if( (m1[val_1] >= koto_bar) && (m1[val_2] >= koto_bar) )
            {
                m1[val_1] -= koto_bar;
                m1[val_2] -= koto_bar;

                if(m1[val_1] == 0)
                {
                    s1.erase(val_1);
                }
                if(m1[val_2] == 0)
                {
                    s1.erase(val_2);
                }

                s2.erase(val_1 + val_2);
            }
            else
            {
                s2.insert(val_1);
                s2.insert(val_2);
                m2[val_1]++;
                m2[val_2]++;
                m2[mxs2]--;
                s2.erase(mxs2);

            }
        }
    }
}

// --- Think the problem backwards ---

int main()
{
    Baba_Yaga;
    ll tc = 1; cin >> tc;
    while(tc--) solve();
}

Answer: 1