func_code_string: #include <bits/stdc++.h>   using namespace std;   multiset<int> ms;   const int MAXN = 1000000;   int pos[MAXN], a[MAXN], b[MAXN], st[MAXN];   int n, i, j, k, ans;   int main() {     scanf( %d , &n);     for (i = 1; i <= n; ++i) {       scanf( %d , &a[i]);       pos[a[i]] = i;     }     for (j = 1; j <= n; ++j) {       scanf( %d , &b[j]);       int diff = j - pos[b[j]];       st[j] = diff;       ms.insert(diff);     }     for (i = 0; i < n; ++i) {       ans = n;       multiset<int>::iterator it = ms.lower_bound(i);       if (it != ms.end()) ans = min(ans, abs(*(it)-i));       if (it != ms.begin()) ans = min(ans, abs(*(--it) - i));       cout << ans << endl;       ms.erase(ms.find(st[i + 1]));       int num = b[i + 1];       ms.insert((i + n + 1) - pos[num]);     }   }   