func main() var t: int :: cui@inputInt() for(1, t) var A: int :: cui@inputInt() var B: int :: cui@inputInt() var C: int :: cui@inputInt() ; bが最大のとき var ans1: int :: 10 ^ 10 block var a: int :: A var b: int :: B var c: int :: C var cnt: int :: 0 if(a >= b) do cnt :+ a - (b - 1) do a :: b - 1 end if if(c >= b) do cnt :+ c - (b - 1) do c :: b - 1 end if if(a = c) do cnt :+ 1 do a :- 1 end if if(a > 0 & c > 0) do ans1 :: cnt end if end block ; bが最小のとき var ans2: int :: 10 ^ 10 block var a: int :: A var b: int :: B var c: int :: C var cnt: int :: 0 if(a = c) do cnt :+ 1 do a :- 1 end if var target: int :: lib@min(a, c) if(b >= target) do cnt :+ b - (target - 1) do b :: target - 1 end if if(b > 0) do ans2 :: cnt end if end block var ans: int :: lib@min(ans1, ans2) if(ans = 10 ^ 10) do ans :: -1 end if do cui@print("\{ans}\n") end for end func