ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)

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

int maximumComponents() {
  int n; cin >> n;
  vector<vector<int>> adjList(n + 1, vector<int>());
  vector<int> inDegree(n + 1, 0);
  for (int i = 1; i < n; ++i) {
    int u, v; cin >> u >> v;
    adjList[u].push_back(v);
    adjList[v].push_back(u);
    inDegree[u]++; inDegree[v]++;
  }

  vector<int> visited(n + 1, 0);

  function<void(int)> componentExplore = [&](int node) -> void {
    visited[node] = 1;

    for (int neighbor : adjList[node]) {
      if (!visited[neighbor]) {
        componentExplore(neighbor);
      }
    }
  };

  function<int()> getMaxIndegreeNode = [&]() -> int {
    int maxIndegreeNode = 0;
    for (int i = 1; i <= n; ++i) {
      if (inDegree[i] >= inDegree[maxIndegreeNode]) {
        maxIndegreeNode = i;
      }
    }

    return maxIndegreeNode;
  };

  for (int i = 1; i < 3; ++i) {
    int maxIndegreeNode = getMaxIndegreeNode();
    visited[maxIndegreeNode] = 1;
    inDegree[maxIndegreeNode] = -1;
    for (int neighbor : adjList[maxIndegreeNode]) {
      inDegree[neighbor]--;
    }
  }

  int components = 0;
  for (int i = 1; i <= n; ++i) {
    if (!visited[i]) {
      componentExplore(i);
      components++;
    }
  }

  return components;
}

int32_t main() {
  ios_base::sync_with_stdio(false); cin.tie(0);

  int test; cin >> test;
  while (test--) {
    cout << maximumComponents() << '\n';
  }
    
  return 0;
}

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

int maximumComponents() {
  int n; cin >> n;

  vector<int> degree(n + 1, 0);
  set<pair<int, int>> edges;
  for (int i = 1; i < n; i++) {
    int u, v; cin >> u >> v;
    degree[u]++; degree[v]++;
    edges.insert({u, v});
    edges.insert({v, u});
  }

  vector<pair<int, int>> degreeNode;
  for (int i = 1; i <= n; i++) {
    degreeNode.push_back({degree[i], i});
  }

  sort(degreeNode.begin(), degreeNode.end(), greater<pair<int, int>>());
  int components = 0;

  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (edges.find({degreeNode[i].second, degreeNode[j].second}) == edges.end()) {
        components = max(components, degreeNode[i].first + degreeNode[j].first - 1);
      }
    }
  }

  for (auto edge : edges) {
    components = max(components, degree[edge.first] + degree[edge.second] - 2);
  }

  return components;
}

int32_t main() {
  ios_base::sync_with_stdio(false); cin.tie(0);

  int test; cin >> test;
  while (test--) {
    cout << maximumComponents() << '\n';
  }
    
  return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)

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

int maximumComponents() {
  int n; cin >> n;
  vector<vector<int>> adjList(n + 1, vector<int>());
  vector<int> inDegree(n + 1, 0);
  for (int i = 1; i < n; ++i) {
    int u, v; cin >> u >> v;
    adjList[u].push_back(v);
    adjList[v].push_back(u);
    inDegree[u]++; inDegree[v]++;
  }

  vector<int> visited(n + 1, 0);

  function<void(int)> componentExplore = [&](int node) -> void {
    visited[node] = 1;

    for (int neighbor : adjList[node]) {
      if (!visited[neighbor]) {
        componentExplore(neighbor);
      }
    }
  };


  int maxIndegreeNode = 0;
  int secondMaxIndegreeNode = 0;

  for (int i = 1; i <= n; ++i) {
    if (inDegree[i] > inDegree[maxIndegreeNode]) {
      secondMaxIndegreeNode = maxIndegreeNode;
      maxIndegreeNode = i;
    } else if (inDegree[i] > inDegree[secondMaxIndegreeNode]) {
      secondMaxIndegreeNode = i;
    }
  }

  visited[maxIndegreeNode] = 1;
  visited[secondMaxIndegreeNode] = 1;

  int components = 0;
  for (int i = 1; i <= n; ++i) {
    if (!visited[i]) {
      componentExplore(i);
      components++;
    }
  }

  return components;
}

int32_t main() {
  ios_base::sync_with_stdio(false); cin.tie(0);

  int test; cin >> test;
  while (test--) {
    cout << maximumComponents() << '\n';
  }
    
  return 0;
}

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

int maximumComponents() {
  int n; cin >> n;
  vector<vector<int>> adjList(n + 1, vector<int>());
  vector<int> inDegree(n + 1, 0);
  for (int i = 1; i < n; ++i) {
    int u, v; cin >> u >> v;
    adjList[u].push_back(v);
    adjList[v].push_back(u);
    inDegree[u]++; inDegree[v]++;
  }

  vector<int> visited(n + 1, 0);

  function<void(int)> componentExplore = [&](int node) -> void {
    visited[node] = 1;

    for (int neighbor : adjList[node]) {
      if (!visited[neighbor]) {
        componentExplore(neighbor);
      }
    }
  };

  function<int()> getMaxIndegreeNode = [&]() -> int {
    int maxIndegreeNode = 1;
    for (int i = 1; i <= n; ++i) {
      if (inDegree[i] >= inDegree[maxIndegreeNode]) {
        maxIndegreeNode = i;
      }
    }

    return maxIndegreeNode;
  };

  for (int i = 1; i < 3; ++i) {
    int maxIndegreeNode = getMaxIndegreeNode();
    visited[maxIndegreeNode] = 1;
    inDegree[maxIndegreeNode] = -1;
    for (int neighbor : adjList[maxIndegreeNode]) {
      inDegree[neighbor]--;
    }
  }

  int components = 0;
  for (int i = 1; i <= n; ++i) {
    if (!visited[i]) {
      componentExplore(i);
      components++;
    }
  }

  return components;
}

int32_t main() {
  ios_base::sync_with_stdio(false); cin.tie(0);

  int test; cin >> test;
  while (test--) {
    cout << maximumComponents() << '\n';
  }
    
  return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)

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

int maximumComponents() {
  int n; cin >> n;

  vector<int> degree(n + 1, 0);
  set<pair<int, int>> edges;
  for (int i = 1; i < n; i++) {
    int u, v; cin >> u >> v;
    degree[u]++; degree[v]++;
    edges.insert({u, v});
    edges.insert({v, u});
  }

  vector<pair<int, int>> degreeNode;
  for (int i = 1; i <= n; i++) {
    degreeNode.push_back({degree[i], i});
  }

  sort(degreeNode.begin(), degreeNode.end(), greater<pair<int, int>>());
  int components = 0;

  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (edges.find({degreeNode[i].second, degreeNode[j].second}) == edges.end()) {
        components = max(components, degreeNode[i].first + degreeNode[j].first - 1);
      }
    }
  }

  for (auto edge : edges) {
    components = max(components, degree[edge.first] + degree[edge.second] - 2);
  }

  return components;
}

int32_t main() {
  ios_base::sync_with_stdio(false); cin.tie(0);

  int test; cin >> test;
  while (test--) {
    cout << maximumComponents() << '\n';
  }
    
  return 0;
}

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

int maximumComponents() {
  int n; cin >> n;

  vector<int> degree(n + 1, 0);
  set<pair<int, int>> edges;
  for (int i = 1; i < n; i++) {
    int u, v; cin >> u >> v;
    degree[u]++; degree[v]++;
    edges.insert({u, v});
    edges.insert({v, u});
  }

  vector<pair<int, int>> degreeNode;
  for (int i = 1; i <= n; i++) {
    degreeNode.push_back({degree[i], i});
  }

  sort(degreeNode.begin(), degreeNode.end(), greater<pair<int, int>>());
  int components = 0;

  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (edges.find({degreeNode[i].second, degreeNode[j].second}) == edges.end()) {
        components = max(components, degreeNode[i].first + degreeNode[j].first - 1);
        break;
      }
    }
  }

  for (auto edge : edges) {
    components = max(components, degree[edge.first] + degree[edge.second] - 2);
  }

  return components;
}

int32_t main() {
  ios_base::sync_with_stdio(false); cin.tie(0);

  int test; cin >> test;
  while (test--) {
    cout << maximumComponents() << '\n';
  }
    
  return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)


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

int maximumComponents() {
  int n; cin >> n;
  vector<vector<int>> adjList(n + 1, vector<int>());
  vector<int> inDegree(n + 1, 0);
  for (int i = 1; i < n; ++i) {
    int u, v; cin >> u >> v;
    adjList[u].push_back(v);
    adjList[v].push_back(u);
    inDegree[u]++; inDegree[v]++;
  }

  vector<int> visited(n + 1, 0);

  function<void(int)> componentExplore = [&](int node) -> void {
    visited[node] = 1;

    for (int neighbor : adjList[node]) {
      if (!visited[neighbor]) {
        componentExplore(neighbor);
      }
    }
  };


  int maxIndegreeNode = 0;
  int secondMaxIndegreeNode = 0;

  for (int i = 1; i <= n; ++i) {
    if (inDegree[i] > inDegree[maxIndegreeNode]) {
      secondMaxIndegreeNode = maxIndegreeNode;
      maxIndegreeNode = i;
    } else if (inDegree[i] > inDegree[secondMaxIndegreeNode]) {
      secondMaxIndegreeNode = i;
    }
  }

  visited[maxIndegreeNode] = 1;
  visited[secondMaxIndegreeNode] = 1;

  int components = 0;
  for (int i = 1; i <= n; ++i) {
    if (!visited[i]) {
      componentExplore(i);
      components++;
    }
  }

  return components;
}

int32_t main() {
  ios_base::sync_with_stdio(false); cin.tie(0);

  int test; cin >> test;
  while (test--) {
    cout << maximumComponents() << '\n';
  }
    
  return 0;
}
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)

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

using namespace std;

int main(){

    int t;

    cin>>t;

    while(t--){

        int n;

        cin>>n;

        vector<int>ritik(n);

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

        cin>>ritik[i];

        int sum_o=0,sum_e=0;

        int c1=0,c2=0;

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

            if(i%2==0){

              sum_e+=ritik[i];  

              c1++;

            }

            else{

                sum_o+=ritik[i];

                c2++;

            }

        }

        if(sum_e/c1==sum_o/c2 && sum_e%c1==0&& sum_o%c2==0){

            cout<<"YES"<<endl;

        }

        else

            cout<<"NO"<<endl;

    }

}





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

using namespace std;

int main(){

    int t;

    cin>>t;

    while(t--){

        long long int n;

        cin>>n;

        vector<int>ritik(n);

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

        cin>>ritik[i];

        long long int sum_o=0,sum_e=0;

        long long int c1=0,c2=0;

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

            if(i%2==0){

              sum_e+=ritik[i];  

              c1++;

            }

            else{

                sum_o+=ritik[i];

                c2++;

            }

        }

        if(sum_e/c1==sum_o/c2 && sum_e%c1==0&& sum_o%c2==0){

            cout<<"YES"<<endl;

        }

        else

            cout<<"NO"<<endl;

    }

}
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)


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

using namespace std;

int main(){

    int t;

    cin>>t;

    while(t--){

        int n;

        cin>>n;

        vector<int>ritik(n);

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

        cin>>ritik[i];

        int sum_o=0,sum_e=0;

        int c1=0,c2=0;

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

            if(i%2==0){

              sum_e+=ritik[i];  

              c1++;

            }

            else{

                sum_o+=ritik[i];

                c2++;

            }

        }

        if(sum_e/c1==sum_o/c2 && sum_e%c1==0){

            cout<<"YES"<<endl;

        }

        else

            cout<<"NO"<<endl;

    }

}
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)

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

using namespace std;

int main(){

    int t;

    cin>>t;

    while(t--){

        int n;

        cin>>n;

        vector<int>ritik(n);

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

        cin>>ritik[i];

        int sum_o=0,sum_e=0;

        int c1=0,c2=0;

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

            if(i%2==0){

              sum_e+=ritik[i];  

              c1++;

            }

            else{

                sum_o+=ritik[i];

                c2++;

            }

        }

        if(sum_e/c1==sum_o/c2 && sum_e%c1==0){

            cout<<"YES"<<endl;

        }

        else

            cout<<"NO"<<endl;

    }

}





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

using namespace std;

int main(){

    int t;

    cin>>t;

    while(t--){

        int n;

        cin>>n;

        vector<int>ritik(n);

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

        cin>>ritik[i];

        int sum_o=0,sum_e=0;

        int c1=0,c2=0;

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

            if(i%2==0){

              sum_e+=ritik[i];  

              c1++;

            }

            else{

                sum_o+=ritik[i];

                c2++;

            }

        }

        if(sum_e/c1==sum_o/c2 && sum_e%c1==0&& sum_o%c2==0){

            cout<<"YES"<<endl;

        }

        else

            cout<<"NO"<<endl;

    }

}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t!=0){
        int n;
        cin>>n;
        int arr[n];
        for(int i=0;i<n;i++) cin>>arr[i];
        
        long long maxi=LLONG_MIN;
        int now=n;
        for(int i=0;i<n;i++){
            long long sum=0;
            for(int j=0;j<now;j++){
                sum+=arr[j];
            }
            if(i==0){
                maxi=max(maxi,sum);
            }
            else{
                maxi=max(maxi,max(sum,-sum));
            }
            
            for(int j=0;j<now-1;j++){
                arr[i]=arr[i+1]-arr[i];
            }
            now--;
        }
        cout<<maxi<<endl;
        t--;
    }
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t!=0){
        int n;
        cin>>n;
        int arr[n];
        for(int i=0;i<n;i++) cin>>arr[i];
        
        long long maxi=LLONG_MIN;
        int now=n;
        for(int i=0;i<n;i++){
            long long sum=0;
            for(int j=0;j<now;j++){
                sum+=arr[j];
            }
            if(i==0){
                maxi=max(maxi,sum);
            }
            else{
                maxi=max(maxi,max(sum,(-sum)));
            }
            
            for(int j=0;j<now-1;j++){
                arr[j]=arr[j+1]-arr[j];
            }
            now--;
        }
        cout<<maxi<<endl;
        t--;
    }
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t!=0){
        int n;
        cin>>n;
        long long arr[n];
        for(int i=0;i<n;i++) cin>>arr[i];
        
        long long maxi=LLONG_MIN;
        int now=n;
        for(int i=0;i<n;i++){
            long long sum=0;
            for(int j=0;j<now;j++){
                sum+=arr[j];
            }
            if(i==0){
                maxi=max(maxi,sum);
            }
            else{
                maxi=max(maxi,max(sum,(-sum)));
            }
            
            for(int j=0;j<now-1;j++){
                arr[j]=arr[j+1]-arr[j];
            }
            now--;
        }
        cout<<maxi<<endl;
        t--;
    }
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t!=0){
        int n;
        cin>>n;
        int arr[n];
        for(int i=0;i<n;i++) cin>>arr[i];
        
        long long maxi=LLONG_MIN;
        int now=n;
        for(int i=0;i<n;i++){
            long long sum=0;
            for(int j=0;j<now;j++){
                sum+=arr[j];
            }
            if(i==0){
                maxi=max(maxi,sum);
            }
            else{
                maxi=max(maxi,max(sum,-sum));
            }
            
            for(int j=0;j<now-1;j++){
                arr[i]=arr[i+1]-arr[i];
            }
            now--;
        }
        cout<<maxi<<endl;
        t--;
    }
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t!=0){
        int n;
        cin>>n;
        int arr[n];
        for(int i=0;i<n;i++) cin>>arr[i];
        
        long long maxi=LLONG_MIN;
        int now=n;
        for(int i=0;i<n;i++){
            long long sum=0;
            for(int j=0;j<now;j++){
                sum+=arr[j];
            }
            if(i==0){
                maxi=max(maxi,sum);
            }
            else{
                maxi=max(maxi,max(sum,(-sum)));
            }
            
            for(int j=0;j<now-1;j++){
                arr[j]=arr[j+1]-arr[j];
            }
            now--;
        }
        cout<<maxi<<endl;
        t--;
    }
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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

using namespace std;



typedef long long ll;

typedef vector<long long> vll;



void solve() {

    ll n, l, r;

    cin >> n >> l >> r;

    vector<pair<ll, ll>> elements(n);

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

        cin>> elements[i].first;

        elements[i].second = i;

    }

    ll sum = 0;

    ll len = r-l+1;

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

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

        if(len==0) break;    

        sum+=elements[i].first;

        len--;

    }

    

    cout << sum << "\n";

}



int main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);



    int t;

    cin >> t;

    while (t--) {

        solve();

    }



    return 0;

}

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

using namespace std;



typedef long long ll;

typedef vector<long long> vll;



void solve() {

    ll n, l, r;

    cin >> n >> l >> r;



    vll a(n);

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

        cin >> a[i];

    }



    // Sort the array to get the smallest values easily

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



    // Compute the sum of the smallest (r - l + 1) elements

    ll sum = 0;

    for (ll i = 0; i < (r - l + 1); i++) {

        sum += a[i];

    }



    cout << sum << "\n";

}



int main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);



    int t;

    cin >> t;

    while (t--) {

        solve();

    }



    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


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

using namespace std;



typedef long long ll;

typedef vector<long long> vll;



void solve() {

    ll n, l, r;

    cin >> n >> l >> r;

    vector<pair<ll, ll>> elements(n);

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

        cin>> elements[i].first;

        elements[i].second = i;

    }

    ll sum = 0;

    ll len = r-l+1;

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

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

        if(len==0) break;    

        sum+=elements[i].first;

        len--;

    }

    

    cout << sum << "\n";

}



int main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);



    int t;

    cin >> t;

    while (t--) {

        solve();

    }



    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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

using namespace std;



typedef long long ll;

typedef vector<long long> vll;



void solve() {

    ll n, l, r;

    cin >> n >> l >> r;



    vll a(n);

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

        cin >> a[i];

    }



    // Sort the array to get the smallest values easily

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



    // Compute the sum of the smallest (r - l + 1) elements

    ll sum = 0;

    for (ll i = 0; i < (r - l + 1); i++) {

        sum += a[i];

    }



    cout << sum << "\n";

}



int main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);



    int t;

    cin >> t;

    while (t--) {

        solve();

    }



    return 0;

}

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

typedef long long ll;
typedef vector<long long> vll;

void solve() {
    ll n, l, r;
    cin >> n >> l >> r;

    vll a(n);
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    vll la, ra;
    
    for(int i=0; i<r; i++){
        la.push_back(a[i]);
    }
    sort(la.begin(), la.end());
    
    for(int j=l-1; j<n; j++){
        ra.push_back(a[j]);
    }
    sort(ra.begin(), ra.end());

    ll lsum = 0, rsum = 0;
    for (int i = 0; i < (r - l + 1); i++) {
        lsum += la[i];
    }
    for (int j = 0; j < (r - l + 1); j++) {
        rsum += ra[j];
    }
    cout << min(lsum, rsum) << "\n";
}

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

    int t;
    cin >> t;
    while (t--) {
        solve();
    }

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

Previous submission (verdict: Time limit exceeded on test 25):
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
int main(int argc, char const *argv[])
{
  int T,n,m;
  for(std::cin>>T;T!=0;--T){
    std::cin>>n>>m;
    std::map<int,int> origin;
    for(int cx=0,og;cx!=n;++cx){
      std::cin>>og;
      ++origin[og];
    }
    bool valid=true;
    for(int cx=0,tg;cx!=m;++cx){
      std::queue<int> queries;
      std::cin>>tg;
      queries.push(tg);
      while(!queries.empty()){
        tg=queries.front();
        queries.pop();
        if(tg==0||static_cast<int>(queries.size())>n){
          valid=false;
          break;
        }else if(origin.find(tg)!=origin.end()&&origin[tg]>0) 
          --origin[tg],--n;
        else queries.push(tg>>1),queries.push((tg+1)>>1);
      }
    }
    for(auto &&[cx,ct]:origin)
      if(ct!=0) valid=false;
    if(valid) std::cout<<"Yes"<<std::endl;
    else std::cout<<"No"<<std::endl;
  }
  return 0;
}

Submission (verdict: Compilation error):
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
int main(int argc, char const *argv[])
{
  int T,n,m;
  for(std::cin>>T;T!=0;--T){
    std::cin>>n>>m;
    std::map<int,int> origin;
    long long ogsum=0;
    for(int cx=0,og;cx!=n;++cx){
      std::cin>>og;
      ++origin[og];
      ogsum+=og;
    }
    std::queue<int> queries;
    long long tgsum=0;
    for(int cx=0,tg;cx!=m;++cx){
      std::cin>>tg;
      queries.push(tg);
      tgsum+=og;
    }
    bool valid=tgsum==ogsum;
    while(!queries.empty()&&valid){
      tg=queries.front();
      queries.pop();
      if(tg==0||static_cast<int>(queries.size())>n){
        valid=false;
        break;
      }else if(origin.find(tg)!=origin.end()&&origin[tg]>0) 
        --origin[tg];
      else queries.push(tg>>1),queries.push((tg+1)>>1);
    }
    for(auto &&[cx,ct]:origin)
      if(ct!=0) valid=false;
    if(valid) std::cout<<"Yes"<<std::endl;
    else std::cout<<"No"<<std::endl;
  }
  return 0;
}