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

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
long long my_sqrt(long long a) {
    long long l = 0, r = 5000000001;
    while (r - l > 1) {
        long long mid = (l + r) / 2;
        if (1ll * mid * mid <= a) l = mid;
        else r = mid;
    }
    return l;
}
void swap(int& a, int& b) {
    int temp = a;
    a = b;
    b = temp;
    return;
}
void Nischal() {
    int n;
    cin >> n;
    vi c(n);
    for (int i = 0;i < n;i++)cin >> c[i];
    if (n == 1) {
        cout << 0 << endl;
        return;
    }
    vpi over;
    // counts extra overtakes for which are in increasing order 
    for (int i = 0;i < n;i++) {
        for (int j = 0;j < n-i-1;j++) {
            if (c[j] < c[j+1]) {
                over.push_back({ c[j+1],c[j] });
                swap(c[j], c[j + 1]);
            }
        }
    }
    // for reversing the array from increasing to decreasing 
    for (int i = 0;i < n;i++) {
        for (int j = 0;j < n - i - 1;j++) {
            if (c[j] > c[j+1]) {
                over.push_back({ c[j+1],c[j] });
                swap(c[j], c[j + 1]);
            }
        }
    }
    cout << over.size() << endl;
    reverse(all(over));
    // sort(all(over), [](const pi& x, const pi& y) { if (x.second == y.second) return x.first < y.first; else return  x.second < y.second; });
    for (auto pair: over) {
        cout << pair.first << " " << pair.second<<endl;
    }
}
int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t;
    cin >> t;

    while (t--) {
        Nischal();
    }
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
long long my_sqrt(long long a) {
    long long l = 0, r = 5000000001;
    while (r - l > 1) {
        long long mid = (l + r) / 2;
        if (1ll * mid * mid <= a) l = mid;
        else r = mid;
    }
    return l;
}
void swap(int& a, int& b) {
    int temp = a;
    a = b;
    b = temp;
    return;
}
void Nischal() {
    int n;
    cin >> n;
    vi c(n);
    for (int i = 0;i < n;i++)cin >> c[i];
    if (n == 1) {
        cout << 0 << endl;
        return;
    }
    vpi over;
    // counts extra overtakes for which are in increasing order 
    for (int i = 0;i < n;i++) {
        for (int j = 0;j < n-i-1;j++) {
            if (c[j] < c[j+1]) {
                over.push_back({ c[j+1],c[j] });
                swap(c[j], c[j + 1]);
            }
        }
    }
    // for reversing the array from increasing to decreasing 
    for (int i = 0;i < n;i++) {
        for (int j = 0;j < n - i - 1;j++) {
            if (c[j] > c[j+1]) {
                over.push_back({ c[j+1],c[j] });
                swap(c[j], c[j + 1]);
            }
        }
    }
    cout << over.size() << endl;
    reverse(all(over));
    // sort(all(over), [](const pi& x, const pi& y) { if (x.second == y.second) return x.first < y.first; else return  x.second < y.second; });
    for (auto pair: over) {
        cout << pair.first << " " << pair.second<<endl;
    }
}
int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t=1;
    // cin >> t;

    while (t--) {
        Nischal();
    }
    return 0;
}