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

Submission status: Accepted

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

n.sort()

c = 0

c += n[2] - n[1]
# print(c)
if c > 0:
    n[0] += c
    n[1] += c
# print(n)
if (n[1] - n[0]) % 2 == 0:
    c += (n[1] - n[0]) // 2
else:
    c += (n[1] - n[0]) // 2 + 2
print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=list(map(int,input().split()))
o=0
e=0
ans=0
for i in range(3):
    if a[i]%2==0:
        e+=1
    else:
        o+=1
if e==2:
    ans+=1
    for i in range(3):
        if a[i]%2==0:
            a[i]+=1
elif e==1:
    ans+=1
    for i in range(3):
        if a[i]%2==1:
            a[i]+=1
a.sort()
print(ans+a[2]-a[1]+(a[1]-a[0])//2)

Submission status: Accepted

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

if A % 2 == B % 2 == C % 2:
    ans += (C - B) // 2
    ans += (C - A) // 2
    print(ans)
elif A % 2 == B % 2 != C % 2:
    A += 1
    B += 1
    ans += 1
    ans += (C - B) // 2
    ans += (C - A) // 2
    print(ans) 
elif A % 2 == C % 2 != B % 2:
    ans += (C - A) // 2
    ans += (C - B) // 2 + 1
    ans += 1
    print(ans)
elif B % 2 == C % 2 != A % 2:
    ans += (C - B) // 2
    ans += (C - A) // 2 + 1
    ans += 1
    print(ans)

Submission status: Accepted

Solution code:
import math
A = list(map(int,input().split()))
A.sort(reverse=True)
cnt1 = (A[0] - A[1]) / 2
cnt2= (A[0] - A[2]) / 2
#print(cnt1)
#print(cnt2)
d1 ,i1 = math.modf(cnt1)
d2 ,i2 = math.modf(cnt2)

if d1 + d2 == 1:
    both_increase = 1
elif d1 + d2 == 0.5:
    both_increase = 2
else:
    both_increase = 0
print(int(i1 + i2 + both_increase))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

M = max(A, B, C)

if M % 2 == (A + B + C) % 2:
    X = M
else:
    X = M + 1

ans = (3 * X - (A + B + C)) // 2
print(ans)

Submission status: Accepted

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

import numpy as np
import scipy

#N = int(input())
#C = [[0 for i in range(3)] for j in range(3)]
#for i in range(3):
#    C[i] = list(map(int, input().split()))
S = list(map(int, input().split()))
#A, B, C = map(int, input().split())

def plus1(X, Y):
    return X+1, Y+1

def plus2(Z):
    return Z+2

c = 0
S = sorted(S)

while True:
    if S[1] == S[2]:
        break
    S[0], S[1] = plus1(S[0], S[1])
    c += 1

if (S[1] - S[0])%2 != 0:
    S[1], S[2] = plus1(S[1], S[2])
    c += 1

while True:
    if S[0] == S[1]:
        break
    S[0] = plus2(S[0])
    c += 1

print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L = sorted(list(map(int, input().split())))
d = L[2]-L[1]
count = d
L[0] += d
L[1] += d
s = L[1]-L[0]
count += s//2
if s%2 == 1:
  count += 2
print(count)

Submission status: Accepted

Solution code:
nums = [int(i) for i in input().split()]
Max = max(nums)
a = Max - nums[0]
b = Max - nums[1]
c = Max - nums[2]
 
d = a + b + c
  
if d % 2 != 0 :
  a += 1
  b += 1
  c += 1
    
print( (a+b+c)//2 )

Submission status: Accepted

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

Submission status: Accepted

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

one = N[0] - N[1]
two = N[0] - N[2]

ans = 0

if one % 2 == 0 and two % 2 == 0:
    ans += one /2 + two /2
elif one % 2 == 1 and two % 2 == 1:
    ans += one //2 + two //2 + 1
else:
    ans += one //2 + two //2 + 2

print(int(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,C=map(int, input().split())
diff=max(A,B,C)*3-A-B-C

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,C=sorted(map(int,input().split()))
ab=B-A
bc=C-B
if ab%2!=0:
  bc=bc+1
  ab=ab+1
print(ab//2+bc)

Submission status: Accepted

Solution code:
A,B,C=map(int,input().split())
L=sorted([A,B,C])
ab=L[1]-L[0]
bc=L[2]-L[1]
if ab%2!=0:
  bc=bc+1
  ab=ab+1
print(ab//2+bc)

Submission status: Accepted

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



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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
a,b,c=map(int,input().split())
l=[a,b,c]
arr=np.array(l)
m=max(arr)
t=m-arr
#print(t)
s=sum(t)
if s%2==0:
  ans=s//2
else:
  ans=(s+3)//2
print(ans)

Submission status: Accepted

Solution code:
abc=list(map(int,input().split()))
count=0
while not abc[0]==abc[1]==abc[2]:
    count+=1
    abc.sort()
    if abc[0]==abc[1]:
        abc[0]+=1
        abc[1]+=1
    else:
        abc[0]+=2
    # print(*abc)
print(count)

Submission status: Accepted

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

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

ans = 0
while lis[1] != lis[2] and lis[1]+1 != lis[2]:
  lis[1] += 2
  ans += 1

while lis[0] != lis[2] and lis[0]+1 != lis[2]:
  lis[0] += 2
  ans += 1

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

Submission status: Accepted

Solution code:
v = sorted(list(map(int,input().split())))
cnt = 0
while v[0]!=v[2]:
    if v[2]-v[0]>=2:
        cnt += (v[2]-v[0])//2
        v[0]+=((v[2]-v[0])//2)*2
    elif v[2]-v[0]==1:
        v[0]+=1
        v[1]+=1
        cnt+=1
    v.sort()
print(cnt)

Submission status: Accepted

Solution code:
def examC():
    ABC = LI(); ABC.sort()
    ans = (ABC[2]*2-ABC[1]-ABC[0]+1)//2 + (ABC[2]*2-ABC[1]-ABC[0])%2
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()

Submission status: Accepted

Solution code:
import numpy as np
V=np.array(input().split(),dtype=int)

maxv=V.max()
minv=V.min()
midv=int(np.median(V))

print((maxv-midv)+(midv-minv)//2+((midv-minv)%2)*2)

Submission status: Accepted

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

while num[0] != num[1] or num[1] != num[2] or num[0] != num[2]:
    num.sort()
    if num[0] + 1 == num[2] and num[1] + 1 == num[2]:
        num[0] += 1
        num[1] += 1

    else:
        num[0] += 2

    ans += 1
print(ans)

Submission status: Accepted

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

m = max(a,b,c)
n = (m - a) + (m - b) + (m - c)

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

Submission status: Accepted

Solution code:
abc = [int(x) for x in input().split()]
abc = sorted(abc)

num = 0
while True:
#     print(abc)
    if (abc[0] == abc[1]) & (abc[1] == abc[2]):
        break

    if (abc[0] == abc[1]):
        abc[0] +=1
        abc[1] +=1
        abc = sorted(abc)
        num += 1
        continue

    if (abc[0] < abc[1]):
        abc[0] += 2
        abc =sorted(abc)
        num += 1
        continue

print(num)

Submission status: Accepted

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

Submission status: Accepted

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

odd_num = []
for i in range(len(ABC)):
    if ABC[i] % 2 != 0:
        odd_num.append(i)
        
if len(odd_num) == 0 or len(odd_num) == 3:
    count = 0
elif len(odd_num) == 1:
    for i in range(len(ABC)):
        if i not in odd_num:
            ABC[i] += 1
    count = 1
elif len(odd_num) == 2:
    for i in range(len(ABC)):
        if i in odd_num:
            ABC[i] += 1
    count = 1
    
max_ABC = max(ABC)
for i in range(len(ABC)):
    if ABC[i] != max_ABC:
        count += (max_ABC - ABC[i]) // 2

print(count)

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
# op1 : 1つを-1する
# op2 : 1つを+2する
# ソートして、なるべくop2をしてop1で最終調整が良さそう

# abcをsort
A, B, C = sorted([A, B, C])

cnt = 0
cnt += (C - A) // 2 
cnt += (C - B) // 2

# 今、A, B , C の偶奇性は保存されてる
if (B - A) % 2 == 0:
    if (C - A) % 2 != 0:
        cnt += 1
else:
    cnt += 2

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    A=list(map(int,input().split()))
    A.sort()
    a,b,c=A
    ans=0

    # a<=b=cにする
    ans+=c-b
    a+=c-b
    b=c

    # aとcの偶奇が一致するかどうか
    if((c-a)&1):
        ans+=(c-a+1)//2+1
    else:
        ans+=(c-a)//2
    print(ans)

resolve()

Submission status: Accepted

Solution code:
from sys import stdin
import math

li = list(map(int,stdin.readline().rstrip().split()))

li.sort(reverse = True)

point = 0
su = sum(li)%2
sai = li[0]%2

if sum(li) == 1:
    print(1)
    exit()

else:
    if su != sai:
        li[0] += 1
        point += 1
    point += (li[0]*2-li[1]-li[2])//2

print(point)

Submission status: Accepted

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

Submission status: Accepted

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

A = L[0]
B = L[1]
C = L[2]

dif1 = C - A
dif2 = C - B

if (dif1 + dif2) % 2 == 0:
  print(int((dif1 + dif2)/2))
  
else:
  print(((dif1 + dif2) // 2 ) + 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
key_num = list(int(x) for x in input().split())
key_num.sort()
ans = 0

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

key = key_num[2]*2 - key_num[1] - key_num[0] - ans*2
if key == 2:
    ans += 1
elif key == 1:
    ans += 2

print(ans)

Submission status: Accepted

Solution code:
a = sorted(list(map(int, input().split())))
cnt = 0
while a[1] != a[2]:
    a[0] += 1
    a[1] += 1
    cnt += 1

while a[0] < a[2]:
    a[0] += 2
    cnt += 1
if (a[2] - a[0]) % 2 == 1:
    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import numpy as np
a = [int(x) for x in input().split()]

count = 0
while True:
    if (a[0] == a[1] and a[1] == a[2]):
        break
    elif (max(a) - min(a) >= 2):
        a[np.argmin(a)] += 2
        count += 1
        #print(a)
    else:
        a = [x+1 if i != np.argmax(a) else x for i, x in enumerate(a)]
        count += 1
        #print(a)
print(count)

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
cnt=0
while a!=b or b!=c or c!=a:
    if max(a,b,c)-min(a,b,c)!=1:
        if a==min(a,b,c):
            a+=2
        elif b==min(a,b,c):
            b+=2
        else:
            c+=2
        cnt+=1
    else:
        if a==max(a,b,c):
            b+=1
            c+=1
        elif b==max(a,b,c):
            a+=1
            c+=1
        else:
            a+=1
            b+=1
        cnt+=1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a ,b, c = map(int, input().split())
m = max(a, b, c)
for i in range(100000):
        mod1 = 3*(m + i) % 2
        mod2 = (a + b + c) % 2
        if mod1 == mod2:
                print((3*(m + i) - (a + b + c))//2)
                exit()

Submission status: Accepted

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

# まず2数に1を加えて一方が最大値と同じになるように調整
count = ABC[2]-ABC[1]
count += (ABC[2]-(ABC[0]+count)+1)//2 + (ABC[2]-(ABC[0]+count))%2

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
number = list(map(int,input().split()))
count = 0
while True:
	if len(set(number)) == 1:
		break
	number.sort()
	if number[0] == number[1]:
		number[0] += 1
		number[1] += 1
		count+=1
	else:
		number[0] += 2
		count+=1

print(count)

Submission status: Accepted

Solution code:
A, B, C = sorted([int(x) for x in input().split()])
ans = 0
ans += C - B
ans += (C - (A + ans)) // 2 + (C - (A + ans)) % 2 * 2
print(ans)

Submission status: Accepted

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

# 全部奇数または偶数にする
# そこからそれぞれ2ずつ足していく
ans = 0
if a%2 == 0 and b%2 == 0 and c%2 == 0:
    pass
elif a%2 == 1 and b%2 == 1 and c%2 == 1:
    pass

elif a%2 == 0 and b%2 == 1 and c%2 == 1:
    b += 1
    c += 1
    ans += 1
elif a%2 == 1 and b%2 == 0 and c%2 == 1:
    a += 1
    c += 1
    ans += 1
elif a%2 == 1 and b%2 == 1 and c%2 == 0:
    a += 1
    b += 1
    ans += 1
elif a%2 == 0 and b%2 == 0 and c%2 == 1:
    a += 1
    b += 1
    ans += 1
elif a%2 == 0 and b%2 == 1 and c%2 == 0:
    a += 1
    c += 1
    ans += 1
elif a%2 == 1 and b%2 == 0 and c%2 == 0:
    b += 1
    c += 1
    ans += 1

while not a == b == c:
    if a == min(a, b, c):
        a += 2
        ans += 1
    
    if a == b == c:
        break

    if b == min(a, b, c):
        b += 2
        ans += 1

    if a == b == c:
        break

    if c == min(a, b, c):
        c += 2
        ans += 1

    if a == b == c:
        break
print(ans)

Submission status: Accepted

Solution code:
X = sorted(list(map(lambda x: int(x), input().split(' '))))

ans = 0

# 2番目に大きい数字を1番大きい数字と同じにする
ans += X[2] - X[1]
X[1] += ans
X[0] += ans

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
ans = 0
while True:
    if a == b and b == c:
        break
    a, b, c = sorted([a, b, c])
    if a == b:
        a += 1
        b += 1
    else:
        a += 2
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
#                         author:  kagemeka 
#                         created: 2019-11-07 02:35:07(JST)
import sys
# import collections
import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator

def main():
    *n, = (int(x) for x in sys.stdin.readline().split())
    n.sort()
    diff = n[2] * 2 - n[1] - n[0]
    print(diff // 2 if diff % 2 == 0 else math.ceil(diff / 2) + 1)
    


if __name__ == "__main__":
    # execute only if run as a script
    main()

Submission status: Accepted

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

ans = 0
while max(A, B, C) > min(A, B, C):
    A, B, C = sorted([A, B, C])
    if B == C:
        A += 2
    else:
        A += 1
        B += 1
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
A,B,C = map(int,input().split())
maxi = max(A,B,C)
mini = min(A,B,C)
mid = sum([A,B,C]) - (maxi+mini)
i,j,k,l = 0,0,0,0
if mini%2 != mid%2:
    #midだけ偶奇が違うとき
    if maxi%2 == mini%2 and maxi%2 != mid%2:
        if mid - maxi != 1:
            i = (maxi+1-mid)//2
            mid = maxi + 1
    #miniだけ偶奇が違うとき
    if maxi%2 != mini%2 and maxi%2 == mid%2:
        if mini - maxi != 1:
            j = (maxi+1-mini)//2
            mini = maxi + 1
while maxi - mini > 1:
    mini += 2
    k += 1
while maxi - mid > 1:
    mid += 2
    l += 1
if maxi == mini and maxi == mid:
    print(i+j+k+l)
else:
    print(i+j+k+l+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
da = list(map(int, input().split()))
ma = max(da)
ma *= 3
su = da[1] + da[2] + da[0]
if (ma - su) % 2:
    ma += 3
print((ma - su)//2)

Submission status: Accepted

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

Submission status: Accepted

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

if wa % 2 == maxnum % 2:
    print((3*maxnum-wa)//2)
else:
    print((3*(maxnum+1)-wa)//2)

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
res = 0
while (not (A == B == C)):
    A, B, C = sorted((A, B, C))
    if A < B <= C:
        A += 2
        res += 1
    A, B, C = sorted((A, B, C))
    if A <= B < C:
        A += 1
        B += 1
        res += 1

print(res)

Submission status: Accepted

Solution code:
abc = list(map(int, input().rstrip("\n").split()))
parities = [n % 2 for n in abc]
i = (parities.count(0) < parities.count(1))
new_abc = list()

ans = 0

if len(set(parities)) == 2:
    for num, parity in zip(abc, parities):
        if parity == i:
            num += 1
        new_abc.append(num)
    ans += 1
else:
    new_abc = abc

max_ = max(new_abc)
new_abc.remove(max_)

for num in new_abc:
    ans += (max_ - num) // 2

print(ans)

Submission status: Accepted

Solution code:
import math
l = sorted([int(i) for i in input().split()])
x =  (2*l[2] - l[1]-l[0])
if x%2 == 0:
    print(x//2)
else:
    print(math.ceil(x/2) + 1)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
if (a[0] - a[2]) % 2 == 0:
    ans += (a[0] - a[2]) // 2
    if (a[0] - a[1]) % 2 == 0:
        ans += (a[0] - a[1]) // 2
    else: # 6 3 2
        a[0] += 1
        a[2] += 1
        ans += 1 # 7 3 3
        ans += (a[0] - a[1]) // 2
else:
    if (a[0] - a[1]) % 2 == 0: # 5 3 2
        a[0] += 1
        a[1] += 1
        ans += 1 # 6 4 2
        ans += (a[0] - a[2]) // 2
        ans += (a[0] - a[1]) // 2
    else: # 7 4 2
        a[1] += 1
        a[2] += 1
        ans += 1 # 7 5 3
        ans += (a[0] - a[2]) // 2
        ans += (a[0] - a[1]) // 2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

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

if a[2] % 2 != a[0] % 2:
    ans += 1
    a[1] += 1
    a[2] += 1

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

Submission status: Accepted

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

for i in range(3):
    while ABC[i]<max(ABC)-1:
        ABC[i]+=2
        c+=1

if ABC.count(max(ABC))==3:
    print(c)
elif ABC.count(max(ABC))==2:
    print(c+2)
else:
    print(c+1)

Submission status: Accepted

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

Submission status: Accepted

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

nums = (int(i) for i in sys.stdin.readline().rstrip().split())
a, b, c = sorted(nums)

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

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
_max = max(A, B, C)
sum = A + B + C
ans = 0
# 50回目の試行結果の判定は５１回目に実施する必要があるので51回ループ回す
for i in range(51):
    a = sum % 3
    b = sum / 3  
    #print(sum)
    if a == 0 and  b >= _max:
        print(ans)
        break
    else:
        ans += 1
        sum += 2
#print(ans)

Submission status: Accepted

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

# x = max(A,B,C) * 3 - (A + B + C)


sum_ = A + B + C
max_sum = max(A,B,C) * 3

ans = 0

if (sum_ % 2) == (max_sum % 2):
    ans = (max_sum - sum_) // 2
else:
    ans = ((max(A,B,C) + 1 ) * 3 - sum_) // 2

print(ans)

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

n = (vals[2] - vals[0]) + (vals[2] - vals[1])

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

Submission status: Accepted

Solution code:
# 二つの操作で増える総数は同じ
# 最も小さい数を2ずつ増やし、小さい数が同数なら1ずつ増やす

def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools

    nums = list(map(int, input().split()))
    i = 0
    while True:
        if len(set(nums)) == 1:
            print(i)
            break

        nums.sort()
        if nums[0] == nums[1]:
            nums[0] += 1
            nums[1] += 1
        else:
            nums[0] += 2
        
        i += 1

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a=list(map(int,input().split()))
a.sort()
b=0
ans=0
while a[2]-a[1]!=0 or a[1]-a[0]!=0:
  if a[0]>a[1] or a[1]>a[2]:
    a.sort()
  if a[1]==a[2]:
    if (a[1]-a[0])%2==1:
      a[1]+=1
      a[2]+=1
      ans+=1
      #print('ifif')
    else:
      #print('ifelse')
      while a[0]!=a[1]:
        a[0]+=2
        ans+=1
      print(ans)
      exit()
  elif a[1]==a[0]:
    #print('elif')
    print(ans+a[2]-a[1])
    exit()
  else:
    #print('else')
    a[0]+=2
    ans+=1
  #print(a,ans)
print(ans)

Submission status: Accepted

Solution code:
import heapq
class PriorityQueue:
	"""
	動的に優先度付きで値をpopする
	値を変更してから再度ソートして取り出すみたいな操作をするなら
	Priority Queue!
	"""
	def __init__(self,num_list=None,reverse=False):
		self.reverse = reverse
		self.heap = []
		if num_list != None :
			for num in num_list:
				self.push(num)

	def push(self,num):
		heapq.heappush(self.heap,-num if self.reverse else num)

	def pop(self):
		num = heapq.heappop(self.heap)
		return -num if self.reverse else num
	
	def get(self):
		return list(map(lambda x: x*(-1),self.heap))


def cmd1(a,b):
	return a+1,b+1

def cmd2(n):
	return n+2

a,b,c = map(int,input().split())
const = min(a,b,c)
a -= const
b -= const
c -= const
count = 0
pq = PriorityQueue(num_list=[a,b,c],reverse=True)
total = 0
while True :
	num_max = pq.pop()
	a = pq.pop()
	b = pq.pop()

	a_req = num_max - a
	b_req = num_max - b
	
	if num_max == a == b :
		break

	if a_req > 0 and b_req > 0:
		a,b = cmd1(a,b)
		total += 1
	else :
		b = cmd2(b)
		total += 1
	pq.push(num_max)
	pq.push(a)
	pq.push(b)
print(total)

Submission status: Accepted

Solution code:
item=list(map(int,input().split()))
item.sort()
times=0
while sum(item)/3!=item[0]:
  if item[1]==item[2]:
    item[0]+=2
    times+=1
    item.sort()
  else:
    item[0]+=1
    item[1]+=1
    times+=1
    item.sort()
print(times)

Submission status: Accepted

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

Submission status: Accepted

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

if A%2==B%2!=C%2:
    A,B=A+1,B+1
    cnt=1
elif B%2==C%2!=A%2:
    B,C=B+1,C+1
    cnt=1
elif C%2==A%2!=B%2:
    C,A=C+1,A+1
    cnt=1

A,B,C=min(A,B,C),A+B+C-min(A,B,C)-max(A,B,C),max(A,B,C)

print(cnt+(C-A)//2+(C-B)//2)

Submission status: Accepted

Solution code:
import sys

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

A = sorted(A)

cnt = 0
for i in range(2):
    tmp = int((A[2] - A[i]) / 2)
    A[i] += tmp * 2
    cnt += tmp

A = sorted(A)
if A[0] == A[1] and A[1] == A[2]:
    print(cnt)
    sys.exit()
elif A[0] == A[1]:
    A[0] += 1
    A[1] += 1
    cnt += 1
elif A[1] == A[2]:
    A[0] += 2
    A[1] += 1
    A[2] += 1
    cnt += 2

print(cnt)

Submission status: Accepted

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

ABC.sort()


miin = min(ABC)

ABC[0] -= miin
ABC[1] -= miin
ABC[2] -= miin

res=0


if ABC[1] %2 != 0:
        res+=1
        ABC[1] -= 1


res+= (ABC[1]/2) + (ABC[2] - ABC[1])


print(int(res))

Submission status: Accepted

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

Submission status: Accepted

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

m = max(A, B, C)
diff = [m - A, m - B, m - C]
s = sum(diff)
if s % 2 == 0:
    print(s // 2)
else:
    print((s // 2) + 2)

Submission status: Accepted

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

dif = arr[2] - arr[0] + arr[2] - arr[1]

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

Submission status: Accepted

Solution code:
def slove():
    import sys
    import bisect
    import collections
    import fractions
    import heapq
    input = sys.stdin.readline
    a, b, c = list(map(int, input().rstrip('\n').split()))
    cnt = 0
    while True:
        a, b, c = sorted([a, b, c])
        if abs(a - c) >= 2:
            a += 2
            cnt += 1
        else:
            if a == b == c:
                print(cnt)
                exit()
            if a == b:
                a += 1
                b += 1
                cnt += 1
            elif b == c:
                b += 1
                c += 1
                cnt += 1
            elif a == c:
                a += 1
                c += 1
                cnt += 1


if __name__ == '__main__':
    slove()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c = map(int,input().split())
cnt=0
x=[a,b,c]
while x[0]!=x[1] or x[1]!=x[2] or x[2]!=x[0]:
    x.sort()
    if x[2]>=x[0]+2:
        x[0]+=2
        cnt+=1
    else:
        x[0]+=1
        x[1]+=1
        cnt+=1
print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

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


while len(set(abc))!=1:
  if abc[2]-abc[1] > 0 and abc[2]-abc[0] > 0:
    abc[0] += 1
    abc[1]+=1
  elif abc[2]-abc[1] > 0:
    abc[1] += 2
  else:
    abc[0] += 2
  answer+=1
  abc.sort()

print(answer)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
abc = list(map(int, input().split()))
x = 0
y = 0
ans = 1
for i in range(3):
    if abc[i]%2==0:
        x+=1
    else:
        y+=1
if x==2:
    for i in range(3):
        if abc[i]%2==0:
            abc[i]+=1
elif y==2:
    for i in range(3):
        if abc[i]%2==1:
            abc[i]+=1
else:
    ans -= 1
abc.sort(reverse=True)
ans = ans + (abc[0]-abc[1])//2 + (abc[0]-abc[2])//2
print(ans)