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

Previous submission (verdict: Time limit exceeded on test 2):
#include <bits/stdc++.h>
// #include <atcoder/segtree>
// #include <atcoder/lazysegtree>
// #include <atcoder/dsu>
using namespace std;
// using namespace atcoder;
// using mll = modll998244353;
#define lol 1000000007
#define all(c) c.begin(), c.end()
#define vi vector<ll>
#define vvi vector<vi>
#define fi first
#define se second
#define pb push_back
#define mod1 998244353
#define MAXN 2e6
#pragma GCC optimize("Ofast")
typedef long long ll;
// #define ll int
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update>
constexpr ll N = 3e5 + 1;
ll inf = 1e18;
mt19937_64 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
const ll MOD = 998244353;

struct mi
{
    ll v;
    explicit operator ll() const { return v; }
    mi() { v = 0; }
    mi(long long _v) : v(_v % MOD) { v += (v < 0) * MOD; }
};

mi &operator+=(mi &a, mi b)
{
    if ((a.v += b.v) >= MOD)
        a.v -= MOD;
    return a;
}
mi &operator-=(mi &a, mi b)
{
    if ((a.v -= b.v) < 0)
        a.v += MOD;
    return a;
}
mi operator+(mi a, mi b) { return a += b; }
mi operator-(mi a, mi b) { return a -= b; }
mi operator*(mi a, mi b) { return mi((int)a.v * b.v); }
mi &operator*=(mi &a, mi b) { return a = a * b; }
mi mpow(mi a, long long p)
{
    assert(p >= 0);
    return p == 0 ? 1 : mpow(a * a, p / 2) * (p & 1 ? a : 1);
}
mi inv(mi a)
{
    assert(a.v != 0);
    return mpow(a, MOD - 2);
}
mi operator/(mi a, mi b) { return a * inv(b); }

void solve()
{
    ll n, m;
    cin >> n >> m;
    vi arr(n), check(m);
    for (ll i = 0; i < n; i++)
        cin >> arr[i];
    for (ll i = 0; i < m; i++)
        cin >> check[i];
    sort(all(arr));
    sort(all(check));
    multiset<ll> s;
    for (ll i = 0; i < n; i++)
    {
        s.insert(arr[i]);
    }
    for (ll i = 0; i < m; i++)
    {
        ll p = 0;
        while (1)
        {
            auto it = *s.begin();
            s.erase(s.find(it));
            if (it == check[i])
            {
                p = 1;
                break;
            }
            if (s.size() == 0)
                break;
            auto it1 = *s.begin();
            s.erase(s.find(it1));
            if (it1 - it <= 1)
            {
                s.insert(it1 + it);
                continue;
            }
            else
                break;
        }
        if (!p)
        {
            cout << "No\n";
            return;
        }
    }
    if (s.size() == 0)
        cout << "Yes\n";
    else
        cout << "No\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll ft = 1;
    cin >> ft;
    while (ft--)
    {

        solve();
    }
}

// DONT GET STUCK ON ONE IDEA
//  think abt your logic thoroughly before implementing, look for all edge cases and stl structures which can cause tle/mle

Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
// #include <atcoder/segtree>
// #include <atcoder/lazysegtree>
// #include <atcoder/dsu>
using namespace std;
// using namespace atcoder;
// using mll = modll998244353;
#define lol 1000000007
#define all(c) c.begin(), c.end()
#define vi vector<ll>
#define vvi vector<vi>
#define fi first
#define se second
#define pb push_back
#define mod1 998244353
#define MAXN 2e6
#pragma GCC optimize("Ofast")
typedef long long ll;
// #define ll int
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update>
constexpr ll N = 3e5 + 1;
ll inf = 1e18;
mt19937_64 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
const ll MOD = 998244353;

struct mi
{
    ll v;
    explicit operator ll() const { return v; }
    mi() { v = 0; }
    mi(long long _v) : v(_v % MOD) { v += (v < 0) * MOD; }
};

mi &operator+=(mi &a, mi b)
{
    if ((a.v += b.v) >= MOD)
        a.v -= MOD;
    return a;
}
mi &operator-=(mi &a, mi b)
{
    if ((a.v -= b.v) < 0)
        a.v += MOD;
    return a;
}
mi operator+(mi a, mi b) { return a += b; }
mi operator-(mi a, mi b) { return a -= b; }
mi operator*(mi a, mi b) { return mi((int)a.v * b.v); }
mi &operator*=(mi &a, mi b) { return a = a * b; }
mi mpow(mi a, long long p)
{
    assert(p >= 0);
    return p == 0 ? 1 : mpow(a * a, p / 2) * (p & 1 ? a : 1);
}
mi inv(mi a)
{
    assert(a.v != 0);
    return mpow(a, MOD - 2);
}
mi operator/(mi a, mi b) { return a * inv(b); }

void solve()
{
    ll n, m;
    cin >> n >> m;
    vi arr(n), check(m);
    for (ll i = 0; i < n; i++)
        cin >> arr[i];
    for (ll i = 0; i < m; i++)
        cin >> check[i];
    sort(all(arr));
    sort(all(check));
    multiset<ll> s;
    for (ll i = 0; i < n; i++)
    {
        s.insert(arr[i]);
    }
    for (ll i = 0; i < m; i++)
    {
        ll p = 0;
        while (s.size())
        {
            auto it = *s.begin();
            s.erase(s.find(it));
            if (it == check[i])
            {
                p = 1;
                break;
            }
            if (s.size() == 0)
                break;
            auto it1 = *s.begin();
            s.erase(s.find(it1));
            if (it1 - it <= 1)
            {
                s.insert(it1 + it);
                continue;
            }
            else
                break;
        }
        if (!p)
        {
            cout << "No\n";
            return;
        }
    }
    if (s.size() == 0)
        cout << "Yes\n";
    else
        cout << "No\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll ft = 1;
    cin >> ft;
    while (ft--)
    {

        solve();
    }
}

// DONT GET STUCK ON ONE IDEA
//  think abt your logic thoroughly before implementing, look for all edge cases and stl structures which can cause tle/mle