Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 4):
#include<bits/stdc++.h>
using namespace std;

#define ll          long long

#define vi          vector<int>
#define vl          vector<long long>
#define vll          vector<vector<long long>>
#define vii         vector<vector<int>>

#define pb          push_back
#define pf          push_front
#define fr          front
#define eb          emplace_back
#define ff          first
#define ss          second
#define endl        "\n"

#define FAST_IO             (ios_base:: sync_with_stdio(false),cin.tie(NULL));

template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename... Args> ostream& operator<<(ostream& os, const tuple<Args...>& t) { os << '('; apply([&os](const Args&... args) { size_t n = 0; ((os << args << (++n != sizeof...(Args) ? ", " : "")), ...); }, t); return os << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
 

#define MOD         1e9 + 7

// ------------------------------- //

void solve(){
    ll n;cin>>n;
    vl arr(n);
    for(ll &x : arr) cin>>x;

    vll steps;
    
    for(int i=0;i<n;i++){
        for(int j=i-1;j>=0;j--){
            steps.push_back({arr[j],arr[j+1]});
            swap(arr[j],arr[j+1]);
        }
    }

    for(int i=n-1;i>0;i--){
        // cout<<i<<' '<<arr<<endl;
        int j = i;
        while(arr[j] != j+1 && j>0){
            steps.push_back({arr[j-1],arr[j]});
            swap(arr[j-1],arr[j]);
            j--;
        }
        // cout<<arr<<endl;
    }
    // cout<<endl;
    // cout<<steps<<endl;

    cout<<steps.size()<<endl;
    for(int i=steps.size()-1;i>=0;i--){
        for(auto x : steps[i]) cout<<x<<' ';
        cout<<endl;
    }


}

int main()
{
    FAST_IO;
    int TC = 1;
    // cin >> TC;
    while (TC--) solve();
    return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;

#define ll          long long

#define vi          vector<int>
#define vl          vector<long long>
#define vll          vector<vector<long long>>
#define vii         vector<vector<int>>

#define pb          push_back
#define pf          push_front
#define fr          front
#define eb          emplace_back
#define ff          first
#define ss          second
#define endl        "\n"

#define FAST_IO             (ios_base:: sync_with_stdio(false),cin.tie(NULL));

template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename... Args> ostream& operator<<(ostream& os, const tuple<Args...>& t) { os << '('; apply([&os](const Args&... args) { size_t n = 0; ((os << args << (++n != sizeof...(Args) ? ", " : "")), ...); }, t); return os << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
 

#define MOD         1e9 + 7

// ------------------------------- //

void solve(){
    ll n;cin>>n;
    vl arr(n);
    for(ll &x : arr) cin>>x;

    vll steps;
    
    // cout<<arr<<endl;
    for(int i=0;i<n;i++){
        for(int j=i-1;j>=0;j--){
            steps.push_back({arr[j],arr[j+1]});
            swap(arr[j],arr[j+1]);
            // cout<<arr<<endl;
        }
    }

    for(int num=1;num<=n;num++){
        for(int i=0;i<n;i++){
            if(arr[i]!=num) continue;

            for(int j=i-1;j>=num-1;j--){
                steps.push_back({arr[j],arr[j+1]});
                swap(arr[j],arr[j+1]);
                // cout<<arr<<endl;
            }
        }
        // cout<<arr<<endl;
    }
    // cout<<endl;
    // cout<<steps<<endl;

    cout<<steps.size()<<endl;
    for(int i=steps.size()-1;i>=0;i--){
        for(auto x : steps[i]) cout<<x<<' ';
        cout<<endl;
    }


}

int main()
{
    FAST_IO;
    int TC = 1;
    // cin >> TC;
    while (TC--) solve();
    return 0;
}