ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define rep(i, n) for (int i = 0; i < n; ++i)
#define repl(i, n) for (ll i = 0; i < n; i++)
#define repr(i,x1,x2) for(ll i=x1; i<x2; ++i)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
int main(){
    IOS;
    int t;
    cin>>t;
    while (t--){
        int l , r;
        cin>>l>>r;
        int a = l;
        int b = r;
        bool flag = false;
        for (int i=31 ; i>=0 ; i--){
            if (flag){
                a = a | (1<<i);
                b = b & (~(1<<i));
            }
            bool temp1 = (l>>i)&1;
            bool temp2 = (r>>i)&1;
            if (temp1 != temp2){
                flag = true;
            }
        }
        if (l != a){
            cout <<l<<" "<<a<<" "<<b<<endl;
        }
        else{
            cout<<l<<" "<<l+1<<" "<<b<<endl;
        }
    }
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define rep(i, n) for (int i = 0; i < n; ++i)
#define repl(i, n) for (ll i = 0; i < n; i++)
#define repr(i,x1,x2) for(ll i=x1; i<x2; ++i)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
int main(){
    IOS;
    int t;
    cin>>t;
    while (t--){
        int l , r;
        cin>>l>>r;
        int a = l;
        int b = r;
        bool flag = false;
        for (int i=31 ; i>=0 ; i--){
            if (flag){
                a = a | (1<<i);
                b = b & (~(1<<i));
            }
            bool temp1 = (l>>i)&1;
            bool temp2 = (r>>i)&1;
            if (temp1 != temp2){
                flag = true;
            }
        }
        int c = 1;
        for (int i=l; i<=r ; i++){
            if (i!=a && i!=b){
                c = i;
                break;
            }
        }
        cout<<a<<b<<c<<endl;
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define rep(i, n) for (int i = 0; i < n; ++i)
#define repl(i, n) for (ll i = 0; i < n; i++)
#define repr(i,x1,x2) for(ll i=x1; i<x2; ++i)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
int main(){
    IOS;
    int t;
    cin>>t;
    while (t--){
        int l , r;
        cin>>l>>r;
        int a = l;
        int b = r;
        bool flag = false;
        for (int i=31 ; i>=0 ; i--){
            if (flag){
                a = a | (1<<i);
                b = b & (~(1<<i));
            }
            bool temp1 = (l>>i)&1;
            bool temp2 = (r>>i)&1;
            if (temp1 != temp2){
                flag = true;
            }
        }
        if (l != a){
            cout <<l<<" "<<a<<" "<<b<<endl;
        }
        else{
            cout<<l<<" "<<l+1<<" "<<b<<endl;
        }
    }
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

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

#define IO cin.tie(0) -> sync_with_stdio(0)

#define endl "\n"

#define F first

#define S second

#define pLL pair<LL, LL>

#define mkp make_pair

#define pb emplace_back

#define LL loli

#define loli long long

using namespace std;

template<typename T> using Vec = vector<T>;

template<typename T> using Mat = Vec<Vec<T> >;

const LL mod = 1e9+7, inf = 9e18, maxN = 0;



LL TT = 1;

LL n, m;

multiset<LL> st;

Vec<LL> vec;



void solve() {

  cin >> n >> m;

  st.clear();

  while(n--) {

    LL x;

    cin >> x;

    st.insert(x);

  }

  vec.assign(m, 0);

  for(auto &i : vec) cin >> i;

  sort(vec.begin(), vec.end());

  bool bln=0;

  for(auto &i : vec) {

    if(st.find(i)!=st.end()) {

      // cout << i << " !!!" << endl;

      st.erase(st.find(i));

      continue;

    }

    LL a = i/2, b = i-a;

    bool bln2=0;

    while(st.size()>=2) {

      auto ait = st.find(a), bit = st.find(b);

      if(bit==ait && bit!=st.end()) bit = next(bit);

      if(ait!=st.end() && bit!=st.end() && *bit==b) {

        // cout << a << ' ' << b << ' ' << i << " !!!" << endl;

        st.erase(ait);

        st.erase(st.find(b));

        bln2=1;

        break;

      }

      LL x = *st.begin(); st.erase(st.begin());

      LL y = *st.begin(); st.erase(st.begin());

      if(y-x>1) {

        bln2=1;

        bln=1;

        break;

      }

      st.insert(x+y);

    }

    if(!bln2) {

      if(st.empty()) bln=1;

      else if(*st.begin()!=i) bln=1;

      else st.erase(st.begin());

    }

    if(bln) break;

  }

  bln |= !st.empty();

  cout << (!bln ? "Yes" : "No") << endl;

}



int main() {

  IO;

  cin >> TT;

  for(int cs=0; cs<TT; cs++) {

    solve();

  }

}



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

#define IO cin.tie(0) -> sync_with_stdio(0)

#define endl "\n"

#define F first

#define S second

#define pLL pair<LL, LL>

#define mkp make_pair

#define pb emplace_back

#define LL loli

#define loli long long

using namespace std;

template<typename T> using Vec = vector<T>;

template<typename T> using Mat = Vec<Vec<T> >;

const LL mod = 1e9+7, inf = 9e18, maxN = 0;



LL TT = 1;

LL n, m, x;

multiset<LL> a, b;



void solve() {

  cin >> n >> m;

  a.clear(), b.clear();

  for(LL i=0; i<n; i++) {cin>>x, a.insert(x);}

  for(LL i=0; i<m; i++) {cin>>x, b.insert(x);}

  for(LL i=0; i<n-m; i++) {

    while(!b.empty() && a.find(*prev(b.end())) != a.end()) {

      a.erase(a.find(*prev(b.end())));

      b.erase(prev(b.end()));

    }

    if(b.empty()) break;

    LL k = *prev(b.end());

    b.erase(b.find(k)), b.insert(k/2), b.insert(k-k/2);

  }

  while(!b.empty() && a.find(*prev(b.end())) != a.end()) {

    a.erase(a.find(*prev(b.end())));

    b.erase(prev(b.end()));

  }

  cout << (a.empty()&&b.empty() ? "Yes" : "No") << endl;

}



int main() {

  IO;

  cin >> TT;

  for(int cs=0; cs<TT; cs++) {

    solve();

  }

}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


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

#define IO cin.tie(0) -> sync_with_stdio(0)

#define endl "\n"

#define F first

#define S second

#define pLL pair<LL, LL>

#define mkp make_pair

#define pb emplace_back

#define LL loli

#define loli long long

using namespace std;

template<typename T> using Vec = vector<T>;

template<typename T> using Mat = Vec<Vec<T> >;

const LL mod = 1e9+7, inf = 9e18, maxN = 0;



LL TT = 1;

LL n, m;

priority_queue<LL, Vec<LL>, greater<LL>> pq;

Vec<LL> vec;



void solve() {

  cin >> n >> m;

  while(!pq.empty()) pq.pop();

  while(n--) {

    LL x;

    cin >> x;

    pq.push(x);

  }

  vec.assign(m, 0);

  for(auto &i : vec) cin >> i;

  sort(vec.begin(), vec.end());

  bool bln=1;

  for(auto &i : vec) {

    bool bln2=0;

    while(pq.size()>=2) {

      if(i==pq.top()) {

        pq.pop();

        bln2=1;

        break;

      }

      LL a = pq.top(); pq.pop();

      LL b = pq.top(); pq.pop();

      // cout << a << ' ' << b << "???" << endl;

      if(llabs(a-b)>1) {

        bln2=1;

        bln=0;

        break;

      }

      pq.push(a+b);

    }

    if(!bln2) {

      if(pq.empty()) bln=0;

      else if(pq.top()!=i) bln=0;

      else pq.pop();

    }

    if(!bln) break;

  }

  bln &= pq.empty();

  cout << (bln ? "Yes" : "No") << endl;

}



int main() {

  IO;

  cin >> TT;

  for(int cs=0; cs<TT; cs++) {

    solve();

  }

}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

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

using i64 = long long;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int n;
    std::cin >> n;

    std::vector<int> a(n);
    for (int i = 0; i < n; i ++) {
        std::cin >> a[i];
    }

    std::vector<std::array<int, 2>> ans;
    for (int i = 0; i < n; i ++) {
        for (int j = i + 1; j < n; j ++) {
            ans.push_back({a[i], a[j]});
            if (a[i] < a[j]) {
                ans.push_back({a[j], a[i]});
            }
        }
    }

    std::cout << ans.size() << '\n';
    for (auto [x, y] : ans) {
        std::cout << x << ' ' << y << '\n';
    }

    return 0;
}


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

using i64 = long long;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int n;
    std::cin >> n;

    std::vector<int> a(n);
    for (int i = 0; i < n; i ++) {
        std::cin >> a[i];
    }

    std::vector<std::array<int, 2>> ans;
    for (int i = 0; i < n; i ++) {
        for (int j = i + 1; j < n; j ++) {
            ans.push_back({a[i], a[j]});
            if (a[i] < a[j]) {
                ans.push_back({a[j], a[i]});
            }
        }
    }

    std::cout << ans.size() << '\n';
    for (auto [x, y] : std::ranges::reverse_view(ans)) {
        std::cout << x << ' ' << y << '\n';
    }

    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)


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

using i64 = long long;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int n;
    std::cin >> n;

    std::vector<int> a(n);
    for (int i = 0; i < n; i ++) {
        std::cin >> a[i];
    }

    std::vector<std::array<int, 2>> ans;
    for (int i = 0; i < n; i ++) {
        for (int j = i + 1; j < n; j ++) {
            ans.push_back({a[i], a[j]});
            if (a[i] < a[j]) {
                ans.push_back({a[j], a[i]});
            }
        }
    }

    std::cout << ans.size() << '\n';
    for (auto [x, y] : ans) {
        std::cout << x << ' ' << y << '\n';
    }

    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

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

using i64 = long long;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int n;
    std::cin >> n;

    std::vector<int> a(n);
    for (int i = 0; i < n; i ++) {
        std::cin >> a[i];
    }

    std::vector<std::array<int, 2>> ans;
    for (int i = 0; i < n; i ++) {
        for (int j = i + 1; j < n; j ++) {
            ans.push_back({a[i], a[j]});
            if (a[i] < a[j]) {
                ans.push_back({a[j], a[i]});
            }
        }
    }

    std::cout << ans.size() << '\n';
    for (auto [x, y] : std::ranges::reverse_view(ans)) {
        std::cout << x << ' ' << y << '\n';
    }

    return 0;
}


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

using i64 = long long;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int n;
    std::cin >> n;

    std::vector<int> a(n);
    for (int i = 0; i < n; i ++) {
        std::cin >> a[i];
    }

    std::vector<std::array<int, 2>> ans;
    for (int i = 0; i < n; i ++) {
        for (int j = 0; j < n - 1; j ++) {
            if (a[j] < a[j + 1]) {
                std::swap(a[j], a[j + 1]);
                ans.push_back({a[j + 1], a[j]});
            }
        }
    }

    for (int i = 0; i < n; i ++) {
        for (int j = 0; j < n - 1; j ++) {
            if (a[j] > a[j + 1]) {
                std::swap(a[j], a[j + 1]);
                ans.push_back({a[j + 1], a[j]});
            }
        }
    }

    std::cout << ans.size() << '\n';
    for (auto [x, y] : std::views::reverse(ans)) {
        std::cout << x << ' ' << y << '\n';
    }

    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    ll t;
    cin>>t;
    while(t--){
   
    string a,b,c;
    cin>>a;
    cin>>b;
    cin>>c;
    vector<vector<ll> > dp(2001,vector<ll>(2001));
    for(ll i=0;i<=b.size();i++){
      for(ll j=0;j<=a.size();j++){
         if(i==0&&j==0){
            dp[i][j]=0;
         }
         else if(i==0){
            dp[i][j]=dp[i][j-1];
            if(a[j-1]!=c[j-1]){
              dp[i][j]++;
            }
         }
          else if(j==0){
            dp[i][j]=dp[i-1][j];
            if(b[j-1]!=c[j-1]){
              dp[i][j]++;
            }
         }
         else{
            ll k=i+j;
            ll x=dp[i-1][j],y=dp[i][j-1];
            if(a[j-1]!=c[k-1]){
               y++;
            }
            if(b[i-1]!=c[k-1]){
               x++;
            }
            dp[i][j]=min(x,y);
         }
         // cout<<dp[i][j]<<" ";
      }
      // cout<<endl;
    }
    cout<<dp[b.size()][a.size()]<<"\n";


    }
}

Submission (verdict: Time limit exceeded on test 2):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    ll t;
    cin>>t;
    while(t--){
   
    string a,b,c;
    cin>>a;
    cin>>b;
    cin>>c;
    vector<vector<ll> > dp(2001,vector<ll>(2001));
    for(ll i=0;i<=b.size();i++){
      for(ll j=0;j<=a.size();j++){
         if(i==0&&j==0){
            dp[i][j]=0;
         }
         else if(i==0){
            dp[i][j]=dp[i][j-1];
            if(a[j-1]!=c[j-1]){
              dp[i][j]++;
            }
         }
          else if(j==0){
            dp[i][j]=dp[i-1][j];
            if(b[i-1]!=c[i-1]){
              dp[i][j]++;
            }
         }
         else{
            ll k=i+j;
            ll x=dp[i-1][j],y=dp[i][j-1];
            if(a[j-1]!=c[k-1]){
               y++;
            }
            if(b[i-1]!=c[k-1]){
               x++;
            }
            dp[i][j]=min(x,y);
         }
        //   cout<<dp[i][j]<<" ";
      }
    //   cout<<endl;
    }
    cout<<dp[b.size()][a.size()]<<"\n";


    }
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 2):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    ll t;
    cin>>t;
    while(t--){
   
    string a,b,c;
    cin>>a;
    cin>>b;
    cin>>c;
    vector<vector<ll> > dp(2001,vector<ll>(2001));
    for(ll i=0;i<=b.size();i++){
      for(ll j=0;j<=a.size();j++){
         if(i==0&&j==0){
            dp[i][j]=0;
         }
         else if(i==0){
            dp[i][j]=dp[i][j-1];
            if(a[j-1]!=c[j-1]){
              dp[i][j]++;
            }
         }
          else if(j==0){
            dp[i][j]=dp[i-1][j];
            if(b[i-1]!=c[i-1]){
              dp[i][j]++;
            }
         }
         else{
            ll k=i+j;
            ll x=dp[i-1][j],y=dp[i][j-1];
            if(a[j-1]!=c[k-1]){
               y++;
            }
            if(b[i-1]!=c[k-1]){
               x++;
            }
            dp[i][j]=min(x,y);
         }
        //   cout<<dp[i][j]<<" ";
      }
    //   cout<<endl;
    }
    cout<<dp[b.size()][a.size()]<<"\n";


    }
}

Submission (verdict: Compilation error):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    ll t;
    cin>>t;
    while(t--){
   
    string a,b,c;
    cin>>a;
    cin>>b;
    cin>>c;
    vector<vector<ll> > dp(b.size()+1,vector<ll>(a.size()+1));
    dp[0][0]=0;
    for(ll i=1;i<=b.size();i++){
       dp[i][0]=dp[i-1][0];
            if(b[i-1]!=c[i-1]){
              dp[i][=]++;
    }
    }
    for(ll j=1;j<=a.size;j++){
     dp[0][j]=dp[0][j-1];
            if(a[j-1]!=c[j-1]){
              dp[0][j]++;
            }
    }
    for(ll i=0;i<=b.size();i++){
      for(ll j=0;j<=a.size();j++){
         
            ll k=i+j;
            ll x=dp[i-1][j],y=dp[i][j-1];
            if(a[j-1]!=c[k-1]){
               y++;
            }
            if(b[i-1]!=c[k-1]){
               x++;
            }
            dp[i][j]=min(x,y);
         
         // cout<<dp[i][j]<<" ";
      }
      // cout<<endl;
    }
    cout<<dp[b.size()][a.size()]<<"\n";


    }
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Compilation error):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    ll t;
    cin>>t;
    while(t--){
   
    string a,b,c;
    cin>>a;
    cin>>b;
    cin>>c;
    vector<vector<ll> > dp(b.size()+1,vector<ll>(a.size()+1));
    dp[0][0]=0;
    for(ll i=1;i<=b.size();i++){
       dp[i][0]=dp[i-1][0];
            if(b[i-1]!=c[i-1]){
              dp[i][=]++;
    }
    }
    for(ll j=1;j<=a.size;j++){
     dp[0][j]=dp[0][j-1];
            if(a[j-1]!=c[j-1]){
              dp[0][j]++;
            }
    }
    for(ll i=0;i<=b.size();i++){
      for(ll j=0;j<=a.size();j++){
         
            ll k=i+j;
            ll x=dp[i-1][j],y=dp[i][j-1];
            if(a[j-1]!=c[k-1]){
               y++;
            }
            if(b[i-1]!=c[k-1]){
               x++;
            }
            dp[i][j]=min(x,y);
         
         // cout<<dp[i][j]<<" ";
      }
      // cout<<endl;
    }
    cout<<dp[b.size()][a.size()]<<"\n";


    }
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    ll t;
    cin>>t;
    while(t--){
   
    string a,b,c;
    cin>>a;
    cin>>b;
    cin>>c;
    vector<vector<ll> > dp(b.size()+1,vector<ll>(a.size()+1));
    dp[0][0]=0;
    for(ll i=1;i<=b.size();i++){
        dp[i][0]=dp[i-1][0];
            if(b[i-1]!=c[i-1]){
              dp[i][0]++;
            }
    }
    for(ll j=1;j<=a.size();j++){
        dp[0][j]=dp[0][j-1];

            if(a[j-1]!=c[j-1]){
              dp[0][j]++;
            }
    }
    for(ll i=1;i<=b.size();i++){
      for(ll j=1;j<=a.size();j++){
         
            ll k=i+j;
            ll x=dp[i-1][j],y=dp[i][j-1];
            if(a[j-1]!=c[k-1]){
               y++;
            }
            if(b[i-1]!=c[k-1]){
               x++;
            }
            dp[i][j]=min(x,y);
         
        //   cout<<dp[i][j]<<" ";
      }
    //   cout<<endl;
    }
   //  for(ll i=0;i<=b.size();i++){
   //    for(ll j=0;j<=a.size();j++){
   //       cout<<dp[i][j]<<" ";
   //    }
   //    cout<<endl;
   //  }
    cout<<dp[b.size()][a.size()]<<"\n";


    }
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


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

int main(){
    ll t;
    cin>>t;
    while(t--){
   
    string a,b,c;
    cin>>a;
    cin>>b;
    cin>>c;
    vector<vector<ll> > dp(2001,vector<ll>(2001));
    for(ll i=0;i<=b.size();i++){
      for(ll j=0;j<=a.size();j++){
         if(i==0&&j==0){
            dp[i][j]=0;
         }
         else if(i==0){
            dp[i][j]=dp[i][j-1];
            if(a[j-1]!=c[j-1]){
              dp[i][j]++;
            }
         }
          else if(j==0){
            dp[i][j]=dp[i-1][j];
            if(b[j-1]!=c[j-1]){
              dp[i][j]++;
            }
         }
         else{
            ll k=i+j;
            ll x=dp[i-1][j],y=dp[i][j-1];
            if(a[j-1]!=c[k-1]){
               y++;
            }
            if(b[i-1]!=c[k-1]){
               x++;
            }
            dp[i][j]=min(x,y);
         }
         // cout<<dp[i][j]<<" ";
      }
      // cout<<endl;
    }
    cout<<dp[b.size()][a.size()]<<"\n";


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


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define all(x) x.begin(),x.end()
#define All(x) x.begin()+1,x.end()
#define int long long 
typedef unsigned long long ull;
typedef long long ll;
typedef __int128 i128;
typedef pair<int,int> pii;
const int dx[4]={1,-1,0,0};
const int dy[4]={0,0,1,-1};

void solve(){
    int n,m;
    cin>>n>>m;
    vector<int>a(n+1),b(m+1);
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=m;i++)cin>>b[i];
    sort(All(a)),sort(All(b));
    int id=1;
    map<int,int>mp,need;

    function<bool(int)> dfs=[&](int now){
        if(now==0)return 0;
        if(mp[now]>0)need[now]++;
        else if(now==1){
            return 0;
        }
        else {
            if(dfs(now/2)==1&&dfs((now+1)/2)==1)return 1;
            else return 0;
        }

        if(need[now]>mp[now])return 0;
        return 1;
    };

    function<void(int)> clear=[&](int now){
        if(mp[now]>0){
            mp[now]--;
            if(mp[now]==0)mp.erase(now);
        }
        else {
            clear(now/2);
            clear((now+1)/2);
        }
        return;
    };

    for(int i=1;i<=m;i++){
        if(id<=n){
            while(id<=n&&a[id]<b[i])mp[a[id]]++,id++;
            if(a[id]==b[i]){
                id++;
                continue;
            }
        }
        need.clear();
        if(dfs(b[i])){
            clear(b[i]);
        }
        else {
            No;
            return;
        }
    }
    if(id==n+1)Yes
    else No
}

signed main(){
    ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
    int t=1;
    cin>>t;
    while(t--)solve();
    return 0;
}