Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 9):
#include<bits/stdc++.h>
using namespace std;
bool isequal(multiset<long long>&a, multiset<long long>&b)
{
    int n=a.size();
    int m=b.size();
    if(n!=m) return false;
    auto it_a=a.begin(),it_b=b.begin();
    for(int i=0;i<n;i++)
    if((*it_a++)!=(*it_b++)) return false;
    return true;
}
void removecommon(multiset<long long> &a, multiset<long long>&b)
{
    auto it_a=a.begin();
    while(it_a!=a.end())
    {
        auto it_b=b.find(*it_a);
        if(it_b!=b.end())
        {
            it_a=a.erase(it_a);
            b.erase(it_b);
        }
        else
        it_a++;
    }
}
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n,m,x;
        cin>>n>>m;
        multiset<long long> a,b;
        for(int i=0;i<n;i++)
        cin>>x,a.insert(x);
        for(int i=0;i<m;i++)
        cin>>x,b.insert(x);
        removecommon(a,b);
        int diff=a.size()-b.size();
        auto ita=a.begin();
        auto itb=b.begin();
        if(a.empty() and b.empty())
        {
            cout<<"YES\n";
            continue;
        }
        if(diff<0 or *ita>*itb or b.empty()) 
        {
            cout<<"NO\n";
            continue;
        }
        bool flag=false;
        while(diff--)
        {
            auto it_b=b.begin();
            auto it1=a.begin();
            if(*it_b==*it1) it_b++,it1++;
            auto it2=next(it1,1);
            if(abs(*it2-*it1)>1 and *it1!=*it_b)
            {
                flag=true;
                break;
            }
            it2=next(it1,1);
            long long nxt=*it1+*it2;
            a.erase(it1);
            a.erase(it2);
            a.insert(nxt);
        }
        if(isequal(a,b) and !flag) cout<<"YES\n";
        else cout<<"NO\n";
    }
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;

#define long long int;

signed main(){
    int t;
    cin >> t;

    while(t--){
        int n, m;
        cin >> n >> m;

        if(n==1){
            cout << "No" << endl;
            continue;
        }

        vector<int> a(n), b(m);
        map<int,int> mpa, mpb;
        multiset<int, greater<int>> sta, stb;
        for(int i=0; i<n; i++){
            cin >> a[i];
            mpa[a[i]]++;
            sta.insert(a[i]);
        }
        for(int i=0; i<m; i++){
            cin >> b[i];
            mpb[b[i]]++;
            stb.insert(b[i]);
        }

        while(1){
            if(sta.empty() && stb.empty()){
                cout << "Yes" << endl;
                break;
            }
            if(sta.empty() || stb.empty()){
                cout << "No" << endl;
                break;
            }
            int mxa = *sta.begin();
            int mxb = *stb.begin();
            if(mxa > mxb){
                cout << "No" << endl;
                break;
            }
            else if(mxa == mxb){
                //remove from both
                int mini = min(mpa[mxb], mpb[mxb]);
                mpa[mxb] -= mini;
                mpb[mxb] -= mini;
                if(mpa[mxb]==0){
                    sta.erase(mxb);
                }
                if(mpb[mxb]==0){
                    stb.erase(mxb);
                }
            }
            else if(mxa < mxb){
                int f = mpb[mxb];
                int cv = (mxb+1)/2;
                int fv = mxb/2;
                mpb[mxb]= 0;
                stb.erase(mxb);
                for(int i=1; i<=f; i++){
                    stb.insert(cv), mpb[cv]++;
                    stb.insert(fv), mpb[fv]++;
                }
            }
        }
    }
}