#include #include #include using namespace std; #define DEB(x) cout << #x << " = " << x << endl; long long int a[100001]; long long int b[100001]; int main(void) { int n; while (scanf("%d", &n) == 1) { long long int x1, x2; for (int i = 0; i < n; i++) { cin >> x1 >> x2; a[i] = (long long int)x1 + (long long int)x2; b[i] = (long long int)x1 - (long long int)x2; } /* DEB(a[0]) DEB(a[1]) DEB((long long int)10000000000 + (long long int)10000000000) */ sort(a, a + n); sort(b, b + n); /*for (int i = 0; i < n; i++) { DEB(a[i]) } for (int i = 0; i < n; i++) { DEB(b[i]) }*/ int res = 0; int resA = 1; int resB = 1; for (int i = 0; i < n - 1; i++) { if (a[i] == a[i + 1]) resA++; else { res += resA * (resA - 1); resA = 1; } //DEB(resA) if (b[i] == b[i + 1]) resB++; else { res += resB * (resB - 1); resB = 1; } } res += resA * (resA - 1); res += resB * (resB - 1); double r = res / ((double)n * (double)n); printf("%.6lf\n", r); /*double all = (double)n * (double)n; //cout << all << endl; uint64_t cnt = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i == j) continue; int dx = abs(xy[i][0] - xy[j][0]); int dy = abs(xy[i][1] - xy[j][1]); if (dx == dy) { cnt++; } } } //DEB(cnt); double res = cnt / (double)all;*/ //printf("%.6lf\n", res); } return 0; }