func_code_string: #include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long power(long long first, unsigned long long second,                   unsigned long long m) {     if (second == 0) return 1;     long long p = power(first, second / 2, m) % m;     p = (p * p) % m;     return (second % 2 == 0) ? p : (first * p) % m;   }   long long modInverse(long long a, long long m) {     { return power(a, m - 2, m); }   }   const long long maxn = 500004;   void __print(long long first) { cerr << first; }   void __print(float first) { cerr << first; }   void __print(double first) { cerr << first; }   void __print(long double first) { cerr << first; }   void __print(char first) { cerr <<      << first <<     ; }   void __print(const char *first) { cerr <<     << first <<    ; }   void __print(const string &first) { cerr <<     << first <<    ; }   void __print(bool first) { cerr << (first ?  true  :  false ); }   template <typename T, typename V>   void __print(const pair<T, V> &first) {     cerr <<  { ;     __print(first.fi);     cerr <<  , ;     __print(first.se);     cerr <<  } ;   }   template <typename T>   void __print(const T &first) {     long long f = 0;     cerr <<  { ;     for (auto &i : first) cerr << (f++ ?  ,  :   ), __print(i);     cerr <<  } ;   }   void _print() { cerr <<  ] n ; }   template <typename T, typename... V>   void _print(T t, V... v) {     __print(t);     if (sizeof...(v)) cerr <<  ,  ;     _print(v...);   }   struct BIT {     long long N;     vector<long long> bit;     void init(long long n) {       N = n;       bit.assign(n + 4, 0);     }     void update(long long idx, long long val) {       idx++;       while (idx <= N) {         bit[idx] += val;         idx += idx & -idx;       }     }     long long query(long long idx) {       long long ans = 0;       idx++;       while (idx > 0) {         ans += bit[idx];         idx -= idx & -idx;       }       return ans;     }     long long search(long long val) {       long long curSum = 0, pos = 0;       for (long long i = log2(N) + 1; i >= 0; i--) {         if (pos + (1 << i) < N && curSum + bit[pos + (1 << i)] < val) {           curSum += bit[pos + (1 << i)];           pos += (1 << i);         }       }       return pos + 1;     }     void updateMax(long long idx, long long val) {       while (idx <= N) {         bit[idx] = max(bit[idx], val);         idx += idx & -idx;       }     }     long long prefMax(long long idx) {       long long ans = -2e9;       while (idx > 0) {         ans = max(ans, bit[idx]);         idx -= idx & -idx;       }       return ans;     }   };   void solve() {     BIT bit;     long long n;     cin >> n;     bit.init(n + 4);     long long a[n], b[n], c[n + 3];     memset(c, 0, sizeof c);     memset(a, 0, sizeof a);     memset(b, 0, sizeof b);     for (long long i = 0; i < n; i++) {       cin >> a[i];       ;       bit.update(i, 1);     }     for (long long i = 0; i < n; i++) {       c[n - i - 1] = bit.query(a[i]) - 1;       bit.update(a[i], -1);     }     for (long long i = 0; i < n; i++) {       cin >> b[i];       bit.update(i, 1);     }     for (long long i = 0; i < n; i++) {       c[n - i - 1] += bit.query(b[i]) - 1;       bit.update(b[i], -1);     }     for (long long i = 1; i <= n + 2; i++) {       c[i + 1] += c[i] / (i + 1);       c[i] %= i + 1;     }     c[n] = 0;     for (long long i = 0; i < n; i++) bit.update(i, 1);     for (long long i = 1; i <= n; i++) {       long long first = c[n - i];       first++;       long long l = 0, r = n - 1;       long long wh;       while (l <= r) {         long long mid = l + r >> 1;         if (bit.query(mid) >= first) {           wh = mid;           r = mid - 1;         } else {           l = mid + 1;         }       }       cout << wh <<    ;       bit.update(wh, -1);     }   }   signed main() {     ios_base ::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     solve();     return 0;   }   