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

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
//                                       Sk Najir
#ifndef ONLINE_JUDGE
#include "db.hpp"
#else
#define dbg(x)
#define dbg2(x, y)
#define dbg3(x, y, z)
#endif
#define IOS                      \
    ios::sync_with_stdio(false); \
    cin.tie(0);                  \
    cout.tie(0);

// pre_define
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

// shortcut type
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;

// Constants
const int MOD = 1e9 + 7;

void solve()
{
    int n, m;
    cin >> n >> m;
    multiset<ll> a, b;
    ll x;
    for (int i = 0; i < n; i++)
        cin >> x, a.insert(x);
    for (int i = 0; i < m; i++)
    {
        cin >> x;
        if (a.find(x) != a.end())
        {
            a.erase(a.find(x));
        }
        else
            b.insert(x);
    }
    if (a.size() == 0 and b.size() == 0)
    {
        cout << "YES" << endl;
        return;
    }
    int y;
    while (a.size() > 1)
    {
        x = *a.begin();
        a.erase(a.begin());
        y = *a.begin();
        a.erase(a.begin());
        if (y - x > 1)
        {
            cout << "No" << endl;
            return;
        }
        if (b.find(y + x) != b.end())
        {
            b.erase(b.find(x + y));
        }
        else
            a.insert(x + y);
    }
    if (a.size() != 0)
    {
        cout << "No" << endl;
    }
    else if (!b.empty())
    {
        cout << "No" << endl;
    }
    else
        cout << "Yes" << endl;
}

int main()
{
    IOS;
    int tc = 1;
    cin >> tc;
    for (int t = 1; t <= tc; t++)
        solve();
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
//                                       Sk Najir
#ifndef ONLINE_JUDGE
#include "db.hpp"
#else
#define dbg(x)
#define dbg2(x, y)
#define dbg3(x, y, z)
#endif
#define IOS                      \
    ios::sync_with_stdio(false); \
    cin.tie(0);                  \
    cout.tie(0);

// pre_define
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

// shortcut type
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;

// Constants
const int MOD = 1e9 + 7;

void solve()
{
    int n, m;
    cin >> n >> m;
    multiset<ll> a, b;
    ll x;
    for (int i = 0; i < n; i++)
        cin >> x, a.insert(x);
    for (int i = 0; i < m; i++)
    {
        cin >> x;
        if (a.find(x) != a.end())
        {
            a.erase(a.find(x));
        }
        else
            b.insert(x);
    }
    if (a.size() == 0 and b.size() == 0)
    {
        cout << "YES" << endl;
        return;
    }
    ll y;
    // dbg(a);
    // dbg(b);
    while (a.size() > 1)
    {
        x = *a.begin();
        a.erase(a.begin());
        y = *a.begin();
        a.erase(a.begin());
        if (y - x > 1)
        {
            cout << "No" << endl;
            return;
        }
        if (b.find(y + x) != b.end())
        {
            b.erase(b.find(x + y));
        }
        else
            a.insert(x + y);
    }
    // dbg(a);
    // dbg(b);
    if (a.size() != 0)
    {
        cout << "No" << endl;
    }
    else if (!b.empty())
    {
        cout << "No" << endl;
    }
    else
        cout << "Yes" << endl;
}

int main()
{
    IOS;
    int tc = 1;
    cin >> tc;
    for (int t = 1; t <= tc; t++)
        solve();
}