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

Previous submission (verdict: Wrong answer on test 3):
#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>

void solve(){
int n,m;
cin>>n>>m;
vi a(n);
rep(i,0,n){
    in(a[i]);
}
vi b(m);
map<int,int>mp;
map<int,int>mp2;
rep(i,0,m){
    in(b[i]);
    mp[b[i]]++;
    mp2[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(a));
sort(all(b));
multiset<int>ms;
set<int>ind;
// debug(mp2);
for(int i=0;i<n;i++){
    ms.insert(a[i]);
}
vi a2=a;
sort(all(a2));
// debug(a);
for(int i=0;i<a2.size()-1;i++){
    if(mp2.find(a2[i])!=mp2.end() && mp2[a2[i]]>0){
        mp2[a2[i]]--;
        continue;
    }
    if(abs(a2[i+1]-a2[i])<=1){
        // deb(a[i]);
        // deb2(a[i+1]);
        int x = a2[i+1]+a2[i];
        // deb2(x);
        if(mp2.find(x)!=mp2.end() && mp2[x]>0){
            mp2[x]--;
            // deb(a[i]);
            // deb2(a[i+1]);
            auto it = ms.find(a2[i]);
            ms.erase(it);
            ms.erase(ms.find(a2[i+1]));
            ms.insert(x);
            // deb(x);
            i++;
        }else{
            ms.erase(ms.find(a2[i]));
            ms.erase(ms.find(a2[i+1]));
            ms.insert(x);
            a2[i+1]= x;
        }
    }
    // debug(a);
    // debug(ms);
}

int z=0;
if(ms.size()>b.size() || ms.size()<b.size()){
    no;
    return;
}
for(auto it:ms){
    if(it!=b[z]){
        no;
        return;
    }
    z++;
}
yes;

}

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

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();
}
}