Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 4):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fill(v) for(auto& i: v) cin>>i;
#define acc(v) sort(v.begin(), v.end())
#define dec(v) sort(v.rbegin(), v.rend())
#define has(c, x) {return c.find(x)!=c.end();}
#define pr(v) for(auto i: v) cout<<i<<" "; cout<<endl;
#define pb(r) push_back(r)
#define pr1(v, i) for(auto j: v) cout<<j[i]<<" "; cout<<endl; 
#define del(s, x) if(s.find(x)!=s.end()) s.erase(s.find(x)) 
#define no {cout<<"no"<<endl; return;}
#define show(x) cout<<#x<<": "<<x<<" ";
#define _init_(v) iota(v.begin(), v.end(), 0);
#define rev(v) reverse(v.begin(), v.end())
#define vll vector<ll>
#define vvll vector<vll>
#define vvvll vector<vvll>
#define vd vector<double>
#define GCD(a, b) __gcd<long long>(a, b)
#define yes {cout<<"yes"<<endl; return;}
// const ll MOD1=998244353;
// const ll MOD2=1e9+7;
const ll MOD=1e9+7;
ll MAX=1e16;
void solve(){
    ll n; cin>>n;
    vll fin_res(n); fill(fin_res); for(auto& i: fin_res)i--;
    //fin_res is final result where ith position has vehicle i
    vll curr_car(n); for(int i=0; i<n; i++)curr_car[i]=i;
    //curr_car contains the car at position i
    vll car_pos=curr_car;
    //car contains the position of car i
    vvll res;

    for(int i=0;i<n;i++){
        int curr_position=car_pos[fin_res[i]];
        int next_position=curr_position+1;
        int now_car=curr_car[curr_position];
        if(next_position<n){
            int next_car=curr_car[next_position];
            res.push_back({next_car, now_car});
            res.push_back({now_car, next_car});
        }
        for(int j=curr_position-1; j>=i; j--){
            int prev_car=curr_car[j];
            res.push_back({now_car, prev_car});
            int prev_position=j, curr_position=j+1;
            swap(curr_car[prev_position], curr_car[curr_position]);
            car_pos[now_car]=j; car_pos[prev_car]=j+1;
        }
    } 
    cout<<res.size()<<endl;
    for(auto i: res){
        cout<<i[0]+1<<" "<<i[1]+1<<endl;
    }
}

int main(){
    int t=1;
    // cin>>t;
    while(t--) solve();
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fill(v) for(auto& i: v) cin>>i;
#define acc(v) sort(v.begin(), v.end())
#define dec(v) sort(v.rbegin(), v.rend())
#define has(c, x) {return c.find(x)!=c.end();}
#define pr(v) for(auto i: v) cout<<i<<" "; cout<<endl;
#define pb(r) push_back(r)
#define pr1(v, i) for(auto j: v) cout<<j[i]<<" "; cout<<endl; 
#define del(s, x) if(s.find(x)!=s.end()) s.erase(s.find(x)) 
#define no {cout<<"no"<<endl; return;}
#define show(x) cout<<#x<<": "<<x<<" ";
#define _init_(v) iota(v.begin(), v.end(), 0);
#define rev(v) reverse(v.begin(), v.end())
#define vll vector<ll>
#define vvll vector<vll>
#define vvvll vector<vvll>
#define vd vector<double>
#define GCD(a, b) __gcd<long long>(a, b)
#define yes {cout<<"yes"<<endl; return;}
// const ll MOD1=998244353;
// const ll MOD2=1e9+7;
const ll MOD=1e9+7;
ll MAX=1e16;
void solve(){
    ll n; cin>>n;
    vll fin_res(n); fill(fin_res); for(auto& i: fin_res)i--;
    //fin_res is final result where ith position has vehicle i
    vll curr_car(n); for(int i=0; i<n; i++)curr_car[i]=i;
    //curr_car contains the car at position i
    vll car_pos=curr_car;
    //car contains the position of car i
    vvll res;

    for(int i=0;i<n;i++){
        int curr_position=car_pos[fin_res[i]];
        int next_position=curr_position+1;
        int now_car=curr_car[curr_position];
        for(int j=curr_position+1; j<n; j++){
            int prev_car=curr_car[j];
            res.push_back({now_car, prev_car});
            int prev_position=j, curr_position=j-1;
            swap(curr_car[prev_position], curr_car[curr_position]);
            car_pos[now_car]=j; car_pos[prev_car]=j-1;
        }
        for(int j=n-2; j>=i; j--){
            int prev_car=curr_car[j];
            res.push_back({now_car, prev_car});
            int prev_position=j, curr_position=j+1;
            swap(curr_car[prev_position], curr_car[curr_position]);
            car_pos[now_car]=j; car_pos[prev_car]=j+1;
        }
    } 
    cout<<res.size()<<endl;
    for(auto i: res){
        cout<<i[0]+1<<" "<<i[1]+1<<endl;
    }
}

int main(){
    int t=1;
    // cin>>t;
    while(t--) solve();
}