func_code_string: #include <bits/stdc++.h>   using namespace std;   queue<int> qQuit;   int ind[100000], n;   bool entered[100000];   priority_queue<pair<int, int>, vector<pair<int, int> >,                  greater<pair<int, int> > >       qLeft, qRight;   int data[100000];   int main(void) {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       int temp;       scanf( %d , &temp);       ind[temp - 1] = i;     }     for (int i = 0; i < n; i++) {       scanf( %d , data + i);       data[i]--;     }     for (int i = 0; i < n; i++) {       qQuit.push(data[i]);       if (i >= ind[data[i]])         qRight.push(make_pair(i - ind[data[i]], data[i]));       else {         qLeft.push(make_pair(ind[data[i]] - i, data[i]));         entered[data[i]] = true;       }     }     for (int i = 0; i < n; i++) {       int minVal = 99999999;       int minFrom;       if (qRight.size()) {         if (minVal > qRight.top().first - i) minFrom = qRight.top().second;         minVal = min(minVal, qRight.top().first - i);       }       while (qLeft.size() && entered[qLeft.top().second] == false) qLeft.pop();       if (qLeft.size()) {         if (minVal > qLeft.top().first + i) minFrom = qLeft.top().second;         minVal = min(minVal, qLeft.top().first + i);       }       printf( %d n , minVal);       while (qRight.size() && qRight.top().first - i == 0) {         pair<int, int> val = qRight.top();         qRight.pop();         qLeft.push(make_pair(-i, val.second));         entered[val.second] = true;       }       int toQuit = qQuit.front();       qQuit.pop();       entered[toQuit] = false;       qRight.push(make_pair(n - 1 - ind[toQuit] + (i + 1), toQuit));     }     return 0;   }   