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

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define LOCAL
#ifdef LOCAL
#if __has_include("C:\Users\HP\Desktop\Codeforces\template.cpp")
#include "C:\Users\HP\Desktop\Codeforces\template.cpp"
#else
#pragma message("template.cpp not found. Proceeding without it.")
#endif
#else
#define debug(...)
#endif
using namespace std;
#define out(x) cout<<x<<endl
#define in(x)  cin>>x
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define int long long
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define deb(x) cout<<"#"<<x<<endl
#define deb2(x) cout<<"^"<<x<<endl
#define rep(i,x,y) for(int i=x;i<y;i++)
#define nxt cout<<endl;
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vc vector<char>

int rec(int n,map<int,int>&mp){
    if(n==0){
        return 0;
    }
    if(mp.find(n)!=mp.end() && mp[n]>0){
        mp[n]--;
        return 1;
    }else{
        int e1 = rec((n/2),mp);
        if(e1==0) return 0;
        int e2 = rec(((n+1)/2),mp);
        if(e2==0) return 0;
        return 1;
    }
}

void solve(){
int n,m;
cin>>n>>m;
vi a(n);
rep(i,0,n){
    in(a[i]);
}
vi b(m);
rep(i,0,m){
    in(b[i]);
}
if(n==m){
    sort(all(a));
    sort(all(b));
    for(int i=0;i<n;i++){
        if(a[i]!=b[i]){
            no;
            return;
        }
    }
    yes;
    return;
}
sort(all(b));
map<int,int>mp;
rep(i,0,n){
    mp[a[i]]++;
}
for(int i=0;i<m;i++){
    int c = rec(b[i],mp);
    if(c==0){
        no;
        return;
    }
}
int flg=0;
for(int i=0;i<m;i++){
    if(mp[b[i]]>0) flg=1;
}
if(flg){
    no;
    return;
}
yes;

}

signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin>>t;
while(t--){
solve();
}
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
#define LOCAL
#ifdef LOCAL
#if __has_include("C:\Users\HP\Desktop\Codeforces\template.cpp")
#include "C:\Users\HP\Desktop\Codeforces\template.cpp"
#else
#pragma message("template.cpp not found. Proceeding without it.")
#endif
#else
#define debug(...)
#endif
using namespace std;
#define out(x) cout<<x<<endl
#define in(x)  cin>>x
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define int long long
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define deb(x) cout<<"#"<<x<<endl
#define deb2(x) cout<<"^"<<x<<endl
#define rep(i,x,y) for(int i=x;i<y;i++)
#define nxt cout<<endl;
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vc vector<char>

int rec(int n,map<int,int>&mp){
    if(n==0){
        return 0;
    }
    if(mp.find(n)!=mp.end() && mp[n]>0){
        mp[n]--;
        return 1;
    }else{
        int e1 = rec((n/2),mp);
        if(e1==0) return 0;
        int e2 = rec(((n+1)/2),mp);
        if(e2==0) return 0;
        return 1;
    }
}

void solve(){
int n,m;
cin>>n>>m;
vi a(n);
rep(i,0,n){
    in(a[i]);
}
vi b(m);
rep(i,0,m){
    in(b[i]);
}
if(n==m){
    sort(all(a));
    sort(all(b));
    for(int i=0;i<n;i++){
        if(a[i]!=b[i]){
            no;
            return;
        }
    }
    yes;
    return;
}
sort(all(b));
map<int,int>mp;
rep(i,0,n){
    mp[a[i]]++;
}
for(int i=0;i<m;i++){
    int c = rec(b[i],mp);
    if(c==0){
        no;
        return;
    }
}
int flg=0;
for(int i=0;i<n;i++){
    if(mp[a[i]]>0) flg=1;
}
if(flg){
    no;
    return;
}
yes;

}

signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin>>t;
while(t--){
solve();
}
}