Problem: 2052A - Adrenaline Rush
Language: python

Solution 1 (runtime: 655 ms):
import io,os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline




def main():
    n = int(input())
    arr = list(map(int,input().split()))
    for i in range(n):
        arr[i] -= 1


    curr = [i for i in range(n)]

    ans = []


    for i in range(n):
        index = -1
        for j in range(n):
            if curr[j]==arr[i]:  
                index = j   
                break

        for j in range(index,n-1):
            curr[j],curr[j+1] = curr[j+1],curr[j]
            ans.append((curr[j]+1,curr[j+1]+1))
        for j in range(n-2,i-1,-1):
            curr[j],curr[j+1] = curr[j+1],curr[j]
            ans.append((curr[j]+1,curr[j+1]+1))        



    print(len(ans))
    for ele in ans:
        print(*ele)



main()


Solution 2 (runtime: 1218 ms):
def ii():
    return int(input())
def li():
    return list(map(int,input().split()))
def si():
    return input()
def ti():
    return map(int,input().split())
def di():
    return deque((map(int,input().split())))
from math import *
from bisect import bisect_left,bisect_right
from heapq import heapify,heappop,heappush
from itertools import permutations
from collections import deque,defaultdict,Counter
def maxsubarraysum(arr,k):
    sumi=0
    best=0
    for i in range(k):
        sumi=max(arr[i],arr[i]+sumi)
        best=max(best,sumi)
    return best
def mod_inverse(a, m):
    m0 = m
    y = 0
    x = 1
    if m == 1:
        return 0
    while a > 1:
        q = a // m
        t = m
        m = a % m
        a = t
        t = y
        y = x - q * y
        x = t
    if x < 0:
        x = x + m0
    return x
def prefixsum(l,n):
    if n==0:
        return []
    array=[l[0]]
    for i in range(1,n):
        array.append(array[-1]+l[i])
    return array
def suffixsum(l,n):
    array=[0]*n
    temperory=0
    for i in range(n):
        temperory+=l[n-1-i]
        array[n-1-i]=temperory
    return array
def prime(x):
    if x==1:
        return(0)
    elif x==2:
        return(1)
    else:
        t=(sqrt(x))+1
        t=int(t)
        for i in range(2,t):
            if x%i==0:
                return(0)
        else:
            return(1)
def prefixmax(l,n):
    array=[l[0]]
    for i in range(1,n):
        array.append(max(array[-1],l[i]))
    return array
def prefixmin(l,n):
    array=[l[0]]
    for i in range(1,n):
        array.append(min(array[-1],l[i]))
    return array
def BinarySearch(a, x):
 
    i = bisect_left(a, x)
 
    if i != len(a) and a[i] == x:
 
        return i
 
    else:
 
        return -1
def sortremoveDuplicates(arr, n):
    if n == 0 or n == 1:
        return arr
 
    temp = []
    j = 0
    for i in range(0, n-1):
        if arr[i] != arr[i+1]:
            temp += [arr[i]]
            j += 1
    temp += [arr[n-1]]
    return temp
def decimalToBinary(n):
    return bin(n).replace("0b", "")
def ato1(chr):
    return ord(chr)-ord("A")
def permutationindex(l,n):
    arr=[0]*(n)
    for i in range(n):
        arr[l[i]-1]=i
    return arr
def issubsequence(s, s2):
 
    n, m = len(s), len(s2)
    i, j = 0, 0
    while (i < n and j < m):
        if (s[i] == s2[j]):
            i += 1
        j += 1
 
    # If i reaches end of s,that mean we found all
    # characters of s in s2,
    # so s is subsequence of s2, else not
    return i == n
def def_value():
    return -1
def primef(n):
    l1=[]
    i=2
    while i*i<=n:
        if n%i!=0:
            i+=1
        else:
            l1.append(i)
            while(n%i==0):
                n//=i
    if n>1:
        l1.append(n)
    return l1
"""
def search( k) :
        global ans
        if (k == len(l)) :
           if len(subset)%2==0 and len(subset)>0:
               ans+=maxi//product(subset)
           elif len(subset)>0:
               ans-=maxi//product(subset)
        else:
           search(k+1)
           subset.append(l[k])
           search(k+1)
           subset.pop()
"""
def seive(n):
    ans=[0]*(n+1)
    #primes=[]
    for i in range(2,n+1):
        if ans[i]==0:
            #primes.append(i)
            for j in range(2*i,n+1,i):
                ans[j]=i
    return ans
def inte(s,s2):
    if s[1]<s2[0] or s2[1]<s[0]:
        return 0
    return [max(s[0],s2[0]),min(s[1],s2[1])]
def checksq(x):
    z=isqrt(x)
    if z<0:
        return False
    if z*z==x:
        return True
    return False
def counti(l,n):
    l1=[]
    z=1
    for i in range(1,n):
        if l[i]==l[i-1]:
            z+=1
        else:
            l1.append([l[i-1],z])
            z=1
    l1.append([l[-1],z])
    return l1
def next(arr, target):
    start = 0; 
    end = len(arr) - 1; 
    # Minimum size of the array should be 1
    if (end == 0):
        return -1
    '''
    If target lies beyond the max element, than the index of strictly smaller
    value than target should be (end - 1)
    '''
    if (target > arr[end]):
        return end
   
    ans = -1; 
    while (start <= end): 
        mid = (start + end) // 2; 
        if (arr[mid] >= target): 
            end = mid - 1; 
        else: 
            ans = mid; 
            start = mid + 1; 
 
    return ans; 
def next1(arr, target):
    start = 0
    end = len(arr) - 1
 
    ans = -1
    while (start <= end):
        mid = (start + end) // 2
 
        # Move to right side if target is
        # greater.
        if (arr[mid] <= target):
            start = mid + 1
 
        # Move left side.
        else:
            ans = mid
            end = mid - 1
 
    return ans
def next_greatest_indices(arr):
    result = [len(arr)] * len(arr)
    stack = []
    for i in range(len(arr) - 1, -1, -1):
        while stack and arr[stack[-1]] < arr[i]:
            stack.pop()
        if stack:
            result[i] = stack[-1]
        stack.append(i)
    return result
def find_largest_index(arr, k):
    left, right = 0, len(arr) - 1
    result = -1

    while left <= right:
        mid = (left + right) // 2

        if arr[mid] < k:
            result = mid
            left = mid + 1
        else:
            right = mid - 1

    return result

import sys
input=sys.stdin.readline
for _ in range(1):
    n=ii()
    a=li()
    cur=[i for i in range(1,n+1)]
    l=[]
    for i in range(n):
        ind=0
        for j in range(n):
            if (cur[j]==a[i]):
                ind=j
                break
        for j in range(ind+1,n):
            l.append([cur[j],a[i]])
        for j in range(n-1,ind,-1):
            l.append([a[i],cur[j]])
        for j in range(ind-1,i-1,-1):
            l.append([a[i],cur[j]])
        cur.pop(ind)
        cur.insert(i,a[i])
    print(len(l))
    for i in l:
        print(* i)