ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

int main(){

ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

int t;cin>>t;

while(t--){

int n;cin>>n;

int a[200005],pre[200005];

bool flag=1;

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

cin>>a[i];

pre[i]=a[i]-a[i-1];

}

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

if(pre[i]<0&&i!=n){

if((pre[i]+min(a[i],a[i+1])+min(a[i],a[i-1]))<0) { cout << "No"<<endl;flag=0;break; }

else {

pre[i+1]+=min(a[i],a[i+1]);

}

}

else if(i==n&&pre[i]<0){

cout<<"No"<<endl;

flag=0;

break;

}

}

if(flag==1)cout<<"Yes"<<endl;

}

return 0;

}

Submission (verdict: Accepted):
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

using vll = vector <ll>;

using ii = pair <ll, ll>;

using vii = vector <ii>;



void tc () {

ll n;

cin >> n;

vll ve(n);

for (ll &i : ve) cin >> i;

ll j = 0;

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

if (ve[i-1] > ve[i]) j = i;

}

if (j == 0) { // all done

cout << "YES\n";

return;

}

auto fop = [&](ll i) {

ll minN = min(ve[i], ve[i+1]);

ve[i] -= minN;

ve[i+1] -= minN;

};

for (ll i = 0; i < j; i++) {

fop(i);

}

cout << (is_sorted(ve.begin(), ve.end()) ? "YES" : "NO") << '\n';

}



int main () {

cin.tie(nullptr) -> sync_with_stdio(false);

ll T; cin >> T; while (T--) { tc(); }

return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

int main(){

ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

int t;cin>>t;

while(t--){

int n;cin>>n;

int a[200005],pre[200005];

bool flag=1;

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

cin>>a[i];

pre[i]=a[i]-pre[i-1];

}

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

if(pre[i]<0){

if((pre[i]+min(a[i],a[i+1]))<0) { cout << "No"<<endl;flag=0;break; }

else {

pre[i+1]+=min(a[i],a[i+1]);

}

}

}

if(flag==1)cout<<"Yes"<<endl;

}

return 0;

}

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

using namespace std;

int main(){

ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

int t;cin>>t;

while(t--){

int n;cin>>n;

int a[200005],pre[200005];

bool flag=1;

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

cin>>a[i];

pre[i]=a[i]-a[i-1];

}

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

if(pre[i]<0&&i!=n){

if((pre[i]+min(a[i],a[i+1])+min(a[i],a[i-1]))<0) { cout << "No"<<endl;flag=0;break; }

else {

pre[i+1]+=min(a[i],a[i+1]);

}

}

else if(i==n&&pre[i]<0){

cout<<"No"<<endl;

flag=0;

break;

}

}

if(flag==1)cout<<"Yes"<<endl;

}

return 0;

}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
// #define ONLINE_JUDGE 1
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long; using pll = pair<ll, ll>;
#define all(a) (a).begin(),(a).end()
#define LL(...) ll __VA_ARGS__; input(__VA_ARGS__)
const ll N = 2e6 + 10;
#ifdef ONLINE_JUDGE
#define dbg(x)
#else
#define dbg(x) cerr << #x << "==" << (x) << '\n' << flush;
#endif
template<class... T> void input(T &...a) { (cin >> ... >> a); }
template<class T,class U> bool chmax(T &a, const U b) {return a<b?a=b,true:false; }
template<class T,class U> bool chmin(T &a, const U b) {return a>b?a=b,true:false; }
// clang-format on
bool gbit(ll n, ll k) { return (n >> k) & 1; }
void solve()
{
    LL(l, r);
    vector<ll> ans(3);
    ll now = 0;
    for (ll k = 30; k >= 0; k--)
    {
        if (gbit(l, k) != gbit(r, k))
        {
            now = k;
            break;
        }
    }
    ll a = (1 << now), b = a - 1, c = (b - 1 >= l ? b - 1 : a + 1);
    cout << a << ' ' << b << ' ' << c << '\n';
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll T = 1;
    // cin >> T;
    while (T--) solve();
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
// #define ONLINE_JUDGE 1
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long; using pll = pair<ll, ll>;
#define all(a) (a).begin(),(a).end()
#define LL(...) ll __VA_ARGS__; input(__VA_ARGS__)
const ll N = 2e6 + 10;
#ifdef ONLINE_JUDGE
#define dbg(x)
#else
#define dbg(x) cerr << #x << "==" << (x) << '\n' << flush;
#endif
template<class... T> void input(T &...a) { (cin >> ... >> a); }
template<class T,class U> bool chmax(T &a, const U b) {return a<b?a=b,true:false; }
template<class T,class U> bool chmin(T &a, const U b) {return a>b?a=b,true:false; }
// clang-format on
bool gbit(ll n, ll k) { return (n >> k) & 1; }
void solve()
{
    LL(l, r);
    vector<ll> ans(3);
    ll now = 0;
    ll base = 0;
    for (ll k = 30; k >= 0; k--)
    {
        if (gbit(l, k) != gbit(r, k))
        {
            now = k;
            break;
        }
        base |= (gbit(l, k) << k);
    }
    ll a = (1 << now), b = a - 1, c = (b - 1 >= l ? b - 1 : a + 1);
    a|=base, b|=base, c|=base;
    cout << a << ' ' << b << ' ' << c << '\n';
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll T = 1;
    cin >> T;
    while (T--) solve();
    return 0;
}

Submission (verdict: Accepted):
// #define ONLINE_JUDGE 1
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long; using pll = pair<ll, ll>;
#define all(a) (a).begin(),(a).end()
#define LL(...) ll __VA_ARGS__; input(__VA_ARGS__)
const ll N = 2e6 + 10;
#ifdef ONLINE_JUDGE
#define dbg(x)
#else
#define dbg(x) cerr << #x << "==" << (x) << '\n' << flush;
#endif
template<class... T> void input(T &...a) { (cin >> ... >> a); }
template<class T,class U> bool chmax(T &a, const U b) {return a<b?a=b,true:false; }
template<class T,class U> bool chmin(T &a, const U b) {return a>b?a=b,true:false; }
// clang-format on
bool gbit(ll n, ll k) { return (n >> k) & 1; }
void solve()
{
    LL(l, r);
    vector<ll> ans(3);
    ll now = 0;
    ll base = 0;
    for (ll k = 30; k >= 0; k--)
    {
        if (gbit(l, k) != gbit(r, k))
        {
            now = k;
            break;
        }
        base |= (gbit(l, k) << k);
    }
    ll a = (1 << now), b = a - 1; 
    a |= base, b |= base;
    ll c = (b - 1 >= l ? b - 1 : a + 1);
    cout << a << ' ' << b << ' ' << c << '\n';
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll T = 1;
    cin >> T;
    while (T--) solve();
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
// #define ONLINE_JUDGE 1
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long; using pll = pair<ll, ll>;
#define all(a) (a).begin(),(a).end()
#define LL(...) ll __VA_ARGS__; input(__VA_ARGS__)
const ll N = 2e6 + 10;
#ifdef ONLINE_JUDGE
#define dbg(x)
#else
#define dbg(x) cerr << #x << "==" << (x) << '\n' << flush;
#endif
template<class... T> void input(T &...a) { (cin >> ... >> a); }
template<class T,class U> bool chmax(T &a, const U b) {return a<b?a=b,true:false; }
template<class T,class U> bool chmin(T &a, const U b) {return a>b?a=b,true:false; }
// clang-format on
bool gbit(ll n, ll k) { return (n >> k) & 1; }
void solve()
{
    LL(l, r);
    vector<ll> ans(3);
    ll now = 0;
    for (ll k = 30; k >= 0; k--)
    {
        if (gbit(l, k) != gbit(r, k))
        {
            now = k;
            break;
        }
    }
    ll a = (1 << now), b = a - 1, c = (b - 1 >= l ? b - 1 : a + 1);
    cout << a << ' ' << b << ' ' << c << '\n';
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll T = 1;
    cin >> T;
    while (T--) solve();
    return 0;
}

Submission (verdict: Wrong answer on test 2):
// #define ONLINE_JUDGE 1
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long; using pll = pair<ll, ll>;
#define all(a) (a).begin(),(a).end()
#define LL(...) ll __VA_ARGS__; input(__VA_ARGS__)
const ll N = 2e6 + 10;
#ifdef ONLINE_JUDGE
#define dbg(x)
#else
#define dbg(x) cerr << #x << "==" << (x) << '\n' << flush;
#endif
template<class... T> void input(T &...a) { (cin >> ... >> a); }
template<class T,class U> bool chmax(T &a, const U b) {return a<b?a=b,true:false; }
template<class T,class U> bool chmin(T &a, const U b) {return a>b?a=b,true:false; }
// clang-format on
bool gbit(ll n, ll k) { return (n >> k) & 1; }
void solve()
{
    LL(l, r);
    vector<ll> ans(3);
    ll now = 0;
    ll base = 0;
    for (ll k = 30; k >= 0; k--)
    {
        if (gbit(l, k) != gbit(r, k))
        {
            now = k;
            break;
        }
        base |= (gbit(l, k) << k);
    }
    ll a = (1 << now), b = a - 1, c = (b - 1 >= l ? b - 1 : a + 1);
    a|=base, b|=base, c|=base;
    cout << a << ' ' << b << ' ' << c << '\n';
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll T = 1;
    cin >> T;
    while (T--) solve();
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
// #define ONLINE_JUDGE 1
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long; using pll = pair<ll, ll>;
#define all(a) (a).begin(),(a).end()
#define LL(...) ll __VA_ARGS__; input(__VA_ARGS__)
const ll N = 2e6 + 10;
#ifdef ONLINE_JUDGE
#define dbg(x)
#else
#define dbg(x) cerr << #x << "==" << (x) << '\n' << flush;
#endif
template<class... T> void input(T &...a) { (cin >> ... >> a); }
template<class T,class U> bool chmax(T &a, const U b) {return a<b?a=b,true:false; }
template<class T,class U> bool chmin(T &a, const U b) {return a>b?a=b,true:false; }
// clang-format on
bool gbit(ll n, ll k) { return (n >> k) & 1; }
void solve()
{
    LL(l, r);
    vector<ll> ans(3);
    ll now = 0;
    for (ll k = 30; k >= 0; k--)
    {
        if (gbit(l, k) != gbit(r, k))
        {
            now = k;
            break;
        }
    }
    ll a = (1 << now), b = a - 1, c = (b - 1 >= l ? b - 1 : a + 1);
    cout << a << ' ' << b << ' ' << c << '\n';
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll T = 1;
    // cin >> T;
    while (T--) solve();
    return 0;
}

Submission (verdict: Wrong answer on test 1):
// #define ONLINE_JUDGE 1
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long; using pll = pair<ll, ll>;
#define all(a) (a).begin(),(a).end()
#define LL(...) ll __VA_ARGS__; input(__VA_ARGS__)
const ll N = 2e6 + 10;
#ifdef ONLINE_JUDGE
#define dbg(x)
#else
#define dbg(x) cerr << #x << "==" << (x) << '\n' << flush;
#endif
template<class... T> void input(T &...a) { (cin >> ... >> a); }
template<class T,class U> bool chmax(T &a, const U b) {return a<b?a=b,true:false; }
template<class T,class U> bool chmin(T &a, const U b) {return a>b?a=b,true:false; }
// clang-format on
bool gbit(ll n, ll k) { return (n >> k) & 1; }
void solve()
{
    LL(l, r);
    vector<ll> ans(3);
    ll now = 0;
    for (ll k = 30; k >= 0; k--)
    {
        if (gbit(l, k) != gbit(r, k))
        {
            now = k;
            break;
        }
    }
    ll a = (1 << now), b = a - 1, c = (b - 1 >= l ? b - 1 : a + 1);
    cout << a << ' ' << b << ' ' << c << '\n';
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll T = 1;
    cin >> T;
    while (T--) solve();
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 3):
// #define ONLINE_JUDGE 1
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long; using pll = pair<ll, ll>;
#define all(a) (a).begin(),(a).end()
#define LL(...) ll __VA_ARGS__; input(__VA_ARGS__)
const ll N = 2e6 + 10;
#ifdef LOCAL
#include <dbg.h>
#else
#define dbg(...) (__VA_ARGS__)
#endif
template<class... T> void input(T &...a) { (cin >> ... >> a); }
template<class T,class U> bool chmax(T &a, const U b) {return a<b?a=b,true:false; }
template<class T,class U> bool chmin(T &a, const U b) {return a>b?a=b,true:false; }
// clang-format on

void solve()
{
    LL(n, m);
    priority_queue<ll, vector<ll>, greater<ll>> qu;
    for (ll i = 0; i < n; i++)
    {
        LL(x);
        qu.push(x);
    }
    map<ll, ll> mp;
    for (ll i = 0; i < m; i++)
    {
        LL(x);
        mp[x]++;
    }
    while (!qu.empty())
    {
        ll x = qu.top();
        qu.pop();
        if (mp[x] > 0) mp[x]--;
        else if (!qu.empty() && qu.top() - x <= 1)
        {
            x += qu.top();
            qu.pop();
            qu.push(x);
        }
        else return cout << "No\n", void();
    }
    for (auto [x, y] : mp)
        if (y) return cout << "No\n", void();
    cout << "Yes\n";
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll T = 1;
    cin >> T;
    while (T--) solve();
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
// #define ONLINE_JUDGE 1
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long; using pll = pair<ll, ll>;
#define all(a) (a).begin(),(a).end()
#define LL(...) ll __VA_ARGS__; input(__VA_ARGS__)
const ll N = 2e6 + 10;
#ifdef LOCAL
#include <dbg.h>
#else
#define dbg(...) (__VA_ARGS__)
#endif
template<class... T> void input(T &...a) { (cin >> ... >> a); }
template<class T,class U> bool chmax(T &a, const U b) {return a<b?a=b,true:false; }
template<class T,class U> bool chmin(T &a, const U b) {return a>b?a=b,true:false; }
// clang-format on

void solve()
{
    LL(n, m);
    priority_queue<ll, vector<ll>, greater<ll>> qu;
    for (ll i = 0; i < n; i++)
    {
        LL(x);
        qu.push(x);
    }
    map<ll, ll> mp;
    for (ll i = 0; i < m; i++)
    {
        LL(x);
        mp[x]++;
    }
    while (!qu.empty())
    {
        ll x = qu.top();
        qu.pop();
        if (mp[x] > 0) mp[x]--;
        else if (!qu.empty() && qu.top() - x <= 1)
        {
            x += qu.top();
            qu.pop();
            qu.push(x);
        }
        else return cout << "No\n", void();
    }
    for (auto [x, y] : mp)
        if (y) return cout << "No\n", void();
    cout << "Yes\n";
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll T = 1;
    cin >> T;
    while (T--) solve();
    return 0;
}

Submission (verdict: Wrong answer on test 3):
// #define ONLINE_JUDGE 1
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long; using pll = pair<ll, ll>;
#define all(a) (a).begin(),(a).end()
#define LL(...) ll __VA_ARGS__; input(__VA_ARGS__)
const ll N = 2e6 + 10;
#ifdef LOCAL
#include <dbg.h>
#else
#define dbg(...) (__VA_ARGS__)
#endif
template<class... T> void input(T &...a) { (cin >> ... >> a); }
template<class T,class U> bool chmax(T &a, const U b) {return a<b?a=b,true:false; }
template<class T,class U> bool chmin(T &a, const U b) {return a>b?a=b,true:false; }
// clang-format on

void solve()
{
    LL(n, m);
    map<ll, ll> mp;
    for (ll i = 0; i < n; i++)
    {
        LL(x);
        mp[x]++;
    }
    ll cnt = 0;
    function<ll(ll)> dfs = [&](ll x) -> ll
    {
        dbg(x);
        if (mp[x]) return mp[x]--, cnt++, 0;
        if (cnt >= n || x == 1) return 1;
        if (dfs(x / 2)) return 1;
        return dfs((x + 1) / 2);
    };
    for (ll i = 1; i <= m; i++)
    {
        LL(x);
        if (dfs(x)) return cout << "No\n", void();
    }
    cout << (cnt == n ? "Yes\n" : "No\n");
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll T = 1;
    cin >> T;
    while (T--) solve();
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
// #define ONLINE_JUDGE 1
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long; using pll = pair<ll, ll>;
#define all(a) (a).begin(),(a).end()
#define LL(...) ll __VA_ARGS__; input(__VA_ARGS__)
const ll N = 2e6 + 10;
#ifdef LOCAL
#include <dbg.h>
#else
#define dbg(...) (__VA_ARGS__)
#endif
template<class... T> void input(T &...a) { (cin >> ... >> a); }
template<class T,class U> bool chmax(T &a, const U b) {return a<b?a=b,true:false; }
template<class T,class U> bool chmin(T &a, const U b) {return a>b?a=b,true:false; }
// clang-format on

void solve()
{
    LL(n, m);
    map<ll, ll> mp;
    for (ll i = 0; i < n; i++)
    {
        LL(x);
        mp[x]++;
    }
    ll cnt = 0;
    function<ll(ll)> dfs = [&](ll x) -> ll
    {
        dbg(x);
        if (mp[x]) return mp[x]--, cnt++, 0;
        if (cnt >= n || x == 1) return 1;
        if (dfs(x / 2)) return 1;
        return dfs((x + 1) / 2);
    };
    for (ll i = 1; i <= m; i++)
    {
        LL(x);
        if (dfs(x)) return cout << "No\n", void();
    }
    cout << (cnt == n ? "Yes\n" : "No\n");
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll T = 1;
    cin >> T;
    while (T--) solve();
    return 0;
}

Submission (verdict: Wrong answer on test 3):
// #define ONLINE_JUDGE 1
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long; using pll = pair<ll, ll>;
#define all(a) (a).begin(),(a).end()
#define LL(...) ll __VA_ARGS__; input(__VA_ARGS__)
const ll N = 2e6 + 10;
#ifdef LOCAL
#include <dbg.h>
#else
#define dbg(...) (__VA_ARGS__)
#endif
template<class... T> void input(T &...a) { (cin >> ... >> a); }
template<class T,class U> bool chmax(T &a, const U b) {return a<b?a=b,true:false; }
template<class T,class U> bool chmin(T &a, const U b) {return a>b?a=b,true:false; }
// clang-format on

void solve()
{
    LL(n, m);
    map<ll, ll> mp;
    for (ll i = 0; i < n; i++)
    {
        LL(x);
        mp[x]++;
    }
    ll cnt = 0;
    function<ll(ll)> dfs = [&](ll x) -> ll
    {
        dbg(x);
        if (mp[x]) return mp[x]--, cnt++, 0;
        if (x == 1) return 1;
        if (dfs(x / 2)) return 1;
        return dfs((x + 1) / 2);
    };
    for (ll i = 1; i <= m; i++)
    {
        LL(x);
        if (dfs(x)) return cout << "No\n", void();
    }
    cout << (cnt == n ? "Yes\n" : "No\n");
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll T = 1;
    cin >> T;
    while (T--) solve();
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
// #define ONLINE_JUDGE 1
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long; using pll = pair<ll, ll>;
#define all(a) (a).begin(),(a).end()
#define LL(...) ll __VA_ARGS__; input(__VA_ARGS__)
const ll N = 2e6 + 10;
#ifdef LOCAL
#include <dbg.h>
#else
#define dbg(...) (__VA_ARGS__)
#endif
template<class... T> void input(T &...a) { (cin >> ... >> a); }
template<class T,class U> bool chmax(T &a, const U b) {return a<b?a=b,true:false; }
template<class T,class U> bool chmin(T &a, const U b) {return a>b?a=b,true:false; }
// clang-format on

void solve()
{
    LL(n, m);
    map<ll, ll> mp;
    for (ll i = 0; i < n; i++)
    {
        LL(x);
        mp[x]++;
    }
    ll cnt = 0;
    function<ll(ll)> dfs = [&](ll x) -> ll
    {
        dbg(x);
        if (mp[x]) return mp[x]--, cnt++, 0;
        if (x == 1) return 1;
        if (dfs(x / 2)) return 1;
        return dfs((x + 1) / 2);
    };
    for (ll i = 1; i <= m; i++)
    {
        LL(x);
        if (dfs(x)) return cout << "No\n", void();
    }
    cout << (cnt == n ? "Yes\n" : "No\n");
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll T = 1;
    cin >> T;
    while (T--) solve();
    return 0;
}

Submission (verdict: Accepted):
// #define ONLINE_JUDGE 1
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long; using pll = pair<ll, ll>;
#define all(a) (a).begin(),(a).end()
#define LL(...) ll __VA_ARGS__; input(__VA_ARGS__)
const ll N = 2e6 + 10;
#ifdef LOCAL
#include <dbg.h>
#else
#define dbg(...) (__VA_ARGS__)
#endif
template<class... T> void input(T &...a) { (cin >> ... >> a); }
template<class T,class U> bool chmax(T &a, const U b) {return a<b?a=b,true:false; }
template<class T,class U> bool chmin(T &a, const U b) {return a>b?a=b,true:false; }
// clang-format on

void solve()
{
    LL(n, m);
    dbg(n, m);
    map<ll, ll> mp;
    for (ll i = 0; i < n; i++)
    {
        LL(x);
        mp[x]++;
    }
    ll cnt = 0;
    priority_queue<ll> qu;
    for (ll i = 0; i < m; i++)
    {
        LL(x);
        qu.push(x);
    }
    while (!qu.empty() && cnt < n)
    {
        if((ll)qu.size() > n-cnt)return void(cout << "No\n");
        ll x = qu.top();
        qu.pop();
        if (mp[x])
        {
            mp[x]--;
            cnt++;
        }
        else
        {
            if(x == 1)return void(cout << "No\n");
            qu.push(x / 2);
            qu.push((x + 1) / 2);
        }
    }
    cout << (cnt == n ? "Yes\n" : "No\n");
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll T = 1;
    cin >> T;
    while (T--) solve();
    return 0;
}