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

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) begin(x), end(x)
const int M = 1e9 + 7;

template <typename T>
istream &operator>>(istream &istream, vector<T> &v) {
    for (auto &it : v)
        cin >> it;
    return istream;
}

template <typename T>
ostream &operator<<(ostream &ostream, const vector<T> &c) {
    for (auto &it : c)
        cout << it << " ";
    return ostream;
}

void solve() {
    ll n,m;
    cin>>n>>m;
    vector<ll>a(n);
    cin>>a;
    vector<ll>b(m);
    cin>>b;
    multiset<ll>st;
    multiset<ll>st2;
    for (auto &c:a){
        st.insert(c);
    }
    vector<ll>remove;
    for (auto &c:b){
        st2.insert(c);
        if (st.find(c)!=st.end()){
            st.erase(st.find(c));
            remove.push_back(c);
        }
    }
    for (auto &c:remove){
        st2.erase(st2.find(c));
    }
    while(st.size()>0 && st2.size()>0){
        ll curr=*st.begin();
        ll tar=*st2.begin();
        // cout << curr << " " << tar << endl;
        if (curr>tar){
            cout << "No" << endl;return;
        }
        if (curr==tar){
            st.erase(st.begin());
            st2.erase(st2.begin());
        }
        else{
            st2.erase(st2.begin());
            if (tar%2==0){
                st2.insert(tar/2);
                st2.insert(tar/2);
            }
            else{
                st2.insert(tar/2);
                st2.insert((tar+1)/2);
            }
        }
    }
    if (st.size()==0 && st2.size()==0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
 
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) begin(x), end(x)
const int M = 1e9 + 7;

template <typename T>
istream &operator>>(istream &istream, vector<T> &v) {
    for (auto &it : v)
        cin >> it;
    return istream;
}

template <typename T>
ostream &operator<<(ostream &ostream, const vector<T> &c) {
    for (auto &it : c)
        cout << it << " ";
    return ostream;
}

void solve() {
    ll n,m;
    cin>>n>>m;
    vector<ll>a(n);
    cin>>a;
    vector<ll>b(m);
    cin>>b;
    multiset<ll>st;
    multiset<ll>st2;
    for (auto &c:a){
        st.insert(c);
    }
    vector<ll>remove;
    for (auto &c:b){
        st2.insert(c);
        if (st.find(c)!=st.end()){
            st.erase(st.find(c));
            remove.push_back(c);
        }
    }
    for (auto &c:remove){
        st2.erase(st2.find(c));
    }
    while(st.size()>0 && st2.size()>0){
        ll tar=*st2.begin();
        if (*st.begin()>tar){
            cout << "No" << endl;return;
        }
        if (st.find(tar)!=st.end()){
            st.erase(st.begin());
            st2.erase(st2.begin());
        }
        else{
            st2.erase(st2.begin());
            if (tar%2==0){
                st2.insert(tar/2);
                st2.insert(tar/2);
            }
            else{
                st2.insert(tar/2);
                st2.insert((tar+1)/2);
            }
        }
    }
    if (st.size()==0 && st2.size()==0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
 
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}