Problem: 2052A - Adrenaline Rush
Language: c++23 

Code 1:
#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<n;k++){
                ans.push_back(make_pair(arr[k+1],arr[k]));
                swap(arr[k],arr[k+1]);
                state[arr[k]][arr[k+1]] = 1;
            }
            for(int k=n;k>j;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 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++){
            //printf("%d %d:%d\n",arr[j-1],arr[j],state[arr[j-1]][arr[j]]);
            if(!state[arr[j-1]][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;
                k = j;
            }
            else {
                k = j-1;
                break;
            }

        }
        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 << state[3][1] << endl;
    cout << ans.size() << endl;
    for(int i=0;i<ans.size();i++){
        printf("%d %d\n",ans[i].first,ans[i].second);
    }
}

Code 2:
#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);
    }
}

Answer: 1