func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<long long> pa, pb;   struct fenw {     vector<long long> fw;     long long n;     void ini(long long pn) {       n = pn;       fw.clear();       fw.resize(n, 0);     }     void ad(long long l, long long x) {       while (l < n) {         fw[l] += x;         l |= (l + 1);       }     }     long long sm(long long l) {       long long r = 0;       while (l >= 0) {         r += fw[l];         l &= (l + 1);         --l;       }       return r;     }   };   fenw fa, fb, fr;   vector<long long> resd;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     long long n;     cin >> n;     pa.resize(n);     pb.resize(n);     for (long long i = 0; i < (n); ++i) cin >> pa[i];     for (long long i = 0; i < (n); ++i) cin >> pb[i];     fa.ini(n);     fb.ini(n);     fr.ini(n);     resd.resize(n);     for (long long i = n - 1; i >= 0; --i) {       long long cc = fa.sm(pa[i]) + fb.sm(pb[i]);       fa.ad(pa[i], 1);       fb.ad(pb[i], 1);       resd[i] += cc;       if (i > 0) resd[i - 1] += resd[i] / (n - i);       resd[i] %= (n - i);     }     for (long long i = 0; i < (n); ++i) {       long long mn = 0;       long long mx = n;       long long md;       while (mx - mn > 1) {         md = (mx + mn) / 2;         if (md - fr.sm(md - 1) <= resd[i])           mn = md;         else           mx = md;       }       fr.ad(mn, 1);       cout << mn <<    ;     }     cout <<   n ;     return 0;   }   