#P5955. [POI 2018] Pionek

[POI 2018] Pionek

Problem Description

A piece is placed at the origin (0,0)(0,0) on an infinite 2D plane. You have nn available movement commands, and each command can be represented by a 2D integer vector. Each command can be executed once or not executed at all. The piece may pass through the same point multiple times, and the direction vectors of two commands may also be the same. Your goal is to make the piece end up as far from the origin as possible in Euclidean distance. What is this maximum distance?

Input Format

The first line contains a positive integer nn, the number of commands.

The next nn lines each contain two integers x,yx, y, meaning you can move from (a,b)(a,b) to (a+x,b+y)(a+x,b+y).

Output Format

Output one integer on a single line: the square of the maximum distance.

5
2 -2
-2 -2
0 2
3 1
-3 1
26

Hint

For 100%100\% of the testdata, n2×105n \le 2 \times 10^5, and x,y104|x|, |y| \le 10^4.


Sample Explanation

Translated by ChatGPT 5