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:
l=list(map(int,input().split()))
l.sort()
a,b,c=l[0],l[1],l[2]
if (c-a)%2==1 and (c-b)%2==1:
  print(1+(2*c-2-a-b)//2)
elif (c-a)%2==0 and (c-b)%2==0:
  print((2*c-a-b)//2)
else:
  print(1+(2*c+1-a-b)//2)

Submission status: Accepted

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

desc = sorted([a,b,c], reverse=True)
d1, m1 = divmod(desc[0] - desc[1], 2)
d2, m2 = divmod(desc[0] - desc[2], 2)

ans = d1 + d2
if m1 + m2 == 2:
  ans += 1
elif m1 + m2 == 1:
  ans += 2

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

l = list(map(int,input().split()))
l.sort()
a = l[0]
b = l[1]
c = l[2]

s = c - a
t = c - b

if s % 2 == t % 2:
    ans = (s + t) // 2
else:
    ans = (s + 1 + t + 1 + 1) // 2

print(ans)

Submission status: Accepted

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

s_m=l[1]-l[0]
m_l=l[2]-l[1]

if s_m%2==0:
    print(s_m//2+m_l)
else:
    print((s_m-1)//2+m_l+2)

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
count = 0
while True:
    a.sort(reverse=True)
    max_elem_count = a.count(max(a))
    if max_elem_count == len(a):
        break
    elif max_elem_count == 2:
        a[2] += 2
    elif max_elem_count == 1:
        a[1] += 1
        a[2] += 1
    count += 1
print(count)

Submission status: Accepted

Solution code:
l=list(map(int,input().split()))
l.sort()
a=l[0]
b=l[1]
c=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 and b!=c:
  print(ans+1)
else:
  print(ans+2)

Submission status: Accepted

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

l.sort()

count = 0
while l[2] - l[0] > 1:
    l[0] += 2
    count += 1
    l.sort()

if l[2] == l[1] != l[0]:
    count += 2
elif l[0] == l[1] != l[2]:
    count += 1

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

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


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

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

Submission status: Accepted

Solution code:
A = list(map(int,input().split()))
A.sort()
B = []
for i in A:
    B.append(i%2)

ans = 0

if B.count(1) == 1:
    for i in range(3):
        if B[i] == 0:
            A[i] += 1
    ans += 1
elif B.count(0) == 1:
    for i in range(3):
        if B[i] == 1:
            A[i] += 1
    ans += 1

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

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def biggest_idx(abc):
    res = -1
    for i, v in enumerate(abc):
        if i == 0 or v > abc[res]:
            res = i
    return res
def smallest_idx(abc):
    res = -1
    for i, v in enumerate(abc):
        if i == 0 or v < abc[res]:
            res = i
    return res

abc = list(map(int, input().split(' ')))
ans = 0
while abc[0] != abc[1] or abc[1] != abc[2]:
    is_mid = [1, 1, 1]
    biggest = biggest_idx(abc)
    is_mid[biggest] = 0
    smallest = smallest_idx(abc)
    is_mid[smallest] = 0
    if abc[biggest] - abc[smallest] >= 2:
        abc[smallest] += 2
        ans += 1
        continue
    mid = is_mid.index(1)
    if abc[biggest] - abc[smallest] == 1 and abc[biggest] == abc[mid]:
        abc[biggest] += 1
        abc[mid] += 1
        ans += 1
        continue
    if abc[biggest] - abc[smallest] == 1 and abc[mid] == abc[smallest]:
        abc[mid] += 1
        abc[smallest] += 1
        ans += 1
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

t.sort()

if (t[2]*2-t[1]-t[0])%2==0:
    print((t[2]*2-t[1]-t[0])//2)
else:
    print((3+t[2]*2-t[1]-t[0])//2)

Submission status: Accepted

Solution code:
A = list(map(int,input().split()))
A.sort()
ret = 0
ret += A[2]-A[1]
A[1] += ret
A[0] += ret
while A[0] < A[1]:
  ret += 1
  A[0] += 2
if A[0] > A[1]:
  ret += 1
print(ret)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C = list(map(int, input().split()))
H = [A, B, C]
S = [A%2, B%2, C%2]

def kouhan(l):
  ans = (3 * max(l) - sum(l)) //2
  return ans

if S == [0,0,0] or S == [1,1,1]:
  count = kouhan(H)
  
elif S.count(1) == 2:
  for i in range(3):
    if H[i]%2 == 1:
      H[i] += 1
  count = 1
  count += kouhan(H)
  
elif S.count(1) == 1:
  for i in range(3):
    if H[i]%2 == 0:
      H[i] += 1
  count = 1
  count += kouhan(H)


print(count)

Submission status: Accepted

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

Submission status: Accepted

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

n1=abc[2]-abc[0]
n2=abc[2]-abc[1]

if (n1-n2)%2==0:
    print((n1-n2)//2+n2)
else:
    print((n1-n2+1)//2+n2+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#093_C
a,b,c=sorted(map(int,input().split()))
x,y=b-a,c-a
print(y-x//2+(x%2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
C, B, A = sorted([int(i) for i in input().split()])
ans = (A-B)//2+(A-C)//2
if (A-B) & 1 and (A-C) & 1:
    ans += 1
elif (A-B) & 1 or (A-C) & 1:
    ans += 2
print(ans)

Submission status: Accepted

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

a, b, c = sorted([a, b, c])

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

Submission status: Accepted

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

while True:
    if (3*i-A-B-C)%2==0:
        print((3*i-A-B-C)//2)
        break
    else:
        i=i+1

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(x):
    print(x,file=sys.stderr)
def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())


"""
"""

#solution:

#input
def resolve():
    A=sorted(list(pin()))
    B=[a%2 for a in A]
    ans=0
    odd=[]
    even=[]
    for i in range(len(B)):
        if B[i]==0:odd.append(i)
        else:even.append(i)
    if len(odd)==1:
        for x in even:
            A[x]+=1
        ans+=1
    elif len(even)==1:
        for y in odd:
            A[y]+=1
        ans+=1
    ans+=(A[2]*2-A[1]-A[0])//2
    print(ans)
    return 0
    #print(["No","Yes"][cond])
    #print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])
#if __name__=="__main__":resolve()
"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2 5 4"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """2 6 3"""
        output = """5"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """31 41 5"""
        output = """23"""
        self.assertIO(input, output)

if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

while(True):
    abc = sorted(abc, reverse=True)

    if abc[0] == abc[1] == abc[2]:
        break
    elif abc[1] == abc[2]:
        abc[1] += 1
        abc[2] += 1
    else:
        abc[2] += 2
    count += 1
print(count)

Submission status: Accepted

Solution code:
arr = input("")
num = [int(n) for n in arr.split()]
num.sort()
ans = (num[2]-num[0])//2 + (num[2]-num[1])//2
num[0] = (num[2]-num[0])//2*2+num[0]
num[1] = (num[2]-num[1])//2*2+num[1]


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
a=list(map(int,input().split()))
a.sort()
cnt=0
if a[0]==a[1]==a[2]:
  print(0)
  exit()
if a[0]==[1]:
  print(a[2]-a[1])
  exit()
if a[1]==a[2]:
  if (a[2]-a[0])%2==0:
    print(math.ceil((a[2]-a[0])/2))
    exit()
  else:
    print(math.ceil((a[2]-a[0])/2+1))
    exit()
cnt+=a[2]-a[1]
a[0]+=cnt
if (a[2]-a[0])%2==0:
  cnt+=math.ceil((a[2]-a[0])/2)
else:
  cnt+=math.ceil((a[2]-a[0])/2+1)
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L = sorted(list(map(int, input().split())),reverse=True)

x = L[0]-L[1]
y = L[0]-L[2]
count = 0

while x!= 0 or y != 0:
    if (x+y)%2 == 1:
        y += 1
        count += 1
    if x%2 == 0 and x>0:
        x -= 2
        count += 1
    elif y%2 == 0 and y>0:
        y -= 2
        count += 1
    elif x%2 == 1 and y%2 == 1:
        x -= 1
        y -= 1
        count += 1
    else:
        break
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l=list(map(int,input().split()));k=max(l)*3-sum(l);print(k//2+k%2*2)

Submission status: Accepted

Solution code:
l=list(map(int,input().split()))
k=max(l)*3-sum(l)
print(k//2+2*(k%2))

Submission status: Accepted

Solution code:
l=sorted(map(int,input().split()))
d1=l[2]-l[0]
d2=l[2]-l[1]
if d1%2==0 and d2%2==0:
    print(d1//2 + d2//2)
elif d1%2==0 or d2%2==0:
    print(d1//2 + d2//2 + 2)
else:
    print(d1//2 + d2//2 + 1)

Submission status: Accepted

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

count = 0
while(True):
  if arr[1] < arr[2]:
    arr[1]+= 1
    arr[0]+=1
    count+=1
  else:
    break
    
while(True):
  if arr[0] < arr[2]:
    arr[0] +=2
    count+=1
  else:
    break
    
if arr[0] == arr[1] == arr[2]:
  print(count)
else:
  print(count+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections
a,b,c = map(int,input().split())
lists = [str(a%2),str(b%2),str(c%2)]
abc = [a,b,c]
an = []
if len(set(lists)) != 1:

    d = collections.Counter(lists)
    jud = int(d.most_common()[0][0])
    for i in range(3):
        if jud == int(lists[i]):
            an.append(i)
    for i in an:
            abc[i] += 1
    cnt = 1
else:
    cnt = 0

while 1:
    Max = max(abc)
    count = 0
    for i in range(3):
        if Max == abc[i]:
            count += 1
    if count == 1:
        cnt += 1
        for i in range(3):
            if Max != abc[i]:
                abc[i] += 1

    elif count == 2:
        cnt += abs(max(abc) - min(abc)) // 2
        abc.sort()
        abc[0] += abs(max(abc) - min(abc))
    elif count == 3:
        break

print(cnt)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def main():
    nums = sorted(map(int, input().split()))
    plus1 = nums[2] - nums[1]
    if (nums[2] - nums[0] - plus1) % 2 == 0:
        print(int(plus1 + (nums[2] - nums[0] - plus1) / 2))
    else:
        print(int(plus1 + ((nums[2] - nums[0] - plus1) + 1) / 2 + 1))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

L = [A, B, C]
L.sort(reverse = True)

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

print(ans)

Submission status: Accepted

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

odds = list(filter(lambda x: x % 2 == 1, abc))
ans = 0
if len(odds) == 1:
    for i in range(len(abc)):
        if abc[i] % 2 == 0:
            abc[i] += 1
    ans = 1
elif len(odds) == 2:
    for i in range(len(abc)):
        if abc[i] % 2 == 1:
            abc[i] += 1
    ans = 1

abc.sort()
print((abc[2] * 2 - abc[0] - abc[1]) // 2 + ans)

Submission status: Accepted

Solution code:
import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A = [int(x) for x in readline().split()]
s = max(A) * 3 - sum(A)
print(s // 2 if s % 2 == 0 else (s + 3) // 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
abc = sorted([a, b, c])
even = 0
for i in abc:
    if i % 2 == 0:
        even += 1
ans = 0
if even == 0 or even == 3:
    ans = (abc[2] - abc[0]) // 2 + (abc[2] - abc[1]) // 2
elif even == 1:
    abc = [i + 1 if i % 2 == 1 else i for i in abc]
    ans = (abc[2] - abc[0]) // 2 + (abc[2] - abc[1]) // 2 + 1
else:
    abc = [i + 1 if i % 2 == 0 else i for i in abc]
    ans = (abc[2] - abc[0]) // 2 + (abc[2] - abc[1]) // 2 + 1

print(ans)

Submission status: Accepted

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


def plus1(num_list :list) ->(list,int):
    num_list.sort()
    count = 0
    
    diff_1 = num_list[2] - num_list[1]
    count += diff_1
    num_list[0]+= diff_1
    num_list[1]+= diff_1
    
    return num_list,count

#----------
num_list = list(map(int, input().rstrip().split()))

# count up +1
num_list,count = plus1(num_list)

# count up +2
num_2times = (num_list[1] - num_list[0]) // 2
num_list[0] += num_2times *2
count += num_2times

# count up +2 and +1
if (num_list[1] - num_list[0]) % 2 != 0:
    num_list[0] += 2
    count += 1
    
    num_list,c = plus1(num_list)
    count += c
    
print(count)

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
x=[a,b,c]
cnt=0
if a%2==0 and b%2==0 and c%2==1:
    a+=1
    b+=1
    cnt+=1
elif a%2==0 and b%2==1 and c%2==0:
    a+=1
    c+=1
    cnt+=1
elif a%2==1 and b%2==0 and c%2==0:
    b+=1
    c+=1
    cnt+=1
elif a%2==1 and b%2==0 and c%2==1:
    a+=1
    c+=1
    cnt+=1
elif a%2==1 and b%2==1 and c%2==0:
    a+=1
    b+=1
    cnt+=1
elif a%2==0 and b%2==1 and c%2==1:
    b+=1
    c+=1
    cnt+=1
x=[a,b,c]
print(cnt+(3*max(x)-sum(x))//2)

Submission status: Accepted

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

cnt = 0
while a <= b-2:
    a += 2
    cnt += 1

while a <= c-1 or b <= c-1:
    a += 1
    b += 1
    cnt += 1

if a == b == c:
    print(cnt)
else:
    print(cnt + 1)

Submission status: Accepted

Solution code:
lis=sorted(list(map(int,input().split())))
lis.sort(reverse=True)
if (lis[1]-lis[2])%2==0:#偶数
    print(((lis[0]-lis[1])+(lis[0]-lis[2]))//2)
else:#奇数
    print(((lis[0]-lis[1])+(lis[0]-lis[2])+3)//2)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#最終上体がわかれば回数fin*3 - (a+b+c) //2
a =list(map(int,input().split()))
a.sort()
# maxがfinにならないのは、a[0]-1[1]が奇数の時
if (a[1] -a[0])%2 == 0:
    print((a[-1]*3-sum(a))//2)
else:
    print((a[-1]*3+3-sum(a))//2)
"""
x = a[-1]-a[1]
y = a[1] -a[0]
def dist(n):
    if n % 2 == 0: return n//2
    else: return n//2+2
print(min(2*x+y,dist(y)+x,dist(x+y)+dist(x)))"""

Submission status: Accepted

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

ans = 0
while s % 3 != 0 or s < max(a) * 3:
  s += 2
  ans += 1
print(ans)

Submission status: Accepted

Solution code:
abc = sorted(list(map(int,input().split())))
x = abc[0]
y = abc[1]
z = abc[2]
cnt = (z-x)//2 + (z-y)//2
if z == 2*((z-x)//2)+x and z == 2*((z-y)//2)+y:
    print(cnt)
elif z > 2*((z-x)//2)+x and z > 2*((z-y)//2)+y:
    print(cnt + 1)
else:
    print(cnt + 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
num = []
num.append(A)
num.append(B)
num.append(C)
answer = 0
# print(num)
if (num[0] % 2 == 0 and num[1] % 2 == 0 and num[2] % 2 == 0) or (num[0] % 2 != 0 and num[1] % 2 != 0 and num[2] % 2 != 0):
    pass
elif (num[0] % 2 == 0 and num[1] % 2 == 0) or (num[0] % 2 != 0 and num[1] % 2 != 0):
    num[0] += 1
    num[1] += 1
    answer += 1
elif (num[2] % 2 == 0 and num[1] % 2 == 0) or (num[2] % 2 != 0 and num[1] % 2 != 0):
    num[2] += 1
    num[1] += 1
    answer += 1
elif (num[0] % 2 == 0 and num[2] % 2 == 0) or (num[0] % 2 != 0 and num[2] % 2 != 0):
    num[0] += 1
    num[2] += 1
    answer += 1
# print(answer)
num.sort()
# print(num)
answer += (num[2] - num[0]) // 2
answer += (num[2] - num[1]) // 2
# print(A, num[1], C)
print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

target=A[-1]
if sum(A)%2!=A[-1]%2:
    target+=1
    
print((target*3-sum(A))//2)

Submission status: Accepted

Solution code:
A,B,C = list(map(int,input().split()))
a1 = A+B+C
a2 = 3*max(A,B,C)

if a1%2==a2%2:
  print((a2-a1)//2)
else:
  print((a2-a1+3)//2)

Submission status: Accepted

Solution code:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

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

ans = (A[2]-A[1]) + (A[1]-A[0])//2 + ((A[1]-A[0])%2)*2
print(ans)

Submission status: Accepted

Solution code:
a=list(map(int,input().split()))
a=sorted(a)
maxim=a[-1]
for i in range(3):
    a[i]=a[-1]-a[i]

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

Submission status: Accepted

Solution code:
def main():
    numbers = list(map(int, input().split(" ")))
    numbers.sort()
    diff = 3 * numbers[2] - sum(numbers)
    if diff % 2:
        answer = (diff + 3) // 2
    else:
        answer = diff // 2
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

count = 0
while(True):
    if arr[1] < arr[2]:
        arr[1] += 1
        arr[0] += 1
        count += 1
    else:
        break

while(True):
    if arr[0] < arr[2]:
        arr[0] += 2
        count += 1
    else:
        break

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

Submission status: Accepted

Solution code:
l = list(map(int, input().split()))
l.sort()
C = l.pop()
if sum(l) % 2 == 0:
  print(C - sum(l)//2)
else:
  print(C - (sum(l) - 3)//2)

Submission status: Accepted

Solution code:
lst = [int(x) for x in input().split()]
lst.sort()
sum = 0
for i in lst:
    sum += i
cnt = 0
if max(lst)%2 != sum%2:
    lst[2] += 1
    lst[1] +=1
    cnt += 1
cnt += (lst[2] - lst[1] + lst[2] - lst[0]) // 2
print(cnt)

Submission status: Accepted

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

diff = (ABC[2] - ABC[1]) + (ABC[2] - ABC[0])

ans = 0
if diff % 2 == 0:
    ans = int(diff / 2)
else:
    ans = int(diff // 2 + 2)

print(ans)

Submission status: Accepted

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

A,B,C = list_[0],list_[1],list_[2]

ans = 0
while A < B:
  A += 2
  ans += 1
if B < A:
  B += 1
  C += 1
  ans += 1
while B < C:
  B += 1
  ans += 1
  
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
aa,bb,cc=a%2,b%2,c%2
def check(a,b,c):
    max_=max(a,b,c)
    ans=((max_-a)//2)+((max_-b)//2)+((max_-c)//2)
    return ans
if aa==bb==cc:
    print(check(a,b,c))
else:
    if aa==bb and aa!=cc:
        print(check(a+1,b+1,c)+1)
    elif cc==bb and aa!=cc:
        print(check(a,b+1,c+1)+1)
    else:
        print(check(a+1,b,c+1)+1)

Submission status: Accepted

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

Submission status: Accepted

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

x = 0

while A[0] < A[2] - 1:
    A[0] += 2
    x += 1

while A[1] < A[2] - 1:
    A[1] += 2
    x += 1

if A[0] == A[1] == A[2]:
    x = x

elif A[0] == A[1]:
    x = x + 1

else:
    x = x + 2

print(x)

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
minimum = min(a, b, c)
maximum = max(a, b, c)
middle = sum((a, b, c)) - (minimum + maximum)
ans = 0
tmp = minimum

while tmp <= (middle - 2):
    tmp += 2
    ans += 1

if tmp == middle:
    ans += (maximum - tmp)
else:
    maximum += 1
    ans += (maximum - tmp)
print(ans)

Submission status: Accepted

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

lmax = max(A,B,C)
l.remove(lmax)
lmin = min(l)
l.remove(lmin)
lmid = l[0]
ans = 0
#A,B,Cがすべて同じ場合
if lmax==lmid and lmid == lmin:
    print(0)
    exit()
#lmax==lmidのみ
if lmax==lmid:
    if (lmid-lmin)%2==0:
        ans += (lmid-lmin)//2
        print(ans)
        exit()
    else:
        ans += (lmid-1-lmin)//2
        ans += 2
        print(ans)
        exit()
#lmid==lminのみ
if lmid == lmin:
    ans += lmax - lmid
    print(ans)
    exit()
#A,B,Cがすべて異なる場合
if (lmid-lmin)%2 == 0:
    ans += (lmid-lmin)//2
    ans += lmax - lmid
else:
    ans += (lmid-1-lmin)//2
    ans += (lmax-lmid)
    ans += 2
print(ans)

Submission status: Accepted

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

delta = abs(ABC[2]-ABC[0])+abs(ABC[2]-ABC[1])

if delta % 2:
    print((delta+1)//2+1)
else:
    print(delta//2)

Submission status: Accepted

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

print(int(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
abc = list(map(int, input().split()))
abc.sort()
abc_min,abc_middle,abc_max = abc
step1 = abc_max - abc_middle
abc_min += step1
step2 = (abc_max - abc_min)//2
step3 = (abc_max - abc_min)%2 * 2
print(step1+step2+step3)

Submission status: Accepted

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


cnt = 0

while val[1] < val[2]:
    val[1] += 1
    val[0] += 1
    cnt += 1
while val[0] < val[2]:
    val[0] += 2
    cnt += 1
if val[0] > val[2]:
    val[1] += 1
    val[2] += 1
    cnt += 1
print(cnt)

Submission status: Accepted

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

A, B, C = sorted(ABC)

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

print(answer)

Submission status: Accepted

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

A, B, C = ABC

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

print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

num0 = [A, B, C]
max_num = max([A, B, C])
# res = 0
diff = [max_num - A, max_num - B, max_num - C]

while True:
    # div_c = 0
    # mod_c = 0
    res = 0
    for i in range(3):
        if diff[i] != 0:
            mod = diff[i] % 2
            div = int(diff[i] / 2)
            res += div
            res += mod / 2
            num0[i] += (2 * div + mod)
    # res = div_c + mod_c
    integer = int(res)

    if res - integer == 0 and num0[0] == num0[1] and num0[1] == num0[2]:
        break

    max_num += 1
    diff = [max_num - A, max_num - B, max_num - C]
    num0 = [A, B, C]

print(int(res))

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
# print(', '.join(list(map(str, [A, B, C]))))

num0 = [A, B, C]
max_num = max([A, B, C])
res = 0

diff = [max_num - A, max_num - B, max_num - C]

while True:
    div_c = 0
    mod_c = 0
    for i in range(3):
        if diff[i] != 0:
            mod = diff[i] % 2
            div = int(diff[i] / 2)
            div_c += div
            mod_c += mod / 2
            num0[i] += (2 * div + mod)
    res = div_c + mod_c
    integer = int(res)

    if res - integer == 0 and num0[0] == num0[1] and num0[1] == num0[2]:
        break

    max_num += 1
    diff = [max_num - A, max_num - B, max_num - C]
    num0 = [A, B, C]

print(int(res))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    A, B, C = sorted(map(int, input().split()))
    print((2 * C - A - B) // 2 + 2 if (2 * C - A - B) % 2 else
          (2 * C - A - B) // 2)
    return


main()

Submission status: Accepted

Solution code:
n = sorted((map(int,input().split())))
M = max(n)
print((3*M-sum(n))//2 if sum(n)%2==M*3%2 else (3*(M+1)-sum(n))//2)

Submission status: Accepted

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

odd_even = [0]*3
change_cnt = 0

for i in range(3):
    if A[i] % 2 == 0:
        odd_even[i] = 0
    else:
        odd_even[i] = 1
    
if sum(odd_even) == 1:
    change_cnt +=1
    for i in range(3):
        if odd_even[i] == 0:
            A[i] += 1
elif sum(odd_even) == 2:
    change_cnt += 1
    for i in range(3):
        if odd_even[i] == 1:
            A[i] += 1

max_val = max(A)
max_idx = A.index(max_val)

for i in range(3):
    while A[i] != max_val:
        change_cnt += 1
        A[i] += 2

print(change_cnt)

Submission status: Accepted

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