ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>

using namespace std;
const int INF = 0x3f3f3f3f;

int calc(string &a, string &b, string &c, int i = 0, int j = 0, int k = 0) {
    if (k == (int)c.size()) return 0;
    int mn = INF;
    if (i < (int)a.size())
        mn = calc(a, b, c, i + 1, j, k + 1) + (a[i] != c[k]);
    if (j < (int)b.size())
        mn = min(mn, calc(a, b, c, i, j + 1, k + 1) + (b[j] != c[k]));
    return mn;
}

int main() {
    int t, n, m;
    string a, b, c;
    cin >> t;
    while (t--) {
        cin >> a;
        cin >> b;
        cin >> c;
        cout << calc(a, b, c) << "\n";
    }
    return 0;
}

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

using namespace std;
const int INF = 0x3f3f3f3f, N = 1e3 + 5;
int dp[N][N];

int main() {
    int t, n, m;
    string a, b, c;
    cin >> t;
    while (t--) {
        cin >> a;
        cin >> b;
        cin >> c;
        a = "." + a;
        b = ">" + b;
        c = "<" + c;
        dp[0][0] = 0;
        for (int i = 1; i <= (int)a.size(); i++) dp[i][0] = dp[i - 1][0] + (a[i] != c[i]);
        for (int i = 1; i <= (int)b.size(); i++) dp[0][i] = dp[0][i - 1] + (b[i] != c[i]);
        for (int i = 1; i <= (int)a.size(); i++) {
            for (int j = 1; j <= (int)b.size(); j++) {
                dp[i][j] = min(
                    (i + j < (int)a.size() + (int)b.size() && a[i] != c[i + j]) + (i - 1 >= 0 ? dp[i - 1][j] : 0),
                    (i + j < (int)a.size() + (int)b.size() && b[j] != c[i + j]) + (j - 1 >= 0 ? dp[i][j - 1] : 0));
                // cerr << dp[i][j] << " ";
            }
            // cerr << endl;
        }
        cout << dp[(int)a.size()][(int)b.size()] << "\n";
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)


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

int main(){

    int t;
    cin >> t;

    while (t--){

        int n, k;
        cin >> n >> k;

        vector<int> nums(n);
        map<int,set<int>> fren;
        for (int i = 0; i < n; ++i) cin >> nums[i];
        sort(nums.begin(),nums.end());
        int cnt = 0;
        for (int i = 0; i < n; ++i){
            if (i > 0 && nums[i-1] != nums[i]){
                fren[cnt].insert(nums[i-1]);
                cnt = 1;
            }
            else cnt++;
        }
        fren[cnt].insert(nums.back());
        auto it = fren.begin();
        while (k > 0){
            while (!it->second.empty() && k > 0){
                k -= it->first;
                it->second.erase(it->second.begin());
                if (fren.size() == 1 && fren.begin()->second.size() == 1) break;
            }
            if (fren.size() == 1 && fren.begin()->second.size() == 1) break;
        }

        cnt = 0;
        for (auto &[u,v]: fren){
            for (auto x: v) cnt++;
        }

        cout << cnt << '\n';
    }

    return 0;
}
Problem: 2057B - Gorilla and the Exam
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(){

    int t;
    cin >> t;

    while (t--){

        int n, k;
        cin >> n >> k;

        vector<int> nums(n);
        map<int,set<int>> fren;
        for (int i = 0; i < n; ++i) cin >> nums[i];
        sort(nums.begin(),nums.end());
        int cnt = 0;
        for (int i = 0; i < n; ++i){
            if (i > 0 && nums[i-1] != nums[i]){
                fren[cnt].insert(nums[i-1]);
                cnt = 1;
            }
            else cnt++;
        }
        fren[cnt].insert(nums.back());
        auto it = fren.begin();
        while (k > 0){
            while (!it->second.empty() && k > 0){
                k -= it->first;
                it->second.erase(it->second.begin());
                if (fren.size() == 1 && fren.begin()->second.size() == 1) break;
            }
            if (fren.size() == 1 && fren.begin()->second.size() == 1) break;
        }

        cnt = 0;
        for (auto &[u,v]: fren){
            for (auto x: v) cnt++;
        }

        cout << cnt << '\n';
    }

    return 0;
}

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

int main(){

    int t;
    cin >> t;

    while (t--){

        int n, k;
        cin >> n >> k;

        vector<int> nums(n);
        map<int,set<int>> fren;
        for (int i = 0; i < n; ++i) cin >> nums[i];
        sort(nums.begin(),nums.end());
        int cnt = 0;
        for (int i = 0; i < n; ++i){
            if (i > 0 && nums[i-1] != nums[i]){
                fren[cnt].insert(nums[i-1]);
                cnt = 1;
            }
            else cnt++;
        }
        fren[cnt].insert(nums.back());
        while (k > 0){
            auto it = fren.begin();
            while (!it->second.empty() && k > 0){
                k -= it->first;
                if (k < 0) break;
                it->second.erase(it->second.begin());
                if (it->second.empty()) fren.erase(it);
                if (fren.size() == 1 && fren.begin()->second.size() == 1) break;
            }
            if (fren.size() == 1 && fren.begin()->second.size() == 1) break;
        }

        cnt = 0;
        for (auto &[u,v]: fren){
            for (auto x: v) cnt++;
        }

        cout << cnt << '\n';
    }

    return 0;
}
Problem: 2057B - Gorilla and the Exam
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;

int main(){

    int t;
    cin >> t;

    while (t--){

        int n, k;
        cin >> n >> k;

        vector<int> nums(n);
        map<int,set<int>> fren;
        for (int i = 0; i < n; ++i) cin >> nums[i];
        sort(nums.begin(),nums.end());
        int cnt = 0;
        for (int i = 0; i < n; ++i){
            if (i > 0 && nums[i-1] != nums[i]){
                fren[cnt].insert(nums[i-1]);
                cnt = 1;
            }
            else cnt++;
        }
        fren[cnt].insert(nums.back());
        while (k > 0){
            auto it = fren.begin();
            while (!it->second.empty() && k > 0){
                k -= it->first;
                if (k < 0) break;
                it->second.erase(it->second.begin());
                if (it->second.empty()) fren.erase(it);
                if (fren.size() == 1 && fren.begin()->second.size() == 1) break;
            }
            if (fren.size() == 1 && fren.begin()->second.size() == 1) break;
        }

        cnt = 0;
        for (auto &[u,v]: fren){
            for (auto x: v) cnt++;
        }

        cout << cnt << '\n';
    }

    return 0;
}

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

int main(){

    int t;
    cin >> t;

    while (t--){

        int n, k;
        cin >> n >> k;

        vector<int> nums(n);
        map<int,set<int>> fren;
        for (int i = 0; i < n; ++i) cin >> nums[i];
        sort(nums.begin(),nums.end());
        int cnt = 0;
        for (int i = 0; i < n; ++i){
            if (i > 0 && nums[i-1] != nums[i]){
                fren[cnt].insert(nums[i-1]);
                cnt = 1;
            }
            else cnt++;
        }
        fren[cnt].insert(nums.back());
        while (k > 0){
            auto it = fren.begin();
            while (!it->second.empty() && k > 0){
                k -= it->first;
                if (k < 0) break;
                it->second.erase(it->second.begin());
                if (it->second.empty()){ fren.erase(it); break; }
                if (fren.size() == 1 && fren.begin()->second.size() == 1) break;
            }
            if (fren.size() == 1 && fren.begin()->second.size() == 1) break;
        }

        cnt = 0;
        for (auto &[u,v]: fren){
            for (auto x: v) cnt++;
        }

        cout << cnt << '\n';
    }

    return 0;
}
Problem: 2057B - Gorilla and the Exam
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;

int main(){

    int t;
    cin >> t;

    while (t--){

        int n, k;
        cin >> n >> k;

        vector<int> nums(n);
        map<int,set<int>> fren;
        for (int i = 0; i < n; ++i) cin >> nums[i];
        sort(nums.begin(),nums.end());
        int cnt = 0;
        for (int i = 0; i < n; ++i){
            if (i > 0 && nums[i-1] != nums[i]){
                fren[cnt].insert(nums[i-1]);
                cnt = 1;
            }
            else cnt++;
        }
        fren[cnt].insert(nums.back());
        while (k > 0){
            auto it = fren.begin();
            while (!it->second.empty() && k > 0){
                k -= it->first;
                if (k < 0) break;
                it->second.erase(it->second.begin());
                if (it->second.empty()){ fren.erase(it); break; }
                if (fren.size() == 1 && fren.begin()->second.size() == 1) break;
            }
            if (fren.size() == 1 && fren.begin()->second.size() == 1) break;
        }

        cnt = 0;
        for (auto &[u,v]: fren){
            for (auto x: v) cnt++;
        }

        cout << cnt << '\n';
    }

    return 0;
}

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

int main(){

    int t;
    cin >> t;

    while (t--){

        int n, k;
        cin >> n >> k;

        vector<int> nums(n);
        map<int,int> fren;
        for (int i = 0; i < n; ++i) cin >> nums[i];
        sort(nums.begin(),nums.end());
        int cnt = 0;
        for (int i = 0; i < n; ++i){
            if (i > 0 && nums[i-1] != nums[i]){
                fren[cnt]++;
                cnt = 1;
            }
            else cnt++;
        }
        fren[cnt]++;

        while (k > 0){
            if (fren.size() == 1 && fren.begin()->second == 1) break;
            k -= fren.begin()->first;
            if (k < 0) break;
            fren.begin()->second--;
            if (fren.begin()->second == 0){
                fren.erase(fren.begin());
            }
            
        }
        cnt = 0;
        for (auto &[u, v]: fren){
            cnt += v;
        }

        cout << cnt << '\n';
    }

    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef __int128 i128;
typedef  unsigned __int128 u128;

mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
//uniform_int_distribution<T> dist(l,r);

//T x=dist(rnd); {random x \in [l,r]}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//clog<<"\n\n--------------------------------\n\n";
	int n;cin>>n;
	while(n--) solve();
	return 0;
}

//cout << fixed << setprecision(x);
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef __int128 i128;
typedef  unsigned __int128 u128;

mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
//uniform_int_distribution<T> dist(l,r);

//T x=dist(rnd); {random x \in [l,r]}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//clog<<"\n\n--------------------------------\n\n";
	int n;cin>>n;
	while(n--) solve();
	return 0;
}

//cout << fixed << setprecision(x);

Submission (verdict: Wrong answer on test 1):
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef __int128 i128;
typedef  unsigned __int128 u128;

mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
//uniform_int_distribution<T> dist(l,r);

//T x=dist(rnd); {random x \in [l,r]}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//clog<<"\n\n--------------------------------\n\n";
	int n;cin>>n;
	while(n--) solve();
	return 0;
}

//cout << fixed << setprecision(x);
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef __int128 i128;
typedef  unsigned __int128 u128;

mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
//uniform_int_distribution<T> dist(l,r);

//T x=dist(rnd); {random x \in [l,r]}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//clog<<"\n\n--------------------------------\n\n";
	int n;cin>>n;
	while(n--) solve();
	return 0;
}

//cout << fixed << setprecision(x);

Submission (verdict: Accepted):
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef __int128 i128;
typedef  unsigned __int128 u128;

mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
//uniform_int_distribution<T> dist(l,r);

//T x=dist(rnd); {random x \in [l,r]}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//clog<<"\n\n--------------------------------\n\n";
	int n;cin>>n;
	while(n--) solve();
	return 0;
}

//cout << fixed << setprecision(x);
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    const int K = 200; // 取前200个顶点检查
    while (t--) {
        int n;
        cin >> n;
        if (n == 2) {
            cout << 0 << '\n';
            int u, v;
            cin >> u >> v;
            continue;
        }
        vector<unordered_set<int>> adj(n + 1);
        vector<int> degrees(n + 1, 0);
        vector<pair<int, int>> edges;
        for (int i = 0; i < n - 1; ++i) {
            int u, v;
            cin >> u >> v;
            adj[u].insert(v);
            adj[v].insert(u);
            degrees[u]++;
            degrees[v]++;
            edges.emplace_back(u, v);
        }
        // 计算相邻顶点对的最大度数之和-1
        int max_adj = 0;
        for (auto &[u, v] : edges) {
            int current = degrees[u] + degrees[v] - 1;
            if (current > max_adj) {
                max_adj = current;
            }
        }
        // 按度数降序排列顶点
        vector<int> nodes(n);
        iota(nodes.begin(), nodes.end(), 1);
        sort(nodes.begin(), nodes.end(), [&](int a, int b) {
            return degrees[a] > degrees[b];
        });
        // 检查前K个顶点中的不相邻对
        int m = min(n, K);
        int max_non_adj = 0;
        for (int i = 0; i < m; ++i) {
            int u = nodes[i];
            for (int j = i + 1; j < m; ++j) {
                int v = nodes[j];
                if (adj[u].find(v) == adj[u].end()) {
                    int current = degrees[u] + degrees[v];
                    if (current > max_non_adj) {
                        max_non_adj = current;
                    }
                }
            }
        }
        // 计算最大值并输出结果
        int max_value = max(max_adj, max_non_adj);
        cout << max_value - 1 << '\n';
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define F first
#define S second
#define int long long

using namespace std;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

void solve() {
    int n;
    cin >> n;
    int c[n + 1];
    for(int i = 1; i <= n; i++) {
        cin >> c[i];
    }
    vector <pii> ans;
    int pos[n + 1];
    int p[n + 1];
    for(int i = 1; i <= n; i++) {
        pos[i] = i;
        p[i] = i;
    }
    for(int i = 1; i <= n; i++) {
        int x = pos[c[i]];
        for(int j = x + 1; j <= n - i + 1; j++) {
            ans.pb({p[j], c[i]});
            swap(p[j], p[j - 1]);
            x++;
        }
        for(int j = n - i; j >= 1; j--) {
            ans.pb({c[i], p[j]});
            swap(p[j], p[j + 1]);
        }
        for(int j = 1; j <= n; j++) {
            swap(p[j], p[j + 1]);
        }
    }
    cout << ans.size() << "\n";
    for(auto [x, y] : ans)
        cout << x << " " << y << "\n";
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef STRIKAZA
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif // STRIKAZA
    int t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define F first
#define S second
#define int long long

using namespace std;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

void solve() {
    int n;
    cin >> n;
    int c[n + 1];
    for(int i = 1; i <= n; i++) {
        cin >> c[i];
    }
    vector <pii> ans;
    int pos[n + 1];
    int p[n + 1];
    for(int i = 1; i <= n; i++) {
        pos[i] = i;
        p[i] = i;
    }
    for(int i = 1; i <= n; i++) {
        int x = pos[c[i]];
        for(int j = x + 1; j <= n - i + 1; j++) {
            ans.pb({p[j], c[i]});
            swap(p[j], p[j - 1]);
            x++;
        }
        for(int j = n - i; j >= 1; j--) {
            ans.pb({c[i], p[j]});
            swap(p[j], p[j + 1]);
        }
        for(int j = 1; j <= n; j++) {
            swap(p[j], p[j + 1]);
        }
    }
    cout << ans.size() << "\n";
    for(auto [x, y] : ans)
        cout << x << " " << y << "\n";
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef STRIKAZA
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif // STRIKAZA
    int t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}


Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define F first
#define S second
#define int long long

using namespace std;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

void solve() {
    int n;
    cin >> n;
    int c[n + 1];
    for(int i = 1; i <= n; i++) {
        cin >> c[i];
    }
    vector <pii> ans;
    int pos[n + 1];
    int p[n + 1];
    for(int i = 1; i <= n; i++) {
        pos[i] = i;
        p[i] = i;
    }
    for(int i = 1; i <= n; i++) {
        int x = pos[c[i]];
        for(int j = x + 1; j <= n - i + 1; j++) {
            ans.pb({p[j], c[i]});
            swap(p[j], p[j - 1]);
            x++;
        }
        for(int j = n - i; j >= 1; j--) {
            ans.pb({c[i], p[j]});
            swap(p[j], p[j + 1]);
        }
        for(int j = 1; j <= n - i; j++) {
            swap(p[j], p[j + 1]);
        }
    }
    cout << ans.size() << "\n";
    for(auto [x, y] : ans)
        cout << x << " " << y << "\n";
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef STRIKAZA
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif // STRIKAZA
    int t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}