ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

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


int input[100010];

void swap(int &a, int &b){
    int temp =a;
    a=b;
    b=a;
}

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

     int n, x;
     cin>>n;
     
     for(int i=0;i<n;i++){
        cin>>x;
        input[i] = x;
     }

     int arr[n];
     for(int i=0;i<n;i++){
        arr[i] = i+1;
     }

    int count = 0;
    vector<pair<int,int> > result;
    for(int i=0;i<n;i++){
        for(int j=i;j<n;j++){
            if(input[i]==arr[j]){
                for(int l=j+1;l<n;l++){
                    count+=2;
                    result.push_back(pair<int,int>(arr[l], arr[j]));
                    result.push_back(pair<int,int>(arr[j], arr[l]));
                }
                
                for(int l=j-1;l>=i;l--){
                    count++;
                    result.push_back(pair<int,int>(input[i], arr[l]));
                    arr[l+1] = arr[l];
                }
                arr[i] = input[i];
                break;
            }
        }
    }

    cout<<result.size()<<endl;
    for(int i=0;i<result.size();i++){
        cout<<result[i].first<<" "<<result[i].second<<endl;
    }
}

Submission (verdict: Wrong answer on test 4):
#include<iostream>
#include<set>
#include<map>
#include<queue>
using namespace std;


int input[100010];

void swap(int &a, int &b){
    int temp =a;
    a=b;
    b=a;
}

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

     int n, x;
     cin>>n;
     
     for(int i=0;i<n;i++){
        cin>>x;
        input[i] = x;
     }

     int arr[n];
     for(int i=0;i<n;i++){
        arr[i] = i+1;
     }

    int count = 0;
    vector<pair<int,int> > result;
    for(int i=0;i<n;i++){
        for(int j=i;j<n;j++){
            if(input[i]==arr[j]){
                for(int l=j+1;l<n;l++){
                    count+=1;
                    result.push_back(pair<int,int>(arr[l], arr[j]));
                    
                }
                for(int l=j+1;l<n;l++){
                    count+=1;
                    result.push_back(pair<int,int>(arr[j], arr[l]));
                    
                }
                
                
                for(int l=j-1;l>=i;l--){
                    count++;
                    result.push_back(pair<int,int>(input[i], arr[l]));
                    arr[l+1] = arr[l];
                }
                arr[i] = input[i];
                break;
            }
        }
        // for(int l=0;l<n;l++){
        //     cout<<arr[l]<<" ";
        // }
        // cout<<endl;

    }

    cout<<result.size()<<endl;
    for(int i=0;i<result.size();i++){
        cout<<result[i].first<<" "<<result[i].second<<endl;
    }
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

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


int input[100010];

void swap(int &a, int &b){
    int temp =a;
    a=b;
    b=a;
}

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

     int n, x;
     cin>>n;
     
     for(int i=0;i<n;i++){
        cin>>x;
        input[i] = x;
     }

     int arr[n];
     for(int i=0;i<n;i++){
        arr[i] = i+1;
     }

    int count = 0;
    vector<pair<int,int> > result;
    for(int i=0;i<n;i++){
        for(int j=i;j<n;j++){
            if(input[i]==arr[j]){
                for(int l=j+1;l<n;l++){
                    count+=1;
                    result.push_back(pair<int,int>(arr[l], arr[j]));
                    
                }
                for(int l=j+1;l<n;l++){
                    count+=1;
                    result.push_back(pair<int,int>(arr[j], arr[l]));
                    
                }
                
                
                for(int l=j-1;l>=i;l--){
                    count++;
                    result.push_back(pair<int,int>(input[i], arr[l]));
                    arr[l+1] = arr[l];
                }
                arr[i] = input[i];
                break;
            }
        }
        // for(int l=0;l<n;l++){
        //     cout<<arr[l]<<" ";
        // }
        // cout<<endl;

    }

    cout<<result.size()<<endl;
    for(int i=0;i<result.size();i++){
        cout<<result[i].first<<" "<<result[i].second<<endl;
    }
}

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


int input[100010];

void swap(int &a, int &b){
    int temp =a;
    a=b;
    b=a;
}

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

     int n, x;
     cin>>n;
     
     for(int i=0;i<n;i++){
        cin>>x;
        input[i] = x;
     }

     int arr[n];
     for(int i=0;i<n;i++){
        arr[i] = i+1;
     }

    int count = 0;
    vector<pair<int,int> > result;
    for(int i=0;i<n;i++){
        for(int j=i;j<n;j++){
            if(input[i]==arr[j]){
                for(int l=j+1;l<n;l++){
                    count+=1;
                    result.push_back(pair<int,int>(arr[l], arr[j]));
                    
                }
                for(int l=n-1;l>=j+1;l--){
                    count+=1;
                    result.push_back(pair<int,int>(arr[j], arr[l]));
                    
                }
                
                
                for(int l=j-1;l>=i;l--){
                    count++;
                    result.push_back(pair<int,int>(input[i], arr[l]));
                    arr[l+1] = arr[l];
                }
                arr[i] = input[i];
                break;
            }
        }
        // for(int l=0;l<n;l++){
        //     cout<<arr[l]<<" ";
        // }
        // cout<<endl;

    }

    cout<<result.size()<<endl;
    for(int i=0;i<result.size();i++){
        cout<<result[i].first<<" "<<result[i].second<<endl;
    }
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 4):
#include<iostream>
#include<set>
#include<map>
#include<queue>
using namespace std;


int input[100010];

void swap(int &a, int &b){
    int temp =a;
    a=b;
    b=a;
}

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

     int n, x;
     cin>>n;
     
     for(int i=0;i<n;i++){
        cin>>x;
        input[i] = x;
     }

     int arr[n];
     for(int i=0;i<n;i++){
        arr[i] = i+1;
     }

    int count = 0;
    vector<pair<int,int> > result;
    for(int i=0;i<n;i++){
        for(int j=i;j<n;j++){
            if(input[i]==arr[j]){
                for(int l=j+1;l<n;l++){
                    count+=2;
                    result.push_back(pair<int,int>(arr[l], arr[j]));
                    result.push_back(pair<int,int>(arr[j], arr[l]));
                }
                
                for(int l=j-1;l>=i;l--){
                    count++;
                    result.push_back(pair<int,int>(input[i], arr[l]));
                    arr[l+1] = arr[l];
                }
                arr[i] = input[i];
                break;
            }
        }
    }

    cout<<result.size()<<endl;
    for(int i=0;i<result.size();i++){
        cout<<result[i].first<<" "<<result[i].second<<endl;
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define endl '\n'
#define fi first
#define se second
using namespace std;
using ll = long long;
using vt = vector<int>;
using vvt = vector<vt>;
using pr = pair<int, int>;
using vp = vector<pr>;

void solve() {
    int n;
    cin >> n;

    vt a(n);
    for(auto &e : a) {
        cin >> e;
    }

    if((a[0] < a[1]) && (a[n-2] < a[n-1])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define endl '\n'
#define fi first
#define se second
using namespace std;
using ll = long long;
using vt = vector<int>;
using vvt = vector<vt>;
using pr = pair<int, int>;
using vp = vector<pr>;

void solve() {
    int n;
    cin >> n;

    vt a(n);
    for(auto &e : a) {
        cin >> e;
    }

    ll sum = 0;
    for(int i = 0; i+1 < n; i++) {
        if(a[i+1] >= a[i]) {
            sum += a[i];
        } else {
            if(max<ll>(0, a[i]-sum) > a[i+1]) {
                cout << "No" << endl;
                return;
            } else {
                sum = max<ll>(0, a[i]-sum);
            }
        }
    }
    cout << "Yes" << endl;
}

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int T = 1; cin >> T;
    while(T--) solve();
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define endl '\n'
#define fi first
#define se second
using namespace std;
using ll = long long;
using vt = vector<int>;
using vvt = vector<vt>;
using pr = pair<int, int>;
using vp = vector<pr>;

void solve() {
    int n;
    cin >> n;

    vt a(n);
    for(auto &e : a) {
        cin >> e;
    }

    if((a[0] < a[1]) && (a[n-2] < a[n-1])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int T = 1; cin >> T;
    while(T--) solve();
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define endl '\n'
#define fi first
#define se second
using namespace std;
using ll = long long;
using vt = vector<int>;
using vvt = vector<vt>;
using pr = pair<int, int>;
using vp = vector<pr>;

void solve() {
    int n;
    cin >> n;

    vt a(n);
    for(auto &e : a) {
        cin >> e;
    }

    ll sum = 0;
    for(int i = 0; i+1 < n; i++) {
        if(a[i+1] >= a[i]) {
            sum += a[i];
        } else {
            if(max<ll>(0, a[i]-sum) > a[i+1]) {
                cout << "No" << endl;
                return;
            } else {
                sum = max<ll>(0, a[i]-sum);
            }
        }
    }
    cout << "Yes" << endl;
}

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


Submission (verdict: Accepted):
#include<bits/stdc++.h>
#define endl '\n'
#define fi first
#define se second
using namespace std;
using ll = long long;
using vt = vector<int>;
using vvt = vector<vt>;
using pr = pair<int, int>;
using vp = vector<pr>;

void solve() {
    int n;
    cin >> n;

    vt a(n);
    for(auto &e : a) {
        cin >> e;
    }

    ll sum = 0;
    for(int i = 0; i+1 < n; i++) {
        if(a[i+1] >= a[i]) {
            sum = a[i]-sum;
        } else {
            if(max<ll>(0, a[i]-sum) > a[i+1]) {
                cout << "No" << endl;
                return;
            } else {
                sum = max<ll>(0, a[i]-sum);
            }
        }
    }
    cout << "Yes" << endl;
}

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int T = 1; cin >> T;
    while(T--) solve();
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

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

using ll = long long;

ll best_replacement(std::vector<ll>& cur, std::vector<ll>& alt) {
    std::sort(cur.begin(), cur.end());
    std::sort(alt.begin(), alt.end());
    ll max_swap = std::min(cur.size(), alt.size());
    ll cur_sum = 0;
    ll alt_sum = 0;
    ll best_swap_benefit = 0;
    for (size_t k = 0; k < max_swap; k++) {
        cur_sum += *(cur.rbegin() + k);
        alt_sum += *(alt.begin() + k);
        best_swap_benefit = std::max(cur_sum - alt_sum, best_swap_benefit);
    }
    return std::accumulate(cur.begin(), cur.end(), 0) - best_swap_benefit;
}

ll solve(std::vector<ll>& as, ll l, ll r) {
    std::vector<ll> left(as.begin(), as.begin() + l - 1);
    std::vector<ll> mid(as.begin() + l - 1, as.begin() + r);
    std::vector<ll> right(as.begin() + r, as.end());

    ll best_left_swap = best_replacement(mid, left);
    ll best_right_swap = best_replacement(mid, right);

    return std::min(best_left_swap, best_right_swap);
}

int main() {
    int t;
    std::cin >> t;

    for (int i = 0; i < t; i++) {
        int n, l, r;
        std::vector<ll> as;
        std::cin >> n >> l >> r;

        for (size_t i = 0; i < n; i++) {
            ll a;
            std::cin >> a;
            as.push_back(a);
        }

        std::cout << solve(as, l, r) << std::endl;
    }
}

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

using ll = long long;

ll best_replacement(std::vector<ll>& cur, std::vector<ll>& alt) {
    std::sort(cur.begin(), cur.end());
    std::sort(alt.begin(), alt.end());
    ll max_swap = std::min(cur.size(), alt.size());
    ll cur_sum = 0;
    ll alt_sum = 0;
    ll best_swap_benefit = 0;
    for (size_t k = 0; k < max_swap; k++) {
        cur_sum += *(cur.rbegin() + k);
        alt_sum += *(alt.begin() + k);
        best_swap_benefit = std::max(cur_sum - alt_sum, best_swap_benefit);
    }
    return std::accumulate(cur.begin(), cur.end(), 0LL) - best_swap_benefit;
}

ll solve(std::vector<ll>& as, ll l, ll r) {
    std::vector<ll> left(as.begin(), as.begin() + l - 1);
    std::vector<ll> mid(as.begin() + l - 1, as.begin() + r);
    std::vector<ll> right(as.begin() + r, as.end());

    ll best_left_swap = best_replacement(mid, left);
    ll best_right_swap = best_replacement(mid, right);

    return std::min(best_left_swap, best_right_swap);
}

int main() {
    int t;
    std::cin >> t;

    for (int i = 0; i < t; i++) {
        int n, l, r;
        std::vector<ll> as;
        std::cin >> n >> l >> r;

        for (size_t i = 0; i < n; i++) {
            ll a;
            std::cin >> a;
            as.push_back(a);
        }

        std::cout << solve(as, l, r) << std::endl;
    }
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

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

int best_replacement(std::vector<int>& cur, std::vector<int>& alt) {
    std::sort(cur.begin(), cur.end());
    std::sort(alt.begin(), alt.end());
    int max_swap = std::min(cur.size(), alt.size());
    int cur_sum = 0;
    int alt_sum = 0;
    int best_swap_benefit = 0;
    for (int k = 0; k < max_swap; k++) {
        cur_sum += *(cur.rbegin() + k);
        alt_sum += *(alt.begin() + k);
        best_swap_benefit = std::max(cur_sum - alt_sum, best_swap_benefit);
    }
    return std::accumulate(cur.begin(), cur.end(), 0) - best_swap_benefit;
}

int solve(std::vector<int>& as, int l, int r) {
    std::vector<int> left(as.begin(), as.begin() + l - 1);
    std::vector<int> mid(as.begin() + l - 1, as.begin() + r);
    std::vector<int> right(as.begin() + r, as.end());

    int best_left_swap = best_replacement(mid, left);
    int best_right_swap = best_replacement(mid, right);

    return std::min(best_left_swap, best_right_swap);
}

int main() {
    freopen("subseq.in", "r", stdin);
    int t;
    std::cin >> t;

    for (int i = 0; i < t; i++) {
        int n, l, r;
        std::vector<int> as;
        std::cin >> n >> l >> r;

        for (int i = 0; i < n; i++) {
            int a;
            std::cin >> a;
            as.push_back(a);
        }

        std::cout << solve(as, l, r) << std::endl;
    }
}

Submission (verdict: Wrong answer on test 8):
#include <algorithm>

#include <iostream>

#include <numeric>

#include <vector>



int best_replacement(std::vector<int>& cur, std::vector<int>& alt) {

    std::sort(cur.begin(), cur.end());

    std::sort(alt.begin(), alt.end());

    int max_swap = std::min(cur.size(), alt.size());

    int cur_sum = 0;

    int alt_sum = 0;

    int best_swap_benefit = 0;

    for (int k = 0; k < max_swap; k++) {

        cur_sum += *(cur.rbegin() + k);

        alt_sum += *(alt.begin() + k);

        best_swap_benefit = std::max(cur_sum - alt_sum, best_swap_benefit);

    }

    return std::accumulate(cur.begin(), cur.end(), 0) - best_swap_benefit;

}



int solve(std::vector<int>& as, int l, int r) {

    std::vector<int> left(as.begin(), as.begin() + l - 1);

    std::vector<int> mid(as.begin() + l - 1, as.begin() + r);

    std::vector<int> right(as.begin() + r, as.end());



    int best_left_swap = best_replacement(mid, left);

    int best_right_swap = best_replacement(mid, right);



    return std::min(best_left_swap, best_right_swap);

}



int main() {

    int t;

    std::cin >> t;



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

        int n, l, r;

        std::vector<int> as;

        std::cin >> n >> l >> r;



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

            int a;

            std::cin >> a;

            as.push_back(a);

        }



        std::cout << solve(as, l, r) << std::endl;

    }

}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)


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

int best_replacement(std::vector<int>& cur, std::vector<int>& alt) {
    std::sort(cur.begin(), cur.end());
    std::sort(alt.begin(), alt.end());
    int max_swap = std::min(cur.size(), alt.size());
    int cur_sum = 0;
    int alt_sum = 0;
    int best_swap_benefit = 0;
    for (int k = 0; k < max_swap; k++) {
        cur_sum += *(cur.rbegin() + k);
        alt_sum += *(alt.begin() + k);
        best_swap_benefit = std::max(cur_sum - alt_sum, best_swap_benefit);
    }
    return std::accumulate(cur.begin(), cur.end(), 0) - best_swap_benefit;
}

int solve(std::vector<int>& as, int l, int r) {
    std::vector<int> left(as.begin(), as.begin() + l - 1);
    std::vector<int> mid(as.begin() + l - 1, as.begin() + r);
    std::vector<int> right(as.begin() + r, as.end());

    int best_left_swap = best_replacement(mid, left);
    int best_right_swap = best_replacement(mid, right);

    return std::min(best_left_swap, best_right_swap);
}

int main() {
    freopen("subseq.in", "r", stdin);
    int t;
    std::cin >> t;

    for (int i = 0; i < t; i++) {
        int n, l, r;
        std::vector<int> as;
        std::cin >> n >> l >> r;

        for (int i = 0; i < n; i++) {
            int a;
            std::cin >> a;
            as.push_back(a);
        }

        std::cout << solve(as, l, r) << std::endl;
    }
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 8):
#include <algorithm>

#include <iostream>

#include <numeric>

#include <vector>



int best_replacement(std::vector<int>& cur, std::vector<int>& alt) {

    std::sort(cur.begin(), cur.end());

    std::sort(alt.begin(), alt.end());

    int max_swap = std::min(cur.size(), alt.size());

    int cur_sum = 0;

    int alt_sum = 0;

    int best_swap_benefit = 0;

    for (int k = 0; k < max_swap; k++) {

        cur_sum += *(cur.rbegin() + k);

        alt_sum += *(alt.begin() + k);

        best_swap_benefit = std::max(cur_sum - alt_sum, best_swap_benefit);

    }

    return std::accumulate(cur.begin(), cur.end(), 0) - best_swap_benefit;

}



int solve(std::vector<int>& as, int l, int r) {

    std::vector<int> left(as.begin(), as.begin() + l - 1);

    std::vector<int> mid(as.begin() + l - 1, as.begin() + r);

    std::vector<int> right(as.begin() + r, as.end());



    int best_left_swap = best_replacement(mid, left);

    int best_right_swap = best_replacement(mid, right);



    return std::min(best_left_swap, best_right_swap);

}



int main() {

    int t;

    std::cin >> t;



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

        int n, l, r;

        std::vector<int> as;

        std::cin >> n >> l >> r;



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

            int a;

            std::cin >> a;

            as.push_back(a);

        }



        std::cout << solve(as, l, r) << std::endl;

    }

}

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

using ll = long long;

ll best_replacement(std::vector<ll>& cur, std::vector<ll>& alt) {
    std::sort(cur.begin(), cur.end());
    std::sort(alt.begin(), alt.end());
    ll max_swap = std::min(cur.size(), alt.size());
    ll cur_sum = 0;
    ll alt_sum = 0;
    ll best_swap_benefit = 0;
    for (size_t k = 0; k < max_swap; k++) {
        cur_sum += *(cur.rbegin() + k);
        alt_sum += *(alt.begin() + k);
        best_swap_benefit = std::max(cur_sum - alt_sum, best_swap_benefit);
    }
    return std::accumulate(cur.begin(), cur.end(), 0) - best_swap_benefit;
}

ll solve(std::vector<ll>& as, ll l, ll r) {
    std::vector<ll> left(as.begin(), as.begin() + l - 1);
    std::vector<ll> mid(as.begin() + l - 1, as.begin() + r);
    std::vector<ll> right(as.begin() + r, as.end());

    ll best_left_swap = best_replacement(mid, left);
    ll best_right_swap = best_replacement(mid, right);

    return std::min(best_left_swap, best_right_swap);
}

int main() {
    int t;
    std::cin >> t;

    for (int i = 0; i < t; i++) {
        int n, l, r;
        std::vector<ll> as;
        std::cin >> n >> l >> r;

        for (size_t i = 0; i < n; i++) {
            ll a;
            std::cin >> a;
            as.push_back(a);
        }

        std::cout << solve(as, l, r) << std::endl;
    }
}