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 all(x) (x).begin(), (x).end()
#define repeat(x) for(int taramtam = 0;taramtam<(x);taramtam++)
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
template<typename S, typename T> void semax(S &a, const T &b) {if (a<b) a = b;}
template<typename S, typename T> void semin(S &a, const T &b) {if (a>b) a = b;}

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) { cerr << ' ' << H;dbg_out(T...);}
#define debug(...) cerr << "(" #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)

const int INF = 1e9+100;
const int MOD = 1e9+7;
const int MOD9 = 998244353;
#define int long long
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename S>
void displayvec(vector<S> a){
    for (S thing:a){
        cout << thing << ' ';
    }
    cout << '\n';
}
template <typename S> 
void readvec(vector<S>& a){
    for (S& thing:a){
        cin>>thing;
    }
} 


int re(vector<int>& a,int i, vector<int>& memo){
    
    if (i<0)return 0;
    if (i==0)return (int) a[0]==0;
    if (memo[i]!=-1)return memo[i];
    int res =0;
    if (a[i-1]==a[i]-1)res+=re(a, i-1, memo);
    if (i!=1 && a[i-2] == a[i]-1)res+=re(a, i-2, memo);
    if (i==1 && a[i]==0)res++;
    memo[i]=res%MOD9;
    return res%MOD9;
}

void solve(){
    map<int, int> fra, frb;
    int n, m;cin>>n>>m;
    for(int i = 0;i<n;i++){
        int x;cin>>x;fra[x]++;
    }
    for(int i = 0;i<m;i++){
        int x;cin>>x;
        frb[x]++;
    }
    auto th = fra.begin();
    while (th!=--fra.end()){
        if ((*th).second>frb[(*th).first] && fra[(*th).first+1]>frb[(*th).first+1]){
            int s = (*th).second-frb[(*th).first];
            fra[(*th).first]-=s;
            fra[(*th).first+1]-=s;
            fra[(*th).first*2+1]+=s;
            if (fra[(*th).first+1]<0)break;
        }
        while ((*th).second>frb[(*th).first]){
            fra[(*th).first]-=2;
            fra[2*(*th).first]++;
        }
        th++;
    }
    cout << (fra==frb ? "Yes" : "No") << '\n';
}







signed main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    //freopen("compin.txt", "r", stdin);
	//freopen("compout.txt", "w", stdout);
    int TestCase = 1;
    cin >> TestCase;
    while(TestCase--) solve();
}

Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define repeat(x) for(int taramtam = 0;taramtam<(x);taramtam++)
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
template<typename S, typename T> void semax(S &a, const T &b) {if (a<b) a = b;}
template<typename S, typename T> void semin(S &a, const T &b) {if (a>b) a = b;}

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) { cerr << ' ' << H;dbg_out(T...);}
#define debug(...) cerr << "(" #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)

const int INF = 1e9+100;
const int MOD = 1e9+7;
const int MOD9 = 998244353;
#define int long long
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename S>
void displayvec(vector<S> a){
    for (S thing:a){
        cout << thing << ' ';
    }
    cout << '\n';
}
template <typename S> 
void readvec(vector<S>& a){
    for (S& thing:a){
        cin>>thing;
    }
} 


int re(vector<int>& a,int i, vector<int>& memo){
    
    if (i<0)return 0;
    if (i==0)return (int) a[0]==0;
    if (memo[i]!=-1)return memo[i];
    int res =0;
    if (a[i-1]==a[i]-1)res+=re(a, i-1, memo);
    if (i!=1 && a[i-2] == a[i]-1)res+=re(a, i-2, memo);
    if (i==1 && a[i]==0)res++;
    memo[i]=res%MOD9;
    return res%MOD9;
}

void solve(){
    map<int, int> fra, frb;
    int n, m;cin>>n>>m;
    for(int i = 0;i<n;i++){
        int x;cin>>x;fra[x]++;
    }
    for(int i = 0;i<m;i++){
        int x;cin>>x;
        frb[x]++;
    }
    auto th = fra.begin();
    while (th!=fra.end()){
        if ((*th).second>frb[(*th).first] && fra[(*th).first+1]>frb[(*th).first+1]){
            int s = (*th).second-frb[(*th).first];
            fra[(*th).first]-=s;
            fra[(*th).first+1]-=s;
            fra[(*th).first*2+1]+=s;
            if (fra[(*th).first+1]<0)break;
        }
        while (fra[(*th).first]>frb[(*th).first]){
            fra[(*th).first]-=2;
            fra[2*(*th).first]++;
        }
        th++;
    }
    cout << (fra==frb ? "Yes" : "No") << '\n';
}







signed main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    //freopen("compin.txt", "r", stdin);
	//freopen("compout.txt", "w", stdout);
    int TestCase = 1;
    cin >> TestCase;
    while(TestCase--) solve();
}