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

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;

#define fastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout.precision(numeric_limits<double>::max_digits10);
#define int long long
#define ll long long
#define endl '\n'

// STL Input Outputs
#define vdef(v,n) vector<int> v((n)); for(int i=0;i<(n);i++) cin>>v[i]
#define vvdef(v,n,m) vector<vector<int>> v(n, vector<int>(m)); for(int i=0; i<n; i++) for(int j=0; j<m; j++) cin >> v[i][j];
#define vout(v) for(auto& el:v) cout<<el<<" "; cout << endl
#define vvout(vec) for(auto& v: vec){for(auto& ele: v){cout << ele <<" ";}cout << endl;}
#define mpdef(mp) map<int, int> mp
#define mpout(mp) for(auto& el: mp) { cout << el.first << " " << el.second << endl; }
#define strin(s) string s; cin >> s

// Pairs
#define pr pair<int, int>
#define ff first
#define ss second

// STL Functions Related
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()

// Inputs and Outputs
#define rd1(x) int x; cin >> x
#define rd2(x, y) int x, y; cin >> x >> y
#define rd3(x, y, z) int x, y, z; cin >> x >> y >> z
#define rd4(x, y, z, w) int x, y, z, w; cin >> x >> y >> z >> w
#define ha cout << "YES" << endl
#define na cout << "NO" << endl
#define nl cout << endl
#define aout(ans) cout << ans << endl

const int MOD = 1000000007;
const int MOD2 = 998244353;

void solve() {
    rd2(n,m);
    map<int, int> mp1, mp2;
    for(int i=0; i<n; i++){
        rd1(x);
        mp1[x]++;
    } 
    for(int i=0; i<m; i++){
        rd1(x);
        mp2[x]++;
    }
    while(!mp1.empty() && !mp2.empty()){
        int mx1 = mp1.rbegin()->first, mx2 = mp2.rbegin()->first;
        if(mx1 > mx2){
            na;
            return;
        }else if(mx1 == mx2){
            mp1[mx1]--;
            if(mp1[mx1] == 0) mp1.erase(mx1);
            mp2[mx2]--;
            if(mp2[mx2] == 0) mp2.erase(mx2);
        }else{
            int v1 = (mx2+1)/2, v2 = mx2/2;
            if(mp1.find(v1) == mp1.end() && mp1.find(v2) == mp1.end()){
                mp1[v1]--;
                if(mp1[v1] == 0) mp1.erase(v1);
                mp1[v2]--;
                if(mp1[v2] == 0) mp1.erase(v2);
                mp2[mx2]--;
                if(mp2[mx2] == 0) mp2.erase(mx2);
            }else{
                mp2[v1]++;
                mp2[v2]++;
                mp2[mx2]--;
                if(mp2[mx2] == 0) mp2.erase(mx2);
            }
        }
    }
    if(mp1.empty() && mp2.empty()) ha;
    else na;    
}

signed main() {
    fastIO;
    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;

#define fastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout.precision(numeric_limits<double>::max_digits10);
#define int long long
#define ll long long
#define endl '\n'

// STL Input Outputs
#define vdef(v,n) vector<int> v((n)); for(int i=0;i<(n);i++) cin>>v[i]
#define vvdef(v,n,m) vector<vector<int>> v(n, vector<int>(m)); for(int i=0; i<n; i++) for(int j=0; j<m; j++) cin >> v[i][j];
#define vout(v) for(auto& el:v) cout<<el<<" "; cout << endl
#define vvout(vec) for(auto& v: vec){for(auto& ele: v){cout << ele <<" ";}cout << endl;}
#define mpdef(mp) map<int, int> mp
#define mpout(mp) for(auto& el: mp) { cout << el.first << " " << el.second << endl; }
#define strin(s) string s; cin >> s

// Pairs
#define pr pair<int, int>
#define ff first
#define ss second

// STL Functions Related
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()

// Inputs and Outputs
#define rd1(x) int x; cin >> x
#define rd2(x, y) int x, y; cin >> x >> y
#define rd3(x, y, z) int x, y, z; cin >> x >> y >> z
#define rd4(x, y, z, w) int x, y, z, w; cin >> x >> y >> z >> w
#define ha cout << "YES" << endl
#define na cout << "NO" << endl
#define nl cout << endl
#define aout(ans) cout << ans << endl

const int MOD = 1000000007;
const int MOD2 = 998244353;

void solve() {
    rd2(n,m);
    map<int, int> mp1, mp2;
    for(int i=0; i<n; i++){
        rd1(x);
        mp1[x]++;
    } 
    for(int i=0; i<m; i++){
        rd1(x);
        mp2[x]++;
    }
    int count = 2*n;
    while(count--){
        if(mp1.empty() || mp2.empty()) break;
        int mx1 = mp1.rbegin()->first, mx2 = mp2.rbegin()->first;
        if(mx1 > mx2){
            na;
            return;
        }else if(mx1 == mx2){
            mp1[mx1]--;
            if(mp1[mx1] == 0) mp1.erase(mx1);
            mp2[mx2]--;
            if(mp2[mx2] == 0) mp2.erase(mx2);
        }else{
            int v1 = (mx2+1)/2, v2 = mx2/2;
            if((mp1.find(v1) != mp1.end()) && (mp1.find(v2) != mp1.end())){
                mp1[v1]--;
                if(mp1[v1] == 0) mp1.erase(v1);
                mp1[v2]--;
                if(mp1[v2] == 0) mp1.erase(v2);
                mp2[mx2]--;
                if(mp2[mx2] == 0) mp2.erase(mx2);
            }else{
                mp2[v1]++;
                mp2[v2]++;
                mp2[mx2]--;
                if(mp2[mx2] == 0) mp2.erase(mx2);
            }
        }
    }
    if(mp1.empty() && mp2.empty()) ha;
    else na;    
}

signed main() {
    fastIO;
    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}