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

Code 1:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N = 1002, M = 2e5 + 9, mod = 998244353, inf = 1e9;  
void solve() { 
    int n;
    cin >> n;
    vector<int> v(n), pos(n + 1);
    for(int i = 0; i < n; i++) {
        cin >> v[i];
        pos[v[i]] = i;
    }
    vector<pair<int, int>> vec;
    for(int i = 1; i <= n; i++) {
        for(int j = pos[i] - 1; j >= 0; j--) {
            if(v[j] > i) {
                vec.push_back({v[j], i});
            }
            else {
                vec.push_back({i, v[j]});
                vec.push_back({v[j], i});
            }
        }
    }
    cout << vec.size() << "\n";
    for(auto [x, y] : vec) {
        cout << x << " " << y << "\n";
    }
}          
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t = 1, cs = 1;  
    //cin >> t;
    while (t--) {
        //cout << "Case " << cs++ << ": ";
        solve();
    }
    return 0;
}


Code 2:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N = 1002, M = 2e5 + 9, mod = 998244353, inf = 1e9;  
void solve() { 
    int n;
    cin >> n;
    vector<int> v(n), ans(n + 1);
    for(int i = 0; i < n; i++) {
        cin >> v[i];
        ans[i] = i + 1;
    }
    vector<pair<int, int>> vec;
    for(int i = n - 1; i >= 0; i--) {
        int val = v[i], pos = 0;
        for(int j = 0; j < n; j++) {
            if(ans[j] == val) {
                pos = j;
                break;
            }
        }
        for(int j = pos - 1; j >= 0; j--) {
            vec.push_back({val, ans[j]});
        }
        for(int j = 0; j < pos; j++) {
            vec.push_back({ans[j], val});
        }
        for(int j = pos + 1; j <= i; j++) {
            vec.push_back({ans[j], ans[j - 1]});
            swap(ans[j], ans[j - 1]);
        }
    }
    cout << vec.size() << "\n";
    for(auto [x, y] : vec) {
        cout << x << " " << y << "\n";
    }
}          
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t = 1, cs = 1;  
    //cin >> t;
    while (t--) {
        //cout << "Case " << cs++ << ": ";
        solve();
    }
    return 0;
}


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

Code 1:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'

void solve()
{
    ll n,val,pos;cin>>n;
    vector <ll> v(n),p(n);
    vector <pair<ll,ll>> vp;

    for(auto &i:v) cin>>i;
    iota(p.begin(),p.end(),1);
    
    for(int i=n-1;i>=0;i--){
        val=v[i];
        for(int j=0;j<n;j++){
            if(val==p[j]){
                pos=j;
                break;
            }
        }
        for(int j=pos-1;j>=0;j--){
            vp.push_back({p[j],val});
            swap(p[j],p[j+1]);
        }
        for(int j=0;j<i;j++){
            vp.push_back({p[j],p[j+1]});
            swap(p[j],p[j+1]);
        }
    }

    cout<<vp.size()<<endl;
    for(auto i:vp){
        cout<<i.first<<" "<<i.second<<endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

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


Code 2:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'

void solve()
{
    ll n,val,pos;cin>>n;
    vector <ll> v(n),p(n);
    vector <pair<ll,ll>> vp;

    for(auto &i:v) cin>>i;
    iota(p.begin(),p.end(),1);
    
    for(int i=n-1;i>=0;i--){
        val=v[i];
        for(int j=0;j<n;j++){
            if(val==p[j]){
                pos=j;
                break;
            }
        }
        for(int j=pos-1;j>=0;j--){
            vp.push_back({val,p[j]});
            swap(p[j],p[j+1]);
        }
        for(int j=0;j<i;j++){
            vp.push_back({p[j+1],p[j]});
            swap(p[j],p[j+1]);
        }
    }

    cout<<vp.size()<<endl;
    for(auto i:vp){
        cout<<i.first<<" "<<i.second<<endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

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


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

Code 1:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
ll i,j,k,t,n,m;
struct pxy
{
	ll x,y;
};
int main()
{
	cin>>n;
	ll a[n+10],b[n+10];
	map<ll,ll>vv;
	for(i=1;i<=n;i++)cin>>a[i],b[i]=i,vv[b[i]]=i;
	pxy c[2000000];
	ll q=0;
	for(i=n;i>=1;i--)
	{
			for(j=vv[a[i]];j>1;j--)
			{
				c[++q].x=b[j],c[q].y=b[j-1];
				vv[b[j]]=j-1;
				vv[b[j-1]]=j;
				swap(b[j],b[j-1]);
			}
			for(j=1;j<i;j++)
			{
				c[++q].x=b[j+1],c[q].y=b[j];
				vv[b[j]]=j+1;
				vv[b[j+1]]=j;
				swap(b[j],b[j+1]);
			}
	}
	cout<<q<<'\n';
	for(i=1;i<=q;i++)
	{
		cout<<c[i].x<<' '<<c[i].y<<'\n';
	}
}

Code 2:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
ll i,j,k,t,n,m;
struct pxy
{
	ll x,y;
};
int main()
{
	cin>>n;
	ll a[n+10],b[n+10];
	map<ll,ll>vv;
	for(i=1;i<=n;i++)cin>>a[i],b[i]=i,vv[b[i]]=i;
	pxy c[100000];
	ll q=0;
	for(i=n;i>=n;i--)
	{
			for(j=vv[b[i]];j>1;j--)
			{
				c[++q].x=b[j],c[q].y=b[j-1];
				vv[b[j]]=j-1;
				vv[b[j-1]]=j;
				swap(b[j],b[j-1]);
			}
			for(j=1;j<i;j++)
			{
				c[++q].x=b[j+1],c[q].y=b[j];
				vv[b[j]]=j+1;
				vv[b[j+1]]=j;
				swap(b[j],b[j+1]);
			}
	}
	cout<<q<<'\n';
	for(i=1;i<=q;i++)
	{
		cout<<c[i].x<<' '<<c[i].y<<'\n';
	}
}

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

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

mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());

const int INF = 1e18;

void Solve() 
{
	int n;
	cin >> n;
	vector<int> a(n + 1), pos(n + 1);
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		pos[a[i]] = i;
	}
	vector<pair<int, int> > overtakes;
	vector<int> current_positioning;
	current_positioning.push_back(1);
	for(int i = 2; i <= n; i++) {
		for(int j = current_positioning.size() - 1; j >= 0; j--) {
			overtakes.push_back({i, current_positioning[j]});
		}
		for(int j = 0; j < current_positioning.size(); j++) {
			if(pos[current_positioning[j]] < pos[i]) {
				overtakes.push_back({current_positioning[j], i});
			}
			else {
				current_positioning.insert(current_positioning.begin() + j, i);
				break;
			}
		}

		if(current_positioning.size() == i - 1) {
			current_positioning.push_back(i);
		}

		// for(int j = 0; j < current_positioning.size(); j++) {
		// 	cout << current_positioning[j] << " ";
		// }
		// cout << "\n";
	}

	// for(int i = 0; i < n; i++) {
	// 	for(int j = i + 1; j < n; j++) {
	// 		if(a[i] < a[j]) {
	// 			overtakes.push_back({a[j], a[i]});
	// 			overtakes.push_back({a[i], a[j]});
	// 		}
	// 		else {
	// 			overtakes.push_back({a[i], a[j]});
	// 		}
	// 	}
	// }
	
	cout << overtakes.size() << "\n";
	for(auto p: overtakes) {
		cout << p.first << " " << p.second << "\n";
	}
}

int32_t main() 
{
	auto begin = std::chrono::high_resolution_clock::now();
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	// cin >> t;
	for(int i = 1; i <= t; i++) 
	{
		//cout << "Case #" << i << ": ";
		Solve();
	}
	auto end = std::chrono::high_resolution_clock::now();
    auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
    //cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n"; 
	return 0;
}

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

mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());

const int INF = 1e18;

void Solve() 
{
	int n;
	cin >> n;
	vector<int> a(n);
	for(int &x: a) {
		cin >> x;
	}
	vector<pair<int, int> > overtakes;
	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n; j++) {
			if(a[i] < a[j]) {
				overtakes.push_back({a[j], a[i]});
				overtakes.push_back({a[i], a[j]});
			}
			else {
				overtakes.push_back({a[i], a[j]});
			}
		}
	}
	
	cout << overtakes.size() << "\n";
	for(auto p: overtakes) {
		cout << p.first << " " << p.second << "\n";
	}
}

int32_t main() 
{
	auto begin = std::chrono::high_resolution_clock::now();
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	// cin >> t;
	for(int i = 1; i <= t; i++) 
	{
		//cout << "Case #" << i << ": ";
		Solve();
	}
	auto end = std::chrono::high_resolution_clock::now();
    auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
    //cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n"; 
	return 0;
}

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

Code 1:
#include <bits/stdc++.h>
using namespace std;
#define f(i, a) for(ll (i) = 0; (i)<(a) ;(i)++)
#define r(i, a) for (ll (i) = a-1; (i)>=0 ;(i)--)
#define F(i, a, b) for(ll (i) = (a); (i)<(b) ;(i)++)
#define R(i, a, b) for (ll (i) = (b)-1; (i)>=(a) ;(i)--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ll long long int


void sol(){
    ll n;
    cin>>n;
    ll a[n+1] = {0};
    ll c[n];
    ll b[n];
    f(i, n) {cin>>b[i]; c[i] = i+1;}
    vector<pair<ll, ll>> v;
    r(i, n){
        ll vic = b[i];
        a[vic] = 1;
        ll j=0;
        f(k, n){if(c[k]==vic){j=k;break;}}
        while(j>0){
            j--;
            v.pb({c[j+1], c[j]});
            swap(c[j], c[j+1]);
        }
        while(j<i){
            v.pb({c[j+1], c[j]});
            swap(c[j], c[j+1]);
            j++;
        }

        

    }
    cout<<v.size()<<endl;
    for(auto k : v){
        cout<<k.first<<" "<<k.second<<endl;
    }
 
}

int main(){

 //#ifndef ONLINE_JUDGE
 //freopen("input.txt", "r", stdin);
 //freopen("output.txt", "w", stdout);
 //#endif
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 ll T;
//  cin>>T; while(T--)
        {
     sol();
        }
}

Code 2:
#include <bits/stdc++.h>
using namespace std;
#define f(i, a) for(ll (i) = 0; (i)<(a) ;(i)++)
#define r(i, a) for (ll (i) = a-1; (i)>=0 ;(i)--)
#define F(i, a, b) for(ll (i) = (a); (i)<(b) ;(i)++)
#define R(i, a, b) for (ll (i) = (b)-1; (i)>=(a) ;(i)--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ll long long int


void sol(){
    ll n;
    cin>>n;
    ll a[n+1] = {0};
    ll b[n];
    f(i, n) cin>>b[i];
    vector<pair<ll, ll>> v;
    r(i, n){
        ll vic = b[i];
        a[vic] = 1;
        ll j = vic-1;
        while(j>0){
            // cout<<vic<<" - "<<j<<endl;
            if(a[j]==0) 
            v.pb({vic, j});
            j--;
        }
        j++;
        while(j<=i+1){
            // cout<<vic<<" + "<<j<<endl;

            if(a[j]==0) 
            v.pb({j, vic});
            j++;
        }

    }
    cout<<v.size()<<endl;
    for(auto k : v){
        cout<<k.first<<" "<<k.second<<endl;
    }
 
}

int main(){

 //#ifndef ONLINE_JUDGE
 //freopen("input.txt", "r", stdin);
 //freopen("output.txt", "w", stdout);
 //#endif
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 ll T;
//  cin>>T; while(T--)
        {
     sol();
        }
}

Answer: 1
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 = 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;
}



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;
	for(int i = 1;i <= n;i ++) {
		cin >> a[i];
	}
	
	vector<pii> ans;
	
	for(int i = n;i >= 1;i --) {
		if(a[i] < i) {
			for(int j = a[i] + 1;j <= i;j ++) {
				ans.push_back({j, a[i]});
			}
		} else {
			if(i == 1) break;
			ans.push_back({a[i], a[i - 1]});
			ans.push_back({a[i - 1], 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: 1
Problem: 2052A - Adrenaline Rush
Language: c++17 

Code 1:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef long double ld;
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;
#define all(x) x.begin(), x.end()
#define pll pair<ll, ll>
#define vec vector
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
const ll mod = 998244353;
ll fpow(ll a, ll b, ll m = -1)
{
	if (m != -1)
		a %= m;
	ll res = 1;
	while (b > 0)
	{
		if (b % 2 == 1)
		{
			if (m != -1)
				res = res * a % m;
			else
			{
				res *= a;
			}
		}
		a = a * a;
		if (m != -1)
		{
			a %= m;
		}
		b /= 2;
	}
	return res;
}
int main()
{
	fast;
	// freopen("pails.in", "r", stdin);
	// freopen("pails.out", "w", stdout);
	ll t = 1;
	// cin >> t;
end:;
	while (t--)
	{
		ll n, k;
		cin >> n;
		vec<ll> v(n);
		for (int i = 0; i < n; i++)
		{
			cin >> v[i];
		}
		set<ll> st;
		ll mx = 0;
		vec<pll> ans;
		for (int i = 0; i < n; i++)
		{
			for(int j = i - 1; j >= 0; j--)
			{
				swap(v[j+1], v[j]);
				ans.push_back({v[j+1], v[j]});
			}
			ll in = 0;
			while(in < i && v[in]> v[in+1])
			{
				swap(v[in], v[in+1]);
				ans.push_back({v[in+1], v[in]});
				in++;
			}
		}
		reverse(all(ans));
		cout << ans.size() << '\n';
		for (int i = 0; i < ans.size(); i++)
		{
			cout << ans[i].first << ' ' << ans[i].second << '\n';
		}
		
	}
	return 0;
}

Code 2:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef long double ld;
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;
#define all(x) x.begin(), x.end()
#define pll pair<ll, ll>
#define vec vector
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
const ll mod = 998244353;
ll fpow(ll a, ll b, ll m = -1)
{
	if (m != -1)
		a %= m;
	ll res = 1;
	while (b > 0)
	{
		if (b % 2 == 1)
		{
			if (m != -1)
				res = res * a % m;
			else
			{
				res *= a;
			}
		}
		a = a * a;
		if (m != -1)
		{
			a %= m;
		}
		b /= 2;
	}
	return res;
}
int main()
{
	fast;
	// freopen("pails.in", "r", stdin);
	// freopen("pails.out", "w", stdout);
	ll t = 1;
	// cin >> t;
end:;
	while (t--)
	{
		ll n, k;
		cin >> n;
		vec<ll> v(n);
		for (int i = 0; i < n; i++)
		{
			cin >> v[i];
		}
		set<ll> st;
		ll mx = 0;
		vec<pll> ans;
		for (int i = 0; i < n; i++)
		{
			for(int j = i - 1; j >= 0; j--)
			{
				swap(v[j+1], v[j]);
				ans.push_back({v[j+1], v[j]});
			}
			ll in = 0;
			while(in < i && v[in]> v[in+1])
			{
				swap(v[in], v[in+1]);
				ans.push_back({v[in+1], v[in]});
			}
		}
		reverse(all(ans));
		cout << ans.size() << '\n';
		for (int i = 0; i < ans.size(); i++)
		{
			cout << ans[i].first << ' ' << ans[i].second << '\n';
		}
		
	}
	return 0;
}

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

Code 1:
#include <iostream>
#include <algorithm>

using namespace std;

int a[1005], cur[1005], ans[1000005], ans1[1000005];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    
    for(int i = 1; i <= n; i++){
        cur[i] = i;
    }
    for(int i = n; i >= 2; i--){
        int pos = 0;
        for(int j = 1; j <= n; j++){
            if(cur[j] == a[i]){
                pos = j;
                break;
            }
        }
        for(int j = pos; j >= 2; j--){
            cnt++;
            ans[cnt] = cur[j];
            ans1[cnt] = cur[j - 1];
            swap(cur[j], cur[j - 1]);
        }
        for(int j = 1; j <= i - 1; j++){
            cnt++;
            ans[cnt] = cur[j + 1];
            ans1[cnt] = cur[j];
            swap(cur[j], cur[j + 1]);
        }
    }
    
    cout << cnt << "\n";
    for(int i = 1; i <= cnt; i++){
        cout << ans[i] << " " << ans1[i] << "\n";
    }
    return 0;
}

Code 2:
#include <iostream>
#include <algorithm>

using namespace std;

int a[1005], cur[1005], ans[1005], ans1[1005];

int main(){
    int n;
    cin >> n;
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    
    for(int i = 1; i <= n; i++){
        cur[i] = i;
    }
    for(int i = n; i >= 2; i--){
        int pos = 0;
        for(int j = 1; j <= n; j++){
            if(cur[j] == a[i]){
                pos = j;
                break;
            }
        }
        for(int j = pos; j >= 2; j--){
            cnt++;
            ans[cnt] = cur[j];
            ans1[cnt] = cur[j - 1];
            swap(cur[j], cur[j - 1]);
        }
        for(int j = 1; j <= i - 1; j++){
            cnt++;
            ans[cnt] = cur[j + 1];
            ans1[cnt] = cur[j];
            swap(cur[j], cur[j + 1]);
        }
    }
    
    cout << cnt << "\n";
    for(int i = 1; i <= cnt; i++){
        cout << ans[i] << " " << ans1[i] << "\n";
    }
    return 0;
}

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

Code 1:
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef vector<int> ve;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vp;
typedef vector<char> vc;
typedef vector<double> vd;
#define fi first
#define se second
#define pb push_back
#define con continue 
#define rep(i,a,b) for (int i=a;i<b;i++)
#define res(j,a,b) for (int j=a;j>=b;j--)
const double eps = 1e-6;
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define endl "\n"
signed main()
{
    fastio;
        int n;
        cin>>n;
        ve v(n);
        stack<int>a,b;
        rep(i,0,n){
        cin>>v[i];
        a.push(n-i);
        }
        if(n==1){
        cout<<"0"<<endl;
        }
        else{
        vp ans;
        res(j,n-1,0){
            while(a.top()!=v[j]){
               b.push(a.top());
               a.pop();
            }
            a.pop();
            while(!b.empty()){
                ans.pb({v[j],b.top()});
                a.push(b.top());
                b.pop();
            }
            a.push(v[j]);
        }
        cout<<ans.size()<<endl;
        for(auto k:ans)
        cout<<k.fi<<" "<<k.se<<endl;
    }
        return 0;
    }
    

Code 2:
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef vector<int> ve;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vp;
typedef vector<char> vc;
typedef vector<double> vd;
#define fi first
#define se second
#define pb push_back
#define con continue 
#define rep(i,a,b) for (int i=a;i<b;i++)
#define res(j,a,b) for (int j=a;j>=b;j--)
const double eps = 1e-6;
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define endl "\n"
signed main()
{
    fastio;
        int n;
        cin>>n;
        ve v(n);
        stack<int>a,b;
        rep(i,0,n){
        cin>>v[i];
        a.push(n-i);
        }
        res(j,n-1,0){
            while(a.top()!=v[j]){
               cout<<v[j]<<" "<<a.top()<<endl;
               b.push(a.top());
               a.pop();
            }
            a.pop();
            while(!b.empty()){
                a.push(b.top());
                b.pop();
            }
            a.push(v[j]);
        }
        return 0;
    }
    

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

Code 1:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define vpll vector<pair<long long,long long>>
#define fl(n) for (ll i=0; i < n; i++)
#define st(v) sort(v.begin(),v.end())
#define pb push_back

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll t;
 t=1;

    
    while (t--) {
        ll n;  cin >> n;
       vll v(n);
       fl(n)cin>>v[i];
       vpll ans;
       for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            // ans.pb(make_pair(v[i],v[j]));
            if(v[i]<v[j]){
                ans.pb(make_pair(v[j],v[i]));
            }
            ans.pb(make_pair(v[i],v[j]));

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



    }
    return 0;
}


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

#define ll long long
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define fl(n) for (ll i=0; i < n; i++)
#define st(v) sort(v.begin(),v.end())
#define pb push_back
#define el '\n'
#define mod 998244353

ll mod_inverse(ll a,ll m) {
    ll res=1,p=m - 2;
    while (p > 0) {
        if (p & 1) res=(res * a)%m;
        a=(a * a)%m;
        p >>= 1;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    while (t--) {
        int n;cin>>n;vll v(n);fl(n){cin>>v[i];} vpll ans;
        vll x(n);fl(n){x[i]=i+1;}
        for(int i=n-1;i>=0;i--){
           
            bool found=false;int a;
            for(int j=n-1;j>=0;j--){
                 if(found){
                    // cout<<v[i]<<" "<<x[j]<<endl;
                    ans.pb(make_pair(v[i],x[j]));
                 }
                 if(x[j]==v[i]&& !found){found=true;a=j;}
            }
            
          x.erase(x.begin()+a);
          x.insert(x.begin(),v[i]);
           

            }
            cout<<ans.size()<<endl;
            fl(ans.size()){cout<<ans[i].first<<" "<<ans[i].second<<endl;}

        }
      
    
    return 0;
}

Answer: 2