P2660 zzc Farming

Background

Maybe in the future zzc will go farming.

Description

The field is a huge rectangle. However, zzc can plant only one square at a time, and the stamina cost for planting a square is the square’s perimeter. Areas that have already been planted cannot be planted again. zzc is lazy and wants to save stamina to hang out with girls, so he wants to finish planting the entire field with the least stamina. Find the minimum stamina cost.

Input Format

Two positive integers $x, y$, representing the length and width of the field.

Output Format

Output the minimum stamina cost.

Explanation/Hint

Constraints: $1 \le x, y \le 10^{16}$. Translated by ChatGPT 5