Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
// Humare saath Shri Raghunath toh
// Kis baat ki chinta :)

#include<bits/stdc++.h>
using namespace std;
//-----------------------------------------------------------------------------------------------------------------------//
typedef long long int ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;
typedef vector<pi> vp;
#define endl "\n"
#define all(_obj) _obj.begin(), _obj.end()
#define rev(i,a,b) for (ll i = b; i >= a; i--)
#define ff first
#define ss second
#define pb push_back
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define YES cout << "YES"
#define NO cout << "NO"
#define Yes cout << "Yes"
#define No cout << "No"
const ll M = 1e9 + 7;
//-----------------------------------------------------------------------------------------------------------------------//
bool cmp(pi &a, pi &b) {
    if (a.ff == b.ff) return a.ss > b.ss;
    else return a.ff > b.ff;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/
    ll t;
    cin >> t;
    for (ll h = 1; h <= t; h++) {
        //cout<<"Case #"<<h<<": ";
        ll n, m;
        cin >> n >> m;
        multiset<ll> set1;
        loop(i, 0, n) {
            ll in;
            cin >> in;
            set1.insert(in);
        }
        multiset<ll> set2;
        loop(i, 0, m) {
            ll in;
            cin >> in;
            if (set1.find(in) == set1.end()) set2.insert(in);
            else {
                set1.erase(set1.find(in));
            }
        }
        while (!set1.empty() && !set2.empty()) {
            auto it = set1.begin(), it2 = set2.begin();
            if (*it2 < *it) break;
            else if (*it2 == *it) {
                set1.erase(set1.find(*it));
                set2.erase(set2.find(*it2));
            }
            else {
                ll x = *it2;
                set2.erase(set2.find(*it2));
                if (x % 2) {
                    set2.insert(x / 2);
                    set2.insert(x / 2 + 1);
                }
                else {
                    set2.insert(x / 2);
                    set2.insert(x / 2);
                }
            }
        }
        (set1.empty() && set2.empty()) ? Yes : No;
        cout << endl;
    }
}

Submission (verdict: Runtime error on test 9):
// Humare saath Shri Raghunath toh
// Kis baat ki chinta :)

#include<bits/stdc++.h>
using namespace std;
//-----------------------------------------------------------------------------------------------------------------------//
typedef long long int ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;
typedef vector<pi> vp;
#define endl "\n"
#define all(_obj) _obj.begin(), _obj.end()
#define rev(i,a,b) for (ll i = b; i >= a; i--)
#define ff first
#define ss second
#define pb push_back
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define YES cout << "YES"
#define NO cout << "NO"
#define Yes cout << "Yes"
#define No cout << "No"
const ll M = 1e9 + 7;
//-----------------------------------------------------------------------------------------------------------------------//
bool cmp(pi &a, pi &b) {
    if (a.ff == b.ff) return a.ss > b.ss;
    else return a.ff > b.ff;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/
    ll t;
    cin >> t;
    for (ll h = 1; h <= t; h++) {
        //cout<<"Case #"<<h<<": ";
        ll n, m;
        cin >> n >> m;
        multiset<ll> set1;
        loop(i, 0, n) {
            ll in;
            cin >> in;
            set1.insert(in);
        }
        multiset<ll> set2;
        loop(i, 0, m) {
            ll in;
            cin >> in;
            if (set1.find(in) == set1.end()) set2.insert(in);
            else {
                set1.erase(set1.find(in));
            }
        }
        // for (auto x : set1) cout << x << " ";
        // cout << endl;
        // for (auto x : set2) cout << x << " ";
        // cout << endl;
        while (!set1.empty() && !set2.empty()) {
            auto it = set2.begin();
            if (set1.find(*it) != set1.end()) {
                set2.erase(it);
                set1.erase(set1.find(*it));
            }
            else {
                ll x = *it;
                if (x < *set1.begin()) break;
                else if (x % 2) {
                    set2.erase(it);
                    set2.insert(x / 2);
                    set2.insert(x / 2 + 1);
                }
                else {
                    set2.erase(it);
                    set2.insert(x / 2);
                    set2.insert(x / 2);
                }
            }
            // cout << endl;
            // for (auto x : set1) cout << x << " ";
            // cout << endl;
            // for (auto x : set2) cout << x << " ";
            // cout << endl;
        }
        (set1.empty() && set2.empty()) ? Yes : No;
        cout << endl;
    }
}