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):
A,B,C = map(int,input().split())
m = max(A,B,C)*3
s = A+B+C
ans = m-s
if ans%2 == 1:
    ans += 3
print(ans//2)

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

s = a+b+c
cnt = 0
while not (s%3==0 and s//3 >= a and s//3 >= b and s//3>= c):
    s += 2
    cnt += 1
print(cnt)

Solution (Python):

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

l.sort()

ans = 0
ans += l[2] - l[1]

if  (l[2] - (ans + l[0])) % 2 == 0:
    ans += (l[2] - (ans + l[0])) / 2
else:
    ans += int((l[2] - (ans + l[0])) / 2) + 2

print(int(ans))

Solution (Python):


def main():
    N = sorted(list(map(int, input().split())))
    ans = N[2] - N[1]
    d = N[1] - N[0]
    if d % 2 != 0:
        ans += 2
    ans += d // 2
    print(ans)

if __name__ == "__main__":
    main()

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

Solution (Python):









import os
import sys




def main():
    L = list(map(int, input().split()))
    ans = 0
    max_idx = L.index(max(L))
    min_idx = L.index(min(L))
    for i in range(len(L)):
        if i == max_idx or i == min_idx:
            pass
        else:
            medium_idx = i
    ans += (L[max_idx] - L[medium_idx])
    L[medium_idx] = L[max_idx]
    L[min_idx] += ans
    if (L[max_idx]-L[min_idx]) % 2 == 0:
        print(ans + (L[max_idx]-L[min_idx])//2)
    else:
        print(ans + (L[max_idx]-L[min_idx]+1)//2 + 1)


if __name__ == "__main__":
    main()

Solution (Python):
a, b, c = sorted(map(int, input().split()))
print((c - a) // 2 + (c - b) // 2 + (((c - a) % 2 + (c - b) % 2) ^ 3) % 3)

Solution (Python):
N_List = sorted(list(map(int,input().split())))
cnt = 0
if N_List[0] + 2 <= N_List[2]:
    cnt += (N_List[2] - N_List[0])//2
    N_List[0] += ((N_List[2] - N_List[0])//2) * 2

if N_List[1] + 2 <= N_List[2]:
    cnt += (N_List[2] - N_List[1])//2
    N_List[1] += ((N_List[2] - N_List[1])//2) * 2

if N_List.count(max(N_List)) == 2:
    cnt += 2
elif N_List.count(max(N_List)) == 1:
    cnt += 1
else:
    cnt += 0
print(cnt)

Solution (Python):
a,b,c = [int(x) for x in input().split()]
res = 3 * max(a,b,c) - (a + b + c)
if res % 2 == 1:
  res += 3
print(res // 2)

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

x = max(a,b,c)
z = min(a,b,c)
y = a + b + c - x - z

cnt = 0

if z % 2 == y % 2:
    cnt += (y - z) / 2
    cnt += (x - y)
elif z % 2 != y % 2 and z % 2 == x % 2:
    cnt += (x - z) / 2
    if y % 2 == x % 2:
        cnt += (x - y)
    else:
        cnt += ((x + 1)- y) / 2
        cnt += 1
elif z % 2 != y % 2 and z % 2 != x % 2:
    cnt += (x - y) / 2
    cnt += ((x + 1)- z) / 2
    cnt += 1

print(int(cnt))

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

li = [A, B, C]

diff = max(li) * 3 - sum(li)
if diff % 2 == 0:
    print(int(diff / 2))
else:
    print(int((diff + 3) / 2))

Solution (Python):
l = sorted(map(int, input().split()))
p = (l[0]%2 != l[1]%2) or (l[1]%2 != l[2]%2)

p=(l[0]%2!=l[1]%2)or(l[1]%2!=l[2]%2)
l[0],l[1],l[2]=sorted([l[0]+((l[0]%2==l[1]%2)^(l[0]%2==l[2]%2)),l[1]+((l[1]%2==l[0]%2)^(l[1]%2==l[2]%2)),l[2]+((l[2]%2==l[0]%2)^(l[2]%2==l[1]%2))])
print((l[2]-l[0])//2+(l[2]-l[1])//2+p)

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

Solution (Python):

"""
Created on Sun Sep 20 23:06:24 2020

@author: liang
"""
num = [int(x) for x in input().split()]
M = max(num)
S = sum(num)
if M*3%2 == S%2:
    print((3*M-S)//2)
else:
    print((3*(M+1)-S)//2)

Solution (Python):

"""
Created on Sun Sep 20 22:44:27 2020

@author: liang
"""

A, B, C = map(int, input().split())

if A > B:
    if B > C:
        m1,m2,m3 = A, B, C
    else:
        if A > C:
            m1,m2,m3 = A, C, B
        else:
            m1,m2,m3 = C, A, B
else:
    if A > C:
        m1,m2,m3 = B, A, C
    else:
        if B > C:
            m1,m2,m3 = B, C, A
        else:
            m1,m2,m3 = C, B, A
ans = 0
ans += m1 - m2
ans += (m2-m3)//2
if (m2-m3)%2 == 1:
    ans += 2
print(ans)

Solution (Python):
def solve():
    L = [int(i) for i in input().split()]
    L.sort()
    a, b, c = L
    ans = 0
    while b < c:
        a += 1
        b += 1
        ans += 1
    while a < b:
        a += 2
        ans += 1
    print(ans if a == b else ans + 1)


if __name__ == "__main__":
    solve()

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

A=abc[0]
B=abc[1]
C=abc[2]

if (B-A)%2 == 0:
  print(C-B+(B-A)//2)
else:
  print(C-B+(B-A+3)//2)

Solution (Python):
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    a,b,c = i_map()
    ra = a%2
    rb = b%2
    rc = c%2
    if ra == rb == rc:
        m = max(a,b,c)
        ans = 0
        for i in [a,b,c]:
            ans += (m-i)//2
        print(ans)
    else:
        if ra == rb:
            a += 1
            b += 1
        elif ra == rc:
            a += 1
            c += 1
        else:
            b += 1
            c += 1
        ans = 1
        m = max(a,b,c)
        for i in [a,b,c]:
            ans += (m-i)//2
        print(ans)


if __name__=="__main__":
    main()

Solution (Python):
abc=[int(x) for x in input().split()]
abc.sort()
a=abc[0]
b=abc[1]
c=abc[2]

ans=float('inf')
for i in range(a,100):
  for j in range(b,100):
    for k in range(c,100):
      now=0
      if i==j and j==k and i==k:
        now=i-a+j-b+k-c
        if now%2==0:
          ans=min(now//2,ans)
          break
        
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

ans = 0
while not (a % 2 == b % 2 == c % 2):
    if a % 2 == b % 2:
        a += 1
        b += 1
    elif a % 2 == c % 2:
        a += 1
        c += 1
    elif b % 2 == c % 2:
        b += 1
        c += 1
    ans += 1

print(ans + (c - a) // 2 + (c - b) // 2)

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

Solution (Python):


A,B,C = map(int, input().split())

s = A + B + C
M = max(A,B,C)
if M % 2 == 0 and s % 2 != 0:
    M += 1
elif M % 2 != 0 and s % 2 == 0:
    M += 1

ans = (3 * M - s) / 2
print(int(ans))

Solution (Python):


def count(data):
    even = odd = 0
    for val in data:
        if val % 2 == 0:
            even += 1
        else:
            odd += 1

    return even,odd

A,B,C = map(int, input().split())

ans = 0
even,odd = count([A, B, C])
if even == 2:
    ans += 1
    if A % 2 == 0:
        A += 1
    if B % 2 == 0:
        B += 1
    if C % 2 == 0:
        C += 1
elif odd == 2:
    ans += 1
    if A % 2 != 0:
        A += 1
    if B % 2 != 0:
        B += 1
    if C % 2 != 0:
        C += 1

max_val = max(A,B,C)

ans += (max_val - A) / 2
ans += (max_val - B) / 2
ans += (max_val - C) / 2
print(int(ans))

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

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

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

num = list(map(int,input().split()))
num.sort()
dif1 = num[2] - num[1]
dif2 = num[2] - num[0]

if (dif2 - dif1) % 2 == 0:
    ans = dif1 + (dif2-dif1)//2
else:
    ans = dif1 + (dif2-dif1+1)//2 + 1

print(ans)

Solution (Python):
z=input().split()
a=int(z[0])
b=int(z[1])
c=int(z[2])
goukei=a+b+c
count = 0
if a == b and b == c:
    print(0)
    exit()
while 1:
  count += 1
  
  goukei = goukei + 2

  if goukei>=max([a,b,c])*3 and goukei%3 == 0:
    print(count)
    break

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

Solution (Python):

def resolve():
    import sys
    input = sys.stdin.readline

    a, b, c = [int(x) for x in input().rstrip().split(" ")]

    max_num = max([a, b, c]) if (sum([a, b, c]) + max([a, b, c])) % 2 == 0 else max([a, b, c]) + 1

    print(int((max_num * 3 - sum([a, b, c])) / 2))




if __name__ == "__main__":
    resolve()

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

ans = ABC[2]-ABC[1]

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

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

Solution (Python):
a,b,c=map(int,input().split())
p = max(a,b,c)
q = min(a,b,c)
r = a+b+c-(p+q)
x =(p-q)//2+(p-r)//2
q +=((p-q)//2)*2
r +=((p-r)//2)*2
if p == q and p == r:
        print(x)
elif p != q and p != r:
        print(x+1)
else:
        print(x+2)

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

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

ABC_sort = sorted(ABC,reverse=True)
AB = ABC_sort[0] - ABC_sort[1]
BC = ABC_sort[1] - ABC_sort[2]
time = 0
if BC % 2 == 0:
    time += BC // 2
    time += AB
else:
    AB += 1
    BC += 1
    time += BC // 2
    time += AB
print(time)

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

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

cnt = ll[2] + ll[2] - ll[1] - ll[0]

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

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

cnt = 0
A,B,C = sorted([A,B,C])
i = C - B
cnt += i
B += i
A += i

j = C - A
if j % 2 == 0:
  cnt += j // 2
else:
  cnt += j // 2 + 2
  
print(cnt)

Solution (Python):
abc = list(map(int,input().split()))
maxnum = max(abc)
parity = maxnum%2
ans = 0
for i in abc:
    if i%2==parity:
        ans+=(maxnum-i)//2+1
    else:
        ans+=(maxnum-1-i)//2
if abc[0]%2==abc[1]%2 and abc[1]%2==abc[2]%2:
    ans-=3
print(ans)

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

if max(A,B,C)*3%2==(A+B+C)%2:
    print((3*max(A,B,C)-(A+B+C))//2)
else:
    print((3*(max(A,B,C)+1)-(A+B+C))//2)

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

Solution (Python):
nums = list(map(int, input().split()))
total_diff = 0
max_num = max(nums)
for i in range(3):
    total_diff += max_num - nums[i]

if total_diff % 2 == 1:
    max_num += 1

print(int((max_num * 3 - sum(nums)) / 2))

Solution (Python):
A,B,C = [int(i) for i in input().split()]
M = max(A,B,C)
S = A + B + C
ans = 0
if S%2 != M%2:
  ans += 2
ans += int((3*M - S) / 2)
print(ans)

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

else:
  print(x // 2 + 2)

Solution (Python):
from math import ceil
a = list(map(int, input().split()))
a.sort()
kisu_cnt = 0
ans = 0
for _a in a:
    if _a % 2 == 1:
        kisu_cnt += 1
if kisu_cnt == 3 or kisu_cnt == 0:
    ans += (a[-1] - a[1]) // 2
    ans += (a[-1] - a[0]) // 2
    print(ans)
    exit()
else:
    if kisu_cnt == 1:
        for i in range(3):
            if a[i] % 2 == 0:
                a[i] += 1
    else:
        for i in range(3):
            if a[i] % 2 == 1:
                a[i] += 1
a.sort()
ans += 1
ans += (a[-1] - a[1]) // 2
ans += (a[-1] - a[0]) // 2
print(ans)

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

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

a.sort(reverse=True)

s=2*a[0]-a[1]-a[2]

if s%2==0:
    print(s//2)
else:
    s+=1
    print(1+s//2)

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

if a % 2 == b % 2 == c % 2:
    count = 0

elif a % 2 == b % 2 != c % 2:
    count += 1
    a += 1
    b += 1

elif b % 2 == c % 2 != a % 2:
    count += 1
    b += 1
    c += 1

elif a % 2 == c % 2 != b % 2:
    count += 1
    a += 1
    c += 1
maxnum = max(a, b, c)

while a < maxnum:
    a += 2
    count += 1

while b < maxnum:
    b += 2
    count += 1

while c < maxnum:
    c += 2
    count += 1

print(count)

Solution (Python):


import math


def main():
    li = list(map(int, input().split()))
    li.sort(reverse=True)
    m = li[0] - li[1]
    n = li[0] - li[2]
    p = n - m
    ans = m + math.ceil(p / 2) + (p % 2)
    print(ans)


if __name__ == "__main__":
    main()

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

max_v = max(arr)
sum_arr = sum(arr)

if (max_v*3 - sum_arr) % 2:
    
    print(((max_v+1)*3 - sum_arr) // 2)
else:
    
    print((max_v*3 - sum_arr) // 2)

Solution (Python):
data=list(map(int,input().split()))
data.sort()
a=data[0]
b=data[1]
c=data[2]
if a == b == c:
    print(0)
elif b == c:
    count=0
    while a < c:
        a += 2
        count += 1
    if a > c:
        print(count+1)
    else:
        print(count)
else:
    count=0
    while a < c and b < c:
        a += 1
        b += 1
        count += 1
    if a == b == c:
        print(count)
    else:
        while a < c:
            a += 2
            count += 1
        if a > c:
            print(count+1)
        else:
            print(count)

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

a_L = list(sorted(a_L))

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


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

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

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

l.sort()

ans = 0

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

if (l[2] - l[1]) % 2 == 1:
    ans += (l[2] - l[1]) // 2
    l[1] = l[2] - 1
else:
    ans += (l[2] - l[1]) // 2
    l[1] = l[2]

if l[0] == l[1] == l[2] - 1:
    print(ans + 1)
elif l[0] == l[1] == l[2]:
    print(ans)
else:
    print(ans + 2)

Solution (Python):
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    X=list(mi())

    X.sort()

    ans = 0
    while X[1] != X[2]:
        X[0] += 1
        X[1] += 1
        ans += 1
    
    if X[0] == X[1]:
        print(ans)
        exit()
    
    if X[0] % 2 == X[1] % 2:
        ans += (X[1] - X[0])//2
    else:
        ans += (X[1]+1 - X[0])//2
        ans += 1
    
    print(ans)







if __name__ == "__main__":
    main()

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

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

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

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

X = max([A, B, C])
X = X if (3 * X - (A + B + C)) % 2 == 0 else X + 1
diff = 3 * X - (A + B + C)

print(diff // 2)

Solution (Python):
A, B, C = map(int, input().split())
L = sorted([A, B, C])

ans = (L[1] - L[0]) / 2 + (L[2] - L[1])

if (L[0] % 2 == 1 and L[1] % 2 == 0) or (L[1] % 2 == 1 and L[0] % 2 == 0):
  ans = ans + 1.5
print(int(ans))

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

if A == B and A == C:
    print(0)
    exit()
cnt = 0
cnt += (C - A) // 2
A = ((C - A) // 2) * 2 + A
cnt += (C - B) // 2
B = ((C - B) // 2) * 2 + B

if A == B and A == C:
    print(cnt)
elif A == B and A != C:
    print(cnt+1)
else:
    print(cnt+2)

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

ans = 0
while l[2] > l[1]:
    ans += 1
    l[1] += 1
    l[0] += 1

while l[1] > l[0]:
    ans += 1
    l[0] += 2

if l[0] > l[1]:
    ans += 1

print(ans)

Solution (Python):
import math
A,B,C = map(int,input().split())
ns = sorted([A,B,C])
diff32 = ns[2]-ns[1]
diff21 = ns[1]-ns[0]
ans = diff32+math.ceil(diff21/2)
if diff21 % 2 == 1:
    ans += 1
print(ans)

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

while A != B or A != C or B != C:
    num = [A, B, C]
    num = sorted(num)
    if num[0] == num[1]:
        num[0] += 1
        num[1] += 1
    
    else:
        num[0] += 2
    
    ans += 1
    A = num[0]
    B = num[1]
    C = num[2]

print(ans)

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

res = 0
if ac % 2 == 0 and bc % 2 == 0:
    res = ac // 2 + bc // 2
elif ac % 2 == 1 and bc % 2 == 1:
    res = 1 + ac // 2 + bc // 2
else:
    res = 2 + ac // 2 + bc // 2

print(res)

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

l.sort()
x=l[2]-l[1]+(l[1]-l[0])//2
ans=x if (l[1]-l[0])%2==0 else x+2
print(ans)

Solution (Python):
X=list(map(int,input().split()))
if (max(X)*3)%2==sum(X)%2:
    print(int((max(X)*3-sum(X))/2))
else:
    print(int(((max(X)+1)*3-sum(X))/2))

Solution (Python):
a, b, c = map(int, input().split())
A = a % 2
B = b % 2
C = c % 2
cnt = 0
s = [a,b,c]
flag = [0,0,0,0]
if A == B == C:
    t = [a,b,c]
    t.sort()
    cnt = cnt + (t[2]-t[1])//2 + (t[2]-t[0])//2
    flag[0] += 1
elif A == B:
    cnt = cnt + 1
    a = a + 1
    b = b + 1
    t = [a,b,c]
    t.sort()
    cnt = cnt + (t[2]-t[1])//2 + (t[2]-t[0])//2
    flag[1] += 1
elif B == C:
    cnt = cnt + 1
    b = b + 1
    c = c + 1
    t = [a,b,c]
    t.sort()
    cnt = cnt + (t[2]-t[1])//2 + (t[2]-t[0])//2
    flag[2] += 1
elif C == A:
    cnt = cnt + 1
    c = c + 1
    a = a + 1
    t = [a,b,c]
    t.sort()
    cnt = cnt + (t[2]-t[1])//2 + (t[2]-t[0])//2
    flag[3] += 1
print(cnt)

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

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

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

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

arr.sort()

a, b, c = arr

k = (c - a) + (c - b)

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

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

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

key=(L[0]-L[1])
Key=(L[0]-L[2])
if (key+Key)%2==0:
  print((key+Key)//2)
else:
  print((key+Key)//2+2)

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

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

Solution (Python):
a = sorted(map(int, input().split()))
b, c = a[2] - a[1], a[2] - a[0]

あ = b // 2 + c // 2
ばいく = b % 2 + c % 2
if ばいく == 1:
    あ += 2
elif ばいく == 2:
    あ += 1
print(あ)

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate, product 

from collections import deque,defaultdict,Counter
import decimal
import re
import math















import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7


from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
a,b,c = readInts()
ma = max(a,b,c)
sa = (ma-a) + (ma-b) + (ma-c)
if sa%2 == 0:
    print(sa//2)
else:
    print(sa//2 + 2)

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

Solution (Python):
a, b, c = sorted([int(i)for i in input().split()])
ans = 0
ma, mb, mc = [a % 2, b % 2, c % 2]

if ma == mb == mc:
    pass
elif ma != mb and mb == mc:
    b += 1
    c += 1
    ans += 1
elif ma == mc and ma != mb:
    a += 1
    c += 1
    ans += 1
elif ma == mb and mb != mc:
    a += 1
    b += 1
    ans += 1

ans += (c - b) // 2
ans += (c - a) // 2

print(ans)

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

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

Solution (Python):
import math
A,B,C = map(int,input().split())
k = [A,B,C]
k.sort()
k.reverse()
ans = 0
ans += k[0]-k[1]
now = k[2]
now += ans
if (k[0]-now)%2 == 0:
    ans += math.ceil((k[0]-now)/2)
    print(ans)
else:
    ans += math.ceil((k[0]-now)/2)
    ans += 1
    print(ans)

Solution (Python):
D = sorted(list(map(int,input().split())))
A,B,C = D
if (C-B)%2==0 and (B-A)%2==0:
    n = (C-B)//2+(C-A)//2
elif (C-B)%2==1 and (B-A)%2==0:
    n = (B-A)//2+(C-B)
elif (C-B)%2==0 and (B-A)%2==1:
    n = (C-B)//2+1 +(C+1-A)//2
elif (C-B)%2==1 and (B-A)%2==1:
    n = 1+(C-B-1)//2+1+(C-A)//2
print(n)

Solution (Python):
X = list(map(int, input().split()))
Y = sorted(X)
ans = 0
if Y[0]%2==Y[1]%2 and Y[1]%2 != Y[2]%2:
  ans +=1
  Y = [Y[0]+1,Y[1]+1,Y[2]]
elif Y[1]%2==Y[2]%2 and Y[2]%2 != Y[0]%2:
  ans +=1
  Y = [Y[0], Y[1]+1,Y[2]+1]
elif Y[2]%2==Y[0]%2 and Y[0]%2 != Y[1]%2:
  ans +=1
  Y = [Y[0]+1, Y[1], Y[2]+1]

A = Y[2]-Y[0]
B = Y[2]-Y[1]
C = min(A,B)
D = max(A,B)
ans += C + (D-C)//2
print(ans)

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


N = LI()
N.sort()
A, B, C = N
a = (C-A)//2
A += a*2
b = (C-B)//2
B += b*2
if A == B == C:
    ans = a+b
elif A == B:
    ans = a+b+1
else:
    ans = a+b+2
print(ans)

Solution (Python):
a = sorted(list(map(int, input().split())))
even = []
No = []
for i in range(3):
    if a[i] % 2 == 0:
        even.append(a[i])
    else: No.append(a[i])

if len(even) == 0 or len(even) == 3:
    ans = (a[1] - a[0])//2 + a[2]-a[1]
elif len(even) == 1:
    ans = 1
    a = sorted(even+ [No[0]+1, No[1]+1])
    ans += (a[1]-a[0])//2 + a[2]-a[1]
elif len(even) == 2:
    ans = 1
    a = sorted(No + [even[0]+ 1, even[1]+1])
    ans += (a[1]-a[0])//2 + a[2]-a[1]
print(ans)

Solution (Python):
aa = list(sorted(map(int, input().split())))
nn = sum(map(lambda x: x % 2, aa))
ans = 0
if nn == 1:
    ans += 1
    for i in range(3):
        if aa[i] % 2 == 0:
            aa[i] += 1
elif nn == 2:
    ans += 1
    for i in range(3):
        if aa[i] % 2 == 1:
            aa[i] += 1
ans += (aa[2] - aa[0]) // 2
ans += (aa[2] - aa[1]) // 2
print(ans)

Solution (Python):
A,B,C=map(int, input().split())
m = max([A,B,C])
s = sum([m-A, m-B, m-C])
if s %2 == 0:
    print(s//2)
else:
    s += 1
    print(1+s//2)

Solution (Python):
def judge1(lst):
    flag = False
    if lst[-1] == lst[-2]:
        flag = True
    return flag


def main():
    lst = list(map(int, input().split()))
    lst.sort()
    count = 0

    while True:
        if judge1(lst):
            break

        lst[0] += 1
        lst[1] += 1
        count += 1

    while lst[2] - lst[0] >= 2:
        lst[0] += 2
        count += 1

    if lst[2] - lst[0] == 1:
        count += 2

    print(count)


if __name__ == '__main__':
    main()

Solution (Python):


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

abc.sort()

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

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

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

s = a+b+c
m = max(a,b,c)

if s%2==m%2:
    ans = (3*m-s)//2
else:
    ans = (3*(m+1)-s)//2
    
print(ans)

Solution (Python):
num = list(map(int,input().split()))
num.sort(reverse=True)
M = max(num)
l = [M-i for i in num]
gap = l[2] - l[1]
ans = 0

if gap % 2 == 0:
    ans = l[1] + int(gap/2)
else:
    ans = l[1] + int(gap/2)+2
print(ans)

Solution (Python):

import math

if __name__ == '__main__':
    A, B, C = map(int, input().split())

    MV = max(A, B, C) * 3
    SumABC = A + B + C

    if MV % 2 == 0 and SumABC % 2 == 0:
        ans = (MV - SumABC) / 2

    elif MV % 2 == 1 and SumABC % 2 == 1:
        ans = math.ceil(MV - SumABC) / 2

    else:
        ans = math.ceil((MV - SumABC) / 2) + 1

    print(int(ans))

Solution (Python):

ABC = list(map(int,input().split()))
ABC = sorted(ABC,reverse = True)
A = ABC[0]
B = ABC[1]
C = ABC[2]
count = 0
while A != B:
    C += 1
    B += 1
    count += 1
while (B - C)%2 == 1:
    A += 1
    B += 1
    count += 1
while A!=C:
    C += 2
    count += 1
print(count)

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

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

ans = 0
if (abc[1]-abc[0])%2 == 1:
  ans += 1
  abc[1] += 1
  abc[2] += 1

ans += (abc[1]-abc[0])//2
abc[0] += abc[1]-abc[0]
ans += abc[2]-abc[1]
print(ans)

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

Solution (Python):
a = list(map(int,input().split()))
M = max(a)
if (3 * M - sum(a))%2 == 0:
    print((3 * M - sum(a))//2)
else:
    print((3 * (M+1) - sum(a))//2)

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

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

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

if A[1]-A[0]>=2:
  cnt += (A[1]-A[0])//2
  A[0]+= cnt*2

if A[0]==A[1] and A[1]==A[2]:
  print(cnt)
  exit()

  
while(True):
  cnt+=1
  A = sorted(A)
  A[0]+=1
  A[1]+=1
  
  if A[0]==A[1] and A[1]==A[2]:
    break

print(cnt)

Solution (Python):
a = list(map(int,input().split()))
M = max(a)
if (3 * M - sum(a))%2 == 0:
    print((3 * M - sum(a))//2)
else:
    print((3 * (M+1) - sum(a))//2)

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

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

ans = A[2] - A[1]

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

Solution (Python):

A,B,C=map(int,input().split())
SUM=A+B+C
MAX=max(A,B,C)*3
if (MAX-SUM)%2==0:
    count=(MAX-SUM)/2
else:
    count=(MAX-SUM)/2+2
print(int(count))

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

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

for n in range(50):
  if A==B==C:
    break
  elif A<C and B<C:
    A+=1
    B+=1
    ans+=1
  elif A<C and B==C:
    A+=2
    ans+=1
  else:
    B+=1
    C+=1
    ans+=1
    
print(ans)

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

diff1 = a[0] - a[1]
diff2 = a[0] - a[2]
cnt1 = diff1 // 2
cnt2 = diff2 // 2
result = sum([cnt1, cnt2])

diff1 -= cnt1 * 2
diff2 -= cnt2 * 2

s = sum([diff1, diff2])
if s & 1:
  print(result + 2)
else:
  print(result + s // 2)

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

Solution (Python):


def main():
	a, b , c = map(int , input().split())
	if a==b and b==c:
		print(0)
	else:
		tot=0
		tot = tot+(a+b+c)
		mx = max(a, max(b, c))
		i = 0
		f=0
		while f==0:
			if((tot+2*i)%3==0):
				p = ((tot+2*i))//3
				if p>=mx:
					f=1
			i = i+1
		print(i-1)
if __name__=="__main__":
	main()

Solution (Python):

def main():
	a, b , c = map(int , input().split())
	if a==b and b==c:
		print(0)
	else:
		tot=0
		tot = tot+(a+b+c)
		mx = max(a, max(b, c))
		i = 0
		f=0
		while f==0:
			if((tot+2*i)%3==0):
				p = ((tot+2*i))//3
				if p>=mx:
					f=1
			i = i+1
		print(i-1)
if __name__=="__main__":
	main()

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

Solution (Python):
def main():
    a, b, c = map(int, input().split())
    total = a + b + c
    sa =  max(a, b, c) * 3 - total

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




if __name__ == "__main__":
    main()

Solution (Python):
A, B, C = map(int, input().split())
D = max(A, B, C)
S = sum([A, B, C])
print((D * 3 - S) // 2 if D % 2 == S % 2 else ((D + 1) * 3 - S) // 2)