#include #define rep(i,a,b) for(int i=int(a);i> A >> B >> S; //Aが移動する if(abs(S - A) <= abs(S - B) || S == 1 && A == 0){ cout << abs(S - A) + S << endl; }else{ int a = abs(S - B) + abs(S - A) + A; int b = abs(S - B) + (S - 1) + abs(S - 1 - A) + 1; cout << min(a,b) << endl; } }