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;
#define int long long

signed main(){
    int t; cin >> t;
    while(t--){
        int n,m; cin >> n >> m;
        int A[n],B[m];

        for(int i = 0; i <n;i++){
            cin >> A[i];
        }
        for(int i = 0; i < m;i++){
            cin >> B[i];
        }

        multiset<int> s1,s2;
        for(auto i : A){
            s1.insert(i);
        }
        for(auto i : B){
            s2.insert(i);
        }

        bool flag = true;
        int tt = 0;
        while(true){
            tt +=1;
            if(tt == 40){break;}
            if(s1.size() == 0 || s2.size() == 0){
                break;
            }
            auto x = s1.end();
            x = prev(x);
            auto y = s2.end();
            y = prev(y);
           
            if(*x == *y){
                s1.erase(x);
                s2.erase(y);
            }

            else{

                if(*x > *y){
                    flag = false;
                    break;
                }
                if(s1.size() == s2.size()){break;}
                int pp = *y;

                s2.erase(y);

                int t1 = pp/2;
                int t2 = pp - t1;
                s2.insert(t1);
                s2.insert(t2);
                
            }

        }

        if(s1.size() == 0 && s2.size() == 0){
            cout << "Yes" << endl;
        }


        else{

            vector<int> v1,v2;
            for(auto i : s1){
                v1.push_back(i);
            }
            for(auto i : s2){
                v2.push_back(i);
            }

            if(v1.size() != v2.size()){
                cout << "No" << endl;
                continue;
            }

            bool flag = true;
            for(int i = 0; i < v1.size();i++){
                if(v1[i] != v2[i]){
                    flag = false;
                    break;
                }
            }

            if(flag){
                cout << "Yes" << endl;
            }
            else{
                cout << "No" << endl;
            }

            
        }


    }
}

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();
}