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

Previous submission (verdict: Runtime error on test 3):
#include<bits/stdc++.h>
#define ll long long
using namespace std;

bool findEl(multiset <ll> &ms, ll val, vector <ll> k){
    if (val == 1){
        auto pt = ms.find(val);
        if (pt == ms.end()){
            return false;
        }
        else{
            k.push_back(val);
            ms.erase(pt);
            return true;
        }
    } 
    auto pt = ms.find(val);
    if (pt == ms.end()){
        //could not find val
        return findEl(ms,val/2,k)&&findEl(ms,val/2 + (val&1),k);
    }else{
        ms.erase(pt);
        return true;
    }

}


int main() {

    int t;
    cin>>t;
    while(t--){
        int n,m;
        cin>>n>>m;
        
        multiset <ll> m1,m2;

        for (int i = 0; i<n; i++){
            int x;cin>>x;
            m1.insert(x);
        }
        for (int i = 0; i<m; i++){
            int x;
            cin>>x;
            auto pt = m1.find(x);
            if (pt != m1.end()){
                m1.erase(pt);
            }else{
                m2.insert(x);
            }
        }

        for (auto it = m2.begin(); it!= m2.end(); it++){
            vector <ll> k;
            bool found = findEl(m1,*it,k);
            if (found){
                auto x = it;
                m2.erase(x);
            }else{
                for (int i : k){
                    m1.insert(i);
                }
            }
        }

        if (m2.size() == 0 && m1.size() == 0){
            cout<<"yes"<<endl;
        }else{
            cout<<"no"<<endl;
        }



    }

    return 0;
}

Submission (verdict: Runtime error on test 3):
#include<bits/stdc++.h>
#define ll long long
using namespace std;

bool findEl(multiset <ll> &ms, ll val, vector <ll> k){
    if (val == 1){
        auto pt = ms.find(val);
        if (pt == ms.end()){
            return false;
        }
        else{
            k.push_back(val);
            ms.erase(pt);
            return true;
        }
    } 
    auto pt = ms.find(val);
    if (pt == ms.end()){
        //could not find val
        return findEl(ms,val/2,k)&&findEl(ms,val/2 + (val&1),k);
    }else{
        ms.erase(pt);
        return true;
    }

}


int main() {

    int t;
    cin>>t;
    while(t--){
        int n,m;
        cin>>n>>m;
        
        multiset <ll> m1,m2;

        for (int i = 0; i<n; i++){
            ll x;cin>>x;
            m1.insert(x);
        }
        for (int i = 0; i<m; i++){
            ll x;
            cin>>x;
            auto pt = m1.find(x);
            if (pt != m1.end()){
                m1.erase(pt);
            }else{
                m2.insert(x);
            }
        }

        for (auto it = m2.begin(); it!= m2.end(); it++){
            vector <ll> k;
            bool found = findEl(m1,*it,k);
            if (found){
                auto x = it;
                m2.erase(x);
            }else{
                for (ll i : k){
                    m1.insert(i);
                }
            }
        } 

        if (m1.size() == 0 && m2.size() == 0){
            cout<<"yes"<<endl;
        }else{
            cout<<"no"<<endl;
        }
    }

    return 0;
}