Company: Swiggy_25nov
Difficulty: medium
Problem Description You are standing at position 0 on an infinite number line and you want to reach the target position N while spending as few coins as possible. You make moves one after another, numbered 1, 2, 3, and so on. On move i you must travel exactly i units, either to the left or to the right, and that move costs you i coins. You may not skip a move and you may not stay where you are. You stop as soon as you are standing on the target position N. Report the minimum total number of coins you have to spend to be standing on position N. Input A single line containing one integer N, the target position on the number line. Output Print a single integer: the minimum total cost, in coins, of standing on position N. If N is 0 you are already standing on the target before any move is made, so the answer is 0. Examples Input: 4 Output: 6 Explanation: One move can only end at 1 or -1, and two moves can only end at 3, 1, -1 or -3, so neither reaches 4. Three moves do reach it: going left