ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 3):
// author: лелутик :3
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <cassert>
#include <map>
#include <cmath>
#include <iomanip>
#include <random>
#include <functional>
#include <string>
#include <queue>
#include <stack>

using namespace std;
#define int               long long
#define pii               pair<int, int>
#define line              cout << "\n"
#define pb                push_back
#define ppb               pop_back
#define sz(a)             (int) a.size()
#define all(a)            a.begin(), a.end()
#define rall(a)           a.rbegin(), a.rend()
#define fast              ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
typedef long long ll;
typedef long double ld;
typedef string str;
mt19937 rnd(time(0));
const int MOD = 998244353;


void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(m);
    multiset<int> st;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        st.insert(a[i]);
    }
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
    sort(all(b));
    int i = 0;
    while (sz(st) && i < sz(b)) {
        int x = *st.begin();
        st.erase(st.begin());
        if (x == b[i]) {
            i++;
            continue;
        }
        if (!sz(st)) {
            cout << "No"; line;
            return;
        }
        int y = *st.begin();
        st.erase(st.begin());
        if (y - x > 1) {
            cout << "No"; line;
            return;
        }
        st.insert(x + y);
    }
    if (sz(st) || i != sz(b)) {
        cout << "No"; line;
        return;
    }
    cout << "Yes"; line;
}


signed main() {
    fast;


#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif


    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


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



#define pb push_back

#define eb emplace_back

#define all0(a) a.begin(), a.end()

#define all1(a) a.begin() + 1, a.end()

#define int long long

using namespace std;

typedef long long LL;

typedef pair<int, int> PII;

typedef pair<double, int> PDI;

const int N = 2e5 + 10, INF = 0x3f3f3f3f3f3f3f3f, MOD = 998244353, mod = 1e9 + 7;



void solve() {

    int n, m;

    cin >> n >> m;

    vector<int> a(n + 1), b(m + 1);

    map<int, int> mp1, mp2;

    for (int i = 1; i <= n;i++) cin >> a[i],mp1[a[i]]++;

    for (int i = 1; i <= m;i++) cin >> b[i],mp2[b[i]]++;

    sort(all1(a)), sort(all1(b));

    bool ok = 1;



    auto calc = [&](auto self, int x) -> void {

        if(x == 1)  return;

        if(x % 2 == 0){

            int l, r;

            l = r = x / 2;

            if(mp1[l] >= 2){

                mp1[x]++;

                mp1[l] -= 2;

                return;

            }else    self(self, l);

        }else{

            int l, r;

            l = x / 2, r = (x + 1) / 2;

            if(mp1[l] && mp1[r]){

                mp1[x]++;

                mp1[l]--, mp1[r]--;

            }else{

                self(self, l), self(self, r);

            }

        }

    };

    for(auto [x,y] : mp2){

        if(mp1[x] >= y) mp1[x] -= y;

        else{

            int t1 = x, cnt = y - mp1[x];

            int l, r;

            if(x % 2 == 0)  l = r = x / 2;

            else l = x / 2,r = (x + 1) / 2;

            while(cnt > 0){

                if(l == r){

                    if(mp1[l] >= 2) mp1[l] -= 2,cnt--;

                    else break;

                }else{

                    calc(calc,l), calc(calc,r);

                    if(mp1[l] && mp1[r])    mp1[l]--,mp1[r]--,cnt--;

                    else break;

                }

            }

            if(cnt){

                ok = 0;

                break;

            }

        }

    }

    vector<int> c, d;

    for(auto [x,y] : mp1)

        for (int j = 0; j < y;j++)  c.pb(x);

    for(auto [x,y] : mp2)

        for(int j = 0;j < y;j++)    d.pb(x);

    sort(all0(c)), sort(all0(d));

    // for(auto x : c) cout << x << ' ';

    // cout << '\n';

    // for(auto x : d) cout << x << ' ';

    // cout << '\n';

    if(c.size() != 0) ok = 0; 

    if(ok)  cout << "Yes\n";

    else cout << "No\n";

}

signed main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr), cout.tie(nullptr);

    // freopen("in.txt", "r", stdin);

    // freopen("out.txt", "w", stdout);

    int T = 1;

    cin >> T;

    while (T--) {

        solve();

    }

    return 0;

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


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

void solve()
{
	int l,r;
	cin>>l>>r;
	int a=0,b=0,c=0;
	for(int i=29;i>=0;i--)
	{
		if((l^r)>>i&1)
		{
			b|=1<<i;
			a|=(1<<i)-1;
			break;
		}
		//else
		//{
		//	a|=l&(1<<i);
		//	b|=l&(1<<i);
		//}
	}
	c=l;
	while(c==a||c==b)
		c++;
	cout<<a<<" "<<b<<" "<<c<<"\n";
	return ;
}


int main()
{
	int t;
	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):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vv vector

void solve()
{
	int l,r;
	cin>>l>>r;
	int a=0,b=0,c=0;
	for(int i=29;i>=0;i--)
	{
		if((l^r)>>i&1)
		{
			b|=1<<i;
			a|=(1<<i)-1;
			break;
		}
		//else
		//{
		//	a|=l&(1<<i);
		//	b|=l&(1<<i);
		//}
	}
	c=l;
	while(c==a||c==b)
		c++;
	cout<<a<<" "<<b<<" "<<c<<"\n";
	return ;
}


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

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define inf 1000000007
const int N = 1e7;
int a[N];

void solve()
{
	int l,r;
	cin>>l>>r;
	int a=0,b=0,c=0;
	for(int i=29;i>=0;i++)
	{
		if((l^r)>>i&1)
		{
			a|=1<<i;
			b|=(1<<i)-1;
			break;
		}
		else
		{
			a|=r&(1<<i);
			b|=r&(1<<i);
		}
	}
	c=l;
	while(c==a||c==b)c++;
	cout<<a<<" "<<b<<" "<<c<<"\n";
	return;
}

int main()
{
	int t;
	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):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define inf 1000000007
const int N = 1e7;
int a[N];

void solve()
{
	int l,r;
	cin>>l>>r;
	int a=0,b=0,c=0;
	for(int i=29;i>=0;i++)
	{
		if((l^r)>>i&1)
		{
			a|=1<<i;
			b|=(1<<i)-1;
			break;
		}
		else
		{
			a|=l&(1<<i);
			b|=l&(1<<i);
		}
	}
	c=l;
	while(c==a||c==b)c++;
	cout<<a<<" "<<b<<" "<<c<<"\n";
	return;
}

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

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define inf 1000000007
const int N = 1e7;
int a[N];

void solve()
{
	int l,r;
	cin>>l>>r;
	int a=0,b=0,c=0;
	for(int i=29;i>=0;i--)
	{
		if((l^r)>>i&1)
		{
			a|=1<<i;
			b|=(1<<i)-1;
			break;
		}
		else
		{
			a|=l&(1<<i);
			b|=l&(1<<i);
		}
	}
	c=l;
	while(c==a||c==b)c++;
	cout<<a<<" "<<b<<" "<<c<<"\n";
	return;
}

int main()
{
	int t;
	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):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define inf 1000000007
const int N = 1e7;
int a[N];

void solve()
{
	int l,r;
	cin>>l>>r;
	int a=0,b=0,c=0;
	for(int i=29;i>=0;i++)
	{
		if((l^r)>>i&1)
		{
			a|=1<<i;
			b|=(1<<i)-1;
			break;
		}
		else
		{
			a|=r&(1<<i);
			b|=r&(1<<i);
		}
	}
	c=l;
	while(c==a||c==b)c++;
	cout<<a<<" "<<b<<" "<<c<<"\n";
	return;
}

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

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define inf 1000000007
const int N = 1e7;
int a[N];

void solve()
{
	int l,r;
	cin>>l>>r;
	int a=0,b=0,c=0;
	for(int i=29;i>=0;i++)
	{
		if((l^r)>>i&1)
		{
			a|=1<<i;
			b|=(1<<i)-1;
			break;
		}
		else
		{
			a|=l&(1<<i);
			b|=l&(1<<i);
		}
	}
	c=l;
	while(c==a||c==b)c++;
	cout<<a<<" "<<b<<" "<<c<<"\n";
	return;
}

int main()
{
	int t;
	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):
#include <iostream>
#include <vector>
#include <set>
using namespace std;

int main() {
    int tt;
    cin >> tt;
    while(tt--) {
        int n, m;
        cin >> n >> m;
        multiset<long long> a;
        multiset<long long> b;
        for(int i=0; i<n;i++) {
            int x;
            cin >> x;
            a.insert(x);
        }
        for(int i=0; i<m;i++) {
            int x;
            cin >> x;
            b.insert(x);
        }

        bool f = true;
        while(a.begin() != a.end() && b.begin() != b.end()) {
            if(*a.begin() == *b.begin()) {
                a.erase(a.begin());
                b.erase(b.begin());
            }
            else if(*a.begin() < *b.begin()){
                int x1 = *a.begin();
                a.erase(a.begin());
                if(a.begin() == a.end()) {
                    f = false;
                    break;
                }
                int x2 = *a.begin();
                a.erase(a.begin());
                if(x2-x1 <= 1) {
                    a.insert(x1+x2);
                }
                else {
                    f = false;
                    break;
                }
            }
            else {
                f = false;
                break;
            }
        }

        if(f && a.empty() && b.empty()) {
            cout << "YES" << endl;
        }
        else {
            cout << "NO" << endl;
        }


    }
    return 0;
}


Submission (verdict: Accepted):
#include <iostream>
#include <vector>
#include <set>
using namespace std;

int main() {
    int tt;
    cin >> tt;
    while(tt--) {
        int n, m;
        cin >> n >> m;
        multiset<long long> a;
        multiset<long long> b;
        for(int i=0; i<n;i++) {
            int x;
            cin >> x;
            a.insert(x);
        }
        for(int i=0; i<m;i++) {
            int x;
            cin >> x;
            b.insert(x);
        }

        bool f = true;
        while(!b.empty()) {
            auto it = a.find(*b.begin());
            if(it == a.end()) {
                if(*b.begin() == 1 || a.empty()) {
                    f = false;
                    break;
                }
                int x = *b.begin();
                b.erase(b.begin());
                int x1 = x/2;
                int x2 = x/2 + x%2;
                b.insert(x1);
                b.insert(x2);
            }
            else {
                a.erase(it);
                b.erase(b.begin());
            }
        }

        if(f && a.empty()) {
            cout << "YES" << endl;
        }
        else {
            cout << "NO" << endl;
        }

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

Previous submission (verdict: Wrong answer on test 3):
#include <iostream>
#include <vector>
#include <set>
using namespace std;

int main() {
    int tt;
    cin >> tt;
    while(tt--) {
        int n, m;
        cin >> n >> m;
        multiset<long long> a;
        multiset<long long> b;
        for(int i=0; i<n;i++) {
            int x;
            cin >> x;
            a.insert(x);
        }
        for(int i=0; i<m;i++) {
            int x;
            cin >> x;
            b.insert(x);
        }

        bool f = true;
        while(a.begin() != a.end()) {
            if(*a.begin() == *b.begin()) {
                a.erase(a.begin());
                b.erase(b.begin());
            }
            else if(*a.begin() < *b.begin()){
                int x1 = *a.begin();
                a.erase(a.begin());
                if(a.begin() == a.end()) {
                    f = false;
                    break;
                }
                int x2 = *a.begin();
                a.erase(a.begin());
                if(x2-x1 <= 1) {
                    a.insert(x1+x2);
                }
                else {
                    f = false;
                    break;
                }
            }
            else {
                f = false;
                break;
            }
        }

        if(f && a.empty() && b.empty()) {
            cout << "YES" << endl;
        }
        else {
            cout << "NO" << endl;
        }


    }
    return 0;
}


Submission (verdict: Wrong answer on test 3):
#include <iostream>
#include <vector>
#include <set>
using namespace std;

int main() {
    int tt;
    cin >> tt;
    while(tt--) {
        int n, m;
        cin >> n >> m;
        multiset<long long> a;
        multiset<long long> b;
        for(int i=0; i<n;i++) {
            int x;
            cin >> x;
            a.insert(x);
        }
        for(int i=0; i<m;i++) {
            int x;
            cin >> x;
            b.insert(x);
        }

        bool f = true;
        while(a.begin() != a.end() && b.begin() != b.end()) {
            if(*a.begin() == *b.begin()) {
                a.erase(a.begin());
                b.erase(b.begin());
            }
            else if(*a.begin() < *b.begin()){
                int x1 = *a.begin();
                a.erase(a.begin());
                if(a.begin() == a.end()) {
                    f = false;
                    break;
                }
                int x2 = *a.begin();
                a.erase(a.begin());
                if(x2-x1 <= 1) {
                    a.insert(x1+x2);
                }
                else {
                    f = false;
                    break;
                }
            }
            else {
                f = false;
                break;
            }
        }

        if(f && a.empty() && b.empty()) {
            cout << "YES" << endl;
        }
        else {
            cout << "NO" << endl;
        }


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

Previous submission (verdict: Wrong answer on test 3):
#include <iostream>
#include <vector>
#include <set>
using namespace std;

int main() {
    int tt;
    cin >> tt;
    while(tt--) {
        int n, m;
        cin >> n >> m;
        multiset<long long> a;
        multiset<long long> b;
        for(int i=0; i<n;i++) {
            int x;
            cin >> x;
            a.insert(x);
        }
        for(int i=0; i<m;i++) {
            int x;
            cin >> x;
            b.insert(x);
        }

        bool f = true;
        while(a.begin() != a.end()) {
            if(*a.begin() == *b.begin()) {
                a.erase(a.begin());
                b.erase(b.begin());
            }
            else if(*a.begin() < *b.begin()){
                int x1 = *a.begin();
                a.erase(a.begin());
                if(a.begin() == a.end()) {
                    f = false;
                    break;
                }
                int x2 = *a.begin();
                a.erase(a.begin());
                if(x2-x1 <= 1) {
                    a.insert(x1+x2);
                }
                else {
                    f = false;
                }
            }
            else {
                f = false;
                break;
            }
        }

        if(f && a.empty() && b.empty()) {
            cout << "YES" << endl;
        }
        else {
            cout << "NO" << endl;
        }


    }
    return 0;
}


Submission (verdict: Wrong answer on test 3):
#include <iostream>
#include <vector>
#include <set>
using namespace std;

int main() {
    int tt;
    cin >> tt;
    while(tt--) {
        int n, m;
        cin >> n >> m;
        multiset<long long> a;
        multiset<long long> b;
        for(int i=0; i<n;i++) {
            int x;
            cin >> x;
            a.insert(x);
        }
        for(int i=0; i<m;i++) {
            int x;
            cin >> x;
            b.insert(x);
        }

        bool f = true;
        while(a.begin() != a.end()) {
            if(*a.begin() == *b.begin()) {
                a.erase(a.begin());
                b.erase(b.begin());
            }
            else if(*a.begin() < *b.begin()){
                int x1 = *a.begin();
                a.erase(a.begin());
                if(a.begin() == a.end()) {
                    f = false;
                    break;
                }
                int x2 = *a.begin();
                a.erase(a.begin());
                if(x2-x1 <= 1) {
                    a.insert(x1+x2);
                }
                else {
                    f = false;
                    break;
                }
            }
            else {
                f = false;
                break;
            }
        }

        if(f && a.empty() && b.empty()) {
            cout << "YES" << endl;
        }
        else {
            cout << "NO" << endl;
        }


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


Submission (verdict: Wrong answer on test 3):
#include <iostream>
#include <vector>
#include <set>
using namespace std;

int main() {
    int tt;
    cin >> tt;
    while(tt--) {
        int n, m;
        cin >> n >> m;
        multiset<long long> a;
        multiset<long long> b;
        for(int i=0; i<n;i++) {
            int x;
            cin >> x;
            a.insert(x);
        }
        for(int i=0; i<m;i++) {
            int x;
            cin >> x;
            b.insert(x);
        }

        bool f = true;
        while(a.begin() != a.end()) {
            if(*a.begin() == *b.begin()) {
                a.erase(a.begin());
                b.erase(b.begin());
            }
            else if(*a.begin() < *b.begin()){
                int x1 = *a.begin();
                a.erase(a.begin());
                if(a.begin() == a.end()) {
                    f = false;
                    break;
                }
                int x2 = *a.begin();
                a.erase(a.begin());
                if(x2-x1 <= 1) {
                    a.insert(x1+x2);
                }
                else {
                    f = false;
                }
            }
            else {
                f = false;
                break;
            }
        }

        if(f && a.empty() && b.empty()) {
            cout << "YES" << endl;
        }
        else {
            cout << "NO" << endl;
        }


    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

void solve(int n, int k, vector<int> vec)
{
    vector<long long> frequencies;
    sort(vec.begin(), vec.end());

    long long current = vec[0];
    long long count = 0;

    for (int i = 0; i < n; i++)
    {
        if (vec[i] == current)
        {
            count++;
        }
        else 
        {
            frequencies.push_back(count);
            current = vec[i];
            count = 1;
        }
    }
    frequencies.push_back(count);
    int fa = 0;
    for (int i = 0; i < frequencies.size(); i++)
    {
        fa++;
    }

    sort(frequencies.begin(), frequencies.end(), [](const long long &a, const long long &b) -> bool{
            return a > b;
        });

    if (k >= n)
    {
        cout << "1\n";        
    }
        
    long long target = n - k;
    long long cumulative = 0;
    long long r =0;
    for(auto f: frequencies){
        cumulative += f;
        r++;
        if(cumulative >= target){
            break;
        }
    }
    r = max(r, (long long)1);
    cout << r << "\n";

}

int main()
{
    int cases;
    cin >> cases;

    while (cases--)
    {
        int n, k;
        cin >> n >> k;
        vector<int> vec(n);
        for (int i = 0; i < n; i++)
        {
            cin >> vec[i];
        }
        solve(n, k, vec);
    }
    return 0;
}

Submission (verdict: Accepted):
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

void solve(int n, int k, vector<int> vec)
{
    vector<long long> frequencies;
    sort(vec.begin(), vec.end());

    long long current = vec[0];
    long long count = 0;

    for (int i = 0; i < n; i++)
    {
        if (vec[i] == current)
        {
            count++;
        }
        else 
        {
            frequencies.push_back(count);
            current = vec[i];
            count = 1;
        }
    }
    frequencies.push_back(count);
    int fa = 0;
    for (int i = 0; i < frequencies.size(); i++)
    {
        fa++;
    }

    sort(frequencies.begin(), frequencies.end(), [](const long long &a, const long long &b) -> bool{
            return a > b;
        });

    if (k >= n)
    {
        cout << "1\n";        
        return;
    }
        
    long long target = n - k;
    long long cumulative = 0;
    long long r =0;
    for(auto f: frequencies){
        cumulative += f;
        r++;
        if(cumulative >= target){
            break;
        }
    }
    r = max(r, (long long)1);
    cout << r << "\n";

}

int main()
{
    int cases;
    cin >> cases;

    while (cases--)
    {
        int n, k;
        cin >> n >> k;
        vector<int> vec(n);
        for (int i = 0; i < n; i++)
        {
            cin >> vec[i];
        }
        solve(n, k, vec);
    }
    return 0;
}