1. Rhombuses
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

An infinite grid is filled with consecutive natural numbers arranged in the form of concentric rhombuses. The filling of each rhombus starts from its top cell and goes clockwise — see the figure. The cell containing the number 1 is called the central cell.

For several given pairs of values x and y, determine which number is located in the cell that is x steps to the right of the central cell and y steps above it. For example, for x=2, y=1 the answer will be 16. Find the answers for the following pairs:

  • x=3, y=2.
  • x=0, y=10.
  • x=12, y=0.
  • x=12345, y=54321.

To submit a solution in the Codeforces system, click the "Submit code" link (above the problem statement). In the "Source code" field, write four integers separated by spaces, without writing anything extra. In the "Language" field, select the PHP language.

Scoring

Each correct answer is worth 25 points. The participant is informed of the total points scored.

During the Olympiad, participants had 10 attempts to submit a solution. There is no such restriction on Codeforces.