Program time limit: 1 seconds
Program memory limit: 256 MB
Frank the Space duck has landed on earth. He landed here in Sydney and found himself surrounded by buildings. As a huge fan of pizza, he wants to eat at least one pizza from every pizza place. To eat a pizza, Frank the duck needs to get on the straight line, and he can use his cosmic gaze to teleport the pizza from the pizza place, to his position. More formally, if the pizza place and Frank are both located on a horizontal street $x$, or if the pizza place and Frank are both located on a vertical street $y$, Frank can eat the pizza.
His friend space bear Noah, told him the pizza locations. To make navigation simple, he wants to visit the pizza places in the order Noah told him. In doing so, Noah denoted Frank's current position as $(0, 0)$. But since, Frank needs to go back to the Cosmic Pond Mallards (CPM), he wants to find the shortest distance he needs to travel.
You should read from standard input.
Additionally:
You should write to standard output.
4
1 1
5 5
1 1000
1000 1
10
First, travel $1$ unit to reach point $(1, 0)$ and eat pizza from $(1, 1)$.
Second, travel $4$ units to reach point $(5, 0)$ and eat pizza from $(5, 5)$.
Third, travel $4$ units to reach point $(1, 0)$ and eat pizza from $(1, 1000)$.
Fourth, travel $1$ unit to reach point $(1, 1)$ and eat pizza from $(1000, 1)$.
Your program will be tested on the sample cases and several hidden cases. If it produces the correct output for all test cases, it will be considered correct. Recall that your final score for this problem is the score of your highest-scoring submission.
The contest ended at 8:16 p.m. AEST on Thursday 2nd July. All submissions will be unofficial .