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



Sample input:
2 5 4


Sample output:
2

Submission status: Accepted

Solution code:
#import numpy as np
#n = int(input())
x = [int(i) for i in input().split()]
#s = list(input())
x.sort()
a = x[0]
b = x[1]
c = x[2]

k = b-a
j = c-b

cnt = 0
cnt += j

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

Submission status: Accepted

Solution code:
x = list(map(int,input().split()))
x.sort()
ans=0
while not x[0]==x[1]==x[2]:
    if x[0]%2 != x[1]%2:
        x[1]+=1
        x[2]+=1
        ans+=1
    elif x[1]!=x[2]:
        x[0]+=1
        x[1]+=1
        ans+=1 
    else:
        x[0]+=2
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
S = list(map(int, input().split()))
x = sum(S)
y = max(S)
v = (y * 3 - x) // 2
if x % 2 == y % 2:
    print(v)
else:
    print(v+2)

Submission status: Accepted

Solution code:
def main():
    a = list(map(int, input().split()))
    a.sort()
    C,B,A = a
    AB = A-B
    AC = A-C
    if AB%2==0 and AC%2==0:
        return AB//2 + AC//2
    elif AB%2==1 and AC%2==1:
        return AB//2 + AC//2 + 1
    else:
        return AB//2 + AC//2 + 2


if __name__ == '__main__':
    print(main())

Submission status: Accepted

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

m = max(A, B, C)
num1 = min(A, B, C)
num2 = min(max(A, B), C) if A == num1 or B == num1 else min(max(B, C), A)
count = 0

if (m - num1) % 2 == (m - num2) % 2:
    if (m - num1) % 2 == 0:
        count += (m - num1) / 2
        count += (m - num2) / 2
    else:
        count += (m - num1) // 2
        count += (m - num2) // 2
        count += 1
    print(int(count))

else:
    if (m - num1) % 2 == 0:
        count += (m - num1) / 2
        count += (m - num2) // 2
        count += 2
    else:
        count += (m - num2) / 2
        count += (m - num1) // 2
        count += 2
    print(int(count))

Submission status: Accepted

Solution code:
a, b, c = sorted(map(int, raw_input().split()))[::-1]
print (a - b) / 2 + (a - c) / 2 + [0,2,1][(a - b) % 2 + (a - c) % 2]

Submission status: Accepted

Solution code:
mondai = input()

mondai = mondai.rstrip().split(" ")
kazu=[]
for i in range(3):
    if int(mondai[i])>=10:
        kazu.append(mondai[i])
        i +=1
    else:
        mondai[i]="0"+str(mondai[i])
        kazu.append(mondai[i])
        i +=1
kazu.sort(reverse=True)
#print(kazu)
sa1=int(kazu[0])-int(kazu[1])
sa2=int(kazu[0])-int(kazu[2])

if (int(kazu[1]) + int(kazu[2]))%2==0:
    print(int((int(sa1)+int(sa2))/2))
else:
    print(int((int(sa1)+int(sa2)-1)/2+2))

Submission status: Accepted

Solution code:
ns = [int(n) for n in input().split()]
ans = 0
while True:
    ns = sorted(ns)
    a = ns[0]
    b = ns[1]
    c = ns[2]
    if a == b and b == c:
        break
    elif a == b:
        if abs(a - c) >= 2:
            ns[1] = a + 2
        else:
            ns[0] = a + 1
            ns[1] = a + 1
        ans = ans + 1
    elif b == c:
        if abs(a - b) == 1:
            ans = ans + 2
            break
        else:
            ns[0] = a + 2
            ans = ans + 1
    else:
        ns[0] = a + 2
        ans = ans + 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,C=sorted(map(int,input().split()))
ct1=(C-A)//2
A+=ct1*2
ct2=(C-B)//2
B+=ct2*2
print(ct1+ct2+(A+B+C)%3)

Submission status: Accepted

Solution code:
S = list(map(int, input().split()))
S.sort(reverse  = True)
A, B, C = S[0], S[1], S[2]

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

Submission status: Accepted

Solution code:
a , b, c = map(int,input().split())
aaa = [a,b,c]
m = max(a,b,c)
aaaa = list(sorted(aaa))
x = aaaa[0]
y = aaaa[1]
z = aaaa[2]
sousa = 0

if (3 * m) % 2 == (a + b + c) % 2:
    truemax = m    
else:
    truemax = m + 1
    
    
while x <= truemax:
    sousa = sousa + 1
    x = x + 2
    
while y <= truemax:
    sousa = sousa + 1
    y = y + 2
    
b = list(sorted([x,y,z]))

xx = b[0]
yy = b[1]
zz = b[2]
    
sousa = sousa + (3 * truemax -xx -yy -zz) //2
print(sousa)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
m = list(map(int, input().split()))
A = m[0]
B = m[1]
C = m[2]

ans = 0
m.sort()

while (m[0] != m[1] and m[0] != m[1] - 1):
    m[0] += 2
    ans += 1

if m[0] == m[1]:
    ans += m[2] - m[1]
else:
    m[0]+=1
    m[2]+=1
    ans+=1
    ans += m[2] - m[1]

print(ans)

Submission status: Accepted

Solution code:
numList = input().split()
numList = list(map(int, numList))
commandList = [
	[2,0,0],
	[0,2,0],
	[0,0,2],
	[0,1,1],
	[1,0,1],
	[1,1,0]
]
numListList = [numList]

def search(depth):
	global numListList
	tmpList = []
	for numList in numListList:
		for command in commandList:
			sumedList = sumList(numList, command)
			if check(sumedList, depth+1):
				return
			tmpList.append(sumedList)
	numListList = tmpList
	search(depth+1)

def sumList(list1, list2):
	return [list1[0]+list2[0], list1[1]+list2[1], list1[2]+list2[2]]

def check(numList, count):
	if numList[0] == numList[1] and numList[1] == numList[2]:
		print(count)
		return True

	if numList[0] == numList[1]:
		return check2(numList[0], numList[2], count)

	if numList[1] == numList[2]:
		return check2(numList[1], numList[0], count)

	if numList[0] == numList[2]:
		return check2(numList[0], numList[1], count)

	return False

def check2(num1, num2, count):
	if num1 > num2:
		if (num1-num2)%2 == 0:
			print(int(count+(num1-num2)/2))
			return True
		else:
			print(int(count+(num1-num2)/2)+2)
			return True
	else:
		print(int(count+(num2-num1)))
		return True

if check(numList, 0):
	pass
else:
	search(0)

Submission status: Accepted

Solution code:
As = [ int(i) for i in input('').split()]
#As = "2 6 3"
#As = [ int(i) for i in As.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)

Submission status: Accepted

Solution code:
# PROBLEM C
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))
#print(list)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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:
#     print("a")
    add = (x+y)/2
elif x%2 == 1 and y%2  == 1:
#     print("b")
    add = (x+y-2)/2 + 1
else:
#     print("c")
    add = (x+y-1)/2 + 2
    
    
print(int(add))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
#coding: utf-8                          
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))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
#abc093c

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

Submission status: Accepted

Solution code:
#!python
# -*- coding: utf-8 -*-

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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

    #f(A, B, C)
    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:
        # A+2,BC+1
        ans += 2

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
   
#A = 7
#B = 5
#C = 2

lst = input().split(' ')

#lst = [A, B, C]
for i in range(len(lst)):
    lst[i] = int(lst[i])

i = -1
while True:
    i += 1
    lst.sort()
#    print(i, lst)
    if lst[0] == lst [2]:
        break
    
    if lst[0] == lst[1]:
        lst[0] += 1
        lst[1] += 1
    else:
        lst[0] += 2
        


print(i)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C

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

    # See:
    # https://www.youtube.com/watch?v=HDRfgn_UXLE
    # https://img.atcoder.jp/arc094/editorial.pdf
    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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:

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

#a_min = min(a)
#a[0] -= a_min
#a[1] -= a_min
#a[2] -= a_min

count = 0
while(True):
    if a[0] == a[1] and a[1] == a[2]:
        #print(count)
        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)

Submission status: Accepted

Solution code:
#coding: utf-8
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))

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
def c_same_integers(A, B, C):
    # A,B,Cの和と、これらのうち最大のもの(Mとする)との偶奇が一致するなら、
    # 最終的に3つの整数はMとなる
    # 偶奇が一致しないなら、最終的に3つの整数はM+1となる
    m = max(A, B, C)
    parity = 3 * max(A, B, C) % 2 == (A + B + C) % 2
    max_value = m if parity else m + 1
    # 3数の和は1回の操作で2増えるため,ans回の操作が必要
    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))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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)