ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


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

// Yash Raj 2112047
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second

// Fast Input/Output
void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

// Debugging (for personal use during development)
#define debug(x) cerr << #x << " = "; _print(x); cerr << endl;
template <typename T> void _print(T x) { cerr << x; }
template <typename T, typename V> void _print(pair<T, V> p) { cerr << "{" << p.F << "," << p.S << "}"; }
template <typename T> void _print(vector<T> v) { cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]"; }

int main() {
    fast_io(); // Ensures fast input/output
    
    int t;
    cin >> t; // Multiple test cases
    while (t--) {
        
        int n, l, r;
        cin >> n>>l>>r;
        vector<int> arr;
        for (int i = 0; i < n; i++) {
            int a;cin>>a;
            arr.push_back(a);
        }
        priority_queue<int, vector<int>, greater<int>>pq(arr.begin(), arr.end());
        int sum = 0;
        int d = r-l+1;
        while(d--){
            sum += pq.top();
            pq.pop();
        }
        cout<<sum <<endl;
    }

    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;

// Yash Raj 2112047
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second

// Fast Input/Output
void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

// Debugging (for personal use during development)
#define debug(x) cerr << #x << " = "; _print(x); cerr << endl;
template <typename T> void _print(T x) { cerr << x; }
template <typename T, typename V> void _print(pair<T, V> p) { cerr << "{" << p.F << "," << p.S << "}"; }
template <typename T> void _print(vector<T> v) { cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]"; }

int main() {
    fast_io(); // Ensures fast input/output
    
    int t;
    cin >> t; // Multiple test cases
    while (t--) {
        
        int n, l, r;
        cin >> n>>l>>r;
        vector<int> arr;
        for (int i = 0; i < n; i++) {
            int a;cin>>a;
            arr.push_back(a);
        }
        priority_queue<int, vector<int>, greater<int>>pq(arr.begin(), arr.end());
        int sum = 0;
        int d = r-l+1;
        while(d--){
            sum += pq.top();
            pq.pop();
        }
        cout<<sum <<endl;
    }

    return 0;
}

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

// Yash Raj 2112047
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second

// Fast Input/Output
void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

// Debugging (for personal use during development)
#define debug(x) cerr << #x << " = "; _print(x); cerr << endl;
template <typename T> void _print(T x) { cerr << x; }
template <typename T, typename V> void _print(pair<T, V> p) { cerr << "{" << p.F << "," << p.S << "}"; }
template <typename T> void _print(vector<T> v) { cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]"; }

int main() {
    fast_io(); // Ensures fast input/output
    
    int t;
    cin >> t; // Multiple test cases
    while (t--) {
        
        ll n, l, r;
        cin >> n>>l>>r;
        vector<ll> arr(n);
        for (int i = 0; i < n; i++) {
            cin >> arr[i];
        }
        sort(arr.begin(), arr.end());
        int sum = 0, sum2=0, sum3=0;
        
        // for(int i=0; i<r; i++)
        //     sum += arr[i];
        for(int i=0; i<r-l+1; i++)
            sum3 += arr[i];
        // for(int i=l; i<n; i++)
        //     sum2+= arr[i];
        
        cout<<sum3 << "\n";
    }

    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;
#define ll long long

void solve() {
    int n, l, r;
    cin >> n >> l >> r;
    vector<int> arr(n + 1);
    arr[0] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
    }

    vector<int> a, b, c;
    for (int i = 1; i < l; i++) {
        a.push_back(arr[i]);
    }
    for (int i = l; i <= r; i++) {
        b.push_back(arr[i]);
    }
    for (int i = r + 1; i <= n; i++) {
        c.push_back(arr[i]);
    }

    ll ans = 0;
    for (int i = l; i <= r; i++) {
        ans += arr[i];
    }

    int x = a.size(), y = b.size(), z = c.size();
    sort(a.begin(), a.end());
    sort(b.rbegin(), b.rend());
    sort(c.begin(), c.end());

    int i = 0, j = 0;
    ll temp = ans;

    while (i < y && j < z && b[i] > c[j]) {
        temp = (temp - b[i] + c[j]);
        ans = min(ans, temp);
        i++;
        j++;
    }

    i = 0, j = 0;
    temp = ans;

    while (i < y && j < x && b[i] > a[j]) {
        temp = (temp - b[i] + a[j]);
        ans = min(ans, temp);
        i++;
        j++;
    }

    cout << ans << endl;
}

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


Submission (verdict: Accepted):
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;
#define ll long long

void solve() {
    int n, l, r;
    cin >> n >> l >> r;
    vector<int> arr(n + 1);
    arr[0] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
    }

    vector<int> a(arr.begin() + 1, arr.begin() + l);
    vector<int> b(arr.begin() + l, arr.begin() + r + 1);
    vector<int> c(arr.begin() + r + 1, arr.end());

    ll ans = 0;
    for (int i = l; i <= r; i++) {
        ans += arr[i];
    }
    ll ans1=ans;
    int x = a.size(), y = b.size(), z = c.size();
    sort(a.begin(), a.end());
    sort(b.rbegin(), b.rend());
    sort(c.begin(), c.end());

    int i = 0, j = 0;
    ll temp = ans1;

    while (i < y && j < z && b[i] > c[j]) {
        temp = (temp - b[i] + c[j]);
        ans = min(ans, temp);
        i++;
        j++;
    }

    i = 0, j = 0;
    temp = ans1;

    while (i < y && j < x && b[i] > a[j]) {
        temp = (temp - b[i] + a[j]);
        ans = min(ans, temp);
        i++;
        j++;
    }

    cout << ans << endl;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <iostream>

#include <vector>

#include <algorithm>

#include <climits>



using namespace std;

#define ll long long



void solve() {

    int n, l, r;

    cin >> n >> l >> r;

    vector<int> arr(n + 1);

    arr[0] = 0;

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

        cin >> arr[i];

    }



    vector<int> a(arr.begin() + 1, arr.begin() + l);

    vector<int> b(arr.begin() + l, arr.begin() + r + 1);

    vector<int> c(arr.begin() + r + 1, arr.end());



    ll ans = 0;

    for (int i = l; i <= r; i++) {

        ans += arr[i];

    }



    int x = a.size(), y = b.size(), z = c.size();

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

    sort(b.rbegin(), b.rend());

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



    int i = 0, j = 0;

    ll temp = ans;



    while (i < y && j < z && b[i] > c[j]) {

        temp = (temp - b[i] + c[j]);

        ans = min(ans, temp);

        i++;

        j++;

    }



    i = 0, j = 0;

    temp = ans;



    while (i < y && j < x && b[i] > a[j]) {

        temp = (temp - b[i] + a[j]);

        ans = min(ans, temp);

        i++;

        j++;

    }



    cout << ans << endl;

}



int main() {

    int t;

    cin >> t;

    while (t--) {

        solve();

    }

    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>

#include <vector>

#include <algorithm>

#include <climits>



using namespace std;

#define ll long long



void solve() {

    int n, l, r;

    cin >> n >> l >> r;

    vector<int> arr(n + 1);

    arr[0] = 0;

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

        cin >> arr[i];

    }



    vector<int> a(arr.begin() + 1, arr.begin() + l);

    vector<int> b(arr.begin() + l, arr.begin() + r + 1);

    vector<int> c(arr.begin() + r + 1, arr.end());



    ll ans = 0;

    for (int i = l; i <= r; i++) {

        ans += arr[i];

    }



    int x = a.size(), y = b.size(), z = c.size();

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

    sort(b.rbegin(), b.rend());

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



    int i = 0, j = 0;

    ll temp = ans;



    while (i < y && j < z && b[i] > c[j]) {

        temp = (temp - b[i] + c[j]);

        ans = min(ans, temp);

        i++;

        j++;

    }



    i = 0, j = 0;

    temp = ans;



    while (i < y && j < x && b[i] > a[j]) {

        temp = (temp - b[i] + a[j]);

        ans = min(ans, temp);

        i++;

        j++;

    }



    cout << ans << endl;

}



int main() {

    int t;

    cin >> t;

    while (t--) {

        solve();

    }

    return 0;

}



Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;
#define ll long long

void solve() {
    int n, l, r;
    cin >> n >> l >> r;
    vector<int> arr(n + 1);
    arr[0] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
    }

    vector<int> a, b, c;
    for (int i = 1; i < l; i++) {
        a.push_back(arr[i]);
    }
    for (int i = l; i <= r; i++) {
        b.push_back(arr[i]);
    }
    for (int i = r + 1; i <= n; i++) {
        c.push_back(arr[i]);
    }

    ll ans = 0;
    for (int i = l; i <= r; i++) {
        ans += arr[i];
    }

    int x = a.size(), y = b.size(), z = c.size();
    sort(a.begin(), a.end());
    sort(b.rbegin(), b.rend());
    sort(c.begin(), c.end());

    int i = 0, j = 0;
    ll temp = ans;

    while (i < y && j < z && b[i] > c[j]) {
        temp = (temp - b[i] + c[j]);
        ans = min(ans, temp);
        i++;
        j++;
    }

    i = 0, j = 0;
    temp = ans;

    while (i < y && j < x && b[i] > a[j]) {
        temp = (temp - b[i] + a[j]);
        ans = min(ans, temp);
        i++;
        j++;
    }

    cout << ans << endl;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: PyPy 3-64


Submission (verdict: Wrong answer on test 2):
def voir(test,nb3):
    while test%9!=0 and nb3>0:
        test=(test+6)%9
        nb3-=1
    if test%9==0:
        return True
    else :
        return False

OUT=[]
for i in range(int(input())):
    s=input()
    somme=0
    nb2=0
    nb3=0
    for i in s:
        somme=(somme+int(i))%9
        if i=="2":
            nb2+=1 
        if i=="3":
            nb3+=1
    
    if somme==0 :
        OUT.append("YES")
    else :
        nb3+=nb2//3
        nb2=nb2%3
        
        if nb2==2 :
            test1=(somme+4)%9
            test2=(somme+2)%9
            test3=somme
            if voir(test1,nb3) or voir(test2,nb3) or voir(test3,nb3):
                OUT.append("YES")
            else :
                OUT.append("NO")
        elif nb2==1 :
            
            test2=(somme+2)%9
            test3=somme
            if voir(test2,nb3) or voir(test3,nb3):
                OUT.append("YES")
            else :
                OUT.append("NO")
        else:
            
            test3=somme
            if voir(test3,nb3):
                OUT.append("YES")
            else :
                OUT.append("NO")


for i in OUT:
    print(i)
Problem: 2050C - Uninteresting Number
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 2):
def voir(test,nb3):
    while test%9!=0 and nb3>0:
        test=(test+6)%9
        nb3-=1
    if test%9==0:
        return True
    else :
        return False

OUT=[]
for i in range(int(input())):
    s=input()
    somme=0
    nb2=0
    nb3=0
    for i in s:
        somme=(somme+int(i))%9
        if i=="2":
            nb2+=1 
        if i=="3":
            nb3+=1
    
    if somme==0 :
        OUT.append("YES")
    else :
        nb3+=nb2//3
        nb2=nb2%3
        
        if nb2==2 :
            test1=(somme+4)%9
            test2=(somme+2)%9
            test3=somme
            if voir(test1,nb3) or voir(test2,nb3) or voir(test3,nb3):
                OUT.append("YES")
            else :
                OUT.append("NO")
        elif nb2==1 :
            
            test2=(somme+2)%9
            test3=somme
            if voir(test2,nb3) or voir(test3,nb3):
                OUT.append("YES")
            else :
                OUT.append("NO")
        else:
            
            test3=somme
            if voir(test3,nb3):
                OUT.append("YES")
            else :
                OUT.append("NO")


for i in OUT:
    print(i)

        

    
    

Submission (verdict: Wrong answer on test 2):
def voir(test,nb3):
    while test!=0 and nb3>0:
        test=(test+6)%9
        nb3-=1
    if test==0:
        return True
    else :
        return False

OUT=[]
for i in range(int(input())):
    s=input()
    somme=0
    nb2=0
    nb3=0
    for i in s:
        somme=(somme+int(i))%9
        if i=="2":
            nb2+=1 
        if i=="3":
            nb3+=1
    
    if somme==0 :
        OUT.append("YES")
    else :
        nb3+=nb2//3
        nb2=nb2%3
        
        if nb2==2 :
            test1=(somme+4)%9
            test2=(somme+2)%9
            test3=somme
            if voir(test1,nb3) or voir(test2,nb3) or voir(test3,nb3):
                OUT.append("YES")
            else :
                OUT.append("NO")
        elif nb2==1 :
            test2=(somme+2)%9
            test3=somme
            if voir(test2,nb3) or voir(test3,nb3):
                OUT.append("YES")
            else :
                OUT.append("NO")
        else:
            
            test3=somme
            if voir(test3,nb3):
                OUT.append("YES")
            else :
                OUT.append("NO")


for i in OUT:
    print(i)
Problem: 2050C - Uninteresting Number
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 2):
def voir(test,nb3):
    while test!=0 and nb3>0:
        test=(test+6)%9
        nb3-=1
    if test==0:
        return True
    else :
        return False

OUT=[]
for i in range(int(input())):
    s=input()
    somme=0
    nb2=0
    nb3=0
    for i in s:
        somme=(somme+int(i))%9
        if i=="2":
            nb2+=1 
        if i=="3":
            nb3+=1
    
    if somme==0 :
        OUT.append("YES")
    else :
        nb3+=nb2//3
        nb2=nb2%3
        
        if nb2==2 :
            test1=(somme+4)%9
            test2=(somme+2)%9
            test3=somme
            if voir(test1,nb3) or voir(test2,nb3) or voir(test3,nb3):
                OUT.append("YES")
            else :
                OUT.append("NO")
        elif nb2==1 :
            test2=(somme+2)%9
            test3=somme
            if voir(test2,nb3) or voir(test3,nb3):
                OUT.append("YES")
            else :
                OUT.append("NO")
        else:
            
            test3=somme
            if voir(test3,nb3):
                OUT.append("YES")
            else :
                OUT.append("NO")


for i in OUT:
    print(i)

        

    
    
    

Submission (verdict: Accepted):
def voir(test,nb3):
    while test!=0 and nb3>0:
        test=(test+6)%9
        nb3-=1
    if test==0:
        return True
    else :
        return False

OUT=[]
for i in range(int(input())):
    s=input()
    somme=0
    nb2=0
    nb3=0
    for i in s:
        somme=(somme+int(i))%9
        if i=="2":
            nb2+=1 
        if i=="3":
            nb3+=1
    
    if somme==0 :
        OUT.append("YES")
    else :
        
        
        if nb2>=2 :
            
            if voir((somme+4)%9,(nb3+(nb2-2)//3)) or voir((somme+2)%9,(nb3+(nb2-1)//3)) or voir((somme)%9,(nb3+(nb2)//3)):
                OUT.append("YES")
            else :
                OUT.append("NO")
        elif nb2==1 :
            
            if voir((somme+2)%9,(nb3+(nb2-1)//3)) or voir((somme)%9,(nb3+(nb2)//3)):
                OUT.append("YES")
            else :
                OUT.append("NO")
        else:
            
            if voir((somme)%9,(nb3+(nb2)//3)):
                OUT.append("YES")
            else :
                OUT.append("NO")


for i in OUT:
    print(i)
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 8):
// @author : yassjd199
//
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vii;
typedef vector<long long> vll;
double eps = std::numeric_limits<double>::epsilon();
#define f first
#define s second
#define pb push_back
#define endl '\n'
#define ll  long long int
#define ull unsigned long long int
const int dx[4] = {0, 0, -1, 1}, dy[4] = { -1, 1, 0, 0};
//const int dx[8] = {0, 0, -1, 1, -1, -1, 1, 1} , dy[8] = {-1, 1, 0, 0, -1, 1, -1, 1};
const long long mod = 1e9 + 7;
const int N = 1e6 + 1, M = 20;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
template<typename T> using Set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename K, typename V> using Map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>;

void dbg_out() {
	cerr << endl;
}
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
	cerr << ' ' << H;
	dbg_out(T...);
}
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)





void testcase() {

	string str; cin >> str;
	int n = (int)str.size();
	string tmp;
	for (int i = 0; (int)tmp.size() != n;) {
		if (str[i] == '#') {
			i++;
			continue ;
		}
		int ans = str[i] - '0';
		int pos = i;
		for (int j = i + 1, ct = 0, cnt = 0; j < n && cnt < 9; j++) {
			if (str[j] == '#') {
				ct++;
				continue ;
			}
			int diff = j - i - ct ;
			cnt++;
			//dbg(j, str[j] - '0' - diff);
			if (ans < str[j] - '0' - diff) {
				ans = str[j] - '0' - diff;
				pos = j;
			}
		}
		str[pos] = '#';
		i += (pos == i);
		tmp += (ans + '0');
	}
	cout << tmp << endl;








}

int main() {
	ios::sync_with_stdio (0);
	cin.tie (0);
	cout.tie (0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int _ = 1;
	//int __ = 1;
	clock_t z = clock();
	cin >> _;

	while (_--) {
		//cout<<"Case #"<<__++<<": ";
		testcase();
	}

	cerr << endl << "Run Time: " << (( double ) ( clock() - z ) / CLOCKS_PER_SEC ) << endl;
	return 0;
}

/*   /\_/\
*   (= ._.)
*   / >  \>
*/
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

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

#define int long long
    signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL); 

int t;
cin>>t;
while(t--){
    int n,m;
    cin>>n>>m;
   
    map<int,int> mp1,mp2;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        mp1[x]++;
    }
    for(int i=0;i<m;i++){
        int x;
        cin>>x;
        mp2[x]++;
       
    }
   
    bool ans=true;
    auto it=mp2.end();
    
    int count=n-m;
    while(count){
        it=mp2.end();
        it--;
        int val=it->first;
        if(val==1){
            break;
        }
        if(mp1.find(val)==mp1.end()){
            count--;
            int fr=it->second;
            mp2.erase(it);
            if(val%2){
                
              mp2[val/2]+=fr;
              mp2[(val+1)/2]+=fr;
            }
            else{
                mp2[val/2]+=2*fr;
            }
        }
        else{
            if(mp1[val]==mp2[val]){
                mp1.erase(val);
                mp2.erase(val);
            }
            else if(mp1[val]>mp2[val]){
                mp1[val]-=mp2[val];
                mp2.erase(val);
            }
            else{
                mp2[val]-=mp1[val];
                mp1.erase(val);
            }
        }
        // cout<<mp1.size()<<" "<<mp2.size()<<endl;
      
    }
      if(mp1==mp2){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
   

}
}

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

#define int long long
    signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL); 

int t;
cin>>t;
while(t--){
    int n,m;
    cin>>n>>m;
   
    map<int,int> mp1,mp2;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        mp1[x]++;
    }
    for(int i=0;i<m;i++){
        int x;
        cin>>x;
        mp2[x]++;
       
    }
   
    bool ans=true;
    auto it=mp2.end();
    
    int count=n-m;
    while(count){
        it=mp2.end();
        it--;
        if(mp2.empty()){
            break;
        }
        int val=it->first;
        if(val==1||mp2.empty()){
            break;
        }
        if(mp1.find(val)==mp1.end()){
            count--;
            int fr=it->second;
            mp2.erase(it);
            if(val%2){
                
              mp2[val/2]+=fr;
              mp2[(val+1)/2]+=fr;
            }
            else{
                mp2[val/2]+=2*fr;
            }
        }
        else{
            if(mp1[val]==mp2[val]){
                mp1.erase(val);
                mp2.erase(val);
            }
            else if(mp1[val]>mp2[val]){
                mp1[val]-=mp2[val];
                mp2.erase(val);
            }
            else{
                mp2[val]-=mp1[val];
                mp1.erase(val);
            }
        }
        // cout<<mp1.size()<<" "<<mp2.size()<<endl;
      
    }
      if(mp1==mp2){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
   

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


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

#define int long long
    signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL); 

int t;
cin>>t;
while(t--){
    int n,m;
    cin>>n>>m;
   
    map<int,int> mp1,mp2;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        mp1[x]++;
    }
    for(int i=0;i<m;i++){
        int x;
        cin>>x;
        mp2[x]++;
       
    }
   
    bool ans=true;
    auto it=mp2.end();
    
    int count=n-m;
    while(count){
        it=mp2.end();
        it--;
        int val=it->first;
        if(val==1){
            break;
        }
        if(mp1.find(val)==mp1.end()){
            count--;
            int fr=it->second;
            mp2.erase(it);
            if(val%2){
                
              mp2[val/2]+=fr;
              mp2[(val+1)/2]+=fr;
            }
            else{
                mp2[val/2]+=2*fr;
            }
        }
        else{
            if(mp1[val]==mp2[val]){
                mp1.erase(val);
                mp2.erase(val);
            }
            else if(mp1[val]>mp2[val]){
                mp1[val]-=mp2[val];
                mp2.erase(val);
            }
            else{
                mp2[val]-=mp1[val];
                mp1.erase(val);
            }
        }
        // cout<<mp1.size()<<" "<<mp2.size()<<endl;
      
    }
      if(mp1==mp2){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
   

}
}