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

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <array>
#include <stdio.h>
#include <string.h>
#include <numeric>
#include <stdlib.h>
#define int long long
#define fi first
#define se second
#define pb push_back


using namespace std;
int gcd(int a, int b) {
	while (b != 0) {
		int t = b;
		b = a % b;
		a = t;
	}
	return a;
}
int sumnum(int a) {
	string s = to_string(a);
	int ans = 0;
	for (int i = 0; i < s.size(); i++)
	{
		ans += (s[i] - '0');
	}
	return ans;
}
bool sumnum2(int a) {
	string s = to_string(a);
	if (s.size() == 1)
	{
		return false;
	}
	for (int i = 0; i < s.size() - 1; i++)
	{
		if (s[i] > s[i + 1])
		{
			return false;
		}
	}
	return true;
}
bool valid(int a, int b, vector<int>& v) {
	if (b >= v.size())
	{
		return true;
	}
	if (a <= v[b])
	{
		return true;
	}
	else
	{
		return false;
	}
}
vector<int>prmnoz;
void rozout(long long n, vector<int> &v)
{
	int j = 2;
	while ((long long)j * j <= n) {
		if (n % j == 0) {
			v.push_back(j);
			n /= j;
		}
		else ++j;
	}
	v.push_back(n);
}
int binpoisk2(int a, vector<int> v, vector<int> v1)
{
	int left = 0, right = (a / v[0] + 1)*v1[0], mid;
	while (left + 1 != right)
	{
		mid = (left + right) / 2;
		int damage = 0;
		for (int i = 0; i < v.size(); i++)
		{
			damage += ((mid - 1) / v1[i] + 1) * v[i];
			if (damage >= a)
			{
				break;
			}
		}
		if (damage < a)
		{
			left = mid;
		}
		else
		{
			right = mid;
		}
	}
	return right;
}
int newpow(int a, int b)
{
	if (b == 0)
	{
		return 1;
	}
	if (b % 2 == 0)
	{
		int c = newpow(a, b / 2)%1000000007;
		return (c*c)%1000000007;
	}
	else
	{
		int c = newpow(a, (b - 1) / 2)%1000000007;
		return (((c*c)%1000000007)*a)%1000000007;
	}
}
string iz10v2(int o)
{
	string ans;
	for (int i=0; i<32; i++)
	{
		if (o % 2 == 0)
		{
			ans += '0';
			o /= 2;
		}
		else
		{
			ans += '1';
			o /= 2;
		}
	}
    //for (int i = 0; i < ans.size() / 2; i++)
	//{
	//	swap(ans[i], ans[ans.size() - 1 - i]);
	//}
	return ans;
}
int iz2v10(string o)
{
	int ans = 0;
	for (int i = 0; i < o.size(); i++)
	{
		if (o[i] == '1')
		{
			ans += newpow(2, o.size() - 1 - i);
		}
	}
	return ans;
}
bool y(pair<int,pair<int,string>> a,pair<int,pair<int,string>> b)
{
    if(a.first<b.first)return false;
    if(a.first==b.first)
    {
        if(a.second.first>b.second.first)return false;
    }
    if(a.first==b.first && a.second.first==b.second.first)
    {
        if(a.second.second>b.second.second)return false;
    }
    return true;
}



int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	ofstream fout("number.txt");
	int a,ans=0;
	cin>>a;
	vector<int> v(a);
	vector<pair<int,int>> n;
	map<pair<int,int>,int> m;
	for(int i=0; i<a; i++)
    {
        cin>>v[i];
    }
    for(int i=0; i<a; i++)
    {
        for(int j=0; j<a-1; j++)
        {
            if(v[j]<v[j+1] && m[make_pair(v[j],v[j+1])]+m[make_pair(v[j+1],v[j])]==0)
            {
                ans+=2;
                n.push_back(make_pair(v[j],v[j+1]));
                n.push_back(make_pair(v[j+1],v[j]));
                m[make_pair(v[j],v[j+1])]+=2;
            }
            else if(m[make_pair(v[j+1],v[j])]+m[make_pair(v[j],v[j+1])]<2 && v[j]>v[j+1])
            {
                n.pb(make_pair(v[j],v[j+1]));
                swap(v[j],v[j+1]);
                m[make_pair(v[j],v[j+1])]+=1;
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    for(int i=0; i<ans; i++)
    {
        cout<<n[i].first<<' '<<n[i].second<<'\n';
    }
    return 0;
}


Submission (verdict: Wrong answer on test 4):
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <array>
#include <stdio.h>
#include <string.h>
#include <numeric>
#include <stdlib.h>
#define int long long
#define fi first
#define se second
#define pb push_back


using namespace std;
int gcd(int a, int b) {
	while (b != 0) {
		int t = b;
		b = a % b;
		a = t;
	}
	return a;
}
int sumnum(int a) {
	string s = to_string(a);
	int ans = 0;
	for (int i = 0; i < s.size(); i++)
	{
		ans += (s[i] - '0');
	}
	return ans;
}
bool sumnum2(int a) {
	string s = to_string(a);
	if (s.size() == 1)
	{
		return false;
	}
	for (int i = 0; i < s.size() - 1; i++)
	{
		if (s[i] > s[i + 1])
		{
			return false;
		}
	}
	return true;
}
bool valid(int a, int b, vector<int>& v) {
	if (b >= v.size())
	{
		return true;
	}
	if (a <= v[b])
	{
		return true;
	}
	else
	{
		return false;
	}
}
vector<int>prmnoz;
void rozout(long long n, vector<int> &v)
{
	int j = 2;
	while ((long long)j * j <= n) {
		if (n % j == 0) {
			v.push_back(j);
			n /= j;
		}
		else ++j;
	}
	v.push_back(n);
}
int binpoisk2(int a, vector<int> v, vector<int> v1)
{
	int left = 0, right = (a / v[0] + 1)*v1[0], mid;
	while (left + 1 != right)
	{
		mid = (left + right) / 2;
		int damage = 0;
		for (int i = 0; i < v.size(); i++)
		{
			damage += ((mid - 1) / v1[i] + 1) * v[i];
			if (damage >= a)
			{
				break;
			}
		}
		if (damage < a)
		{
			left = mid;
		}
		else
		{
			right = mid;
		}
	}
	return right;
}
int newpow(int a, int b)
{
	if (b == 0)
	{
		return 1;
	}
	if (b % 2 == 0)
	{
		int c = newpow(a, b / 2)%1000000007;
		return (c*c)%1000000007;
	}
	else
	{
		int c = newpow(a, (b - 1) / 2)%1000000007;
		return (((c*c)%1000000007)*a)%1000000007;
	}
}
string iz10v2(int o)
{
	string ans;
	for (int i=0; i<32; i++)
	{
		if (o % 2 == 0)
		{
			ans += '0';
			o /= 2;
		}
		else
		{
			ans += '1';
			o /= 2;
		}
	}
    //for (int i = 0; i < ans.size() / 2; i++)
	//{
	//	swap(ans[i], ans[ans.size() - 1 - i]);
	//}
	return ans;
}
int iz2v10(string o)
{
	int ans = 0;
	for (int i = 0; i < o.size(); i++)
	{
		if (o[i] == '1')
		{
			ans += newpow(2, o.size() - 1 - i);
		}
	}
	return ans;
}
bool y(pair<int,pair<int,string>> a,pair<int,pair<int,string>> b)
{
    if(a.first<b.first)return false;
    if(a.first==b.first)
    {
        if(a.second.first>b.second.first)return false;
    }
    if(a.first==b.first && a.second.first==b.second.first)
    {
        if(a.second.second>b.second.second)return false;
    }
    return true;
}



int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	ofstream fout("number.txt");
	int a,ans=0;
	cin>>a;
	vector<int> v(a);
	vector<pair<int,int>> n;
	map<pair<int,int>,int> m;
	for(int i=0; i<a; i++)
    {
        cin>>v[i];
    }
    for(int i=0; i<a; i++)
    {
        for(int j=0; j<a-1; j++)
        {
            if(v[j]<v[j+1] && m[make_pair(v[j],v[j+1])]+m[make_pair(v[j+1],v[j])]==0)
            {
                ans+=2;
                n.push_back(make_pair(v[j],v[j+1]));
                n.push_back(make_pair(v[j+1],v[j]));
                m[make_pair(v[j],v[j+1])]+=2;
            }
            else if(m[make_pair(v[j+1],v[j])]+m[make_pair(v[j],v[j+1])]<2 && v[j]>v[j+1])
            {
                n.pb(make_pair(v[j],v[j+1]));
                swap(v[j],v[j+1]);
                m[make_pair(v[j],v[j+1])]+=1;
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    for(int i=ans-1; i>=0; i--)
    {
        cout<<n[i].fi<<' '<<n[i].se<<'\n';
    }
    return 0;
}