Problem: 2052A - Adrenaline Rush
Language: c++17 

Code 1:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define sig(x) (x<0?-1:1)
#define sz(x) ((int)size(x))
#define all(x) begin(x),end(x)
#define all1(x) begin(x)+1,end(x)
#define cmax(x,y) x=max(x,y)
#define cmin(x,y) x=min(x,y)
template <typename T> void vprint(T st, T nd) {auto it=st;while (next(it)!=nd){cout<<*it<<' ';it=next(it);}cout<<*it<<'\n';}
void yn(bool ans) {puts(ans?"yes":"no");}
template <typename T> T cdiv(T a, T b) {return a/b+(sig(a)/sig(b)==1 && a%b);}
template <typename T> using vec=vector<T>;
template <typename T> struct vec2:vector<vector<T>> {vec2()=default;vec2(int n, int m, T val=T()):vector<vector<T>>(n,vector<T>(m,val)){}};
template <typename T> struct vec3:vector<vector<vector<T>>> {vec3()=default;vec3(int n, int m, int k, T val=T()):vector<vector<vector<T>>>(n,vector<vector<T>>(m,vector<T>(k,val))){}};
template <typename T> void reset(T *arr, int l, int r, T val) {fill(arr+l,arr+r+1,val);}

const int N=1000;
int n;
int c[N+1];

int cind[N+1];

void solve() {
    for (int i=1; i<=n; ++i) {
        cind[c[i]]=i;
    }

    vec<int> a(n+1);
    for (int i=1; i<=n; ++i) {
        a[i]=i;
    }

    vec<pair<int,int>> ans;
    for (int x=1; x<=n; ++x) {
        int i=find(all1(a),x)-begin(a);

        // pass everyone ahead
        for (int j=i-1; j>=1; --j) {
            ans.push_back({a[j+1],a[j]});
            swap(a[j],a[j+1]);
        }

        // let actual ahead go through
        i=1;
        for (int j=2; j<=n; ++j) {
            // a[j] pass x?
            if (cind[a[j]]<cind[a[i]]) {
                for (int k=j-1; k>=i; --k) {
                    ans.push_back({a[k+1],a[k]});
                    swap(a[k],a[k+1]);
                }

                i++;
            }
        }
    }

    printf("%d\n", sz(ans));
    for (auto &[x,y]:ans) {
        printf("%d %d\n", x,y);
    }
}

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

    cin>>n;
    for (int i=1; i<=n; ++i) cin>>c[i];
    solve();
}


Code 2:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define sig(x) (x<0?-1:1)
#define sz(x) ((int)size(x))
#define all(x) begin(x),end(x)
#define all1(x) begin(x)+1,end(x)
#define cmax(x,y) x=max(x,y)
#define cmin(x,y) x=min(x,y)
template <typename T> void vprint(T st, T nd) {auto it=st;while (next(it)!=nd){cout<<*it<<' ';it=next(it);}cout<<*it<<'\n';}
void yn(bool ans) {puts(ans?"yes":"no");}
template <typename T> T cdiv(T a, T b) {return a/b+(sig(a)/sig(b)==1 && a%b);}
template <typename T> using vec=vector<T>;
template <typename T> struct vec2:vector<vector<T>> {vec2()=default;vec2(int n, int m, T val=T()):vector<vector<T>>(n,vector<T>(m,val)){}};
template <typename T> struct vec3:vector<vector<vector<T>>> {vec3()=default;vec3(int n, int m, int k, T val=T()):vector<vector<vector<T>>>(n,vector<vector<T>>(m,vector<T>(k,val))){}};
template <typename T> void reset(T *arr, int l, int r, T val) {fill(arr+l,arr+r+1,val);}

const int N=1000;
int n;
int c[N+1];

int cind[N+1];

void solve() {
    for (int i=1; i<=n; ++i) {
        cind[c[i]]=i;
    }

    vec<int> a(n+1);
    for (int i=1; i<=n; ++i) {
        a[i]=i;
    }

    vec<pair<int,int>> ans;
    for (int y=1; y<=n; ++y) {
        int x=c[n-y+1];
        int i=find(all1(a),x)-begin(a);

        // pass everyone ahead
        for (int j=i-1; j>=1; --j) {
            ans.push_back({a[j+1],a[j]});
            swap(a[j],a[j+1]);
        }

        // let actual ahead go through
        i=1;
        for (int j=2; j<=n; ++j) {
            // a[j] pass x?
            if (cind[a[j]]<cind[a[i]]) {
                for (int k=j-1; k>=i; --k) {
                    ans.push_back({a[k+1],a[k]});
                    swap(a[k],a[k+1]);
                }

                i++;
            }
        }
    }

    printf("%d\n", sz(ans));
    for (auto &[x,y]:ans) {
        printf("%d %d\n", x,y);
    }
}

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

    cin>>n;
    for (int i=1; i<=n; ++i) cin>>c[i];
    solve();
}


Answer: 2