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()))

cnt = 0
while not (a == b == c):
    if (b - a) % 2 == 0:
        cnt = (b - a) // 2
        cnt += c - b
        print(cnt)
        exit()
    else:
        cnt = (b - a) // 2
        cnt += c - b + 2
        print(cnt)
        exit()


print(cnt)

Submission status: Accepted

Solution code:
import sys
from statistics import *
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

li = na()
li.sort()
ct = 0
dif = li[1] - li[0]
ct += dif // 2
li[0] += (dif // 2) * 2
if li[0] == li[1]:
    ct += li[2] - li[1]
else:
    ct += li[2] - li[0] + 1
print(ct)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
from math import ceil

def solve(A: int, B: int, C: int):
    l = [A, B, C]
    l.sort()

    t = l[2]-l[1] + l[2] - l[0]

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

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c=sorted(map(int,input().split()));d=2*c-a-b;print(d//2+d%2*2)

Submission status: Accepted

Solution code:
t = sorted(list(map(int, input().split())), reverse=True)
m = max(t)
ans = 0
if t[1] % 2 != t[2] % 2:
    t[0] += 1
    t[1] += 1
    m += 1
    ans += 1
while any([x != m for x in t]):
    if t[1]+2 <= m: t[1] += 2
    elif t[2]+2 <= m: t[2] += 2
    elif t[1]+1 <= m and t[2]+1 <= m:
        t[1] += 1
        t[2] += 1
    ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 1. 3つとも違う数字
#  => 小さいふたつを + 1
# 2. 2つ同じ数字
#  => 1つだけの数字が小さい
#     小さい数字を + 2
#  => 1つだけの数字が大きい
#     小さいふたつを + 1
a, b, c = map(int, input().split())
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:
x = [int(i) for i in input().split()]
x.sort()
ans = (x[1]-x[0])//2 + x[2] - x[1]
if (x[1]-x[0]) % 2 != 0:
    print(ans + 2)
else:
    print(ans)

Submission status: Accepted

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

ABC = sorted(ABC)

N = ABC[2] - ABC[1]
M = ABC[2] - ABC[0] - N

ans = N + M // 2

if M % 2 == 1:
    ans += 2

print(ans)

Submission status: Accepted

Solution code:
#ABCを小さい順にリスト化
nums=sorted(list(map(int, input().split())))

#ABCのあまりをリスト化
rest=[i%2 for i in nums]

#ABCの偶奇が一致しているとき、差の半分だけ操作すれば良い（差は常に偶数）
if sum(rest)==0 or sum(rest)==3:
    print(((nums[2]-nums[1])+(nums[2]-nums[0]))//2) 
#一つだけ奇数のとき。偶数2つに１を加えて奇数にした後、差の半分だけ操作すれば良い（差は常に偶数）
elif sum(rest)==1:
    nums_2=[i+1 if i%2==0 else i for i in nums]
    print(((nums_2[2]-nums_2[1])+(nums_2[2]-nums_2[0]))//2+1) 
#一つだけ偶数のとき。奇数2つに１を加えて偶数にした後、差の半分だけ操作すれば良い（差は常に偶数）
elif sum(rest)==2:
    nums_3=[i+1 if i%2==1 else i for i in nums]
    print(((nums_3[2]-nums_3[1])+(nums_3[2]-nums_3[0]))//2+1)

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
ary = list(map(int,input().split()))
count = 0
#最初から同じだった時
if ary[0] == ary[1] == ary[2]:
    print(0)
    sys.exit()

#和が偶数だった時
if (ary[0] + ary[1] + ary[2]) % 2 == 0:
    for i in range(3):
        if ary[i] % 2 == 1:
            ary[i] += 1
            count += 0.5
# 和が奇数だった時
elif (ary[0] + ary[1] + ary[2]) % 2 == 1:
    for i in range(3):
        if ary[i] % 2 == 0:
            ary[i] += 1
            count += 0.5

while not ary[0] == ary[1] == ary[2]:
    ary.sort()
    ary[0] += 2
    count += 1

print(int(count))

Submission status: Accepted

Solution code:
a, b, c = map(int,input().split())
m = max(a,b,c)
a = abs(a-m)
b = abs(b-m)
c = abs(c-m)
cnt = 0
cnt += a//2 + b//2 + c//2
a -= a//2 * 2
b -= b//2 * 2
c -= c//2 * 2
if a + b + c == 2:
    cnt += 1
elif a + b + c == 1:
    cnt += 2

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

once = L[2]-L[1]
dif = L[2] - once - L[0]

if dif % 2 == 0:
    ans = once + dif // 2
else:
    dif += 1
    ans = 1 + once + dif // 2 

print(ans)

Submission status: Accepted

Solution code:
def main():
    A, B, C = map(int, input().split())
    A, B, C = sorted([A, B, C])
    if A == B == C:
        return 0
    elif B == C:
        if (B-A) % 2 == 0:
            return (B-A) // 2
        else:
            return (B-A+1) // 2 + 1
    elif A == B:
        return (C-B)
    else:
        if (B-A) % 2 == 0:
            return (B-A)//2 + C-B
        else:
            return (B-A+1)//2 + (C-B) + 1

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

Submission status: Accepted

Solution code:
a=sorted([int(i) for i in input().split()])
b=2*a[2]-a[1]-a[0]
if b%2==0:print(b//2)
else:print(b//2+2)

Submission status: Accepted

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

cnt = 0
while max(L)-min(L) > 1:
  L[L.index(min(L))] += 2
  cnt +=1
L.sort()
if L[0] == L[1] != L[2]:
  cnt += 1
elif L[0] != L[1]:
  cnt += 2
print (cnt)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc093/tasks/arc094_a
# C - Same Integers

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

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

if (abc_list[1] - abc_list[0]) % 2 != 0:
    # 2番目と3番目に+1することで、最小値と2番目の差を偶数にする
    c += 1
    abc_list[1] += 1
    abc_list[2] += 1

# 最小値と2番目の値を揃える
c += (abc_list[1] - abc_list[0]) / 2
abc_list[0] += 2 * ((abc_list[1] - abc_list[0]) / 2)

# 両方をmax値まで揃える
c += (abc_list[2] - abc_list[1])
c = int(c)

print(c)

Submission status: Accepted

Solution code:
"""
# 標準入力取得
## 文字列
 = 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(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

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

mod = 1000000007

if __name__ == "__main__":
    a,b,c = map(int, sys.stdin.readline().split())
    #a,b,c → x,x,xになる過程を求める問題
    #上の過程は(3x-(a+b+c))/2回
    #m=max{a,b,c}とするとx=m or m+1。条件分岐:和とmaxの偶奇が一致してればx=m
    wa = a+b+c
    m=max(a,b,c)

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

Submission status: Accepted

Solution code:
nums = sorted(map(int, input().split()))
flag = 2 * nums[2] - sum(nums[:2])
ans = int(flag / 2)
print(ans if flag % 2 == 0 else ans + 2)

Submission status: Accepted

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

flag = 2 * nums[2] - sum(nums[:2])
ans = int(nums[2] - 1/2 * sum(nums[:2]))
if  flag % 2 == 0:
    print(ans)
else:
    print(ans + 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:
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
A, B, C = list(map(int, input().split()))
m = max(A, B, C)
T = m * 3 if (A + B + C + m) % 2 == 0 else(m + 1) * 3  # 目標値
print(str((T-A-B-C)//2))

Submission status: Accepted

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

a0 = abc[2] - abc[0]
a1 = abc[2] - abc[1]

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

Submission status: Accepted

Solution code:
l=sorted(list(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:
l=list(map(int,input().split()))
l.sort()
s=2*l[2]-l[1]-l[0]
if s%2==0:
    print(s//2)
else:
    print((s+3)//2)

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
a.sort(reverse=True)
diff = a[0]*2 - a[1] - a[2]

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

Submission status: Accepted

Solution code:
import copy

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

max_v = max(a,b,c)


if max_v == b:
    tmp = a
    a = b
    b = tmp
elif max_v == c:
    tmp = a
    a = c
    c = tmp

tmp_b = (a-b) // 2
tmp_c = (a-c) // 2

if a - (b + 2 * tmp_b) + a - (c + 2 * tmp_c) == 2:
    ans = tmp_b + tmp_c + 1
elif a - (b + 2 * tmp_b) + a - (c + 2 * tmp_c) == 0:
    ans = tmp_b + tmp_c
else:
    ans = tmp_b + tmp_c + 2

print(ans)

Submission status: Accepted

Solution code:
As = sorted(list(map(int, input().split())))
"""
2つ選んで両方を1増やす
1つ選んで2増やす

2 5 4
2 6 3
偶奇が一致しているものを選ぶ
・全部一致している -> 差の総数を2で割る
・1つだけ異なる -> 一回、1つ選んで2増やす

"""
amari = [a%2 for a in As]
# すべての偶機が一致
if sum(amari) == 0 or sum(amari) == 3:
    print(((As[2]-As[1])+(As[2]-As[0]))//2)
# 一箇所だけ奇数
elif sum(amari) == 1:
    Bs = [a+1 if a%2==0 else a for a in As]
    print(((Bs[2]-Bs[1])+(Bs[2]-Bs[0]))//2 + 1)
# 一箇所だけ偶数
elif sum(amari) == 2:
    Bs = [a+1 if a%2==1 else a for a in As]
    print(((Bs[2]-Bs[1])+(Bs[2]-Bs[0]))//2 + 1)

Submission status: Accepted

Solution code:
n=list(map(int,input().split()))
count=0
while not n[0]==n[1]==n[2]:
    if max(n)-min(n)>=2:
        n[n.index(min(n))] +=2
        count +=1
    elif max(n)-min(n)==1:
        point=[0,1,2]
        point.remove(n.index(min(n)))
        point.remove(n.index(max(n)))
        n[point[0]] +=1
        n[n.index(min(n))] +=1
        count +=1
print(count)

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
diff_a = sum(map(lambda x: max(a) - x, a))
if diff_a % 2 == 0:
    print(diff_a // 2)
else:
    print(diff_a // 2 + 2)

Submission status: Accepted

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


ans = C - B
A += C - B

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

Submission status: Accepted

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

sorted_lst = sorted(lst)

diff1 = sorted_lst[2] - sorted_lst[1]
diff2 = sorted_lst[2] - sorted_lst[0]
ans = 0
if (diff1 % 2 == 0 and diff2 % 2 == 0):
  ans = diff1 // 2 + diff2 // 2
elif (diff1 % 2 != 0 and diff2 % 2 != 0):
  ans = (diff1 - 1) // 2 + (diff2 - 1) // 2 + 1
elif (diff1 % 2 != 0 and diff2 % 2 == 0):
  ans = (diff1 - 1) // 2 + diff2 // 2 + 2
elif (diff1 % 2 == 0 and diff2 % 2 != 0):
  ans = (diff2 - 1) // 2 + diff1 // 2 + 2
print(ans)

Submission status: Accepted

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

abc.sort()

def func(a,b,c):
    return int((c-a)/2+(c-b)/2)

if abc[0]%2==abc[1]%2:
    if abc[0]%2!=abc[2]%2:
        print(func(abc[0]+1,abc[1]+1,abc[2])+1)
    else:
        print(func(abc[0],abc[1],abc[2]))
else:
    if abc[0]%2==abc[2]%2:
        print(func(abc[0]+1,abc[1],abc[2]+1)+1)
    else:
        print(func(abc[0],abc[1]+1,abc[2]+1)+1)

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
odd_num = 0
for e in [A, B, C]:
    if e % 2 == 1:
        odd_num += 1
        
if odd_num == 3 or odd_num == 0:
    ans = 0
    for e in [A, B, C]:
        ans += (max(A, B, C) - e) // 2
    print(ans)
else:
    ans = 1
    ABC = [A, B, C]
    if odd_num == 1:
        for i in range(3):
            if ABC[i] % 2 == 0:
                ABC[i] += 1
        for e in ABC:
            ans += (max(ABC) - e) // 2
    else:
        for i in range(3):
            if ABC[i] % 2 == 1:
                ABC[i] += 1
        for e in ABC:
            ans += (max(ABC) - e) // 2
            
    print(ans)

Submission status: Accepted

Solution code:
A,B,C=map(int,input().split())
total=abs(max(A,B,C)-A)+abs(max(A,B,C)-B)+abs(max(A,B,C)-C)

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

Submission status: Accepted

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

    sort_A = sorted(A)

    cnt = 0

    cnt += (sort_A[2] - sort_A[0]) // 2
    sort_A[0] = sort_A[0] + ((sort_A[2] - sort_A[0]) // 2) * 2

    cnt += (sort_A[2] - sort_A[1]) // 2
    sort_A[1] = sort_A[1] + ((sort_A[2] - sort_A[1]) // 2) * 2

    sort_A.sort()
    if sort_A[0] == sort_A[1] == sort_A[2]:
        print(cnt)
    elif sort_A[1] == sort_A[2]:
        print(cnt + 2)
    elif sort_A[0] == sort_A[1]:
        print(cnt + 1)

    

main()

Submission status: Accepted

Solution code:
import heapq
ls = list(map(int, input().split()))
cnt = 0
heapq.heapify(ls)
a = heapq.heappop(ls)
b = heapq.heappop(ls)
c = heapq.heappop(ls)
cnt += (c - a) // 2
a += (c - a) // 2 * 2
cnt += (c - b) // 2
b += (c - b) // 2 * 2
if a == b == c:
    print(cnt)
else:
    if a == c or b == c:
        print(cnt + 2)
    else:
        print(cnt + 1)

Submission status: Accepted

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

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

k = 0
while True:
    if a[0] == a[1] == a[2]:
        break
    a.sort()
    if a[1] == a[2]:
        a[0] += 2
        k += 1
    else:
        a[0] += 1
        a[1] += 1
        k += 1
print(k)

Submission status: Accepted

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

if A % 2 == B % 2 == C % 2:
    N = max(A, B, C)
    ans = (N - A) // 2 + (N - B) // 2 + (N - C) // 2
    print(ans)
else:
    if A % 2 == B % 2:
        A += 1
        B += 1
    elif B % 2 == C % 2:
        B += 1
        C += 1
    else:
        C += 1
        A += 1
    N = max(A, B, C)
    ans = 1 + (N - A) // 2 + (N - B) // 2 + (N - C) // 2
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def cal(a, b, c):
    z = max(a, b, c)
    return (3*z-a-b-c)//2


a, b, c = map(int, input().split())
odd_count = 0
for _ in a, b, c:
    if _ % 2 == 1:
        odd_count += 1

if odd_count in [0, 3]:
    print(cal(a, b, c))

elif odd_count == 1:
    if a % 2 == 0:
        a += 1
    if b % 2 == 0:
        b += 1
    if c % 2 == 0:
        c += 1
    print(cal(a, b, c)+1)

else:
    if a % 2 == 1:
        a += 1
    if b % 2 == 1:
        b += 1
    if c % 2 == 1:
        c += 1
    print(cal(a, b, c)+1)

Submission status: Accepted

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

Submission status: Accepted

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

time = (top - a)//2 + (top - b)//2 + (top - c)//2
rest = (top - a)%2 + (top - b)%2 + (top - c)%2

if rest == 1:
    time += 2
elif rest == 2:
    time += 1

print(time)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
A,B,C = [int(x) for x in stdin.readline().rstrip().split()]
d = sorted([A,B,C])
 
a = A % 2
b = B % 2
c = C % 2
 
if a == b == c:
    ans = ((d[2] - d[1]) + (d[2] -d[0])) // 2
    
elif a == b:
    A += 1
    B += 1
    d = sorted([A,B,C])
    ans = ((d[2] - d[1]) + (d[2] -d[0])) // 2
    ans += 1
    
elif a == c:
    A += 1
    C += 1
    d = sorted([A,B,C])
    ans = ((d[2] - d[1]) + (d[2] -d[0])) // 2
    ans += 1
 
elif c == b:
    B += 1
    C += 1
    d = sorted([A,B,C])
    ans = ((d[2] - d[1]) + (d[2] -d[0])) // 2
    ans += 1
 
    
print(ans)

Submission status: Accepted

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

count = 0
while nums[0] != nums[1] or nums[1] != nums[2]:
    if nums[1] != nums[2]:
        nums[1] += 1
        nums[0] += 1
        count += 1
    else:
        nums[0] += 2
        count += 1
    nums.sort()
print(count)

Submission status: Accepted

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

i = 0
while l[1] != l[2]:
  l[0], l[1] = l[0]+1, l[1]+1
  i += 1

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

Submission status: Accepted

Solution code:
from math import ceil
vals=list(map(int, input().split()))
cnt=0
vals.sort(reverse=True)
cnt += vals[0] - vals[1]
diffmaxmin = vals[0] - (vals[2] + cnt)
if diffmaxmin % 2 == 0:
    cnt += diffmaxmin/2
else:
    cnt += ceil(diffmaxmin/2) + 1

print(int(cnt))

Submission status: Accepted

Solution code:
a = list(map(int,input().split()))
ans = 0
if (a[0]%2+a[1]%2+a[2]%2) == 1:
    a = [i+1 if (i%2)==0 else i for i in a]
    ans += 1
    b,a[a.index(min(a))] = (max(a) - min(a))//2,max(a)
    c,a[a.index(min(a))] = (max(a) - min(a))//2,max(a)
    ans += (b+c)
elif (a[0]%2+a[1]%2+a[2]%2) == 2:
    a = [i+1 if (i%2)==1 else i for i in a]
    ans += 1
    b,a[a.index(min(a))] = (max(a) - min(a))//2,max(a)
    c,a[a.index(min(a))] = (max(a) - min(a))//2,max(a)
    ans += (b+c)
else:
    b,a[a.index(min(a))] = (max(a) - min(a))//2,max(a)
    c,a[a.index(min(a))] = (max(a) - min(a))//2,max(a)
    ans += (b+c)
print(ans)

Submission status: Accepted

Solution code:
num = [int(i) for i in input().split()]
num.sort()
count = 0
a = num[2]-num[1]
count += a//2+a%2
if a%2 == 1:
    num[0]+=1
b = num[2]-num[0]
if b%2 == 0:
    count += b//2
    print(count)
else:
    count += (b+1)//2+1
    print(count)

Submission status: Accepted

Solution code:
import itertools

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

a,b,c = getints()

res = 0
if a % 2 == b % 2 and a % 2 != c % 2:
    a += 1
    b += 1
    res += 1
if b % 2 == c % 2 and c % 2 != a % 2:
    b += 1
    c += 1
    res += 1
if c % 2 == a % 2 and a % 2 != b % 2:
    c += 1
    a += 1
    res += 1

xs = list(sorted([a,b,c]))
while xs[0] != xs[2]:
    xs[0] += 2
    xs = list(sorted(xs))
    res += 1

print(res)

Submission status: Accepted

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

ans = 0
samenum = 0
for i in range(3):
    num = (max(ABC) - ABC[i]) // 2
    ABC[i] += num * 2
    ans += num
    if ABC[i] == max(ABC):
        samenum += 1

if samenum == 2:
    ans += 2
elif samenum == 1:
    ans += 1

print(ans)

Submission status: Accepted

Solution code:
a,b,c = map(int,input().split())
cnt = 0
if a%2 == b%2 and a%2 != c%2:
  a += 1
  b += 1
  cnt += 1
elif a%2 == c%2 and a%2 != b%2:
  a += 1
  c += 1
  cnt += 1
elif b%2 == c%2 and a%2 != b%2:
  b += 1
  c += 1
  cnt += 1
M = max(a,b,c)
print(int(cnt + (M-a)/2 + (M-b)/2 + (M-c)/2))

Submission status: Accepted

Solution code:
lst = [int(i) for i in input().split()]
if len(set(lst))==1:
    print(0)
    exit()

lst.sort()
dist1 = lst[2] - lst[0]
dist2 = lst[2] - lst[1]

if dist1 == dist2:
    print(dist1)
else:
    cnt = dist2
    dist1 -= dist2
    if dist1 % 2 == 0: 
        cnt += dist1 // 2
    else:
        cnt += dist1 // 2 + 2
    print(cnt)

Submission status: Accepted

Solution code:
a,b,c=sorted(map(int,input().split()));d=b-a;print(c-b+d//2+d%2*2)

Submission status: Accepted

Solution code:
*l,=map(int,input().split());a,b,c=sorted(l);d=b-a;print(c-b+d//2+d%2*2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l = list(map(int, input().split()))
l.sort(reverse=True)
x = l[0] - l[1]
y = l[0] - l[2]
count = 0

if x % 2 == 0 and y % 2 == 1:
    x += 1
    count += 1
if y % 2 == 0 and x % 2 == 1:
    y += 1
    count += 1

if x % 2 == 1 and y % 2 == 1:
    count += (x+1)//2
    count += (y-1)//2
    print(count)
elif x % 2 == 0 and y % 2 == 0:
    print((x+y)//2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=list(map(int, input().split()))
t=sorted(s)
ans=(t[2]-t[1])+(t[2]-t[0])
if s[0]%2==0 and  s[1]%2==0 and s[2]%2==0\
or s[0]%2==1 and s[1]%2==1 and s[2]%2==1:
    print(ans//2)
else:
    if (sum(s))%2==1:
        if t[2]%2==0:
            print((ans+3)//2)
        else:
            print(ans//2)
    else:
        if t[2]%2==1:
            print((ans+3)//2)
        else:
            print(ans//2)

Submission status: Accepted

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

Submission status: Accepted

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

X.sort()
fir = (X[2]-X[1])%2
sec = (X[2]-X[0])%2
if (fir == 0 and sec == 0):
	ans = (X[2]-X[1])//2+(X[2]-X[0])//2
elif (fir == 1 and sec == 1):
	ans = (X[2]-X[1])//2+(X[2]-X[0])//2+1
else:
	ans = (X[2]-X[1])//2+(X[2]-X[0])//2+2

print(ans)

Submission status: Accepted

Solution code:
# ABC093-C
tmp = list(map(int, input().split()))
tmp = sorted(tmp)
A = tmp[0]
B = tmp[1]
C = tmp[2]
ans = 0
ca = (C - A) // 2
cb = (C - B) // 2
ans += ca + cb
A = A + ca * 2
B = B + cb * 2
if C == A and C == B:
    print(ans)
elif C == A and C == B + 1:
    print(ans + 2)
elif C == A + 1 and C == B:
    print(ans + 2)
elif C == A + 1 and C == B + 1:
    print(ans + 1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,C=map(int,input().split())
x=max(A,B,C)
y=(x-A)+(x-B)+(x-C)
if y%2==1:
  y+=3
print(y//2)

Submission status: Accepted

Solution code:
a, b, c = sorted([int(i) for i in input().split()])
ans = 0
ans += (b - a) // 2 # (b or b - 1) b c
ans += (b - a) % 2 # b b c
c += (b - a) % 2 # b b (c or c + 1)
ans += (c - b) # c c c

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
Z = [int(s) for s in input().split()]
Z.sort()
d = 2 * Z[2] - Z[0] - Z[1]
print(d // 2 if d % 2 == 0 else d // 2 + 2)

Submission status: Accepted

Solution code:
a,b,c = map(int,input().split())
ssum = a+b+c
target = max(a,b,c)*3
i = 0
while True:
  if(ssum%3==0 and ssum>=target): break;
  ssum += 2
  i += 1
print(i)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    s.sort()
    if s == ["a", "b", "c"]:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    a, b, k = LI()
    ans = []
    for i in range(a, min(a + k, b + 1)):
        ans.append(i)
    for i in range(max(b - k + 1, a + k), b + 1):
        ans.append(i)
    for i in ans:
        print(i)
    return

#C
def C():
    abc= LI()
    abc.sort()
    a,b,c = abc
    a1 = (c - a) % 2
    b1 = (c - b) % 2
    if a1 and b1:
        print((c - a) // 2 + (c - b) // 2 + 1)
        return
    if a1 or b1:
        print((c - a) // 2 + (c - b) // 2 + 2)
        return
    print((c - a) // 2 + (c - b) // 2 )

    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()

Submission status: Accepted

Solution code:
alist=[int(i) for i in input().split()]
alist.sort()
a=alist[0]
b=alist[1]
c=alist[2]
if (c-a) %2 !=0 and (c-b)%2 !=0:
	print((c-a) //2+(c-b) //2+1)
elif (c-a) %2 !=0 or (c-b)%2 !=0:
	print((c-a) //2+(c-b) //2+2)
else:
	print((c-a) //2+(c-b) //2)

Submission status: Accepted

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

def g(t, x):
  res = 0
  while t > x:
    x += 2
    res += 1
  if t < x:
    res += x - t
  return res
  
def f(t, A, B, C):
  return g(t, A) + g(t, B) + g(t, C)

ans = 99999
for t in range(0, 401):
  ans = min(ans, f(t, A, B, C))
print(ans)