Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

Previous submission (verdict: Runtime error on test 7):
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 69;
vector <int> adj[N];
int ans = 0;
int deg[N];
mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());

void Solve() 
{   
    int n, m; cin >> n >> m;
    int a[n];
    int b[m];
    multiset <int> s1;
    multiset <int> s2;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        s1.insert(a[i]);
    } 
    for(int i = 0; i < m; i++) {
        cin >> b[i];
        s2.insert(b[i]);
    }
    
        while(s2.size() != 0 && s1.size() != 0){
            int y = *(--s2.end());
            auto x = s1.find(y);
            if(x != s1.end()){
                s1.erase(x);
                s2.erase(s2.find(*x));
            }
            else{
                if(y == 1) {
                    cout << "No" << endl;
                    return;
                }
                s2.erase(s2.find(y));
                s2.insert(y/2);
                s2.insert((y+1)/2);
                if(s2.size() > s1.size()) {
                    cout << "No" << endl;
                    return;
                }
            }
        }
    
    if(s1.size() == 0 && s2.size() == 0) 
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;
}
 
int32_t main() 
{
    auto begin = std::chrono::high_resolution_clock::now();
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    cin >> t;
    for(int i = 1; i <= t; i++) 
    {
        Solve();
    }
    auto end = std::chrono::high_resolution_clock::now();
    auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
    cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n"; 
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 69;
vector <int> adj[N];
int ans = 0;
int deg[N];
mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());

void Solve() 
{   
    int n, m; cin >> n >> m;
    int a[n];
    int b[m];
    multiset <int> s1;
    multiset <int> s2;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        s1.insert(a[i]);
    } 
    for(int i = 0; i < m; i++) {
        cin >> b[i];
        s2.insert(b[i]);
    }
    
        while(s2.size() != 0 && s1.size() != 0){
            int y = *(--s2.end());
            auto x = s1.find(y);
            if(x != s1.end()){
                s1.erase(x);
                s2.erase(s2.find(y));
            }
            else{
                if(y == 1) {
                    cout << "No" << endl;
                    return;
                }
                s2.erase(s2.find(y));
                s2.insert(y/2);
                s2.insert((y+1)/2);
                if(s2.size() > n) {
                    cout << "No" << endl;
                    return;
                }
            }
        }
    
    if(s1.size() == 0 && s2.size() == 0) 
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;
    
    
}
 
int32_t main() 
{
    auto begin = std::chrono::high_resolution_clock::now();
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    cin >> t;
    for(int i = 1; i <= t; i++) 
    {
        Solve();
    }
    auto end = std::chrono::high_resolution_clock::now();
    auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
    cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n"; 
    return 0;
}