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

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define int long long 
using namespace std;

void solve(){
     int n , m; cin >> n >> m;
     
     multiset<int> a , b;
     
     for(int i = 0; i < n; ++i) {
         int x; cin >> x;
         a.insert(x);
     } 
     
     for(int i = 0; i < m; ++i) {
        int x; cin >> x;
        b.insert(x);
     }
     
     while(((int)b.size() > 0) and ((int)a.size() > 0)) {
        //     for(auto &it : a) {
        //     cout << it << " ";
        // } cout << " $\n";
        
        
         
        if(*a.begin() == *b.begin()) {
            a.erase(a.begin());
            b.erase(b.begin());
        } else {
            // cout << ((int)a.count(*a.begin() + 1)) << " " << ((*a.begin()) + 1) <<  "\n";
            // cout << ((int)a.count(*a.begin())) << " " << ((*a.begin())) <<  "\n";
            
            if(((int)a.size() > 1) and ((int)a.count(*a.begin()) > 1)) {
                int x = *a.begin();
                a.erase(a.begin());
                a.erase(a.find(x));
                // b.erase(b.begin());
                
                a.insert((int)2 * x);                
            } else if(((int)a.size() > 1) and (int)a.count(*a.begin() + 1)) {
                int x = *a.begin();
                a.erase(a.begin());
                a.erase(a.find(x + 1));
                // b.erase(b.begin());
                
                a.insert(((int)2 * x)  + (int)1);
            } else {
                cout << "No" << "\n"; return;
            }
        }
     }
     
    //  for(auto &it : a) {
    //       cout << it << " ";
    // } cout << " $\n";
     
     if(!(int)a.size()) {
         cout << "Yes" << "\n";
     } else {
         cout << "No" << "\n";
     }
}  
 
int32_t main(){
 
    int t = 1;
    cin >> t;
 
    while(t--){
        solve();
    } 
 
    return 0;
}

/*
Yes
No
Yes
Yes
No
Yes
No
No
No

*/


















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

void solve(){
     int n , m; cin >> n >> m;
     
     multiset<int> a , b;
     
     for(int i = 0; i < n; ++i) {
         int x; cin >> x;
         a.insert(x);
     } 
     
     for(int i = 0; i < m; ++i) {
        int x; cin >> x;
        b.insert(x);
     }
     
     while(((int)b.size() > 0) and ((int)a.size() > 0)) {
        //     for(auto &it : a) {
        //     cout << it << " ";
        // } cout << " $\n";
        
        if(*a.begin() == *b.begin()) {
            a.erase(a.begin());
            b.erase(b.begin());
        } else {
            // cout << ((int)a.count(*a.begin() + 1)) << " " << ((*a.begin()) + 1) <<  "\n";
            // cout << ((int)a.count(*a.begin())) << " " << ((*a.begin())) <<  "\n";
            
            if(((int)a.size() > 1) and ((int)a.count(*a.begin()) > 1)) {
                int x = *a.begin();
                a.erase(a.begin());
                a.erase(a.find(x));
                
                a.insert((int)2 * x);                
            } else if(((int)a.size() > 1) and (int)a.count(*a.begin() + 1)) {
                int x = *a.begin();
                a.erase(a.begin());
                a.erase(a.find(x + 1));
                
                a.insert(((int)2 * x)  + (int)1);
            } else {
                cout << "No" << "\n"; return;
            }
        }
     }
     
    //  for(auto &it : a) {
    //       cout << it << " ";
    // } cout << " $\n";
     
     if(!(int)a.size() and !(int)b.size()) {
         cout << "Yes" << "\n";
     } else {
         cout << "No" << "\n";
     }
}  
 
int32_t main(){
 
    int t = 1;
    cin >> t;
 
    while(t--){
        solve();
    } 
 
    return 0;
}

/*
Yes
No
Yes
Yes
No
Yes
No
No
No

*/