cin >> n; for (int i = 1, x, y; i <= 2 * n; ++i) { cin >> x >> y; if (x > y) swap(x, y); vec.emplace_back(x + y, x, y); } sort(vec.begin(), vec.end()); ll ans = 0; for (int i = 0; i < n; ++i) ans -= get<1>(vec[i]); for (int i = n; i < 2 * n; ++i) ans += get<2>(vec[i]); cout << ans << "\n"; return0; }