#include using namespace std; using ll = long long; vector> Totsuho(vector> &pos){ int n=pos.size(),n1,n2; sort(pos.begin(), pos.end()); if(pos.empty()) return pos; vector> res1={pos[0],pos[1]},res2={pos[0],pos[1]}; auto cross=[&](pair a,pair b){ return (long long)a.first*b.second-(long long)a.second*b.first; }; auto sub=[&](pair a,pair b){ return make_pair(a.first-b.first,a.second-b.second); }; for(int i=2;i=2&&cross(sub(res1[n1-1],res1[n1-2]),sub(pos[i],res1[n1-1]))<=0){ res1.pop_back(); n1--; } while(n2>=2&&cross(sub(res2[n2-1],res2[n2-2]),sub(pos[i],res2[n2-1]))>=0){ res2.pop_back(); n2--; } res1.push_back(pos[i]); res2.push_back(pos[i]); } for (int i=res2.size()-2;i>=1;i--)res1.push_back(res2[i]); return res1; } long long Area(vector> &tot){ int n = tot.size(); long long res = 0,xa,xb,ya,yb,dx,dy; for(int i=0;i> &tot){ int n = tot.size(); long long res = n, xa, xb, ya, yb, dx, dy; for(int i=0;i> x1 >> y1 >> x2 >> y2 >> d; vector> c = { {x1, y1}, {x1, y2}, {x2, y1}, {x2, y2}, {d, 0}, {-d, 0}, {0, d}, {0, -d}, {x1, d - abs(x1)}, {x1, d - abs(x1)}, {x2, d - abs(x2)}, {x2, -(d - abs(x2))}, {d - abs(y1), y1}, {-(d - abs(y1)), y1}, {d - abs(y2), y2}, {-(d - abs(y2)), y2} }; vector> pos; auto f = [&](int x, int y){ if(abs(x) + abs(y) <= d && x1 <= x && x <= x2 && y1 <= y && y <= y2){ pos.emplace_back(x, y); } }; for(auto &&p : c) f(p.first, p.second); auto tot = Totsuho(pos); if(tot.size() <= 1){ cout << 0 << '\n'; return 0; } cout << (Area(tot) + count_edgepoint(tot) + 2) / 2 << '\n'; }