ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 1):
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

bool is_non_decreasing(const vector<int>& a) {
    for (size_t i = 0; i + 1 < a.size(); ++i) {
        if (a[i] > a[i + 1]) {
            return false;
        }
    }
    return true;
}

string solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    vector<int> current_a = a;
    while (true) {
        bool changed = false;
        for (int i = 0; i < n - 1; ++i) {
            if (current_a[i] > current_a[i + 1]) {
                int min_val = min(current_a[i], current_a[i + 1]);
                current_a[i] -= min_val;
                current_a[i + 1] -= min_val;
                changed = true;
            }
        }
        if (!changed) {
            break;
        }
    }

    if (is_non_decreasing(current_a)) {
        return "YES";
    } else {
        return "NO";
    }
}

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

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

using namespace std;

bool is_non_decreasing(const vector<int>& a) {
    for (size_t i = 0; i + 1 < a.size(); ++i) {
        if (a[i] > a[i + 1]) {
            return false;
        }
    }
    return true;
}

string solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    for (int pass = 0; pass < n; ++pass) {
        bool changed_in_pass = false;
        for (int i = 0; i < n - 1; ++i) {
            if (a[i] > a[i + 1]) {
                int min_val = min(a[i], a[i + 1]);
                a[i] -= min_val;
                a[i + 1] -= min_val;
                changed_in_pass = true;
            }
        }
        if (!changed_in_pass) {
            break;
        }
    }

    if (is_non_decreasing(a)) {
        return "YES";
    } else {
        return "NO";
    }
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        cout << solve() << endl;
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


Submission (verdict: Time limit exceeded on test 1):
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

bool is_non_decreasing(const vector<int>& a) {
    for (size_t i = 0; i + 1 < a.size(); ++i) {
        if (a[i] > a[i + 1]) {
            return false;
        }
    }
    return true;
}

string solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    vector<int> current_a = a;
    while (true) {
        bool changed = false;
        for (int i = 0; i < n - 1; ++i) {
            if (current_a[i] > current_a[i + 1]) {
                int min_val = min(current_a[i], current_a[i + 1]);
                current_a[i] -= min_val;
                current_a[i + 1] -= min_val;
                changed = true;
            }
        }
        if (!changed) {
            break;
        }
    }

    if (is_non_decreasing(current_a)) {
        return "YES";
    } else {
        return "NO";
    }
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        cout << solve() << endl;
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 11):
#include <bits/stdc++.h>
using namespace std;
int arr[100002];
void solve(){
    int n,k;
    cin>>n>>k;
    unordered_map<int,int>mp;
    int x;
    for(int i=0;i<n;i++){
        cin>>x;
        mp[x]++;
    }
    int size=mp.size();
    priority_queue<int,vector<int>,greater<int>>pq;
    int i=0;
    for(auto it:mp){
        arr[i++]=it.second;
    }
    sort(arr,arr+i);
    for(int j=0;j<i;j++){
        if(k>=arr[j]){
            k-=arr[j];
            size--;
        }
        else break;
    }
    if(size<=0)size=1;
    cout<<size<<endl;
}
int main() {
	int t;
	cin>>t;
	while(t--){
	    solve();
	}

}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
int arr[100002];
map<int,int>mp;
void solve(){
    int n,k;
    cin>>n>>k;
    mp.clear();
    int x;
    for(int i=0;i<n;i++){
        cin>>x;
        mp[x]++;
    }

    int i=0;
    for(auto it:mp){
        arr[i++]=it.second;
    }
    int size=i;
    sort(arr,arr+i);
    for(int j=0;j<i;j++){
        if(k>=arr[j]){
            k-=arr[j];
            size--;
        }
        else break;
    }
    if(size<=0)size=1;
    cout<<size<<endl;
}
int main() {
	int t;
	cin>>t;
	while(t--){
	    solve();
	}

}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

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

void solve(){
    int n,k;
    cin>>n>>k;
    unordered_map<int,int>mp;
    int x;
    for(int i=0;i<n;i++){
        cin>>x;
        mp[x]++;
    }
    int size=mp.size();
    priority_queue<int,vector<int>,greater<int>>pq;
    for(auto it:mp){
        pq.push(it.second);
    }
    while(!pq.empty()){
        int mini=pq.top();pq.pop();
        if(k>=mini){
            k-=mini;
            size--;
        }
        else break;
        
    }
    if(size<=0)size=1;
    cout<<size<<endl;
}
int main() {
	int t;
	cin>>t;
	while(t--){
	    solve();
	}

}


Submission (verdict: Time limit exceeded on test 11):
#include <bits/stdc++.h>
using namespace std;
int arr[100002];
void solve(){
    int n,k;
    cin>>n>>k;
    unordered_map<int,int>mp;
    int x;
    for(int i=0;i<n;i++){
        cin>>x;
        mp[x]++;
    }
    int size=mp.size();
    priority_queue<int,vector<int>,greater<int>>pq;
    int i=0;
    for(auto it:mp){
        arr[i++]=it.second;
    }
    sort(arr,arr+i);
    for(int j=0;j<i;j++){
        if(k>=arr[j]){
            k-=arr[j];
            size--;
        }
        else break;
    }
    if(size<=0)size=1;
    cout<<size<<endl;
}
int main() {
	int t;
	cin>>t;
	while(t--){
	    solve();
	}

}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)


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

void solve(){
    int n,k;
    cin>>n>>k;
    unordered_map<int,int>mp;
    int x;
    for(int i=0;i<n;i++){
        cin>>x;
        mp[x]++;
    }
    int size=mp.size();
    priority_queue<int,vector<int>,greater<int>>pq;
    for(auto it:mp){
        pq.push(it.second);
    }
    while(!pq.empty()){
        int mini=pq.top();pq.pop();
        if(k>=mini){
            k-=mini;
            size--;
        }
        else break;
        
    }
    if(size<=0)size=1;
    cout<<size<<endl;
}
int main() {
	int t;
	cin>>t;
	while(t--){
	    solve();
	}

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


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

#define ll long long
#define ld long double
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;

void solve() {
    int n,l,r;
    cin >> n>>l>>r;
    int a[n];
    for(int i=0;i<n;i++) {
        cin>>a[i];
    }
    sort(a,a+n);
    int sum=0;
    int x=r-l;
    for(int i=0;i<=x;i++){
        sum+=a[i];
    }
    cout<<sum<<'\n';
    return;
}

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

    int t; // number of test cases
    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 <bits/stdc++.h> // include all standard headers
using namespace std;

#define ll long long
#define ld long double
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;

void solve() {
    int n,l,r;
    cin >> n>>l>>r;
    int a[n];
    for(int i=0;i<n;i++) {
        cin>>a[i];
    }
    sort(a,a+n);
    int sum=0;
    int x=r-l;
    for(int i=0;i<=x;i++){
        sum+=a[i];
    }
    cout<<sum<<'\n';
    return;
}

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

    int t; // number of test cases
    cin >> t;

    while (t--) {
        solve();
    }

    return 0;
}

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

#define ll long long
#define ld long double
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;

void solve() {
    int n,l,r;
    cin >> n>>l>>r;
    vector<int> a(n), b(n);
    for(int i=0;i<n;i++) {
        cin>>a[i];
        b[i]=a[i];
    }
    l--;r--;
    sort(a.begin()+l, a.end());
    int sum1=accumulate(a.begin() + l, a.begin() + r + 1, 0);
    sort(b.begin(),b.begin()+r+1);
    reverse(b.begin(),b.begin()+r+1);
    int sum2=accumulate(b.begin() + l, b.begin() + r+1 , 0);
    cout<<min(sum1,sum2)<<'\n';
    return;
}

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

    int t; // number of test cases
    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 8):
#include <bits/stdc++.h> // include all standard headers
using namespace std;

#define ll long long
#define ld long double
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;

void solve() {
    int n,l,r;
    cin >> n>>l>>r;
    vector<int> a(n), b(n);
    for(int i=0;i<n;i++) {
        cin>>a[i];
        b[i]=a[i];
    }
    l--;r--;
    sort(a.begin()+l, a.end());
    int sum1=accumulate(a.begin() + l, a.begin() + r + 1, 0);
    sort(b.begin(),b.begin()+r+1);
    reverse(b.begin(),b.begin()+r+1);
    int sum2=accumulate(b.begin() + l, b.begin() + r+1 , 0);
    cout<<min(sum1,sum2)<<'\n';
    return;
}

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

    int t; // number of test cases
    cin >> t;

    while (t--) {
        solve();
    }

    return 0;
}

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

#define ll long long
#define ld long double
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;

void solve() {
    int n,l,r;
    cin >> n>>l>>r;
    vector<ll> a(n), b(n);
    for(int i=0;i<n;i++) {
        cin>>a[i];
        b[i]=a[i];
    }
    l--;r--;
    sort(a.begin()+l, a.end());
    ll sum1=accumulate(a.begin() + l, a.begin() + r + 1, 0);
    sort(b.begin(),b.begin()+r+1);
    reverse(b.begin(),b.begin()+r+1);
    ll sum2=accumulate(b.begin() + l, b.begin() + r+1 , 0);
    cout<<min(sum1,sum2)<<'\n';
    return;
}

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

    int t; // number of test cases
    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 8):
#include <bits/stdc++.h> // include all standard headers
using namespace std;

#define ll long long
#define ld long double
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;

void solve() {
    int n,l,r;
    cin >> n>>l>>r;
    vector<ll> a(n), b(n);
    for(int i=0;i<n;i++) {
        cin>>a[i];
        b[i]=a[i];
    }
    l--;r--;
    sort(a.begin()+l, a.end());
    ll sum1=accumulate(a.begin() + l, a.begin() + r + 1, 0);
    sort(b.begin(),b.begin()+r+1);
    reverse(b.begin(),b.begin()+r+1);
    ll sum2=accumulate(b.begin() + l, b.begin() + r+1 , 0);
    cout<<min(sum1,sum2)<<'\n';
    return;
}

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

    int t; // number of test cases
    cin >> t;

    while (t--) {
        solve();
    }

    return 0;
}

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

using namespace std;



#define ll long long

#define ld long double

#define pii pair<int, int>

#define mp make_pair

#define pb push_back

#define eb emplace_back

#define fi first

#define se second



const int INF = 1e9;

const ll INFLL = 1e18;

const int MOD = 1e9 + 7;



void solve() {

    ll n,l,r;

    cin >> n>>l>>r;

    vector<ll> a(n), b(n);

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

        cin>>a[i];

        b[i]=a[i];

    }

    l--;r--;

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

    ll sum1=accumulate(a.begin() + l, a.begin() + r + 1, 0LL);

    sort(b.begin(),b.begin()+r+1);

    reverse(b.begin(),b.begin()+r+1);

    ll sum2=accumulate(b.begin() + l, b.begin() + r+1 , 0LL);

    cout<<min(sum1,sum2)<<'\n';

    return;

}



int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);



    int t; // number of test cases

    cin >> t;



    while (t--) {

        solve();

    }



    return 0;

}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

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

int f(string a,string b,string c,int i,int j,vector<vector<int>> &dp){
    if(i+j>=c.size()){
        return 0;
    }
    // if(i>=a.size()){
        
    // }
    if(dp[i][j]!=-1){
        return dp[i][j];
    }
    int tk = 1e9;
    if(i<a.size()){
        if(c[i+j]==a[i]){
            tk = f(a,b,c,i+1,j,dp);
        }
        else{
            tk = 1+f(a,b,c,i+1,j,dp);
        }
    }
    int ntk = 1e9;
    if(j<b.size()){
        if(c[i+j]==b[j]){
            ntk = f(a,b,c,i,j+1,dp);
        }
        else{
            ntk = 1+f(a,b,c,i,j+1,dp);
        }
    }
    return dp[i][j]=min(tk,ntk);
}

int main(){
    int t;
    cin>>t;
    while(t--){
        string a,b,c;
        cin>>a>>b>>c;
        int n = a.size();
        int m = b.size();
        vector<vector<int>> dp(n+1,vector<int>(m+1,-1));
        int g = f(a,b,c,0,0,dp);
        cout<<g<<endl;
    }
}

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

int f(string a,string b,string c,int i,int j,vector<vector<int>> &dp){
    if(i+j>=c.size()){
        return 0;
    }
    if(i>=a.size()){
        int g=0;
        for(int k=j;k<b.size();k++){
            if(b[k]!=c[k+i]){
                g++;
            }
        }
        return g;
    }
    if(j>=b.size()){
        int g=0;
        for(int k=i;k<a.size();k++){
            if(a[k]!=c[k+j]){
                g++;
            }
        }
        return g;
    }
    if(dp[i][j]!=-1){
        return dp[i][j];
    }
    int tk = 1e6;
        if(c[i+j]==a[i]){
            tk = f(a,b,c,i+1,j,dp);
        }
        else{
            tk = 1+f(a,b,c,i+1,j,dp);
        }
    int ntk = 1e6;
        if(c[i+j]==b[j]){
            ntk = f(a,b,c,i,j+1,dp);
        }
        else{
            ntk = 1+f(a,b,c,i,j+1,dp);
        }
    return dp[i][j]=min(tk,ntk);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin>>t;
    while(t--){
        string a,b,c;
        cin>>a>>b>>c;
        int n = a.size();
        int m = b.size();
        vector<vector<int>> dp(n+1,vector<int>(m+1,-1));
        int g = f(a,b,c,0,0,dp);
        cout<<g<<endl;
    }
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)


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

int f(string a,string b,string c,int i,int j,vector<vector<int>> &dp){
    if(i+j>=c.size()){
        return 0;
    }
    // if(i>=a.size()){
        
    // }
    if(dp[i][j]!=-1){
        return dp[i][j];
    }
    int tk = 1e9;
    if(i<a.size()){
        if(c[i+j]==a[i]){
            tk = f(a,b,c,i+1,j,dp);
        }
        else{
            tk = 1+f(a,b,c,i+1,j,dp);
        }
    }
    int ntk = 1e9;
    if(j<b.size()){
        if(c[i+j]==b[j]){
            ntk = f(a,b,c,i,j+1,dp);
        }
        else{
            ntk = 1+f(a,b,c,i,j+1,dp);
        }
    }
    return dp[i][j]=min(tk,ntk);
}

int main(){
    int t;
    cin>>t;
    while(t--){
        string a,b,c;
        cin>>a>>b>>c;
        int n = a.size();
        int m = b.size();
        vector<vector<int>> dp(n+1,vector<int>(m+1,-1));
        int g = f(a,b,c,0,0,dp);
        cout<<g<<endl;
    }
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
void solve()
{
    int n; cin >> n;
    vector<int>cars(n);
    map<int, int>mp;
    for(int i = 0; i < n; i++){
        cin >> cars[i];
    }

    int count = 0;
    vector<pair<int, int>>v;
    
    pair<int, int>temp;
    for(int i = 0; i < n; i++){
        vector<int>overtakes;
        for(int j = cars[i] + 1; j <= n; j++){
            if(mp[j] == 0){
                overtakes.push_back(j);
                overtakes.push_back(cars[i]);
            }
        }
        for(int j = overtakes.size() - 1; j >= 0; j--){
            overtakes.push_back(overtakes[j]);
        }
        for(int j = cars[i] - 1; j >= 1; j--){
            if(mp[j] == 0){
                overtakes.push_back(cars[i]);
                overtakes.push_back(j);
            }
        }
        for(int j = 0; j < overtakes.size(); j+=2){
            cout << overtakes[j] << " " << overtakes[j + 1] << endl;
        }
        mp[cars[i]]++;
    }
    
}
int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll test = 1;
    // cin >> test;
    while(test--)
    {
        solve();
    }
    return 0;
}


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
void solve()
{
    int n; cin >> n;
    vector<int>cars(n);
    map<int, int>mp;
    for(int i = 0; i < n; i++){
        cin >> cars[i];
    }

    int count = 0;
    vector<pair<int, int>>v;
    
    pair<int, int>temp;
    for(int i = 0; i < n; i++){
        vector<int>overtakes;
        for(int j = cars[i] + 1; j <= n; j++){
            if(mp[j] == 0){
                overtakes.push_back(j);
                overtakes.push_back(cars[i]);
            }
        }
        for(int j = overtakes.size() - 1; j >= 0; j--){
            overtakes.push_back(overtakes[j]);
        }
        for(int j = cars[i] - 1; j >= 1; j--){
            if(mp[j] == 0){
                overtakes.push_back(cars[i]);
                overtakes.push_back(j);
            }
        }
        for(int j = 0; j < overtakes.size(); j+=2){
            // cout << overtakes[j] << " " << overtakes[j + 1] << endl;
            pair<int, int>p(overtakes[j], overtakes[j + 1]);
            v.push_back(p);
        }
        mp[cars[i]]++;
    }
    for(int i = 0; i < v.size(); i++){
        int j = i + 1; 
        while(j < v.size()){
            if(v[j].second < v[i].second){
                swap(v[i], v[j]);
            }
            j++;
        }
    }
    for(auto i: v) cout << i.first << " " << i.second << endl;
}
int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll test = 1;
    // cin >> test;
    while(test--)
    {
        solve();
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 1):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
void solve()
{
    int n; cin >> n ;
    vector<int>cars(n);

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

    vector<vector<int>>swaps;
    int count=0;
    for(int i = n - 1; i > 0; i--){
        for(int j = i - 1 ; j >= 0; j--){
            swaps[count].push_back(i);
            swaps[count].push_back(j);
            // cout << i << " " << j << endl ;
        }
    }


    for(int i = 0; i < swaps.size(); i++){
        cout << swaps[i][0] << " " << swaps[i][1] << endl ;
    }
}
int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
    return 0;
}


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
void solve()
{
    int n; cin >> n;
    vector<int>cars(n);
    map<int, int>mp;
    for(int i = 0; i < n; i++){
        cin >> cars[i];
    }

    int count = 0;
    vector<pair<int, int>>v;
    
    pair<int, int>temp;
    for(int i = 0; i < n; i++){
        vector<int>overtakes;
        for(int j = cars[i] + 1; j <= n; j++){
            if(mp[j] == 0){
                overtakes.push_back(j);
                overtakes.push_back(cars[i]);
            }
        }
        for(int j = overtakes.size() - 1; j >= 0; j--){
            overtakes.push_back(overtakes[j]);
        }
        for(int j = cars[i] - 1; j >= 1; j--){
            if(mp[j] == 0){
                overtakes.push_back(cars[i]);
                overtakes.push_back(j);
            }
        }
        for(int j = 0; j < overtakes.size(); j+=2){
            cout << overtakes[j] << " " << overtakes[j + 1] << endl;
        }
        mp[cars[i]]++;
    }
    
}
int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll test = 1;
    // cin >> test;
    while(test--)
    {
        solve();
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


Submission (verdict: Runtime error on test 1):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
void solve()
{
    int n; cin >> n ;
    vector<int>cars(n);

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

    vector<vector<int>>swaps;
    int count=0;
    for(int i = n - 1; i > 0; i--){
        for(int j = i - 1 ; j >= 0; j--){
            swaps[count].push_back(i);
            swaps[count].push_back(j);
            // cout << i << " " << j << endl ;
        }
    }


    for(int i = 0; i < swaps.size(); i++){
        cout << swaps[i][0] << " " << swaps[i][1] << endl ;
    }
}
int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
    return 0;
}