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

Previous submission (verdict: Time limit exceeded on test 1):
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#include "DEBUG/debug.h"
#else
#define debug(x)
#endif
using namespace std;
bool Delete(long long ele, multiset<long long> &a)
{
    auto it = a.find(ele);
    if (it != a.end())
    {
        a.erase(it);
        return true;
    }
    if (ele <= 1)
    {
        return false;
    }
    long long x = ele / 2;
    long long y = (ele + 1) / 2;
    return Delete(x, a) & Delete(y, a);
}
void solve()
{
    long long n, m;
    cin >> n >> m;
    vector<long long> va(n), vb(m);
    for (auto &x : va)
        cin >> x;
    for (auto &y : vb)
        cin >> y;
    sort(va.begin(), va.end());
    sort(vb.begin(), vb.end());
    multiset<long long> a;
    for (auto &e : va)
    {
        a.insert(e);
    }
    debug(a);
    debug(va);
    debug(vb);
    for (long long i = 0; i < m; i++)
    {
        long long ele = vb[i];
        if (!Delete(ele, a))
        {
            cout << "No" << endl;
            return;
        }
    }
    if(!a.empty())
    {
        cout<<"No\n";
        return;
    }
    cout << "Yes\n";
}

signed main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    long long t = 1;
    cin >> t;

    while (t--)
    {
        // cout<<9-t+1<<" ";
        solve();
    }

    return 0;
}


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#include "DEBUG/debug.h"
#else
#define debug(x)
#endif
using namespace std;
bool Delete(long long ele, multiset<long long> &a)
{
    if(a.empty()) return false;
    auto it = a.find(ele);
    if (it != a.end())
    {
        a.erase(it);
        return true;
    }
    if (ele <= 1)
    {
        return false;
    }
    long long x = ele / 2;
    long long y = (ele + 1) / 2;
    bool check1=Delete(x, a);
    if(check1==false) return false;
    bool check2=Delete(y, a);
    if(check2==false) return false;
    return true;
}
void solve()
{
    long long n, m;
    cin >> n >> m;
    vector<long long> va(n), vb(m);
    for (auto &x : va)
        cin >> x;
    for (auto &y : vb)
        cin >> y;
    sort(va.begin(), va.end());
    sort(vb.begin(), vb.end());
    multiset<long long> a, b;
    for (auto &e : va)
    {
        a.insert(e);
    }
    for(auto &e: vb)
    {
        b.insert(e);
    }
    debug(a);
    debug(b);
    while(!a.empty() && !b.empty())
    {
        auto itb=b.begin();
        auto ita=a.find(*itb);
        if(ita!=a.end())
        {
            a.erase(ita);
            b.erase(itb);
            continue;
        }


        int ele=*itb;
        int x=ele/2;
        int y=ele-x;
        if(ele<*ita)
        {
            cout<<"No"<<endl;
            return;
        }

        b.erase(itb);
        b.insert(x);
        b.insert(y);

    }
    if(!a.empty() || !b.empty()) 
    {
        cout<<"No\n";
        return;
    }
    cout<<"Yes\n";
    return;
    debug(a);
    debug(va);
    debug(vb);
    for (long long i = 0; i < m; i++)
    {
        long long ele = vb[i];
        if (!Delete(ele, a))
        {
            cout << "No" << endl;
            return;
        }
    }
    if(!a.empty())
    {
        cout<<"No\n";
        return;
    }
    cout << "Yes\n";
}

signed main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    long long t = 1;
    cin >> t;

    while (t--)
    {
        // cout<<9-t+1<<" ";
        solve();
    }

    return 0;
}