#include using namespace std; typedef long long ll; #define INF 1000000000 int main() { ll n; cin >> n; vector > data(n); ll p1, p2; for(ll i=0;i> p1 >> p2; data[i] = make_pair(p1, p2); } ll asize; ll bsize = n/2; if(n%2 == 0) { asize = n/2; } else { asize = n/2+1; } vector a; vector b; for(ll i=0;i<(1<>j)&1) { t1+=data[j].first; } else { t2+=data[j].second; } } a.push_back(t1-t2); } sort(a.begin(), a.end()); for(ll i=0;i<(1<>j)&1) { t1+=data[j+asize].first; } else { t2+=data[j+asize].second; } } b.push_back(t1-t2); } ll m3 = INF; ll m4 = INF; sort(b.begin(), b.end()); ll ans = INF; for(ll i=0;i b.size()) { ll m4 = INF; } else { ll m4 = abs(a[i]+ (b[lower+1])); } //cout << r << " "<< m1 << " " << m2 << " " << m3 << " " << m4 << endl; ans = min(min(m1, m2), min(m3, m4)); if(ans==16) { cout << r << " "<< m1 << " " << m2 << " " << m3 << " " << m4 << endl; } } cout << ans << endl; for(int i=0;i