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

Solution 1 (runtime: 296 ms):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vl>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vpi = vector<pair<int,int>>;
using vpl = vector<pair<ll,ll>>;
using vpll = vector<vector<pair<ll,ll>>>;
#define rt return
struct custom_hash {
   static uint64_t splitmix64(uint64_t x) {
      x += 0x9e3779b97f4a7c15;
      x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
      x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
      return x ^ (x >> 31);
   }
   size_t operator()(uint64_t x) const {
       static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
       return splitmix64(x + FIXED_RANDOM);
   }
};
#ifdef ONLINE_JUDGE
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define um gp_hash_table
#define debug(x...)
#define debugmul(v...)
#else
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#define debugmul(v...) cerr<< "[" << #v <<"] = ["; __print_auto(v)
#define um unordered_map
void __print(auto x){
    cerr << x;
}
void __print(pair<auto,auto> p){
    cerr << "{" << p.first <<","<<p.second<<"}";
}
void _print() {cerr << "]\n";}
template<typename T, typename... V>
void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
void __print_auto(){cerr << "]\n";}
template<typename T,typename... V>
void __print_auto(const T &x, const V&... y) {
    int f = 0;
    cerr << '{';
    for (const auto &i: x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
    if (sizeof...(y)) cerr << ", ";
    __print_auto(y...);
}
#endif
template<typename Key, typename Value, typename Hash = custom_hash>
using hashmap = um<Key, Value, Hash>;
#define pyes cout<<"YES"<<endl
#define pno cout<<"NO"<<endl
#define endl '\n'
#define M 1000000007
void pr(auto x){
    cout<<x<<endl;
}
template<typename T>
void autopr(const T&v) {
    for (auto &x : v) cout << x << ' ';
    cout << endl;
}
pair<vector<bool>,vector<int>> sieve(int n) {
    vector<bool> is_prime(n + 1, true);
    vector<int> primes;
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i * i <= n; i++) {
        if (is_prime[i]) {
            for (int j = i * i; j <= n; j += i) {
                is_prime[j] = false;
            }
        }
    }
    for(int i=0;i<=n;i++){
        if(is_prime[i]) primes.push_back(i);
    }
    return make_pair(is_prime,primes);
}
vector<ll> prefix_sum(const vector<ll> &v) {
    if(!v.size()) return vl();
    vector<ll> prefix;
    prefix.push_back(v[0]);
    for (int i = 1; i < (int) v.size(); ++i) {
        prefix.push_back(v[i]+prefix.back());
    }
    return prefix;
}
template<typename T>
pair<T,int> min(const vector<T>& v) {
    auto it = min_element(v.begin(), v.end());
    return {*it,it-v.begin()};
}
template<typename T>
pair<T,int> max(const vector<T>& v) {
    auto it = max_element(v.begin(), v.end());
    return {*it,it-v.begin()};
}
#define precision(x, p) std::cout << std::fixed << std::setprecision(p) << x << endl;
#define pb push_back
#define get_bit(x,r) (x&(1<<r))
#define all(v) v.begin(),v.end()
#define sz(x) (int)x.size()
#define len(x) (int)x.length()
#define srt(v) sort(all(v))

void solve(){
    ll n;
    cin>>n;
    vl final;
    for(int i=0;i<n;i++){
        ll x;
        cin>>x;
        final.push_back(x);
    }
    vl curr;
    for(int i=0;i<n;i++){
        curr.pb(i+1);
    }
    vpl ans;
    for(int i=0;i<n;i++){
        ll idx = i;
        for(int j=i;j<n;j++){
            if(curr[j]==final[i]) idx = j;
        }
        for(int j=idx+1;j<n;j++){
            ans.pb({curr[j],curr[j-1]});
            swap(curr[j],curr[j-1]);
        }
        for(int j=n-1;j>i;j--){
            ans.pb({curr[j],curr[j-1]});
            swap(curr[j],curr[j-1]);
        }
    }
    pr(sz(ans));
    for(auto &e:ans){
        cout<<e.first<<" "<<e.second<<endl;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Solution 2 (runtime: 1280 ms):
#include <iostream>

#include <vector>

#include <map>

using namespace std;

struct node

{

	int value=0;

	int location=0;

};

int main() {

	int n;

	cin >> n;

	map<int, int> m1, m2;

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

		//这个数在什么位置

		m1[n + 1 - i] = i;

		//存储的数

		m2[i] = n + 1 - i;

	}

	vector<int> brr(n + 1);

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

		cin >> brr[i];

	}

	int ans = n * (n - 1) / 2;

	vector<node> arr;

	for (int i = n; i > 0; i--) {

		ans += i - m1[brr[i]];

		for (int j = m1[brr[i]] + 1; j <= i; j++) {

			node temp;

			temp.value = brr[i];

			temp.location = m2[j];

			arr.push_back(temp);

			m1[brr[i]] = m1[brr[i]] + 1;

			m2[j] = brr[i];

			m1[temp.location] = m1[brr[i]] - 1;

			m2[j - 1] = temp.location;

		}



	}

	cout << ans << endl;

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

		for (int j = i + 1; j <= n; j++) {

			cout << j << " " << i << endl;

		}

	}

	for (int i = 0; i < arr.size(); i++) {

		cout << arr[i].location << " " << arr[i].value << endl;

	}

}