ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <string>

void solve() 
{
	std::string n;
	std::cin >> n;

	int sum = 0;
	int twos = 0, threes = 0;
	for (int i = 0; i < n.size(); i++) {
		sum += n[i] - '0';	
		if (n[i] == '2') ++twos;
		if (n[i] == '3') ++threes;
	}

	int tmp1 = twos, tmp2 = threes;
	
	int add1 = 0;
	while ((sum + add1) % 9 != 0 && threes--)
		add1 += 6;
	while ((sum + add1) % 9 != 0 && twos--) 
		add1 += 2;
	
	twos = tmp1, threes = tmp2;
	
	int add2 = 0;
	while ((sum + add2) % 9 != 0 && twos--)
		add2 += 2;
	while ((sum + add2) % 9 != 0 && threes--) 
		add2 += 6;
	
	std::cout << (((sum + add1) % 9) && ((sum + add2) % 9) ? "NO" : "YES") << std::endl;
}

int main() 
{
	std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.tie(0);

	int t = 1; 
	std::cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <string>

void solve() 
{
	std::string n;
	std::cin >> n;

	int sum = 0;
	int twos = 0, threes = 0;
	for (int i = 0; i < n.size(); i++) {
		sum += n[i] - '0';	
		if (n[i] == '2') ++twos;
		if (n[i] == '3') ++threes;
	}

	int tmp1 = twos, tmp2 = threes;
	
	int add1 = 0;
	while ((sum + add1) % 9 != 0 && threes--)
		add1 += 6;
	while ((sum + add1) % 9 != 0 && twos--) 
		add1 += 2;
	
	twos = tmp1, threes = tmp2;
	
	int add2 = 0;
	while ((sum + add2) % 9 != 0 && twos--)
		add2 += 2;
	while ((sum + add2) % 9 != 0 && threes--) 
		add2 += 6;

	if ((sum + add1) % 9 == 0)
		std::cout << "YES" << std::endl;
	else if ((sum + add2) % 9 == 0)
		std::cout << "YES" << std::endl;
	else 
		std::cout << "NO" << std::endl;
	
	//std::cout << (((sum + add1) % 9) && ((sum + add2) % 9) ? "NO" : "YES") << std::endl;
}

int main() 
{
	std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.tie(0);

	int t = 1; 
	std::cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <string>

void solve() 
{
	std::string n;
	std::cin >> n;

	int sum = 0;
	int twos = 0, threes = 0;
	for (int i = 0; i < n.size(); i++) {
		sum += n[i] - '0';	
		if (n[i] == '2') ++twos;
		if (n[i] == '3') ++threes;
	}

	int tmp1 = twos, tmp2 = threes;
	
	int add1 = 0;
	while ((sum + add1) % 9 != 0 && threes--)
		add1 += 6;
	while ((sum + add1) % 9 != 0 && twos--) 
		add1 += 2;
	
	twos = tmp1, threes = tmp2;
	
	int add2 = 0;
	while ((sum + add2) % 9 != 0 && twos--)
		add2 += 2;
	while ((sum + add2) % 9 != 0 && threes--) 
		add2 += 6;
	
	std::cout << (((sum + add1) % 9) && ((sum + add2) % 9) ? "NO" : "YES") << std::endl;
}

int main() 
{
	std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.tie(0);

	int t = 1; 
	std::cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <string>

void solve() 
{
	std::string n;
	std::cin >> n;

	int sum = 0;
	int twos = 0, threes = 0;
	for (int i = 0; i < n.size(); i++) {
		sum += n[i] - '0';	
		if (n[i] == '2') ++twos;
		if (n[i] == '3') ++threes;
	}

	int tmp1 = twos, tmp2 = threes;
	
	int add1 = 0;
	while ((sum + add1) % 9 != 0 && threes--)
		add1 += 6;
	while ((sum + add1) % 9 != 0 && twos--) 
		add1 += 2;
	
	twos = tmp1, threes = tmp2;
	
	int add2 = 0;
	while ((sum + add2) % 9 != 0 && twos--)
		add2 += 2;
	while ((sum + add2) % 9 != 0 && threes--) 
		add2 += 6;

	if ((sum + add1) % 9 == 0)
		std::cout << "YES" << std::endl;
	else if ((sum + add2) % 9 == 0)
		std::cout << "YES" << std::endl;
	else 
		std::cout << "NO" << std::endl;
	
	//std::cout << (((sum + add1) % 9) && ((sum + add2) % 9) ? "NO" : "YES") << std::endl;
}

int main() 
{
	std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.tie(0);

	int t = 1; 
	std::cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}


Submission (verdict: Accepted):
#include <iostream>
#include <string>

void solve() 
{
	std::string n;
	std::cin >> n;

	int sum = 0;
	int twos = 0, threes = 0;
	for (int i = 0; i < n.size(); i++) {
		sum += n[i] - '0';	
		if (n[i] == '2') ++twos;
		if (n[i] == '3') ++threes;
	}

	for (int i = 0; i <= (twos < 8 ? twos : 8); i++) {
		for (int j = 0; j <= (threes < 8 ? threes : 8); j++) {
			if ((sum + i * 2 + j * 6) % 9 == 0) {
				std::cout << "YES\n";
				return;
			}
		}
	}
	std::cout << "NO\n";
}

int main() 
{
	std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.tie(0);

	int t = 1; 
	std::cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
#include<unordered_map>
#include <random>
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3fLL
#define int long long
#define pb push_back
#define PII pair<int,int>
#define ls p<<1
#define rs p<<1|1
#define f(x,y,z) for(int x=(y);x<=(z);++x)
#define umap unordered_map
#define vi vector<int>
#define vii vector<pair<int,int>>
using namespace std;

void init() {
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(0);
}
bool cmp2(PII a, PII b) { return a.fi > b.fi; }

const int N = (1<<20) + 10;
//--------------分割线---------------

int c[N], s[N],sw[N],ans[N];
int n, m, k;
//8
 
void solve() {
    cin >> n;
    f(i, 1, n) {
        cin >> m;
        c[m] = i;
    }
    vii v;
    f(i, 1, n-1) {
        f(j, i + 1, n) {
            if (c[i] < c[j]) {
                k += 2;
                v.pb({ j,i });
                v.pb({ i,j });
            }
            else {
                k += 1;
                v.pb({ j,i });
            }
        }
    }
    cout << v.size() << endl;
    for (auto x : v) {
        cout << x.first << " " << x.second << endl;
    }

}
signed main() {
    init();
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
        //  cout << endl;
    }
}


//反思的目标：过段时间重看一遍、下次碰到类似题目或技巧能写得出来（抓本质）
//为什么我没想到？赛时怎么想才能出题？
//一句话概括



Submission (verdict: Wrong answer on test 7):
#include <bits/stdc++.h>
#include<unordered_map>
#include <random>
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3fLL
#define int long long
#define pb push_back
#define PII pair<int,int>
#define ls p<<1
#define rs p<<1|1
#define f(x,y,z) for(int x=(y);x<=(z);++x)
#define umap unordered_map
#define vi vector<int>
#define vii vector<pair<int,int>>
using namespace std;

void init() {
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(0);
}
bool cmp2(PII a, PII b) { return a.fi > b.fi; }

const int N = (1<<20) + 10;
//--------------分割线---------------

int c[N], s[N],sw[N],ans[N];
int n, m, k;
//8
 
void solve() {
    cin >> n;
    f(i, 1, n) {
        cin >> m;
        c[m] = i;
    }
    vii v;
    f(i, 1, n) {
        f(j, i + 1, n)v.pb({j,i});
        f(j, 1, i - 1) {
            if (c[j] <= c[i])v.pb({ j,i });
        }
    }
    cout << v.size() << endl;
    for (auto x : v) {
        cout << x.first << " " << x.second << endl;
    }

}
signed main() {
    init();
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
        //  cout << endl;
    }
}


//反思的目标：过段时间重看一遍、下次碰到类似题目或技巧能写得出来（抓本质）
//为什么我没想到？赛时怎么想才能出题？
//一句话概括
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 7):
#include <bits/stdc++.h>
#include<unordered_map>
#include <random>
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3fLL
#define int long long
#define pb push_back
#define PII pair<int,int>
#define ls p<<1
#define rs p<<1|1
#define f(x,y,z) for(int x=(y);x<=(z);++x)
#define umap unordered_map
#define vi vector<int>
#define vii vector<pair<int,int>>
using namespace std;

void init() {
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(0);
}
bool cmp2(PII a, PII b) { return a.fi > b.fi; }

const int N = (1<<20) + 10;
//--------------分割线---------------

int c[N], s[N],sw[N],ans[N];
int n, m, k;
//8
 
void solve() {
    cin >> n;
    f(i, 1, n) {
        cin >> m;
        c[m] = i;
    }
    vii v;
    f(i, 1, n) {
        f(j, i + 1, n)v.pb({j,i});
        f(j, 1, i - 1) {
            if (c[j] <= c[i])v.pb({ j,i });
        }
    }
    cout << v.size() << endl;
    for (auto x : v) {
        cout << x.first << " " << x.second << endl;
    }

}
signed main() {
    init();
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
        //  cout << endl;
    }
}


//反思的目标：过段时间重看一遍、下次碰到类似题目或技巧能写得出来（抓本质）
//为什么我没想到？赛时怎么想才能出题？
//一句话概括



Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#include<unordered_map>
#include <random>
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3fLL
#define int long long
#define pb push_back
#define PII pair<int,int>
#define ls p<<1
#define rs p<<1|1
#define f(x,y,z) for(int x=(y);x<=(z);++x)
#define umap unordered_map
#define vi vector<int>
#define vii vector<pair<int,int>>
using namespace std;

void init() {
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(0);
}
bool cmp2(PII a, PII b) { return a.fi > b.fi; }

const int N = (1<<20) + 10;
//--------------分割线---------------

int c[N], a[N],sw[N],ans[N];
int n, m, k;
//8
 
void solve() {
    cin >> n;
    f(i, 1, n)a[i] = i;
    f(i, 1, n) {
        cin >> m;
        c[m] = i;
    }
    vii v;
    f(i, 1, n) {
        f(j, 1, n-i) { v.pb({ a[j+1],a[j]}); swap(a[j+1], a[j]); }
        f(j, n-i+2, n) {
            if (c[a[j]] <= c[a[j-1]]) {
                swap(a[j],a[j-1]); v.pb({a[j],a[j-1]});
            }
        }
    }
    cout << v.size() << endl;
    for (auto x : v) {
        cout << x.first << " " << x.second << endl;
    }

}
signed main() {
    init();
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
        //  cout << endl;
    }
}


//反思的目标：过段时间重看一遍、下次碰到类似题目或技巧能写得出来（抓本质）
//为什么我没想到？赛时怎么想才能出题？
//一句话概括
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#include<unordered_map>
#include <random>
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3fLL
#define int long long
#define pb push_back
#define PII pair<int,int>
#define ls p<<1
#define rs p<<1|1
#define f(x,y,z) for(int x=(y);x<=(z);++x)
#define umap unordered_map
#define vi vector<int>
using namespace std;

void init() {
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(0);
}
bool cmp2(PII a, PII b) { return a.fi > b.fi; }

const int N = (1<<20) + 10;
//--------------分割线---------------

int c[N], s[N],sw[N],ans[N];
int n, m, k;
//8
 
void solve() {
    cin >> n;
    f(i, 1, n) {
        cin >> m;
        c[m] = i;
    }
    f(i, 1, n-1) {
        f(j, i + 1, n) {
            if (c[i] < c[j]) {
                cout << j << " " << i << endl;
                cout << i << " " << j << endl;
            }
            else {
                cout << j << " " << i << endl;
            }
        }
    }

}
signed main() {
    init();
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
        //  cout << endl;
    }
}


//反思的目标：过段时间重看一遍、下次碰到类似题目或技巧能写得出来（抓本质）
//为什么我没想到？赛时怎么想才能出题？
//一句话概括



Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
#include<unordered_map>
#include <random>
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3fLL
#define int long long
#define pb push_back
#define PII pair<int,int>
#define ls p<<1
#define rs p<<1|1
#define f(x,y,z) for(int x=(y);x<=(z);++x)
#define umap unordered_map
#define vi vector<int>
#define vii vector<pair<int,int>>
using namespace std;

void init() {
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(0);
}
bool cmp2(PII a, PII b) { return a.fi > b.fi; }

const int N = (1<<20) + 10;
//--------------分割线---------------

int c[N], s[N],sw[N],ans[N];
int n, m, k;
//8
 
void solve() {
    cin >> n;
    f(i, 1, n) {
        cin >> m;
        c[m] = i;
    }
    vii v;
    f(i, 1, n-1) {
        f(j, i + 1, n) {
            if (c[i] < c[j]) {
                k += 2;
                v.pb({ j,i });
                v.pb({ i,j });
            }
            else {
                k += 1;
                v.pb({ j,i });
            }
        }
    }
    cout << v.size() << endl;
    for (auto x : v) {
        cout << x.first << " " << x.second << endl;
    }

}
signed main() {
    init();
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
        //  cout << endl;
    }
}


//反思的目标：过段时间重看一遍、下次碰到类似题目或技巧能写得出来（抓本质）
//为什么我没想到？赛时怎么想才能出题？
//一句话概括
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#include<unordered_map>
#include <random>
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3fLL
#define int long long
#define pb push_back
#define PII pair<int,int>
#define ls p<<1
#define rs p<<1|1
#define f(x,y,z) for(int x=(y);x<=(z);++x)
#define umap unordered_map
#define vi vector<int>
#define vii vector<pair<int,int>>
using namespace std;

void init() {
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(0);
}
bool cmp2(PII a, PII b) { return a.fi > b.fi; }

const int N = (1<<20) + 10;
//--------------分割线---------------

int c[N], a[N],sw[N],ans[N];
int n, m, k;
//8
 
void solve() {
    cin >> n;
    f(i, 1, n)a[i] = i;
    f(i, 1, n) {
        cin >> m;
        c[m] = i;
    }
    vii v;
    f(i, 1, n) {
        f(j, 1, n-i) { v.pb({ a[j+1],a[j]}); swap(a[j+1], a[j]); }
        f(j, n-i+2, n) {
            if (c[a[j]] <= c[a[j-1]]) {
                swap(a[j],a[j-1]); v.pb({a[j],a[j-1]});
            }
        }
    }
    cout << v.size() << endl;
    for (auto x : v) {
        cout << x.first << " " << x.second << endl;
    }

}
signed main() {
    init();
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
        //  cout << endl;
    }
}


//反思的目标：过段时间重看一遍、下次碰到类似题目或技巧能写得出来（抓本质）
//为什么我没想到？赛时怎么想才能出题？
//一句话概括



Submission (verdict: Accepted):
#include <bits/stdc++.h>
#include<unordered_map>
#include <random>
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3fLL
#define int long long
#define pb push_back
#define PII pair<int,int>
#define ls p<<1
#define rs p<<1|1
#define f(x,y,z) for(int x=(y);x<=(z);++x)
#define umap unordered_map
#define vi vector<int>
#define vii vector<pair<int,int>>
using namespace std;

void init() {
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(0);
}
bool cmp2(PII a, PII b) { return a.fi > b.fi; }

const int N = (1<<20) + 10;
//--------------分割线---------------

int c[N], a[N],sw[N],ans[N];
int n, m, k;
//8
 
void solve() {
    cin >> n;
    f(i, 1, n)a[i] = i;
    f(i, 1, n) {
        cin >> m;
        c[m] = i;
    }
    vii v;
    f(i, 1, n) {
        f(j, 1, n-i) { v.pb({ a[j+1],a[j]}); swap(a[j+1], a[j]); }
        f(j, n-i+2, n) {
            if (c[a[j]] <= c[a[j-1]]) {
                 v.pb({a[j],a[j-1]}); swap(a[j], a[j - 1]);
            }
        }
    }
    cout << v.size() << endl;
    for (auto x : v) {
        cout << x.first << " " << x.second << endl;
    }

}
signed main() {
    init();
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
        //  cout << endl;
    }
}


//反思的目标：过段时间重看一遍、下次碰到类似题目或技巧能写得出来（抓本质）
//为什么我没想到？赛时怎么想才能出题？
//一句话概括
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#include<unordered_map>
#include <random>
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3fLL
#define int long long
#define pb push_back
#define PII pair<int,int>
#define ls p<<1
#define rs p<<1|1
#define f(x,y,z) for(int x=(y);x<=(z);++x)
#define umap unordered_map
#define vi vector<int>
using namespace std;

void init() {
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(0);
}
bool cmp2(PII a, PII b) { return a.fi > b.fi; }

const int N = (1<<20) + 10;
//--------------分割线---------------

int c[N], s[N],sw[N],ans[N];
int n, m, k;
//8
 
void solve() {
    cin >> n;
    f(i, 1, n) {
        cin >> m;
        c[m] = i;
    }
    f(i, 1, n-1) {
        f(j, i + 1, n) {
            if (c[i] < c[j]) {
                cout << j << " " << i << endl;
                cout << i << " " << j << endl;
            }
            else {
                cout << j << " " << i << endl;
            }
        }
    }

}
signed main() {
    init();
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
        //  cout << endl;
    }
}


//反思的目标：过段时间重看一遍、下次碰到类似题目或技巧能写得出来（抓本质）
//为什么我没想到？赛时怎么想才能出题？
//一句话概括
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)


Submission (verdict: Memory limit exceeded on test 14):
#include <bits/stdc++.h>
#define ll long long 
#define pi pair<ll,ll>
#define vi vector<ll> 
#define dd double
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define lcm(a, b) ((a) * (b)) / __gcd(a, b)
#define mp make_pair
#define in insert
#define fi first
#define lb lower_bound
#define ub upper_bound
#define se second
#define yes cout<<"YES"
#define no cout<<"NO"
#define rd(n) ll n; cin>>n;
#define all(v) (v).begin(),(v).end()
#define ra(a,n) vi a(n); f(i,0,n){cin>>a[i];}
const int mod = 1e9 + 7;
using namespace std;
#define int long long

int n, m;

int fun(string a, string b, string c, int i, int j, vector<vector<vector<int>>>& dp) {
    if (i >= n && j >= m) return 0;
    if (dp[i][j][i + j] != -1) return dp[i][j][i + j];
    int ans = 1e5;
    if (i < n) {
        if (a[i] != c[i + j]) {
            ans = min(ans, fun(a, b, c, i + 1, j, dp) + 1);
        } else {
            ans = min(ans, fun(a, b, c, i + 1, j, dp));
        }
    }
    if (j < m) {
        if (b[j] != c[i + j]) {
            ans = min(ans, fun(a, b, c, i, j + 1, dp) + 1);
        } else {
            ans = min(ans, fun(a, b, c, i, j + 1, dp));
        }
    }
    return dp[i][j][i + j] = ans;
}

void solve() {
    string a, b, c;
    cin >> a >> b >> c;
    n = a.size(), m = b.size();
    vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(m + 1, vector<int>(n + m + 1, -1)));
    cout << fun(a, b, c, 0, 0, dp);
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long t = 1;
    cin >> t;
    while (t--) {
        solve();
        cout << endl;
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 1):
#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
   ll n;
   cin>>n;
   vector<ll>a(n);
   for(ll i = 0;i<n;i++)
   cin>>a[i];
   ll m = 0;
   vector<vector<ll>>greater(n+1,vector<ll>());
   vector<vector<ll>>smaller(n+1,vector<ll>());
   for(ll i = 0;i<n;i++)
   {
      for(ll j = i+1;j<n;j++)
      {
         if(a[j]<a[i])
        {
           m+=1;
           smaller[a[i]].push_back(a[j]);
        }
        else
        {
          m+=2;
          greater[a[i]].push_back(a[j]);
        }
      }
   }
   cout<<m<<endl;
   for(ll i = 0;i<n;i++)
   {
      for(auto it:greater[a[i]])
      {
        cout<<it<<" "<<a[i]<<endl;
      }
       for(ll j = greater[a[i]].size()-1;j>=0;j--)
      {
        cout<<a[i]<<" "<<greater[a[i]][j]<<endl;
      }

      for(auto it:smaller[a[i]])
      {
        cout<<a[i]<<" "<<it<<endl;
      }
   }

}


Submission (verdict: Runtime error on test 1):
#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
   ll n;
   cin>>n;
   vector<ll>a(n);
   for(ll i = 0;i<n;i++)
   cin>>a[i];
   ll m = 0;
   vector<vector<ll>>greater(n+1,vector<ll>());
   vector<vector<ll>>smaller(n+1,vector<ll>());
   for(ll i = 0;i<n;i++)
   {
      for(ll j = i+1;j<n;j++)
      {
         if(a[j]<a[i])
        {
           m+=1;
           smaller[a[i]].push_back(a[j]);
        }
        else
        {
          m+=2;
          greater[a[i]].push_back(a[j]);
        }
      }
   }
   cout<<m<<endl;
   for(ll i = 0;i<n;i++)
   {
      for(auto it:greater[a[i]])
      {
        cout<<it<<" "<<a[i]<<endl;
      }
       for(ll j = greater[a[i]].size()-1;j>=0;j--)
      {
        cout<<a[i]<<" "<<greater[a[i]][j]<<endl;
      }

      for(auto it:smaller[a[i]])
      {
        cout<<a[i]<<" "<<it<<endl;
      }
   }
   return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 1):
#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
   ll n;
   cin>>n;
   vector<ll>a(n);
   for(ll i = 0;i<n;i++)
   cin>>a[i];
   ll m = 0;
   vector<vector<ll>>greater(n+1,vector<ll>());
   vector<vector<ll>>smaller(n+1,vector<ll>());
   for(ll i = 0;i<n;i++)
   {
      for(ll j = i+1;j<n;j++)
      {
         if(a[j]<a[i])
        {
           m+=1;
           smaller[a[i]].push_back(a[j]);
        }
        else
        {
          m+=2;
          greater[a[i]].push_back(a[j]);
        }
      }
   }
   cout<<m<<endl;
   for(ll i = 0;i<n;i++)
   {
      for(auto it:greater[a[i]])
      {
        cout<<it<<" "<<a[i]<<endl;
      }
       for(ll j = greater[a[i]].size()-1;j>=0;j--)
      {
        cout<<a[i]<<" "<<greater[a[i]][j]<<endl;
      }

      for(auto it:smaller[a[i]])
      {
        cout<<a[i]<<" "<<it<<endl;
      }
   }
   return 0;
}


Submission (verdict: Wrong answer on test 7):
#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
   ll n;
   cin>>n;
   vector<ll>a(n);
   for(ll i = 0;i<n;i++)
   cin>>a[i];
   ll m = 0;
   vector<vector<ll>>greater(n+1,vector<ll>());
   vector<vector<ll>>smaller(n+1,vector<ll>());
   for(ll i = 0;i<n;i++)
   {
      for(ll j = i+1;j<n;j++)
      {
         if(a[j]<a[i])
        {
           m+=1;
           smaller[a[i]].push_back(a[j]);
        }
        else
        {
          m+=2;
          greater[a[i]].push_back(a[j]);
        }
      }
   }
   cout<<m<<endl;
   for(ll i = 0;i<n;i++)
   {
      for(auto it:greater[a[i]])
      {
        cout<<it<<" "<<a[i]<<endl;
      }
       for (auto it = greater[a[i]].rbegin(); it != greater[a[i]].rend(); ++it)
{
    cout << a[i] << " " << *it << endl;
}

      for(auto it:smaller[a[i]])
      {
        cout<<a[i]<<" "<<it<<endl;
      }
   }
   return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 7):
#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
   ll n;
   cin>>n;
   vector<ll>a(n);
   for(ll i = 0;i<n;i++)
   cin>>a[i];
   ll m = 0;
   vector<vector<ll>>greater(n+1,vector<ll>());
   vector<vector<ll>>smaller(n+1,vector<ll>());
   for(ll i = 0;i<n;i++)
   {
      for(ll j = i+1;j<n;j++)
      {
         if(a[j]<a[i])
        {
           m+=1;
           smaller[a[i]].push_back(a[j]);
        }
        else
        {
          m+=2;
          greater[a[i]].push_back(a[j]);
        }
      }
   }
   cout<<m<<endl;
   for(ll i = 0;i<n;i++)
   {
      for(auto it:greater[a[i]])
      {
        cout<<it<<" "<<a[i]<<endl;
      }
       for (auto it = greater[a[i]].rbegin(); it != greater[a[i]].rend(); ++it)
{
    cout << a[i] << " " << *it << endl;
}

      for(auto it:smaller[a[i]])
      {
        cout<<a[i]<<" "<<it<<endl;
      }
   }
   return 0;
}


Submission (verdict: Accepted):
#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
   ll n;
   cin>>n;
   vector<ll>pos(n+1);
   vector<ll>cur(n+1);
   vector<ll>a(n+1);
   for(ll i = 1;i<=n;i++)
   {
     cin>>a[i];
     pos[a[i]] = i;
     cur[i] = i;
   }
   vector<pair<ll,ll>>ans;
   for(ll i = 1;i<=n;i++)
   {
     for(ll j = 1;j<n;j++)
     {
        if(pos[cur[j]] < pos[cur[j+1]])
        {
           ans.push_back({cur[j+1],cur[j]});
           swap(cur[j],cur[j+1]);
        }
     }
   }
   for(ll i = 1;i<=n;i++)
   {
     for(ll j = 1;j<n;j++)
     {
        if(pos[cur[j]] > pos[cur[j+1]])
        {
          ans.push_back({cur[j+1],cur[j]});
          swap(cur[j+1],cur[j]);
        }
     }
   }
   cout<<ans.size()<<endl;
   for(auto [x,y] : ans)
   cout<<x<<" "<<y<<endl;
   return 0;
}