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

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl "\n"
#define take(x)       \
    for (auto &y : x) \
        cin >> y;
#define show(x)           \
    for (auto y : x)      \
        cout << y << " "; \
    cout << endl;
#define pb push_back
#define max3(a, b, c) max(max((a), (b)), (c))
#define max4(a, b, c, d) max(max((a), (b)), max((c), (d)))
#define min3(a, b, c) min(min((a), (b)), (c))
#define min4(a, b, c, d) min(min((a), (b)), min((c), (d)))
#define all(v) v.begin(), v.end()
ll M = 998244353;
ll mod = 1e9 + 7;

void solve()
{
    ll n,m;
    cin>>n>>m;
    vector<ll> a(n);
    vector<ll> b(m);
    map<ll,ll> mp;
    priority_queue<ll> pq;
    for(int i = 0;i<n;i++)
    {
        cin>>a[i];
        mp[a[i]]++;
    }
    sort(all(a));
    for(int i = 0;i<m;i++)
    {
        cin>>b[i];
        pq.push(b[i]);
    }
    int used = 0;
    while(!pq.empty() && used <= n)
    {
        if(pq.size() > n){
            cout<<"No"<<endl;
            return;
        }
        if(pq.top() < a[0])
        {
            cout<<"No"<<endl;
            return;
        }
        ll tp = pq.top();
        pq.pop();
        if(mp[tp]>=1)
        {
            mp[tp]--;
            used++;
            continue;
        }
        if(tp&1)
        {
            ll x = (tp+1)/2;
            ll y = tp - x;
            if(mp[x]>=1 && mp[y]>=1)
            {
                used += 2;
                mp[x]--;
                mp[y]--;
                continue;
            }
            else if(mp[x]>=1)
            {
                used+=1;
                mp[x]--;
                pq.push(y);
                continue;
            }
            else if(mp[y]>=1)
            {
                used+=1;
                mp[y]--;
                pq.push(x);
                continue;
            }
            else
            {
                pq.push(x);
                pq.push(y);
                continue;
            }
        }
        else
        {
            ll x = (tp+1)/2;
            ll y = tp - x;
            // cout<<x<<" "<<y<<" "<<mp[x]<<" "<<mp[y]<<endl;
            // return;
            if(mp[x]>=1 && mp[y]>=1)
            {
                used += 2;
                mp[x]--;
                mp[y]--;
                continue;
            }
            else if(mp[x]>=1)
            {
                used+=1;
                mp[x]--;
                pq.push(y);
                continue;
            }
            else if(mp[y]>=1)
            {
                used+=1;
                mp[y]--;
                pq.push(x);
                continue;
            }
            else
            {
                pq.push(x);
                pq.push(y);
                continue;
            }
        }

    }
    if(pq.empty() && n == used) 
    {
        cout<<"Yes"<<endl;
        return;
    }
    cout<<"No"<<endl;
    return;
}

int main()
{
    int tt;
    cin >> tt;
    while (tt--)
    {
        solve();
    }

    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl "\n"
#define take(x)       \
    for (auto &y : x) \
        cin >> y;
#define show(x)           \
    for (auto y : x)      \
        cout << y << " "; \
    cout << endl;
#define pb push_back
#define max3(a, b, c) max(max((a), (b)), (c))
#define max4(a, b, c, d) max(max((a), (b)), max((c), (d)))
#define min3(a, b, c) min(min((a), (b)), (c))
#define min4(a, b, c, d) min(min((a), (b)), min((c), (d)))
#define all(v) v.begin(), v.end()
ll M = 998244353;
ll mod = 1e9 + 7;

void solve()
{
    ll n,m;
    cin>>n>>m;
    vector<ll> a(n);
    vector<ll> b(m);
    map<ll,ll> mp;
    priority_queue<ll> pq;
    for(int i = 0;i<n;i++)
    {
        cin>>a[i];
        mp[a[i]]++;
    }
    sort(all(a));
    for(int i = 0;i<m;i++)
    {
        cin>>b[i];
        pq.push(b[i]);
    }
    int used = 0;
    while(!pq.empty() && used <= n)
    {
        if(pq.size() > n){
            cout<<"No"<<endl;
            return;
        }
        if(pq.top() < a[0])
        {
            cout<<"No"<<endl;
            return;
        }
        ll tp = pq.top();
        pq.pop();
        if(mp[tp]>=1)
        {
            mp[tp]--;
            used++;
            continue;
        }
        if(tp&1)
        {
            ll x = (tp+1)/2;
            ll y = tp - x;
            if(mp[x]>=1 && mp[y]>=1)
            {
                used += 2;
                mp[x]--;
                mp[y]--;
                continue;
            }
            else if(mp[x]>=1)
            {
                used+=1;
                mp[x]--;
                pq.push(y);
                // mp[y]++;
                continue;
            }
            else if(mp[y]>=1)
            {
                used+=1;
                mp[y]--;
                pq.push(x);
                // mp[x]++;
                continue;
            }
            else
            {
                pq.push(x);
                pq.push(y);
                // mp[x]++;
                // mp[y]++;
                continue;
            }
        }
        else
        {
            ll x = (tp+1)/2;
            ll y = tp - x;
            // cout<<x<<" "<<y<<" "<<mp[x]<<" "<<mp[y]<<endl;
            // return;
            if(mp[x]>=2)
            {
                used += 2;
                mp[x]--;
                mp[x]--;
                continue;
            }
            else if(mp[x]>=1)
            {
                used+=1;
                mp[x]--;
                pq.push(x);
                // mp[y]++;
                continue;
            }
            else
            {
                pq.push(x);
                pq.push(x);
                // mp[x]++;
                // mp[y]++;
                continue;
            }
        }

    }
    if(pq.empty()) 
    {
        for(auto i:mp)
        {
            if(i.second)
            {
                cout<<"No"<<endl;
                return;
            }
        }
        cout<<"Yes"<<endl;
        return;
    }
    cout<<"No"<<endl;
    return;
}

int main()
{
    int tt;
    cin >> tt;
    while (tt--)
    {
        solve();
    }

    return 0;
}