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 sys

s_args = sys.stdin.read().splitlines()

s_args = s_args[0].split(' ')

a = int(s_args[0])
b = int(s_args[1])
c = int(s_args[2])

eo = []
res = 0

if a % 2 == 0:
    eo.append('a')
if b % 2 == 0:
    eo.append('b')
if c % 2 == 0:
    eo.append('c')

if len(eo) != 0 and len(eo) != 3:
    res += 1
    if len(eo) == 1:
        if not 'a' in eo:
            a += 1
        if not 'b' in eo:
            b += 1
        if not 'c' in eo:
            c += 1
    elif len(eo) == 2:
        if 'a' in eo:
            a += 1
        if 'b' in eo:
            b += 1
        if 'c' in eo:
            c += 1

n = [a, b, c]
n.sort()
res += (n[2] - n[0]) // 2
res += (n[2] - n[1]) // 2

print(res)

Submission status: Accepted

Solution code:
inLine = list(map(int,input().split()))
ret = 0
inLine.sort(reverse = True)
if (inLine[1]-inLine[2]) % 2 != 0 :
    inLine[0] += 1
    inLine[2] += 1
    ret += 1
while inLine[0] != inLine[1]:
    inLine[1] += 1
    inLine[2] += 1
    ret += 1
while inLine[0] != inLine[2]:
    inLine[2] += 2
    ret += 1
print(ret)

Submission status: Accepted

Solution code:
text = input()

a = int(text.split(' ')[0])
b = int(text.split(' ')[1])
c = int(text.split(' ')[2])

x, y, z = sorted([a, b, c])

cnt = z - y
y = z
x += cnt

cnt += int((y - x) / 2)
x += int((y - x) / 2) * 2

if y - x == 1:
    print(cnt+2)
else:
    print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def get_next_int():
    return int(float(input()))


def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])


def get_next_str():
    return input()


def get_next_strs(delim=" "):
    return tuple(input().split(delim))


def get_next_by_types(*value_types, delim=" "):
    return tuple([t(x) for t, x in zip(value_types, input().split(delim))])


def solve():
    A, B, C = get_next_ints()
    parity = (A % 2 + B % 2 + C % 2)
    ans = 0
    if parity == 1:
        A += 1 if A % 2 == 0 else 0
        B += 1 if B % 2 == 0 else 0
        C += 1 if C % 2 == 0 else 0
        ans += 1
    if parity == 2:
        A += 1 if A % 2 != 0 else 0
        B += 1 if B % 2 != 0 else 0
        C += 1 if C % 2 != 0 else 0
        ans += 1
    max_val = max(A, B, C)
    ans += int((max_val - A) / 2 + (max_val - B) / 2 + (max_val - C) / 2)
    print(ans)

solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l = list(map(int, input().split()))
l_2 = list(i % 2 for i in l)
cnt = 0
##偶奇そろえて
for r in (0, 1):
    if l_2.count(r) == 2:
        cnt += 1
        for i in range(len(l)):
            if l[i] % 2 == r:
               l[i] += 1
##全体からmaxを引いたものを正負反転して/2
##print(cnt)
l_d = list(abs(i - max(l)) // 2 for i in l)
##print(l)
##print(l_d)
cnt += sum(l_d)
print(cnt)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8
#

def main(input_str):
    a, b, c = list(map(int, input_str.split(' ')))
    max_val = max([a, b, c])
    counter = 0
    for i in [a, b, c]:
        counter += max_val - i

    if 1 == counter % 2:
        counter -= 1
        print(int(counter/2 + 2))
        return
    else:
        print(int(counter/2))
        
if __name__ == '__main__':
    try:
        main(input().strip())
    except EOFError:
        pass

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = list(map(int, input().split()))
x.sort()

first_1 = x[2] - x[1]
y = (x[2] - x[0] - first_1)
                                                                                                      
if y % 2 == 0:
  print(first_1 + (y//2))
else:
  print(first_1 + (y//2) + 2)

Submission status: Accepted

Solution code:
raw_a, raw_b, raw_c = map(int, input().split())

# 偶奇をそろえたい
# 2 6 3
# 4 6 3
# 6 6 3
# 6 6 5
# 6 6 7
# 7 7 7

a_guuki = raw_a % 2
b_guuki = raw_b % 2
c_guuki = raw_c % 2

if a_guuki == b_guuki == c_guuki:
    a = raw_a
    b = raw_b
    c = raw_c
    if a == b == c:
        print(0)
        exit()
    max_number = max(a, b, c)
    if max_number == a:
        print((a-b)//2 + (a-c)//2)
        exit()
    if max_number == b:
        print((b-a)//2 + (b-c)//2)
        exit()
    if max_number == c:
        print((c-a)//2 + (c-b)//2)
        exit()

elif a_guuki == b_guuki:
    a = raw_a
    b = raw_b
    c = raw_c
elif a_guuki == c_guuki:
    a = raw_a
    b = raw_c
    c = raw_b
elif b_guuki == c_guuki:
    a = raw_b
    b = raw_c
    c = raw_a

ans = 0

ans += abs(a-b)//2 + 1  # aとbをそろえて偶奇をcに合わせる

ans += (max(a, b)+1 - c) // 2  # cをa、bに合わせる

print(ans)

Submission status: Accepted

Solution code:
import sys

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


def sousa1():
	global count
	global l
	x_min=l.index(min(l))
	x_max=l.index(max(l))
	x_else = 0 if x_min+x_max==3 else 1 if x_min+x_max==2 else 2
	count+=l[x_max]-l[x_else]

	l[x_min]+=l[x_max]-l[x_else]
	l[x_else]=l[x_max]
	

def sousa1_2():
	global count
	global l
	x_min=l.index(min(l))
	x_max=l.index(max(l))
	x_else = 0 if x_min+x_max==3 else 1 if x_min+x_max==2 else 2

	count+=1
	l[x_else]+=1
	l[x_max]+=1

def sousa2():
	global count
	global l
	x_min=l.index(min(l))
	x_max=l.index(max(l))
	count+=(l[x_max]-l[x_min])/2
	l[x_min]=l[x_max]


def judge():
	x_min=l.index(min(l))
	x_max=l.index(max(l))
	x_else = 0 if x_min+x_max==3 else 1 if x_min+x_max==2 else 2
	if l[x_max]!=l[x_else]:
		return 0
	elif (l[x_max]-l[x_min])%2==0:
		return 1
	else:
		return 2

while not(l[0]==l[1] and l[1]==l[2] and l[0]==l[2]):
	hoge=judge()
	if hoge==0:
		sousa1()
	elif hoge==1:
		sousa2()
	else:
		sousa1_2()

print(int(count))

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    abc = [int(x) for x in stdin.readline().rstrip().split()]
    count = 0
    while True:
        abc.sort()
        if abc[0] == abc[1] == abc[2]:
            print('{}'.format(count))
            return
        if abc[1] == abc[2]:
            abc[0] += 2
        else:
            abc[0] += 1
            abc[1] += 1
        count += 1


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

def exec():
    arr = map(int, input().split())
    a,b,c = sorted(arr)

    t1 = c - b
    t2 = c - (t1+a)
    if t2 % 2 == 0:
        t1 += int(t2/2)
    else:
        t1 += int(t2/2) + 1 + 1
    print(t1)


if __name__ == "__main__":
    exec()

Submission status: Accepted

Solution code:
def mod2(n):
    return n%2

def f(L): #L=[A,B,C]
    L2 = list(map(mod2, L))
    num0 = L2.count(0)
    if num0 == 0 or num0 == 3:
        L.sort()
        L.reverse()
        return (L[0] * 2 -L[2] - L[1]) //2
    else:
        d = 0 if num0 == 1 else 1
        m = {0, 1, 2} - {L2.index(d)}
        Lnext = [L[n] + 1 if n in m else L[n] for n in range(3)]
        return 1 + f(Lnext)
        
print(f(list(map(int, input().split()))))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
inputs = np.array(input().split(), dtype = 'float')

diff = inputs.max() * 3 - inputs.sum()
if diff % 2 == 0:
    print(int(diff / 2.0))
else:
    print(int(np.floor(diff / 2.0)) + 2)

Submission status: Accepted

Solution code:
a = list(map(int,input().split()))
count = 0
a.sort()
sub = a[0]
for i in range(3):
	a[i] -= sub
while a[0] < a[1]-1:
	count += 1
	a[0] += 2
if a[0] == a[1]:
	count += a[2]-a[1]
else:
	count += 2 + a[2] - a[1]
print(count)

Submission status: Accepted

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

num = 0

while (A != B or B != C or C != A):
    if max(A,B,C) == A and A != B and A != C:
        B += 1
        C += 1
    elif max(A,B,C) == A and A == B and A != C:
        C += 2
    elif max(A,B,C) == A and A != B and A == C:
        B += 2
    elif max(A,B,C) == B and B != A and B != C:
        A += 1
        C += 1
    elif max(A,B,C) == B and B != A and B == C:
        A += 2
    elif max(A,B,C) == B and B == A and B != C:
        C += 2
    elif max(A,B,C) == C and C != A and C != B:
        A += 1
        B += 1
    # elif max(A,B,C) == C and C != A and C == B:
    #     A += 2
    #     num += 1
    # elif max(A,B,C) == C and C == A and C != B:
    #     B += 2
    #     num += 1
    else:
        print "unexpect"

    num += 1
#    print A, B, C

print num

Submission status: Accepted

Solution code:
def c_same_integers(A, B, C):
    max_value = max(A, B, C)
    t = []
    ans = 0
    for e in [A, B, C]:
        if e == max_value:
            t.append(max_value)
            continue
        if e % 2 == max_value % 2:
            t.append(max_value)
        else:
            t.append(max_value - 1)
        ans += (max_value - e) // 2
    t.sort(reverse=True)
    x, y, z = t
    if x == y == z:
        pass
    elif x == y:
        ans += 2
    elif y == z:
        ans += 1
    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, B, C = sorted(map(int, input().split()))

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

Submission status: Accepted

Solution code:
vals = [int(s) for s in input().split()]

rs = [v%2 for v in vals]

def f(vs):
    m = max(vs)
    d = [(m-x)//2 for x in vs]
    return sum(d)

add = 0
if not (sum(rs)==0 or sum(rs)==3):
    add = 1
    if rs[0]==rs[1]:
        vals[0] += 1
        vals[1] += 1
    if rs[1]==rs[2]:
        vals[1] += 1
        vals[2] += 1
    if rs[2]==rs[0]:
        vals[2] += 1
        vals[0] += 1

print(f(vals) + add)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

d1 = a[2] - a[1]
d2 = a[2] - a[0]

print(d1 + (d2 - d1) // 2 + ((d2 - d1) % 2) * 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A=[int(x) for x in input().split()]
A.sort()

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

Submission status: Accepted

Solution code:
def main():
    ABC = tuple(map(int, input().split()))

    abc = sorted(ABC)
    cnt = abc[2] - abc[1]
    abc = [abc[0] + cnt, abc[1] + cnt, abc[2]]
    n = abc[1] - abc[0]
    if n % 2:
        cnt += -(-n // 2) + 1
    else:
        cnt += n // 2

    print(cnt)

main()

Submission status: Accepted

Solution code:
A,B,C = map(int, input().split())
o1 = min(A,B,C)
o3 = max(A,B,C)
o2 = A + B + C - o1 - o3
#print (str(o1) +  " " + str(o2) +  " "  + str(o3))
count = 0 
count += o3 - o2
o2 += count 
o1 += count
#print (count)
#print (str(o1) +  " " + str(o2) +  " "  + str(o3))
count += (o2 - o1)//2
o1 += ((o2 - o1)//2)*2
#print (str(o1) +  " " + str(o2) +  " "  + str(o3))
if (o1 == o2) :
	print (count)
else :
	print (count + 2)

Submission status: Accepted

Solution code:
abc = list(map(int, input().split()))
abc.sort()
count = 0
count += int((abc[2]-abc[1])/2)
abc[1] += 2*int((abc[2]-abc[1])/2)

count += int((abc[2]-abc[0])/2)
abc[0] += 2*int((abc[2]-abc[0])/2)

if abc[2]*3-sum(abc) == 1:
	count += 2
elif abc[2]*3-sum(abc) == 2:
	count += 1

print(count)

Submission status: Accepted

Solution code:
smallest, medium, biggest = sorted(map(int, input().split()))
ops_1 = biggest - medium
ops_2 = (biggest - (smallest + ops_1)) // 2
rest = 2 * ((biggest - (smallest + ops_1)) % 2)
print(ops_1 + ops_2 + rest)

Submission status: Accepted

Solution code:
number_list = list(map(int,input().split()))

number_list.sort()

a = number_list[0]
b = number_list[1]
c = number_list[2]
counter = 0

if (b-a)%2==0:
    counter += (b-a)/2
    counter += (c-b)
    print(int(counter))

else:
    a = a + 1
    c = c + 1
    counter += (b-a)/2
    counter += (c-b)
    print(int(counter+1))

Submission status: Accepted

Solution code:
num=list(map(int,input().split()))
num.sort()
a,b,c=num[0],num[1],num[2]

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

Submission status: Accepted

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

if __name__ == "__main__":
    """
    操作1：２つを選んで、その両方を+1する
    操作2：１つを選んで、その数字を+2する
    """
    nums = list(map(int, input().split()))
    # (1) 2番目に大きい数字が、最も大きい数字になるように、操作1を繰り返す
    # (2) その後、最も小さい数字が、最も大きい数字に鳴るように操作2を繰り返す

    # (1)
    nums.sort()
    A = nums[0]
    B = nums[1]
    C = nums[2]
    ans = 0
    n = C - B # 操作回数
    A += n
    B += n
    ans += n

    # (2)
    diff = C - A
    if diff%2 != 0:
        C += 1
        B += 1
        ans += 1 # 最も大きい数字に追加で操作1を行う
    diff = C - A
    ans += math.floor(diff/2)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

    f(A,B,C)


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:
List = list(map(int,input().split()))

judge = 3*max(List) - sum(List)

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

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
a.sort()
b = (a[2]-a[0])//2
c = (a[2]-a[1])//2

if (a[2]-a[0])%2 == 0 and (a[2]-a[1])%2 == 0:
    print(b+c)
if (a[2]-a[0])%2 != 0 and (a[2]-a[1])%2 != 0:
    print(b+c+1)
if (a[2]-a[0])%2 == 0 and (a[2]-a[1])%2 != 0:
    print(b+c+2)
if (a[2]-a[0])%2 != 0 and (a[2]-a[1])%2 == 0:
    print(b+c+2)

Submission status: Accepted

Solution code:
A = list(map(int, input().split()))
t=0


while max(A)-min(A)>1:
    x = min(A)
    A.remove(x)
    A.append(x+2)
    t += 1

P = A.count(max(A))
if P == 1:
    t+=1
elif P == 2:
    t += 2

print(t)

Submission status: Accepted

Solution code:
import sys

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    L = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
    L.sort()
    Min = L[0]
    Mid = L[1]
    Max = L[2]
    s = (Max - Mid)/2
    s += (Max - Min)/2
    if (Max - Mid)%2 != 0 and (Max - Min)%2 != 0:
        s += 1
    elif (Max - Mid)%2 != 0 or (Max - Min)%2 != 0:
        s += 2

    print s



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a, b, c = sorted([int(x) for x in input().split()])

xb = (c - b) // 2
b += xb * 2
xa = (c - a) // 2
a += xa * 2

x = xa + xb
if a == b and b == c:
    print(x)
elif a < c and b < c:
    print(x + 1)
else:
    print(x + 2)

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
d = [a, b, c]
d.sort()

count = 0

while d[2] > d[1]:
    d[1] += 1
    d[0] += 1
    count += 1

while d[0] < d[1]-1:
    d[0] += 2
    count += 1

if d[0] == d[1]:
    print(count)
else:
    print(count+2)

Submission status: Accepted

Solution code:
A = sorted(list(map(int, input().split())))
ans = 0

while len(set(A))>1:
    if A[2] > A[0]+1:
        A[0] += 2
    elif A[1] == A[2] and A[0] == A[1]-1:
        A[1] += 1
        A[2] += 1
    elif A[0]== A[1] and A[1] == A[2]-1:
        A[0] += 1
        A[1] += 1
    elif A[0] < A[1]:
        A[0] += 2
    ans += 1
    A.sort()

print(ans)

Submission status: Accepted

Solution code:
A, B, C = sorted(list(map(int, input().split())))
#print(A,B,C)

dA = C - A
dB = C - B

ans = 0
if dA%2==0 and dB%2!=0:
    A += 1
    C += 1
    ans += 1
elif dA%2!=0 and dB%2==0:
    B += 1
    C += 1
    ans += 1
elif dA%2!=0 and dB%2!=0:
    A += 1
    B += 1
    ans += 1

dA = C - A
dB = C - B
ans += dA//2 + dB//2

print(ans)

Submission status: Accepted

Solution code:
a, b, c = [int(x) for x in input().strip().split()]

M = max(a, b, c)
s = sum([M-x for x in [a, b, c]])
if s&1:
    s += 3

print(s//2)

Submission status: Accepted

Solution code:
import numpy as np

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

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

s = m - a + m - b + m - c

if(s % 2 == 1):
    s += 3

print(int(s/2))

Submission status: Accepted

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

S = A + B + C
D = max(A, B, C)
S_ = S
while True:
    if S_ % 3 == 0:
        E = S_ // 3
        if E >= D:
            F = 3*E - A - B - C
            if F % 2 == 0:
                ans = F // 2
                break
    S_ += 2

print(ans)

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
cnt = 0


while not(a[0] == a[1] == a[2]):
    a.sort()
    if a[2] - a[0] >= 2:
        a[0] += 2
        cnt += 1


    elif a[2] - a[0] >= 1 or a[2] - a[1] >= 1:
        a.sort()
        a[0] += 1
        a[1] += 1
        cnt += 1

print(cnt)

Submission status: Accepted

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

    max_value = max(A, B, C)
    diff_sum = sum([max_value - v for v in [A, B, C]])

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

Submission status: Accepted

Solution code:
# coding : utf-8

import numpy as np

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


maxl = max(A,B,C)
diff = [maxl-A,maxl-B,maxl-C]

diff = sorted(diff)

count = 0

count += diff[1]
diff[2] -= diff[1]

count += int(diff[2]/2)
diff[2] = diff[2]%2

if diff[2] == 1:
	count += 2

print(int(count))

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
x = max(a+b+c, 3*max(a, b, c))
y = (x//3 + (x%3>0))*3 
if (a+b+c)%2 != y%2:
  y += 3
print((y-(a+b+c))//2)

Submission status: Accepted

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

if a > b:
    d = a
    a = b
    b = d
    
if b > c:
    d = b
    b = c
    c = d
   
if a > b:
    d = a
    a = b
    b = d 


if (b-a) % 2 == 1:
    ans = c-b+int((b-a)/2)+2
else:
    ans = c-b+int((b-a)/2)

print(ans)

Submission status: Accepted

Solution code:
s = [int(x) for x in input().split()]
s.sort()
cnt = 0

tmp = abs(s[0] - s[1])
if tmp % 2 == 0:
    cnt += tmp // 2
else:
    cnt += tmp // 2 + 1
    s[2] += 1

print(cnt+s[2]-s[1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l = list(map(int, input().split()))
count = 0
while True:
  l.sort()
  if l[0] == l[1] and l[1] == l[2]:
    break

  if l[0] < l[1] and l[1] == l[2]:
    l[0] += 2
    count += 1
  else:
    l[0] += 1
    l[1] += 1
    count += 1

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
count = 0
abclist = [int(x) for x in input().split()]
abclist = sorted(abclist)
while(abclist[1] - abclist[0] >= 2):
    abclist[0] += 2
    count += 1
while(abclist[1] - abclist[0] == 1):
    abclist[0] += 1
    abclist[2] += 1
    count += 1
while(abclist[2] - abclist[1] > 0):
    abclist[0] += 1
    abclist[1] += 1
    count += 1
print(count)

Submission status: Accepted

Solution code:
# your code goes here
num = list(map(int,input().split()))
num.sort()

ans = int((num[2] - num[1])/2)
num[1] += ans*2
ans += int((num[2]- num[0])/2)
num[0] += int((num[2]- num[0])/2)*2
num.sort()

if num[0] == num[1] and num[1] == num[2]:
	print(ans)
elif num[0] == num[1]:
	print(ans+1)
else:
	print(ans+2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
nums = [int(_) for _ in input().split()]
nums.sort()
ans = 0

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

Submission status: Accepted

Solution code:
a = map(int,raw_input().split())
a.sort()

count = 0

d = [0,0]

d[0] = a[2] - a[1]
d[1] = a[2] - a[0]
d.sort()

while d[0] != 0:
  d[0] -= 1
  d[1] -= 1 
  count += 1

if d[1] == 0:
  print count
  exit(0)

if d[1] % 2 == 1:
  d[1] += 1
  count += 1

count += d[1]/2
print count

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ABC = sorted(list(map(int, input().split())))
if (ABC[2]%2 == ABC[1]%2 and ABC[2]%2 != ABC[0]%2) or (ABC[2]%2 != ABC[1]%2 and ABC[2]%2 == ABC[0]%2):
    print(1+((ABC[2]+1)*2-(ABC[0]+ABC[1]+1))//2)
else:
    print((ABC[2]*2-(ABC[0]+ABC[1]))//2)

Submission status: Accepted

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

count = 0

while(1):
    # print(a,b,c)
    if a == b == c:
        break
    if a == b and b < c:
        a += 1
        b += 1
        count += 1
    elif b == c and c < a:
        b += 1
        c += 1
        count += 1
    elif c == a and a < b:
        c += 1
        a += 1
        count += 1
    else:
        if a == min(a,b,c):
            a += 2
            count += 1
        elif b == min(a,b,c):
            b += 2
            count += 1
        elif c == min(a,b,c):
            c += 2
            count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input().split(" ")
s = [int(i) for i in s]
s = sorted(s)
Max = s[2]
Med = s[1]
Min = s[0]

count = Max - Med
left = (Max - Min - count) 
if left % 2 == 1 : 
    count += (left+1)/2 + 1
else : 
    count += left/2
print(int(count))

Submission status: Accepted

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

maximum = max(num)
dif = [maximum - n for n in num]

counter = 0
odd = 0
for d in dif:
    q, r = divmod(d, 2)
    counter += q
    odd += r

if odd == 0:
    pass
elif odd == 1:
    counter += 2
else:
    counter += 1

print(counter)

Submission status: Accepted

Solution code:
A,B,C = [int(x) for x in input().split()]
D = max(A,B,C)
ans = 0

ans += (D-A)//2
A += 2*((D-A)//2)
ans += (D-B)//2
B += 2*((D-B)//2)
ans += (D-C)//2
C += 2*((D-C)//2)

if max(A,B,C) != (A+B+C)/3:
    if A+B+C+1 == max(A,B,C)*3:
        ans +=2
    else:
        ans +=1

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8

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

d = max(A, B, C)
t = d*3 - (A + B + C)

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    nums = sorted(list(map(int, input().split())))

    ans = 0
    l_s = nums[2] - nums[0]
    l_m = nums[2] - nums[1]
    ans += l_s // 2 + l_m // 2
    nums[0] += 2 * (l_s // 2)
    nums[1] += 2 * (l_m // 2)

    # print(ans)
    # print(nums)
    if nums[0] == nums[1] and nums[0] == nums[2]:
        print(ans)
    elif nums[0] == nums[1] and nums[1] != nums[2]:
        print(ans + 1)
    else:
        print(ans + 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#! /usr/bin/env python3

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

value_max = max(a, b, c)

diff = 0
for z in [a, b, c]:
    diff += value_max - z

res = 0
if diff % 2 == 0:
    res = diff // 2
else:
    res = diff // 2 + 2

print(res)

Submission status: Accepted

Solution code:
n=list(map(int,input().split()))
n.sort()
c=0
while True:
    if(n[0]==n[1] and n[0]==n[2]):
        break
    if(n[0]==n[1]):
        n[0]+=1
        n[1]+=1
    else:
        n[0]+=2
    n.sort()
    c+=1
print(c)

Submission status: Accepted

Solution code:
def inpl(): return list(map(int, input().split()))
a = inpl()
a = sorted(a)

mid_count, min_count = (a[2]-a[1])//2, (a[2]-a[0])//2

if a[0]+min_count*2==a[1]+mid_count*2:
    if a[0]+min_count*2==a[2]:
        diff = 0
    else:
        diff = 1
else:
    diff = 2

print(mid_count+min_count+diff)

Submission status: Accepted

Solution code:
abc = list(map(int, input().split()))
count = 0
while abc[0] != abc[1] or abc[1] != abc[2] or abc[2] != abc[0]:
    abc = sorted(abc)
    if len(set(abc)) == 2:
        if abc[0] == abc[1]:
            abc[0] += 1
            abc[1] += 1
        else:
            abc[0] += 2
    else:
        abc[0] += 1
        abc[1] += 1
    count += 1
print(count)

Submission status: Accepted

Solution code:

a, b, c = map(int, input().split(" "))
count = 0
while min(a, b, c) < max(a, b, c):
    if max(a, b, c) - min(a, b, c) > 1:
        count += 1
        if a == min(a, b, c):
            a += 2
        elif b == min(a, b, c):
            b += 2
        elif c == min(a, b, c):
            c += 2
    else:
        num = 0
        for i in [a, b, c]:
            if i == max(a, b, c):
                num += 1
        if num == 1:
            count += 1
        else:
            count += 2
        break
print(count)

Submission status: Accepted

Solution code:
arr=list(map(int, input().split(" ")))
arr=sorted(arr)
diff=arr[2]-arr[1]+arr[2]-arr[0]
if diff%2==0:
    print(int(diff/2))
else:
    print(int((diff+3)/2))

Submission status: Accepted

Solution code:
a,b,c=list(map(int,input().split()))
mi=min([a,b,c])
ma=max([a,b,c])
mid=a+b+c-mi-ma
ans=0

if (mid-mi)%2==1:
  ans+=1
  ma+=1
  mi+=1
  ans+=(mid-mi)/2
  ans+=ma-mid
else:
  ans+=(mid-mi)/2
  ans+=ma-mid

print(int(ans))

Submission status: Accepted

Solution code:
int_list = list(map(int, input().split(' ')))

max_int = max(int_list)

cnt = 0
for i in range(3):
    if i < max_int:
        cnt_tmp = (max_int - int_list[i]) // 2
        int_list[i] += 2 * cnt_tmp
        cnt += cnt_tmp

min_int = min(int_list)
int_list2 = sorted([i - min_int for i in int_list])

if int_list2 == [0, 0, 0]:
    print(cnt)
elif int_list2 == [0, 0, 1]:
    print(cnt + 1)
else:
    print(cnt + 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A = sorted([int(x) for x in input().split()])
count = 0
for x in range(A[2] - A[1]):
 count += 1
 A[0] += 1
 A[1] += 1
for x in range((A[2] - A[0])//2):
 count += 1
 A[0] += 2
print(count if A.count(A[0]) == 3 else count+2)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# import numpy as np
N = map(int, raw_input().split())
N.sort()

a,b,c = tuple(N)


cnt = 0
# if a=b=c:
#     print 0:
# else:

d1 = c - a
d2 = c - b

i = d1 / 2
d1 = d1 - i * 2

cnt += i

j = d2 / 2
d2 = d2 - j * 2

cnt += j

if d1 == d2 == 0:
    print cnt

elif d1 == d2 == 1:
    print cnt + 1
else:
    print cnt + 2

Submission status: Accepted

Solution code:
A, B, C = [int(x) for x in input().split()]

d = sorted([A, B, C], reverse=True)
parity = (A + B + C) % 2

if (parity == 0 and d[0] % 2 == 1) or (parity == 1 and d[0] % 2 == 0):
    goal = d[0] + 1
else:
    goal = d[0]

print((goal * 3 - (A + B + C)) // 2)

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
a = max(A, B, C)
c = min(A, B, C)
b = (A + B + C) - (a + c)

ans = (a - b) + (b - c) // 2
if (b - c) % 2 == 1:
    ans += 2

print(ans)

Submission status: Accepted

Solution code:
line = list(map(int,input().split()))

line.sort()

large = line[2]

board = 3*large

total = sum(line)

while (board-total)%2 !=0:
    board += 3

print(int((board-total)/2))