Geometry
Geometry-12
Geometry-13
Geometry-14
~/algor $ cat problems/ichki-butun-nuqtalar
Interior lattice points
Medium
1000 ms
128 MB
56%
A polygon with $n$ vertices is given on the plane: its vertices $(x_{1}; y_{1}), (x_{2}; y_{2}), \ldots, (x_{n}; y_{n})$ are listed in order (clockwise or counterclockwise), and all coordinates are integers. The polygon does not intersect itself. How many points with both coordinates integer lie strictly inside the polygon (not on its boundary)?
Input
The first line contains a positive integer $n$. Each of the next $n$ lines contains two integers: $x_{i}$ and $y_{i}$.
Output
One integer — the number of interior lattice points.
Note
$3 \le n \le 10^{5}$
$-10^{6} \le x_{i}, y_{i} \le 10^{6}$
Examples
Input #1
3 0 0 5 0 0 4
Output #1
6
Input #2
4 0 0 1 0 1 1 0 1
Output #2
0