ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


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;
      }
   }

}
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 int long long
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);

void solve()
{
    int n;
    cin >> n;
    vector<int> c(n);
    for (int i = 0; i < n; i++)
    {
        cin >> c[i];
    }
    vector<int> v1(n);
    for (int i = 0; i < n; i++)
    {
        v1[i] = i + 1;
    }
    vector<pair<int, int>> chk;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (i != j)
            {
                chk.push_back({i + 1, j + 1});
            }
        }
    }
    int hash[n + 1][n + 1];
    for (int i = 0; i < n + 1; i++)
    {
        for (int j = 0; j < n + 1; j++)
        {
            hash[i][j] = 0;
        }
    }
    vector<pair<int, int>> ans;
    for (int i = 0; i < n; i++)
    {
        int idx = find(v1.begin(), v1.end(), c[i]) - v1.begin();
        for (int j = idx; j > i; j--)
        {
            ans.push_back({v1[j], v1[j - 1]});
            swap(v1[j], v1[j - 1]);
            hash[v1[j]][v1[j - 1]] = 1;
        }
    }
    for (int i = 0; i < n - 1; i++)
    {
        if (hash[c[i]][c[i + 1]] == 0 && hash[c[i + 1]][c[i]] == 0)
        {
            ans.push_back({c[i + 1], c[i]});
            ans.push_back({c[i], c[i + 1]});
        }
    }
    cout << ans.size() << endl;
    for (auto e : ans)
    {
        cout << e.first << " " << e.second << endl;
    }
    cout << endl;
}

signed main()
{
    fast;
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);

void solve()
{
    int n;
    cin >> n;
    vector<int> c(n);
    for (int i = 0; i < n; i++)
    {
        cin >> c[i];
    }
    vector<int> v1(n);
    for (int i = 0; i < n; i++)
    {
        v1[i] = i + 1;
    }
    vector<pair<int, int>> ans;
    for (int i = 0; i < n; i++)
    {
        int idx = find(v1.begin(), v1.end(), c[i]) - v1.begin();
        for (int j = idx; j < n - 1; j++)
        {
            ans.push_back({v1[j + 1], v1[j]});
            swap(v1[j], v1[j + 1]);
        }
        for (int j = n - 1; j > i; j--)
        {
            ans.push_back({v1[j], v1[j - 1]});
            swap(v1[j], v1[j - 1]);
        }
    }
    cout << ans.size() << endl;
    for (auto e : ans)
    {
        cout << e.first << " " << e.second << endl;
    }
    cout << endl;
}

signed main()
{
    fast;
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);

void solve()
{
    int n;
    cin >> n;
    vector<int> c(n);
    for (int i = 0; i < n; i++)
    {
        cin >> c[i];
    }
    vector<int> v1(n);
    for (int i = 0; i < n; i++)
    {
        v1[i] = i + 1;
    }
    vector<pair<int, int>> chk;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (i != j)
            {
                chk.push_back({i + 1, j + 1});
            }
        }
    }
    int hash[n + 1][n + 1];
    for (int i = 0; i < n + 1; i++)
    {
        for (int j = 0; j < n + 1; j++)
        {
            hash[i][j] = 0;
        }
    }
    vector<pair<int, int>> ans;
    for (int i = 0; i < n; i++)
    {
        int idx = find(v1.begin(), v1.end(), c[i]) - v1.begin();
        for (int j = idx; j > i; j--)
        {
            ans.push_back({v1[j], v1[j - 1]});
            swap(v1[j], v1[j - 1]);
            hash[v1[j]][v1[j-1]] = 1;
        }
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            if (i != j)
            {
                if (hash[i][j] == 0 && hash[j][i] == 0)
                {
                    ans.push_back({i, j});
                    ans.push_back({j, i});
                    hash[i][j] = 1;
                    hash[j][i] = 1;
                }
            }
        }
    }
    for(auto e: ans){
        cout<<e.first<<" "<<e.second<<endl;
    }
    cout<<endl;
}

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


Submission (verdict: Wrong answer on test 3):
// Source: https://usaco.guide/general/io

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

string check(long long total, int threes, int twos) {
	if(total%9==0) {
		return "YES\n";
	} else {
		for(int x=threes; x>=0; x--) {
			for(int y=twos; y>=0; y--) {
				if((total+(6*x + y*2))%9==0) {
					return "YES\n";
				}
			}
		}
	}
	return "NO\n";
}

int main() {
	int n; cin >> n;

	for(int i=0; i<n; i++) {
		long long k; cin >> k;
		
		long long total = 0;
		int threes = 0;
		int twos = 0;
		for(char j : to_string(k)) {
			int digit = j - '0';
			if(digit==3) threes++;
			if(digit==2) twos++;
			total+=digit;
		}
		cout << check(total, threes, twos);
		
	}
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
// Source: https://usaco.guide/general/io

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

string check(long long total, int threes, int twos) {
	if(total%9==0) {
		return "YES\n";
	} else {
		for(int x=min(10,threes); x>=0; x--) {
			for(int y=min(10,twos); y>=0; y--) {
				if((total+(6*x + y*2))%9==0) {
					return "YES\n";
					break;
				}
			}
		}
	}
	return "NO\n";
}

int main() {
	int n; cin >> n;

	for(int i=0; i<n; i++) {
		long long k; cin >> k;
		
		long long total = 0;
		int threes = 0;
		int twos = 0;
		for(char j : to_string(k)) {
			int digit = j - '0';
			if(digit==3) threes++;
			if(digit==2) twos++;
			total=(total+digit)%9;
		}
		cout << check(total, threes, twos);
		
	}
}

Submission (verdict: Compilation error):
// Source: https://usaco.guide/general/io

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

string check(int total, int threes, int twos) {
	if(total%9==0) {
		return "YES\n";
	} else {
		for(int x=min(10,threes); x>=0; x--) {
			for(int y=min(10,twos); y>=0; y--) {
				if((total+(6*x + y*2))%9==0) {
					return "YES\n";
				}
			}
		}
	}
	return "NO\n";
}

int main() {
	int n; cin >> n;

	for(int i=0; i<n; i++) {
		string k; cin >> k;
		
		int total = 0;
		int threes = 0;
		int twos = 0;
		for(char j : to_string(k)) {
			int digit = j - '0';
			if(digit==3) threes++;
			if(digit==2) twos++;
			total=(total+digit)%9;
		}
		cout << check(total, threes, twos);
		
	}
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Compilation error):
// Source: https://usaco.guide/general/io

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

string check(int total, int threes, int twos) {
	if(total%9==0) {
		return "YES\n";
	} else {
		for(int x=min(10,threes); x>=0; x--) {
			for(int y=min(10,twos); y>=0; y--) {
				if((total+(6*x + y*2))%9==0) {
					return "YES\n";
				}
			}
		}
	}
	return "NO\n";
}

int main() {
	int n; cin >> n;

	for(int i=0; i<n; i++) {
		string k; cin >> k;
		
		int total = 0;
		int threes = 0;
		int twos = 0;
		for(char j : to_string(k)) {
			int digit = j - '0';
			if(digit==3) threes++;
			if(digit==2) twos++;
			total=(total+digit)%9;
		}
		cout << check(total, threes, twos);
		
	}
}

Submission (verdict: Accepted):
// Source: https://usaco.guide/general/io

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

string check(int total, int threes, int twos) {
	if(total%9==0) {
		return "YES\n";
	} else {
		for(int x=min(10,threes); x>=0; x--) {
			for(int y=min(10,twos); y>=0; y--) {
				if((total+(6*x + y*2))%9==0) {
					return "YES\n";
				}
			}
		}
	}
	return "NO\n";
}

int main() {
	int n; cin >> n;

	for(int i=0; i<n; i++) {
		string k; cin >> k;
		
		int total = 0;
		int threes = 0;
		int twos = 0;
		for(char j : k) {
			int digit = j - '0';
			if(digit==3) threes++;
			if(digit==2) twos++;
			total=(total+digit)%9;
		}
		cout << check(total, threes, twos);
		
	}
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
// Source: https://usaco.guide/general/io

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

string check(long long total, int threes, int twos) {
	if(total%9==0) {
		return "YES\n";
	} else {
		for(int x=threes; x>=0; x--) {
			for(int y=twos; y>=0; y--) {
				if((total+(6*x + y*2))%9==0) {
					return "YES\n";
				}
			}
		}
	}
	return "NO\n";
}

int main() {
	int n; cin >> n;

	for(int i=0; i<n; i++) {
		long long k; cin >> k;
		
		long long total = 0;
		int threes = 0;
		int twos = 0;
		for(char j : to_string(k)) {
			int digit = j - '0';
			if(digit==3) threes++;
			if(digit==2) twos++;
			total=(total+digit)%9;
		}
		cout << check(total, threes, twos);
		
	}
}

Submission (verdict: Wrong answer on test 3):
// Source: https://usaco.guide/general/io

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

string check(long long total, int threes, int twos) {
	if(total%9==0) {
		return "YES\n";
	} else {
		for(int x=min(10,threes); x>=0; x--) {
			for(int y=min(10,twos); y>=0; y--) {
				if((total+(6*x + y*2))%9==0) {
					return "YES\n";
					break;
				}
			}
		}
	}
	return "NO\n";
}

int main() {
	int n; cin >> n;

	for(int i=0; i<n; i++) {
		long long k; cin >> k;
		
		long long total = 0;
		int threes = 0;
		int twos = 0;
		for(char j : to_string(k)) {
			int digit = j - '0';
			if(digit==3) threes++;
			if(digit==2) twos++;
			total=(total+digit)%9;
		}
		cout << check(total, threes, twos);
		
	}
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
// Source: https://usaco.guide/general/io

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

string check(long long total, int threes, int twos) {
	if(total%9==0) {
		return "YES\n";
	} else {
		for(int x=threes; x>=0; x--) {
			for(int y=twos; y>=0; y--) {
				if((total+(6*x + y*2))%9==0) {
					return "YES\n";
				}
			}
		}
	}
	return "NO\n";
}

int main() {
	int n; cin >> n;

	for(int i=0; i<n; i++) {
		long long k; cin >> k;
		
		long long total = 0;
		int threes = 0;
		int twos = 0;
		for(char j : to_string(k)) {
			int digit = j - '0';
			if(digit==3) threes++;
			if(digit==2) twos++;
			total+=digit;
		}
		cout << check(total, threes, twos);
		
	}
}

Submission (verdict: Wrong answer on test 3):
// Source: https://usaco.guide/general/io

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

string check(long long total, int threes, int twos) {
	if(total%9==0) {
		return "YES\n";
	} else {
		for(int x=threes; x>=0; x--) {
			for(int y=twos; y>=0; y--) {
				if((total+(6*x + y*2))%9==0) {
					return "YES\n";
				}
			}
		}
	}
	return "NO\n";
}

int main() {
	int n; cin >> n;

	for(int i=0; i<n; i++) {
		long long k; cin >> k;
		
		long long total = 0;
		int threes = 0;
		int twos = 0;
		for(char j : to_string(k)) {
			int digit = j - '0';
			if(digit==3) threes++;
			if(digit==2) twos++;
			total=(total+digit)%9;
		}
		cout << check(total, threes, twos);
		
	}
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
/*
*   author: bobbyCodes
*/

#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/treepolicy.hpp>
//#define pbds tree<ll , null_type, less , rb_tree_tag, tree_order_static_node_update> 
#define ll long long
#define pb push_back
#define IM INT_MAX
#define IN INT_MIN
#define fo for(int i=0;i<n;i++){}
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
/* -------------------------------------------------------------------------------------------------------------
//ll gcd(ll a,ll b){for(ll i = min(a,b);i >=1;i--){if(!(a%i) && !(b%i)){return i;}}return 1;}
ll seiveOfErytosthesis(ll k,ll n = 1e6){vector<bool> v(n+1,true);v[0]=v[1]=false;for(ll i =2; i*i<= n; i++){for(ll j =2*i; j <=n ; j+=i){if(v[j]){v[j]=false;}}}ll num=0;for(ll i=k; i<=1e6;i++){if(v[i]){num= i;break;}}return num;}
-------------------------------------------------------------------------------------------------------------
*/
//using namespace __gnu_pbds

void init_code(){
    fast_io;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 
}
void solve(){
   int n;
   cin>>n;

   vector<int>v(n);

   for(int i=0; i<n; i++){
      cin>>v[i];
   }

   int now=n;

   long long ans= -1e18;

   for(int i=0; i<n ;i ++){
      long long sum=0;
      for(int i=0; i< now; i++ ){
         sum+=v[i];
      }
      if(i==0){
         ans=max(ans,sum);
      }else{
         ans=max(ans, max(sum,(-sum)));
      }
      for(int i=0; i<now-1; i++){
         v[i]=v[i+1] - v[i];
      }
      now--;
   }
   cout<<ans<<endl;
}
int main() {
   init_code();
   int t = 1; cin >> t;
   while(t--){
         solve();
   }
   return 0;
}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

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

//#include "atcoder/all"

//using namespace atcoder;

using namespace std;

typedef long long int ll;



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



const ll MAXN = 5e5 + 16;

vector<ll> adj[MAXN];



int main(){

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    int t; cin >> t;

    for (;t--;) {

        ll n, l, r; cin >> n >> l >> r;

        vector<ll> a(n);

        for (auto &x : a) cin >> x;

        sort(all(a));

        ll sum = 0;

        for (int i = 0; i < r-l+1; i++) {

            sum += a[i];

        }

        cout << sum << '\n';

    }

}



Submission (verdict: Wrong answer on test 2):
#include "bits/stdc++.h"
//#include "atcoder/all"
//using namespace atcoder;
using namespace std;
typedef long long int ll;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t; cin >> t;
    for (;t--;) {
        ll n, l, r; cin >> n >> l >> r;
        vector<ll> a(n);
        ll mn = INT_MAX;
        for (auto& x : a) cin >> x, mn = min(mn, x);
        vector<ll> b = a;
        for (int i = 1; i < n; i++) a[i] += a[i-1];
        
        int len = r - l - 1, seq = 0, idx;
        if (len < 0) { cout << mn << '\n'; continue; }
        mn = INT_MAX;
        for (int i = len; i < n; i++) {
            ll prev = mn;
            if (seq > 0) mn = min(mn, a[i] - a[seq-1]);
            else mn = min(mn, a[i]);
            if (prev != mn) idx = i;
            ++seq;
        }
        ll minimum = INT_MAX;
        for (int i = 0; i < n; i++) {
            if (i <= idx && i >= idx - len) continue;
            minimum = min(minimum, b[i]);
        }
        cout << mn + minimum << '\n';

    }
}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)


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

//#include "atcoder/all"

//using namespace atcoder;

using namespace std;

typedef long long int ll;



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



const ll MAXN = 5e5 + 16;

vector<ll> adj[MAXN];



int main(){

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    int t; cin >> t;

    for (;t--;) {

        ll n, l, r; cin >> n >> l >> r;

        vector<ll> a(n);

        for (auto &x : a) cin >> x;

        sort(all(a));

        ll sum = 0;

        for (int i = 0; i < r-l+1; i++) {

            sum += a[i];

        }

        cout << sum << '\n';

    }

}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include "bits/stdc++.h"
//#include "atcoder/all"
//using namespace atcoder;
using namespace std;
typedef long long int ll;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t; cin >> t;
    for (;t--;) {
        ll n, l, r; cin >> n >> l >> r;
        vector<ll> a(n);
        ll mn = INT_MAX;
        for (auto& x : a) cin >> x, mn = min(mn, x);
        vector<ll> b = a;
        for (int i = 1; i < n; i++) a[i] += a[i-1];
        
        int len = r - l - 1, seq = 0, idx;
        if (len < 0) { cout << mn << '\n'; continue; }
        mn = INT_MAX;
        for (int i = len; i < n; i++) {
            ll prev = mn;
            if (seq > 0) mn = min(mn, a[i] - a[seq-1]);
            else mn = min(mn, a[i]);
            if (prev != mn) idx = i;
            ++seq;
        }
        ll minimum = INT_MAX;
        for (int i = 0; i < n; i++) {
            if (i <= idx && i >= idx - len) continue;
            minimum = min(minimum, b[i]);
        }
        cout << mn + minimum << '\n';

    }
}


Submission (verdict: Accepted):
#include "bits/stdc++.h"
//#include "atcoder/all"
//using namespace atcoder;
using namespace std;
typedef long long int ll;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t; cin >> t;
    for (;t--;) {
        ll n, l, r; cin >> n >> l >> r;
        vector<ll> a(n), la, ra, seg;
        for (auto& x : a) cin >> x;
        --l, --r;
        for (int i = 0; i < l; i++) {
            la.emplace_back(a[i]);
        }
        for (int i = r + 1; i < n; i++) {
            ra.emplace_back(a[i]);
        }
        ll sum = 0;
        for (int i = l; i <= r; i++) {
            sum += a[i];
            seg.emplace_back(a[i]);
        }
        ll mn = sum;
        sort(all(la)); sort(all(ra));
        
        sum = 0;
        vector<ll> cmb = seg;
        cmb.insert(cmb.end(), all(la));
        sort(all(cmb));
        for (int i = 0; i <= r-l; i++) {
            sum += cmb[i];
        }
        mn = min(sum, mn);

        sum = 0;
        cmb = seg;
        cmb.insert(cmb.end(), all(ra));
        sort(all(cmb));
        for (int i = 0; i <= r-l; i++) {
            sum += cmb[i];
        }
        mn = min(sum, mn);
        cout << mn << '\n';
    }
}
Problem: 2052A - Adrenaline Rush
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 7):
n = int(input())
a = list(map(int, input().split()))
d = dict()
cnt = 0
res = []
for i in range(n):
    d[a[i]] = i
b = a.copy()
for i in range(n):
    for j in range(n-1):
        if b[j] > b[j+1]:
            res.append((b[j], b[j+1]))
            b[j], b[j+1] = b[j+1], b[j]
res = res[::-1]

for i in range(1, n+1):
    for j in range(d[i]+1, n):
        if a[j] > i:
            res.append((a[j], i))
    for j in range(n-1, d[i], -1):
        if a[j] > i:
            res.append((i, a[j]))

print(len(res))
for t in res:
    print(t[0], t[1])



Submission (verdict: Accepted):
n = int(input())
b = list(map(int, input().split()))
d = dict()
cnt = 0
res = []
for i in range(n):
    d[b[i]] = i

a = [i+1 for i in range(n)]
for i in range(n):
    for j in range(n-1):
        if a[j] < a[j+1]:
            res.append((a[j+1], a[j]))
            a[j], a[j+1] = a[j+1], a[j]

for i in range(n):
    for j in range(n-1):
        if d[a[j]] > d[a[j+1]]:
            res.append((a[j+1], a[j]))
            a[j], a[j+1] = a[j+1], a[j]

print(len(res))
for t in res:
    print(t[0], t[1])
Problem: 2052A - Adrenaline Rush
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 7):
n = int(input())
a = list(map(int, input().split()))
d = dict()
cnt = 0
res = []
for i in range(n):
    d[a[i]] = i

for i in range(1, n+1):
    for j in range(i+1, n+1):
        if d[i] > d[j]:
            res.append((j, i))

for i in range(1, n+1):
    for j in range(d[i]+1, n):
        if a[j] > i:
            res.append((a[j], i))
    for j in range(n-1, d[i], -1):
        if a[j] > i:
            res.append((i, a[j]))

print(len(res))
for t in res:
    print(t[0], t[1])



Submission (verdict: Wrong answer on test 7):
n = int(input())
a = list(map(int, input().split()))
d = dict()
cnt = 0
res = []
for i in range(n):
    d[a[i]] = i
b = a.copy()
for i in range(n):
    for j in range(n-1):
        if b[j] > b[j+1]:
            res.append((b[j], b[j+1]))
            b[j], b[j+1] = b[j+1], b[j]
res = res[::-1]

for i in range(1, n+1):
    for j in range(d[i]+1, n):
        if a[j] > i:
            res.append((a[j], i))
    for j in range(n-1, d[i], -1):
        if a[j] > i:
            res.append((i, a[j]))

print(len(res))
for t in res:
    print(t[0], t[1])
Problem: 2052A - Adrenaline Rush
Language: PyPy 3-64


Submission (verdict: Wrong answer on test 4):
n = int(input())
a = list(map(int, input().split()))
d = dict()
cnt = 0
res = []
for i in range(n):
    d[a[i]] = i

for i in range(1, n+1):
    for j in range(i+1, n+1):
        res.append((j, i))
        if d[i] < d[j]:
            res.append((i, j))

print(len(res))
for t in res:
    print(t[0], t[1])
Problem: 2052A - Adrenaline Rush
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 4):
n = int(input())
a = list(map(int, input().split()))
d = dict()
cnt = 0
res = []
for i in range(n):
    d[a[i]] = i

for i in range(1, n+1):
    for j in range(i+1, n+1):
        res.append((j, i))
        if d[i] < d[j]:
            res.append((i, j))

print(len(res))
for t in res:
    print(t[0], t[1])



Submission (verdict: Wrong answer on test 7):
n = int(input())
a = list(map(int, input().split()))
d = dict()
cnt = 0
res = []
for i in range(n):
    d[a[i]] = i

for i in range(1, n+1):
    for j in range(i+1, n+1):
        if d[i] > d[j]:
            res.append((j, i))

for i in range(1, n+1):
    for j in range(d[i]+1, n):
        if a[j] > i:
            res.append((a[j], i))
    for j in range(n-1, d[i], -1):
        if a[j] > i:
            res.append((i, a[j]))

print(len(res))
for t in res:
    print(t[0], t[1])