ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2052A - Adrenaline Rush
Language: c++20 

Code 1:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(),(x).end()
typedef pair<int, int> PII;
const int N = 2e6 + 10;

int a[N];

void solve() {
    int n;
    cin>>n;
    map<int,int>pos;
    vector<PII>ans;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        pos[a[i]]=i;
    }
    for(int i=1;i<=n;i++){
        for(int j=pos[i];j<n;j++){
            swap(a[j],a[j+1]);
            pos[a[j]]=j;
            pos[a[j+1]]=j+1;
            ans.push_back({a[j],a[j+1]});
            // for(int i=1;i<=n;i++){
            //     cout<<a[i]<<' ';
            // }
            // cout<<endl;
        }
        for(int j=n;j>=i+1;j--){
            swap(a[j],a[j-1]);
            pos[a[j]]=j;
            pos[a[j-1]]=j-1;
            ans.push_back({a[j-1],a[j]});
            // for(int i=1;i<=n;i++){
            //     cout<<a[i]<<' ';
            // }
            // cout<<endl;
        }
    }
    // for(int i=0;i<ans.size();i++){
    //     cout<<ans[i].first<<' '<<ans[i].second<<endl;
    // }
    cout<<ans.size()<<endl;
    for(int i=ans.size()-1;i>=0;i--){
        cout<<ans[i].first<<' '<<ans[i].second<<endl;
    }
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int T = 1;
    //cin >> T;
    while (T--) solve();
    return 0;
}


Code 2:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(),(x).end()
typedef pair<int, int> PII;
const int N = 2e6 + 10;

int a[N];

void solve() {
    int n;
    cin>>n;
    map<int,int>pos;
    vector<PII>ans;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        pos[a[i]]=i;
    }
    for(int i=1;i<=n;i++){
        for(int j=pos[i];j<n;j++){
            swap(a[j],a[j+1]);
            pos[a[j]]=j;
            pos[a[j+1]]=j+1;
            ans.push_back({a[j+1],a[j]});
            // for(int i=1;i<=n;i++){
            //     cout<<a[i]<<' ';
            // }
            // cout<<endl;
        }
        for(int j=n;j>=i+1;j--){
            swap(a[j],a[j-1]);
            pos[a[j]]=j;
            pos[a[j-1]]=j-1;
            ans.push_back({a[j],a[j-1]});
            // for(int i=1;i<=n;i++){
            //     cout<<a[i]<<' ';
            // }
            // cout<<endl;
        }
    }
    // for(int i=0;i<ans.size();i++){
    //     cout<<ans[i].first<<' '<<ans[i].second<<endl;
    // }
    cout<<ans.size()<<endl;
    for(int i=ans.size()-1;i>=0;i--){
        cout<<ans[i].first<<' '<<ans[i].second<<endl;
    }
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int T = 1;
    //cin >> T;
    while (T--) solve();
    return 0;
}


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

Code 1:
#pragma ccc optimize(3)
#pragma ccc optimize(2)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
#define INF 0x3f3f3f3f
#define il inline
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define pb push_back
#define P pair<int,int>
//#define cin fin
//#define cout fout
//ifstream cin("文件名.in");
//ofstream cout("文件名.out");
int a[1005];
void solve(){
	int n;
	cin >> n;
	vector<P > ans;
	for(int i = 1; i <= n; ++i)cin >> a[i];
	for(int i = 1; i <= n; ++i){
		for(int j = i + 1; j <= n; ++j){
			if(a[i] < a[j]){
				ans.pb(mp(a[j], a[i]));
				ans.pb(mp(a[i], a[j]));
			} 
			else ans.pb(mp(a[i], a[j]));
		}
	}
	cout << ans.size() << endl;
	for(int i = 0; i < ans.size(); ++i)cout << ans[i].ft << ' ' << ans[i].sd << endl; 
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
	return 0;
}



Code 2:
#pragma ccc optimize(3)
#pragma ccc optimize(2)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
#define INF 0x3f3f3f3f
#define il inline
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define pb push_back
#define P pair<int,int>
//#define cin fin
//#define cout fout
//ifstream cin("文件名.in");
//ofstream cout("文件名.out");
int a[1005];
bool expr[1005];
void solve(){
	int n;
	cin >> n;
	vector<P > ans;
	for(int i = 1; i <= n; ++i)cin >> a[i];
	for(int i = 1; i <= n; ++i){
		for(int j = a[i] + 1; j <= n; ++j){
			if(expr[j])continue;
			ans.pb(mp(j, a[i]));
		}
		expr[a[i]] = 1;
		for(int j = n; j >= 1; --j){
			if(expr[j])continue;
			ans.pb(mp(a[i], j));
		}
	}
	cout << ans.size() << endl;
	for(int i = 0; i < ans.size(); ++i)cout << ans[i].ft << ' ' << ans[i].sd << endl; 
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
	return 0;
}



Answer: 2
Problem: 2052A - Adrenaline Rush
Language: c++20 

Code 1:
#include <bits/stdc++.h>
using namespace std;

int  main()
{
     long long int  n,t=1,i,j,m,k;
    //cin >> t ;
    while(t--)
    {
    //string s;
    cin >> n ;
    long long int ans=0,a[n],b[n+1]={};
    char op;
    //pair<long long int,long long int>a[n];
    for(i=0;i<n;i++)
    {
      cin >> a[i] ;
      ans+=max(i-i,n-a[i])+n-i-1;
    }
    cout << ans << "\n" ;
    for(i=0;i<n;i++)
    {
      //b[a[i]]++;
      for(j=a[i]+1;j<=n;j++)
      {
        if(b[j]==0)
        cout << j << " " << a[i] << "\n" ;
      }
      for(j=n;j>0;j--)
      {
        if(b[j]==0&&j!=a[i])
        cout << a[i] << " " << j << "\n" ;
      }
      b[a[i]]++;
    }
  }
  return 0;
}

Code 2:
#include <bits/stdc++.h>
using namespace std;

int  main()
{
     long long int  n,t=1,i,j,m,k;
    //cin >> t ;
    while(t--)
    {
    //string s;
    cin >> n ;
    long long int ans=0,a[n],b[n+1]={},x;
    vector<long long int>c;
    char op;
    //pair<long long int,long long int>a[n];
    for(i=0;i<n;i++)
    {
      cin >> a[i] ;
      x=n-a[i];
      for(j=0;j<c.size()&&x;j++)
      {
        if(c[j]>a[i])
        x--;
      }
      ans+=x+n-i-1;
      c.push_back(a[i]);
    }
    cout << ans << "\n" ;
    for(i=0;i<n;i++)
    {
      //b[a[i]]++;
      for(j=a[i]+1;j<=n;j++)
      {
        if(b[j]==0)
        cout << j << " " << a[i] << "\n" ;
      }
      for(j=n;j>0;j--)
      {
        if(b[j]==0&&j!=a[i])
        cout << a[i] << " " << j << "\n" ;
      }
      b[a[i]]++;
    }
  }
  return 0;
}

Answer: 2
Problem: 2052A - Adrenaline Rush
Language: c++20 

Code 1:
#include<bits/stdc++.h>
using namespace std;
const int N=1100;
int a[N];
int n;
int ans;
vector<pair<int,int>>cnt;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	if(n==1)
	{
		cout<<ans<<endl;return 0;
	}
	for(int i=1;i<=n-1;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			if(a[i]<a[j])
			{
				ans+=2;
				cnt.push_back({a[j],a[i]});
				cnt.push_back({a[i],a[j]});
			}
			else
			{
				ans++;
				cnt.push_back({a[i],a[j]});
			}
		}
	}
	cout<<ans<<endl;
	for(auto it:cnt)
	{
		cout<<it.first<<' '<<it.second<<endl;
	}
}

Code 2:
#include<bits/stdc++.h>
using namespace std;
const int N=1100;
int a[N],pos[N],b[N];
int n;
int ans;
vector<pair<int,int>>cnt;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		pos[a[i]]=i;
		b[i]=i;
	}
	if(n==1)
	{
		cout<<ans<<endl;return 0;
	}
	for(int i=n;i;i--)
	{
		int ind;
		for(int j=1;j<=n;j++)
		{
			if(b[j]==a[i])
			{
				ind=j;break;
			}
		}
		for(int j=ind-1;j;j--)
		{
			cnt.push_back({b[j+1],b[j]});
			swap(b[j+1],b[j]);
		}
		for(int j=2;j<=i;j++)
		{
			cnt.push_back({b[j],b[j-1]});
			swap(b[j-1],b[j]);
		}
		//for(int j=1;j<=n;j++)cout<<b[j]<<' ';cout<<endl;
	}
	cout<<cnt.size()<<endl;
	for(auto it:cnt)cout<<it.first<<' '<<it.second<<endl;
}

Answer: 2
Problem: 2052A - Adrenaline Rush
Language: c++17 

Code 1:
// Problem: A. Adrenaline Rush
// Contest: Codeforces - 2024-2025 ICPC, NERC, Northern Eurasia Finals (Unrated, Online Mirror, ICPC Rules, Teams Preferred)
// URL: https://codeforces.com/problemset/problem/2052/A
// Memory Limit: 1024 MB
// Time Limit: 3000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pii;
typedef pair<int, long long> pil;
typedef pair<long long, int> pli;

const int M = 1e9+7;
const int N = 2e6 + 10;
int a[N], b[N];
int l[N], r[N];
char g[110][110];
char mapp[110][110];
bool st[110][110];
int n, m;

void solve() {
	cin >> n;
	set<int> S;
	for(int i = 1;i <= n;i ++) {
		cin >> a[i];
		S.insert(i);
	}
	
	vector<pii> ans;
	
	for(int i = n;i >= 1;i --) {
		for(int j = 1;j < a[i];j ++) {
			if(S.count(j) == 0) continue;
			ans.push_back({a[i], j});
		}
		S.erase(a[i]);
		for(auto t : S) {
			ans.push_back({t, a[i]});
		}
	}
	
	cout << ans.size() << endl;
	for(auto t : ans) {
		cout << t.first << " " << t.second << endl;
	}
}

int main() {
    ios::sync_with_stdio(false);
    int t = 1;
    // cin >> t;
    while(t --) {
        solve();
    }
    return 0;
}



Code 2:
// Problem: A. Adrenaline Rush
// Contest: Codeforces - 2024-2025 ICPC, NERC, Northern Eurasia Finals (Unrated, Online Mirror, ICPC Rules, Teams Preferred)
// URL: https://codeforces.com/problemset/problem/2052/A
// Memory Limit: 1024 MB
// Time Limit: 3000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pii;
typedef pair<int, long long> pil;
typedef pair<long long, int> pli;

const int M = 1e9+7;
const int N = 2e6 + 10;
int a[N], b[N];
int l[N], r[N];
char g[110][110];
char mapp[110][110];
bool st[110][110];
int n, m;

void solve() {
	cin >> n;
	set<int> S;
	for(int i = 1;i <= n;i ++) {
		cin >> a[i];
		S.insert(i);
	}
	
	vector<pii> ans;
	
	for(int i = n;i >= 1;i --) {
		for(int j = a[i] - 1;j >= 1;j --) {
			if(S.count(j) == 0) continue;
			ans.push_back({a[i], j});
		}
		S.erase(a[i]);
		for(auto t : S) {
			ans.push_back({t, a[i]});
		}
	}
	
	cout << ans.size() << endl;
	for(auto t : ans) {
		cout << t.first << " " << t.second << endl;
	}
}

int main() {
    ios::sync_with_stdio(false);
    int t = 1;
    // cin >> t;
    while(t --) {
        solve();
    }
    return 0;
}



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

Code 1:
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin>>n;
    vector<int>arr(n);
    unordered_map<int, int>mp;
    int count = 0;
    vector<pair<int, int>>cd;
    for(int i = 0;i<n;i++)
    {
        cin>>arr[i];
        mp[arr[i]] = i+1;
    }
    for(int i = 1;i<n;i++)
    {
        for(int j = i+1;j<=n;j++)
        {
            if(mp[i] > mp[j])
            {
                count++;
                cd.push_back({j,i});
            }
            else
            {
                count += 2;
                cd.push_back({j, i});
                cd.push_back({i, j});
            }
        }
    }
    cout<<count<<endl;
    for(int i = 0;i<cd.size();i++)
    {
        cout<<cd[i].first<<" "<<cd[i].second<<endl;
    }


    return 0;
}


Code 2:
#include <bits/stdc++.h>
using namespace std;

int main() {
        int n;
        cin >> n;
        vector<int>arr(n);
        for (auto &i : arr)cin >> i;
        vector<pair<int, int>>ans;
        vector<int>ou(n);
        for (int i = 0; i < n; i++)ou[i] = i + 1;
        for (int i = n; i >= 2; i--)
        {
            for (int j = i - 1; j >= 1; j--)
            {
                ans.push_back({i, j});
            }
        }
        map<int, int>mp;
        int c = 0;
        for (auto i : arr)
        {
            mp[i] = c;
            c++;
        }
        for (int i = n - 1; i > 0; i--)
        {
            int cur = i;
            for (int j = n - 1; j >= mp[i] + 1; j--)
            {
                if (arr[j] > cur)
                {
                    ans.push_back({cur, arr[j]});
                }
            }
            }

        cout << ans.size();
        cout << endl;
        for (auto i : ans)cout << i.first << " " << i.second << endl;




    return 0;
}


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

Code 1:
#include <bits/stdc++.h>
using namespace std;
#define int long long int
void print(vector<int> &a){
   // for(auto _ : a)cerr<<_<<" ";
    cerr<<endl;
}
void incheck(){
    cerr<<"inloop"<<endl;
}
void solve() {
    int n;
    cin>>n;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int ans = 0;
    vector<pair<int,int>> res;
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            if(a[j] < a[j+1]){
               // incheck();
                res.push_back({a[j],a[j+1]});
                swap(a[j],a[j+1]);
            }
          // print(a);
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            if(a[j] > a[j+1]){
                //incheck();
                res.push_back({a[j],a[j+1]});
                swap(a[j],a[j+1]);
            }
            //print(a);
        }
    }
    reverse(res.begin(),res.end());
    cout<<res.size()<<endl;
    for(auto it : res){
        cout<<it.first<<" "<<it.second<<endl;
    }
    
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    t = 1;

    while (t--) {
        solve();
    }

    return 0;
}

Code 2:
#include <bits/stdc++.h>
using namespace std;
#define int long long int
void print(vector<int> &a){
    for(auto _ : a)cerr<<_<<" ";
    cerr<<endl;
}
void incheck(){
    cerr<<"inloop"<<endl;
}
void solve() {
    int n;
    cin>>n;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int ans = 0;
    vector<pair<int,int>> res;
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            if(a[j] < a[j+1]){
                //incheck();
                res.push_back({a[j+1],a[j]});
                swap(a[j+1],a[j]);
            }
           
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            if(a[j] > a[j+1]){
                //incheck();
                res.push_back({a[j+1],a[j]});
                swap(a[j+1],a[j]);
            }
            //print(a);
        }
    }
    cout<<res.size()<<endl;
    for(auto it : res){
        cout<<it.first<<" "<<it.second<<endl;
    }
    
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;

    while (t--) {
        solve();
    }

    return 0;
}

Answer: 1
Problem: 2052A - Adrenaline Rush
Language: c++20 

Code 1:
//Date: 2024-12-25 08:35:32
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int rd() {
    int s=0,m=0;char ch=getchar();
    while(!isdigit(ch)) {if(ch=='-')m=1;ch=getchar();}
    while( isdigit(ch)) s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
    return m?-s:s;
}
bool MBE;
namespace SOLVER {
int n,a[1005];vector<pair<int,int>> ans;
void MAIN() {
    cin>>n;for(int i=1;i<=n;i++) a[i]=rd();
    for(int i=1;i<n;i++) {
        int pos=0;for(int j=i;j<=n;j++) if(a[j]==i) pos=j;
        for(int j=pos+1;j<=n;j++) ans.emplace_back(a[j-1],a[j]),swap(a[j-1],a[j]);
        for(int j=n;j>i;j--) ans.emplace_back(a[j-1],a[j]),swap(a[j-1],a[j]);
        assert(a[i]==i);
    }
    cout<<ans.size()<<endl;
    for(int i=(int)ans.size()-1;i>=0;i--) printf("%lld %lld\n",ans[i].first,ans[i].second);
}
}
bool MED;
signed main() {
    //freopen(".in","r",stdin);freopen(".out","w",stdout);
    for(int tt=1;tt;tt--) SOLVER::MAIN();
    cerr<<(&MBE-&MED)/1024<<" KB, "<<1000*clock()/CLOCKS_PER_SEC<<" ms\n";
    return 0;
}

Code 2:
//Date: 2024-12-25 08:35:32
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int rd() {
    int s=0,m=0;char ch=getchar();
    while(!isdigit(ch)) {if(ch=='-')m=1;ch=getchar();}
    while( isdigit(ch)) s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
    return m?-s:s;
}
bool MBE;
namespace SOLVER {
int n,a[1005];vector<pair<int,int>> ans;
void MAIN() {
    cin>>n;for(int i=1;i<=n;i++) a[i]=rd();
    for(int i=1;i<n;i++) {
        int pos=0;for(int j=i;j<=n;j++) if(a[j]==i) pos=j;
        for(int j=pos+1;j<=n;j++) ans.emplace_back(a[j],a[j-1]),swap(a[j-1],a[j]);
        for(int j=n;j>i;j--) ans.emplace_back(a[j],a[j-1]),swap(a[j-1],a[j]);
        assert(a[i]==i);
    }
    cout<<ans.size()<<endl;
    for(auto x:ans) printf("%lld %lld\n",x.first,x.second);
}
}
bool MED;
signed main() {
    //freopen(".in","r",stdin);freopen(".out","w",stdout);
    for(int tt=1;tt;tt--) SOLVER::MAIN();
    cerr<<(&MBE-&MED)/1024<<" KB, "<<1000*clock()/CLOCKS_PER_SEC<<" ms\n";
    return 0;
}

Answer: 1
Problem: 2052A - Adrenaline Rush
Language: c++20 

Code 1:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int x[]={0,0,-1,1};
int y[]={-1,1,0,0};
char dir[]={'L','R','U','D'};
using pi = pair<ll,ll>;

void fast() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}


void solve() {
   ll n;
    cin>>n;
    vector<ll> v(n);
    for(ll i=0;i<n;i++) {
        cin>>v[i];
    }
    vector<pi>ans;
    for(ll i=n-1;i>=0;i--) {
        for(ll j=i+1;j<n;j++) {
           ans.push_back(pi(v[i],v[j]));
            ans.push_back(pi(v[j],v[i]));
        }
    }
reverse(ans.begin(),ans.end());

cout<<ans.size()<<endl;
    for(ll i=0;i<ans.size();i++) {
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    }

}


int main() {
    fast();

    int T = 1;
 // cin >> T;
    while (T--) {
        solve();

    }
    return 0;
}


Code 2:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int x[]={0,0,-1,1};
int y[]={-1,1,0,0};
char dir[]={'L','R','U','D'};
using pi = pair<ll,ll>;

void fast() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}


void solve() {
   ll n;
    cin>>n;
    vector<pi> ans;
    map<ll,ll> vis;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        vis[x] = 1;
        for (int j = x + 1; j <= n; j++) {
            if (vis[j]) continue;
            ans.push_back({j, x});
        }
        for (int j = n; j > x; j--) {
            if (vis[j]) continue;
            ans.push_back({x, j});
        }
        for (int j = x - 1; j; j--) {
            if (vis[j]) continue;
            ans.push_back({x, j});
        }
    }
    cout << ans.size();
    for (auto &i : ans) cout << '\n' << i.first << ' ' << i.second;



}


int main() {
    fast();

    int T = 1;
 // cin >> T;
    while (T--) {
        solve();

    }
    return 0;
}


Answer: 2
Problem: 2052A - Adrenaline Rush
Language: c++20 

Code 1:
#include <iostream>
#include <vector>
using namespace std;

int n;
int c[1100];
int v[1100][1100] = {0};
int main()
{

    vector<pair<int, int>> ans;
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> c[i];
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n - i; j++)
        {
            if (c[j] > c[j + 1])
            {
                ans.push_back({c[j], c[j + 1]});
                swap(c[j + 1], c[j]);
            }
            else if (v[c[j]][c[j + 1]] == 0)
            {
                ans.push_back({c[j], c[j + 1]});
                ans.push_back({c[j + 1], c[j]});
                v[c[j]][c[j + 1]] == 1;
            }
        }

    cout << ans.size() << endl;
    for (int i = (int)ans.size() - 1; i >= 0; i--)
        cout << ans[i].first << " " << ans[i].second << endl;

    system("pause");
    return 0;
}

Code 2:
#include <iostream>
#include <vector>
using namespace std;

int n;
int c[1100];
int v[1100][1100] = {0};
int main()
{

    vector<pair<int, int>> ans;
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> c[i];
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n - i; j++)
        {
            if (c[j] < c[j + 1])
            {
                ans.push_back({c[j], c[j + 1]});
                swap(c[j + 1], c[j]);
            }
        }
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n - i; j++)
        {
            if (c[j] > c[j + 1])
            {
                ans.push_back({c[j], c[j + 1]});
                swap(c[j + 1], c[j]);
            }
        }
    cout << ans.size() << endl;
    for (int i = (int)ans.size() - 1; i >= 0; i--)
        cout << ans[i].first << " " << ans[i].second << endl;

    system("pause");
    return 0;
}

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

Code 1:
#include<iostream>
#include<math.h>
#include<unordered_set>
#include<unordered_map>
#include<list>
#include<string>
#include<limits.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<stack>
#include<set>
#include<sstream>
#include<utility>
#include<cstring>
#define int long long
using namespace std;

int cnt = 1;
void solve() {
	int n;
	cin >> n;
	int final[n];
	vector<int> cur(n);
	for (auto& e : final) {
		cin >> e;
	}
	for (int i = 0; i < n; i++) {
		cur[i] = cnt++;
	}

	cnt = 0;
	/*int overtake[n + 1][n + 1];
	for (int i = 0; i <= n; i++) {
		memset(overtake[i], 0, sizeof(overtake[i]));
	}*/
	for (int i = 0; i < n; i++) {
		int index;
		for (int j = n - 1; j >= 0; j--) {
			if (cur[j] == final[i]) {
				index = j;
				break;
			}
		}
		for (int j = index + 1; j < n; j++) {
			cout << cur[j] << ' ' << final[i] << endl;
			cnt++;
		}
		for (int j = n - 1; j > index; j--) {
			cout << final[i] << ' ' << cur[j] << endl;
			cnt++;
		}
		for (int j = index - 1; j >= i; j--) {
			cout << final[i] << ' ' << cur[j] << endl;
			cnt++;
		}
		cur.erase(cur.begin() + index);
		cur.insert(cur.begin() + i, final[i]);
	}
	cout << cnt;
}

signed main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Code 2:
#include<iostream>
#include<math.h>
#include<unordered_set>
#include<unordered_map>
#include<list>
#include<string>
#include<limits.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<stack>
#include<set>
#include<sstream>
#include<utility>
#include<cstring>
#define int long long
using namespace std;

int cnt = 1;
void solve() {
	int n;
	cin >> n;
	int final[n];
	vector<int> cur(n);
	for (auto& e : final) {
		cin >> e;
	}
	for (int i = 0; i < n; i++) {
		cur[i] = cnt++;
	}

	cnt = 0;
	vector<int> res;
	/*int overtake[n + 1][n + 1];
	for (int i = 0; i <= n; i++) {
		memset(overtake[i], 0, sizeof(overtake[i]));
	}*/
	for (int i = 0; i < n; i++) {
		int index;
		for (int j = n - 1; j >= 0; j--) {
			if (cur[j] == final[i]) {
				index = j;
				break;
			}
		}
		for (int j = index + 1; j < n; j++) {
			//cout << cur[j] << ' ' << final[i] << endl;
			res.push_back(cur[j]);
			res.push_back(final[i]);
			cnt++;
		}
		for (int j = n - 1; j > index; j--) {
			//cout << final[i] << ' ' << cur[j] << endl;
			res.push_back(final[i]);
			res.push_back(cur[j]);
			cnt++;
		}
		for (int j = index - 1; j >= i; j--) {
			//cout << final[i] << ' ' << cur[j] << endl;
			res.push_back(final[i]);
			res.push_back(cur[j]);
			cnt++;
		}
		cur.erase(cur.begin() + index);
		cur.insert(cur.begin() + i, final[i]);
	}

	cout << cnt << endl;
	for (int i = 0; i < res.size(); i += 2) {
		cout << res[i] << " " << res[i + 1] << endl;
	}
}

signed main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Answer: 2