Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#include <iomanip>
#include <cmath>
#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<>, rb_tree_tag, tree_order_statistics_node_update>
#define ordered_multiset tree <int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;
#define pb push_back
#define F first
#define S second
#define all(a)  a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) ((int)(x).size())
#define int long long
#define popcoutn(x) __builtin_popcountll(x)
//__builtin_clzll()->leading zeros in binary
#define inf 1e18
#define el "\n"
#define Bassmala ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
vector<int> take(int n){
    vector<int>v(n);
    for(int i=0;i<n;i++)cin>>v[i];
    return v;
}
//--------------------------------global variables----------------------------------//
//---------------------------------functions----------------------------------------//
//-----------------------------------code-------------------------------------------//
void pewpew(){
    multiset<int>st;
    int n,m;cin>>n>>m;
    for(int i=0;i<n;i++){
        int a;cin>>a;
        st.insert(a);
    }
    map<int,int>mp;
    for(int i=0;i<m;i++){
        int a;cin>>a;
        mp[a]++;
    }
    while(sz(st)){
        int cur=*st.begin();
        st.erase(st.begin());
        if(mp.count(cur) and mp[cur]){
            mp[cur]--;
            continue;
        }else if(st.empty()){
            cout<<"NO"<<el;
            return;
        }
        if(sz(st) and abs(cur-*st.begin())<=1){
            cur+=*st.begin();
            st.erase(st.begin());
            st.insert(cur);

        }else break;
    }
    for(auto it:mp)if(it.S or sz(st)){
        cout<<"NO"<<el;
        return;
    }
    cout<<"YES"<<el;
// Yes
// No
// Yes
// Yes
// No
// Yes
// No
// No
// No

}
//----------------------------------------------------------------------------------//
signed main()
{
    /* ☯︎☯︎☯︎ */    Bassmala;    /* ☯︎☯︎☯︎ */
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt","w",stdout);
    int x_x = 1;
    cin >> x_x;
    while (x_x--) {
        pewpew();
    }
    return 0;
}





Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#include <iomanip>
#include <cmath>
#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<>, rb_tree_tag, tree_order_statistics_node_update>
#define ordered_multiset tree <int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;
#define pb push_back
#define F first
#define S second
#define all(a)  a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) ((int)(x).size())
#define int long long
#define popcoutn(x) __builtin_popcountll(x)
//__builtin_clzll()->leading zeros in binary
#define inf 1e18
#define el "\n"
#define Bassmala ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
vector<int> take(int n){
    vector<int>v(n);
    for(int i=0;i<n;i++)cin>>v[i];
    return v;
}
//--------------------------------global variables----------------------------------//
//---------------------------------functions----------------------------------------//
//-----------------------------------code-------------------------------------------//
void pewpew(){
    multiset<int>st,st2;
    int n,m;cin>>n>>m;
    for(int i=0;i<n;i++){
        int a;cin>>a;
        st.insert(a);
    }
    for(int i=0;i<m;i++){
        int a;cin>>a;
        st2.insert(a);
    }
    while(sz(st)){
        int cur=*st.begin();
        st.erase(st.begin());
        if(st2.count(cur)){
            st2.extract(cur);
            continue;
        }else if(st.empty()){
            cout<<"NO"<<el;
            return;
        }
        if(sz(st) and llabs(cur-*st.begin())<=1){
            cur+=*st.begin();
            st.erase(st.begin());
            st.insert(cur);
        }else break;
    }
    if(sz(st) or sz(st2))cout<<"NO"<<el;
    else
    cout<<"YES"<<el;
// Yes
// No
// Yes
// Yes
// No
// Yes
// No
// No
// No

}
//----------------------------------------------------------------------------------//
signed main()
{
    /* ☯︎☯︎☯︎ */    Bassmala;    /* ☯︎☯︎☯︎ */
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt","w",stdout);
    int x_x = 1;
    cin >> x_x;
    while (x_x--) {
        pewpew();
    }
    return 0;
}