Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/kvadrat-tort-nuqta

Are four points a square?

Easy 1000 ms 128 MB 31%
Share

Four points are given on the plane in arbitrary order. Can they be the vertices of a square of positive area? (The sides of the square need not be parallel to the coordinate axes.) If so, print YES, otherwise print NO.

Four points on the plane and the tilted square they form

Input

Each of the four lines contains two integers — the coordinates of a point.

Output

YES or NO.

Note

$-10^{9} \le x_{i}, y_{i} \le 10^{9}$

Examples

Input #1
1 1
4 2
0 4
3 5
Output #1
YES
Input #2
0 0
2 0
2 1
0 1
Output #2
NO

Sign in to submit a solution

Signing up is free and takes a minute.