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

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define endl '\n'
typedef pair <int,int> PII;
const int dx[] = {1,0,-1,0},dy[] = {0,-1,0,1};
template <typename T1,typename T2> bool tomax (T1 &x,T2 y) {
    if (y > x) return x = y,true;
    return false;
}
template <typename T1,typename T2> bool tomin (T1 &x,T2 y) {
    if (y < x) return x = y,true;
    return false;
}
inline int qmi(int a,int b,int p){
    int ans=1%p;
    for(;b;b>>=1){
        if(b&1) ans=(long long)ans*a%p;
        a=(long long)a*a%p;
    }
    return ans;
}
const int N=2e5+10;
#define int long long
inline int gcd(int a,int b){
	return b?gcd(b,a%b):a;
}
int n,m;
int a[N],b[N];
map<int,int> mpa;
bool get(int s){
	if(!s) return false;
	if(mpa[s]){
		mpa[s]--;
		return true;
	}
	int x,y;
	if(s%2==0){
		x=y=s/2;
	}else{
		x=s/2;
		y=x+1;
	}
	if(y==s) return false;
	if(mpa[y]) mpa[y]--;
	else return get(y);
	if(mpa[x]) mpa[x]--;
	else return get(x);
	return true;
}
void solve(){
	mpa.clear();
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		mpa[a[i]]++;
	}
	for(int i=1;i<=m;i++){
		cin>>b[i];
	}
	sort(b+1,b+m+1,greater<int>());
	bool res=true;
	for(int i=1;i<=m;i++){
		// cout<<b[i]<<" ";
		res=get(b[i]);
		if(!res) break; 
	}
	for(int i=1;i<=n;i++){
		if(mpa[a[i]]){
			res=false;
			break;
		}
	}
	if(res) cout<<"YES\n";
	else cout<<"NO\n";
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    t=1;
    cin>>t;
    while(t--){
        solve();
    }
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define endl '\n'
typedef pair <int,int> PII;
const int dx[] = {1,0,-1,0},dy[] = {0,-1,0,1};
template <typename T1,typename T2> bool tomax (T1 &x,T2 y) {
    if (y > x) return x = y,true;
    return false;
}
template <typename T1,typename T2> bool tomin (T1 &x,T2 y) {
    if (y < x) return x = y,true;
    return false;
}
inline int qmi(int a,int b,int p){
    int ans=1%p;
    for(;b;b>>=1){
        if(b&1) ans=(long long)ans*a%p;
        a=(long long)a*a%p;
    }
    return ans;
}
const int N=2e5+10;
#define int long long
inline int gcd(int a,int b){
	return b?gcd(b,a%b):a;
}
int n,m;
int a[N],b[N];
map<int,int> mpa;
bool get(int s){
	if(!s) return false;
	if(mpa[s]){
		mpa[s]--;
		return true;
	}
	int x,y;
	if(s%2==0){
		x=y=s/2;
	}else{
		x=s/2;
		y=x+1;
	}
	if(y==s) return false;
	return get(y)&&get(x);
}
void solve(){
	mpa.clear();
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		mpa[a[i]]++;
	}
	for(int i=1;i<=m;i++){
		cin>>b[i];
	}
	sort(b+1,b+m+1,greater<int>());
	bool res=true;
	for(int i=1;i<=m;i++){
		// cout<<b[i]<<" ";
		res=get(b[i]);
		if(!res) break; 
	}
	for(int i=1;i<=n;i++){
		if(mpa[a[i]]){
			// cout<<mpa[a[i]]<<endl;
			res=false;
			break;
		}
	}
	if(res) cout<<"YES\n";
	else cout<<"NO\n";
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    t=1;
    cin>>t;
    while(t--){
        solve();
    }
}