ll@N,@(X,Y)[N]; coordcomp(N,X); coordcomp(N,Y); vectorZ[N]; fenwick fw; ll P = 0,Q = 0; rep(i,N)Z[X[i]].push_back(Y[i]); fw.walloc(N,1); rep(i,N){ for(int y:Z[i]){ P+=fw.range(0,y-1); Q+=fw.range(y+1,N); } for(int y:Z[i]){ fw.add(y,1); } } ll R=N*(N-1)/2,S=N*(N-1)/2; ll cx[N]{},cy[N]{}; rep(i,N)cx[X[i]]++,cy[Y[i]]++; rep(i,N)R-=cx[i]*(cx[i]-1)/2,S-=cy[i]*(cy[i]-1)/2; double numer=P-Q; double denom=std::sqrt(R)*std::sqrt(S); wt(numer/denom);