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

Code 1:
/*'ॐ नमः शिवाय'*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
const int mod = 1e9 + 7;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n), c(n);
    map<int, int>ind, m;
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        ind[c[i]] = i;
    }
    for (int i = 0; i < n; i++) {
        a[i] = i + 1;
        m[a[i]] = i;
    }
    vector<pair<int, int>> v;
    for (int i = 0; i < n; i++)a[i] = i + 1;
    int i = n - 1;
    int ans = 0;
    while (i >= 0) {
        int j = m[c[i]];
        while (j < i) {
            v.push_back({a[j + 1], a[j]});
            swap(a[j], a[j + 1]);
            ans++;
            j++;
        }
        for (int i = 0; i < n; i++) {
            m[a[i]] = i;
        }
        i--;
    }
    vector<pair<int, int>> temp;
    for (int i = n; i >= 1; i--) {
        int j = ind[i];
        while (j >= 0) {
            if (c[j - 1] < i) {
                v.push_back({i, c[j - 1]});
                temp.push_back({i, c[j - 1]});
                ans += 2;
            }
            j--;
        }
    }
    int size = temp.size();
    for (int j = size - 1; j >= 0; j--) {
        int x = temp[j].first;
        int y = temp[j].second;
        v.push_back({y, x});
    }
    cout << ans << endl;
    for (int i = 0; i < v.size(); i++) {
        cout << v[i].first << " " << v[i].second << endl;
    }
}

int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
    freopen("input.txt",  "r",  stdin);
    freopen("output.txt", "w", stdout);
#endif

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

    return 0;
}

Code 2:
/*'ॐ नमः शिवाय'*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
const int mod = 1e9 + 7;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n), c(n);
    map<int, int>ind, m;
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        ind[c[i]] = i;
    }
    for (int i = 0; i < n; i++) {
        a[i] = i + 1;
        m[a[i]] = i;
    }
    map<pair<int, int>, int> mp;
    vector<pair<int, int>> v;
    for (int i = 0; i < n; i++)a[i] = i + 1;
    int i = n - 1;
    int ans = 0;
    while (i >= 0) {
        int j = m[c[i]];
        while (j < i) {
            v.push_back({a[j + 1], a[j]});
            swap(a[j], a[j + 1]);
            ans++;
            j++;
        }
        for (int i = 0; i < n; i++) {
            m[a[i]] = i;
        }
        i--;
    }
    vector<pair<int, int>> temp;
    for (int i = n; i >= 1; i--) {
        int j = ind[i];
        while (j >= 0) {
            if (c[j - 1] < i) {
                v.push_back({i, c[j - 1]});
                temp.push_back({i, c[j - 1]});
                ans += 2;
            }
            j--;
        }
    }
    int size = temp.size();
    for (int j = size - 1; j >= 0; j--) {
        int x = temp[j].first;
        int y = temp[j].second;
        v.push_back({y, x});
    }
    cout << ans << endl;
    for (int i = 0; i < v.size(); i++) {
        cout << v[i].first << " " << v[i].second << endl;
    }
}

int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
    freopen("input.txt",  "r",  stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t = 1;
    cin >> t;
    while (t--) solve();

    return 0;
}

Answer: 1