func_code_string: #include <bits/stdc++.h>   using namespace std;   int da[100010], db[100010], ida[100010], idb[100010];   map<int, int> mp;   map<int, int>::iterator it;   void solve(int n) {     for (int i = 1; i <= n; i++) {       int ret = 0x3fffffff;       it = mp.lower_bound(i - 1);       if (it != mp.end()) ret = min(ret, it->first - (i - 1));       if (it != mp.begin()) {         --it;         ret = min(ret, (i - 1) - it->first);       }       printf( %d n , ret);       mp[i - ida[db[i]]]--;       if (mp[i - ida[db[i]]] == 0) mp.erase(i - ida[db[i]]);       mp[i + n - ida[db[i]]]++;     }   }   int main() {     int n;     while (scanf( %d , &n) != EOF) {       mp.clear();       for (int i = 1; i <= n; i++) {         scanf( %d , &da[i]);         ida[da[i]] = i;       }       for (int i = 1; i <= n; i++) {         scanf( %d , &db[i]);         idb[db[i]] = i;       }       for (int i = 1; i <= n; i++) mp[i - ida[db[i]]]++;       solve(n);     }     return 0;   }   