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

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define ve vector
#define fi first
#define se second
#define pb push_back
#define pll pair<int,int>
#define AC cout << "\n---------------------\n";
#define vi vector<int>
#define vii vector<vi>
//srand((unsigned int)time(NULL));        rand();
const double eps = 1e-6;
const double pi = acos(-1.0);
const int N = 1e5 + 10;
const int mod = 998244353;
const int inf = 1e18;
void solve() {
    int n, m;
    cin >> n >> m;
    vi a1(n + 1);
    vi a2(m + 1);
    int sum1 = 0, sum2 = 0;
    for (int i = 1; i <= n; i++)cin >> a1[i], sum1 += a1[i];
    for (int i = 1; i <= m; i++)cin >> a2[i], sum2 += a2[i];
    vi vis2(m + 1);
    vi vis1(n + 1);
    if (sum1 != sum2){
        cout << "NO\n";
        return ;
    }
    sort(a1.begin(), a1.end());
    sort(a2.begin(), a2.end());
    int p1 = 1;
    for (int i = 1; i <= m; i++){
        while (p1 + 1 <= n && a1[p1] < a2[i])p1++;
        if (p1 <= n && a1[p1] == a2[i]){
            vis1[p1] = 1;
            vis2[i] = 1;
            p1++;
        }
    }
    multiset<int> s1, s2;
    for (int i = 1; i <= n; i++){
        if (vis1[i] == 0)s1.insert(a1[i]);
    }
    for (int i = 1; i <= m; i++){
        if (vis2[i] == 0)s2.insert(a2[i]);
    }
    while (s2.size()){
        while(s1.size() && *s1.begin() == *s2.begin()){
            s1.erase(s1.begin());
            s2.erase(s2.begin());
        }
        if (s2.size() == 0)break;
        if (*s1.begin() > *s2.begin()){
            break;
        }
        int x = *s1.begin();
        s1.erase(s1.begin());
        int y = *s1.begin();
        s1.erase(s1.begin());
        if (abs(x - y) > 1){
            break;
        }
        s1.insert(x + y);
    }
    cout << (s2.size() == 0 ? "YES\n" : "NO\n");
}
/*

*/
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);// getline()前请使用cin.ignore();  或者关闭ios 启动getchar()
    int t1 = 1;
    cin >> t1;
    while (t1--){
        solve();
    }
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define ve vector
#define fi first
#define se second
#define pb push_back
#define pll pair<int,int>
#define AC cout << "\n---------------------\n";
#define vi vector<int>
#define vii vector<vi>
//srand((unsigned int)time(NULL));        rand();
const double eps = 1e-6;
const double pi = acos(-1.0);
const int N = 1e5 + 10;
const int mod = 998244353;
const int inf = 1e18;
void solve() {
    int n, m;
    cin >> n >> m;
    priority_queue<int> a, b;
    for (int i = 1; i <= n; i++){
        int x;
        cin >> x;
        a.push(x);
    }
    for (int i = 1; i <= m; i++){
        int x;
        cin >> x;
        b.push(x);
    }
    while (a.size()){
        if (b.size() == 0 || b.size() > a.size()){
            cout << "NO\n";
            return ;
        }
        int x = b.top();
        b.pop();
        if (x < a.top()){
            cout << "NO\n";
            return ;
        }
        if (x == a.top())a.pop();
        else {
            b.push(x / 2);
            b.push((x + 1) / 2);
        }
    }
    cout << (b.size() == 0 ? "YES\n" : "NO\n");

}
/*

*/
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);// getline()前请使用cin.ignore();  或者关闭ios 启动getchar()
    int t1 = 1;
    cin >> t1;
    while (t1--){
        solve();
    }
    return 0;
}