#include using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x>A>>B>>S; if(abs(A-S)<=abs(B-S) || (B>=S && A>=S)) { x=abs(A-S)+S; } else { x=abs(B-S); if(A>S) { x+=min(A-S+A,(S-1)+A); } else if(A==0) { x+=(S-1)+2; } else x+=S; if(A<=S) x=min(x,(S-A)+S); else x=min(x,A); } cout<