#include using namespace std; #define rep(i,a,b) for(int i=a;i> x >> y; int x2, y2; cin >> x2 >> y2; int d1 = max(x2, y2) + max(abs(x - x2), abs(y - y2)); int d2 = max(x, y); if (d2 < d1) { cout << d2 << endl; return 0; } int ans = INF; rep(i, 0, 8) { int xx = x2 + dx[i]; int yy = y2 + dy[i]; d1 = max(xx, yy) + max(abs(x - xx), abs(y - yy)); ans = min(ans, d1); } cout << ans << endl; }