Preview:
#include <iostream>
#include <algorithm>
using namespace std;
long long w, h, s, g, x1, y1, x2, y2, sum1, sum2, y, tot, n;
int main()
{
    cin>>w>>h>>s>>g>>x1>>y1>>x2>>y2;
    y=(y2-y1)*(g+1);
    s=min(s, w-s);
    if(s<x1)
    {
        sum2=x2-x1;
    }
    else if(x2>s)
    {
        sum1=2*(s-x1);
        sum2=x2-s;
    }
    else
    {
        sum1=2*(x2-x1);
    }
    tot=w*h-y*(sum1+sum2);
    cout<<tot;
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter