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

Previous submission (verdict: Time limit exceeded on test 5):
#include <bits/stdc++.h>
#define ll long long
#define yes cout << "YES" << '\n'
#define no cout << "NO" << '\n'
#define K ios_base::sync_with_stdio(NULL),cin.tie(0),cout.tie(0);
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
ll const mod = 1e9+7,N=200005;
ll f[N],ff[N],dp[N],dp1[N],fff[N],r,k,n,m,q,ans,ans1,sum,sum1,ind1,ind2,ind3,l,l1,r1,x,y,z,mx,mn,cnt,a,b,c,d,t=1,xy[1][1];
char xy1[1][1],fc[N],ch;
bool bv2[N],bv1[N],bb,bbb;
string s,s1,s2;
vector<ll> v,v1,v2,v3,v4,aa1[N];
vector<pair<ll,ll>> vp,vp1,aa[N];
multiset <ll> st,st1;
map<ll,ll> mp,mp2,mp3;

void s0()
{
    cin>>n>>m;
    st.clear(),st1.clear();
    sum=0;
    for(int i=1 ; i<=n ; i++) 
    {
        cin>>x;
        st.insert(x);
        sum+=x;
    }
    for(int i=1 ; i<=m ; i++) 
    {
        cin>>x;
        st1.insert(x);
        sum-=x;
    }
    if(sum) return void (no);
    ind1=0;
    while((int)st1.size())
    {
        v.clear();
        v1.clear();
        for(auto ss:st1)
        {
            if(st.count(ss)) st.erase(st.find(ss));
            else if(ss/2) v1.push_back(ss/2),v1.push_back(ss/2+(ss&1));
            else {return void (no);}
            v.push_back(ss);
        }
        for(auto vv:v) st1.erase(st1.find(vv));
        for(auto vv:v1) st1.insert(vv);
        ind1++;
        if(ind1==32) return void (no);
    }
    (st==st1)? yes : no ;
}

int main()
{
    // freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
    K;
    cin>>t;
    while(t--) s0();
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define ll long long
#define yes cout << "YES" << '\n'
#define no cout << "NO" << '\n'
#define K ios_base::sync_with_stdio(NULL),cin.tie(0),cout.tie(0);
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
ll const mod = 1e9+7,N=200005;
ll f[N],ff[N],dp[N],dp1[N],fff[N],r,k,n,m,q,ans,ans1,sum,sum1,ind1,ind2,ind3,l,l1,r1,x,y,z,mx,mn,cnt,a,b,c,d,t=1,xy[1][1];
char xy1[1][1],fc[N],ch;
bool bv2[N],bv1[N],bb,bbb;
string s,s1,s2;
vector<ll> v,v1,v2,v3,v4,aa1[N];
vector<pair<ll,ll>> vp,vp1,aa[N];
multiset <ll> st,st1;
map<ll,ll> mp,mp2,mp3;

void s0()
{
    cin>>n>>m;
    st.clear(),st1.clear();
    for(int i=1 ; i<=n ; i++) 
    {
        cin>>x;
        st.insert(x);
    }
    for(int i=1 ; i<=m ; i++) 
    {
        cin>>x;
        st1.insert(x);
    }
    while((int)st1.size())
    {
        v.clear();
        v1.clear();
        for(auto ss:st1)
        {
            if(st.count(ss)) st.erase(st.find(ss));
            else if(ss/2) v1.push_back(ss/2),v1.push_back(ss/2+(ss&1));
            else {return void (no);}
            v.push_back(ss);
        }
        for(auto vv:v) st1.erase(st1.find(vv));
        for(auto vv:v1) st1.insert(vv);
        if((int)st1.size()>(int)st.size()) return void (no);
    }
    (st==st1)? yes : no ;
}

int main()
{
    // freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
    K;
    cin>>t;
    while(t--) s0();
}