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;
#define int long long 
using ll = long long;
using pii = pair<int,int>;
#define _rep(i,a,b) for(int i = (a);i <= (b);i ++)
#define _for(i,a,b) for(int i = (a);i < (b) ;i ++)
#define pb push_back
void solve(){
	int n , m; cin >> n >> m;
	priority_queue<int,vector<int>,greater<int>> q1;
	priority_queue<int,vector<int>,greater<int>> q2;
	vector<int> a(n);
	vector<int> b(m);
	map<int,int> mp1;
	map<int,int> mp2;
	for(auto & v :a) {
		cin >> v;
		mp1[v] ++;
	}
	
	for(auto & v : b) {
		cin >> v; mp2[v] ++;
	}
	for(auto v : a){
		if(mp2[v]){
			mp2[v] --;
			continue;
		}else {
			q1.push(v);
		}
	}
	for(auto v : b){
		if(mp1[v]){
			mp1[v] --; continue;
		}else{
			q2.push(v);
		}
	}
	
	while(q2.size()){
		auto x = q2.top();
		q2.pop();
		if(q1.size() == 0){
			q2.push(x);
			break;
		}
		int u = q1.top();
		q1.pop();
		if(u == x) continue;
		if(x < u){
			q2.push(x);
			break;
		}else{
			if(q1.size() == 0){
				q2.push(x);
				break;
			}
			int v = q1.top();
			
			q1.pop();
		    q2.push(x);
			if(v - u == 1 || v - u == 0){
		    	q1.push(u + v);
			}
			else{
				break;
			}
		}
	}
	if(q1.size() == 0 && q2.size() == 0){
		cout << "Yes" << endl;
		
	}else cout << "No" << endl;
	return;
}
signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
	int _;cin >> _;
	while(_--){
		solve();
	}
	return 0;
}
/*   /\_/\
*   (= ._.)
*   / >  \>
*/



Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
#define int long long 
using ll = long long;
using pii = pair<int,int>;
#define _rep(i,a,b) for(int i = (a);i <= (b);i ++)
#define _for(i,a,b) for(int i = (a);i < (b) ;i ++)
#define pb push_back
void solve(){
	int n , m; cin >> n >> m;
	priority_queue<int,vector<int>,greater<int>> q1;
	priority_queue<int,vector<int>,greater<int>> q2;
	vector<int> a(n);
	vector<int> b(m);
	map<int,int> f;
	multiset<int> s;
	for(int i = 0; i < n; ++ i){
		int x; cin >> x;
		s.insert(x);
		f[x] ++; 
	}for(int i = 0; i < m; ++ i){
		int x; cin >> x; q2.push(x);
	}
	
	while(q2.size()){
		auto t = q2.top(); 
		if(f[t]){
			f[t] --; 
			auto t1 = s.find(t);
			s.erase(t1);
			q2.pop();
		}else{
			if(t % 2 == 0){
				if(f[t / 2] >= 2){
					f[t / 2] -= 2;
					auto t1 = s.find(t / 2);
					s.erase(t1);
					auto t2 = s.find(t / 2);
					s.erase(t2);
					q2.pop();
				}else{
					if(s.size() < 2){
						cout << "No" << endl;
						return ;
					}
					auto t1 = *s.begin();
					auto t2 = * ++ s.begin();
					s.erase(s.begin());
					s.erase(s.begin());
					f[t1] --; f[t2] --;
					if(abs(t1 - t2) <= 1) {
						f[t1 + t2] ++;
						s.insert(t1 + t2);
					}else{
						cout << "No" << endl;
						return; 
					}
				}
			}else{
				if(f[(t + 1) / 2] && f[t / 2]){
					f[(t + 1) / 2] --;
					auto t1 = s.find((t + 1) / 2);
					s.erase(t1);
					f[t / 2] --;
					t1 = s.find(t  / 2);
					s.erase(t1);
					 q2.pop();
				}else{
					if(s.size() < 2){
						cout << "No" << endl;
						return ;
					}
					auto t1 = *s.begin();
					auto t2 = * ++ s.begin();
					s.erase(s.begin());
					s.erase(s.begin());
					f[t1] --; f[t2] --;
					if(abs(t1 - t2) <= 1) {
						f[t1 + t2] ++;
						s.insert(t1 + t2);
					}else{
						cout << "No" << endl;
						return; 
					}
				}
			}
		}
	}
	if(q2.size()|| s.size()){
		cout << "No" << endl;
	}else cout << "Yes" << endl;
	return;
}
signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
	int _;cin >> _;
	while(_--){
		solve();
	}
	return 0;
}
/*   /\_/\
*   (= ._.)
*   / >  \>
*/