~/algor $ cat problems/kesishma-yuzi
Intersection area
Two rectangles with sides parallel to the coordinate axes are given on the plane. The first has its lower-left corner at $(x_{1}; y_{1})$ and upper-right corner at $(x_{2}; y_{2})$; the second at $(x_{3}; y_{3})$ and $(x_{4}; y_{4})$. Find the area of their common part. If there is no common part, or it is only a segment or a point, the area is $0$.
Input
The first line has four integers: $x_{1}$, $y_{1}$, $x_{2}$ and $y_{2}$.
The second line has four integers: $x_{3}$, $y_{3}$, $x_{4}$ and $y_{4}$.
Output
One integer — the area of the common part.
Note
$-10^{6} \le x_{1} \lt x_{2} \le 10^{6}$
$-10^{6} \le y_{1} \lt y_{2} \le 10^{6}$
$-10^{6} \le x_{3} \lt x_{4} \le 10^{6}$
$-10^{6} \le y_{3} \lt y_{4} \le 10^{6}$
Examples
0 0 4 3 2 1 6 5
4
0 0 2 2 3 0 5 2
0