Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 28):
/*

This code template was updated by Yukii_P on 2024/11/12.

*/
#include <bits/stdc++.h>
#define FIO cin.tie(0); ios::sync_with_stdio(false)
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define inf 0x3f3f3f3f

#ifndef ONLINE_JUDGE
#define debug(...) std::cerr << #__VA_ARGS__ << " = "; dbg1(__VA_ARGS__)
void dbg2() { std::cerr << "\n"; }
template<typename T, typename... T2>
void dbg2(T x, T2... args) {
    std::cerr << ", " << x;
    dbg2(args...);
}
template<typename T, typename... T2>
void dbg1(T x, T2... args) {
    std::cerr << x;
    dbg2(args...);
}
#else
#define debug(...) 
#endif

using namespace std;
using i64 = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using pii = std::pair<int, int>;

inline char nc() {
    static char buf[1 << 20], *p1, *p2;
    return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<20, stdin), p1 == p2) ? EOF : *p1++;
}
#ifndef ONLINE_JUDGE
#define nc getchar
#endif
void read() {}
template<typename T, typename... T2> 
inline void read(T &x, T2 &... oth) {
    x = 0; char c = nc(), up = c;
    while(!isdigit(c)) up = c, c = nc();
    while(isdigit(c)) x = x * 10 + c - '0', c = nc();
    up == '-' ? x = -x : 0;
    read(oth...);
}

constexpr int N = 1e3 + 10;
constexpr int MOD = 998244353;

int a[N];
pii ans[N];
int top;

void solve() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j < n; ++j) {
            if (a[j] < a[j+1]) {
                swap(a[j], a[j+1]);
                ans[top++] = {a[j], a[j+1]};
            }
        }
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j < n; ++j) {
            if (a[j] > a[j+1]) {
                swap(a[j], a[j+1]);
                ans[top++] = {a[j], a[j+1]};
            }
        }
    }
    cout << top << '\n';
    for (int i = top - 1; i >= 0; --i) {
        cout << ans[i].se << ' ' << ans[i].fi << '\n';
    }
}

signed main() {
    
    FIO;
    int t = 1;
    while (t--) solve();

    return 0;
}

/*

 __  __     ___    ___      _      __ _            ___      _             _      
 \ \/ /    | _ \  /   \    | |    / _` |   ___    / __|    | |    _  _   | |__   
  >  <     |  _/  | - |    | |    \__, |  / _ \  | (__     | |   | +| |  | '_ \  
 /_/\_\   _|_|_   |_|_|   _|_|_   |___/   \___/   \___|   _|_|_   \_,_|  |_.__/  
_|"""""|_| """ |_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""| 
"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-' 

(Font: ASCII - Train)

"El Psy Kongroo." -- Hououin Kyoma

*/

Submission (verdict: Accepted):
/*

This code template was updated by Yukii_P on 2024/11/12.

*/
#include <bits/stdc++.h>
#define FIO cin.tie(0); ios::sync_with_stdio(false)
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define inf 0x3f3f3f3f

#ifndef ONLINE_JUDGE
#define debug(...) std::cerr << #__VA_ARGS__ << " = "; dbg1(__VA_ARGS__)
void dbg2() { std::cerr << "\n"; }
template<typename T, typename... T2>
void dbg2(T x, T2... args) {
    std::cerr << ", " << x;
    dbg2(args...);
}
template<typename T, typename... T2>
void dbg1(T x, T2... args) {
    std::cerr << x;
    dbg2(args...);
}
#else
#define debug(...) 
#endif

using namespace std;
using i64 = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using pii = std::pair<int, int>;

inline char nc() {
    static char buf[1 << 20], *p1, *p2;
    return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<20, stdin), p1 == p2) ? EOF : *p1++;
}
#ifndef ONLINE_JUDGE
#define nc getchar
#endif
void read() {}
template<typename T, typename... T2> 
inline void read(T &x, T2 &... oth) {
    x = 0; char c = nc(), up = c;
    while(!isdigit(c)) up = c, c = nc();
    while(isdigit(c)) x = x * 10 + c - '0', c = nc();
    up == '-' ? x = -x : 0;
    read(oth...);
}

constexpr int N = 1e3 + 10;
constexpr int MOD = 998244353;

int a[N];
pii ans[N * N];
int top;

void solve() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j < n; ++j) {
            if (a[j] < a[j+1]) {
                swap(a[j], a[j+1]);
                ans[top++] = {a[j], a[j+1]};
            }
        }
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j < n; ++j) {
            if (a[j] > a[j+1]) {
                swap(a[j], a[j+1]);
                ans[top++] = {a[j], a[j+1]};
            }
        }
    }
    cout << top << '\n';
    for (int i = top - 1; i >= 0; --i) {
        cout << ans[i].se << ' ' << ans[i].fi << '\n';
    }
}

signed main() {
    
    FIO;
    int t = 1;
    while (t--) solve();

    return 0;
}

/*

 __  __     ___    ___      _      __ _            ___      _             _      
 \ \/ /    | _ \  /   \    | |    / _` |   ___    / __|    | |    _  _   | |__   
  >  <     |  _/  | - |    | |    \__, |  / _ \  | (__     | |   | +| |  | '_ \  
 /_/\_\   _|_|_   |_|_|   _|_|_   |___/   \___/   \___|   _|_|_   \_,_|  |_.__/  
_|"""""|_| """ |_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""| 
"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-' 

(Font: ASCII - Train)

"El Psy Kongroo." -- Hououin Kyoma

*/