ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 16):
#include <bits/stdc++.h>

using namespace std;

 

typedef long long ll;

#define vi vector <int> 

#define vll vector <ll> 

#define vp vector<pair<ll,ll>>

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

#define rep(i,a) for(int i=0;i<a;i++)

#define fa(v) for (auto &it : (v))

#define ff first

#define ss second

#define pb push_back

#define pl pair<ll ,ll> 

 

    int rec(  vector<vector<int>> &dp,  string a,string b , string c, int i, int j){

        if(i+j>=c.size())return 0 ;



        // dp[i][j] == minimun changes req after index i , j ...

        

        if( dp[i][j]!=-1)return dp[i][j] ;



            

            int x = 1e7, y = 1e7, z= 1e7, w = 1e7 ;

                

            if(i<a.size()){

                x=rec(dp,a,b,c,i+1,j)+1;

                if(c[i+j]==a[i]) z= rec(dp,a,b,c,i+1,j) ;

                z=min(x,z);

            }



            if(j<b.size()){y=rec(dp,a,b,c,i,j+1)+1;

                if(c[i+j]==b[j])w = rec( dp, a,b,c ,i, j+1) ;

                w= min(y,w);

            }

//cout<<x<<z<<y<<x<<endl;

            return dp[i][j]= min(z,w) ;

    



        return 0 ;

    }



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

int t; cin>>t;

while (t--){ 



    string a,b,c; cin>>a>>b>>c;

    int n =a.size(), m = b.size() ;

    vector<vector<int>> dp(n+1, vector<int>(m+1,-1)) ;



    cout<<rec(dp, a,b,c,0,0)<<endl ;





} 

}

Submission (verdict: Time limit exceeded on test 16):
#include <bits/stdc++.h>

using namespace std;

 

typedef long long ll;

#define vi vector <int> 

#define vll vector <ll> 

#define vp vector<pair<ll,ll>>

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

#define rep(i,a) for(int i=0;i<a;i++)

#define fa(v) for (auto &it : (v))

#define ff first

#define ss second

#define pb push_back

#define pl pair<ll ,ll> 

 

    int rec(  vector<vector<int>> &dp,  string a,string b , string c, int i, int j){

        if(i+j>=c.size())return 0 ;



        // dp[i][j] == minimun changes req after index i , j ...

        

        if( dp[i][j]!=-1)return dp[i][j] ;



            

            int x = 1e7, y = 1e7, z= 1e7, w = 1e7 ;

                

            if(i<a.size()){

               

                if(c[i+j]==a[i]) z= rec(dp,a,b,c,i+1,j) ;

                else{ x=rec(dp,a,b,c,i+1,j)+1;}

                z=min(x,z);

            }



            if(j<b.size()){

                if(c[i+j]==b[j])w = rec( dp, a,b,c ,i, j+1) ;

                else{y=rec(dp,a,b,c,i,j+1)+1;}

                w= min(y,w);

            }

//cout<<x<<z<<y<<x<<endl;

            return dp[i][j]= min(z,w) ;

    



        return 0 ;

    }



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

int t; cin>>t;

while (t--){ 



    string a,b,c; cin>>a>>b>>c;

    int n =a.size(), m = b.size() ;

    vector<vector<int>> dp(n+1, vector<int>(m+1,-1)) ;



    cout<<rec(dp, a,b,c,0,0)<<endl ;





} 

}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
    #include <bits/stdc++.h>
    #include <iostream>
    using namespace std;
    #define Ahmed cin.tie(0), cout.tie(0), cin.sync_with_stdio(0), cout.sync_with_stdio(0);

    int main()
    {
        Ahmed
        int t;
        cin>>t;
        while(t--)
        {
            int n;
            cin>>n;
            int arr[n];
            for (int i = 0; i < n; ++i) {
                cin>>arr[i];
            }
            long long Max = LONG_LONG_MIN;
            for (int x = n; x > 1; --x) {
                long long sum= 0;
                for (int i = 0; i < x; ++i) {
                    sum+= arr[i];
                    arr[i] = arr[i] - arr[i + 1];
                }
                Max = max(Max, sum);
            }
            long long a;
            if(n > 1)
                 a = abs(arr[0]);
            else
                a = arr[0];
            cout<<max(Max, a)<<endl;
        }
    }


Submission (verdict: Wrong answer on test 2):
    #include <bits/stdc++.h>
    #include <iostream>
    using namespace std;
    #define Ahmed cin.tie(0), cout.tie(0), cin.sync_with_stdio(0), cout.sync_with_stdio(0);

    int main()
    {
        Ahmed
        int t;
        cin>>t;
        while(t--)
        {
            int n;
            cin>>n;
            int arr[n];
            for (int i = 0; i < n; ++i) {
                cin>>arr[i];
            }
            long long Max = LONG_LONG_MIN;
            for (int x = n-1; x > 0; --x) {
                long long sum= 0;
                for (int i = 0; i < x; ++i) {
                    sum+= arr[i];
                    arr[i] = arr[i + 1] - arr[i];
                }
                sum+= arr[x];
                Max = max(Max, sum);
            }
            long long a;
            if(n > 1)
                 a = abs(arr[0]);
            else
                a = arr[0];
            cout<<max(Max, a)<<endl;
        }
    }
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
    #include <bits/stdc++.h>
    #include <iostream>
    using namespace std;
    #define Ahmed cin.tie(0), cout.tie(0), cin.sync_with_stdio(0), cout.sync_with_stdio(0);

    int main()
    {
        Ahmed
        int t;
        cin>>t;
        while(t--)
        {
            int n;
            cin>>n;
            int arr[n];
            for (int i = 0; i < n; ++i) {
                cin>>arr[i];
            }
            long long Max = LONG_LONG_MIN;
            for (int x = n; x > 1; --x) {
                long long sum= 0;
                for (int i = 0; i < x; ++i) {
                    sum+= arr[i];
                    arr[i] = arr[i] - arr[i + 1];
                }
                Max = max(Max, sum);
            }
            long long a;
            if(n > 1)
                 a = abs(arr[0]);
            else
                a = arr[0];
            cout<<max(Max, a)<<endl;
        }
    }
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
    #include <bits/stdc++.h>
    #include <iostream>
    using namespace std;
    #define Ahmed cin.tie(0), cout.tie(0), cin.sync_with_stdio(0), cout.sync_with_stdio(0);

    int main()
    {
        Ahmed
        int t;
        cin>>t;
        while(t--)
        {
            int n;
            cin>>n;
            int arr[n];
            for (int i = 0; i < n; ++i) {
                cin>>arr[i];
            }
            long long Max = LONG_LONG_MIN;
            for (int x = n-1; x > 0; --x) {
                long long sum= 0;
                for (int i = 0; i < x; ++i) {
                    sum+= arr[i];
                    arr[i] = arr[i + 1] - arr[i];
                }
                sum+= arr[x];
                Max = max(Max, sum);
            }
            long long a;
            if(n > 1)
                 a = abs(arr[0]);
            else
                a = arr[0];
            cout<<max(Max, a)<<endl;
        }
    }


Submission (verdict: Wrong answer on test 2):
    #include <bits/stdc++.h>
    #include <iostream>
    using namespace std;
    #define Ahmed cin.tie(0), cout.tie(0), cin.sync_with_stdio(0), cout.sync_with_stdio(0);

    int main()
    {
        Ahmed
        int t;
        cin>>t;
        while(t--)
        {
            int n;
            cin>>n;
            long long arr[n];
            for (int i = 0; i < n; ++i) {
                cin>>arr[i];
            }
            long long Max = LONG_LONG_MIN;
            for (int x = n-1; x > 0; --x) {
                long long sum= 0;
                for (int i = 0; i < x; ++i) {
                    sum+= arr[i];
                    arr[i] = arr[i + 1] - arr[i];
                }
                sum+= arr[x];
                Max = max(Max, sum);
            }
            long long a;
            if(n > 1)
                 a = abs(arr[0]);
            else
                a = arr[0];
            cout<<max(Max, a)<<endl;
        }
    }
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
    #include <bits/stdc++.h>
    #include <iostream>
    using namespace std;
    #define Ahmed cin.tie(0), cout.tie(0), cin.sync_with_stdio(0), cout.sync_with_stdio(0);

    int main()
    {
        Ahmed
        int t;
        cin>>t;
        while(t--)
        {
            int n;
            cin>>n;
            long long arr[n];
            for (int i = 0; i < n; ++i) {
                cin>>arr[i];
            }
            long long Max = LONG_LONG_MIN;
            for (int x = n-1; x > 0; --x) {
                long long sum= 0;
                for (int i = 0; i < x; ++i) {
                    sum+= arr[i];
                    arr[i] = arr[i + 1] - arr[i];
                }
                sum+= arr[x];
                Max = max(Max, sum);
            }
            long long a;
            if(n > 1)
                 a = abs(arr[0]);
            else
                a = arr[0];
            cout<<max(Max, a)<<endl;
        }
    }


Submission (verdict: Accepted):
    #include <bits/stdc++.h>
    #include <iostream>
    using namespace std;
    #define Ahmed cin.tie(0), cout.tie(0), cin.sync_with_stdio(0), cout.sync_with_stdio(0);

    int main()
    {
        Ahmed
        int t;
        cin>>t;
        while(t--)
        {
            int n;
            cin>>n;
            long long arr[n];
            for (int i = 0; i < n; ++i) {
                cin>>arr[i];
            }
            bool first = true;
            long long Max = LONG_LONG_MIN;
            for (int x = n-1; x > 0; --x) {
                long long sum= 0;
                for (int i = 0; i < x; ++i) {
                    sum+= arr[i];
                    arr[i] = arr[i + 1] - arr[i];
                }
                sum+= arr[x];
                if (first) { Max = max(Max, sum); first = false; }
                else Max = max(Max, abs(sum));
                
            }
            long long a;
            if(n > 1)
                 a = abs(arr[0]);
            else
                a = arr[0];
            cout<<max(Max, a)<<endl;
        }
    }
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):


#include <bits/stdc++.h>



#define go ios::sync_with_stdio(0);cin.tie(0)

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

#define yes cout<<"YES"<<endl

#define no cout<<"NO"<<endl

#define vi vector<int>

#define vll vector<ll>

#define vl vector<l>



typedef long l;

typedef long long  ll;

typedef long long int lli;

typedef unsigned long long ull;



constexpr auto PI = 3.14159265358979323846;



using namespace std;



unsigned long long factorial(ll n) {

if (n == 0 || n == 1) {

return 1;

} else {

return n * factorial(n - 1);

}

}



bool isPrime(ll n) {

if (n == 1)

return false;

if (n == 2)

return true;

for (int i = 2; i <= sqrt(n); i++) {

if (n % i == 0)

return false;

}

return true;

}



ll smallestDiv(ll n) {

for (int i = 2; i <= sqrt(n); i++) {

if (n % i == 0) {

return i;

}

}

return n;

}



lli binaryToDecimal(string binary) {

lli decimal = 0;

int power = 0;



for (int i = binary.length() - 1; i >= 0; i--) {

if (binary[i] == '1') {

decimal += pow(2, power);

}

power++;

}

return decimal;

}



bool binarySearch(vector<ll>& a, ll target) {

ll left = 0, right = a.size() - 1;

while (left <= right) {

ll mid = left + (right - left) / 2;

if (a[mid] == target) {

return true;

} else if (a[mid] > target) {

right = mid - 1;

} else left = mid + 1;

}

return false;

}



int main() {

go;

int t; cin >> t;

while(t--) {

int n;

cin >> n;

vi v(n);

for(auto &e: v) cin >> e;







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

if(v[i] < v[i + 1]) {

v[i + 1] -= v[i];

v[i] = 0;

}

}



bool f = true;

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

if(v[i] > v[i + 1]){

f = false;

break;

}

}



if(f) yes;

else no;

}





}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define no cout << "NO\n"
#define yes cout << "YES\n"
#define all(x) begin(x) , end(x)
#define rall(x) rbegin(x) , rend(x)
#define AS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ll long long
ll const N=1e5+7;
int main() {
    AS
#ifndef ONLINE_JUDGE
freopen("Input.txt", "r", stdin);
    freopen("Output.txt", "w", stdout);
#endif
    int t=1;
    cin>>t;
    while (t--) {
        ll n;cin>>n;
    vector<int>v(n+1);
        for (int i=1;i<=n;i++) {
            cin>>v[i];
        }
        bool vald=1;
        for (int i=1;i<n;i++) {
            if (v[i]<=v[i-1]+v[i+1]) {
                if (v[i-1]<=v[i]&&v[i]<=v[i+1])continue;
                else {
                    v[i]-=v[i-1];
                }
            }else {
                vald=0;
                break;
            }
        }
        if (vald)yes;
        else no;
        }
        }


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define no cout << "NO\n"
#define yes cout << "YES\n"
#define all(x) begin(x) , end(x)
#define rall(x) rbegin(x) , rend(x)
#define AS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ll long long
ll const N=1e5+7;
int main() {
    AS
#ifndef ONLINE_JUDGE
freopen("Input.txt", "r", stdin);
    freopen("Output.txt", "w", stdout);
#endif
    int t=1;
    cin>>t;
    while (t--) {
        ll n;cin>>n;
    vector<int>v(n+1);
        for (int i=1;i<=n;i++) {
            cin>>v[i];
        }
        bool vald=1;
        for (int i=1;i<n;i++) {
            if (v[i]<v[i-1]+v[i+1]) {
                if (v[i-1]<=v[i]&&v[i]<=v[i+1])continue;
                else {
                    v[i]-=v[i-1];
                }
            }else {
                vald=0;
                break;
            }
        }
        if (vald)yes;
        else no;
        }
        }
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define no cout << "NO\n"
#define yes cout << "YES\n"
#define all(x) begin(x) , end(x)
#define rall(x) rbegin(x) , rend(x)
#define AS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ll long long
ll const N=1e5+7;
int main() {
    AS
#ifndef ONLINE_JUDGE
freopen("Input.txt", "r", stdin);
    freopen("Output.txt", "w", stdout);
#endif
    int t=1;
    cin>>t;
    while (t--) {
        ll n;cin>>n;
    vector<int>v(n+1);
        for (int i=1;i<=n;i++) {
            cin>>v[i];
        }
        bool vald=1;
        for (int i=1;i<n;i++) {
            if (v[i]<=v[i-1]+v[i+1]) {
                if (v[i-1]<=v[i]&&v[i]<=v[i+1])continue;
                else {
                    v[i]-=v[i-1];
                }
            }else {
                vald=0;
                break;
            }
        }
        if (vald)yes;
        else no;
        }
        }
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define no cout << "NO\n"
#define yes cout << "YES\n"
#define all(x) begin(x) , end(x)
#define rall(x) rbegin(x) , rend(x)
#define AS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ll long long
ll const N=1e5+7;
int main() {
    AS
#ifndef ONLINE_JUDGE
freopen("Input.txt", "r", stdin);
    freopen("Output.txt", "w", stdout);
#endif
    int t=1;
    cin>>t;
    while (t--) {
        ll n;cin>>n;
    vector<int>v(n+1);
        for (int i=1;i<=n;i++) {
            cin>>v[i];
        }
        bool vald=1;
        for (int i=1;i<n;i++) {
            if (v[i]<v[i-1]+v[i+1]) {
                if (v[i-1]<=v[i]&&v[i]<=v[i+1])continue;
                else {
                    v[i]-=v[i-1];
                }
            }else {
                vald=0;
                break;
            }
        }
        if (vald)yes;
        else no;
        }
        }


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define no cout << "NO\n"
#define yes cout << "YES\n"
#define all(x) begin(x) , end(x)
#define rall(x) rbegin(x) , rend(x)
#define AS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ll long long
ll const N=1e5+7;
int main() {
    AS
#ifndef ONLINE_JUDGE
freopen("Input.txt", "r", stdin);
    freopen("Output.txt", "w", stdout);
#endif
    int t=1;
    cin>>t;
    while (t--) {
        ll n;cin>>n;
    vector<int>v(n+1);
        for (int i=1;i<=n;i++) {
            cin>>v[i];
        }
        for (int i=1;i<n;i++) {
           int mn=min(v[i],v[i+1]);
            v[i]-=mn,v[i+1]-=mn;
        }
        if (is_sorted(all(v)))yes;
        else no;
        }
        }
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;
#define ll long long
int x[]={0,0,-1,1};
int y[]={-1,1,0,0};
char dir[]={'L','R','U','D'};
using pi = pair<ll,ll>;

void fast() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}


void solve() {
   ll n;
    cin>>n;
    vector<ll> v(n);
    for(ll i=0;i<n;i++) {
        cin>>v[i];
    }
    vector<pi>ans;
    for(ll i=n-1;i>=0;i--) {
        for(ll j=i+1;j<n;j++) {
           ans.push_back(pi(v[i],v[j]));
            ans.push_back(pi(v[j],v[i]));
        }
    }
reverse(ans.begin(),ans.end());

cout<<ans.size()<<endl;
    for(ll i=0;i<ans.size();i++) {
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    }

}


int main() {
    fast();

    int T = 1;
 // cin >> T;
    while (T--) {
        solve();

    }
    return 0;
}


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int x[]={0,0,-1,1};
int y[]={-1,1,0,0};
char dir[]={'L','R','U','D'};
using pi = pair<ll,ll>;

void fast() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}


void solve() {
   ll n;
    cin>>n;
    vector<ll> v(n);
    for(ll i=0;i<n;i++) {
        cin>>v[i];
    }
    vector<pi>ans;
    for(ll i=n-1;i>=0;i--) {
        for(ll j=i+1;j<n;j++) {
            if(v[i]<v[j]) {
                ans.push_back(pi(v[i],v[j]));
                ans.push_back(pi(v[j],v[i]));
            }
            else {
                ans.push_back(pi(v[i],v[j]));
            }
        }
    }
reverse(ans.begin(),ans.end());

cout<<ans.size()<<endl;
    for(ll i=0;i<ans.size();i++) {
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    }

}


int main() {
    fast();

    int T = 1;
 // cin >> T;
    while (T--) {
        solve();

    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int x[]={0,0,-1,1};
int y[]={-1,1,0,0};
char dir[]={'L','R','U','D'};
using pi = pair<ll,ll>;

void fast() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}


void solve() {
   ll n;
    cin>>n;
    vector<ll> v(n+1);
    map<ll,ll> mp;
    for(ll i=1;i<=n;i++) {
        cin>>v[i];
        mp[v[i]]=i;
    }
    vector<pi>ans;
   for(int i=n;i>=1;i--) {
       for(int j=i-1;j>=1;j--) {
           ans.emplace_back(i,j);
       }
       for(int j=i+1;j<=n;j++) {
           if(mp[i]<mp[j]) {
               ans.emplace_back(i,j);
           }
       }
   }

cout<<ans.size()<<endl;
    for(ll i=0;i<ans.size();i++) {
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    }

}


int main() {
    fast();

    int T = 1;
 // cin >> T;
    while (T--) {
        solve();

    }
    return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int x[]={0,0,-1,1};
int y[]={-1,1,0,0};
char dir[]={'L','R','U','D'};
using pi = pair<ll,ll>;

void fast() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}


void solve() {
   ll n;
    cin>>n;
    vector<pi> ans;
    map<ll,ll> vis;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        vis[x] = 1;
        for (int j = x + 1; j <= n; j++) {
            if (vis[j]) continue;
            ans.push_back({j, x});
        }
        for (int j = n; j > x; j--) {
            if (vis[j]) continue;
            ans.push_back({x, j});
        }
        for (int j = x - 1; j; j--) {
            if (vis[j]) continue;
            ans.push_back({x, j});
        }
    }
    cout << ans.size();
    for (auto &i : ans) cout << '\n' << i.first << ' ' << i.second;



}


int main() {
    fast();

    int T = 1;
 // cin >> T;
    while (T--) {
        solve();

    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int x[]={0,0,-1,1};
int y[]={-1,1,0,0};
char dir[]={'L','R','U','D'};
using pi = pair<ll,ll>;

void fast() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}


void solve() {
   ll n;
    cin>>n;
    vector<ll> v(n);
    for(ll i=0;i<n;i++) {
        cin>>v[i];
    }
    vector<pi>ans;
    for(ll i=0;i<n;i++) {
        for(ll j=i+1;j<n;j++) {
            if(v[i]>v[j]) {
                ans.push_back(pi(v[i],v[j]));
            }
            else {
                ans.push_back(pi(v[j],v[i]));
                ans.push_back(pi(v[i],v[j]));
            }
        }
    }


cout<<ans.size()<<endl;
    for(ll i=0;i<ans.size();i++) {
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    }

}


int main() {
    fast();

    int T = 1;
 // cin >> T;
    while (T--) {
        solve();

    }
    return 0;
}


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int x[]={0,0,-1,1};
int y[]={-1,1,0,0};
char dir[]={'L','R','U','D'};
using pi = pair<ll,ll>;

void fast() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}


void solve() {
   ll n;
    cin>>n;
    vector<ll> v(n);
    for(ll i=0;i<n;i++) {
        cin>>v[i];
    }
    vector<pi>ans;
    for(ll i=n-1;i>=0;i--) {
        for(ll j=i+1;j<n;j++) {
           ans.push_back(pi(v[i],v[j]));
            ans.push_back(pi(v[j],v[i]));
        }
    }
reverse(ans.begin(),ans.end());

cout<<ans.size()<<endl;
    for(ll i=0;i<ans.size();i++) {
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    }

}


int main() {
    fast();

    int T = 1;
 // cin >> T;
    while (T--) {
        solve();

    }
    return 0;
}