ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 4):
// we will be back Stronger ISA
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
const int mod = 1e9 + 7;
/*
 * Make Sure That you understand the Statment Correctly
 * try always divide and conquer approach
 * always try to look at numbers in binary
 * look at all Edge Cases before submitting any problem
 * always try to look for smart brute force approaches
 */
void solve(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0;i < n;i++) cin >> a[i];
    vector<pair<int , int>> ans;
    for (int i = 0;i < n;i++){
        for (int j = i + 1;j < n;j++){
            if (a[i] < a[j]) ans.emplace_back(a[j] , a[i]) , ans.emplace_back(a[i] , a[j]);
            else ans.emplace_back(a[i] , a[j]);
        }
    }
    cout << ans.size() <<'\n';
    for(auto [x , y]: ans) cout << x << ' ' << y <<'\n';
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("text.out", "r" , stdin);
    int t = 1;
//    cin >>t;
    while(t--) solve();
}


Submission (verdict: Wrong answer on test 1):
// we will be back Stronger ISA
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
const int mod = 1e9 + 7;
/*
 * Make Sure That you understand the Statment Correctly
 * try always divide and conquer approach
 * always try to look at numbers in binary
 * look at all Edge Cases before submitting any problem
 * always try to look for smart brute force approaches
 */
void solve(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0;i < n;i++) cin >> a[i];
    vector<pair<int , int>> ans;
    for (int i = 0;i < n;i++){
        vector<pair<int, int>> stepn;
        for (int j = i + 1;j < n;j++){
            if (a[i] < a[j]) ans.emplace_back(a[j] , a[i]) , stepn.emplace_back(a[i] , a[j]);
            else ans.emplace_back(a[i] , a[j]);
        }
        reverse(begin(stepn), end(stepn));
        for (auto x : stepn) ans.push_back(x);
    }
    cout << ans.size() <<'\n';
    for(auto [x , y]: ans) cout << x << ' ' << y <<'\n';
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("text.out", "r" , stdin);
    int t = 1;
//    cin >>t;
    while(t--) solve();
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 4):
// we will be back Stronger ISA
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
const int mod = 1e9 + 7;
/*
 * Make Sure That you understand the Statment Correctly
 * try always divide and conquer approach
 * always try to look at numbers in binary
 * look at all Edge Cases before submitting any problem
 * always try to look for smart brute force approaches
 */
void solve(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0;i < n;i++) cin >> a[i];
    vector<pair<int , int>> ans;
    for (int i = 0;i < n;i++){
        for (int j = i + 1;j < n;j++){
            if (a[i] < a[j]) ans.emplace_back(a[j] , a[i]) , ans.emplace_back(a[i] , a[j]);
            else ans.emplace_back(a[i] , a[j]);
        }
    }
    cout << ans.size() <<'\n';
    for(auto [x , y]: ans) cout << x << ' ' << y <<'\n';
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("text.out", "r" , stdin);
    int t = 1;
//    cin >>t;
    while(t--) solve();
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
 
/*                                             सम्भवामि युगे युगे ॥                                      */

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define inf std::numeric_limits<int>::max();
#define yup cout<<"YES"<<endl;
#define nope cout<<"NO"<<endl;
const int MOD = 1e9+7;
ll binaryExpo(ll base, ll e)
{
    ll res=1;
    while (e)
    {
        if(e&1) (res *= base)%=MOD;
        (base *= base)%=MOD; e/=2;
    } return res;
}

void solutioN()
{
    ll n; cin>> n;
    vector<ll> v(n), anotherV;
    ll sum = 0;
    for(int i=0; i<n; i++)
    {
        cin>> v[i];
        anotherV.push_back(v[i]);
        sum += v[i];
    }


    while ((anotherV.size())>1)
    {
        if(anotherV[0]>anotherV[(anotherV.size())-1])
        {
            reverse(anotherV.begin(),anotherV.end());
        } 

        vector<ll> tempV;
        for(int i=1; i<anotherV.size(); i++)
        {
            tempV.push_back(anotherV[i]-anotherV[i-1]);
        }

        anotherV.clear();
        anotherV = tempV;
        ll ss = accumulate(tempV.begin(),tempV.end(),0);
        sum = max(sum, ss);
    }
    cout<< sum <<endl;
}

void solve_mul()
{ ll test; cin>>test; while (test--) {solutioN();} }

void solve_single(){solutioN();}

int main()
{
    ios_base::sync_with_stdio(false);
    solve_mul();
    //solve_single();
}






/*                                Ⓒ All rights reserved to Prnc                              */

Submission (verdict: Wrong answer on test 2):
 
/*                                             सम्भवामि युगे युगे ॥                                      */

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define inf std::numeric_limits<int>::max();
#define yup cout<<"YES"<<endl;
#define nope cout<<"NO"<<endl;
const int MOD = 1e9+7;
ll binaryExpo(ll base, ll e)
{
    ll res=1;
    while (e)
    {
        if(e&1) (res *= base)%=MOD;
        (base *= base)%=MOD; e/=2;
    } return res;
}

void solutioN()
{
    ll n; cin>> n;
    vector<ll> v(n), anotherV;
    ll sum = 0;
    for(int i=0; i<n; i++)
    {
        cin>> v[i];
        anotherV.push_back(v[i]);
        sum += v[i];
    }


    while ((anotherV.size())>1)
    {
        vector<ll> chkSorted;
        chkSorted = anotherV;
        sort(chkSorted.begin(),chkSorted.end());

        if(chkSorted!=anotherV) reverse(anotherV.begin(),anotherV.end());

        vector<ll> tempV;
        for(int i=1; i<anotherV.size(); i++)
        {
            tempV.push_back(anotherV[i]-anotherV[i-1]);
        }

        anotherV.clear();
        anotherV = tempV;
        ll ss = accumulate(tempV.begin(),tempV.end(),0);
        sum = max(sum, ss);
    }
    cout<< sum <<endl;
}

void solve_mul()
{ ll test; cin>>test; while (test--) {solutioN();} }

void solve_single(){solutioN();}

int main()
{
    ios_base::sync_with_stdio(false);
    solve_mul();
    //solve_single();
}






/*                                Ⓒ All rights reserved to Prnc                              */
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
 
/*                                             सम्भवामि युगे युगे ॥                                      */

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define inf std::numeric_limits<int>::max();
#define yup cout<<"YES"<<endl;
#define nope cout<<"NO"<<endl;
const int MOD = 1e9+7;
ll binaryExpo(ll base, ll e)
{
    ll res=1;
    while (e)
    {
        if(e&1) (res *= base)%=MOD;
        (base *= base)%=MOD; e/=2;
    } return res;
}

void solutioN()
{
    ll n; cin>> n;
    vector<ll> v(n), anotherV;
    ll sum = 0;
    for(int i=0; i<n; i++)
    {
        cin>> v[i];
        anotherV.push_back(v[i]);
        sum += v[i];
    }


    while ((anotherV.size())>1)
    {
        if(anotherV[0]>anotherV[(anotherV.size())-1])
        {
            reverse(anotherV.begin(),anotherV.end());
        } 

        vector<ll> tempV;
        for(int i=1; i<anotherV.size(); i++)
        {
            tempV.push_back(anotherV[i]-anotherV[i-1]);
        }

        anotherV.clear();
        anotherV = tempV;
        ll ss = accumulate(tempV.begin(),tempV.end(),0);
        sum = max(sum, ss);
    }
    cout<< sum <<endl;
}

void solve_mul()
{ ll test; cin>>test; while (test--) {solutioN();} }

void solve_single(){solutioN();}

int main()
{
    ios_base::sync_with_stdio(false);
    solve_mul();
    //solve_single();
}






/*                                Ⓒ All rights reserved to Prnc                              */
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#pragma GCC optimize("O3")

#pragma GCC optimize("Ofast,unroll-loops")

#include<iostream>

#include<vector>

#include<cstring>

#include<algorithm>

#include<cmath>

#include<map>

#include<set>

#include<queue>

#include<stack>

using namespace std;



typedef long long ll;

typedef long double ld;

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

#define F first 

#define S second 



#define MAXN  1

ll spf[MAXN];



void sieve(){

    spf[1] = 1;

    for (ll i=2; i<MAXN; i++)

        spf[i] = i;

 

    for (ll i=4; i<MAXN; i+=2)

        spf[i] = 2;

 

    for (ll i=3; i*i<MAXN; i++){

        if (spf[i] == i){

            for (ll j=i*i; j<MAXN; j+=i)

                if (spf[j]==j)

                    spf[j] = i;

        }

    }

}

vector<ll> getFactorization(ll x){

    vector<ll> ret;

    while (x != 1){

        ret.push_back(spf[x]);

        x = x / spf[x];

    }

    return ret;

}

ll ABS(ll a){

    if(a<0)return -a;

    return a;

}

ll getIthBit(ll n,ll i){

    ll mask=(1<<i);

    return  (n&mask)>0 ? 1:0;

}

ll GCD(ll a, ll b){

    return b == 0 ? a : GCD(b, a % b);   

}

ll digitsum(ll n){

    ll ret=0;

    while(n){

        ret += n%10;  

        n/=10;

    }

    return ret;

}

ll power(ll x,ll n){

    if(n==0)    return 1;

    ll a = power(x,n/2);

    if(n%2==0)  return (a*a);

    else    return (a*a*x);

}

ll LCM(ll a, ll b){

    return(a*(b/GCD(a,b)));

}

ll RoundUp(ll num,ll deno){

    if(num%deno==0)return(num/deno);

    else return ((num/deno)+1);

}



void solve()

{

    ll n;

    cin>>n;

    vector<ll> a(n);

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

    {

        cin>>a[i];

    }

    set<pair<ll, ll>> s;

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

    {

        for(ll j=i+1; j<n; j++)

        {

            s.insert({a[i], a[j]});

            s.insert({a[j], a[i]});

        }

    }

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

    {

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

        {

            if(a[j]>a[i])

            {

                s.erase({a[i], a[j]});

            }

        }

    }

    cout<<s.size()<<endl;

    for(auto it: s)

    {

        cout<<it.first<<" "<<it.second<<endl;

    }

}



int main(){

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    ll t = 1;

    while(t--)

    {

        solve();

    }

    return 0;

}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int               long long
#define endl              "\n"
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll
#define INF 1000000000000000000
#define mod 1000000007
#define esp 10e-7
const int mx=1e2+7;
int a[mx];
void solve()
{
  int n;
  cin>>n;
  vector<int>v(n);
  int ans=0;
  for(int i=0;i<n;i++)
    {cin>>a[i];v[i]=a[i];ans+=a[i];}
   
   if(n==1){
    cout<<a[0]<<endl;
    return;
   }

  for(int times=0;times<n-1;times++){
      for(int j=0;j<n-times-1;j++)
        v[j]=v[j+1]-v[j];
      // for(int i=0;i<n-times-1;i++)
      //   cout<<v[i]<<" ";
      // cout<<endl;
  }
  

  ans=max(ans,abs(v[0]));
  for(int i=0;i<n;i++)
    v[i]=a[n-i-1];
  
  for(int times=0;times<n-1;times++){
      for(int j=0;j<n-times-1;j++)
        v[j]=v[j+1]-v[j];

      // for(int i=0;i<n-times-1;i++)
      //   cout<<v[i]<<" ";
      // cout<<endl;
  }

  ans=max(ans,abs(v[0]));
  cout<<ans<<endl;
}
signed main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //freopen("error.txt" , "w" , stderr);
    //#endif 
    IOS
    int t=1,n;
    cin>>t;
   
    while(t--)
    {
      solve();
    }
    
    return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int               long long
#define endl              "\n"
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll
#define INF 1000000000000000000
#define mod 1000000007
#define esp 10e-7
const int mx=1e2+7;
int a[mx];
void solve()
{
  int n;
  cin>>n;
  vector<int>v(n);
  int ans=0;
  for(int i=0;i<n;i++)
    {cin>>a[i];v[i]=a[i];ans+=a[i];}
   
   if(n==1){
    cout<<a[0]<<endl;
    return;
   }

  for(int times=0;times<n-1;times++){
      for(int j=0;j<n-times-1;j++)
        v[j]=v[j+1]-v[j];
      int sum=0;

      for(int i=0;i<n-times-1;i++)
        sum+=v[i];
      ans=max(ans,max(sum,-sum));
  }
  

  
  cout<<ans<<endl;
}
signed main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //freopen("error.txt" , "w" , stderr);
    //#endif 
    IOS
    int t=1,n;
    cin>>t;
   
    while(t--)
    {
      solve();
    }
    
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int               long long
#define endl              "\n"
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll
#define INF 1000000000000000000
#define mod 1000000007
#define esp 10e-7
const int mx=1e2+7;
int a[mx];
void solve()
{
  int n;
  cin>>n;
  vector<int>v(n);
  int ans=0;
  for(int i=0;i<n;i++)
    {cin>>a[i];v[i]=a[i];ans+=a[i];}
  

  for(int times=0;times<n-1;times++){
      for(int j=0;j<n-times-1;j++)
        v[j]=v[j+1]-v[j];
      // for(int i=0;i<n-times-1;i++)
      //   cout<<v[i]<<" ";
      // cout<<endl;
  }
  

  ans=max(ans,abs(v[0]));
  for(int i=0;i<n;i++)
    v[i]=a[n-i-1];
  
  for(int times=0;times<n-1;times++){
      for(int j=0;j<n-times-1;j++)
        v[j]=v[j+1]-v[j];

      // for(int i=0;i<n-times-1;i++)
      //   cout<<v[i]<<" ";
      // cout<<endl;
  }

  ans=max(ans,abs(v[0]));
  cout<<ans<<endl;
}
signed main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //freopen("error.txt" , "w" , stderr);
    //#endif 
    IOS
    int t=1,n;
    cin>>t;
   
    while(t--)
    {
      solve();
    }
    
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int               long long
#define endl              "\n"
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll
#define INF 1000000000000000000
#define mod 1000000007
#define esp 10e-7
const int mx=1e2+7;
int a[mx];
void solve()
{
  int n;
  cin>>n;
  vector<int>v(n);
  int ans=0;
  for(int i=0;i<n;i++)
    {cin>>a[i];v[i]=a[i];ans+=a[i];}
  

  for(int times=0;times<n-1;times++){
      for(int j=0;j<n-times-1;j++)
        v[j]=v[j+1]-v[j];
      // for(int i=0;i<n-times-1;i++)
      //   cout<<v[i]<<" ";
      // cout<<endl;
  }
  

  ans=max(ans,abs(v[0]));
  for(int i=0;i<n;i++)
    v[i]=a[n-i-1];
  
  for(int times=0;times<n-1;times++){
      for(int j=0;j<n-times-1;j++)
        v[j]=v[j+1]-v[j];

      // for(int i=0;i<n-times-1;i++)
      //   cout<<v[i]<<" ";
      // cout<<endl;
  }

  ans=max(ans,abs(v[0]));
  cout<<ans<<endl;
}
signed main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //freopen("error.txt" , "w" , stderr);
    //#endif 
    IOS
    int t=1,n;
    cin>>t;
   
    while(t--)
    {
      solve();
    }
    
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int               long long
#define endl              "\n"
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll
#define INF 1000000000000000000
#define mod 1000000007
#define esp 10e-7
const int mx=1e2+7;
int a[mx];
void solve()
{
  int n;
  cin>>n;
  vector<int>v(n);
  int ans=0;
  for(int i=0;i<n;i++)
    {cin>>a[i];v[i]=a[i];ans+=a[i];}
   
   if(n==1){
    cout<<a[0]<<endl;
    return;
   }

  for(int times=0;times<n-1;times++){
      for(int j=0;j<n-times-1;j++)
        v[j]=v[j+1]-v[j];
      // for(int i=0;i<n-times-1;i++)
      //   cout<<v[i]<<" ";
      // cout<<endl;
  }
  

  ans=max(ans,abs(v[0]));
  for(int i=0;i<n;i++)
    v[i]=a[n-i-1];
  
  for(int times=0;times<n-1;times++){
      for(int j=0;j<n-times-1;j++)
        v[j]=v[j+1]-v[j];

      // for(int i=0;i<n-times-1;i++)
      //   cout<<v[i]<<" ";
      // cout<<endl;
  }

  ans=max(ans,abs(v[0]));
  cout<<ans<<endl;
}
signed main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //freopen("error.txt" , "w" , stderr);
    //#endif 
    IOS
    int t=1,n;
    cin>>t;
   
    while(t--)
    {
      solve();
    }
    
    return 0;
}
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)

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

int main(){
    int t;
    std::cin>>t;
    for(int i=0; i<t; i++){
        int n;
        std::cin>>n;
        int arr[n];
        for(int j=0;j<n;j++){
            std::cin>>arr[j];
        }
        bool ans=true;
        for(int k=1;k<n-1;k++){
            if(!((arr[k]>arr[k-1]&&arr[k]<arr[k+1])||(arr[k]<arr[k-1]&&arr[k]>arr[k+1])))
                ans=false;
        }
        if(ans==true) std::cout<<"YES"<<std::endl;
        else std::cout<<"NO"<<std::endl;
    return 0;
}
}

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

int main(){
    int t;
    std::cin>>t;
    while(t--){
        int n;
        std::cin>>n;
        int arr[n];
        for(int j=0;j<n;j++){
            std::cin>>arr[j];
        } 
        int odd=0;
        int even=0;
        for(int i=0;i<n;i++){
            if(i%2==0) even+=arr[i];
            else odd+=arr[i];
        }
        int oddPlace=n/2;
        int evenPlace=(n+1)/2;

        if(odd%oddPlace==0 && even%evenPlace==0 && odd/oddPlace==even/evenPlace) std::cout<<"Yes"<<std::endl;

        else std::cout<<"No"<<std::endl;
    }
        
    return 0;
}
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)

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

int main(){
    int t;
    std::cin>>t;
    while(t--){
        int n;
        std::cin>>n;
        int arr[n];
        for(int j=0;j<n;j++){
            std::cin>>arr[j];
        } 
        int odd=0;
        int even=0;
        for(int i=0;i<n;i++){
            if(i%2==0) even+=arr[i];
            else odd+=arr[i];
        }
        int oddPlace=n/2;
        int evenPlace=(n+1)/2;

        if(odd%oddPlace==0 && even%evenPlace==0 && odd/oddPlace==even/evenPlace) std::cout<<"Yes"<<std::endl;

        else std::cout<<"No"<<std::endl;
    }
        
    return 0;
}

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

int main(){
    int t;
    std::cin>>t;
    while(t--){
        int n;
        std::cin>>n;
        int arr[n];
        for(int j=0;j<n;j++){
            std::cin>>arr[j];
        } 
        long long odd=0;
        long long even=0;
        for(int i=0;i<n;i++){
            if(i%2==0) even+=arr[i];
            else odd+=arr[i];
        }
        long oddPlace=n/2;
        long evenPlace=(n+1)/2;

        if(odd%oddPlace==0 && even%evenPlace==0 && odd/oddPlace==even/evenPlace) std::cout<<"Yes"<<std::endl;

        else std::cout<<"No"<<std::endl;
    }
        
    return 0;
}
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)


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

int main(){
    int t;
    std::cin>>t;
    for(int i=0; i<t; i++){
        int n;
        std::cin>>n;
        int arr[n];
        for(int j=0;j<n;j++){
            std::cin>>arr[j];
        }
        bool ans=true;
        for(int k=1;k<n-1;k++){
            if(!((arr[k]>arr[k-1]&&arr[k]<arr[k+1])||(arr[k]<arr[k-1]&&arr[k]>arr[k+1])))
                ans=false;
        }
        if(ans==true) std::cout<<"YES"<<std::endl;
        else std::cout<<"NO"<<std::endl;
    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 ll long long
#define ff first
#define ss second
const ll N = 1e5 + 1, M = 1e9 + 7;

void solve()
{
    int n;
    cin >> n;
    int a[n];
    set<int> st;
    for (int i = 0; i < n; i++)
    cin >> a[i], st.insert(i + 1);
    vector<pair<int, int>> ans;
    for (int i = 0; i < n; i++)
    {
        for (int j = a[i] + 1; j <= n; j++)
        {
            if (st.count(j))
            {
                ans.push_back({j, a[i]});
                ans.push_back({a[i], j});
            }
        }
        for (int j = 1; j < a[i]; j++)
        {
            if (st.count(j))
            {
                ans.push_back({a[i], j});
            }
        }
        st.erase(a[i]);
    }
    cout << (int)ans.size() << "\n";
    for (auto &x : ans)
    cout << x.first << " " << x.second << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int 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 ll long long
#define ff first
#define ss second
const ll N = 1e5 + 1, M = 1e9 + 7;

void solve()
{
    int n;
    cin >> n;
    int a[n];
    set<int> st;
    for (int i = 0; i < n; i++)
    cin >> a[i], st.insert(i + 1);
    vector<pair<int, int>> ans;
    for (int i = 0; i < n; i++)
    {
        for (int j = a[i] + 1; j <= n; j++)
        {
            if (st.count(j))
            {
                ans.push_back({j, a[i]});
                ans.push_back({a[i], j});
            }
        }
        for (int j = 1; j < a[i]; j++)
        {
            if (st.count(j))
            {
                ans.push_back({a[i], j});
            }
        }
        st.erase(a[i]);
    }
    cout << (int)ans.size() << "\n";
    for (auto &x : ans)
    cout << x.first << " " << x.second << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
const ll N = 1e5 + 1, M = 1e9 + 7;

void solve()
{
    int n;
    cin >> n;
    int a[n];
    set<int> st;
    for (int i = 0; i < n; i++)
    cin >> a[i], st.insert(i + 1);
    vector<pair<int, int>> ans;
    for (int i = 0; i < n; i++)
    {
        for (int j = a[i] + 1; j <= n; j++)
        {
            if (st.count(j))
            {
                ans.push_back({j, a[i]});
            }
        }
        for (int j = a[i] + 1; j <= n; j++)
        {
            if (st.count(j))
            {
                ans.push_back({a[i], j});
            }
        }
        for (int j = 1; j < a[i]; j++)
        {
            if (st.count(j))
            {
                ans.push_back({a[i], j});
            }
        }
        st.erase(a[i]);
    }
    cout << (int)ans.size() << "\n";
    for (auto &x : ans)
    cout << x.first << " " << x.second << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}