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

Previous submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
#define int long long

// macros
#define For(x) for (int i = 0; i < x; i++)
#define SORT(a) sort(a.begin(), a.end())
#define FOR(a, b, c) for(int i = a; i < b; i += c)
#define SUM(a) accumulate(a.begin(), a.end(), 0LL)
#define MAX(a) *max_element(a.begin(), a.end())
#define all(x) (x.begin(), x.end())

// syntax
#define mp make_pair

// other macros
#define MOD (int)1e8

// speed
#pragma GCC optimize("O3")

using namespace std;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int count;
    cin >> count;
    vector<int> arr(count);
    For (count){
        cin >> arr[i];
    }
    int counter = 0;
    for (int i = 0; i < count; i++){
        for (int j = i + 1; j < count; j++){
            if (arr[i] > arr[j]){
                counter++;
            } else {
                counter += 2;
            }
        }
    }
    cout << counter << "\n";
    for (int i = 0; i < count; i++){
        for (int j = i + 1; j < count; j++){
            cout << j + 1 << " " << i + 1 << "\n";
        }
    }
    for (int x = 0; x < count; x++){
        auto revIndex = count - x;
        if (arr[x] != revIndex){
            // cout << revIndex;
            if (arr[x] > revIndex){
                cout << revIndex << " " << arr[x] << "\n";
                auto v = arr[x];
                arr[x] = arr[x-1];
                arr[x-1] = v;
            } else {
                cout << arr[x] << " " << revIndex << "\n";
                
                auto v = arr[x];
                arr[x] = arr[x+1];
                arr[x+1] = v;
            }
        }
    }
}


Submission (verdict: Wrong answer on test 7):
#include <bits/stdc++.h>
#define int long long

// macros
#define For(x) for (int i = 0; i < x; i++)
#define SORT(a) sort(a.begin(), a.end())
#define FOR(a, b, c) for(int i = a; i < b; i += c)
#define SUM(a) accumulate(a.begin(), a.end(), 0LL)
#define MAX(a) *max_element(a.begin(), a.end())
#define all(x) (x.begin(), x.end())

// syntax
#define mp make_pair

// other macros
#define MOD (int)1e8

// speed
#pragma GCC optimize("O3")

using namespace std;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int count;
    cin >> count;
    vector<int> arr(count);
    For (count){
        cin >> arr[i];
    }
    int counter = 0;
    for (int i = 0; i < count; i++){
        for (int j = i + 1; j < count; j++){
            if (arr[i] > arr[j]){
                counter++;
            } else {
                counter += 2;
            }
        }
    }
    cout << counter << "\n";
    for (int i = 0; i < count; i++){
        for (int j = i + 1; j < count; j++){
            cout << j + 1 << " " << i + 1 << "\n";
        }
    }
    for (int i = 0; i < count; i++){
        for (int x = 0; x < count; x++){
            auto revIndex = count - x;
            if (arr[x] != revIndex){
                // cout << revIndex;
                if (arr[x] > revIndex){
                    cout << arr[x-1] << " " << arr[x] << "\n";
                    auto v = arr[x];
                    arr[x] = arr[x-1];
                    arr[x-1] = v;
                } else {
                    cout << arr[x] << " " << arr[x+1] << "\n";
                    
                    auto v = arr[x];
                    arr[x] = arr[x+1];
                    arr[x+1] = v;
                }
            }
        }
    }
}