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

Previous submission (verdict: Runtime error on test 7):
#include "bits/stdc++.h"
#ifdef AlRntn
#include "debug.hpp"
#else
#define debug(...) 
#define tstr(...) 
#endif
using int64 = int64_t;
using uint64 = uint64_t;
using ll = intptr_t;
using ull = uintptr_t;
using ld = long double;
#define fi first
#define se second
#define sz(x) int64(x.size())
#define all(x) x.begin(), x.end()
#define spc ' '
#define endl '\n'
#define pb push_back
#define mp make_pair
#define ever ;1;
constexpr int64 inf = 5e18 + 100;
constexpr int64 mod1 = 1e9+7;
constexpr int64 mod2 = 998244353;
constexpr int64 mod3 = 1e9+9;
constexpr int64 mod4 = (1ll<<31) - 1;
constexpr long double PI = 2*asinl(1.0);
int dx[4] = {0 , 1 , 0 , -1}; // clockwise from north
int dy[4] = {-1 , 0 , 1 , 0};
int dx2[8] = {0 , 1 , 1 , 1 , 0 , -1 , -1 , -1}; // clockwise from north
int dy2[8] = {-1 , -1 , 0 , 1 , 1 , 1 , 0 , -1};
const int N = 1e6 + 50, L = 25;
ll n;
std::vector<ll> A;
int32_t main(){
#ifdef AlRntn
freopen("inputf.in" , "r" , stdin); freopen("outputf.out" , "w" , stdout); freopen("errorf.out" , "w" , stderr);
#endif
    using namespace std;
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    int32_t tc=1;
//#define TestCases
#ifdef TestCases
    std::cin >> tc;
#endif
    while(tc--){
        cin>>n;A.resize(n);
        for(auto &a : A) cin>>a;
        ll tot = 0;
        for(ll i = 0; i < n; i++){
            for(ll j = i+1; j < n; j++) tot += (A[i] > A[j]);
        }
        cout << n*(n-1) - tot << endl;
        std::vector<ll> B(n, 0); iota(all(B), 1);
        for(ll i = n-1; i >= 0; i--){
            ll C = A[i];
            ll pos = 0;
            for(ll j = 0; j < n; j++) if(B[i] == C) pos = i;
            for(ll k = pos-1; k >= 0; k--){
                cout << B[k+1] << spc << B[k] << endl;
                std::swap(B[k+1], B[k]);
            }
            for(ll k = 0; k < i; k++){
                cout << B[k+1] << spc << B[k] << endl;
                std::swap(B[k+1], B[k]);
            }
        }
        assert(A == B);
    }
    return 0;
}

Submission (verdict: Wrong answer on test 7):
#include "bits/stdc++.h"
#ifdef AlRntn
#include "debug.hpp"
#else
#define debug(...) 
#define tstr(...) 
#endif
using int64 = int64_t;
using uint64 = uint64_t;
using ll = intptr_t;
using ull = uintptr_t;
using ld = long double;
#define fi first
#define se second
#define sz(x) int64(x.size())
#define all(x) x.begin(), x.end()
#define spc ' '
#define endl '\n'
#define pb push_back
#define mp make_pair
#define ever ;1;
constexpr int64 inf = 5e18 + 100;
constexpr int64 mod1 = 1e9+7;
constexpr int64 mod2 = 998244353;
constexpr int64 mod3 = 1e9+9;
constexpr int64 mod4 = (1ll<<31) - 1;
constexpr long double PI = 2*asinl(1.0);
int dx[4] = {0 , 1 , 0 , -1}; // clockwise from north
int dy[4] = {-1 , 0 , 1 , 0};
int dx2[8] = {0 , 1 , 1 , 1 , 0 , -1 , -1 , -1}; // clockwise from north
int dy2[8] = {-1 , -1 , 0 , 1 , 1 , 1 , 0 , -1};
const int N = 1e6 + 50, L = 25;
ll n;
std::vector<ll> A;
int32_t main(){
#ifdef AlRntn
freopen("inputf.in" , "r" , stdin); freopen("outputf.out" , "w" , stdout); freopen("errorf.out" , "w" , stderr);
#endif
    using namespace std;
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    int32_t tc=1;
//#define TestCases
#ifdef TestCases
    std::cin >> tc;
#endif
    while(tc--){
        cin>>n;A.resize(n);
        for(auto &a : A) cin>>a;
        ll tot = 0;
        for(ll i = 0; i < n; i++){
            for(ll j = i+1; j < n; j++) tot += (A[i] > A[j]);
        }
        cout << n*(n-1) - tot << endl;
        std::vector<ll> B(n, 0); iota(all(B), 1);
        for(ll i = n-1; i >= 0; i--){
            ll C = A[i];
            ll pos = 0;
            for(ll j = 0; j < n; j++) if(B[i] == C) pos = i;
            for(ll k = pos-1; k >= 0; k--){
                cout << B[k+1] << spc << B[k] << endl;
                std::swap(B[k+1], B[k]);
            }
            for(ll k = 0; k < i; k++){
                cout << B[k+1] << spc << B[k] << endl;
                std::swap(B[k+1], B[k]);
            }
        }
        //assert(A == B);
    }
    return 0;
}