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:
from collections import Counter
def getinputdata():

    array_result = []
    
    array_result.append(input().split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()

arr = sorted([int(x) for x in arr_data[0]])

mindata = int(arr[0])
middledata = int(arr[1])
maxdata = int(arr[2])

sabun01 = middledata-mindata
sabun02 = maxdata-middledata
sabun03 = maxdata-mindata

#minをmiddleに寄せてから　middleをmax
if sabun01 % 2 == 0 :
    
    cnt01 = (sabun01 // 2) + sabun02 

elif sabun01 % 2 != 0 and sabun02 % 2 != 0:

    cnt01 = (sabun01 // 2) + 1 + 2 + sabun02-1

elif sabun01 % 2 != 0 and sabun02 % 2 == 0:
    
    cnt01 = (sabun01 // 2) + 1 + 1 + sabun02


#middleをmaxに寄せてから　minをmax
if sabun02 % 2 == 0 and sabun03 % 2 == 0:
    
    cnt02 = (sabun02 // 2) + sabun03
    
elif sabun02 % 2 == 0 and sabun03 % 2 != 0:
    
    cnt02 = (sabun02 // 2) + sabun03 + 2
    
elif sabun02 % 2 != 0:
    
    cnt02 = (sabun02 // 2) + 1  + 2 + sabun03-1
    
print(min(cnt01,cnt02))

Submission status: Accepted

Solution code:
# ANSHUL GAUTAM
# IIIT-D

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

Submission status: Accepted

Solution code:
li = list(map(int, input().split()))
li.sort(reverse=True)
count, mod = divmod(li[0] * 2 - li[1] - li[2], 2)
if mod == 1:
    count += 2

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def count(line):
	count = 0
	if (line[0]+line[1]+line[2])%2 == 0:
		flag = False
		for i in range(3) :
			if line[i]%2 == 1 :
				line[i] += 1
				flag = True

		if flag == True:
			count += 1
		
		max = 0
		
		for i in range(3):
			if max < line[i]:
				max = line[i]
		for i in range(3):
			count += (max - line[i])/2
		return count
	else :
		flag = False
		for i in range(3):
			if line[i]%2 == 0:
				line[i] += 1
				flag = True
		if flag == True:
			count+= 1
		max = 0
		for i in range(3):
			if max<line[i]:
				max =line[i]
		for i in range(3) : 
			count += (max-line[i])/2
		return count

print count(map(int,raw_input().split()))

Submission status: Accepted

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

Submission status: Accepted

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

M = sorted([A,B,C])
ans = 0

#Step 1
ans += M[2]-M[1]
M[0] += M[2]-M[1]
M[1] += M[2]-M[1]

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

Submission status: Accepted

Solution code:
import numpy as np

a=np.vectorize(int)(input().split())

cnt2=np.vectorize(lambda x: int((np.max(a)-x)/2))(a)
cnt1=np.max(a)-a-2*cnt2
print(sum(cnt2)+[0,2,1][sum(cnt1)])

Submission status: Accepted

Solution code:
import math

s = input().rstrip().split()

l = [int(s[0]), int(s[1]), int(s[2])]

l.sort()

a = l[0]
b = l[1]
c = l[2]
x = b - a
a = c - a
b = c - b



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

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:
a, b, c = sorted(map(int, input().split()))
steps = 0
if (b-a)%2 == 1:
    steps += (b-a)//2+1+1
else:
    steps += (b-a)//2
steps += c-b
print(steps)

Submission status: Accepted

Solution code:
A,B,C=map(int,input().split())
X=sorted([A,B,C])
count=0
while X[1]<X[2]:
    count+=1
    X[1]+=1
    X[0]+=1
while X[0]<X[1]:
    count+=1
    X[0]+=2
if X[0]>X[1]:
    count+=1
print(count)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Contents   : AtCoder Regular Contest 94 C問題 
Author     : Kitaura Hiromi
LastUpdate : 20180414
Since      : 20180414
https://img.atcoder.jp/arc094/editorial.pdf
"""

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

if (A%2 == B%2) and (B%2 == C%2):
    pass
else:
    if A%2 == B%2:
        A += 1
        B += 1
        cnt += 1
    elif A%2 == C%2:
        A += 1
        C += 1
        cnt += 1
    else:
        B += 1
        C += 1
        cnt += 1

ABC = sorted([A, B, C])
cnt += (ABC[2] - ABC[1]) // 2
cnt += (ABC[2] - ABC[0]) // 2
print(cnt)

Submission status: Accepted

Solution code:
arr = [int(x) for x in input().split()]
max_item = max(arr)
max_index = arr.index(max_item)
del arr[max_index]
diff1 = max_item - arr[0]
diff2 = max_item - arr[1]
diff = diff1 + diff2
if diff % 2 == 0:
    print(int(diff/2))
else:
    print(int((diff + 1)/2) + 1)

Submission status: Accepted

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

c = 0
for i in a:
    c += b - i
print(c // 2 + c % 2 * 2)

Submission status: Accepted

Solution code:
def middle(lst):
    _lst = lst
    _lst.sort()
    return _lst[-2]

def min_times(lst):
    data = lst
    times = 0
    idx_even = []
    idx_odd = []
    for i, v in enumerate(data):
        if v % 2 == 0:
            idx_even.append(i)
        else:
            idx_odd.append(i)
    odd_len = len(idx_odd)
    if odd_len == 2:
        for i in idx_odd:
            data[i] += 1
        times += 1
    if odd_len == 1:
        for i in idx_even:
            data[i] += 1
        times += 1
    times += (max(data) - middle(data)) / 2
    times += (max(data) - min(data)) / 2
    return times

use_data = [int(i) for i in raw_input().strip().split()]

print(min_times(use_data))

Submission status: Accepted

Solution code:
def middle(lst):
    _lst = lst
    _lst.sort()
    return _lst[-2]

def min_times(lst):
    data = lst
    times = 0
    idx_even = []
    idx_odd = []
    for i, v in enumerate(data):
        if v % 2 == 0:
            idx_even.append(i)
        else:
            idx_odd.append(i)
    odd_len = len(idx_odd)
    if odd_len in (0, 3):
        times += (max(data) - middle(data)) / 2
        times += (max(data) - min(data)) / 2
    if odd_len == 2:
        for i in idx_odd:
            data[i] += 1
        return min_times(data) + 1
    if odd_len == 1:
        for i in idx_even:
            data[i] += 1
        return min_times(data) + 1
    return times

use_data = [int(i) for i in raw_input().strip().split()]

print(min_times(use_data))

Submission status: Accepted

Solution code:
def middle(lst):
    _lst = lst
    _lst.sort()
    return _lst[-2]

def min_times(lst):
    data = lst
    times = 0
    idx_even = []
    idx_odd = []
    for i, v in enumerate(data):
        if v % 2 == 0:
            idx_even.append(i)
        else:
            idx_odd.append(i)
    odd_len = len(idx_odd)
    if odd_len in (0, 3):
        times += (max(data) - middle(data)) / 2
        times += (max(data) - min(data)) / 2
    if odd_len == 2:
        for i in idx_odd:
            data[i] += 1
        return min_times(data) + 1
    if odd_len == 1:
        for i in idx_even:
            data[i] += 1
        return min_times(data) + 1
    return times

use_data = [int(i) for i in raw_input().split()]

print(min_times(use_data))

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split(" "))
sumABC = sum([A, B, C])
maxABC = max([A, B, C])

if maxABC%2 == sumABC%2:
    print((maxABC*3 - sumABC) // 2)
else:
    print((maxABC*3 + 3 - sumABC) // 2)

Submission status: Accepted

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

if (A%2 == B%2) and (B%2 == C%2):
    pass
else:
    if A%2 == B%2:
        A += 1
        B += 1
        cnt += 1
    elif A%2 == C%2:
        A += 1
        C += 1
        cnt += 1
    else:
        B += 1
        C += 1
        cnt += 1

ABC = sorted([A, B, C])
cnt += (ABC[2] - ABC[1]) // 2
cnt += (ABC[2] - ABC[0]) // 2
print(cnt)

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
def check(num):
    if num%2:
        return 1
    else:
        return 0

if __name__ == "__main__":
    factors = list(map(int, input().split()))
    maximum = max(factors)
    if check(maximum*3) != check(sum(factors)):
        maximum += 1
    else:
        pass
    print(int(((maximum*3)-sum(factors))/2))

Submission status: Accepted

Solution code:
l = map(int, raw_input().split())
a,b,c=sorted(l)
sum_of_sub=2*c-a-b
ret=(sum_of_sub+3*(sum_of_sub%2))/2
print ret

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding=utf-8

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

counter = 0

while not abc[0] == abc[1] == abc[2]:
    abc = sorted(abc)
    
    if abc[1] == abc[2]:
        abc[0] += 2
        counter += 1
    else:
        abc[0] += 1
        abc[1] += 1
        counter += 1

print(counter)

Submission status: Accepted

Solution code:
def arc094C():
    abc = input().split()
    abc = list(map(int, abc))
    abc.sort()

    count = 0
    count += abc[2] - abc[1]
    tmp = abc[2] - (abc[0] + count)
    count += [tmp // 2 + 2, tmp // 2][tmp % 2 == 0]

    print(count)


arc094C()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)

debug_mode = True if len(sys.argv) > 1 and sys.argv[1] == "-d" else False
if debug_mode:
    import os
    infile = open(os.path.basename(__file__).replace(".py", ".in"))

    def input():
        return infile.readline()


# ==============================================================


def main():
    a, b, c = list(map(int, input().strip().split()))
    s = sum((a, b, c))
    x = max(a, b, c)
    steps = 0
    while True:
        if s + steps * 2 == 3 * x:
            break
        elif s + steps * 2 < 3 * x:
            steps += 1
        elif s + steps * 2 > 3 * x:
            x += 1
    print(steps)


main()

# ==============================================================

if debug_mode:
    infile.close()

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
li = list(map(int,raw_input().split()))
count = 0
while True:
    if li[0]==li[1] and li[1]==li[2]:
        break
    else:
        count += 1
        li.sort()
        if li[0] == li[1]:
            li[0]+=1
            li[1]+=1
        else:
            li[0]+=2
print count

Submission status: Accepted

Solution code:
data = sorted(list(map(int, input().split(' '))))
is_even = data[2] % 2

n = ((data[2] - data[1]) + (data[2] - data[0])) // 2
if data[1] % 2 != data[0] % 2:
    n += 2

print(int(n))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C = sorted(map(int, raw_input().split()))
ans = C - B
A += C - B
if (C - A) % 2 == 1:
    C += 1
    ans += 1
ans += (C - A) / 2
print ans

Submission status: Accepted

Solution code:
a, b, c = sorted(map(int, input().split()))
a = c-a; b = c-b
p = a%2; q = b%2
if p and q:
    print(a//2+b//2+1)
elif p or q:
    print(a//2+b//2+2)
else:
    print(a//2+b//2)

Submission status: Accepted

Solution code:
n = sorted(list(map(int, input().split())))
n21 = n[2] - n[1]
n20 = n[2] - n[0]
print((n21 + n20) // 2 if (n21 + n20) % 2 == 0 else (n21 + n20) // 2 + 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c = sorted(map(int, raw_input().split()))
count = 0
 
if (c-a)%2==(c-b)%2==0:
    count = (c-a+c-b)/2
elif (c-a)%2 and (c-b)%2:
    c-=1
    count = (c-a+c-b)/2 + 1
else:
    count = (c-a + c-b + 1)/2 + 1
 
print count

Submission status: Accepted

Solution code:
a,b,c = sorted(map(int, raw_input().split()))
count = 0

if (c-a)%2 and (c-b)%2:
    c-=1
    count = (c-a+c-b)/2 + 1
elif (c-a)%2==(c-b)%2==0:
    count = (c-a+c-b)/2
else:
    count = (c-a + c-b + 1)/2 + 1

print count

Submission status: Accepted

Solution code:
def evenEven(d1, d2):
    return d1//2 + d2//2

# tmpInput = "2 6 3\n"
# inDatas = tmpInput.strip('\n').split(' ')
inDatas = input().strip('\n').split(' ')

inDatas = list(map(int, inDatas))
inDatas.sort()
A = inDatas[0]
B = inDatas[1]
C = inDatas[2]

diff1 = C - A
diff2 = C - B

if not diff1%2 and not diff2%2:
    print(evenEven(diff1, diff2))
elif (diff1%2 and not diff2%2) or (not diff1%2 and diff2%2):
    print(2+evenEven(diff1, diff2))
else:
    print(1+evenEven(diff1, diff2))

Submission status: Accepted

Solution code:
def solve(A, B, C):
    A, B, C = sorted([A, B, C])
    # print(A, B, C)
    r = 0
    while A <= C - 2:
        A += 2
        r += 1
    while B <= C - 2:
        B += 2
        r += 1
    A, B, C = sorted([A, B, C])
    A, B, C = A - A, B - A, C - A
    # print(A, B, C, r)
    if (A, B, C) == (0, 0, 0):
        r += 0
    elif (A, B, C) == (0, 0, 1):
        r += 1
    elif (A, B, C) == (0, 0, 2):
        r += 2
    elif (A, B, C) == (0, 1, 1):
        r += 2
    elif (A, B, C) == (0, 1, 2):
        r += 3
    elif (A, B, C) == (0, 2, 2):
        r += 1
    return r

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

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
m = max(A, B, C)
x = 3 * m - (A + B + C)
if x % 2 == 1:
    x += 3
print(x // 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:
a = list(map(int, input().split()))
ans = 0
even = [i % 2 for i in a]
if not(even[0] == even[1] == even[2]):
    ans += 1
    if even[0] == even[1]:
        a[0] += 1
        a[1] += 1
    elif even[1] == even[2]:
        a[1] += 1
        a[2] += 1
    elif even[2] == even[0]:
        a[2] += 1
        a[0] += 1

ans += (max(a) * 3 - sum(a)) // 2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

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

list.sort(reverse=True)

Even=['Odd','Odd','Odd']

m,n=0,0

for i in range(len(list)):
    if list[i]%2==0:
        Even[i]='Even'

if Even[0]==Even[1] and Even[0]==Even[2]:
    m=0
    n=(2*list[0]-list[1]-list[2])/2

elif Even[0]!=Even[1] and Even[0]!=Even[2]:
    m=list[0]-list[1]
    n=(list[1]-list[2])/2
else:
    m=1
    n=(2*list[0]-list[1]-list[2]+1)/2

print(int(m+n))

Submission status: Accepted

Solution code:
#-*- coding:utf-8 -*-
from heapq import heappush, heappop
func1 = lambda A,B,C: [(A+1,B+1,C),(A,B+1,C+1),(A+1,B,C+1)]
func2 = lambda A,B,C: [(A+2,B,C),(A,B+2,C),(A,B,C+2)]
def cost_func(A,B,C):
	return abs(A-B)+abs(A-C)+abs(B-C)
def makeNode(alphabets,count):
	A,B,C = alphabets
	return cost_func(A,B,C),A,B,C,count+1

A,B,C = [int(n) for n in input().split()]
first_cost = cost_func(A,B,C)
nodes = [(first_cost,A,B,C,0)]
check = set()
check.add((A,B,C))
while len(nodes)!=0:
	cost,A,B,C,count = heappop(nodes)
	if cost == 0:
		print(count)
		break
	for alphabets in func1(A,B,C) + func2(A,B,C):
		A,B,C = alphabets
		cost = cost_func(A,B,C)
		if alphabets not in check:
			check.add(alphabets)
			heappush(nodes,(cost,A,B,C,count+1))

Submission status: Accepted

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

is_even = []
max_num = 0
max_num_idx = 0
for i, a_i in enumerate(a):
    if a_i % 2 == 0:
        is_even.append(i)
    if max_num < a_i:
        max_num = a_i
        max_num_idx = i

count = 0
offset = 0
if len(is_even) == 0 or len(is_even) == 3:
    for i, a_i in enumerate(a):
        if i == max_num_idx:
            continue
        offset += (max_num - a_i)
    count += offset // 2
    print(count)
elif len(is_even) == 1:
    if max_num_idx not in is_even:
        max_num += 1
        count += 1
        offset -= 1
    for i, a_i in enumerate(a):
        if i == max_num_idx:
            continue
        offset += (max_num - a_i)
    count += offset // 2
    print(count)
else:
    if max_num_idx in is_even:
        max_num += 1
        count += 1
        offset -= 1
    for i, a_i in enumerate(a):
        if i == max_num_idx:
            continue
        offset += (max_num - a_i)
    count += offset // 2
    print(count)

Submission status: Accepted

Solution code:
li1 = [int(x) for x in input().split()]
m1 = min(li1)
li1.remove(m1)
m2 = min(li1)
li1.remove(m2)
m3 = min(li1)
if (m2 -m1) % 2 == 0:
    print(int((m2 - m1)/2 + (m3 - m2)))
else:
    print(int((m2 - m1)//2 +(m3 -m2) + 2))

Submission status: Accepted

Solution code:
from sys import stdin 
a = map(int,stdin.readline().split())
ans = 0 
while True:
    b = set(a)
    if len(b)==1:
        break 
    a.sort()
    c = []
    if a[0]==a[1]:
        c = [a[0]+1,a[1]+1,a[2]]
    else:
        c = [a[0]+2,a[1],a[2]]
    ans+= 1 
    a = list(c)
print ans

Submission status: Accepted

Solution code:
import collections

visited = set()


def is_goal(nums):
    A, B, C = nums
    return A == B == C


def bfs(nums):
    q = collections.deque()
    visited.add(nums)
    q.append(nums + (0,))

    if is_goal(nums):
        return 0

    while len(q) != 0:
        n = q.popleft()

        if is_goal(n[:3]):
            return n[3]

        for i in range(3):
            new_n = list(n[:])
            for j in range(3):
                if i != j:
                    new_n[j] += 1
            new_n[3] += 1
            new_n = tuple(new_n)
            if new_n[:3] not in visited:
                visited.add(new_n[:3])
                q.append(new_n)

        for i in range(3):
            new_n = list(n[:])
            new_n[i] += 2
            new_n[3] += 1
            new_n = tuple(new_n)
            if new_n[:3] not in visited:
                visited.add(new_n[:3])
                q.append(new_n)

    return -1


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

print(bfs((A, B, C)))

Submission status: Accepted

Solution code:
a, b, c = sorted(map(int, input().split()))
x = (c-a)//2
a += x*2
y = (c-b)//2
b += y*2
a, b, c = sorted([a, b, c])
r = x + y
if a == b == c:
    print(r)
elif b == a+1 and b == c:
    print(r+2)
else:
    print(r+1)

Submission status: Accepted

Solution code:
num = [int(x) for x in input().split()]
num.sort()
cnt = 0
while True:
    if num[0] == num[1] and num[1] == num[2]:
        break
    cnt += 1
    if num[1] == num[2]:
        if num[0] < num[1]:
            num[0] += 2
        else:
            num[1] += 1
            num[2] += 1
    else:
        num[0] += 1
        num[1] += 1
print(cnt)

Submission status: Accepted

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

a = sorted([A, B, C])
s = 0

for i in range(0, 2):
    tmp = a[2] - a[i]
    
    s += tmp // 2
    a[i] += tmp // 2 * 2

s += sum(a) % 3

print(s)

Submission status: Accepted

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

abc.sort()

a, b, c = abc
ans = c - b
ans += ((c - (a + ans)) // 2) + ((c - (a + ans)) % 2) * 2

print(ans)

Submission status: Accepted

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

mx = max(nums)
ct = 0

ct = sum([(mx - n) // 2 for n in nums])
amari = sum([(mx-n) % 2 for n in nums])
if amari == 1:
  ct += 2
elif amari == 2:
  ct += 1

print(ct)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
a, b, c = map(int, input().split())
answer = 0
while not (a == b == c):
    a, b, c = sorted([ a, b, c ])
    if a + 2 <= c:
        a += 2
    else:
        a += 1
        b += 1
    answer += 1
print(answer)

Submission status: Accepted

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

lst.sort()

mini = lst[0]
av = lst[1]
max = lst[2]

d = max - av
ans1 = 0
mini += d
d2 = max - mini

if d2 % 2:
    d2 = (d2 + 1) // 2
    ans1 += 1

else:
    d2 = d2 // 2

ans1 += d + d2

ans2 = 0
mini = lst[0]
av = lst[1]
max = lst[2]

d = max - av

mini += d

d2 = max + 1 - mini

if d2 % 2:
    d2 = (d2 + 1) // 2
    ans2 += 1
else:
    d2 = d2 // 2

ans2 += d + d2 + 1

print(min(ans1, ans2))

Submission status: Accepted

Solution code:
a=[int(i) for i in input().split()]

a.sort()

if a[0]%2==0 and  a[1]%2==0 and  a[2]%2==0:
    print(int((3*max(a)-sum(a))/2))  
elif a[0]%2==1 and  a[1]%2==1 and  a[2]%2==1:
    print(int((3*max(a)-sum(a))/2))  

else:
    count=0
    for i in range(3):
        if a[i]%2==0:
            count+=1

    if count==2:
        for i in range(3):
            if a[i]%2==0:
                a[i]=a[i]+1
        print(int((3*max(a)-sum(a))/2)+1)  
        
    if count==1:
        for i in range(3):
            if a[i]%2==1:
                a[i]=a[i]+1
        print(int((3*max(a)-sum(a))/2)+1)

Submission status: Accepted

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

ans = 0
while True:
    ABC.sort()
    diff = ABC[2] - ABC[0]
    if diff >= 2:
        ABC[0] += 2
    elif diff == 1:
        ABC[2] -= 1
    else:
        break
    ans += 1

print(ans)

Submission status: Accepted

Solution code:
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

vals = reads()

ls = sorted((v & 1, v) for v in vals)

if ls[0][0] == ls[2][0]:
  vals = [v for (_, v) in ls]
  M = max(vals)
  ans = sum((M - v) // 2 for v in vals)
  print(ans)
else:
  if ls[0][0] != ls[1][0]:
    (ls[0], ls[2]) = (ls[2], ls[0])
  vals = [v for (_, v) in ls]
  # parity differs in vals[2]
  vals[2] -= 1
  M = max(vals)
  ans = sum((M - v) // 2 for v in vals)
  print(ans + 1)

Submission status: Accepted

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

def main():
    x = sorted(list(map(int, input().split())))
    count = 0

    while True:
        if x[0] == x[1] == x[2]:
            break
        elif x[2] > x[1] and x[2] > x[0]:
            x[1] += 1
            x[0] += 1
        else:
            x[0] += 2
        x = sorted(x)
        count += 1

    print(count)

if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
def solve():
    A, B, C = list(map(int, input().split()))
    ans = 0
    if A%2 == B%2 and A%2 != C%2:
        A += 1
        B += 1
        ans += 1
    elif A%2 == C%2 and A%2 != B%2:
        A += 1
        C += 1
        ans += 1
    elif B%2 == C%2 and A%2 != B%2:
        B += 1
        C += 1
        ans += 1
    max_val = max(A, B, C)
    ans += abs(max_val-A)//2 + abs(max_val-B)//2 + abs(max_val-C)//2
    print(ans)
    
    
solve()

Submission status: Accepted

Solution code:
import numpy as np
num = np.array(map(int,raw_input().split()))

num = np.sort(num)

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

else:
    print (num[1] - num[0]) / 2 + num[2] - num[1] + 2

Submission status: Accepted

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

    L = [A, B, C]
    L.sort()
    c = 0

    while L[0] != L[1] or L[0] != L[2]:
        if L[1] < L[2]:
            L[0] += 1
            L[1] += 1
        elif L[0] < L[2]:
            L[0] += 2
        elif L[0] > L[1]:
            L[1] += 1
            L[2] += 1
        c += 1

    return c


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c= map(int, input().split())
ans = 0
def calc(a, b):
    if a < b:
        r = b-a
        if r % 2:
            return r//2 + 2
        return r//2
    else:
        return a-b
def solve(a, b, c):
    return calc(a, c) + calc(b, c)
print(min(solve(a, b, c), solve(b, c, a), solve(c, a, b)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ABC = [int(i) for i in input().split()]
ABC.sort()
ans = ABC[2] - ABC[1]
ans += (ABC[2] - (ABC[0] + ans)) // 2 + 2 * ((ABC[2] - (ABC[0] + ans)) % 2)
print(ans)

Submission status: Accepted

Solution code:
a=[int(i) for i in input().split()]
a.sort(reverse=True)

n1=a[0]-a[1]
n2=a[0]-a[2]
n0=a[1]-a[2]
if (n1 + n2) % 2 ==0:
  print(int((n1+n2)/2))
else:
  print(int((n1+n2+1)/2+1))

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
m = max([a, b, c])
x = [m - i for i in [a, b, c]]
x.sort(reverse=True)
d = x[0] + x[1]
if d % 2 == 0:
    print(d // 2)
else:
    print((d + 1) // 2 + 1)

Submission status: Accepted

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


import collections

INF = 10 ** 8


def solve_by_bfs(abc0):
    dist = collections.defaultdict(lambda: INF)
    dist[abc0] = 0
    q = collections.deque()
    q.append(abc0)
    while q:
        abc1 = q.popleft()
        if abc1[0] == abc1[1] == abc1[2]:
            return dist[abc1]
        a, b, c = abc1
        cands = [(a + 1, b + 1, c),
                 (a, b + 1, c + 1),
                 (a + 1, b, c + 1),
                 (a + 2, b, c),
                 (a, b + 2, c),
                 (a, b, c + 2)]
        for abc in cands:
            if dist[abc] >= INF:
                dist[abc] = dist[abc1] + 1
                q.append(abc)


def main():
    abc0 = tuple(int(x) for x in input().split())
    res = solve_by_bfs(abc0)
    print(res)


if __name__ == '__main__':
    main()

Submission status: Accepted

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


s = 0
e, o = 0, 0
if A % 2 == 0:
    e += 1
else:
    o += 1

if B % 2 == 0:
    e += 1
else:
    o += 1

if C % 2 == 0:
    e += 1
else:
    o += 1

if (e, o) == (2, 1):
    s += 1
    if A % 2 == 0:
        A += 1
    if B % 2 == 0:
        B += 1
    if C % 2 == 0:
        C += 1
if (e, o) == (1, 2):
    s += 1
    if A % 2 != 0:
        A += 1
    if B % 2 != 0:
        B += 1
    if C % 2 != 0:
        C += 1

m = max((A, B, C))
print(int(s + ((m - A) + (m - B) + (m - C)) / 2))

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
M = max(A, B, C)
cnt = 0
dev_result = 0
for i in [A, B, C]:
    cnt += (M - i) // 2
    if (M - i) % 2 == 1:
        dev_result += 1
if dev_result == 1:
    print(cnt + 2)
elif dev_result == 2:
    print(cnt + 1)
else:
    print(cnt)

Submission status: Accepted

Solution code:
a = []
a = list(map(int,input().split(' ')))
a.sort()
#print(a)
num = 0
diff1 =0
diff2 =0
if a[2] > a[1]:
    diff1 = a[2]-a[1]

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

print(diff1+diff2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# encoding:utf-8

import itertools as it

def main(values):
	values.sort()
	
	i = 0
	while True:
		if values[1] == values[2]:
			break
		values[0] += 1
		values[1] += 1
		i += 1

	while True:
		if values[0] == values[2]:
			break
		elif values[0] > values[2]:
			i += 1
			break
		values[0] += 2
		i += 1

	print(i)

if __name__ == '__main__':
	values = list(map(int, input().split()))
	main(values)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
x=i2()
x.sort()
c=0
c+=x[2]-x[1]
if (x[2]-x[0]-c)%2==0:
   print(c+(x[2]-x[0]-c)//2)
else:
   print(c+(x[2]-x[0]-c)//2+2)

Submission status: Accepted

Solution code:
l = sorted(list(map(int,input().split())))
C,B,A = l[0],l[1],l[2]
cnt = 0
while A != B or B != C or C != A:
	if A == B:
		if C < A:
			C += 2
			cnt += 1
		elif C > A:
			A += 1
			B += 1
			cnt += 1
	else:
		B += 1
		C += 1
		cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
A,B,C = sorted(map(int, raw_input().split()))
ans = (B-A)/2
A += (B-A)/2*2
if A<B:
  ans += 1
  A += 1
  C += 1
ans += C-A
print ans

Submission status: Accepted

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

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

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