#include <bits/stdc++.h>   using namespace std;   void desperate_optimization(int precision) {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cout.setf(ios::fixed);     cout.setf(ios::showpoint);     cout.precision(precision);   }   const int N = 2e5;   long long arrA[N + 5], arrB[N + 5];   long long posA[N + 5], posB[N + 5];   long long res[N + 5];   long long bit[N + 5];   int n;   int query(int x) {     int tot = 0;     for (; x; x -= (x & -x)) tot += bit[x];     return tot;   }   void update(int x) {     for (; x <= n; x += (x & -x)) bit[x]++;   }   void hora(int tc) {     cin >> n;     for (int i = 0; i < n; i++) cin >> arrA[i];     for (int i = 0; i < n; i++) cin >> arrB[i];     for (int i = 0; i < n; i++) {       int val = query(arrA[i] + 1);       posA[i] = arrA[i] - val;       update(arrA[i] + 1);     }     memset(bit, 0, sizeof bit);     for (int i = 0; i < n; i++) {       int val = query(arrB[i] + 1);       posB[i] = arrB[i] - val;       update(arrB[i] + 1);     }     long long cur = 0;     long long sisa = 0;     for (int i = n - 1; i >= 0; i--) {       res[i] = posA[i] + posB[i] + sisa;       sisa = res[i] / (cur + 1);       res[i] %= (cur + 1);       cur += 1;     }     memset(bit, 0, sizeof bit);     for (int i = 0; i < n; i++) {       int lo = 0;       int hi = n;       int ans = -1;       while (lo <= hi) {         int mid = (lo + hi) / 2;         if (mid - query(mid + 1) >= res[i]) {           ans = mid;           hi = mid - 1;         } else           lo = mid + 1;       }       update(ans + 1);       cout << ans <<    ;     }   }   int main() {     desperate_optimization(10);     int ntc = 1;     for (int tc = 1; tc <= ntc; tc++) hora(tc);     return 0;   }   