#include #include using namespace std; template struct Compression { vector a; Compression(vector a_) : a(a_) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); } int size() { return (int)a.size(); } T val(int p) { return a[p]; } int idx(T x) { int res = lower_bound(a.begin(), a.end(), x) - a.begin(); return res; } }; using lint = long long; using ld = long double;; int main() { int n; cin >> n; vector> ps; vector ys; map mpx, mpy; for (int i = 0; i < n; i++) { int x, y; cin >> x >> y; ps.emplace_back(x, y); ys.emplace_back(y); mpx[x]++; mpy[y]++; } sort(ps.begin(), ps.end()); Compression cy(ys); atcoder::fenwick_tree fw(cy.size()); lint p = 0, q = 0, r = 0, s = 0; for (int i = 0; i < n; i++) { auto [x, y] = ps[i]; fw.add(cy.idx(y), 1LL); if (i > 0 && ps[i - 1].first == x) { continue; } p += fw.sum(0, cy.idx(y)); q += fw.sum(cy.idx(y) + 1, cy.size()); } r = s = (lint)n * (lint)(n - 1) / 2LL; for (auto [key, val] : mpx) { r -= val * (val - 1LL) / 2LL; } for (auto [key, val] : mpy) { s -= val * (val - 1LL) / 2LL; } cout << fixed << setprecision(10); cout << ((ld)p - (ld)q) / sqrtl((ld)r * (ld)s) << endl; }