using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace yuki0715_D { class Program { static void Main(string[] args) { var sb = new StringBuilder(); int n = getint(); var x = getsplit(); var a = Array.ConvertAll(x, int.Parse); bool s = true; int count = 0; while (s) { s = false; for (int j = n - 1; j > 0; j--) { if (a[j] < a[j - 1]) { int k = a[j - 1]; a[j - 1] = a[j]; a[j] = k; sb.AppendLine(j-1 + " "+j); count++; s = true; } } } Console.WriteLine(count); Console.Write(sb); n = getint(); } public static string[] getsplit() { string[] x = Console.ReadLine().Split(' '); return x; } public static int getint() { int x = int.Parse(Console.ReadLine()); return x; } } }