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

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
 
#define ll long long int
#define MOD 1000000007
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 
using namespace std;

void solve() {
    int n, m; cin >> n >> m;

    if(m > n) {
        cout << "NO" << endl;
        return;
    }

    vector<int> a, b;
    map<int, int> freq_a, freq_b;

    for(int i=0;i<n;i++) {
        int x;
        cin >> x;
        freq_a[x]++;
    }

    for(int i=0;i<m;i++) {
        int x;
        cin >> x;
        freq_b[x]++;
    }

    for(auto& [k, v]:freq_b) {
        while(v && freq_a[k]) {
            v--;
            freq_a[k]--;
        }
    }

    for(auto [k, v]:freq_b) {
        while(v--) b.push_back(k); 
    }

    for(auto [k, v]:freq_a) {
        while(v--) a.push_back(k); 
    }

    sort(all(a)), sort(all(b));

    //for(auto x:a) cout << x << " ";
    //cout << endl;

    //for(auto x:b) cout << x << " ";
    //cout << endl;

    int i = 0, j = 0;
    bool ans = true; 

    while(i < a.size() && j < b.size()) {
        while(i< n-1 && b[j] > a[i] && a[i+1] <= a[i]+1) {
            a[i+1] += a[i];
            i++;
        }

        if(b[j] != a[i]) {
            ans = false;
            break;
        }
        i++, j++;
    }
    //cout << "i: " << i << " j: " << j << endl;
    //cout << "ans: " << ans << endl;
    if(i < a.size()|| j < b.size()) ans = false;

    if(ans) cout << "YES" << endl;
    else cout << "NO" << endl;

    return;
}

int main()
{
    fast;
 
    ll t = 1;
    cin >> t;
    while(t--) {
        solve();
    }    
 
}


Submission (verdict: Compilation error):
#include<bits/stdc++.h>
 
#define ll long long int
#define MOD 1000000007
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 
using namespace std;
using int = ll;

void solve() {
    int n, m; cin >> n >> m;

    if(m > n) {
        cout << "NO" << endl;
        return;
    }

    vector<int> a, b;
    map<int, int> freq_a, freq_b;

    for(int i=0;i<n;i++) {
        int x;
        cin >> x;
        freq_a[x]++;
    }

    for(int i=0;i<m;i++) {
        int x;
        cin >> x;
        freq_b[x]++;
    }

    for(auto& [k, v]:freq_b) {
        while(v && freq_a[k]) {
            v--;
            freq_a[k]--;
        }
    }

    for(auto [k, v]:freq_b) {
        while(v--) b.push_back(k); 
    }

    for(auto [k, v]:freq_a) {
        while(v--) a.push_back(k); 
    }

    sort(all(a)), sort(all(b));

    //for(auto x:a) cout << x << " ";
    //cout << endl;

    //for(auto x:b) cout << x << " ";
    //cout << endl;

    int i = 0, j = 0;
    bool ans = true; 

    while(i < a.size() && j < b.size()) {
        while(i< n-1 && b[j] > a[i] && a[i+1] <= a[i]+1) {
            a[i+1] += a[i];
            i++;
        }

        if(b[j] != a[i]) {
            ans = false;
            break;
        }
        i++, j++;
    }
    //cout << "i: " << i << " j: " << j << endl;
    //cout << "ans: " << ans << endl;
    if(i < a.size()|| j < b.size()) ans = false;

    if(ans) cout << "YES" << endl;
    else cout << "NO" << endl;

    return;
}

int main()
{
    fast;
 
    ll t = 1;
    cin >> t;
    while(t--) {
        solve();
    }    
 
}