func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = (1 << 17);   int a[maxn], pos[maxn], n, b[maxn];   struct num {     int idx, val;     bool operator<(const num &mtp) const { return val > mtp.val; }   };   priority_queue<num> q1, q2;   int out[maxn];   void read() {     int i;     scanf( %d , &n);     for (i = 1; i <= n; ++i) {       scanf( %d , &a[i]);       pos[a[i]] = i;     }     for (i = 1; i <= n; ++i) {       scanf( %d , &b[i]);     }   }   void solve() {     int i;     num tmp;     tmp.idx = maxn + 1;     tmp.val = maxn + 1;     q1.push(tmp);     q2.push(tmp);     for (i = 1; i <= n; ++i) {       if (i > pos[b[i]]) {         tmp.idx = i;         tmp.val = i - pos[b[i]];         q1.push(tmp);       } else {         tmp.idx = i;         tmp.val = pos[b[i]] - i;         q2.push(tmp);       }     }     printf( %d n , min(q1.top().val, q2.top().val));     int k = 0;     for (i = 1; i < n; ++i) {       k++;       tmp.idx = i;       tmp.val = n - pos[b[i]] + k;       q1.push(tmp);       out[i] = 1;       while ((q1.top().val - k) == 0) {         tmp.idx = q1.top().idx;         tmp.val = (-1) * k;         q2.push(tmp);         out[q1.top().idx] = 0;         q1.pop();       }       while (out[q2.top().idx]) q2.pop();       printf( %d n , min(q1.top().val - k, q2.top().val + k));     }   }   int main() {     read();     solve();     return 0;   }   