import std.algorithm, std.array, std.container, std.range, std.bitmanip; import std.numeric, std.math, std.bigint, std.random, core.bitop; import std.string, std.regex, std.conv, std.stdio, std.typecons; void main() { auto n = readln.chomp.to!size_t; auto li = iota(n).map!(_ => readln.split.map!(to!long)).array; long calc(long x) { auto s = li.map!(l => l[0] + l[1] * x); return s.reduce!(max) - s.reduce!(min); } auto r0 = calc(1); auto r1 = calc(2); if (r0 < r1) { writeln(0); return; } auto mi = 1L, ma = 2L; while (r0 > calc(ma)) ma <<= 1; while (ma - mi > 2) { auto mt1 = (mi * 2 + ma) / 3; auto mt2 = (mi + ma * 2) / 3; auto rt1 = calc(mt1); auto rt2 = calc(mt2); if (rt1 > rt2) mi = mt1; else ma = mt2; } auto r = long.max, m = 0L; foreach (mc; mi..ma+1) { auto rc = calc(mc); if (rc < r) { r = rc; m = mc; } } writeln(m); }