Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

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

using namespace std;



#define endl '\n'

#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)



typedef long long LL;

typedef pair<int, int> PII;

typedef pair<LL, LL> PLL;

typedef map<int,int> Map;

typedef unordered_map<int, int> UnMap;

typedef unordered_set<int> Set;

typedef map<LL,LL> MaL;

const int Mod = 998244353;

const int N = 2e5 + 10;



int Add(int a, int b)

{

    return a + b >= Mod ? a + b - Mod : a + b;

}



int Sub(int a, int b)

{

    return a - b < 0 ? a - b + Mod : a - b;

}



int Mul(int a, int b)

{

    return 1LL * a * b % Mod;

}



int Pow(int a, int k)

{

    int R = 1;

    while (k)

    {

        if (k & 1) R = Mul(R, a);

        k >>= 1;

        a = Mul(a, a);

    }

    return R;

}



int Div(int a, int b)

{

    return Mul(a, Pow(b, Mod - 2));

}



int Fac[N + 10], Inv[N + 10];

 

void init()

{

    Fac[0] = 1;

    for(int i = 1 ; i <= N ; i ++)

        Fac[i] = Mul(Fac[i - 1], i);

    Inv[N] = Pow(Fac[N], Mod - 2);

    for(int i = N - 1; i >= 0 ; i --)

        Inv[i] = Mul(Inv[i + 1], i + 1);

}

 

int C(int n, int m)

{

    return Mul(Fac[n], Mul(Inv[m], Inv[n - m]));

}

 



int lowbit(int x)

{

    return x & (-x);

}



int primes[N], cnt;         //     primes记录从2-n中的素数,cnt记录素数个数 



bool st[N];                 



void get_primes(int n)

{

    st[1] = true;

	for(int i = 2; i <= n; i ++)

	{

		if(!st[i])

		{

			primes[cnt ++] = i;

	    }

	    

		for(int j = 0; primes[j] <= n / i; j ++)

		{

		    st[primes[j] * i] = true;

		    if(i % primes[j] == 0) break;

	    }

	}

}



void solve()

{

    int n,m; cin >> n >> m;

    Map mb,ma;

    vector<int> a(n + 1);

    priority_queue<int> q;



    for(int i = 1; i <= n; i ++){

        cin >> a[i];

        ma[a[i]] ++;

    }



    for(int i = 1; i <= m; i ++){

        int x; cin >> x;

        q.push(x);

    }



    while(!q.empty()){

        if(m > n){

            cout << "No" << endl;

            return;

        }

        int tt = q.top();

        q.pop();

        //cout << tt << endl;

        if(tt >= 2)

        {

            if(ma[tt] == 0 || (mb[tt] > ma[tt])){

                int l = tt / 2, r = tt / 2 + (tt % 2 == 1);

                q.push(l);

                q.push(r);

                //cout << l << " " << r << endl;

                if(mb[tt] > ma[tt]) mb[tt] --;

                m += 2;

                continue;

            }

        }

        mb[tt] ++;

    }



    for(int i = 1; i <= n; i ++){

        if(ma[a[i]] != mb[a[i]]){

            cout << "No" << endl;

            return;

        }

    }

    cout << "Yes" << endl; 



}



signed main()

{

    IOS;

    int t = 1; 

    cin >> t;

    while(t --)

    {

        solve();

    }

}



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

using namespace std;



#define endl '\n'

#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)



typedef long long LL;

typedef pair<int, int> PII;

typedef pair<LL, LL> PLL;

typedef map<int,int> Map;

typedef unordered_map<int, int> UnMap;

typedef unordered_set<int> Set;

typedef map<LL,LL> MaL;

const int Mod = 998244353;

const int N = 2e5 + 10;



int Add(int a, int b)

{

    return a + b >= Mod ? a + b - Mod : a + b;

}



int Sub(int a, int b)

{

    return a - b < 0 ? a - b + Mod : a - b;

}



int Mul(int a, int b)

{

    return 1LL * a * b % Mod;

}



int Pow(int a, int k)

{

    int R = 1;

    while (k)

    {

        if (k & 1) R = Mul(R, a);

        k >>= 1;

        a = Mul(a, a);

    }

    return R;

}



int Div(int a, int b)

{

    return Mul(a, Pow(b, Mod - 2));

}



int Fac[N + 10], Inv[N + 10];

 

void init()

{

    Fac[0] = 1;

    for(int i = 1 ; i <= N ; i ++)

        Fac[i] = Mul(Fac[i - 1], i);

    Inv[N] = Pow(Fac[N], Mod - 2);

    for(int i = N - 1; i >= 0 ; i --)

        Inv[i] = Mul(Inv[i + 1], i + 1);

}

 

int C(int n, int m)

{

    return Mul(Fac[n], Mul(Inv[m], Inv[n - m]));

}

 



int lowbit(int x)

{

    return x & (-x);

}



int primes[N], cnt;         //     primes记录从2-n中的素数,cnt记录素数个数 



bool st[N];                 



void get_primes(int n)

{

    st[1] = true;

	for(int i = 2; i <= n; i ++)

	{

		if(!st[i])

		{

			primes[cnt ++] = i;

	    }

	    

		for(int j = 0; primes[j] <= n / i; j ++)

		{

		    st[primes[j] * i] = true;

		    if(i % primes[j] == 0) break;

	    }

	}

}



void solve()

{

    int n,m; cin >> n >> m;

    Map mb,ma;

    vector<int> a(n + 1);

    priority_queue<int> q;



    for(int i = 1; i <= n; i ++){

        cin >> a[i];

        ma[a[i]] ++;

    }



    for(int i = 1; i <= m; i ++){

        int x; cin >> x;

        q.push(x);

    }



    while(!q.empty()){

        if(m > n){

            cout << "No" << endl;

            return;

        }

        int tt = q.top();

        q.pop();

        //cout << tt << endl;

        if(tt >= 2)

        {

            if(ma[tt] == 0 || (mb[tt] > ma[tt])){

                int l = tt / 2, r = tt / 2 + (tt % 2 == 1);

                q.push(l);

                q.push(r);

                //cout << l << " " << r << endl;

                if(mb[tt] > ma[tt]) mb[tt] --;

                m += 1;

                continue;

            }

        }

        mb[tt] ++;

    }



    for(int i = 1; i <= n; i ++){

        if(ma[a[i]] != mb[a[i]]){

            cout << "No" << endl;

            return;

        }

    }

    cout << "Yes" << endl; 

}



signed main()

{

    IOS;

    int t = 1; 

    cin >> t;

    while(t --)

    {

        solve();

    }

}