#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> xy; map mpx, mpy; for (int i = 0; i < n; i++) { int x, y; cin >> x >> y; xy.emplace_back(x, y); mpx[x]++; mpy[y]++; } auto calc = [&]() { vector ys(n); for (int i = 0; i < n; i++) { ys[i] = xy[i].second; } Compression cy(ys); int sz = cy.size(); atcoder::fenwick_tree fw(sz); lint res = 0; for (int i = 0; i < n; i++) { auto [x, y] = xy[i]; res += fw.sum(cy.idx(y) + 1, sz); fw.add(cy.idx(y), 1LL); } return res; }; lint p, q, r, s; sort(xy.begin(), xy.end()); q = calc(); for (int i = 0; i < n; i++) { xy[i].second *= -1; } sort(xy.begin(), xy.end()); p = calc(); r = s = (lint)n * (lint)(n - 1) / 2LL; for (auto [a, b] : mpx) { r -= b * (b - 1LL) / 2LL; } for (auto [a, b] : mpy) { s -= b * (b - 1LL) / 2LL; } cout << fixed << setprecision(10) << (ld)(p - q) / (sqrt((ld)r) * sqrt((ld)s)) << endl; }