Problem: 2052A - Adrenaline Rush
Language: Java 21

Previous submission (verdict: Wrong answer on test 7):
import java.util.*;
import java.io.*;

public class A_Adrenaline_Rush {

    int mod = (int) 1e9 + 7;
    
    public static void main(String[] args) {
        int n = sc.nextInt();
        int[] f = new int[n];
        input(f);
        int[] a = new int[n];
        for(int i=0;i<n;i++) a[i] = i+1;
        List<int[]> l = new ArrayList<>();
        for(int i=0;i<n;i++){
            int pl = f[i];
            // System.out.println(pl);
            int idx = -1;
            for(int j=0;j<n;j++){
                if(a[j]==pl){
                    idx = j;
                    break;
                }
            }
            // System.out.println(idx);
            if(i<=idx){
                int j = idx;
                while(j>0 && a[j]>a[j-1]){
                    int temp = a[j];
                    a[j] = a[j-1];
                    a[j-1] = temp;
                    l.add(new int[]{a[j-1],a[j]});
                    j--;
                }
                if(i>0){
                    while(j<i){
                        int temp = a[j];
                        a[j] = a[j+1];
                        a[j+1] = temp;
                        l.add(new int[]{a[j],a[j+1]});
                        j++;
                    }
                }
            }
            // printArr(a);
        }
        System.out.println(l.size());
        for(int i=0;i<l.size();i++){
            System.out.println(l.get(i)[0] + " " + l.get(i)[1]);
        }
        // printArr(a);
    }
    
    public static void input(Object array) {
        if (array instanceof int[])
            for (int i = 0; i < ((int[]) array).length; i++)
                ((int[]) array)[i] = sc.nextInt();
        else if (array instanceof long[])
            for (int i = 0; i < ((long[]) array).length; i++)
                ((long[]) array)[i] = sc.nextLong();
    }
    
    public static void printArr(Object array) {
        if (array instanceof int[])
            for (int x : (int[]) array)
                System.out.print(x + " ");
        else if (array instanceof long[])
            for (long x : (long[]) array)
                System.out.print(x + " ");
        System.out.println();
    }
    
    public static <T extends Number> long gcd(T a, T b) {
        return b.longValue() == 0 ? a.longValue() : gcd(b, a.longValue() % b.longValue());
    }
    
    static FastReader sc = new FastReader();
    
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
    
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
    
        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
    
        int nextInt() {
            return Integer.parseInt(next());
        }
    
        long nextLong() {
            return Long.parseLong(next());
        }
    
        double nextDouble() {
            return Double.parseDouble(next());
        }
    
        String nextLine() {
            String str = "";
            try {
                str = br.readLine().trim();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

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

public class A_Adrenaline_Rush {

    int mod = (int) 1e9 + 7;
    
    public static void main(String[] args) {
        int n = sc.nextInt();
        int[] f = new int[n];
        input(f);
        int[] a = new int[n];
        for(int i=0;i<n;i++) a[i] = i+1;
        List<int[]> l = new ArrayList<>();
        for(int i=0;i<n;i++){
            int pl = i+1;
            int dest = -1;
            for(int j=0;j<n;j++){
                if(f[j]==pl){
                    dest = j;
                    break;
                }
            }
            // System.out.println(pl);
            int idx = -1;
            for(int j=0;j<n;j++){
                if(a[j]==pl){
                    idx = j;
                    break;
                }
            }
            // System.out.println(idx);
            if(dest<=idx){
                int j = idx;
                while(j>0 && a[j]>a[j-1]){
                    int temp = a[j];
                    a[j] = a[j-1];
                    a[j-1] = temp;
                    l.add(new int[]{a[j-1],a[j]});
                    j--;
                }
                if(dest>0){
                    while(j<dest){
                        int temp = a[j];
                        a[j] = a[j+1];
                        a[j+1] = temp;
                        l.add(new int[]{a[j],a[j+1]});
                        j++;
                    }
                }
            }
            // printArr(a);
        }
        System.out.println(l.size());
        for(int i=0;i<l.size();i++){
            System.out.println(l.get(i)[0] + " " + l.get(i)[1]);
        }
        // printArr(a);
    }
    
    public static void input(Object array) {
        if (array instanceof int[])
            for (int i = 0; i < ((int[]) array).length; i++)
                ((int[]) array)[i] = sc.nextInt();
        else if (array instanceof long[])
            for (int i = 0; i < ((long[]) array).length; i++)
                ((long[]) array)[i] = sc.nextLong();
    }
    
    public static void printArr(Object array) {
        if (array instanceof int[])
            for (int x : (int[]) array)
                System.out.print(x + " ");
        else if (array instanceof long[])
            for (long x : (long[]) array)
                System.out.print(x + " ");
        System.out.println();
    }
    
    public static <T extends Number> long gcd(T a, T b) {
        return b.longValue() == 0 ? a.longValue() : gcd(b, a.longValue() % b.longValue());
    }
    
    static FastReader sc = new FastReader();
    
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
    
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
    
        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
    
        int nextInt() {
            return Integer.parseInt(next());
        }
    
        long nextLong() {
            return Long.parseLong(next());
        }
    
        double nextDouble() {
            return Double.parseDouble(next());
        }
    
        String nextLine() {
            String str = "";
            try {
                str = br.readLine().trim();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}