Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include "bits/stdc++.h"
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace std;

#define fst first
#define snd second
#define pb push_back
#define len(x) (int)x.size()
#define all(x) begin(x), end(x)
#define fore(i,a,b) for(auto i=a;i<b;i++)
#define forn(i, n) fore(i, 0, n)
#define dfor(i, n) for(auto i=n;i-->0;)
#define dbg(x) cerr << "LINE" $ __LINE__ <<":" $ #x << "=" << x << endl;
#define raya cerr << "\n-----------------------------------------------------------\n"
#define $ <<" "<<

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T,U> &p){
    os << '(' << p.first $ p.second << ')';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
    os << "[";
    forn(i, len(v)){
        if(i) os << ", ";
        os << v[i];
    }
    os << "]";
    return os;
}

typedef long long ll;

void solve(){
    int n, m;
    cin>>n>>m;
    vector<int> a(n), b(m);
    forn(i,n) cin>>a[i];
    forn(i,m) cin>>b[i];
    sort(all(b));
    priority_queue<int,vector<int>,greater<int>> pq;
    forn(i,n) pq.push(a[i]);
    int j=0;
    vector<int> c;
    while(len(pq) > 1 && j < m){
        int x = pq.top();
        pq.pop();
        if(x == b[j]){
            c.pb(x);
            j++;
        }
        else{
            int y = pq.top();
            pq.pop();
            if(y - x > 1){
                cout<<"NO\n";
                return;
            }
            pq.push(x+y);
        }
    }
    while(len(pq)){
        c.pb(pq.top());
        pq.pop();
    }
    if(c == b) cout << "YES\n";
    else cout << "NO\n";
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int tt;
    cin>>tt;
    while(tt--) solve();
    return 0;
}



Submission (verdict: Wrong answer on test 1):
#include "bits/stdc++.h"
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace std;

#define fst first
#define snd second
#define pb push_back
#define len(x) (int)x.size()
#define all(x) begin(x), end(x)
#define fore(i,a,b) for(auto i=a;i<b;i++)
#define forn(i, n) fore(i, 0, n)
#define dfor(i, n) for(auto i=n;i-->0;)
#define dbg(x) cerr << "LINE" $ __LINE__ <<":" $ #x << "=" << x << endl;
#define raya cerr << "\n-----------------------------------------------------------\n"
#define $ <<" "<<

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T,U> &p){
    os << '(' << p.first $ p.second << ')';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
    os << "[";
    forn(i, len(v)){
        if(i) os << ", ";
        os << v[i];
    }
    os << "]";
    return os;
}

typedef long long ll;

void solve(){
    int n, m;
    cin>>n>>m;
    vector<int> a(n), b(m);
    forn(i,n) cin>>a[i];
    forn(i,m) cin>>b[i];
    map<int,int> cnt;
    forn(i,n) cnt[a[i]]++;
    queue<int> q;
    forn(i,m) q.push(b[i]);
    while(!q.empty()){
        if(len(q) > n){
            cout<<"NO\n";
            return;
        }
        int x = q.front();
        q.pop();
        if(cnt.find(x) != cnt.end()){
            cnt[x]--, n--;
            if(cnt[x] == 0) cnt.erase(x);
            continue;
        }
        if(x == 1){
            cout<<"NO\n";
            return;
        }
        
        if(x/2 < cnt.begin()->fst){
            cout<<"N0\n";
            return;
        }
        if(x%2==0){
            q.push(x/2);
            q.push(x/2);
        }
        else{
            q.push((x-1)/2);
            q.push((x-1)/2 + 1);
        }
    }
    if(len(cnt)>0) cout<<"NO\n";
    else cout<<"YES\n";
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int tt;
    cin>>tt;
    while(tt--) solve();
    return 0;
}