Aerodynamic
Contest: Codeforces Round 618 (Div. 1)
Difficulty rating: 1800
Tags: geometry

Guy-Manuel and Thomas are going to build a polygon spaceship.

You're given a strictly convex (i. e. no three points are collinear) polygon $$$P$$$ which is defined by coordinates of its vertices. Define $$$P(x,y)$$$ as a polygon obtained by translating $$$P$$$ by vector $$$\overrightarrow {(x,y)}$$$. The picture below depicts an example of the translation:

Define $$$T$$$ as a set of points which is the union of all $$$P(x,y)$$$ such that the origin $$$(0,0)$$$ lies in $$$P(x,y)$$$ (both strictly inside and on the boundary). There is also an equivalent definition: a point $$$(x,y)$$$ lies in $$$T$$$ only if there are two points $$$A,B$$$ in $$$P$$$ such that $$$\overrightarrow {AB} = \overrightarrow {(x,y)}$$$. One can prove $$$T$$$ is a polygon too. For example, if $$$P$$$ is a regular triangle then $$$T$$$ is a regular hexagon. At the picture below $$$P$$$ is drawn in black and some $$$P(x,y)$$$ which contain the origin are drawn in colored:

The spaceship has the best aerodynamic performance if $$$P$$$ and $$$T$$$ are similar. Your task is to check whether the polygons $$$P$$$ and $$$T$$$ are similar.

Input format:
The first line of input will contain a single integer $$$n$$$ ($$$3 \le n \le 10^5$$$) — the number of points.

The $$$i$$$-th of the next $$$n$$$ lines contains two integers $$$x_i, y_i$$$ ($$$|x_i|, |y_i| \le 10^9$$$), denoting the coordinates of the $$$i$$$-th vertex.

It is guaranteed that these points are listed in counterclockwise order and these points form a strictly convex polygon.

Output format:
Output "YES" in a separate line, if $$$P$$$ and $$$T$$$ are similar. Otherwise, output "NO" in a separate line. You can print each letter in any case (upper or lower).

Constraints:
Time limit: 1.0 s
Memory limit: 256.0 MB

Note:
The following image shows the first sample: both $$$P$$$ and $$$T$$$ are squares. The second sample was shown in the statements.

Example input:
4
1 0
4 1
3 4
0 3

Example output:
YES

Example input:
3
100 86
50 0
150 0

Example output:
nO

Editorial:
$$$T$$$ has the central symmetry: indeed, if $$$P(x,y)$$$ covers $$$(0,0)$$$ and $$$(x_0,y_0)$$$ then $$$P(x-x_0,y-y_0)$$$ covers $$$(-x_0,-y_0)$$$ and $$$(0,0)$$$. So the answer for polygons which don't have the sentral symmetry is NO. Let's prove if $$$P$$$ has the central symmetry then the answer is YES. Translate $$$P$$$ in such a way that the origin becomes its center of symmetry. Let's show that the homothety with the center at the origin and the coefficient $$$2$$$ transforms $$$P$$$ into $$$T$$$:
• if a point $$$(x_0,y_0)$$$ lies in $$$P$$$, then $$$P(x_0,y_0)$$$ covers both $$$(0,0)$$$ and $$$(2x_0,2y_0)$$$;
• if a point $$$(x_0,y_0)$$$ doesn't lie in $$$P$$$, then consider a segment connecting the center of symmetry of the polygon $$$P$$$ (also known as origin) and $$$(x_0,y_0)$$$; it crosses some side of $$$P$$$; WLOG, assume this side is parallel to the $$$x$$$-axis and lies in the line $$$y=y_1, y_1>0$$$ (otherwise we can rotate the plane). Since the polygon is convex, it completely lies in the stripe $$$y \in [-y_1;y_1]$$$, that's why there isn't any vector which connects two points in $$$P$$$ with a $$$y$$$-coordinate greater than $$$2y_1$$$. Since $$$2y_0 > 2y_1$$$, there isn't any vector which connects two points in $$$P$$$ with a $$$y$$$-coordinate equal to $$$2y_0$$$, that's why the point $$$(2x_0,2y_0)$$$ doesn't lie in $$$T$$$.
To find whether a polygon has the central symmetry, check whether the midpoints of segments connecting the opposite vertexes coincide; if a polygon has an odd number of vertexes it can't have the central symmetry.