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:
def test():
    a = list(map(int,input().split()))
    odd = 0; even = 0; result = 0
    for i in range(3):
        if a[i] % 2 == 1:
            odd += 1
        else:
            even += 1

    if odd == 2:
        result += 1
        for i in range(3):
            if a[i] % 2 == 1:
                a[i] += 1
    elif even == 2:
        result += 1
        for i in range(3):
            if a[i] % 2 == 0:
                a[i] += 1
    m = max(a)
    for i in range(3):
        result += (m-a[i])//2
    print(result)


if __name__ == "__main__":
    test()

Submission status: Accepted

Solution code:
a, b, c = map(int,input().split())
array = [a,b,c]
array.sort()
ans = 0
d = array[2] - array[1]
e = array[2] - array[0]
ans += (d // 2) + (e // 2)
if d % 2 == 0 and e % 2 == 0:
    print(ans)
elif d % 2 == 0 or e % 2 == 0:
    print(ans+2)
else:
    print(ans+1)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
l=list(map(int,input().split()))
l.sort()

dic=2*l[-1]-l[0]-l[1]

if dic%2==0:
    if l[0]%2==1 and l[1]%2==1 and l[-1]%2==0 or l[0]%2==0 and l[1]%2==0 and l[-1]%2==1:
        print((l[-1]-l[0])//2+(l[-1]-l[1])//2+1)
    else:
        print((l[-1]-l[0])//2+(l[-1]-l[1])//2)
    
else:
    print((l[-1]-l[0])//2+(l[-1]-l[1])//2+2)

Submission status: Accepted

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

ABC.sort()

# まずABCの最小値と2番目に小さい値を同じ値になるように操作する
# 偶奇が一致していない場合、まずABCの最小値と最大値に1を足す
ans = 0
if ABC[0]%2 != ABC[1]%2:
    ans += 1
    ABC[0] += 1
    ABC[2] += 1

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

# 最大値以外の2つの値を最大値と一致するまで1増加させて終了
ans += ABC[2] - ABC[1]

print(ans)

Submission status: Accepted

Solution code:
import numpy as np
*a, = map(int,input().split())
a = np.array(a)
dp = [0]*3
count = 0
if a[0] == a[1] == a[2]:print(0);exit()
for i in range(3):
    if a[i] % 2 == 1:dp[i] = 1
if dp.count(1) == 2:
    for i in range(len(a)):
        if dp[i] == 1:a[i] += 1
    count += 1
    while not a[0] == a[1] == a[2]:
        a[np.argmin(a)] += 2
        count += 1
elif dp.count(0) == 2:
    for i in range(len(a)):
        if dp[i] == 0:a[i] += 1
    count += 1
    while not a[0] == a[1] == a[2]:
        a[np.argmin(a)] += 2
        count += 1
else:
    while not a[0] == a[1] == a[2]:
        a[np.argmin(a)] += 2
        count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
abc = list(map(int,input().split()))
odd = []
even = []
for i in abc:
    if i%2==0:
        even.append(i)
    else:
        odd.append(i)
if (not odd) or (not even):
    print(sum([(max(abc)-x)//2 for x in abc]))
else:
    if len(odd) ==1:
        even = [x+1 for x in even]
    else:
        odd = [x+1 for x in odd]
    abc = odd+even
    print(sum([(max(abc)-x)//2 for x in abc])+1)

Submission status: Accepted

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

# 1. 3つとも違う数字
#  => 小さいふたつを + 1
# 2. 2つ同じ数字
#  => 1つだけの数字が小さい
#     小さい数字を + 2
#  => 1つだけの数字が大きい
#     小さいふたつを + 1
result = 0
while True:
    if A == B and B == C:
        break
    elif A != B and B != C and A != C:
        if A < B:
            if B < C:
                A += 1
                B += 1
            else:
                A += 1
                C += 1
        else:
            if A < C:
                A += 1
                B += 1
            else:
                B += 1
                C += 1
    else:
        if A == B:
            if A > C:
                C += 2
            else:
                A += 1
                B += 1
        elif B == C:
            if A > B:
                B += 1
                C += 1
            else:
                A += 2
        else:
            # A == C
            if A > B:
                B += 2
            else:
                A += 1
                C += 1
    result += 1
print(result)

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
ans=0
ma=max(a,b,c)
mi=min(a,b,c)
mj=a+b+c-ma-mi
ans+=(ma-mi)//2
mi+=((ma-mi)//2)*2
ans+=(ma-mj)//2
mj+=((ma-mj)//2)*2
if ma==mi==mj:
    print(ans)
elif ma==mi+1 and ma==mj+1:
    print(ans+1)
else:
    print(ans+2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    a=list(map(int, input().split()))
    a.sort()
    ans=a[2]-a[1]
    a[0]+=ans
    a[1]+=ans
    d=a[1]-a[0]
    ans+=d//2
    ans+=(d%2)*2
    print(ans)

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l = [int(i) for i in input().split()]
cnt = 0
while not(l[0] == l[1] == l[2]):
  cnt += 1
  if l[0]-l[1]==l[0]-l[2]==1 or l[1]-l[0]==l[1]-l[2]==1 or l[2]-l[0]==l[2]-l[1]==1:
    print(cnt)
    exit()
  else:
    l[l.index(min(l))] += 2
print(cnt)

Submission status: Accepted

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


q1,mod1 = divmod((ABC[2] - ABC[0]), 2)
q2,mod2 = divmod((ABC[2] - ABC[1]), 2)

cnt = q1 + q2

if mod1 == mod2 == 0:
    print(cnt)
elif mod1 == mod2 == 1:
    print(cnt + 1)
else:
    print(cnt + 2)

Submission status: Accepted

Solution code:
l = list(map(int, input().split()))
l = sorted(l)
res = l[2] - l[1]
q, r = divmod(l[1]-l[0], 2)
res = res + q + r * 2
print(res)

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

a = inpl()
a.sort()
b = (a[1]-a[0]) // 2
c = a[2] - a[1]
if (a[1] - a[0]) % 2 == 0:
    print(b + c)
else:
    print(b + c + 2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
sumof3 = A + B + C
maxof3 = max(A, B, C)
oddeven = sumof3 % 2
oe_of_max = maxof3 % 2
if oddeven != oe_of_max:
    maxof3 += 1
ans = (maxof3 * 3 - sumof3) // 2
print(ans)

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
lst=[a,b,c]
lst.sort()
dif1=lst[2]-lst[1]
dif2=lst[2]-lst[0]
q1,mod1=divmod(dif1,2)
q2,mod2=divmod(dif2,2)
dif3=min(dif1,dif2)
if mod1==mod2:
  if mod1==0:
    print(q1+q2)
  else:
    print(q1+q2+1)
else:
  print(q1+q2+2)

Submission status: Accepted

Solution code:
ls=[int(s) for s in input().split()]
x=sum(ls)
y=max(ls)*3
if (y-x)%2==0:
  print((y-x)//2)
else:
  print((y+3-x)//2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from functools import reduce
import copy
import math
from pprint import pprint


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    nums = string_to_int(inputs[0])
    max_num = max(nums)
    sum_num = sum(nums)

    count = 0
    while sum_num % 3 != 0 or (sum_num // 3) < max_num:
        count += 1
        sum_num += 2
    return count


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A,B,C =[int(x) for x in input().split()]
d = max(A,B,C)
l = [d-A,d-B,d-C]
su = sum(l)
if su%2==0:
  print(su//2)
else:
  print(1+(su+1)//2)

Submission status: Accepted

Solution code:
a,b,c = map(int, input().split())
li = sorted([a,b,c])
ans = 0

if (li[2]-li[0])%2 != (li[2]-li[1])%2:

    if li[2]%2 == li[0]%2:
        li[2] += 1
        li[0] += 1
    else:
        li[2] += 1
        li[1] += 1
    ans += 1

d = min(li[2]-li[0],li[2]-li[1])
e = max(li[2]-li[0],li[2]-li[1])
ans += d + (e-d)//2
print(ans)

Submission status: Accepted

Solution code:
abc = sorted(map(int, input().split()))
o = [i%2 for i in abc]
b = 0
if o.count(1)==1:
    b += 1
    for i in range(3): abc[i] += 1^o[i]
if o.count(1)==2:
    b += 1
    for i in range(3): abc[i] += o[i]
print((abc[2]-abc[1])//2+(abc[2]-abc[0])//2+b)

Submission status: Accepted

Solution code:
def solve():
    T = list(map(int, input().split()))
    l = [t%2 for t in T]
    count = 0
    if sum(l) == 1:
        odd = T.pop(l.index(1))
        count += abs(T[0] - T[1]) // 2
        if max(T[0],T[1]) <= odd:
            count += odd - max(T[0],T[1])
        else:
            count += (max(T[0],T[1]) - odd)//2 + 2
    elif sum(l) == 2:
        even = T.pop(l.index(0))
        count += abs(T[0] - T[1]) // 2
        if max(T[0],T[1]) <= even:
            count += even - max(T[0],T[1])
        else:
            count += (max(T[0],T[1]) - even)//2 + 2
    else:
        m = T.pop(T.index(max(T)))
        count += abs(T[0] - T[1]) // 2
        count += abs(m - max(T[0],T[1]))
        
    return count
        

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

Submission status: Accepted

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

m = max(arr)

cnt = 0

for i in range(3):
    if m - arr[i] >= 2:
        x = (m - arr[i]) // 2
        cnt += x

        arr[i] += x*2


arr.sort()

if arr[0] == arr[1] and arr[1] == arr[2]:
    pass
elif arr[0] < arr[1] and arr[1] < arr[2]:
    cnt += 3
elif arr[0] == arr[1] and arr[1] < arr[2]:
    cnt += 1
else:
    cnt += 2

print(cnt)

Submission status: Accepted

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

target = max(a, b, c)
if (target*3 - a - b - c) % 2 == 1:
    target += 1

res = (target*3 - a - b - c) // 2

print(res)

Submission status: Accepted

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

Submission status: Accepted

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

L.sort()
M = max(L)
for i in range(3):
    L[i] -= M
    
ans = -L[1]
L[0] += ans
if L[0]%2 == 0:
    ans -= L[0]//2
else:
    ans -= (L[0]-1)//2-1
    
print(ans)

Submission status: Accepted

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

ans = 0
while (C-A) > 1:
    A += 2
    ans += 1

while (C-B) > 1:
    B += 2
    ans += 1

if A == C:
    if B != C:
        B += 2
        A += 1
        C += 1
        ans += 2
else:
    if B == C:
        A += 2
        B += 1
        C += 1
        ans += 2
    else:
        A += 1
        B += 1
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
#https://atcoder.jp/contests/abc093/tasks/arc094_a

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

diff = 3*max(a, b, c) - (a + b + c)

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

Submission status: Accepted

Solution code:
#https://atcoder.jp/contests/abc093/tasks/arc094_a

import numpy
data = list(map(int, input().split()))
cost = 0

max_index = numpy.argmax(data)
m = data.pop(max_index)
if abs(data[0]-data[1])%2 == 1:
    cost += 2
cost += (abs(data[0]-data[1])//2 + m - max(data))
print(cost)

Submission status: Accepted

Solution code:
a,b,c=[int(i) for i in input().split()]
def ans(m):
    print((m-a)//2+(m-b)//2+(m-c)//2+((m-a)%2+(m-b)%2+(m-c)%2)//2)
ans(max(a,b,c) if sum([a,b,c])%2==max(a,b,c)*3%2 else max(a,b,c)+1)

Submission status: Accepted

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

diff = 3*max(a,b,c) - (a + b + c)

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

Submission status: Accepted

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

diff = ABC[2] - ABC[1]
ret = diff
ABC[0] += diff
ABC[1] += diff

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

Submission status: Accepted

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

if As[-1]-As[0]>=2:
  step = (As[-1]-As[0])//2
  As[0] += step * 2
  ans += step
  
if As[-1]-As[1]>=2:
  step = (As[-1]-As[1])//2
  As[1] += step * 2
  ans += step
    
As = sorted(As)
if As[0]==As[1] and As[-1]>As[1]:
  ans += 1
  
elif As[0]<As[1] and As[1]==As[-1]:
  ans += 2
    
print(ans)

Submission status: Accepted

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

if a % 2 == b % 2 == c % 2:
  pass
elif a % 2 == b % 2:
  out += 1
  a += 1
  b += 1
elif a % 2 == c % 2:
  out += 1
  a += 1
  c += 1
else:
  out += 1
  b += 1
  c += 1
  
l = sorted([a, b, c])
while True:
  if l[1] == l[2]:
    break
  out += 1
  l[0] += 1
  l[1] += 1
while True:
  if l[0] == l[1]:
    break
  out += 1
  l[0] += 2

print(out)

Submission status: Accepted

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

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

Submission status: Accepted

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

ans=0

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

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

Submission status: Accepted

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

if N[0]==N[1]==N[2]:
    ans=0

N.sort()
x=N[2]-N[1]
y=N[1]-N[0]

if x%2==1 and y%2==0:
    ans=y//2+x
elif x%2==1 and y%2==1:
    ans=(x+y)//2+(x+1)//2+1
elif x%2==0 and y%2==0:
    ans=x//2+(x+y)//2
else:
    ans=x//2+(x+y+1)//2+1

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

ans,flag=0,True
cnt=[0]*3
while flag:
  ABC.sort()
  for i in range(3):
    if ABC[i]+2<=max(ABC):
      ABC[i]+=2
      ans+=1
    elif sum(cnt)==3:
      flag=False
    else:
      cnt[i]=1
if sum(ABC)==3*max(ABC):
  print(ans)
elif sum(ABC)==3*max(ABC)-1:
  print(ans+2)
elif sum(ABC)==3*max(ABC)-2:
  print(ans+1)

Submission status: Accepted

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

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

Submission status: Accepted

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

tmpM = max(A, B, C)
tmp = A + B + C
if ((3 * tmpM) - tmp) % 2 == 0:
    print(((3 * tmpM) - tmp) // 2)
else:
    print((3 * (tmpM + 1) - tmp) // 2)

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
a, b, c = sorted((a, b, c))
counter = 0
counter += (c - b) // 2
b += ((c - b) // 2) * 2
if c - b == 1:
  counter += 1
  a += 1
  b += 1
counter += (c - a) // 2
a += ((c- a) // 2) * 2
if c - a == 1:
  counter += 2
  a += 2
  b += 1
  c += 1

print(counter)

Submission status: Accepted

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

cnt = int((b-a)/2)
a += cnt * 2

cnt += c - a + int((b - a) % 2)

print(cnt)

Submission status: Accepted

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

cnt = int((b-a)/2)
a += cnt * 2

if b - a == 1:
    cnt += 1
    a += 1
    c += 1

cnt += c - a
a, b = c, c

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

ma = max(a, b, c)

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

else:
    if (a + b + c) % 2 == 1:
        print((ma*3-(a+b+c)) // 2)
    else:
        print(((ma+1)*3 -(a+b+c))//2)

Submission status: Accepted

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

if abc[2] - abc[1] == 1:
    target = abc[1]
else:
    target = abc[2]

res = 0
for i in range(3):
    res += -(-(target - abc[i]) // 2)
    if (target - abc[i]) % 2 == 1:
        res += 1

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC093 C - Same Integers
abc = list(map(int, input().split()))
m = max(abc)
abc = [m-x for x in abc] 

abc.sort()
m = max(abc)
ans = 0

while m > 0:
    abc.sort()
    if m >= 2:
        abc[2] -= 2
        ans += 1
        m = max(abc)
    elif m == 1:
        if abc.count(1)==3:
            ans += 1
            print(ans)
            exit()
        elif abc.count(1)==2:
            abc[2] -= 1
            abc[1] -= 1
            ans += 1
            m = max(abc)
        elif abc.count(1)==1:
            ans += 2
            print(ans)
            exit()
print(ans)

Submission status: Accepted

Solution code:
# sys.stdin.readline
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        abc = list(map(int, input().split()))

        M = max(abc)
        if M % 2 == sum(abc) % 2:
            print((3 * M - sum(abc)) // 2)
        else:
            print((3 * (M + 1) - sum(abc)) // 2)


# Run main
if __name__ == '__main__':
    AtCoder().main()

Submission status: Accepted

Solution code:
# sys.stdin.readline
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        abc = list(map(int, input().split()))

        M = max(abc)
        if 3 * M % 2 == sum(abc) % 2:
            print((3 * M - sum(abc)) // 2)
        else:
            print((3 * (M + 1) - sum(abc)) // 2)


# Run main
if __name__ == '__main__':
    AtCoder().main()

Submission status: Accepted

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

ans = 0
if A % 2 != B % 2:
  A += 1
  C += 1
  ans += 1

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
M = max(A, B, C); S = sum([A, B, C])
print((M * 3 - S) // 2 + (M * 3 - S) % 2 * 2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

# 2 5 7
# 4 7 7    + c-b
# 6 7 7    + (b-a)//2
# 8 7 7
# 8 8 8    + 2
print((c - b) + ((b - a) // 2) + (2 if (b - a) % 2 else 0))

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    A, B, C = map(int, input().split())
    
    max_v = max(A, B, C)
    min_v = min(A, B, C)
    
    num_list = [A, B, C]
    num_list.remove(max_v)
    if len(num_list) == 2:
        num_list.remove(min_v)
        if len(num_list) == 1:
            mid_v = num_list[0]
        else:
            mid_v = min_v
    else:
        mid_v = max_v
    
    ans = 0
    while True:
        if mid_v < max_v:
            ans += max_v - mid_v
            min_v += max_v - mid_v
            mid_v = max_v
            #print("aaa", min_v, mid_v, max_v)
        else:#mid_v = max_v
            if min_v < max_v:
                if (max_v - min_v) % 2 == 0:
                    #min_v = max_v
                    ans += (max_v - min_v) / 2
                    #print("bbb", min_v, mid_v, max_v)
                    break
                else:
                    #min_v = max_v
                    #max_v += 1
                    #mid_v += 1
                    ans += (max_v + 1 - min_v) / 2
                    ans += 1
                    #print("ccc", min_v, mid_v, max_v)
                    break
            else:
                break
    
    print(int(ans))

Submission status: Accepted

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

if a % 2 == 0 and b % 2 == 0:
    print(a // 2 + b // 2)
elif a % 2 == 0 or b % 2 == 0:
    print(a // 2 + b // 2 + 2)
else:
    print(a // 2 + b // 2 + 1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

diff = lst[2]-lst[1]
res = -(-(lst[1]-lst[0])//2)+(lst[1]-lst[0])%2
print(diff+res)

Submission status: Accepted

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

A = sorted(A)
a,b,c = A
ans = c-b
if (b-a)%2 == 0:
    ans += (b-a)//2
else:
    ans += (b-a+1)//2 + 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
L = [A, B, C]
even = []
odd = []
ans = 0

for i in L:
    if i % 2 == 0:
        even.append(i)
    else:
        odd.append(i)

if len(even) == 2:
    even[0] += 1
    even[1] += 1
    ans += 1
    num = even + odd
elif len(odd) == 2:
    odd[0] += 1
    odd[1] += 1
    ans += 1
    num = even + odd
else:
    num = L

num.sort()
ans_1 = (num[1] - num[0]) // 2
ans_2 = num[2] - num[1]
ans += ans_1 + ans_2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
li=[a,b,c]
li=sorted(li,reverse=True)

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

Submission status: Accepted

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

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

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 = sorted(map(int,input().split()))
cnt = 0
while a!=b or b!=c:
  if a != c and b != c:
    a += 1
    b += 1
  elif a == c+1:
    c += 1
    b += 1
  elif b == c and a != c:
    a += 2
  cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

L =  list(map(int, sys.stdin.readline().split()))
L.sort(reverse=True)

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

if (d1 % 2 == 0 and d2 % 2 == 0) or (d1 % 2 != 0 and d2 % 2 != 0):
    print((d1 + d2) // 2)
else:
    print((d1 + d2 + 1) // 2 + 1)

Submission status: Accepted

Solution code:
def main():
    A, B, C = map(int, input().split())
    num = sorted([A, B, C])
    ans = 0
    even = 0
    for i in range(3):
        if not num[i]&1:
            even += 1
    if even == 2:
        ans = 1
        for i in range(3):
            if not num[i]&1:
                num[i] += 1
    elif even == 1:
        ans = 1
        for i in range(3):
            if num[i]&1:
                num[i] += 1
    ans += (num[2] * 2 - num[0] - num[1]) // 2
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math
a, b, c = map(int, input().split())
# 二つを +1　→　一つを -1 と読み替えて、目標値0 ~ 100までの操作回数を数える

def cnt(crnt, goal):
  diff = abs(goal - crnt)
  if crnt >= goal:
    return diff
  else:
    if diff % 2 == 0:
      return diff // 2
    else:
      return math.ceil(diff/2) + 1

ans = 10**10
for i in range(100):
  ca = cnt(a, i)
  cb = cnt(b, i)
  cc = cnt(c, i)
  csum = ca + cb + cc
  if ans > csum:
    ans = csum
print(ans)

Submission status: Accepted

Solution code:
(a, b, c) = sorted(int(tok) for tok in input().split())
moves = 0

moves += (c - b) // 2
b += (c - b) // 2 * 2

if b < c:
    moves += 1
    b += 1
    a += 1

moves += (c - a) // 2
a += (c - a) // 2 * 2

if a < c:
    moves += 2

print(moves)

Submission status: Accepted

Solution code:
a=sorted(list(map(int,input().split())))
cnt=0
while a[2]-a[0]>=2:
  a[0]+=2
  cnt+=1
while a[2]-a[1]>=2:
  a[1]+=2
  cnt+=1
a=sorted(a)
if a[0]<a[1]:
  cnt+=2
elif a[1]<a[2]:
  cnt+=1
print(cnt)

Submission status: Accepted

Solution code:


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

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

count = 0

# 奇数なので偶数にあわせる
if (A[1]-A[0])%2 == 1:
    A[0] += 1
    A[2] += 1
    count += 1

# 偶数ルート
count += (A[1]-A[0])//2
count += (A[2]-A[1])

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

ans=0

#まず+1, +1を限界まで
b_plus=c-b
b+=b_plus
a+=b_plus
ans+=b_plus

#次に+2を限界まで
a_plus=(c-a)//2
a+=a_plus*2
ans+=a_plus

#微調整
if a!=b:
    ans+=2

print(ans)

Submission status: Accepted

Solution code:
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

x = III()

ans = 0
while 1:
    x.sort()
    if x[0]==x[2]:
        break
    elif x[1]!=x[2]:
        x[0] += 1
        x[1] += 1
        ans += 1
    else:
        x[0] += 2
        ans += 1

print(ans)

Submission status: Accepted

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


cnt = 0

while B < C:
	A += 1
	B += 1
	cnt += 1

if (B - A) % 2 == 0:
	cnt += (B-A) // 2
else:
	cnt += ((B-A) // 2 + 2)

print(cnt)

Submission status: Accepted

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

diff_12 = ABC[1] - ABC[0]
middle = ABC[1]
mx = ABC[2]

ans = 0
ans += (diff_12+1) // 2
if (diff_12 % 2) == 1:
    ans += 1
ans += mx - middle

print(ans)