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

Previous submission (verdict: Runtime error on test 1):
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <vector>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <numeric>  
#include <queue>
#include <stack>
#include <limits.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort(v.rbegin(), v.rend())
#define ASORT(a, n) sort(a, a + n)
// nonstrict lower bound of x in a
#define LB(a, x) lower_bound(a.begin(), a.end(), x)
#define UB(a, x) upper_bound(a.begin(), a.end(), x)
// returns a pair of iterators representing [first, last)]
#define ER(a, x) equal_range(a.begin(), a.end(), x)

const int MOD = 1000000007;
const char nl = '\n';

template <typename Container>
void print(const Container& c) {
    for (const auto& elem : c) {
        cout << elem << " ";
    }
    cout << nl;
}

void solve() {
    int n, m; cin >> n >> m;
    multiset<int> a;
    multiset<int> b;
    int x;
    FOR(i, 0, n) {
        cin >> x; a.insert(x);
    }
    FOR(i, 0, m) {
        cin >> x; 
        if (a.count(x)) a.erase(a.find(x));
        else b.insert(x);
    }
    // remove all overlaps with a and b
    // take the maximum of b repeatedly 
    while (a.size() > b.size()) {
        x = *prev(b.end());
        if (x < *prev(a.end())) {
            // impossible to recoover
            break;
        }
        b.erase(x);
        int y = x/2;
        int z = (x+1)/2;
        if (a.count(y)) a.erase(a.find(y));    
        else b.insert(y);
        if (a.count(z)) a.erase(a.find(z));    
        else b.insert(z);
    }


    if (a.size() == 0) cout << "YES" << nl;
    else cout << "NO" << nl;

    // we will resign when size(a) > size(b)
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
 
    int t; cin >> t;
    FOR(i, 0, t) {
        solve();
    }
}


Submission (verdict: Runtime error on test 1):
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <vector>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <numeric>  
#include <queue>
#include <stack>
#include <limits.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort(v.rbegin(), v.rend())
#define ASORT(a, n) sort(a, a + n)
// nonstrict lower bound of x in a
#define LB(a, x) lower_bound(a.begin(), a.end(), x)
#define UB(a, x) upper_bound(a.begin(), a.end(), x)
// returns a pair of iterators representing [first, last)]
#define ER(a, x) equal_range(a.begin(), a.end(), x)

const int MOD = 1000000007;
const char nl = '\n';

/*
template <typename Container>
void print(const Container& c) {
    for (const auto& elem : c) {
        cout << elem << " ";
    }
    cout << nl;
}*/

void solve() {
    int n, m; cin >> n >> m;
    multiset<int> a;
    multiset<int> b;
    int x;
    FOR(i, 0, n) {
        cin >> x; a.insert(x);
    }
    FOR(i, 0, m) {
        cin >> x; 
        if (a.count(x)) a.erase(a.find(x));
        else b.insert(x);
    }
    // remove all overlaps with a and b
    // take the maximum of b repeatedly 
    while (a.size() > b.size()) {
        x = *prev(b.end());
        if (x < *prev(a.end())) {
            // impossible to recoover
            break;
        }
        b.erase(x);
        int y = x/2;
        int z = (x+1)/2;
        if (a.count(y)) a.erase(a.find(y));    
        else b.insert(y);
        if (a.count(z)) a.erase(a.find(z));    
        else b.insert(z);
    }


    if (a.size() == 0) cout << "YES" << nl;
    else cout << "NO" << nl;

    // we will resign when size(a) > size(b)
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
 
    int t; cin >> t;
    FOR(i, 0, t) {
        solve();
    }
}