Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 7):
#include<bits/stdc++.h>

using namespace std;
using ll = long long int;
using pii = pair<int,int>;

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> c(n), perm(n);
    iota(perm.begin(), perm.end(), 1);
    for(int i=0; i<n; i++){
        cin >> c[i];
    } 
    vector<pii> ans;
    set<pii> st;
    for(int i=0; i<n; i++){
        int pos = find(perm.begin(), perm.end(), c[i]) - perm.begin();
        if(pos == i) continue;
        if(pos<i){
            for(int j=pos; j<i; j++){
                ans.push_back({perm[j+1], perm[j]});
                st.insert({perm[j+1], perm[j]});
                swap(perm[j], perm[j+1]);
            }
        }
        else{
            for(int j=i; j<pos; j++){
                ans.push_back({perm[j+1], perm[j]});
                st.insert({perm[j+1], perm[j]});
                swap(perm[j], perm[j+1]);
            }
        }
    }
    for(int i=1; i<n; i++){
        int ind = i;
        for(int j=i-1; j>=0; j--){
            if(st.count({perm[j], perm[i]})==0){
                ind = j;
            }
            else break;
        }
        if(ind != i){
            for(int j=i-1; j>=ind; j--){
                ans.push_back({perm[i], perm[j]});
            }
            for(int j=ind; j<i; j++){
                ans.push_back({perm[j], perm[i]});
            }
        }
    }
    cout << ans.size() << endl;
    for(auto &[i,j]: ans){
        cout << i << " " << j << endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long int;
using pii = pair<int,int>;

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> c(n), perm(n);
    iota(perm.begin(), perm.end(), 1);
    for(int i=0; i<n; i++){
        cin >> c[i];
    } 
    vector<pii> ans;
    set<pii> st;
    for(int i=0; i<n; i++){
        int pos = find(perm.begin(), perm.end(), c[i]) - perm.begin();
        if(pos == i) continue;
        if(pos<i){
            for(int j=pos; j<i; j++){
                ans.push_back({perm[j+1], perm[j]});
                st.insert({perm[j+1], perm[j]});
                swap(perm[j+1], perm[j]);
            }
        }
        else{
            for(int j=pos; j>i; j--){
                ans.push_back({perm[j], perm[j-1]});
                st.insert({perm[j], perm[j-1]});
                swap(perm[j], perm[j-1]);
            }
        }
    }
    for(int i=1; i<n; i++){
        int ind = i;
        for(int j=i-1; j>=0; j--){
            if(st.count({perm[j], perm[i]})==0){
                ind = j;
            }
            else break;
        }
        if(ind != i){
            for(int j=i-1; j>=ind; j--){
                ans.push_back({perm[i], perm[j]});
            }
            for(int j=ind; j<i; j++){
                ans.push_back({perm[j], perm[i]});
            }
        }
    }
    cout << ans.size() << endl;
    for(auto &[i,j]: ans){
        cout << i << " " << j << endl;
    }
    return 0;
}