#include #include using namespace std; int main() { long n; while (cin >> n) { map mapa1; map mapa2; long long options = n*n, winningOptions = 0; long x, y; for (long i = 0; i < n; i++) { cin >> x >> y; long diff = x - y; long summ = x + y; if (mapa1.find(diff) != mapa1.end()) { mapa1[diff]++; } else { mapa1[diff] = 1; } if (mapa2.find(summ) != mapa2.end()) { mapa2[summ]++; } else { mapa2[summ] = 1; } } for (map::iterator it = mapa1.begin(); it != mapa1.end(); ++it) { if (it->second > 1) { winningOptions += (it->second * (it->second - 1)); } } for (map::iterator it = mapa2.begin(); it != mapa2.end(); ++it) { if (it->second > 1) { winningOptions += (it->second * (it->second - 1)); } } double result = (double)winningOptions / (double)options; cout << result << endl; } return 0; }