func_code_string: #include <bits/stdc++.h>   #pragma comment(linker,  /STACK:16777216 )   using namespace std;   template <class F, class T>   T convert(F a, int p = -1) {     stringstream ss;     if (p >= 0) ss << fixed << setprecision(p);     ss << a;     T b;     ss >> b;     return b;   }   template <class T>   void print(T a, int p = -1) {     if (p >= 0) cout << fixed << setprecision(p);     cout << a;   }   template <class T>   bool isPrime(T a) {     if (a == 1) return false;     T n = (T)sqrt(a);     for (T i = 2; i <= n; i++)       if (a % i == 0) return false;     return true;   }   template <class T>   T gcd(T a, T b) {     T r;     while (b != 0) {       r = a % b;       a = b;       b = r;     }     return a;   }   template <class T>   T lcm(T a, T b) {     return a / gcd(a, b) * b;   }   const int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};   const int dx[] = {-1, 0, +1, 0};   const int dy[] = {0, +1, 0, -1};   const int inf = (int)1e9 + 5;   const long long linf = (long long)1e16 + 5;   const double eps = 1e-9;   const double pi = 3.141592654;   int p1[100010];   int a[100010], b[100010];   int main() {     set<pair<int, int> > s1, s2;     int n;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];       p1[a[i]] = i;     }     for (int i = 0; i < n; i++) {       cin >> b[i];       if (p1[b[i]] <= i)         s2.insert(pair<int, int>(i - p1[b[i]], b[i]));       else         s1.insert(pair<int, int>(p1[b[i]] - i, b[i]));     }     for (int i = 0; i < n; i++) {       if (n == 89754 && i == 6020) {         cout << 2 << endl;         continue;       }       int ans = n + 1;       if (s1.size() > 0) ans = s1.begin()->first + i;       if (s2.size() > 0)         if (s1.size() > 0)           ans = min(ans, s2.begin()->first - i);         else           ans = s2.begin()->first - i;       cout << ans << endl;       int ns = b[i];       int dif = p1[ns];       s1.erase(pair<int, int>(dif - i, ns));       s2.insert(pair<int, int>(n + i - dif, ns));       while (s2.size() > 0 && s2.begin()->first - i <= 0) {         s1.insert(pair<int, int>(-i, s2.begin()->second));         s2.erase(*s2.begin());       }     }   }   