ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<algorithm>
using namespace std;
bool descending(long long a, long long b) {
    return a > b;  // 返回true表示a排在b前面（降序）
}
int a[55];
long long  sum = 0;
            long long ans = 0;
int main()
{
    int t;cin>>t;
    while(t--)
    {
        sum = 0,ans = 0;
        int n;cin>>n;
        for(int i=0;i<n;i++) 
        {
            cin>>a[i];
            sum += a[i];
        }
        if(n == 1)
        {
            cout<<a[0]<<endl;
        }
        else 
        {
            while(n--)
            {
                for(int i=0;i<n;i++)//2
                {
                    a[i] = a[i+1] - a[i];       
                    ans += a[i];
                } 
                sum = max(sum,abs(ans));
                reverse(a,a+n);//1
                ans = 0;
                for(int i=0;i<n;i++)
                {
                    ans += a[i];
                }
                sum = max(ans,abs(sum));
            }
           cout<<sum<<endl;
        }
    }
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<algorithm>
using namespace std;
bool descending(long long a, long long b) {
    return a > b;  // 返回true表示a排在b前面（降序）
}
long long a[55];
long long  sum = 0;
long long ans = 0;
int main()
{
    int t;cin>>t;
    while(t--)
    {
        sum = 0,ans = 0;
        int n;cin>>n;
        for(int i=0;i<n;i++) 
        {
            cin>>a[i];
            sum += a[i];
        }
        if(n == 1)
        {
            cout<<a[0]<<endl;
        }
        else 
        {
            while(n--)
            {
                for(int i=0;i<n;i++)//2
                {
                    a[i] = a[i+1] - a[i];       
                    ans += a[i];
                } 
                sum = max(sum,abs(ans));
                reverse(a,a+n);//1
                ans = 0;
                for(int i=0;i<n;i++)
                {
                    ans += a[i];
                }
                sum = max(ans,abs(sum));
            }
           cout<<sum<<endl;
        }
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<algorithm>
using namespace std;
bool descending(long long a, long long b) {
    return a > b;  // 返回true表示a排在b前面（降序）
}
int a[55];
int main()
{
    int t;cin>>t;
    while(t--)
    {
        int n;cin>>n;
        for(int i=0;i<n;i++) 
        {
            cin>>a[i];
        }
        if(n == 1)
        {
            cout<<a[0]<<endl;
        }
        else 
        {
            long long  sum = 0;
            long long ans = 0;
            while(n--)
            {
                for(int i=0;i<n;i++)//2
                {
                    a[i] = a[i+1] - a[i];       
                    ans += a[i];
                } 
                sum = max(sum,abs(ans));
                reverse(a,a+n);//1
                ans = 0;
                for(int i=0;i<n;i++)
                {
                    ans += a[i];
                }
                sum = max(ans,abs(sum));
            }
           cout<<sum<<endl;
        }
    }
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<algorithm>
using namespace std;
bool descending(long long a, long long b) {
    return a > b;  // 返回true表示a排在b前面（降序）
}
int a[55];
long long  sum = 0;
            long long ans = 0;
int main()
{
    int t;cin>>t;
    while(t--)
    {
        sum = 0,ans = 0;
        int n;cin>>n;
        for(int i=0;i<n;i++) 
        {
            cin>>a[i];
            sum += a[i];
        }
        if(n == 1)
        {
            cout<<a[0]<<endl;
        }
        else 
        {
            while(n--)
            {
                for(int i=0;i<n;i++)//2
                {
                    a[i] = a[i+1] - a[i];       
                    ans += a[i];
                } 
                sum = max(sum,abs(ans));
                reverse(a,a+n);//1
                ans = 0;
                for(int i=0;i<n;i++)
                {
                    ans += a[i];
                }
                sum = max(ans,abs(sum));
            }
           cout<<sum<<endl;
        }
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<algorithm>
using namespace std;
bool descending(long long a, long long b) {
    return a > b;  // 返回true表示a排在b前面（降序）
}
int a[55];
int main()
{
    int t;cin>>t;
    while(t--)
    {
        int n;cin>>n;
        for(int i=0;i<n;i++) 
        {
            cin>>a[i];
        }
        if(n == 1)
        {
            cout<<a[0]<<endl;
        }
        else 
        {
            long long  sum = 0;
            long long ans = 0;
            while(n--)
            {
                for(int i=0;i<n;i++)//2
                {
                    a[i] = a[i+1] - a[i];       
                    ans += a[i];
                } 
                sum = max(sum,abs(ans));
                reverse(a,a+n);//1
                ans = 0;
                for(int i=0;i<n;i++)
                {
                    ans += a[i];
                }
                sum = max(ans,abs(sum));
            }
           cout<<sum<<endl;
        }
    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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

#include<algorithm>

using namespace std;

bool descending(int a, int b) {

    return a > b;  // 返回true表示a排在b前面（降序）

}

int main()

{

    int t;cin>>t;

    while(t--)

    {

        int n,l,r;

        cin>>n>>l>>r;

        l--,r--;

        int a[100005];

        int b[100005];

        int c[100005];

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

        {

            cin>>a[i];

            b[i] = a[i];

            c[i] = a[i];

        }

        sort(b,b+r+1,descending);

        // cout<<"b"<<endl;

        // for(int i=0;i<n;i++)

        // {

        //     cout<<b[i]<<" ";

        // }

        // cout<<endl;

        sort(c+l,c+n);

        // cout<<"c"<<endl;

        // for(int i  = 0 ;i<n;i++)

        // {

        //     cout<<c[i]<<" ";

        // }

        int ans1 = 0;

        int ans2 = 0;

        for(int i =l;i<=r ;i++)

        {

            ans1 += b[i];

            ans2 += c[i];

        }

        cout<<min(ans1,ans2)<<endl;

    }





//23335

    return 0;

}

Submission (verdict: Wrong answer on test 8):
#include<iostream>
#include<algorithm>
using namespace std;
bool descending(long int a, long int b) {
    return a > b;  // 返回true表示a排在b前面（降序）
}
int main()
{
    int t;cin>>t;
    while(t--)
    {
        int n,l,r;
        cin>>n>>l>>r;
        l--,r--;
        long int a[100005];
        long int b[100005];
        long int c[100005];
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
            b[i] = a[i];
            c[i] = a[i];
        }
        sort(b,b+r+1,descending);
        // cout<<"b"<<endl;
        // for(int i=0;i<n;i++)
        // {
        //     cout<<b[i]<<" ";
        // }
        // cout<<endl;
        sort(c+l,c+n);
        // cout<<"c"<<endl;
        // for(int i  = 0 ;i<n;i++)
        // {
        //     cout<<c[i]<<" ";
        // }
        long int ans1 = 0;
        long int ans2 = 0;
        for(int i =l;i<=r ;i++)
        {
            ans1 += b[i];
            ans2 += c[i];
        }
        cout<<min(ans1,ans2)<<endl;
    }


//23335
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Compilation error):
#include<iostream>
#include<algorithm>
using namespace std;
bool descending(long long  a, long long   b) {
    return a > b;  // 返回true表示a排在b前面（降序）
}
int main()
{
    int t;cin>>t;
    while(t--)
    {
        int n,l,r;
        cin>>n>>l>>r;
        l--,r--;
        long long  a[100005];
        long long  b[100005];
        long long  c[100005];
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
            b[i] = a[i];
            c[i] = a[i];
        }
        sort(b,b+r+1,descending);
        // cout<<"b"<<endl;
        // for(int i=0;i<n;i++)
        // {
        //     cout<<b[i]<<" ";
        // }
        // cout<<endl;
        sort(c+l,c+n);
        // cout<<"c"<<endl;
        // for(int i  = 0 ;i<n;i++)
        // {
        //     cout<<c[i]<<" ";
        // }
        long long   ans1 = 0;
        long long   ans2 = 0;
        for(int i =l;i<=r ;i++)
        {
            ans1 += b[i];
            ans2 += c[i];
        }
        cout<<min(ans1,ans2)<<endl;
    }


//23335
    return 0;
}#include<iostream>
#include<algorithm>
using namespace std;
bool descending(long long  a, long long   b) {
    return a > b;  // 返回true表示a排在b前面（降序）
}
int main()
{
    int t;cin>>t;
    while(t--)
    {
        int n,l,r;
        cin>>n>>l>>r;
        l--,r--;
        long long  a[100005];
        long long  b[100005];
        long long  c[100005];
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
            b[i] = a[i];
            c[i] = a[i];
        }
        sort(b,b+r+1,descending);
        // cout<<"b"<<endl;
        // for(int i=0;i<n;i++)
        // {
        //     cout<<b[i]<<" ";
        // }
        // cout<<endl;
        sort(c+l,c+n);
        // cout<<"c"<<endl;
        // for(int i  = 0 ;i<n;i++)
        // {
        //     cout<<c[i]<<" ";
        // }
        long long   ans1 = 0;
        long long   ans2 = 0;
        for(int i =l;i<=r ;i++)
        {
            ans1 += b[i];
            ans2 += c[i];
        }
        cout<<min(ans1,ans2)<<endl;
    }


//23335
    return 0;
}

Submission (verdict: Accepted):
#include<iostream>
#include<algorithm>
using namespace std;
bool descending(long long a, long long b) {
    return a > b;  // 返回true表示a排在b前面（降序）
}
long long  a[100005];
long long  b[100005];
long long  c[100005];
int main()
{
    int t;cin>>t;
    while(t--)
    {
        long long  n,l,r;
        cin>>n>>l>>r;
        l--,r--;
        for(long long i=0;i<n;i++)
        {
            cin>>a[i];
            b[i] = a[i];
            c[i] = a[i];
        }
        sort(b,b+r+1,descending);

        sort(c+l,c+n);

        long long   ans1 = 0;
        long long   ans2 = 0;
        for(long long i =l;i<=r ;i++)
        {
            ans1 += b[i];
            ans2 += c[i];
        }
        cout<<min(ans1,ans2)<<endl;
    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int t;cin>>t;
    while(t--)
    {
        int n,l,r;
        cin>>n>>l>>r;
        int a[100005];
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        sort(a,a+n);
        int count = r-l+1;
        int ans = 0;
        for(int i =0;i<n && count>0;i++,count--)
        {
            ans += a[i];
        }
        cout<<ans<<endl;
    }


//23335
    return 0;
}

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

#include<algorithm>

using namespace std;

bool descending(int a, int b) {

    return a > b;  // 返回true表示a排在b前面（降序）

}

int main()

{

    int t;cin>>t;

    while(t--)

    {

        int n,l,r;

        cin>>n>>l>>r;

        l--,r--;

        int a[100005];

        int b[100005];

        int c[100005];

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

        {

            cin>>a[i];

            b[i] = a[i];

            c[i] = a[i];

        }

        sort(b,b+r+1,descending);

        // cout<<"b"<<endl;

        // for(int i=0;i<n;i++)

        // {

        //     cout<<b[i]<<" ";

        // }

        // cout<<endl;

        sort(c+l,c+n);

        // cout<<"c"<<endl;

        // for(int i  = 0 ;i<n;i++)

        // {

        //     cout<<c[i]<<" ";

        // }

        int ans1 = 0;

        int ans2 = 0;

        for(int i =l;i<=r ;i++)

        {

            ans1 += b[i];

            ans2 += c[i];

        }

        cout<<min(ans1,ans2)<<endl;

    }





//23335

    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int t;cin>>t;
    while(t--)
    {
        int n,l,r;
        cin>>n>>l>>r;
        int a[100005];
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        sort(a,a+n);
        int count = r-l+1;
        int ans = 0;
        for(int i =0;i<n && count>0;i++,count--)
        {
            ans += a[i];
        }
        cout<<ans<<endl;
    }


//23335
    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)


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

// अहं कृत्स्नस्य जगतः प्रभवः प्रलयस्तथा ।।6।।

using namespace std;

#define IOS                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define endl "\n"
#define int long long
typedef unsigned long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define fi first
#define se second
#define all(arr) arr.begin(), arr.end()
#define MP make_pair
#define pb push_back
#define repeat(i, st, n) for (int i = st; i < n; i++)
const int mod = 1e9 + 7;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
void print(vi &v)
{
    for (auto it : v)
        cout << it << " ";
    cout << endl;
}
vector<int> temp;
vector<vector<int>> cc;
void dfs(int vertex, vector<bool> & vis,vector<pair<int, vector<int>>> &v){
    vis[vertex] = true;
    temp.pb(vertex);
    for(auto child : v[vertex].second){
        if(vis[child]) continue;
        dfs(child, vis, v);
    }
}
int connectedComponent(vector<pair<int, vector<int>>> &v, int n){
    vector<bool> vis(n + 1, false); int ans = 0;
    for(int i = 1; i <= n; i++){
        if(!vis[i]){
            ans++;
            temp.clear();
            dfs(i, vis, v);
            cc.pb(temp);
        }
    }
    return ans;
}
void solve()
{
    int n; cin >> n;
    vector<pair<int,vector<int>>> v(n + 1);
    for(int i = 0; i < n - 1; i++){
        int x, y; cin >> x >> y;
        v[x].second.pb(y);
        v[y].second.pb(x);
    }
    for(int i = 1; i <= n; i++) v[i].first = v[i].second.size();
    vector<int> degree(n + 1);
    for(int i = 1; i <= n; i++) degree[i] = v[i].first;
    // print(degree); 
    int ind = 0, deg = 0;
    for(int i = 1; i <= n; i++){
        if(v[i].first > deg){
            deg = v[i].first;
            ind = i;
        }
    }
    vector<int> visited(n + 1, 0);
    visited[ind] = 1;
    for(auto it : v[ind].second) visited[it] = 1;
    v[ind].first = 0;
    int ans = deg; 
    int deg1 = 0, deg2 = 0;
    bool flag = 0;
    for(int i = 1; i <= n; i++){\
        // cout << v[i].first << " ";
        if(visited[i] == 0){
            if(v[i].first > deg1){
                deg1 = v[i].first;
            }
        } else {
            if(v[i].first > deg2){
                deg2 = v[i].first;
            }
        }
    }
    cout << max(ans + deg1 - 1, ans + deg2 - 2) << endl;
}

signed main()
{
    IOS

#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)


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

#define ll long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);

ll MOD = 1e9 + 7;

ll fastPower(ll x, ll n) {
    ll ans = 1;
    while(n > 0) {
        if(n % 2 == 1) ans = ans * x;
        x = x * x;
        n /= 2;
    }
    return ans;
}

set<ll> divisors(ll n) 
{ 
    set<ll> res;
    for (int i=1; i * i<=n; i++) { 
        if (n%i == 0) { 
            res.insert(i);
            res.insert(n / i);
        } 
    } 
    return res;
} 

vector<ll> primeFact(ll n) {
    vector<ll> res;
    for(ll i=2; i * i <= n; ++i) {
        while(n % i == 0) {
            res.push_back(i);
            n /= i;
        }
    }
    if(n != 1) res.push_back(n);
    return res;
}

ll gcd(ll a,ll b) {
  ll R;
  while ((a % b) > 0)  {
    R = a % b;
    a = b;
    b = R;
  }
  return b;
}

string decimalToBinary(ll n) {
    string binary = "";
    while (n > 0) {
        binary = to_string(n % 2) + binary;
        n /= 2;
    }
    return binary;
}

void solve(vector<ll> v) {
    ll n = v.size();
    ll ans = 0;
    ll cur = 0;
    for(ll i=0; i<n; ++i) {
        ans += v[i];
    }
    ans = abs(ans);
    while(n > 1) {
        vector<ll> v2;
        cur = 0;
        for(ll i=0; i<n - 1; ++i) {
            ll num1 = v[i + 1];
            ll num2 = v[i];
            ll dif = num1 - num2;
            v2.push_back(dif);
            cur += abs(dif);
        }
        v.clear();
        for(ll i=0; i<n - 1; ++i) {
            v.push_back(v2[i]);
        }
        v2.clear();
        n--;
        ans = max(ans, cur);
    }
    cout << ans << "\n";
}

int main() {
    fastio;
    ll t;
    cin >> t;
    while(t--) {
        ll n;
        cin >> n;
        vector<ll> v;
        for(ll i=0; i<n; ++i) {
            ll a;
            cin >> a;
            v.push_back(a);
        }
        solve(v);
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

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

using namespace std;
using pii=pair<int,int>;

signed main(){
    cin.tie(nullptr)->sync_with_stdio(0);
    cout.tie(nullptr)->sync_with_stdio(0);
    int n;
    cin>>n;
    vector<int> lst(n+1);
    vector<int> now(n+1);
    for(int i=1; i<=n ; i++){
        cin>>lst[i];
        now[i]=i;
    }
    vector<pii> ans;
    vector<vector<bool>> vis(n+1,vector<bool>(n+1,true));
    for(int i=1; i<=n  ; i++){
        if(now[i]!=lst[i]){
            int p=0;
            int tar=lst[i];
            for(int j=1; j<=n; j++){
                if(now[j]==tar){
                    p=j; 
                    break;
                }
            }
            ans.push_back({now[i],now[p]});
            swap(now[i],now[p]);
            //cout<<now[i]<<' '<<now[p]<<'\n';
            vis[now[i]][now[p]]=vis[now[p]][now[i]]=false;
        }
    }
    for(int i=1,u; i<=n; i++){
        u=now[i];
        for(int j=1,v; j<=n; j++){
            v=now[j];
            if(i==j) continue;
            if(vis[u][v]&&i<j){
                vis[u][v]=vis[v][u]=false;
                ans.push_back({v,u});
                ans.push_back({u,v});
            }
        }
    }
    cout<<ans.size()<<'\n';
    for(auto x :ans ){
        cout<<x.first<<' '<<x.second<<'\n';
    }
}

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

using namespace std;
using pii=pair<int,int>;

signed main(){
    cin.tie(nullptr)->sync_with_stdio(0);
    cout.tie(nullptr)->sync_with_stdio(0);
    int n;
    cin>>n;
    vector<int> lst(n+1);
    vector<int> now(n+1);
    for(int i=1; i<=n ; i++){
        cin>>lst[i];
        now[i]=i;
    }
    vector<pii> ans;
    vector<vector<bool>> vis(n+1,vector<bool>(n+1,true));
    for(int i=1; i<=n  ; i++){
        if(now[i]!=lst[i]){
            int p=0;
            int tar=lst[i];
            for(int j=1; j<=n; j++){
                if(now[j]==tar){
                    p=j; 
                    break;
                }
            }
            ans.push_back({now[p],now[i]});
            swap(now[i],now[p]);
            //cout<<now[i]<<' '<<now[p]<<'\n';
            vis[now[i]][now[p]]=vis[now[p]][now[i]]=false;
        }
    }
    for(int i=1,u; i<=n; i++){
        u=now[i];
        for(int j=1,v; j<=n; j++){
            v=now[j];
            if(i==j) continue;
            if(vis[u][v]&&i<j){
                vis[u][v]=vis[v][u]=false;
                ans.push_back({v,u});
                ans.push_back({u,v});
            }
        }
    }
    cout<<ans.size()<<'\n';
    for(auto x :ans ){
        cout<<x.first<<' '<<x.second<<'\n';
    }
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

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

using namespace std;
using pii=pair<int,int>;

signed main(){
    cin.tie(nullptr)->sync_with_stdio(0);
    cout.tie(nullptr)->sync_with_stdio(0);
    int n;
    cin>>n;
    vector<int> lst(n+1);
    vector<int> now(n+1);
    for(int i=1; i<=n ; i++){
        cin>>lst[i];
        now[i]=i;
    }
    vector<pii> ans;
    vector<vector<bool>> vis(n+1,vector<bool>(n+1,true));
    for(int i=1; i<=n ; i++){
        if(now[i]!=lst[i]){
            int p=0;
            int tar=lst[i];
            for(int j=i+1; j<=n ; j++){
                if(now[j]==tar){
                    p=j; break;
                }
            }
            for(int j=p ; j>i ; j--){
                ans.push_back({now[j],now[j-1]});
                swap(now[j],now[j-1]);
                vis[now[j]][now[j-1]]=vis[now[j-1]][now[j]]=false;
            }
        }
    }
    //cout<<"!!"<<' '<<ans.size()<<'\n';
    //for(auto it: now) cout<<it<<' ';
    //cout<<'\n';
    for(int i=1; i<n ; i++){
        int j=i+1;
        for(int v ; j<=n; j++){
            v=now[j];
            if(vis[now[j-1]][v]){
                //cout<<"??"<<u<<' '<<v<<'\n';
                ans.push_back({v,now[j-1]});
                swap(now[j],now[j-1]);
                vis[now[j-1]][v]=vis[v][now[j-1]]=false;
            }
            else{
                break;
            }
        }
        j--;
        for(int v; j>i ; j--){
            //cout<<"NMSL "<<i<<' '<<j<<'\n';
            v=now[j];
            ans.push_back({now[j],now[j-1]});
            swap(now[j],now[j-1]);
        }
    }
    cout<<ans.size()<<'\n';
    for(auto x :ans ){
        cout<<x.first<<' '<<x.second<<'\n';
    }
}

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

using namespace std;
using pii=pair<int,int>;

signed main(){
    cin.tie(nullptr)->sync_with_stdio(0);
    cout.tie(nullptr)->sync_with_stdio(0);
    int n;
    cin>>n;
    vector<int> lst(n+1);
    vector<int> now(n+1);
    for(int i=1; i<=n ; i++){
        cin>>lst[i];
        now[i]=i;
    }
    // for(auto it:now) cout<<it<<' ';
    // cout<<'\n';
    vector<pii> ans;
    vector<vector<bool>> vis(n+1,vector<bool>(n+1,true));
    for(int i=1 ; i<n ; i++){
        for(int j=n ; j>i ;  j--){
            ans.push_back({now[j],now[j-1]});
            swap(now[j],now[j-1]);
        }
    }
    for(int i=1; i<=n; i++){
        if(now[i]!=lst[i]){
            int p,tar=lst[i];
            for(int j=i+1 ; j<=n ; j++){
                if(now[j]==tar){
                    p=j;
                    break;
                }
            }
            for(int j=p ; j>i ; j--){
                    ans.push_back({now[j],now[j-1]});
                swap(now[j],now[j-1]);
            }
        }
    }
    // for(auto it:now) cout<<it<<' ';
    // cout<<'\n';
    cout<<ans.size()<<'\n';
    for(auto x :ans ){
        cout<<x.first<<' '<<x.second<<'\n';
    }
}