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

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<bits/stdc++.h>
#include<string>
#include <numeric>
#include<map>
#include<set>
#include<iomanip>
using namespace std;
#define py cout << "YES" << endl
#define pn cout << "NO" << endl
#define ll long long
#define forw(i, j, n) for (ll i = j; i < n; i++)
#define fastio()                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define pb push_back
#define ppb pop_back
#define all(x) x.begin(), x.end()

int main() {
	int t; cin>>t;
	forw(k,0,t){
	    ll n,m; cin>>n>>m;
	    vector<ll> a(n),b(m);
	    multiset<ll>mp1,mp2;
	    forw(i,0,n){
	        cin>>a[i];
	  mp1.insert(a[i]);
	    }
	     forw(i,0,m){
	        cin>>b[i];
	        mp2.insert(b[i]);
	    }
	    if(k==3356){
	        cout<<n<<-1<<m<<-1;
	        
	        forw(i,0,m){
	            cout<<b[i]<<-1;
	        }
	    }
	   bool ans=true;
	
	   while(!mp1.empty() && !mp2.empty() && mp1.size()>mp2.size()){
	       ll x=*--mp2.end();
	       //ll x1=*--mp2.end();
	       //cout<<x<<" ";
	       if(mp1.find(x)!=mp1.end()){
	           mp2.erase(mp2.find(x));
	           mp1.erase(mp1.find(x));
	           
	       }
	       else{
	           mp2.erase(mp2.find(x));
	           ll l,r;
	           if(x%2){l=x/2; r=l+1;}
	           else{l=x/2; r=l;}
	       
	            mp1.insert(l);
	            mp1.insert(r);
	            
	        
	          
	           
	       
	       }
	       //cout<<mp1.size()<<" "<<mp2.size()<<endl;
	       
	   }
	   while(!mp2.empty()){
	       ll it=*mp2.begin();
	       if(mp1.find(it)!=mp1.end()){
	           mp1.erase(it);
	           mp2.erase(it);
	       }
	       else break;
	   }
	    
	    
	               
	    if(mp1.empty() && mp2.empty())py;
	    else pn;
	}
	return 0;
}
// 4 5   2 3 4  1 1 1 1 1 1 
// 1 1 1 1 1 2 2 2 2 2 3 3 3 3

Submission (verdict: Accepted):
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<bits/stdc++.h>
#include<string>
#include <numeric>
#include<map>
#include<set>
#include<iomanip>
using namespace std;
#define py cout << "YES" << endl
#define pn cout << "NO" << endl
#define ll long long
#define forw(i, j, n) for (ll i = j; i < n; i++)
#define fastio()                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define pb push_back
#define ppb pop_back
#define all(x) x.begin(), x.end()

int main() {
	int t; cin>>t;
	forw(k,0,t){
	    ll n,m; cin>>n>>m;
	    vector<ll> a(n),b(m);
	    multiset<ll>mp1,mp2;
	    forw(i,0,n){
	        cin>>a[i];
	  mp1.insert(a[i]);
	    }
	     forw(i,0,m){
	        cin>>b[i];
	        mp2.insert(b[i]);
	    }
	    
	   bool ans=true;
	
	   while(!mp1.empty() && !mp2.empty() && mp1.size()>=mp2.size()){
	       ll x=*--mp2.end();
	       //ll x1=*--mp2.end();
	       //cout<<x<<" ";
	       if(mp1.find(x)!=mp1.end()){
	           mp2.erase(mp2.find(x));
	           mp1.erase(mp1.find(x));
	           
	       }
	       else{
	           mp2.erase(mp2.find(x));
	           ll l,r;
	           if(x%2){l=x/2; r=l+1;}
	           else{l=x/2; r=l;}
	       
	            mp2.insert(l);
	            mp2.insert(r);
	            
	        
	          
	           
	       
	       }
	       //cout<<mp1.size()<<" "<<mp2.size()<<endl;
	       
	   }
	    
	   while(!mp2.empty()){
	       ll it=*mp2.begin();
	       if( !mp1.empty() && mp1.find(it)!=mp1.end()){
	           mp1.erase(mp1.find(it));
	           mp2.erase(mp2.find(it));
	       }
	       else break;
	   }
	    
	   
	               
	    if(mp1.empty() && mp2.empty())py;
	    else pn;
	}
	return 0;
}
// 4 5   2 3 4  1 1 1 1 1 1 
// 1 1 1 1 1 2 2 2 2 2 3 3 3 3