#include using namespace std; typedef long long int ll; typedef pair P; typedef vector VI; typedef vector VVI; #define REP(i,n) for(int i=0;i0;k-=k&-k){ res+=dat[k]; } return res; } void add(int k, ll x) { for(;k<=N;k+=k&-k){ dat[k]+=x; } } int lowerBound(int w) { if (w<=0) return 0; int x=0; int k=1; while(k*2<=N) k*=2; for(;k>0;k/=2){ if(x+k<=N&&dat[x+k]> n; VI a(n), b(n); REP(i,n) cin >> a[i]; REP(i,n) cin >> b[i]; sort(ALL(a)); set st; map mp; REP(i,n) st.insert(a[i]),st.insert(b[i]); int c=2; for(auto x:st){ mp[x]=c; c++; } BIT bt(2*n); ll ans=0; REP(i,n){ bt.add(mp[b[i]],1); ans+=bt.sum(mp[a[i]]-1); } cout << ans << endl; return 0; }