#include using namespace std; #define pb emplace_back #define mp make_pair using ll = long long; using pii = pair; constexpr int mod = 998244353; constexpr int inf = 0x3f3f3f3f; constexpr int N = 2e5 + 10; int n, m, b[N]; int s[N]; int lowbit(int x){ return x & (-x); } void add(int x, int v){ for(; x<=m; x+=lowbit(x)) s[x] += v; } int sum(int x){ int ret = 0; for(; x>0; x-=lowbit(x)) ret += s[x]; return ret; } int query(int L, int R){ if(L > R) return 0; return sum(R) - sum(L - 1); } void _main(){ unordered_map cntx, cnty; map> g; cin >> n; ll P = 0, Q = 0, R = 0, S = 0; int x, y; m = 0; for(int i=1; i<=n; ++i){ cin >> x >> y; R += (i - ++cntx[x]); S += (i - ++cnty[y]); g[x].pb(y); b[m++] = y; } sort(b, b+m); m = unique(b, b+m) - b; for(auto &[x, vec] : g){ for(int y : vec){ int j = lower_bound(b, b+m, y) - b + 1; P += query(1, j - 1); Q += query(j + 1, m); } for(int y : vec){ int j = lower_bound(b, b+m, y) - b + 1; add(j, 1); } } cout << setprecision(8) << (P - Q) * 1.0 / sqrt(1.0 * R * S) << '\n'; } int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); _main(); return 0; }