#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 2000;   int n, m, k, t, a[MAX_N + 1], b[MAX_N + 1], p[MAX_N + 1];   vector<int> x;   vector<int> y;   int main() {     int i, j, ans = 0;     scanf( %d , &n);     for (i = 1; i <= n; i++) scanf( %d , a + i);     for (i = 1; i <= n; i++) scanf( %d , b + i), p[b[i]] = i;     for (i = 1; i <= n; i++) {       for (k = i;; k++)         if (p[a[k]] == i) break;       while (k != i) {         for (j = i; j <= k; j++)           if (p[a[j]] >= k) {             x.push_back(k);             y.push_back(j);             ans += k - j;             swap(a[j], a[k]);             k = j;           }       }     }     printf( %d n%d n , ans, x.size());     for (i = 0; i < x.size(); i++) printf( %d %d n , x[i], y[i]);     return 0;   }   