func_code_string: #include <bits/stdc++.h>   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   const int MAX = 2e6 + 5;   int ftree[MAX] = {0};   int sum[MAX] = {0};   int query(int node) {     int sum = 0;     while (node > 0) {       sum += ftree[node];       node -= (node & -node);     }     return sum;   }   void update(int node, int diff, int &mx) {     while (node <= mx) {       ftree[node] += diff;       node += (node & -node);     }   }   int bsearch(int &n, int s) {     int l = 1;     int r = n;     while (l <= r) {       int m = (l + r) >> 1;       int p = query(m);       if (p < s)         l = m + 1;       else         r = m - 1;     }     return l;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     memset(ftree, 0, sizeof(ftree));     memset(sum, 0, sizeof(sum));     int n;     cin >> n;     for (int i = (1); i <= (n); ++i) {       update(i, 1, n);     }     int p;     for (int i = 0; i < (int)(n); ++i) {       cin >> p;       int less = query(p + 1) - 1;       sum[i] += less;       update(p + 1, -1, n);     }     for (int i = (1); i <= (n); ++i) {       update(i, 1, n);     }     for (int i = 0; i < (int)(n); ++i) {       cin >> p;       int less = query(p + 1) - 1;       sum[i] += less;       update(p + 1, -1, n);     }     for (int i = 0; i < n; ++i) {       int carry = sum[n - i - 1] / (i + 1);       sum[n - i - 2] += carry;       sum[n - i - 1] %= (i + 1);       update(i + 1, 1, n);     }     for (int i = 0; i < (int)(n); ++i) {       int f = bsearch(n, sum[i] + 1);       cout << (f - 1) <<    ;       update(f, -1, n);     }     cout <<   n ;     return 0;   }   