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

Previous submission (verdict: Wrong answer on test 2):
# include<bits/stdc++.h>



using namespace std;



#define endl "\n"

#define ll long long int

#define pb push_back

#define rvec_sort(v) sort(v.begin(), v.end(), greater<int>());

#define vec_sort(v) sort(v.begin(),v.end());

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)

#define vec_sum(v) accumulate(v.begin(),v.end(),0ll)

#define PI 3.1415926535897932384626433832795

const ll M=1e9+7;



// ordered_set(pbds) : 1)finding kth element :*A.find_by_order(k)  , 2)finding number of elements smaller than X: A.order_of_key(X)

//#include<ext/pb_ds/assoc_container.hpp>

//#include<ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;



// Binary exponentiation : (a^b)%m

long long binpow(long long a, long long b,long long m) {

    long long result = 1;

    while(b) {

         if (b & 1)

         result = (result * a)%m;

         a = (a * a)%m;

         b >>= 1;

    }

    return result;

}



// Modulo Multiplicative inverse (MMI) : A^-1 = A^(m-2)%m, where gcd(a,m)=1

long long modinverse(long long a,long long m){

    return binpow(a,m-2,m);

}



void solve(){

    int n,m;

    cin>>n>>m;

    multiset<int> b;

    vector<int> a(n);

    vec_sort(a);

    rep(i,n) cin>>a[i];

    rep(i,m){

        int x;

        cin>>x;

        b.insert(x);

    }

    ll sum = 0;

    rep(i,n){

        if(sum == 0 || abs(sum-a[i]) <= 1){

            sum += a[i];

        }

        else{

            cout << "No" << endl; return;

        }

        if(b.find(sum) != b.end()){

            b.erase(sum);

            sum = 0;

        }

    }

    if(b.empty() && sum == 0){

    cout << "Yes" << endl; }

    else{

        cout << "No" << endl;

    }

}



int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL); cout.tie(NULL);

    int t;

    cin>>t;

    while(t--){

    solve();

    }

    return 0;

}

Submission (verdict: Wrong answer on test 3):
# include<bits/stdc++.h>



using namespace std;



#define endl "\n"

#define ll long long int

#define pb push_back

#define rvec_sort(v) sort(v.begin(), v.end(), greater<int>());

#define vec_sort(v) sort(v.begin(),v.end());

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)

#define vec_sum(v) accumulate(v.begin(),v.end(),0ll)

#define PI 3.1415926535897932384626433832795

const ll M=1e9+7;



// ordered_set(pbds) : 1)finding kth element :*A.find_by_order(k)  , 2)finding number of elements smaller than X: A.order_of_key(X)

//#include<ext/pb_ds/assoc_container.hpp>

//#include<ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;



// Binary exponentiation : (a^b)%m

long long binpow(long long a, long long b,long long m) {

    long long result = 1;

    while(b) {

         if (b & 1)

         result = (result * a)%m;

         a = (a * a)%m;

         b >>= 1;

    }

    return result;

}



// Modulo Multiplicative inverse (MMI) : A^-1 = A^(m-2)%m, where gcd(a,m)=1

long long modinverse(long long a,long long m){

    return binpow(a,m-2,m);

}



void solve(){

    int n,m;

    cin>>n>>m;

    multiset<int> b;

    vector<int> a(n);

    vec_sort(a);

    rep(i,n) cin>>a[i];

    rep(i,m){

        int x;

        cin>>x;

        b.insert(x);

    }

    ll sum = 0;

    rep(i,n){

        if(sum == 0 || abs(sum-a[i]) <= 1){

            sum += a[i];

        }

        else{

            cout << "No" << endl; return;

        }

        auto it = b.find(sum);

        if(it != b.end()){

            b.erase(it);

            sum = 0;

        }

    }

    if(b.empty() && sum == 0){

    cout << "Yes" << endl; }

    else{

        cout << "No" << endl;

    }

}



int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL); cout.tie(NULL);

    int t;

    cin>>t;

    while(t--){

    solve();

    }

    return 0;

}