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

Previous submission (verdict: Wrong answer on test 4):
#include <iostream>
#include<vector>
#include<queue>
#include<iterator>
#include<algorithm>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include <numeric>
#include <tuple>
#include <unordered_map>
#include <cstdlib>
#include <string>
#define N 200001
#define M 1001


using namespace std;
using ll = long long;

int ord[M],arr[M];
int find(int x,int n){
    for(int i=1;i<=n;i++){
        if(arr[i] == x){
            return i;
        }
    }
    return -1;
}

int main(){
    int n;
    cin>>n;
    //ll ans = 0ll;
    for(int i=1;i<=n;i++){
        cin>>ord[i];
        arr[i] = i;
    }
    vector<pair<int,int> > ans;
    
    for(int i=1;i<=n;i++){
        if(ord[i] == arr[i]){
            continue;
        }
        else{
            int j = find(ord[i],n);
            for(int k=j;k>i;k--){
                ans.push_back(make_pair(arr[k],arr[k-1]));
                swap(arr[k],arr[k-1]);
            }
        }
    }
    for(int i=1;i<n;i++){
        if(ord[i] < ord[i+1]){
            ans.push_back(make_pair(ord[i+1],ord[i]));
            ans.push_back(make_pair(ord[i],ord[i+1]));
        }
    }
    cout << ans.size() << endl;
    for(int i=0;i<ans.size();i++){
        printf("%d %d\n",ans[i].first,ans[i].second);
    }
}

Submission (verdict: Wrong answer on test 7):
#include <iostream>
#include<vector>
#include<queue>
#include<iterator>
#include<algorithm>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include <numeric>
#include <tuple>
#include <unordered_map>
#include <cstdlib>
#include <string>
#define N 200001
#define M 1001


using namespace std;
using ll = long long;

int ord[M],arr[M];
int state[M][M];
int find(int x,int n){
    for(int i=1;i<=n;i++){
        if(arr[i] == x){
            return i;
        }
    }
    return -1;
}

int main(){
    int n;
    cin>>n;
    //ll ans = 0ll;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            state[i][j] = 0;
        }
    }
    for(int i=1;i<=n;i++){
        cin>>ord[i];
        arr[i] = i;
    }
    vector<pair<int,int> > ans;
    
    for(int i=1;i<=n;i++){
        if(ord[i] == arr[i]){
            continue;
        }
        else{
            int j = find(ord[i],n);
            for(int k=j;k>i;k--){
                ans.push_back(make_pair(arr[k],arr[k-1]));
                swap(arr[k],arr[k-1]);
                state[arr[k-1]][arr[k]] = 1;
                
            }
        }
    }
    for(int i=1;i<n;i++){
        int k = i;
        for(int j=i+1;j<=n;j++){
            if(!state[arr[i]][arr[j]]){
                ans.push_back(make_pair(arr[j],arr[j-1]));
                swap(arr[j-1],arr[j]);
                state[arr[j-1]][arr[j]] = 1;
            }
            else{
                k = j-1;
                break;
            }
            if(j == n){
                k = n;
            }
        }
        if(k > i){
            while(k != i){
                ans.push_back(make_pair(arr[k],arr[k-1]));
                swap(arr[k],arr[k-1]);
                state[arr[k]][arr[k-1]] = 1;
                k--;
            }
        }
    }
    cout << ans.size() << endl;
    for(int i=0;i<ans.size();i++){
        printf("%d %d\n",ans[i].first,ans[i].second);
    }
}