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

Previous submission (verdict: Runtime error on test 1):
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
#define int long long
#define fr(i,a,b) for(int i=a;i<b;i++)

int power(int a, int b) {
    int result = 1;
    while (b) {
        if (b & 1) 
            result = result * a;
        a = a * a;
        b >>= 1;
    }
    return result;
}
int log_a_base_b(int a , int b){
    int cnt=0;
    while(a!=0){
        a/=b;
        cnt++;
    }
    return cnt;
}
void solve(){
    int n,m;
    cin >> n >> m ;
    multiset<int> s1, s2;
    fr(i,0,n){
        int x; cin>>x;
        s1.insert(x);
    }
    fr(i,0,m){
        int x; cin>>x;
        s2.insert(x);
    }
    int ct=0;
    while(ct<n-m){
        auto it1= --s1.end();
        auto it2= --s2.end();
        if(s1.size()>0 && s2.size()>0){
            if((*it2) > (*it1)){
                s2.erase(it2);
                int x=(*it2)/2;
                int y=((*it2)+1)/2;
                s2.insert(x);
                s2.insert(y);
                ct--;
            }
            else if((*it2)==(*it1)){
                s1.erase(it1);
                s2.erase(it2);
            }
            else{
                cout<<"No"<<endl;
                return;
            }
        }
        else{
            cout<<"No"<<endl;
            return;
        }
    }
    if(s1==s2){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t; cin >> t;
    while(t--){
        solve();
    }
}

Submission (verdict: Runtime error on test 9):
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
#define int long long
#define fr(i,a,b) for(int i=a;i<b;i++)

int power(int a, int b) {
    int result = 1;
    while (b) {
        if (b & 1) 
            result = result * a;
        a = a * a;
        b >>= 1;
    }
    return result;
}
int log_a_base_b(int a , int b){
    int cnt=0;
    while(a!=0){
        a/=b;
        cnt++;
    }
    return cnt;
}
void solve(){
    int n,m;
    cin >> n >> m ;
    multiset<int> s1, s2;
    fr(i,0,n){
        int x; cin>>x;
        s1.insert(x);
    }
    fr(i,0,m){
        int x; cin>>x;
        s2.insert(x);
    }
    int ct=0;
    while(ct<n-m){
        if(s1.size()>0 && s2.size()>0){
            auto it1= --s1.end();
            auto it2= --s2.end();
            if((*it2) > (*it1)){
                s2.erase(it2);
                int x=(*it2)/2;
                int y=((*it2)+1)/2;
                s2.insert(x);
                s2.insert(y);
                ct++;
            }
            else if((*it2)==(*it1)){
                s1.erase(it1);
                s2.erase(it2);
            }
            else{
                cout<<"No"<<endl;
                return;
            }
        }
        else{
            cout<<"No"<<endl;
            return;
        }
    }
    if(s1==s2){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t; cin >> t;
    while(t--){
        solve();
    }
}