import sys input = sys.stdin.readline from collections import * class Fenwick_Tree: def __init__(self, n): self._n = n self.data = [0] * n def add(self, p, x): assert 0 <= p < self._n p += 1 while p <= self._n: self.data[p - 1] += x p += p & -p def sum(self, l, r): assert 0 <= l <= r <= self._n return self._sum(r) - self._sum(l) def _sum(self, r): s = 0 while r > 0: s += self.data[r - 1] r -= r & -r return s # T.sum(0, x) <= kとなる最大のxを返す。 def get(self, k): k += 1 x, r = 0, 1 while r < self._n: r <<= 1 len = r while len: if x + len - 1 < self._n: if self.data[x + len - 1] < k: k -= self.data[x + len - 1] x += len len >>= 1 return x def __str__(self): temp = [] for i in range(self._n): temp.append(str(self.sum(i, i + 1))) return ' '.join(temp) from bisect import * from copy import deepcopy def compress(lst): ''' B: lstを座圧したリスト idx_to_val: indexから元の値を取得するリスト val_to_idx: 元の値からindexを取得する辞書 ''' B = [] val_to_idx = {} idx_to_val = deepcopy(lst) idx_to_val = list(set(idx_to_val)) idx_to_val.sort() for i in range(len(lst)): ind = bisect_left(idx_to_val, lst[i]) B.append(ind) for i in range(len(B)): val_to_idx[lst[i]] = B[i] return B, idx_to_val, val_to_idx N = int(input()) X, Y = [], [] D = [] for i in range(N): x, y = map(int, input().split()) X.append(x) Y.append(y) X, _, _ = compress(X) Y, _, _ = compress(Y) D = [[] for i in range(N)] for i in range(N): D[X[i]].append(Y[i]) Cx = Counter(X) Cy = Counter(Y) R, S = N * (N - 1) // 2, N * (N - 1) // 2 for k, v in Cx.items(): R -= v * (v - 1) // 2 for k, v in Cy.items(): S -= v * (v - 1) // 2 P = 0 T = Fenwick_Tree(N + 1) for x in range(N): for y in D[x]: T.add(y, 1) for x in range(N): for y in D[x]: T.add(y, -1) for y in D[x]: P += T.sum(y + 1, N + 1) Q = 0 T = Fenwick_Tree(N + 1) for x in range(N-1, -1, -1): for y in D[x]: T.add(y, 1) for x in range(N-1, -1, -1): for y in D[x]: T.add(y, -1) for y in D[x]: Q += T.sum(y + 1, N + 1) print((P - Q) / (R * S) ** 0.5)