Problem:
 Score : 300 points    Problem Statement You are given three integers A , B and C . Find the minimum number of operations required to make A , B and C all equal by repeatedly performing the following two kinds of operations in any order:   Choose two among A , B and C , then increase both by 1 .  Choose one among A , B and C , then increase it by 2 .   It can be proved that we can always make A , B and C all equal by repeatedly performing these operations.      Constraints  0 \leq A,B,C \leq 50  All values in input are integers.         Input Input is given from Standard Input in the following format:  A  B  C       Output Print the minimum number of operations required to make A , B and C all equal.        Sample Input 1 2 5 4      Sample Output 1 2  We can make A , B and C all equal by the following operations:   Increase A and C by 1 . Now, A , B , C are 3 , 5 , 5 , respectively.  Increase A by 2 . Now, A , B , C are 5 , 5 , 5 , respectively.        Sample Input 2 2 6 3      Sample Output 2 5       Sample Input 3 31 41 5      Sample Output 3 23

Solution (Python):
import numpy as np
 
L=np.array(list(map(int,input().split())))
ans=0
 
while True:
    if L[0]==L[1] and L[1]==L[2]:
        break
    L=sorted(L-max(L))
    if L[1]<L[2]:
        L[0]+=1
        L[1]+=1
        ans+=1
    else:
        L[0]+=2
        ans+=1

print(ans)

Solution (Python):
A,B,C = [int(i) for i in input().split()]
if A%2 == B%2 == C%2:
    m = max(A,B,C)
    print((3*m - A - B - C)//2)
elif A%2 == B%2:
    A += 1
    B += 1
    m = max(A,B,C)
    print(1 + (3*m - A - B - C)//2)
elif A%2 == C%2:
    A += 1
    C += 1
    m = max(A,B,C)
    print(1 + (3*m - A - B - C)//2)
elif B%2 == C%2:
    B += 1
    C += 1
    m = max(A,B,C)
    print(1 + (3*m - A - B - C)//2)

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0
inf = float("inf")

a,b,c = sorted(I())
ans = 0
a += c-b
ans += c-b
if (c-a)%2==0:
    print(ans+(c-a)//2)
else:
    print(ans+(c-a)//2 +2)

Solution (Python):
a = sorted(list(map(int, input().split())))

s = sum(a)
if s%2==a[2]%2:
  if a[2]%2==a[1]%2:
    print((a[2]-a[1])//2+(a[2]-a[0])//2)
  else:
    a[1] += 1
    a[0] += 1
    print((a[2]-a[1])//2+(a[2]-a[0])//2+1)
else:
  a[2] += 1
  a[1] += 1
  if a[2]%2==a[1]%2:
    print((a[2]-a[1])//2+(a[2]-a[0])//2+1)
  else:
    a[1] += 1
    a[0] += 1
    print((a[2]-a[1])//2+(a[2]-a[0])//2+2)

Solution (Python):
import numpy as np

L=np.array(list(map(int,input().split())))
ans=0

while True:
  if L[0]==L[1] and L[1]==L[2]:
    break
  L=sorted(L-max(L))
  if L[1]<L[2]:
    L[0]+=1
    L[1]+=1
    ans+=1
  else:
    L[0]+=2
    ans+=1
    
print(ans)

Solution (Python):
ABC = list(map(int, input().split()))
ABC.sort()
count = ABC[2] - ABC[1]
other = ABC[2] - ABC[0] - count

if other % 2 == 0:
    count += other / 2
else:
    count += other // 2 + 2

print(int(count))

Solution (Python):
a, b, c = sorted(map(int, input().split()))
ans = 0
a += (c-b)
ans += (c-b)
if (c-a)%2==0:
    print(ans+(c-a)//2)
else:
    print(ans+(c-a)//2+2)

Solution (Python):
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return map(int, sys.stdin.readline().split())
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

hq = list(LI())
heapq.heapify(hq)

cnt = 0
while 1:
    if hq[1] == hq[0] and hq[0] == hq[2]:
        break
    else:
        i = heapq.heappop(hq)
        j = heapq.heappop(hq)
        if i == j:
            heapq.heappush(hq, i+1)
            heapq.heappush(hq, i+1)
        else:
            heapq.heappush(hq, i+2)
            heapq.heappush(hq, j)
        cnt += 1

print(cnt)

Solution (Python):
a, b, c = map(int, input().split())

x = 3 * max(a, b, c) - a - b - c
if x % 2 == 0:
    print(x // 2)
else:
    print(x // 2 + 2)

Solution (Python):
import sys
input = sys.stdin.readline

A = sorted(list(map(int,input().split())))
subA = A[2]-A[1]+A[2]-A[0]
print(subA//2 + subA%2*2)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()


def main():
    L = list(map(int, input().split()))
    L.sort()
    a, b, c = L[0], L[1], L[2]
    ans = c - b
    a += ans
    if (c - a) % 2 != 0:
        ans += 1
        c += 1
    print(ans + (c - a) // 2)


if __name__ == "__main__":
    main()

Solution (Python):
def resolve():
    X = list(map(int, input().split()))
    X.sort()
    
    ans = X[-1] - X[1]
    if (X[-1]-X[0]-ans) % 2 == 0:
        ans += (X[-1] - X[0]-ans) / 2
    else:
        ans += 1
        ans += (X[-1] - X[0]-ans) / 2  + 1
    print(int(ans))

    return

resolve()

Solution (Python):

(*a, ) = map(int, input().split())
a.sort()
b = a[-1] - a[-2]
c = a[1] - a[0]
print(b + -(-c // 2) + c % 2)

Solution (Python):
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

aa=sorted(nl())[::-1]

ans = 0
if(aa[1]-aa[2])%2==1:
  aa[0]+=1
  aa[1]+=1
  ans=1
ans+=(aa[1]-aa[2])//2
ans += aa[0]-aa[1]
print(ans)

Solution (Python):
a = list(map(int, input().split()))
a.sort()
ans = a[2]-a[1]
a[0] += ans
if (a[2]-a[0])%2 == 0:
    print(ans+(a[2]-a[0])//2)
else:
    print(ans+(a[2]-a[0])//2+2)

Solution (Python):
nums = list(map(int, input().split()))
nums.sort()
count = nums[2] - nums[1]
nums[0] += nums[2] - nums[1]
if (nums[2]-nums[0])%2 == 0:
  count += (nums[2]-nums[0])//2
else:
  count += (nums[2]-nums[0])//2 + 2
print(count)

Solution (Python):
abc = sorted(list(map(int, input().split())))

if (abc[0]%2==0 and abc[1]%2==0) or (abc[0]%2==1 and abc[1]%2==1):
  ans = 0
  ans += abc[2]-abc[1]
  ans += (abc[1]-abc[0])//2
  print(ans)
else:
  count = 0
  for i in abc:
    if i%2 == 0: count+=1

  for i in range(len(abc)):
    if count == 2:
      if abc[i]%2 == 0: abc[i] += 1
    else:
      if abc[i]%2 == 1: abc[i] += 1
  ans = 1
  ans += abc[2]-abc[1]
  ans += (abc[1]-abc[0])//2
  print(ans)

Solution (Python):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    X = sorted(in_nl())

    A, B, C = X[0], X[1], X[2]

    t = (C - A) + (C - B)
    if t % 2 == 0:
        ans = t // 2
    else:
        C += 1
        A += 1
        ans = ((C - A) + (C - B)) // 2 + 1

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    nums = list(map(int, input().split()))

    M = max(nums)
    diff = 3 * M - sum(nums)

    print((diff) // 2) if diff%2 == 0 else print((3*M+3-sum(nums))//2)

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    nums = list(map(int, input().split()))

    

    
    
    

    
    
    
    
    
    

    
    
    
    M = max(nums)
    diff = 3 * M - sum(nums)

    print((diff) // 2) if diff%2 == 0 else print((3*M+3-sum(nums))//2)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    nums = list(map(int, input().split()))

    res = 0

    while len(set(nums)) != 1:
        maxIdx = nums.index(max(nums))
        minIdx = nums.index(min(nums))

        if nums[maxIdx] - nums[minIdx] >= 2:
            nums[minIdx] += 2
            res += 1
        else:
            nums[minIdx] += 1
            nums[nums.index(min(nums))] += 1

            res += 1
    
    print(res)


if __name__ == '__main__':
    main()

Solution (Python):

a,b,c=map(int,input().split())



mx=max(a,b,c)
dif=3*mx-(a+b+c)
if dif%2==0:
    ans=dif//2
else:
    ans=dif//2+2

print(ans)

Solution (Python):
ABC=list(map(int,input().split()))
ABC.sort()
mn=ABC[0]
md=ABC[1]
mx=ABC[2]
if (mx*2-md-mn)%2==0:
  print((mx*2-md-mn)//2)
else:
  print((mx*2-md-mn+3)//2)

Solution (Python):
def main():
    abc = list(map(int, input().split()))

    abc_sort = sorted(abc)
    min_num, mid_num, max_num = abc_sort
    Count = 0
    while(max_num - min_num > 1):
        diff = max_num - min_num
        Count += diff//2
        abc_sort[0] += (diff//2) * 2
        abc_sort = sorted(abc_sort)
        max_num = abc_sort[2]
        min_num = abc_sort[0]

    if (abc_sort[2] - abc_sort[1] == 1):
        Count += 1
    elif (abc_sort[2]-abc_sort[1] == 0 and abc_sort[1] - abc_sort[0] == 1):
        Count += 2
    print(Count)


if __name__ == "__main__":
    main()

Solution (Python):
nums = list(map(int, input().split()))

M = max(nums)
while True:
    ans = 0
    for num in nums:
        ans += M - num
    if ans % 2 == 0:
        break
    M += 1

print(ans // 2)

Solution (Python):
a = list(map(int,input().split()))
a = sorted(a)
i = (a[1] - a[0])//2
a[0] += i*2
i += a[2] - a[1]
if a[0] != a[1]:
  i += 2

print(i)

Solution (Python):
abc = list(map(int, input().split()))
abc.sort()

bc = abc[2] - abc[1]
ab = abc[1] - abc[0]

print(bc + ab//2 if ab%2==0 else bc + ab//2 + 2)

Solution (Python):
A, B, C = map(int, input().split())
S = [A, B, C]
D = max(S)
less = [0, 0, 0]
for i in range(3):
  less[i] = D - S[i]
less = sorted(less)

ans = less[1]
remain = less[2] - less[1]
if remain % 2 == 0:
  ans += remain // 2
else:
  ans += (remain // 2) + 2

print(int(ans))

Solution (Python):
import sys, os, math, bisect, itertools, collections, heapq, queue

from decimal import Decimal
from collections import defaultdict, deque



sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)


MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    ABC = il()
    if ABC[0] == ABC[1] == ABC[2]:
        print(0)
        exit()
    n = 1
    while True:
        if 3 * n >= sum(ABC) and n >= max(ABC) and (3 * n - sum(ABC)) % 2 == 0:
            print((3 * n - sum(ABC)) // 2)
            exit()
        else:
            n += 1


if __name__ == '__main__':
    main()

Solution (Python):
A, B, C = sorted(map(int, input().split()))
count = 0

diff = C - B
count += diff
A += diff
B += diff

if (B - A) % 2 == 0:
    count += (B - A) // 2
else:
    count += (B - A) // 2 + 2

print(count)

Solution (Python):
A,B,C = map(int,input().split())
a = max(A,B,C)
c = min(A,B,C)
b = A+B+C-a-c
ans = a-b
if (b-c)%2==0:
    print(ans + (b-c)//2)
else:
    print(2 + ans + (b-c)//2)

Solution (Python):
A,B,C=map(int,input().split())
M=max(A,B,C)
tmp=M*3
Sum=A+B+C
Check=tmp-Sum
if Check%2==0:
  ans=(tmp-Sum)//2
else:
  tmp2=(M+1)*3
  ans=(tmp2-Sum)//2
print(ans)

Solution (Python):
s=sorted(map(int,input().split()))
ans=0
while s[0]+2<=s[2]:
    s[0]+=2
    ans+=1
while s[1]+2<=s[2]:
    s[1]+=2
    ans+=1
    
s=sorted(s)
if s[0]==s[2]:
    print(ans)
elif s[0]==s[1]:
    print(ans+1)
else:
    print(ans+2)

Solution (Python):
A, B, C = map(int, input().split())
num = [A, B, C]
cnt =0

for i in range(2):
    multi = (max(num)-min(num))//2
    num[num.index(min(num))] += 2*multi
    cnt += multi

if len([i for i in num if i==max(num)]) ==1:
    cnt += 1
elif len([i for i in num if i==max(num)]) ==2:
    cnt += 2
print(cnt)

Solution (Python):
l=list(map(int, input().split()))
l.sort()
base=l[2]-l[1]
if (l[1]-l[0])%2==1:
  base+=1
  l[1]+=1
ans=base+(l[1]-l[0])//2
print(ans)

Solution (Python):
a, b, c = map(int, input().split())
eo = (a + b + c) % 2
lv = max(a, b, c) * 3
tgt = (lv if lv % 2 == eo else lv + 3)
print((tgt - (a + b + c)) // 2)

Solution (Python):
ABC = list(map(int, input().split()))
ABC.sort()
ans = 0

while ABC.count(min(ABC)) != 3:
    if ABC.count(min(ABC)) == 2:
        dif = ABC[2] - ABC[0]
        ABC[0] += dif
        ABC[1] += dif
        ans += dif
    else:
        ABC[0] += 2
        ans += 1
        ABC.sort()

print(ans)

Solution (Python):
lst = sorted(list(map(int, input().split())), reverse=True)
diff = lst[0] * 2 - lst[1] - lst[2]
if diff % 2 == 0:
  print(diff // 2)
else:
  print(diff // 2 + 2)

Solution (Python):
a = list(map(int, input().split()))
a.sort()
d = a[2] * 2 - a[0] - a[1]
if d % 2 == 1:
  d += 4
print(d//2)

Solution (Python):
A = list(map(int, input().split()))
A.sort()
DifA = A[2] - A[1]
DifB = A[2] - A[0]

if DifA % 2 == 0 and DifB % 2 == 0:
    ans = ( DifA + DifB ) // 2
elif DifA % 2 == 1 and DifB % 2 == 1:
    ans = ( DifA + DifB ) // 2
else:
    ans = ( DifA + DifB + 3 ) // 2
print(ans)

Solution (Python):
a = list(map(int,input().split()))
a.sort()
dif = 2*a[2]-a[1]-a[0]
if dif%2 == 0:
    print(dif//2)
else:
    print(dif//2+2)

Solution (Python):

a,b,c=map(int,input().split())




mx=max(a,b,c)
dif=3*mx-(a+b+c)
if dif%2==0:
    ans=dif//2
else:
    ans=dif//2+2
print(ans)

Solution (Python):
abc = list(map(int, input().split()))
abc.sort()
c = abc[2]
ab = abc[0] + abc[1]
if ab % 2 == 0:
    print((c * 2 - ab) // 2)
else:
    c += 1
    ab += 1
    print((c * 2 - ab) // 2 + 1)

Solution (Python):
A=list(map(int,input().split()))
A.sort()
a=A[2]-A[1]
b=A[2]-A[0]
if a%2==0 and b%2==0:
  print(a//2+b//2)
elif a%2==1 and b%2==1:
  print(a//2+b//2+1)
else:
  print(a//2+1+b//2+1)

Solution (Python):
num = list(map(int, input().split()))
num.sort()

x = num[2] * 3 - sum(num)

if x%2 == 0:
  ans = int(x/2)
else:
  ans = int(x//2 + 2)

print(ans)

Solution (Python):
a,b,c=map(int,sorted(list(map(int,input().split()))))
cnt=0
while True:
  if a==b==c:break
  elif a==b:
    cnt+=c-a
    break
  else:
    a,b,c=map(int,sorted([a+2,b,c]))
    cnt+=1
print(cnt)

Solution (Python):
def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    A, B, C = mi()
    m = max(A, B, C)
    s = sum([A, B, C])
    cnt = 0
    while True:
        if s%3==0 and s>=3*m:
            break
        s += 2
        cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

Solution (Python):
A, B, C = map(int, input().split())
M = max(A, B, C)
s = 3 * M - A - B - C
if s % 2 == 0:
  ans = s // 2
else:
  ans = (s + 3) // 2
print(ans)

Solution (Python):
def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

ABC = LI()
ABC.sort()
ans = 0

if (ABC[1] - ABC[0]) % 2 == 0:
    ans = (ABC[1] - ABC[0]) // 2 + ABC[2] - ABC[1]
    print(ans)

else:
    ABC[0] += 1
    ABC[2] += 1
    ans = ans = (ABC[1] - ABC[0]) // 2 + ABC[2] - ABC[1] + 1
    print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(1000000)

a,b,c=map(int,input().split())
ans=0
def dfs(x,y,z):
    global ans
    if x==y==z:
        print(ans)
    elif x==y and x<z:
        ans+=1
        dfs(x+1,y+1,z)
    elif y==z and y<x:
        ans+=1
        dfs(x,y+1,z+1)
    elif x==z and x<y:
        ans+=1
        dfs(x+1,y,z+1)
    elif x<y<=z or x<z<=y:
        ans+=1
        dfs(x+2,y,z)
    elif y<x<=z or y<z<=x:
        ans+=1
        dfs(x,y+2,z)
    elif z<x<=y or z<y<=x:
        ans+=1
        dfs(x,y,z+2)
dfs(a,b,c)

Solution (Python):
abc = [int(i) for i in input().split()]
abc.sort()
ab, bc = abc[2] - abc[1], abc[2] - abc[0]
cnt = 0
if ab % 2 == 0 and bc % 2 == 0:
    cnt += ab//2
    cnt += bc//2
elif ab % 2 != 0 and bc % 2 != 0:
    cnt += ab//2
    cnt += bc//2 + 1
else:
    cnt += ab//2
    cnt += bc//2 + 2
print(cnt)

Solution (Python):
z,y,x = sorted(list(map(int,input().split())))
print((3*x-(x+y+z))//2 if (3*x-(x+y+z))%2==0 else (3*x-(x+y+z))//2+2)

Solution (Python):
l = sorted(list(map(int,input().split())))
z = l[0]
y = l[1]
x = l[2]


ans = 0

if (y-z) % 2 == 0:
    ans += (y-z)//2
    ans += (x-y)
else:
    x += 1
    z += 1
    ans += 1
    ans += (y-z)//2
    ans += (x-y)
print(ans)

Solution (Python):
a=list(map(int,input().split()))
a.sort()
x=(a[2]-a[1])+(a[1]-a[0])//2+((a[1]-a[0])%2)*2
print(x)

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

A,B,C = I()
cnt = 0
for i in range(1000):
    if A != B and B != C and A != C:
        A += 1
        B += 1
        C += 1
        if max(A,B,C) == A:
            A -= 1
        elif max(A,B,C) == B:
            B -= 1
        else:
            C -= 1
        cnt += 1
    if A == B and B == C and A == C:
        print(cnt)
        exit()
    if A == B or B == C or A == C:
        d = abs(max(A,B,C)-min(A,B,C))
        if [A,B,C].count(max(A,B,C)) == 2:
            if d%2 == 0:
                print(cnt+d//2)
                exit()
            else:
                print(cnt+d//2+2)
                exit()
        else:
            print(cnt+d)
            exit()

Solution (Python):

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

A = lr()
A.sort()
lack = A[2] - A[0] + (A[2] - A[1])
answer = lack // 2
if lack&1:
    answer += 2
print(answer)

Solution (Python):
abc = list(map(int,input().split()))
abc.sort()
a = abc[0]
b = abc[1]
c = abc[2]
count = 0
x = c-b
a += x
b += x
count += x
if not (b-a) % 2 == 0:
    b += 1
    c += 1
    count += 1
x = (b-a)//2
a += (b-a)
count += x
print(count)

Solution (Python):


a, b, c = map(int, input().split())
m = max(a, b, c)

if (3*m-(a+b+c))%2 == 0:
    print((3*m-(a+b+c))//2)
else:
    print((3*(m+1)-(a+b+c))//2)

Solution (Python):

import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left 
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

l = list(map(int, input().split()))
l.sort()

dif = 2*l[2] - l[1] - l[0]
if dif%2==0:
    print(dif//2)
else:
    print((dif+3)//2)

Solution (Python):
a = list(map(int , input().split()))
maxa = max(a)
x = sum(map(lambda x: maxa-x, a))

if x % 2 == 0:
    print(x // 2)
else:
    print((x+3) // 2)

Solution (Python):
a = list(map(int , input().split()))
a.sort()
ans = 0
ans += ((a[-1]-a[0]) // 2)
ans += ((a[-1]-a[1]) // 2)
a[0] += 2 * ((a[-1]-a[0]) // 2)
a[1] += 2 * ((a[-1]-a[1]) // 2)
a.sort()
if a[0] < a[-1] and a[1] == a[-1]:
    print(ans + 2)
    exit()
if a[0] < a[-1] and a[1] < a[-1]:
    print(ans + 1)
    exit()
print(ans)

Solution (Python):
def main():
    nums = list(map(int, input().split()))
    nums.sort(reverse=True)

    cnt = 0
    if (nums[1] - nums[2]) % 2 == 0:
        cnt += (nums[1] - nums[2]) // 2
        cnt += nums[0] - nums[1]

    else:
        cnt += 1
        cnt += (nums[1] - nums[2] + 1) // 2
        cnt += nums[0] - nums[1]

    print(cnt)

if __name__ == '__main__':
    main()

Solution (Python):
l=list(map(int,input().split()))
l = sorted(l, reverse=True)
count = 0
while True:
  if l[0] == l[1] == l[2]:
    break
  elif l[0] > l[1]:
    l[1] += 1
    l[2] += 1
  else:
    l[2] += 2
    
  l = sorted(l, reverse=True)
  count += 1
print(count)

Solution (Python):
import sys
a=list(map(int,input().split()))
a.sort()
ans=0
while True:
    if a[0]==a[1]==a[2]:
        print(ans)
        sys.exit()
    if a[0]<a[1]:
        a[0]+=2
        ans+=1
        a.sort()
        if a[0]==a[1]==a[2]:
            print(ans)
            sys.exit()
    if a[0]==a[1]:
        a[0]+=1
        a[1]+=1
        ans+=1
        a.sort()
        if a[0]==a[1]==a[2]:
            print(ans)
            sys.exit()

Solution (Python):
a,b,c=sorted(map(int,input().split()))

cnt=0
if a%2==b%2==c%2:
    cnt=0
elif a%2==b%2:
    cnt+=1
    a+=1
    b+=1
elif b%2==c%2:
    cnt+=1
    b+=1
    c+=1
elif a%2==c%2:
    cnt+=1
    a+=1
    c+=1

cnt+=(c-a)//2+(c-b)//2
print(cnt)

Solution (Python):
abc = list(map(int, input().split()))
abc.sort()

diff = 2*abc[2] - abc[0] - abc[1]

if diff%2:
    ans = (diff+1)//2 + 1
else:
    ans = diff//2
print(ans)

Solution (Python):
ABC = list(map(int, input().split()))
ABC.sort()
cnt = 0
while not ABC[0] == ABC[1] == ABC[2]:
    ABC.sort()
    if ABC[2] - ABC[0] > 1:
        ABC[0] += 2
        cnt += 1
    else:
        if ABC[0] == ABC[1]:
            ABC[0] += 1
            ABC[1] += 1
            cnt += 1
        else:
            ABC[1] += 1
            ABC[2] += 1
            cnt += 1
print(cnt)

Solution (Python):






abc = list(map(int, input().split()))





abc_s = sorted(abc)
ones = abc_s[2] - abc_s[1]
twos = -(-(abc_s[2] - (abc_s[0]+ones))//2) + (abc_s[2] - (abc_s[0]+ones))%2
print(ones+twos)

Solution (Python):
def main():
    A, B, C = map(int, input().split())

    if A == B and A == C:
        return 0

    ans = 0
    sum = A+B+C
    while True:
        sum += 2
        if (sum % 3) == 0 and A<=(sum/3) and B<=(sum/3) and C<=(sum/3):
            break

    m = sum/3
    while True:
        if (m - A) >= 2:
            A += 2
            ans += 1
        else:
            break

    while True:
        if (m - B) >= 2:
            B += 2
            ans += 1
        else:
            break

    while True:
        if (m - C) >= 2:
            C += 2
            ans += 1
        else:
            break

    if A != m or B != m or C != m:
        ans += 1
    return ans

print(main())

Solution (Python):
a,b,c=map(int,input().split())
l=[a,b,c]
l.sort()
cnt=l[2]-l[1]
sa=l[2]-(l[0]+cnt)
cnt+=sa//2
if sa%2!=0:
  cnt+=2
print(cnt)

Solution (Python):
a,b,c = sorted(list(map(int, input().split())))

ans=0
if b!=c:
    b+=ans
    ans+=c-b
a+=ans
q,r = divmod(c-a, 2)
ans+=q
if r>0:
    ans+=2
print(ans)

Solution (Python):
nums = list(map(int, input().split()))

max_num = max(nums)
sum_num = sum(nums)

if max_num * 3 % 2 != sum_num % 2:
    max_num += 1

ans = (max_num * 3 - sum_num) // 2
print(ans)

Solution (Python):
l=sorted(map(int,input().split()))
a=2*l[2]-l[1]-l[0]
print((a+3)//2 if a%2 else a//2)

Solution (Python):
a = list(map(int,input().split()))
a = sorted(a)
a,b,c = a[0],a[1],a[2]
ca = c-a
cb = c-b
if ca % 2 == 0 and cb % 2 == 0:
    print(ca //2 + cb //2)
elif ca % 2 == 1 and cb % 2 == 1:
    print(((ca-1) // 2) + ((cb-1) // 2) + 1)
elif ca % 2 == 1 and cb % 2 == 0:
    print((cb // 2) + 1 + ((ca+1) // 2))
elif cb % 2 == 1 and ca % 2 == 0:
    print((ca // 2) + 1 + ((cb+1) // 2))

Solution (Python):
a,b,c=map(int,input().split())
m=max(a,b,c)
a=m-a
b=m-b
c=m-c
if (a+b+c)%2==0:
  print((a+b+c)//2)
else:
  print((a+b+c)//2+2)

Solution (Python):
li=list(map(int,input().split()))
li.sort()
ans=0
if (li[1]-li[0])%2:
  li[1]+=1
  li[2]+=1
  ans+=1
ans+=li[2]-li[1]
ans+=(li[1]-li[0])//2
print(ans)

Solution (Python):

a,b,c = map(int,input().split(" "))
sum = a+b+c
max = max(a,b,c)
if (sum - max)%2 == 0:
    print(int((max*3 - sum)/2))
else:
    print(int(((max+1)*3 - sum)/2))

Solution (Python):
a, b, c = map(int, input().split())
h = max(a, b, c)
s = a + b + c
ans = 0
if h % 2 == s % 2:
  ans = (h * 3 - s) // 2
else:
  ans = ((h + 1) * 3 - s) // 2
print(ans)

Solution (Python):
num = list(input().split())
num = sorted([int(num[i]) for i in range(3)])

a = num[2] - num[1]
b = (num[2] - a - num[0]) % 2
c = (num[2] - a - num[0]) // 2

if b == 1:
    print(a + c + 2)
else:
    print(a + c)

Solution (Python):

X = list(map(int, input().split()))
cnt = 0
if sum([x%2 for x in X]) == 2:
    for i in range(3):
        X[i] = X[i] + 1 if X[i]%2 == 1 else X[i]
        cnt = 1
elif sum([x%2 for x in X]) == 1:
    for i in range(3):
        X[i] = X[i] + 1 if X[i]%2 == 0 else X[i]
        cnt = 1
Max = max(X)
X.remove(Max)
print( (2 * Max - sum(X) )//2 + cnt )

Solution (Python):
a,b,c = map(int, input().split())
d = max(a,b,c)
x = d-a + d-b + d-c
if x % 2 == 0:
    print(x//2)
else:
    print((x+1)//2 + 1)

Solution (Python):
a, b, c = sorted(map(int, input().split()), reverse=True)

parity = (a + b + c) % 2 
m3 = (a*3) % 2 

if parity == m3:
    x = a
else:
    x = a + 1

print((x*3 - (a+b+c)) // 2)

Solution (Python):
A = [int(x) for x in input().split()]
if sum(A) % 2 == max(A) % 2:
    ans = (max(A) * 3 - sum(A)) // 2
else:
    ans = ((max(A) + 1) * 3 - sum(A)) // 2
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
def main():
    num = list(map(int, input().split()))
    MAX = max(num)
    CNT = 0
    for i in range(3):
        num[i] -= MAX
        CNT -= num[i]
    if CNT%2 == 0:
        ans = CNT//2
        print(ans)
    else:
        ans = CNT//2 + 2
        print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
a = [int(i) for i in input().split()]
a = sorted(a)
diff = (a[2] - a[0]) + (a[2] - a[1])
if diff % 2 == 0:
    print(diff // 2)
else:
    print(2 + diff // 2)

Solution (Python):
a, b, c = sorted(map(int, input().split()), reverse=True)
ans = (a - b) + (b - c) // 2
if (b - c) % 2 == 1:
    ans += 2
print (ans)

Solution (Python):
a,b,c=map(int,input().split())
A=[a,b,c]
A.sort()
k=A[0]+(A[2]-A[1])
if (A[2]-k)%2==0:
    print(A[2]-A[1]+(A[2]-k)//2)
else:
    print(A[2]-A[1]+(A[2]-k)//2+2)

Solution (Python):
ABC = list(map(int, input().split()))
ABC = sorted(ABC)[::-1]

diff1 = ABC[0]-ABC[1]
diff2 = ABC[1]-ABC[2]

cnt2 = 0

if diff2 % 2 ==0:
  cnt2 = diff2 /2
else:
  cnt2 = 2 + diff2 /2

ans = int(diff1 + cnt2)
print(ans)

Solution (Python):
a, b, c = map(int, input().split())

M = max(a, b, c)

if (a+b+c)%2 != (M* 3) % 2:
    M += 1


diff = 3 * M - a - b - c
print(diff // 2)

Solution (Python):
a, b, c = [int(i) for i in input().split()]

x = max([a,b,c])
tmp = 1
while tmp % 2 == 1:
    tmp = x - a + x - b + x - c
    x += 1

print(tmp // 2)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

abc = list(map(int, readline().split()))
abc.sort()

ans = abc[2]-abc[1]
res = abc[1]-abc[0]
if res % 2 == 0:
    ans += res // 2
else:
    ans += res // 2 + 2

print(ans)

Solution (Python):
a,b,c=map(int,input().split())
num1=max(a,b,c)
if num1==a:
    num2=a-b
    num3=a-c
elif num1==b:
    num2=b-a
    num3=b-c
else:
    num2=c-a
    num3=c-b
num4=abs(num2-num3)
if num4%2==0:
    print((num2+num3)//2)
else:
    print((num2+num3)//2+2)

Solution (Python):
n = list(map(int,input().split()))
cnt = 0

while n.count(n[0]) != len(n):
    n.sort()
    if n[0] == n[1]:
        n[0] += 1
        n[1] += 1
    else:
        n[0] += 2
    cnt += 1
print(cnt)

Solution (Python):
n = list(map(int,input().split()))
cnt = 0

while n.count(n[0]) != len(n):
    n.sort()
    if n[0] == n[1]:
        n[0] += 1
        n[1] += 1
    else:
        n[0] += 2
    cnt += 1
print(cnt)

Solution (Python):
z=list(map(int,input().split()))
list.sort(z, reverse=True)
c=z[0]
b=z[1]
a=z[2]
x=(c-b)//2 + (c-a)//2

if((c-b)%2==1):
  if((c-a)%2==1):
    x+=1
  else:
    x+=2
elif((c-a)%2==1):
  x+=2
print(x)

Solution (Python):
a=list(map(int,input().split()))

a.sort()

answer=((a[2]-a[1])+(a[2]-a[0]))/2
if ((a[2]-a[1])+(a[2]-a[0]))%2!=0:
    answer+=1.5

print(int(answer))

Solution (Python):
a,b,c = map(int,input().split())
max_num = max(a,b,c)
sum_num = a+b+c
if (max_num-3*sum_num)%2==0:
  print((max_num*3-sum_num)//2)
else:
  print(((max_num+1)*3-sum_num)//2)

Solution (Python):
import sys
a=list(map(int,input().split()))
a.sort()
l0=a[0]-a[2]
l1=a[1]-a[2]
l2=0
c=0
while(c<1000):
    if l2==l1 and l2==l0:
        print(c)
        break
    elif l1==l0:
        l1+=1
        l0+=1
    elif (l1-l0)%2==0:
        l0+=2
    else:
        l0+=1
        l2+=1
    c+=1

Solution (Python):
a=list(map(int,input().split()))
a.sort()
cnt=0
if a[1]!=a[2]:
    cnt=a[2]-a[1]
    a[0]+=cnt
    a[1]+=cnt
if 1==(a[1]-a[0])%2:
    a[1]+=1
    a[2]+=1
    cnt+=1
if a[0]!=a[1]:
    n=int((a[1]-a[0])/2)
    cnt+=n
    
print(cnt)

Solution (Python):
num=list(map(int, input().split()))
num.sort()

m=num[2]*3

if sum(num)%2==m%2:
    print((m-sum(num))//2)
else:
    print((m-sum(num))//2+2)

Solution (Python):
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    abc = map(int, input().split())
    a, b, c = sorted(abc)
    if (b - a) % 2 == 0:
        print((2 * c - a - b) // 2)
    else:
        print((2 * (c + 1) - a - b - 1) // 2 + 1)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Solution (Python):
abc = list(map(int, input().split()))
abc.sort()
a, b, c = abc[0], abc[1], abc[2]
if a % 2 == b % 2:
    ans = (2 * c - a - b) // 2
else:
    ans = (2 * c + 1 - a - b) // 2 + 1
print(ans)

Solution (Python):
abc = list(map(int, input().split()))
a, b, c = sorted(abc)
cou = c - b
if (b-a) % 2 == 0:
    cou += (b-a)//2
else:
    cou += (b-a)//2 + 2
print(cou)

Solution (Python):
a, b, c = map(int, input().split())
m = max([a, b, c])
print((m * 3 - (a + b + c)) // 2 if (a + b + c) % 2 == (m * 3) % 2 else ((m + 1) * 3 - (a + b + c)) // 2)

Solution (Python):
abc = list(map(int, input().split()))
abc.sort()
abc2 = abc[:]

if sum(abc) % 2 != 3 * abc[2] % 2:
    abc2[2] += 1

print((abc2[2] * 3 - sum(abc)) // 2)

Solution (Python):
def main():
    a, b, c = map(int, input().split())
    m = max(a, b, c)
    d = m * 3 - sum([a, b, c])
    ans = d // 2
    if d % 2 == 0:
        print(ans)
    else:
        print(ans + 2)
    
if __name__ == '__main__':
    main()

Solution (Python):
li = list(map(int,input().split()))
li.sort()

lin = li[:]

if sum(li)%2 != 3*li[2]%2:
    lin[2] += 1

print((lin[2]*3-sum(li))//2)

Solution (Python):
def main():
    *A, = map(int, input().split())

    ps = tuple(set() for _ in range(2))
    for i, x in enumerate(A):
        ps[x % 2].add(i)

    ret = 0
    for j in range(2):
        if len(ps[j]) == 2:
            for i in ps[j]:
                A[i] += 1
            ret += 1

    ma = max(A)
    ret += (ma * 3 - sum(A)) // 2

    print(ret)


if __name__ == '__main__':
    main()

Solution (Python):
abc = list(map(int, input().split()))
abc.sort()

cnt = 0
while max(abc) - min(abc) > 1:
    abc[0] += 2
    abc.sort()
    cnt += 1

if abc[0] == abc[1] == abc[2]:
    cnt += 0
elif abc[0] == abc[1]:
    cnt += 1
else:
    cnt += 2

print(cnt)

Solution (Python):
a, b, c = map(int, input().split())
s = [a, b, c]
s.sort()
if (s[2] * 2 - s[0] - s[1]) % 2 == 0:
    print((3 * s[2] - sum(s)) // 2)
else:
    print((3 * s[2] + 3 - sum(s)) // 2)

Solution (Python):
a,b,c=map(int,input().split())
l=[a,b,c]
l.sort()
m=l[-1]
from math import ceil
ans=0
if (l[0]+l[1])%2==1:
  ans+=ceil((m-l[0])/2)
  ans+=ceil((m-l[1])/2)
  ans+=1
else:
  ans+=(2*m-l[0]-l[1])//2
print(ans)