ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

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

void solve()
{
	string s;
	cin>>s;

	int cnt=0;
	int cnt2=0;
	int cnt3=0;

	for(auto x:s)
	{
		cnt+=x-'0';
		if(x=='2')
			cnt2++;
		if(x=='3')
			cnt3++;
	}

	bool chk=0;
	cnt=cnt%9;
	cnt2=min(cnt2,10);
	cnt3=min(cnt3,3);

	set<int> ss;
	for(int i=0;i<=cnt2;i++)
	{
		for(int j=0;j<=cnt3;j++)
		{
			ss.insert(cnt+2*i+3*j);
		}
	}

	for(auto x:ss)
		if(x%9==0)
			chk=1;

	if(chk)
		cout<<"YES";
	else
		cout<<"NO\n";
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int t=1;
	cin>>t;

	while(t--){
		solve();
	}
}

Submission (verdict: Accepted):
#include<iostream>
#include<set>
#include<algorithm>
using namespace std;

void solve()
{
	string s;
	cin>>s;

	int cnt=0;
	int cnt2=0;
	int cnt3=0;

	for(auto x:s)
	{
		cnt+=x-'0';
		if(x=='2')
			cnt2++;
		if(x=='3')
			cnt3++;
	}

	bool chk=0;
	cnt=cnt%9;
	cnt2=min(cnt2,10);
	cnt3=min(cnt3,3);

	set<int> ss;
	for(int i=0;i<=cnt2;i++)
	{
		for(int j=0;j<=cnt3;j++)
		{
			ss.insert(cnt+2*i+6*j);
		}
	}

	for(auto x:ss)
		if(x%9==0)
			chk=1;

	if(chk)
		cout<<"YES\n";
	else
		cout<<"NO\n";
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int t=1;
	cin>>t;

	while(t--){
		solve();
	}
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


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

void solve()
{
	string s;
	cin>>s;

	int cnt=0;
	int cnt2=0;

	for(auto x:s)
	{
		cnt+=x-'0';
		if(x=='2')
			cnt2++;
	}

	bool chk=0;
	x=x%9;
	cnt2=min(cnt2,10);

	set<int> s;
	for(int i=0;i<=cnt2;i++)
	{
		s.insert(x+2*i);
	}

	for(auto x:s)
		if(x%9==0)
			chk=1;

	if(chk)
		cout<<"YES";
	else
		cout<<"NO\n";
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int t=1;
	cin>>t;

	while(t--){
		solve();
	}
}
Problem: 2050E - Three Strings
Language: Java 8

Previous submission (verdict: Memory limit exceeded on test 14):
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while (t-->0){
           String a=sc.next();
           String b=sc.next();
           String c=sc.next();
           int[][][] f=new int[a.length()+1][b.length()+1][c.length()+1];
            for (int i = 0; i < a.length(); i++) {
                f[i+1][0][i+1]=f[i][0][i]+(a.charAt(i)==c.charAt(i)?0:1);
            }
            for (int i = 0; i < b.length(); i++) {
                f[0][i+1][i+1]=f[0][i][i]+(b.charAt(i)==c.charAt(i)?0:1);
            }
            for (int i = 0; i <= a.length(); i++) {
                for (int j = 0; j <= b.length(); j++) {
                    f[i][j][0]=0;
                }
            }
            f[0][0][0]=0;
            for (int i = 1; i <= a.length(); i++) {
                for (int j = 1; j <= b.length(); j++) {
                    for (int k = 1; k <= c.length(); k++) {
                        f[i][j][k]=Integer.MAX_VALUE;
                        f[i][j][k]=Math.min(f[i][j][k],f[i-1][j][k-1]+(a.charAt(i-1)==c.charAt(k-1)?0:1));
                        f[i][j][k]=Math.min(f[i][j][k],f[i][j-1][k-1]+(b.charAt(j-1)==c.charAt(k-1)?0:1));

                    }
                }
            }
            System.out.println(f[a.length()][b.length()][c.length()]);

        }
    }
}

Submission (verdict: Memory limit exceeded on test 14):
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while (t-->0){
           String a=sc.next();
           String b=sc.next();
           String c=sc.next();
           int[][][] f=new int[a.length()+1][b.length()+1][c.length()+1];
            for (int i = 0; i < a.length(); i++) {
                f[i+1][0][i+1]=f[i][0][i]+(a.charAt(i)==c.charAt(i)?0:1);
            }
            for (int i = 0; i < b.length(); i++) {
                f[0][i+1][i+1]=f[0][i][i]+(b.charAt(i)==c.charAt(i)?0:1);
            }
            for (int i = 0; i <= a.length(); i++) {
                for (int j = 0; j <= b.length(); j++) {
                    f[i][j][0]=0;
                }
            }
            f[0][0][0]=0;
            for (int i = 1; i <= a.length(); i++) {
                for (int j = 1; j <= b.length(); j++) {
                    for (int k = 1; k <= c.length(); k++) {
                        f[i][j][k]=Integer.MAX_VALUE;
                        f[i][j][k]=Math.min(f[i][j][k],f[i-1][j][k-1]+(a.charAt(i-1)==c.charAt(k-1)?0:1));
                        f[i][j][k]=Math.min(f[i][j][k],f[i][j-1][k-1]+(b.charAt(j-1)==c.charAt(k-1)?0:1));

                    }
                }
            }
            System.out.println(f[a.length()][b.length()][c.length()]);

        }
    }
}
Problem: 2050E - Three Strings
Language: Java 21

Previous submission (verdict: Memory limit exceeded on test 14):
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while (t-->0){
           String a=sc.next();
           String b=sc.next();
           String c=sc.next();
           int[][][] f=new int[a.length()+1][b.length()+1][c.length()+1];
            for (int[][] x : f) {
                for (int[] y : x) {
                    Arrays.fill(y,Integer.MAX_VALUE);
                }
            }

           System.out.println(dfs(f,a,b,c,a.length(),b.length(),c.length()));
        }
    }

    private static int dfs( int[][][] f, String a, String b, String c, int i, int j, int k) {
        if (k <= 0){
            return 0;
        }
        if (f[i][j][k]!= Integer.MAX_VALUE)return f[i][j][k];
        int min=Integer.MAX_VALUE;
        if (i>0){
            min=Math.min(min,dfs(f,a,b,c,i-1,j,k-1)+(a.charAt(i-1)==c.charAt(k-1)?0:1));

        }
        if (j>0){
            min=Math.min(min,dfs( f, a ,b,c,i,j-1,k-1)+(b.charAt(j-1)==c.charAt(k-1)?0:1));
        }
        return f[i][j][k]=min;
    }
}

Submission (verdict: Memory limit exceeded on test 14):
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while (t-->0){
           String a=sc.next();
           String b=sc.next();
           String c=sc.next();
           int[][][] f=new int[a.length()+1][b.length()+1][c.length()+1];
            for (int i = 0; i < a.length(); i++) {
                f[i+1][0][i+1]=f[i][0][i]+(a.charAt(i)==c.charAt(i)?0:1);
            }
            for (int i = 0; i < b.length(); i++) {
                f[0][i+1][i+1]=f[0][i][i]+(b.charAt(i)==c.charAt(i)?0:1);
            }
            for (int i = 0; i <= a.length(); i++) {
                for (int j = 0; j <= b.length(); j++) {
                    f[i][j][0]=0;
                }
            }
            f[0][0][0]=0;
            for (int i = 1; i <= a.length(); i++) {
                for (int j = 1; j <= b.length(); j++) {
                    for (int k = 1; k <= c.length(); k++) {
                        f[i][j][k]=Integer.MAX_VALUE;
                        f[i][j][k]=Math.min(f[i][j][k],f[i-1][j][k-1]+(a.charAt(i-1)==c.charAt(k-1)?0:1));
                        f[i][j][k]=Math.min(f[i][j][k],f[i][j-1][k-1]+(b.charAt(j-1)==c.charAt(k-1)?0:1));

                    }
                }
            }
            System.out.println(f[a.length()][b.length()][c.length()]);

        }
    }
}
Problem: 2050E - Three Strings
Language: Java 21


Submission (verdict: Time limit exceeded on test 6):
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while (t-->0){
           String a=sc.next();
           String b=sc.next();
           String c=sc.next();
           System.out.println(dfs(a,b,c,a.length()-1,b.length()-1,c.length()-1));
        }
    }

    private static int dfs( String a, String b, String c, int i, int j, int k) {
        if (k < 0){
            return 0;
        }
        int min=Integer.MAX_VALUE;
        if (i>=0){
            min=Math.min(min,dfs( a,b,c,i-1,j,k-1)+(a.charAt(i)==c.charAt(k)?0:1));

        }
        if (j>=0){
            min=Math.min(min,dfs( a ,b,c,i,j-1,k-1)+(b.charAt(j)==c.charAt(k)?0:1));
        }
        return  min;
    }
}
Problem: 2050E - Three Strings
Language: Java 21

Previous submission (verdict: Memory limit exceeded on test 14):
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while (t-->0){
           String a=sc.next();
           String b=sc.next();
           String c=sc.next();
           int[][][] f=new int[a.length()+1][b.length()+1][c.length()+1];
            for (int i = 0; i < a.length(); i++) {
                f[i+1][0][i+1]=f[i][0][i]+(a.charAt(i)==c.charAt(i)?0:1);
            }
            for (int i = 0; i < b.length(); i++) {
                f[0][i+1][i+1]=f[0][i][i]+(b.charAt(i)==c.charAt(i)?0:1);
            }
            for (int i = 0; i <= a.length(); i++) {
                for (int j = 0; j <= b.length(); j++) {
                    f[i][j][0]=0;
                }
            }
            f[0][0][0]=0;
            for (int i = 1; i <= a.length(); i++) {
                for (int j = 1; j <= b.length(); j++) {
                    for (int k = 1; k <= c.length(); k++) {
                        f[i][j][k]=Integer.MAX_VALUE;
                        f[i][j][k]=Math.min(f[i][j][k],f[i-1][j][k-1]+(a.charAt(i-1)==c.charAt(k-1)?0:1));
                        f[i][j][k]=Math.min(f[i][j][k],f[i][j-1][k-1]+(b.charAt(j-1)==c.charAt(k-1)?0:1));

                    }
                }
            }
            System.out.println(f[a.length()][b.length()][c.length()]);

        }
    }
}

Submission (verdict: Accepted):
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while (t-->0){
           String a=sc.next();
           String b=sc.next();
           String c=sc.next();
           int[][] f=new int[a.length()+1][b.length()+1];
            for (int i = 0; i < a.length(); i++) {
                f[i+1][0]=f[i][0]+(a.charAt(i)==c.charAt(i)?0:1);
            }
            for (int i = 0; i < b.length(); i++) {
                f[0][i+1]=f[0][i]+(b.charAt(i)==c.charAt(i)?0:1);
            }
            f[0][0]=0;
            for (int i = 1; i <= a.length(); i++) {
                for (int j = 1; j <= b.length(); j++) {
                    f[i][j]=Integer.MAX_VALUE;
                    f[i][j]=Math.min(f[i][j],f[i-1][j]+(a.charAt(i-1)==c.charAt(i+j-1)? 0 : 1));
                    f[i][j]=Math.min(f[i][j],f[i][j-1]+(b.charAt(j-1)==c.charAt(i+j-1)? 0 : 1));
                }
            }
            System.out.println(f[a.length()][b.length()]);
        }
    }
}
Problem: 2050E - Three Strings
Language: Java 21

Previous submission (verdict: Time limit exceeded on test 6):
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while (t-->0){
           String a=sc.next();
           String b=sc.next();
           String c=sc.next();
           System.out.println(dfs(a,b,c,a.length()-1,b.length()-1,c.length()-1));
        }
    }

    private static int dfs( String a, String b, String c, int i, int j, int k) {
        if (k < 0){
            return 0;
        }
        int min=Integer.MAX_VALUE;
        if (i>=0){
            min=Math.min(min,dfs( a,b,c,i-1,j,k-1)+(a.charAt(i)==c.charAt(k)?0:1));

        }
        if (j>=0){
            min=Math.min(min,dfs( a ,b,c,i,j-1,k-1)+(b.charAt(j)==c.charAt(k)?0:1));
        }
        return  min;
    }
}

Submission (verdict: Memory limit exceeded on test 14):
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while (t-->0){
           String a=sc.next();
           String b=sc.next();
           String c=sc.next();
           int[][][] f=new int[a.length()+1][b.length()+1][c.length()+1];
            for (int[][] x : f) {
                for (int[] y : x) {
                    Arrays.fill(y,Integer.MAX_VALUE);
                }
            }

           System.out.println(dfs(f,a,b,c,a.length(),b.length(),c.length()));
        }
    }

    private static int dfs( int[][][] f, String a, String b, String c, int i, int j, int k) {
        if (k <= 0){
            return 0;
        }
        if (f[i][j][k]!= Integer.MAX_VALUE)return f[i][j][k];
        int min=Integer.MAX_VALUE;
        if (i>0){
            min=Math.min(min,dfs(f,a,b,c,i-1,j,k-1)+(a.charAt(i-1)==c.charAt(k-1)?0:1));

        }
        if (j>0){
            min=Math.min(min,dfs( f, a ,b,c,i,j-1,k-1)+(b.charAt(j-1)==c.charAt(k-1)?0:1));
        }
        return f[i][j][k]=min;
    }
}
Problem: 2060D - Subtract Min Sort
Language: Java 21


Submission (verdict: Wrong answer on test 2):
import java.io.*;

import java.math.*;

import java.util.*;



public class Main {

static class IoScanner {

BufferedReader bf;

StringTokenizer st;

BufferedWriter bw;



public IoScanner() {

bf = new BufferedReader(new InputStreamReader(System.in));

st = new StringTokenizer("");

bw = new BufferedWriter(new OutputStreamWriter(System.out));

}



public String nextLine() throws IOException {

return bf.readLine();

}



public String next() throws IOException {

while (!st.hasMoreTokens()) {

st = new StringTokenizer(bf.readLine());

}

return st.nextToken();

}



public char nextChar() throws IOException {

return next().charAt(0);

}



public int nextInt() throws IOException {

return Integer.parseInt(next());

}



public long nextLong() throws IOException {

return Long.parseLong(next());

}



public double nextDouble() throws IOException {

return Double.parseDouble(next());

}



public float nextFloat() throws IOException {

return Float.parseFloat(next());

}



public BigInteger nextBigInteger() throws IOException {

return new BigInteger(next());

}



public BigDecimal nextDecimal() throws IOException {

return new BigDecimal(next());

}

}

static IoScanner sc = new IoScanner();

static PrintWriter out = new PrintWriter(System.out);

static final int mod=(int) (1e9+7);

public static void main(String[] args) throws Exception {

int T = 1;

T = sc.nextInt();

while (T-- > 0) {

solve();

}

out.flush();

}

static void solve() throws IOException {

int n=sc.nextInt();

int[] arr = new int[n];

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

arr[i]=sc.nextInt();

}

if (arr[0] > arr[1]) {

out.println("NO");

return;

}

for (int i = 1; i < arr.length; i++) {

if (arr[i - 1] < arr[i]) {

arr[i]-=arr[i-1];

arr[i-1]=0;

}

}

for (int i = 1; i < arr.length; i++) {

if (arr[i - 1] > arr[i]) {

out.println("NO");

return;

}

}

out.println("YES");

}

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

Previous submission (verdict: Wrong answer on test 4):
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include <queue>
#include <string.h>
#include <stack>

using namespace std;

typedef long long LL;	
typedef pair<int ,int> PII;

const int N = 2e5 + 10 ;
const int MOD = 1e9 + 7;
const int LOGN = 20;

int a[N]; 
void solve()
{
	int n;cin>>n;
	for(int i = 1; i <= n ; i++)cin>>a[i];
	vector<PII>ans;
	for(int i = 1; i <= n ; i++)
	{
		for(int j = i - 1; j >= 1 ; j--)
		{
			if (a[i] > a[j])
			{
				ans.push_back({a[i],a[j]});
				ans.push_back({a[j],a[i]});
			}
		}

	}
	for(int i = 1; i <= n ; i++)
			
		for(int j = i + 1; j <= n ; j++)
			{
				if (a[i] >= a[j])
					ans.push_back({a[i],a[j]});
			}	
//	int st = 1;
//	for(int i = 1; i < n ; i++)
//	{
//		if (a[i] < a[i + 1])continue;
//		else{
//			for(int r = i ; r > st ; r--)
//				for(int j = r - 1;  j >= st ; j--)
//					ans.push_back({a[r],a[j]});
//					
//			for(int j = st ; j < i ; j++)
//				for(int k = j + 1; k <= i ; k++)
//					ans.push_back({a[j],a[k]});
//			st = i + 1;
//		}
//	}
//	for(int r = n ; r > st ; r--)
//		for(int j = r - 1;  j >= st ; j--)
//			ans.push_back({a[r],a[j]});
//					
//	for(int j = st ; j < n ; j++)
//		for(int k = j + 1; k <= n ; k++)
//			ans.push_back({a[j],a[k]});
			
	cout << ans.size() << endl;
	for(int i = 0 ; i < ans.size(); i++)
		cout << ans[i].first << " " << ans[i].second << endl;
} 
int main()
{ 
	solve();
	return 0; 
}



Submission (verdict: Accepted):
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include <queue>
#include <string.h>
#include <stack>

using namespace std;

typedef long long LL;	
typedef pair<int ,int> PII;

const int N = 2e5 + 10 ;
const int MOD = 1e9 + 7;
const int LOGN = 20;

int a[N];
int s[N];
void solve()
{
	int n;cin>>n;
	for(int i = 1; i <= n ; i++)
	{
		cin>>a[i];
		s[i] = i;
	}
	
	vector<PII>ans;
	for(int k = n ; k >= 1; k--)
	{
		int pos = 0;
		for(int i = 1 ; i <= n ; i++)
			if (a[i] == k)pos = i;
		
		int st = 0;
		for(int i = pos - 1; i >= 1 ; i--)
		{
			if (a[i] > k)
			{
				st = i;
				break;
			}
		}
		for(int i = n ; i > 1 ; i--)
		{
			if (s[i - 1] == a[st])break;
			else{
				ans.push_back({s[i], s[i - 1]});
				swap(s[i],s[i - 1]);
			}
		}
		
	}
	
	cout << ans.size() << endl;
	for(int i = 0 ; i < ans.size(); i++)
		cout << ans[i].first << " " << ans[i].second << endl;
} 
int main()
{ 
	solve();
	return 0; 
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 4):
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include <queue>
#include <string.h>
#include <stack>

using namespace std;

typedef long long LL;	
typedef pair<int ,int> PII;

const int N = 2e5 + 10 ;
const int MOD = 1e9 + 7;
const int LOGN = 20;

int a[N]; 
void solve()
{
	int n;cin>>n;
	for(int i = 1; i <= n ; i++)cin>>a[i];
	vector<PII>ans;
	for(int i = 1; i <= n ; i++)
		for(int j = i + 1; j <= n ; j++)
		{
			if (a[i] >= a[j])
				ans.push_back({a[i],a[j]});
		}
	int st = 1;
	for(int i = 1; i < n ; i++)
	{
		if (a[i] < a[i + 1])continue;
		else{
			for(int r = i ; r > st ; r--)
				for(int j = r - 1;  j >= st ; j--)
					ans.push_back({a[r],a[j]});
					
			for(int j = st ; j < i ; j++)
				for(int k = st + 1; k <= i ; k++)
					ans.push_back({a[j],a[k]});
			st = i + 1;
		}
	}
	for(int r = n ; r > st ; r--)
		for(int j = r - 1;  j >= st ; j--)
			ans.push_back({a[r],a[j]});
					
	for(int j = st ; j < n ; j++)
		for(int k = st + 1; k <= n ; k++)
			ans.push_back({a[j],a[k]});
			
	cout << ans.size() << endl;
	for(int i = 0 ; i < ans.size(); i++)
		cout << ans[i].first << " " << ans[i].second << endl;
} 
int main()
{ 
	solve();
	return 0; 
}



Submission (verdict: Wrong answer on test 7):
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include <queue>
#include <string.h>
#include <stack>

using namespace std;

typedef long long LL;	
typedef pair<int ,int> PII;

const int N = 2e5 + 10 ;
const int MOD = 1e9 + 7;
const int LOGN = 20;

int a[N]; 
void solve()
{
	int n;cin>>n;
	for(int i = 1; i <= n ; i++)cin>>a[i];
	vector<PII>ans;
	for(int i = 1; i <= n ; i++)
		for(int j = i + 1; j <= n ; j++)
		{
			if (a[i] >= a[j])
				ans.push_back({a[i],a[j]});
		}
	int st = 1;
	for(int i = 1; i < n ; i++)
	{
		if (a[i] < a[i + 1])continue;
		else{
			for(int r = i ; r > st ; r--)
				for(int j = r - 1;  j >= st ; j--)
					ans.push_back({a[r],a[j]});
					
			for(int j = st ; j < i ; j++)
				for(int k = j + 1; k <= i ; k++)
					ans.push_back({a[j],a[k]});
			st = i + 1;
		}
	}
	for(int r = n ; r > st ; r--)
		for(int j = r - 1;  j >= st ; j--)
			ans.push_back({a[r],a[j]});
					
	for(int j = st ; j < n ; j++)
		for(int k = j + 1; k <= n ; k++)
			ans.push_back({a[j],a[k]});
			
	cout << ans.size() << endl;
	for(int i = 0 ; i < ans.size(); i++)
		cout << ans[i].first << " " << ans[i].second << endl;
} 
int main()
{ 
	solve();
	return 0; 
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 4):
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include <queue>
#include <string.h>
#include <stack>

using namespace std;

typedef long long LL;	
typedef pair<int ,int> PII;

const int N = 2e5 + 10 ;
const int MOD = 1e9 + 7;
const int LOGN = 20;

int a[N]; 
void solve()
{
	int n;cin>>n;
	for(int i = 1; i <= n ; i++)cin>>a[i];
	vector<PII>ans;
	for(int i = 1; i <= n ; i++)
		for(int j = i + 1; j <= n ; j++)
		{
			if (a[i] >= a[j])
				ans.push_back({a[i],a[j]});
		}
	int st = 1;
	for(int i = 1; i < n ; i++)
	{
		if (a[i] < a[i + 1])continue;
		else{
			for(int r = i ; r > st ; r--)
				for(int j = r - 1;  j >= st ; j--)
					ans.push_back({a[r],a[j]});
					
			for(int j = st ; j < i ; j++)
				for(int k = st + 1; k <= i ; k++)
					ans.push_back({a[j],a[k]});
			st = i + 1;
		}
	}
	for(int r = n ; r > st ; r--)
		for(int j = r - 1;  j >= st ; j--)
			ans.push_back({a[r],a[j]});
					
	for(int j = st ; j < n ; j++)
		for(int k = st + 1; k <= n ; k++)
			ans.push_back({a[j],a[k]});
			
	cout << ans.size() << endl;
	for(int i = 0 ; i < ans.size(); i++)
		cout << ans[i].first << " " << ans[i].second << endl;
} 
int main()
{ 
	solve();
	return 0; 
}