ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll long long 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // *A.find_by_order(X), A.order_of_key(X)

string a,b,c;
ll n,m;
ll dp[1001][1001];

ll rec(ll level1,ll level2){
    if(level1==n && level2==m) return 0;
    if(dp[level1][level2]!=-1) return dp[level1][level2];

    ll ans = LLONG_MAX;

if (level1 < n && c[level1 + level2] == a[level1]) {
    ans = min(ans, rec(level1 + 1, level2));
}

if (level2 < m && c[level1 + level2] == b[level2]) {
    ans = min(ans, rec(level1, level2 + 1));
}
    ans=min(ans,1+min(rec(level1+1,level2),rec(level1,level2+1)));
    return dp[level1][level2]=ans;
}

void solve() {

cin>>a>>b>>c;
n=a.size();
m=b.size();
memset(dp,-1,sizeof(dp));
cout<<rec(0,0)<<endl;





}



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


Submission (verdict: Wrong answer on test 1):
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll long long 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // *A.find_by_order(X), A.order_of_key(X)

string a,b,c;
ll n,m;
ll dp[1001][1001];

ll rec(ll level1,ll level2){
    if(level1==n && level2==m) return 0;
    if(dp[level1][level2]!=-1) return dp[level1][level2];

    ll ans = INT_MAX;

if (level1 < n && c[level1 + level2] == a[level1]) {
    ans = min(ans, rec(level1 + 1, level2));
}

if (level2 < m && c[level1 + level2] == b[level2]) {
    ans = min(ans, rec(level1, level2 + 1));
}
    ans=min(ans,1+min(rec(level1+1,level2),rec(level1,level2+1)));
    return dp[level1][level2]=ans;
}

void solve() {

cin>>a>>b>>c;
n=a.size();
m=b.size();
memset(dp,-1,sizeof(dp));
cout<<rec(0,0)<<endl;





}



signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll long long 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // *A.find_by_order(X), A.order_of_key(X)

string a,b,c;
ll n,m;
ll dp[1001][1001];

ll rec(ll level1,ll level2){
    if(level1==n && level2==m) return 0;
    if(dp[level1][level2]!=-1) return dp[level1][level2];

    ll ans = LLONG_MAX;

if (level1 < n && c[level1 + level2] == a[level1]) {
    ans = min(ans, rec(level1 + 1, level2));
}

if (level2 < m && c[level1 + level2] == b[level2]) {
    ans = min(ans, rec(level1, level2 + 1));
}
    ans=min(ans,1+min(rec(level1+1,level2),rec(level1,level2+1)));
    return dp[level1][level2]=ans;
}

void solve() {

cin>>a>>b>>c;
n=a.size();
m=b.size();
memset(dp,-1,sizeof(dp));
cout<<rec(0,0)<<endl;





}



signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Time limit exceeded on test 5):
#include <bits/stdc++.h>
using namespace std;
#define ll long long


int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);

	ll tt;
	cin>>tt;
	while (tt--)
	{
		string str;
		cin>>str;
		ll sum = 0;
		ll three = 0;
		ll two = 0;
		string ans = "NO";
		for (int i = 0; i < str.length(); i++)
		{
			sum += str[i] - '0';
			if(str[i] == '3'){
				three++;
			}
			if(str[i] == '2'){
				two++;
			}
		}
		for (int i = 0; i <= two; i++)
		{
			for (int j = 0; j <= three; j++)
			{
				ll tsum = sum;
				tsum += i*2+j*6;
				if(tsum%9==0){
					ans = "YES";
				}
			}
			
		}
		cout<<ans<<"\n";
		
		

		
	}
	

	return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 5):
#include <bits/stdc++.h>
using namespace std;
#define ll long long


int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);

	ll tt;
	cin>>tt;
	while (tt--)
	{
		string str;
		cin>>str;
		ll sum = 0;
		ll three = 0;
		ll two = 0;
		string ans = "NO";
		for (int i = 0; i < str.length(); i++)
		{
			sum += str[i] - '0';
			if(str[i] == '3'){
				three++;
			}
			if(str[i] == '2'){
				two++;
			}
		}
		for (int i = 0; i <= two; i++)
		{
			for (int j = 0; j <= three; j++)
			{
				ll tsum = sum;
				tsum += i*2+j*6;
				if(tsum%9==0){
					ans = "YES";
				}
			}
			
		}
		cout<<ans<<"\n";
		
		

		
	}
	

	return 0;
}

Submission (verdict: Time limit exceeded on test 5):
#include <bits/stdc++.h>
using namespace std;
#define ll long long


int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);

	ll tt;
	cin>>tt;
	while (tt--)
	{
		string str;
		cin>>str;
		ll sum = 0;
		ll three = 0;
		ll two = 0;
		string ans = "NO";
		for (int i = 0; i < str.length(); i++)
		{
			sum += str[i] - '0';
			sum %= 9;
			if(str[i] == '3'){
				three++;
			}
			if(str[i] == '2'){
				two++;
			}
		}
		for (int i = 0; i <= two; i++)
		{
			for (int j = 0; j <= three; j++)
			{
				ll tsum = sum;
				tsum += i*2+j*6;
				if(tsum%9==0){
					ans = "YES";
				}
			}
			
		}
		cout<<ans<<"\n";
		
		

		
	}
	

	return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 5):
#include <bits/stdc++.h>
using namespace std;
#define ll long long


int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);

	ll tt;
	cin>>tt;
	while (tt--)
	{
		string str;
		cin>>str;
		ll sum = 0;
		ll three = 0;
		ll two = 0;
		string ans = "NO";
		for (int i = 0; i < str.length(); i++)
		{
			sum += str[i] - '0';
			sum %= 9;
			if(str[i] == '3'){
				three++;
			}
			if(str[i] == '2'){
				two++;
			}
		}
		for (int i = 0; i <= two; i++)
		{
			for (int j = 0; j <= three; j++)
			{
				ll tsum = sum;
				tsum += i*2+j*6;
				if(tsum%9==0){
					ans = "YES";
				}
			}
			
		}
		cout<<ans<<"\n";
		
		

		
	}
	

	return 0;
}

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


int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);

	ll tt;
	cin>>tt;
	while (tt--)
	{
		string str;
		cin>>str;
		ll sum = 0;
		ll three = 0;
		ll two = 0;
		string ans = "NO";
		for (auto i : str)
		{
			sum += i - '0';
			sum %= 9;
			if(i == '3'){
				three++;
			}
			if( i == '2'){
				two++;
			}
		}
		for (int i = 0; i <= two; i++)
		{
			for (int j = 0; j <= three; j++)
			{
				ll tsum = sum;
				tsum += i*2+j*6;
				if(tsum%9==0){
					ans = "YES";
					break;
				}
			}
			
		}
		cout<<ans<<"\n";
		
		

		
	}
	

	return 0;
}
Problem: 2049B - pspspsps
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define N 100000000+1;

#define all(v) v.begin(),v.end()

#define fin(v) for(auto &it:v) cin>>it

#define mll map<ll,ll>

#define vl vector<ll>

#define srt(v) sort(v.begin(),v.end())  

#define cnt(a,v) count(a.begin(),a.end(),v)

#define sm(v) accumulate(all(v), 0LL)

#define ln "\n"

#define Griffith ios_base::sync_with_stdio(0);

#define The cin.tie(0);

#define Hawk cout.tie(0);

#define Solve ll tt; cin>>tt; while (tt--){solve();	}





void solve() {

	ll n; cin>>n;

	string s; cin>>s;

	if(n<=2){

		cout<<"YES\n";

		return;

	} 

	bool ss = false; 

	for (ll i = 0; i < n; i++)

	{

		if(s[i] == 'p') ss = true;

		if(s[i] == 's' && ss){

			cout<<"NO\n";

			return;

		}

	}

	ll i = 1;

	ll j  = n-2;

	while (j>i)

	{

		if((s[i] == 's' && s[j] == 'p') || (s[i] == 'p' && s[j] == 's')  ){

			cout<<"NO\n";

			return;

		}

		i++;

		j--;

	}

	

	

	cout<<"YES\n";

 

 

}

int main(){

	Griffith The Hawk

	Solve

	//solve();

	return 0;

}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define N 100000000+1;

#define all(v) v.begin(),v.end()

#define fin(v) for(auto &it:v) cin>>it

#define mll map<ll,ll>

#define vl vector<ll>

#define srt(v) sort(v.begin(),v.end())  

#define cnt(a,v) count(a.begin(),a.end(),v)

#define sm(v) accumulate(all(v), 0LL)

#define ln "\n"

#define Griffith ios_base::sync_with_stdio(0);

#define The cin.tie(0);

#define Hawk cout.tie(0);

#define Solve ll tt; cin>>tt; while (tt--){solve();	}





void solve() {

	ll n; cin>>n;

	ll x,y; cin>>x>>y; x--; y--;

	vl ans(n);

	if(n%2 == 0 && abs(x-y)&1){

		for (ll i = 0; i < n; i++)

		{

			ans[i] = 1&i;

		}

	}

	else{

		for (ll i = 0; i < n; i++)

		{

			if(i == x) ans[i] = 2;

			else ans[i] = ((i-x+n)%n)&1;

		}

		

	}

	for (ll i = 0; i < n; i++)

	{

		cout<<ans[i]<<" ";

	}

	cout<<ln;

 

 

}

int main(){

	Griffith The Hawk

	Solve

	//solve();

	return 0;

}
Problem: 2049B - pspspsps
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define N 100000000+1;

#define all(v) v.begin(),v.end()

#define fin(v) for(auto &it:v) cin>>it

#define mll map<ll,ll>

#define vl vector<ll>

#define srt(v) sort(v.begin(),v.end())  

#define cnt(a,v) count(a.begin(),a.end(),v)

#define sm(v) accumulate(all(v), 0LL)

#define ln "\n"

#define Griffith ios_base::sync_with_stdio(0);

#define The cin.tie(0);

#define Hawk cout.tie(0);

#define Solve ll tt; cin>>tt; while (tt--){solve();	}





void solve() {

	ll n; cin>>n;

	ll x,y; cin>>x>>y; x--; y--;

	vl ans(n);

	if(n%2 == 0 && abs(x-y)&1){

		for (ll i = 0; i < n; i++)

		{

			ans[i] = 1&i;

		}

	}

	else{

		for (ll i = 0; i < n; i++)

		{

			if(i == x) ans[i] = 2;

			else ans[i] = ((i-x+n)%n)&1;

		}

		

	}

	for (ll i = 0; i < n; i++)

	{

		cout<<ans[i]<<" ";

	}

	cout<<ln;

 

 

}

int main(){

	Griffith The Hawk

	Solve

	//solve();

	return 0;

}

Submission (verdict: Accepted):
#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define N 100000000+1;

#define all(v) v.begin(),v.end()

#define fin(v) for(auto &it:v) cin>>it

#define mll map<ll,ll>

#define vl vector<ll>

#define srt(v) sort(v.begin(),v.end())  

#define cnt(a,v) count(a.begin(),a.end(),v)

#define sm(v) accumulate(all(v), 0LL)

#define ln "\n"

#define Griffith ios_base::sync_with_stdio(0);

#define The cin.tie(0);

#define Hawk cout.tie(0);

#define Solve ll tt; cin>>tt; while (tt--){solve();	}





void solve() {

	ll n ;

	string s; cin>>n>>s;

	vl a(n,-1);

	ll cur = 1;

	for (ll i = 0; i < n; i++)

	{

		if(s[i] != 'p' && i+1<n) continue;

		ll j = i;

		while (j>= 0 && a[j] == -1)

		{

			a[j] = cur;

			cur++;

			j--;

		}

	}

	bool flag = true;

	ll sum = 0;

	for (ll i = n-1; i >= 0; i--)

	{

		sum += a[i];

		if(s[i] != 's') continue;

		ll l = n-i;

		if(l*(l+1)/2 != sum) flag = false;

	}

	cout<<(flag ? "YES\n" : "NO\n");

 

}

int main(){

	Griffith The Hawk

	Solve

	//solve();

	return 0;

}
Problem: 2049B - pspspsps
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define N 100000000+1;

#define all(v) v.begin(),v.end()

#define fin(v) for(auto &it:v) cin>>it

#define mll map<ll,ll>

#define vl vector<ll>

#define srt(v) sort(v.begin(),v.end())  

#define cnt(a,v) count(a.begin(),a.end(),v)

#define sm(v) accumulate(all(v), 0LL)

#define ln "\n"

#define Griffith ios_base::sync_with_stdio(0);

#define The cin.tie(0);

#define Hawk cout.tie(0);

#define Solve ll tt; cin>>tt; while (tt--){solve();	}





void solve() {

	ll n; cin>>n;

	string s; cin>>s;

	if(n<=2){

		cout<<"YES\n";

		return;

	} 

	bool ss = false; 

	for (ll i = 0; i < n; i++)

	{

		if(s[i] == 'p') ss = true;

		if(s[i] == 's' && ss){

			cout<<"NO\n";

			return;

		}

	}

	ll i = 1;

	ll j  = n-2;

	while (j>i)

	{

		if((s[i] == 's' && s[j] == 'p') || (s[i] == 'p' && s[j] == 's')  ){

			cout<<"NO\n";

			return;

		}

		i++;

		j--;

	}

	

	

	cout<<"YES\n";

 

 

}

int main(){

	Griffith The Hawk

	Solve

	//solve();

	return 0;

}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)


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

//MACROS
#define F first 
#define S second
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define pb push_back
#define PI 3.14159265359
#define endl '\n'

//ALIASES
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
using vpll = vector<pair<long long, long long>>;
using mll = map<long long, long long>;
using mcll = map<char, long long>;
using vvll = vector<vector<long long>>;
using sll = set<long long>;

//CONSTANTS
constexpr ld EPS = 1e-9;
constexpr ll MOD = 998244353 ;                          
constexpr ull INF = 2e18;

//OPERATOR OVERLOADING  
// cin >> pair<T1, T2>
template <typename T1, typename T2>
istream& operator>>(istream& istream, pair<T1, T2>& p){
    return (istream >> p.first >> p.second);
}
// cout << pair<T1, T2>
template <typename T1, typename T2> 
ostream& operator<<(ostream& ostream, const pair<T1, T2>& p){
    return (ostream << p.first << " " << p.second);
}
// cin >> vector<T>
template <typename T> 
istream& operator>>(istream& istream, vector<T>& v){
    for (auto& it : v) cin >> it;
    return istream;
}
// cout << vector<T>
template <typename T> 
ostream& operator<<(ostream& ostream, const vector<T>& c){
    for (auto& it : c) cout << it << " ";
    return ostream;
}
// cout << set<T>
template <typename T> 
ostream& operator<<(ostream& ostream, const set<T>& c){
    for (auto& it : c) cout << it << " ";
    return ostream;
}

ll l, r;

string binary(ll x){
    string s="";
    while(x>0){
        if(x%2==1) s.insert(0, 1, '1');
        else if(x%2==0) s.insert(0, 1, '0');
        x /= 2;
    }
    while(s.length()<64){
        s.insert(0, 1, '0');
    }
    return s;
}
ll numeric(string s){
    ll x=0;
    for(int i=0; i<s.length(); i++) x += (s[i]=='1')*(1<<(s.length()-i-1)); 
    return x;
}

void solve(){ 
    cin>>l>>r;
    ll a, b, c;
    string L = binary(l), R = binary(r);
    string A = "", B = "", C = "";
    for(int i=0; i<L.length(); i++){
        if(L[i] == R[i]) {A.pb(L[i]); B.pb(L[i]); C.pb(L[i]);}
        else{
            break;
        }
    }
    if(A.length()<L.length()) {A.pb('1'); B.pb('0'); C.pb('0');}
    while(A.length()<L.length()) {
        A.pb('0'); B.pb('1'); C.pb('0');
    }
    cout<<numeric(A)<<" "<<numeric(B)<<" "<<numeric(C)<<"\n";
}

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

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

#define MOD 1000000000
#define ll long long

void solve() {
    int n; cin>>n;
    vector<int> arr(n);
    for (int i=0; i<n; i++) cin>>arr[i];
    int total = n*(n-1);
    int count = 0;
    vector<vector<int>> flag(n, vector<int>(n, 0));
    int j, curr;
    for (int i=1; i<n; i++) {
        curr = arr[i];
        j = i;
        while (j>0 && arr[j-1]>curr) {
            flag[curr-1][arr[j-1]-1] = 1;
            count++;
            arr[j] = arr[j-1];
            j--;
        }
        arr[j] = curr;
    }
    cout<<total-count<<"\n";
    for (int i=0; i<n; i++) {
        for (int j=i+1; j<n; j++) {
            if (flag[i][j] == 1) cout<<j+1<<" "<<i+1<<"\n";
            else {
                cout<<j+1<<" "<<i+1<<"\n";
                cout<<i+1<<" "<<j+1<<"\n";
            }
        }
    }
}
 
int main() {
	ios_base::sync_with_stdio(false);  
	cin.tie(nullptr);

    solve();

    return 0;
}

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

#define MOD 1000000000
#define ll long long

void solve() {
    int n; cin>>n;
    vector<int> arr(n), sorted(n, 0);
    for (int i=0; i<n; i++) cin>>arr[i];
    int total = n*(n-1);
    int count = 0;
    int j, curr;
    for (int i=0; i<n; i++) {
        curr = arr[i];
        j = i;
        while (j>0 && sorted[j-1]>curr) {
            count++;
            sorted[j] = sorted[j-1];
            j--;
        }
        sorted[j] = curr;
    }
    cout<<total-count<<"\n";
    int index;
    for (int i=0; i<n; i++) {
        index = lower_bound(sorted.begin()+i, sorted.end(), arr[i]) - sorted.begin();
        for (int j=index+1; j<n; j++) cout<<sorted[j]<<" "<<sorted[index]<<"\n";
        for (int j=n-1; j>index; j--) cout<<sorted[index]<<" "<<sorted[j]<<"\n";
        for (int j=index-1; j>=i; j--) {
            cout<<sorted[j+1]<<" "<<sorted[j]<<"\n";
            swap(sorted[j], sorted[j+1]);
        }
    }
}
 
int main() {
	ios_base::sync_with_stdio(false);  
	cin.tie(nullptr);

    solve();

    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


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

#define MOD 1000000000
#define ll long long

void solve() {
    int n; cin>>n;
    vector<int> arr(n);
    for (int i=0; i<n; i++) cin>>arr[i];
    int total = n*(n-1);
    int count = 0;
    vector<vector<int>> flag(n, vector<int>(n, 0));
    int j, curr;
    for (int i=1; i<n; i++) {
        curr = arr[i];
        j = i;
        while (j>0 && arr[j-1]>curr) {
            flag[curr-1][arr[j-1]-1] = 1;
            count++;
            arr[j] = arr[j-1];
            j--;
        }
        arr[j] = curr;
    }
    cout<<total-count<<"\n";
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            if (flag[i][j] == 1) cout<<j+1<<" "<<i+1<<"\n";
            else if (flag[j][i] == 0 && i != j) cout<<j+1<<" "<<i+1<<"\n";
        }
    }
}
 
int main() {
	ios_base::sync_with_stdio(false);  
	cin.tie(nullptr);

    solve();

    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

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

#define MOD 1000000000
#define ll long long

void solve() {
    int n; cin>>n;
    vector<int> arr(n);
    for (int i=0; i<n; i++) cin>>arr[i];
    int total = n*(n-1);
    int count = 0;
    vector<vector<int>> flag(n, vector<int>(n, 0));
    int j, curr;
    for (int i=1; i<n; i++) {
        curr = arr[i];
        j = i;
        while (j>0 && arr[j-1]>curr) {
            flag[curr-1][arr[j-1]-1] = 1;
            count++;
            arr[j] = arr[j-1];
            j--;
        }
        arr[j] = curr;
    }
    cout<<total-count<<"\n";
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            if (flag[i][j] == 1) cout<<j+1<<" "<<i+1<<"\n";
            else if (flag[j][i] == 0 && i != j) cout<<j+1<<" "<<i+1<<"\n";
        }
    }
}
 
int main() {
	ios_base::sync_with_stdio(false);  
	cin.tie(nullptr);

    solve();

    return 0;
}

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

#define MOD 1000000000
#define ll long long

void solve() {
    int n; cin>>n;
    vector<int> arr(n);
    for (int i=0; i<n; i++) cin>>arr[i];
    int total = n*(n-1);
    int count = 0;
    vector<vector<int>> flag(n, vector<int>(n, 0));
    int j, curr;
    for (int i=1; i<n; i++) {
        curr = arr[i];
        j = i;
        while (j>0 && arr[j-1]>curr) {
            flag[curr-1][arr[j-1]-1] = 1;
            count++;
            arr[j] = arr[j-1];
            j--;
        }
        arr[j] = curr;
    }
    cout<<total-count<<"\n";
    for (int i=0; i<n; i++) {
        for (int j=i+1; j<n; j++) {
            if (flag[i][j] == 1) cout<<j+1<<" "<<i+1<<"\n";
            else {
                cout<<j+1<<" "<<i+1<<"\n";
                cout<<i+1<<" "<<j+1<<"\n";
            }
        }
    }
}
 
int main() {
	ios_base::sync_with_stdio(false);  
	cin.tie(nullptr);

    solve();

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

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

int main(){
    int n; cin >> n;
    int a[n];
    for(int i=0; i<n; i++) cin >> i[a];
    vector<vector<bool>> b(n+1, vector<bool>(n+1));
    vector<int> g, q;
    for(int i=1; i<n; i++){
        for(int j=i; j>0; j--){
            g.push_back(i+1);
            q.push_back(j);
            if(a[i] > a[j-1]) b[a[i]][a[j-1]] = 1;
        }
    }
    for(int i=0; i<n; i++) a[i] = n-i;
    for(int i = n-1; i>0; i--){
        for(int j=i; j<n && b[a[j-1]][a[j]]; j++){
            g.push_back(a[j-1]);
            q.push_back(a[j]);
            swap(a[j-1], a[j]);
        }
    }
    cout << q.size() << '\n';
    for(int i=0; i < g.size(); i++){
        cout << g[i] <<' '<< q[i] << '\n';
    }
}

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

int main(){
    int n; cin >> n;
    int a[n];
    for(int i=0; i<n; i++) cin >> i[a];
    vector<vector<bool>> b(n+1, vector<bool>(n+1));
    vector<int> g, q;
    for(int i=1; i<n; i++){
        for(int j=i; j>0; j--){
            g.push_back(i+1);
            q.push_back(j);
            if(a[i] > a[j-1]) b[a[i]][a[j-1]] = 1;
        }
    }
    for(int i=0; i<n; i++) a[i] = n-i;
    for(int i = n-1; i>0; i--){
        for(int j=i; j<n && b[a[j-1]][a[j]]; j++){
            g.push_back(a[j]);
            q.push_back(a[j-1]);
            swap(a[j-1], a[j]);
        }
    }
    cout << q.size() << '\n';
    for(int i=0; i < g.size(); i++){
        cout << g[i] <<' '<< q[i] << '\n';
    }
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

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

int main(){
    int n; cin >> n;
    int a[n];
    for(int i=0; i<n; i++) cin >> i[a];
    vector<vector<bool>> b(n+1, vector<bool>(n+1));
    vector<int> g, q;
    for(int i=1; i<n; i++){
        for(int j=i; j>0; j--){
            g.push_back(i+1);
            q.push_back(j);
            if(a[i] > a[j-1]) b[a[i]][a[j-1]] = 1;
        }
    }
    for(int i=0; i<n; i++) a[i] = n-i;
    for(int i = n-1; i>0; i--){
        for(int j=i; j<n && b[a[j-1]][a[j]]; j++){
            g.push_back(a[j]);
            q.push_back(a[j-1]);
            swap(a[j-1], a[j]);
        }
    }
    cout << q.size() << '\n';
    for(int i=0; i < g.size(); i++){
        cout << g[i] <<' '<< q[i] << '\n';
    }
}

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

int main(){
    int n; cin >> n;
    int a[n];
    for(int i=0; i<n; i++) cin >> i[a];
    vector<vector<bool>> b(n+1, vector<bool>(n+1));
    vector<int> g, q;
    for(int i=1; i<n; i++){
        for(int j=0; j<i; j++){
            g.push_back(i+1);
            q.push_back(j+1);
            if(a[i] > a[j]) b[a[i]][a[j]] = 1;
        }
    }
    for(int i=0; i<n; i++) a[i] = n-i;
    for(int i = n-1; i>0; i--){
        for(int j=i; j<n && b[a[j-1]][a[j]]; j++){
            g.push_back(a[j]);
            q.push_back(a[j-1]);
            swap(a[j-1], a[j]);
        }
    }
    cout << q.size() << '\n';
    for(int i=0; i < g.size(); i++){
        cout << g[i] <<' '<< q[i] << '\n';
    }
}