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

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#include <queue>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rem(i, n) for (ll i = n - 1; i >= 0; i--)
#define ll long long
#define vl vector<ll>
#define pi pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define mi 1000001

/*
For using ordered_set :

#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>
1. *s.find_by_order(k) --> Returns the element present at index k.
2.  s.order_of_key(k) -->  Returns the number of elements smaller than k.
*/

// #define vli(n) vector<ll> v;for (ll i = 0; i < n; i++){ ll a; cin >> a;v.pb(a);}
// #define vli(n, m)  vector<vector<ll>> v;  for (ll i = 0; i < n; i++){ vector<ll> temp;for (ll j = 0; j < m; j++){ll a;cin >> a; temp.pb(a);}v.pb(temp);}
// vector<vector<vector<ll>>>arr(n+1,vector<vector<ll>>(n+1,vector<ll>(n+1,0)));
// vector<vector<ll>>arr(n+1,vector<ll>(n+1,0));
// sort(v.begin(),v.end(), greater<ll>());


int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll q;
    cin >> q;
    while (q--)
    {
      ll n,m;
      cin>>n>>m;
      map<ll,ll>mp;
      priority_queue<ll,vector<ll>,greater<ll>>pq;
      vector<int> v;for (ll i = 0; i < n; i++){ int a; cin >> a;v.pb(a);pq.push(a);}
      vector<int> v1;for (ll i = 0; i < m; i++){ int a; cin >> a;v1.pb(a);mp[a]++;}
      while(pq.size()>=1 && mp.size()>0)
      {
        ll x=pq.top();
        if(mp.find(x)!=mp.end())
        {
            mp[x]--;
            if(mp[x]<=0)mp.erase(x);
            pq.pop();
            continue;
        }
        pq.pop();
        if(pq.size()>0)
        {
            ll y=pq.top();
            if(mp.find(y)!=mp.end())
            {
              mp[y]--;
              if(mp[y]<=0)mp.erase(y);
              pq.pop();
              if(y-x<=1)pq.push(x);
              continue;
            }
            pq.pop();
            if(y-x<=1)
            {
                pq.push(x+y);
            }
            else pq.push(y);
        }

      }
    //   cout<<mp.size()<<endl;
      if(mp.size()==0 && pq.size()==0)cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
      
    }
}

Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#include <queue>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rem(i, n) for (ll i = n - 1; i >= 0; i--)
#define ll long long
#define vl vector<ll>
#define pi pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define mi 1000001

/*
For using ordered_set :

#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>
1. *s.find_by_order(k) --> Returns the element present at index k.
2.  s.order_of_key(k) -->  Returns the number of elements smaller than k.
*/

// #define vli(n) vector<ll> v;for (ll i = 0; i < n; i++){ ll a; cin >> a;v.pb(a);}
// #define vli(n, m)  vector<vector<ll>> v;  for (ll i = 0; i < n; i++){ vector<ll> temp;for (ll j = 0; j < m; j++){ll a;cin >> a; temp.pb(a);}v.pb(temp);}
// vector<vector<vector<ll>>>arr(n+1,vector<vector<ll>>(n+1,vector<ll>(n+1,0)));
// vector<vector<ll>>arr(n+1,vector<ll>(n+1,0));
// sort(v.begin(),v.end(), greater<ll>());


int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll q;
    cin >> q;
    while (q--)
    {
      ll n,m;
      cin>>n>>m;
      map<ll,ll>mp;
      priority_queue<ll,vector<ll>,greater<ll>>pq;
      vector<int> v;for (ll i = 0; i < n; i++){ int a; cin >> a;v.pb(a);pq.push(a);}
      vector<int> v1;for (ll i = 0; i < m; i++){ int a; cin >> a;v1.pb(a);mp[a]++;}
      while(pq.size()>=1 && mp.size()>0)
      {
        ll x=pq.top();
        if(mp.find(x)!=mp.end())
        {
            mp[x]--;
            if(mp[x]<=0)mp.erase(x);
            pq.pop();
            continue;
        }
        pq.pop();
        if(pq.size()>0)
        {
            ll y=pq.top();
            if(mp.find(y)!=mp.end())
            {
              mp[y]--;
              if(mp[y]<=0)mp.erase(y);
              pq.pop();
              if(y-x<=1)pq.push(x);
              continue;
            }
            pq.pop();
            if(abs(y-x)<=1)
            {
                pq.push(x+y);
            }
            else 
            {
                pq.push(x);
                break;
            }
        }
        else
        {
           pq.push(x);
           break;
        }

      }
    //   cout<<mp.size()<<endl;
      if(mp.size()==0 && pq.size()==0)cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
      
    }
}