Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
template <class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long
int floor_div(int x, int y) {
	assert(y != 0);
	if (y < 0) {
		y = -y;
		x = -x;
	}
	if (x >= 0) return x / y;
	return (x + 1) / y - 1;
}
int ceil_div(int x, int y) {
	assert(y != 0);
	if (y < 0) {
		y = -y;
		x = -x;
	}
	if (x <= 0) return x / y;
	return (x - 1) / y + 1;
}
void run_case()
{
    int n;
    cin>>n;
    vector<int> a(n + 1);
    vector<int> pos(n + 1);
    vector<pair<int ,int>> swaps;
    vector<vector<bool>> swapped(n + 1 , vector<bool>(n + 1));
    for(int i = 1 ; i <= n ;i++)
    {
        cin>>a[i];
        pos[a[i]] = i;
    }
    for(int i =1 ;i <= n ;i++)
    {
        int p = pos[i];
        if(p == i)
            continue;
        pos[a[i]] = p;
        pos[i] = i;
        swap(a[i] , a[p]);
        swapped[i][p] = swapped[p][i] = 1;
        swaps.push_back({i , p});
    }
    for(int i = 1 ; i <= n ; i++)
    {
        for(int j = 1 ; j <= n ; j++)
        {
            if(i == j || swapped[i][j])
                continue;
            swaps.push_back({i , j});
        }
    }
    reverse(swaps.begin() , swaps.end());
    cout<<(int)swaps.size()<<'\n';
    for(auto p : swaps)
        cout<<p.first<<" "<<p.second<<'\n';
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin>>t;
    while(t--)
    {
        run_case();
    }
}
// THINK OF DP !
// KEEP TRACK OF TIME !

Submission (verdict: Wrong answer on test 4):
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
template <class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long
int floor_div(int x, int y) {
	assert(y != 0);
	if (y < 0) {
		y = -y;
		x = -x;
	}
	if (x >= 0) return x / y;
	return (x + 1) / y - 1;
}
int ceil_div(int x, int y) {
	assert(y != 0);
	if (y < 0) {
		y = -y;
		x = -x;
	}
	if (x <= 0) return x / y;
	return (x - 1) / y + 1;
}
void run_case()
{
    int n;
    cin>>n;
    vector<int> a(n + 1);
    vector<int> pos(n + 1);
    vector<pair<int ,int>> swaps;
    vector<vector<bool>> swapped(n + 1 , vector<bool>(n + 1));
    for(int i = 1 ; i <= n ;i++)
    {
        cin>>a[i];
        pos[a[i]] = i;
    }
    for(int i =1 ;i <= n ;i++)
    {
        int p = pos[i];
        if(p == i)
            continue;
        for(int j = p - 1 ; j >= i ;j--)
        {
            swapped[a[j]][a[j + 1]] = swapped[a[j + 1]][a[j]] = 1;
            swaps.push_back({a[j] , a[j + 1]});
            pos[a[j]] = j + 1;
            pos[a[j + 1]] = j;
            swap(a[j] , a[j + 1]); 
        }
    }
    for(int i = 1 ; i <= n ; i++)
    {
        vector<pair<int ,int>> cur;
        for(int j = i +1 ; j <= n ; j++)
        {
            if(swapped[i][j])
                break;
            cur.push_back({i , j});
        }
        for(auto p : cur)
            swaps.push_back(p);
        for(auto p : cur)
            swaps.push_back({p.second , p.first});
    }
    reverse(swaps.begin() , swaps.end());
    cout<<(int)swaps.size()<<'\n';
    for(auto p : swaps)
        cout<<p.first<<" "<<p.second<<'\n';
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin>>t;
    while(t--)
    {
        run_case();
    }
}
// THINK OF DP !
// KEEP TRACK OF TIME !