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):
As = [ int(i) for i in input('').split()]



As.sort()
As.reverse()

o = 0
diff = As[0] - As[1]
div, mod = divmod(diff,2)
o += div

if mod == 1:
    As[2] += 1
    o += 1

diff = As[0] - As[2]
div, mod = divmod(diff,2)
o += div
if mod == 1:
    o += 1
    o += mod
print(o)

Solution (Python):

a, b, c = sorted([int(arg) for arg in input().split()])
moves = 0
while b < c:
    a += 1
    b += 1
    moves += 1
while a < b:
    a += 2
    moves += 1
while b < a:
    b += 1
    c += 1
    moves += 1

print(moves)

Solution (Python):
def evenOdd(a,b):
    return True if a*b%2==1 or(a%2==0 and b%2==0) else False

x = list(map(int, input().split()))
x = sorted(x)
if evenOdd(x[0],x[1]) and evenOdd(x[1],x[2]) and evenOdd(x[2],x[0]):
    print(int((2*x[2]-x[0]-x[1])/2))
elif evenOdd(x[0],x[1]) and not(evenOdd(x[1],x[2]) and not evenOdd(x[2],x[0])) :
    print(int((x[2]-x[0]-1)/2+(x[2]-x[1]-1)/2 +1))
else:
    print(int((x[2]-x[0])/2)+int((x[2]-x[1])/2)+2)

Solution (Python):
inpt =[int(i) for i in input().split()]
sort = sorted(inpt)
min = sort[0]
med = sort[1]
max = sort[2]

a = max - med
tmp = min + a
if (max-tmp)%2==0:
    ans = a + (max-tmp)/2
else:
    ans = a + int((max-tmp)/2) + 2

print(int(ans))

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

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

Solution (Python):
data = list(map(int,input().split()))
ans = 0
def judge_odd_even(data,ans):
    judge_list=[0,0,0]
    for i in range(3):
        if data[i] % 2 == 0:
            judge_list[i] = 2
        else:
            judge_list[i] = 1
    if judge_list.count(1) == 3 or judge_list.count(2) == 3:
        return data,ans
    else:
        if judge_list.count(1) == 2:
            for i in range(3):
                if judge_list[i] == 1:
                    data[i] += 1
            ans += 1
            return data,ans
        elif judge_list.count(2) == 2:
            for i in range(3):
                if judge_list[i] == 2:
                    data[i] += 1
            ans += 1
            return data,ans
data,ans = judge_odd_even(data, ans)
max_data = max(data)
for i in range(3):
    ans += (max_data-data[i])//2
print(ans)

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

Solution (Python):
A,B,C=map(int,input().split())
list = [A,B,C]
list.sort(reverse=True)
import copy

cnt=0
if (list[0]-list[2])%2==0:
    
    cnt += (list[0]-list[2])/2
    list[2]=copy.deepcopy(list[0])
    if (list[0]-list[1])%2==0:
        cnt += (list[0]-list[1])/2
    else:
        cnt += int((list[0]-list[1])/2)+2
else:
    
    if (list[0]-list[1])%2==0:
        
        cnt += (list[0]-list[1])/2
        cnt += int((list[0]-list[2])/2)+2
    else:
        
        cnt += (list[1]-list[2])/2
        cnt += (list[0]-list[1])
print(int(cnt))

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

Solution (Python):
data = [int(i) for i in input().split()]
data.sort()
count = 0

if (data[1] - data[0]) % 2 == 1:
    data[1] += 1
    data[2] += 1
    count += 1
count += int((data[1] - data[0]) / 2) + (data[2] - data[1])

print(count)

Solution (Python):
arr = list(map(int,input().split()))
ans = 0
arr.sort()
while arr[2] - arr[0] >= 2:
    arr[0] += 2
    ans += 1

while arr[2] - arr[1] >= 2:
    arr[1] += 2
    ans += 1
arr.sort()
if arr[0] != arr[1]:
    ans += 2
else:
    if arr[0] != arr[2]:
        ans += 1
print(ans)

Solution (Python):
states = list(map(int,input().strip().split(' ')))
sortedlist = sorted(states)

diff0 = (sortedlist[2]-sortedlist[0])//2
diff1 = (sortedlist[2]-sortedlist[1])//2

newlist = [sortedlist[0]+2*diff0, sortedlist[1]+2*diff1, sortedlist[2]]

def patternMatch(s):
    if 1==2*s[2]-s[1]-s[0]:
        return 2
    elif 2==2*s[2]-s[1]-s[0]:
        return 1
    elif 0==2*s[2]-s[1]-s[0]:
        return 0

print(patternMatch(newlist)+diff0+diff1)

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

m = 0
for i in range(len(lst)):
    m = max(m,lst[i])
    
for i in range(len(lst)):
    if lst[i]==m:
        idx = i

idx_1 = (idx + 1 + 3)%3
idx_2 = (idx - 1 + 3)%3

cnt_1 = (lst[idx]-lst[idx_1])//2
lst[idx_1] += 2*cnt_1
cnt_2 = (lst[idx]-lst[idx_2])//2
lst[idx_2] += 2*cnt_2

if lst[idx_1] == lst[idx_2] and lst[idx_1] == lst[idx]: print(cnt_1 + cnt_2)
elif lst[idx_1] == lst[idx_2] and lst[idx_1]+1 == lst[idx]: print(cnt_1 + cnt_2 + 1)
else: print(cnt_1 + cnt_2 + 2)

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

is_odd_list = [A % 2 == 0, B % 2 == 0, C % 2 == 0]
if all(is_odd_list) or not any(is_odd_list):
    ans = 0
else:
    if sum(is_odd_list) == 1:
        is_odd_list = [not i for i in is_odd_list]
    A = A + is_odd_list[0]
    B = B + is_odd_list[1]
    C = C + is_odd_list[2]
    ans = 1

num_list = sorted([A, B, C])
ans += (num_list[2] - num_list[0]) / 2 + (num_list[2] - num_list[1]) / 2
print(int(ans))

Solution (Python):
L = [int(i) for i in input().split()]
count = 0
L.sort()
while L[2]-L[0] >= 2:
    L[0] += 2
    count += 1
while L[2]-L[1] >= 2:
    L[1] += 2
    count += 1
L.sort()
if L[0] != L[1]:
    count += 2
else:
    if L[0] != L[2]:
        count += 1

print(count)

Solution (Python):
s=list(map(lambda x:int(x), input().split()))

if sum(s)%2==3*max(s)%2:
    print(int((3*max(s)-sum(s))/2))
else:
    print(int((3*(max(s)+1)-sum(s))/2))

Solution (Python):
import math

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

if a[0] == a[1] == a[2]:
    print(0)
else:
    count = a[2] - a[1]
    a[1] += count
    a[0] += count
    if a[0] == a[1]:
        print(count)
    else:
        tmp_count = math.ceil((a[1] - a[0]) / 2)
        count += int(tmp_count)
        a[0] += tmp_count * 2
        if a[0] == a[1]:
            print(count)
        else:
            print(count + 1)

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

def adder(a, index):
    cnt = 0
    while a[2] - a[index] > 1:
        a[index] += 2
        cnt += 1
    return cnt

cnt = 0
        
cnt += adder(a, 0)
cnt += adder(a, 1)

if(a[0] == a[1]):
    if(a[0] == a[2]):
        print(cnt)
    else:
        print(cnt + 1)
else:
    print(cnt + 2)

Solution (Python):
a, b, c = map(int, input().split())
m = max(a, b, c)*3
s = a + b + c
d = m - s

if m%2 == s%2:
    add = d/2
else:
    add = (d-1)/2 + 2
    
print(int(add))

Solution (Python):
a, b, c = map(int, input().split())
m = max(a, b, c)
s = a + b + c

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

Solution (Python):
a, b, c = map(int, input().split())
s, m, l = sorted([a, b, c])
x = l - m
y = l - s 

if x%2 == 0 and y%2 == 0:

    add = (x+y)/2
elif x%2 == 1 and y%2  == 1:

    add = (x+y-2)/2 + 1
else:

    add = (x+y-1)/2 + 2
    
    
print(int(add))

Solution (Python):
tmp = list(map(int, raw_input().split()))
tmp.sort()
A,B,C = tmp[0],tmp[1],tmp[2]
count = 0
if (B - A) % 2 == 0:
    t = (B-A)/2
    count += t
    count += C - B
    print(count)
else:
    count += 1
    A += 1
    C += 1
    count += (B-A)/2
    count += C -B
    print(count)

Solution (Python):
if __name__ == '__main__':
	inp = map(int, input().split(' '))
	a,b,c = inp
	step = 0
	mx = max((a,b,c))

	while True:
		step += 1
		if a<mx-1:
			a+=2
		elif b<mx-1:
			b+=2
		elif c<mx-1:
			c+=2
		else:
			break

	if 3*max((a,b,c)) == a+b+c+1:
		step+=1

	if 3*max((a,b,c)) == a+b+c:
		step-=1

	print(step)

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

Solution (Python):


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

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

Solution (Python):
ls = list(map(int, input().split()))
a, b, c = sorted(ls)
count = 0
s = sum(ls)

if s % 2 == (3 * c) % 2:
    while s < 3 * c:
        count += 1
        s += 2
else:
    while s < (c + 1) * 3:
        count += 1
        s += 2

print(count)

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

Solution (Python):

import numpy as np                      
                                        
ABC = [int(i) for i in input().split()] 
diff1 = max(ABC) - min(ABC)             
diff2 = max(ABC) - int(np.median(ABC))  
                                        
count = (diff1 + diff2)/2               
if not diff1 % 2 == diff2 % 2:          
  count += 2                            
                                        
print(int(count))

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

while max(a, b, c) - min(a, b, c) >= 2:
    count += 1
    min_num = min(a, b, c)
    if a == min_num:
        a += 2
    else:
        b += 2

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

Solution (Python):

N = map(int, raw_input().split())
num_min = min(N)
num_max = max(N)
num_middle = 0
for i in N:
    num_middle = num_middle + i
num_middle = num_middle - num_max - num_min

ret = num_max - num_middle
buff = num_max - num_min - ret
ret = ret + (buff // 2) + (buff % 2) * 2

print ret

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

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

Solution (Python):
import math
A = [int(i) for i in input().split()]
A.sort()
count = 0
count = A[2] - A[1]
A[1] = count + A[1]
A[0] = count + A[0]
d = math.ceil((A[2]-A[0])/2)
count = count + d
A[0] = 2*d+A[0]
d = abs(A[2]-A[0])
count = count + d

print(count)

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

cnt = 0
sub1 = M[2]-M[1]
cnt += sub1
sub2 = M[2]-M[0]-sub1
if (sub2)%2 == 0:
	cnt += sub2//2
else:
	cnt += 1+(sub2+1)//2
print(cnt)

Solution (Python):
a=list(map(int,input().split()))
ans=0
a.sort()
while a[1]-a[0]>=2:
    a[0]+=2
    ans+=1

if a[1]!=a[0]:
    ans+=2
    
while a[2]-a[1]>0:
    a[1]+=1
    ans+=1

print(ans)

Solution (Python):
a,b,c = map(int,input().split())
def solve_c(a,b,c):
    count = 0
    if abs(b-a)%2 ==1:
        a += 1
        c += 1
        count += 1
    if abs(c-a)% 2 == 1:
        a += 1
        b += 1
        count += 1
    a,b,c = tuple(sorted([a,b,c]))
    print((c-b)//2+(c-a)//2+count)
solve_c(a,b,c)

Solution (Python):
nums = sorted(map(int, raw_input().strip().split()))

total = 0
diff = nums[2] - nums[1]
total += diff
nums[1] = nums[2]
nums[0] += diff

diff = nums[1] - nums[0]
if diff % 2 == 0:
    total += diff / 2
else:
    total += diff / 2 + 2

print total

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

evenodd = []
if n[0] % 2 == 0:
    evenodd.append(0)
else:
    evenodd.append(1)
if n[1] % 2 == 0:
    evenodd.append(0)
else:
    evenodd.append(1)
if n[2] % 2 == 0:
    evenodd.append(0)
else:
    evenodd.append(1)

if evenodd.count(0) == 3 or evenodd.count(1) == 3:
    print(int((n[2] - n[0]) / 2 + (n[2] - n[1]) / 2))
elif evenodd.count(0) == 1:
    if evenodd[2] == 0:
        print(int(n[2] - (n[1] + n[0]) / 2))
    else:
        print(int(n[2] - (n[1] + n[0] - 3) / 2))
elif evenodd.count(0) == 2:
    if evenodd[2] == 1:
        print(int(n[2] - (n[1] + n[0]) / 2))
    else:
        print(int(n[2] - (n[1] + n[0] - 3) / 2))

Solution (Python):


s=map(int,raw_input().split())
s.sort()
if (s[2]*3)%2==sum(s)%2:
 res=(s[2]*2-s[1]-s[0])/2
else:
 res=(s[2]*2-s[1]-s[0])/2+2
print res

Solution (Python):


s=map(int,raw_input().split())
s.sort()
if (s[2]*3)%2==sum(s)%2:
 res=(s[2]*2-s[1]-s[0])/2
else:
 res=(s[2]*2-s[1]-s[0])/2+2
print res

Solution (Python):


s=map(int,raw_input().split())
s.sort()
if (s[2]*3)%2==sum(s)%2:
 res=(s[2]*2-s[1]-s[0])/2
else:
 res=(s[2]*2-s[1]-s[0])/2+2
print res

Solution (Python):



ABC = list(map(int, input().split(' ')))
abc = []
c = 0
MAX = max(ABC)

for i in range(3):
    n = (MAX - ABC[i]) // 2
    c += n
    abc.append(ABC[i] + n * 2 - MAX)

abc.sort()

if abc == [0, 0, 0]:
    pass
elif abc == [-1, 0, 0]:
    c += 2
elif abc == [-1, -1, 0]:
    c += 1
print(c)

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

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

cnt = c - b
a += cnt
cnt += ((c - a) // 2)
a += ((c - a) // 2) * 2
if c - a > 0:
    print(cnt + 2)
else:
    print(cnt)

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

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

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

    
    editorial(A, B, C)


def editorial(A, B, C):
    """
    fより、最終値をxとするとx={max, max + 1}
    操作回数: [3x - (A+B+C)] / 2
    1回の操作で2増えるので
        差分/2が回数となる
        3x mod 2 == abc mod 2

    3max mod 2 == abc mod 2
        true: 上記の通りのあまりの一致
        false: x=max+1より、全体では3max+3より奇数増えるので一致しない
    """
    abc = [A, B, C]
    m = max(abc)
    m3 = m * 3
    s = sum(abc)

    if m3 % 2 == s % 2:
        ans = (m3 - s) // 2
    else:
        ans = (m3 + 3 - s) // 2

    print(ans)


def f(A, B, C):
    """
    A: 545, 565, 666 ans=2
    B: 445,      555 ans=1
    C: 123, 233, A pattern ans=3
    D: 135, 245, 355, 555 ans=3
    E: 235, 345, 455, A pattern ans=4
    """
    A, B, C = sorted([A, B, C])
    ans = 0
    if B != C:
        ans += C - B
        B = C
        A += ans

    diff = B - A
    ans += diff // 2
    if diff % 2 != 0:
        
        ans += 2

    print(ans)


if __name__ == '__main__':
    main()

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

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

Solution (Python):
a, b, c = [int(i) for i in input().split()]
m = max(a, b, c)
dif = (m-a) + (m-b) + (m-c)
if dif%2 == 0:
    print(dif//2)
else:
    print((dif-1)//2 + 2)

Solution (Python):
inpt = map(int, raw_input().split())
inpt.sort()

x = inpt[2]-inpt[0]
y = inpt[2]-inpt[1]

ans = x/2 + y/2

if x%2 == 1 or y%2 == 1: ans = ans + 1
if x%2 != y%2: ans = ans + 1

print ans

Solution (Python):
   




lst = input().split(' ')


for i in range(len(lst)):
    lst[i] = int(lst[i])

i = -1
while True:
    i += 1
    lst.sort()

    if lst[0] == lst [2]:
        break
    
    if lst[0] == lst[1]:
        lst[0] += 1
        lst[1] += 1
    else:
        lst[0] += 2
        


print(i)

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

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

Solution (Python):
ABC = [int(i) for i in input().split()]

r = [ABC[0] % 2, ABC[1] % 2, ABC[2] % 2]
count = 0

if r.count(0) == 2:
    count += 1
    for i in range(3):
        if r.index(1) == i:
            continue
        ABC[i] += 1
elif r.count(1) == 2:
    count += 1
    for i in range(3):
        if r.index(0) == i:
            continue
        ABC[i] += 1
    
m = max(ABC)
for i in ABC:
    count += (m - i) / 2

print(int(count))

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

Solution (Python):





if __name__ == '__main__':
    a, b, c = list(map(int, input().split()))

    
    
    
    count_min = max(a, b, c)

    if ((count_min % 2) != ((a + b + c) % 2)):
        count_min += 1

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

Solution (Python):
A, B, C = map(int,input().split())
ABC = sorted([A,B,C])
counter = 0
for i in range(ABC[1],ABC[2]):
    ABC[0] += 1
    ABC[1] += 1
    counter += 1
while(ABC[0]+2<=ABC[1]):
    ABC[0] += 2
    counter += 1
if ABC[0]!=ABC[1]:
    ABC[1] += 1
    ABC[2] += 1
    counter += 1
    ABC[0] += 2
    counter += 1
print(counter)

Solution (Python):

a = [0,0,0]
s = input().split()
a[0] = int(s[0])
a[1] = int(s[1])
a[2] = int(s[2])






count = 0
while(True):
    if a[0] == a[1] and a[1] == a[2]:
        
        break
    a.sort()
    if a[2] >= a[0]+2:
        a[0] += 2
        count += 1
    elif a[0] == a[1]:
        count += 1
        break
    elif a[1] == a[2]:
        count += 2
        break
print(count)

Solution (Python):

import numpy as np

array = list(map(int,input().strip().split(" ")))
res = 0
array.sort()
if (array[1]-array[0])%2 == 0:
    res_max = array[2]
else:
    res_max = array[2]+1

for ele in array:
    res += res_max - ele

print(int(res/2))

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

Solution (Python):
import numpy as np

num = np.array(list(map(int, input().split())))
surplus = num % 2

sum_sur = sum(surplus)

count = 1
if sum_sur == 1:
    index = np.argmax(surplus)
    num += 1
    num[index] -= 1
    
elif sum_sur == 2:
    index = np.argmin(surplus)
    num += 1
    num[index] -= 1
else:
    count = 0

max_num = max(num)
max_index = np.argmax(num)

num = max_num - num
count += sum(num // 2)

print(count)

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

Solution (Python):
A, B, C = map(int, input().split())
Number=0
count =0
 
for i in range (55):
    MAX=max(A,B,C)
    Number=0
    if MAX==A:
        Number=Number+1
    if MAX==B:
        Number=Number+1
    if MAX==C:
        Number=Number+1
 
    if Number ==1:
        MAX=max(A,B,C)
        if MAX!=A:
            A=A+1
        if MAX!=B:
            B=B+1
        if MAX!=C:
            C=C+1
        count=count +1
        Number=0
 
    if Number ==2:
        MAX=max(A,B,C)
        if MAX!=A:
            A=A+2
        if MAX!=B:
            B=B+2
        if MAX!=C:
            C=C+2
        count=count +1
        Number=0
    
    if Number ==3:
        print('%d'%(count))
        break

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

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

M = max(A, B ,C)


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

Solution (Python):
def c_same_integers(A, B, C):
    
    
    
    m = max(A, B, C)
    parity = 3 * max(A, B, C) % 2 == (A + B + C) % 2
    max_value = m if parity else m + 1
    
    ans = (3 * max_value - (A + B + C)) // 2
    return ans

A,B,C = [int(i) for i in input().split()]
print(c_same_integers(A, B, C))

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

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

D = sorted([A,B,C])

count = int((D[2] - D[0])/2) + int((D[2] - D[1])/2)
E = (D[2] - D[0])%2 + (D[2] - D[1])%2

if E == 2:
    count += 1
elif E == 1:
    count += 2

print(count)

Solution (Python):
a=list(map(int,input().split()))
p,q=divmod(max(a)*3-sum(a),2)
print(p+q*2)

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

Solution (Python):
def main():
    A = list(map(int, input().split()))
    cnt = 0
    while 1:
        A.sort()
        if(A[0] == A[1] and A[1] == A[2]):
            break
        else:
            if(A[0] < A[2] and A[1] < A[2]):
                A[0] = A[0] + 1
                A[1] = A[1] + 1
                cnt = cnt + 1
            else:
                A[0] = A[0] + 2
                cnt = cnt + 1

    print(cnt)

if __name__ == '__main__':
    main()

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

gu = filter(lambda x: x%2==0 ,li)
ki = filter(lambda x: x%2!=0 ,li)

if len(ki) == 1:
    gu = map(lambda x:x+1 , gu)
    maxx = max(ki+gu)
    re = map(lambda x:(maxx-x)/2 ,ki+gu)
    print sum(re)+1

if len(gu) == 1:
    ki = map(lambda x:x+1 , ki)
    maxx = max(ki+gu)
    re = map(lambda x:(maxx-x)/2 ,ki+gu)
    print sum(re)+1


if len(ki) == 3:
    maxx = max(ki+gu)
    re = map(lambda x:(maxx-x)/2 ,ki+gu)
    print sum(re)


if len(gu) == 3:
    maxx = max(ki+gu)
    re = map(lambda x:(maxx-x)/2 ,ki+gu)
    print sum(re)

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

    print(solve(a, b, c))


def solve(a, b, c):
    a, b, c = sorted([a, b, c])
    x = a % 2
    y = b % 2
    z = c % 2

    if x == y == z:
        return ((c - a) // 2) + ((c - b) // 2)
    
    if x == y:
        return solve(a + 1, b + 1, c) + 1
    
    if x == z:
        return solve(a + 1, b, c + 1) + 1
    
    if y == z:
        return solve(a, b + 1, c + 1) + 1


def evens(*args):
    n = 0
    for i in args:
        if i % 2 == 0:
            n += 1
    return n

main()

Solution (Python):
ip=[int(x) for x in input().split()]
ip.sort()
cnt=0
while ip[1]<ip[2]:
  cnt=cnt+1
  ip[0]+=1
  ip[1]+=1
  
if (ip[1]-ip[0])%2!=0:
  cnt+=1
  ip[1]+=1
  ip[0]+=1
  while ip[0]<ip[1]:
    ip[0]+=2
    cnt+=1
else:
  cnt=cnt+(ip[1]-ip[0])/2
print(int(cnt))

Solution (Python):
import math

number_list = [int(i) for i in input().split()]

even_counter = 0

for i in number_list:
        if i % 2 == 0:
                even_counter = even_counter + 1

def even_checker(n_list):
        for i in n_list:
                if i % 2 == 0:
                        return i

def odd_checker(n_list):
        for i in n_list:
                if i % 2 == 1:
                        return i

if even_counter == 3 or even_counter == 0:
        goal = max(number_list)
        number_list.remove(goal)
        bigger = max(number_list)
        smaller = min(number_list)
        first_count = 0
else:
        if even_counter == 2:
                alone = odd_checker(number_list)
        elif even_counter == 1:
                alone = even_checker(number_list)
        number_list.remove(alone)
        bigger = max(number_list)
        smaller = min(number_list)
        if bigger > alone:
                first_count = math.ceil((bigger - alone)/2)
                goal = alone + first_count * 2
        else:
                first_count = 0
                goal = alone

second_count = goal - bigger
third_count = int((goal - (smaller + second_count))/2)

print(first_count+second_count+third_count)

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

s = [A,B,C]
s.sort()

count = 0
a = s[2] - s[1]
count = count + a

s[0] = s[0] + a

b = s[2] - s[0]

if b % 2 == 0:
    count = count + (b // 2)
    print(count)

else:
    count = count + (b // 2) + 2
    print(count)

Solution (Python):
a=input().split()
for i in range(3):
  a[i]=int(a[i])
a.sort()
A=int(a[0])
B=int(a[1])
C=int(a[2])
A0=A%2
B0=B%2
C0=C%2
ans=0

if( (A0==B0)and(A0==C0) ):
   ans=ans+int((C-B)/2)+int((C-A)/2)
   print(ans)
else:
  if(A0==C0):
    ans=ans+int((C-B)/2)+int((C-A)/2)+2
    print(ans)
    
  if(B0==C0):
    ans=ans+int((C-B)/2)+int((C-A)/2)+2
    print(ans)
  if((A0!=C0)and(B0!=C0)):
    ans=ans+int((C-B)/2)+int((C-A)/2)+1
    print(ans)

Solution (Python):
a,b,c=map(int,input().split())
lst=[a,b,c]
lst.sort()
x=lst[0]
y=lst[1]
z=lst[2]

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

Solution (Python):
a,b,c = map(int, input().split())
l = sorted([a,b,c],reverse=True)
ans = 0
def all_same(items):
    return all(x == items[0] for x in items)

while not all_same(l):
    d = l[0] - l[1]
    l[1] += d
    l[2] += d
    ans += d
    d = l[1] - l[2]
    l[2] += 2 * (d//2)
    ans += d // 2
    if l[1] - l[2] == 1:
        l[2] += 2
        ans += 1
    l = sorted(l,reverse=True)    
print(ans)

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

if __name__ == '__main__':
    main()

Solution (Python):
count = 0

def main():
    A = list(map(int,input().split()))
    b1 = max(A)
    A.remove(b1)
    b2 = max(A)
    A.remove(b2)
    b3 = max(A)
    global count
    if b2 % 2 == b3 % 2:
        cal(b1,b2,b3)
    else:
        b1 += 1
        b2 += 1
        count += 1
        cal(b1,b2,b3)

def cal(b1,b2,b3):
    global count
    for _ in range(b2,b1):
        b2 += 1
        b3 += 1
        count += 1
    while b3 < b1:
        b3 += 2
        count += 1
    print(count)

main()

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

if (a[1]-a[0])%2 == 0:
    b = a[2]-a[1] + int((a[1]-a[0])/2)
else:
    b = a[2]-a[1] + int((a[1]-a[0])/2)+2

print(b)

Solution (Python):
num = [int(x) for x in input().split()]
ans = 0


r = [x%2 for x in num]
if 2 == len(set(r)):
    ans += 1
    if sum(r) == 1:
        r = [1-x for x in r]

num = [num[i] + r[i] for i in range(len(num))]


df = [max(num) - num[i] for i in range(len(num))]
ans += sum([x/2 for x in df])

print(int(ans))

Solution (Python):
a,b,c=map(int,input().split())
list=[a,b,c]
x=max(list)
y=min(list)
list.sort()
z=list[1]
if a==b==c:
    print("0")
elif a==b==x or b==c==x or c==a==x:
    if (x-y)%2==0:
        print(int((x-y)/2))
    else:
        print(int((x+1-y)/2)+1)
elif a==b==y or b==c==y or c==a==y:
    print(x-y)
else:
    if (z-y)%2==0:
        print(int((z-y)/2)+x-z)
    else:
        v=x+1
        w=z+1
        print(1+int((w-y)/2)+v-w)

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

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

Solution (Python):
a, b, c = map(int, input().split())
mini = min(a, b, c)
new_list = [ a - mini, b - mini, c - mini]
new_list2 = sorted(new_list)
ans2 = 0

maxi = max(new_list)
mid = new_list2[1]

if mid %2 == 0:
   ans2 = mid / 2
else:
   ans2 = ((mid - 1) / 2) + 2

print(int(ans2 + maxi - mid))

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

Solution (Python):
def main():
    l= [int(i) for i in input().split()]
    k = 0
    while(l.count(max(l)) < 3):
        l.sort()
        if max(l) - min(l) > 1:
            l[0] += 2
        else:
            l[1] += 1
            l[0] += 1
        k += 1
    print(k)
        

main()

Solution (Python):
import numpy as np

abc=list(map(int,input().split()))
abc=np.array(abc)
abc=np.sort(abc)

abc=abc-abc[0]

b=abc[1]
k=abc[2]-b

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

else:
    ans=k+2+(b-1)//2
    print(ans)

Solution (Python):
l = list(map(int, input().split()))
ma = max(l)
c = 0

for i in l:
    c += int((ma - i)/2)
    l[l.index(i)] += int((ma - i)/2) * 2

if l.count(ma-1) == 2:
    c += 1
elif l.count(ma-1) == 1:
    c += 2

print(c)

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

a = na()
b = sorted(a)

ff = b[2]-b[0]
fg = b[2]-b[1]
f = min(ff, fg)
if ff > fg:
    for i in range(f):
        b[0] += 1
        b[1] += 1

    g = b[2] - b[0]
    if g % 2 == 0:
        ans = g // 2
        print(f + ans)
    else:
        ans = g // 2 + 2
        print(f + ans)
elif ff < fg:
    for i in range(f):
        b[0] += 1
        b[1] += 1

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

Solution (Python):
ipt = sorted(map(int,input().split()))
X = ipt[0]
Y = ipt[1]
MAX = ipt[2]
cnt = 0

if X%2!=Y%2:
    X = X +1
    MAX = MAX +1
    cnt = cnt +1


n = int((MAX - X) / 2)
m = int((MAX - Y) / 2)

cnt = cnt + n + m + (MAX-X)%2
print(cnt)