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:
"""解説から
1.  A, B, Cの総和をabcとする。
2.  可能な操作は2種類あるが、abcの増加は必ず2になる
3.  2の前提からabcの偶奇を変更することはできない
4.  A, B, Cそれぞれに操作を加えて、A==B==Cとなった時、それぞれの値をXとする
5.  A, B, Cのいずれの値も減少させることはできないので、max(A, B, C)<=Xとなる
6.  abcの総和を3Xにできるとき、そのXが最終的なA, B, Cの値となる
7.  3と6の前提から、Xとabcの偶奇は一致している必要がある
8.  XとX+1の偶奇は異なるので、Xで無理ならX+1が最終的なA, B, Cの値となる
9.  A, B, Cのいずれかに増加させる値の総和は3X-abcで求めることができる
10. 2と9の前提から操作回数は(3X-abc)//2で求めることができる
"""
ABC = tuple(map(int, input().split()))
abc = sum(ABC)  # 1
X = max(ABC)  #4, 5
if X % 2 != abc % 2:  # 7
    X += 1  # 8
ans = (3 * X - abc) // 2  # 10
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c=sorted(map(int,input().split()))
count=0
A,B=(c-a)//2,(c-b)//2
a+=A*2
b+=B*2
count+=A+B
if a==b==c:
    print(count)
elif a==b:
    print(count+1)
else:
    print(count+2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

l = [A,B,C]
flg = [A%2,B%2,C%2]
cnt = 0
if flg.count(1) == 1:
    for i in range(3):
        if flg[i] == 0:
            l[i] += 1
    cnt += 1
        
elif flg.count(1) == 2:
    for i in range(3):
        if flg[i] == 1:
            l[i] += 1
    cnt += 1

mx = max(l)
SUM = 0
for i in l:
    SUM += (mx - i)
print(SUM//2+cnt)

Submission status: Accepted

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

    ans = 0
    while num[0] != num[1] or num[1] != num[2]:
        tmp = max(num)
        if num.count(tmp) == 2:
            num[num.index(min(num))] += 2
        else:
            num[num.index(max(num))] -= 1
        ans += 1

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0

while True:
  N.sort()
  if N[0] == N[1] == N[2]:
    print(cnt)
    exit()

  if N[1] - N[0] > 1:
    N[0] += 2
    cnt += 1
  elif N[2] - N[1] > 1:
    N[1] += 2
    cnt += 1
  elif N[2] - N[0] == 2:
    N[0] += 2
    cnt += 1
  elif N[0] == N[1] and N[2] - N[1] == 1:
    N[0] += 1
    N[1] += 1
    cnt += 1
  elif N[1] == N[2]:
    N[0] += 2
    cnt += 1

Submission status: Accepted

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

A.sort()
reg = 0
diff_1 = (A[2] - A[0]) // 2
reg += diff_1
diff_2 = (A[2] - A[1]) // 2
reg += diff_2
A[0] += 2 * diff_1
A[1] += 2 * diff_2

A.sort()
if A[0]==A[1]==A[2]:
    print(reg)
elif A[0]==A[1]:
    print(reg+1)
else:
    print(reg+2)

Submission status: Accepted

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

a.sort()
if (a[1]-a[0]) % 2 == 0:
    print((a[2]*3 - sum(a)) // 2)
else:
    print(((a[2]+1)*3 - sum(a)) // 2)

Submission status: Accepted

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


def plusOne(x, y):
    return x+1, y+1


def plusTwo(x):
    return x+2


while True:
    if a[0] == a[1] == a[2]:
        break
    elif a[1] == a[2]:
        a[0] = plusTwo(a[0])
    else:
        a[0], a[1] = plusOne(a[0], a[1])

    a.sort()
    count += 1

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if a[2] != a[1] and a[1] != a[0] and a[2] != a[0]:
  sum = a[2]-a[1]
  for i in range(a[2]-a[1]):
    a[1] += 1
    a[0] += 1  
  for i in range(10**12):
    a[0] += 2
    count += 1
    if a[0] >= a[1]:
      break
      
  if a[0] == a[1]:
    print(sum + count)
  elif a[0] > a[1]:
    print(sum + count + 1)

elif a[2] == a[1] and a[1] != a[0]:
  for i in range(10**4):
    a[0] += 2
    count += 1
    if a[0] >= a[1]:
      break
  
  if a[0] == a[1]:
    print(count)
  elif a[0] > a[1]:
    print(count + 1)
    
elif a[0] == a[1] and a[1] != a[2]:
  print(a[2]-a[1])
  
elif a[1] == a[2] and a[2] == a[0]:
  print(0)

Submission status: Accepted

Solution code:
from sys import stdin

a, b, c = [int(x) for x in stdin.readline().strip().split()]
guki = [a%2, b%2, c%2]
cnt = 0
if guki[0]==guki[1]==guki[2]:
  # 全部同じ
  pass
else:
  cnt += 1
  # 揃える
  if guki[0] == guki[1]:
    # cだけ違う
    a += 1
    b += 1
  elif guki[0] == guki[2]:
    # bだけ違う
    a += 1
    c += 1
  else:
    # aだけ違う
    b += 1
    c += 1
    
cnt += (max([a,b,c]) - a) / 2
cnt += (max([a,b,c]) - b) / 2
cnt += (max([a,b,c]) - c) / 2

print(int(cnt))

Submission status: Accepted

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

Submission status: Accepted

Solution code:

import numpy as np

nums = list(map(int, input().split()))
# N = int(input())

nums.sort()

min_  = nums[0]
mid = nums[1]
max_ = nums[2]

ans = 0
if (max_ - mid) % 2 == 1:
    mid += 1
    min_ += 1
    ans += 1
ans += (max_ - mid) // 2


if (max_ - min_) % 2 == 1:
    mid += 1
    max_ += 1
    ans += 1
ans += (max_ - min_) // 2

print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

abc = [a,b,c]
abc.sort()

aa = abc[0]
bb = abc[1]
cc = abc[2]

diff = bb-aa
ans = 0
if diff %2==0:
    ans += diff//2
    aa = bb
else:
    ans += diff//2 + 1
    aa = bb
    cc += 1

ans += (cc-bb)*2//2

print(ans)

Submission status: Accepted

Solution code:
A = list(map(int, input().split()))
A = sorted(A)
m = max(A)
B = [(m - a) // 2 for a in A]
count = 0
if len(set(A)) == 1:
    print(0)
elif len(set(A)) == 2:
    count = sum(B)
    if A[0] % 2 != A[2] % 2:
        if A[0] == A[1]:
            count += 1
        else:
            count += 2
    print(count)
else:
    count = sum(B)
    if A[0] % 2 == A[1] % 2 == A[2] % 2:
        pass
    elif A[0] % 2 == A[1] % 2:
        count += 1
    else:
        count += 2
    print(count)

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
x_list = [int(x) for x in input().split()]
temp_list = [[], []]
for i in range(3):
    temp_list[x_list[i] % 2].append(i)
temp = len(temp_list[0])
ans = 0
if temp == 1:
    x_list[temp_list[1][0]] += 1
    x_list[temp_list[1][1]] += 1
    ans += 1
elif temp == 2:
    x_list[temp_list[0][0]] += 1
    x_list[temp_list[0][1]] += 1
    ans += 1
x_max = max(x_list)
ans += sum([gap // 2 for gap in [x_max - x for x in x_list]])
print(ans)

Submission status: Accepted

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

l = sorted(l,reverse = True)

a,b,c=l[0],l[1],l[2]

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

Submission status: Accepted

Solution code:
n = list(map(int,input().split()))
ki = []
gu = []
count = 0

for x in range(3):
    if n[x] %2 == 0:
        ki.append(x)
    else:
        gu.append(x)

if len(gu) < len(ki) != 3:
    n[ki[0]] += 1
    n[ki[1]] += 1
    count +=1
elif len(ki) < len(gu) != 3:
    n[gu[0]] += 1
    n[gu[1]] += 1
    count +=1


n.sort(reverse=True)
count += (n[0] -n[1]) / 2
count += (n[0] -n[2]) / 2

print(int(count))

Submission status: Accepted

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

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

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

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

S = IL()
S.sort()

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


c1 = d1//2
c2 = d2//2

if d1%2 == d2%2 == 1:
  a = 1
elif d1%2 == d2%2 == 0:
  a = 0
else:
  a = 2
  
P(c1+c2+a)

Submission status: Accepted

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

count += C - B
q, r = divmod(C - (A + (C - B)), 2)
if r == 0:
    count += q
else:
    count += q + 2

print(count)

Submission status: Accepted

Solution code:
def main():
    A, B, C = list(map(int, input().split(' ')))
    cnt = 0
    if A % 2 == B % 2 != C % 2:
        cnt = 1
        A += 1
        B += 1
    elif B % 2 == C % 2 != A % 2:
        cnt = 1
        B += 1
        C += 1
    elif C % 2 == A % 2 != B % 2:
        cnt = 1
        C += 1
        A += 1
    cnt += (3 * max([A, B, C]) - (A + B + C)) // 2
    print(cnt)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l=list(map(int,input().split()))
ans=0
l.sort()
#print(l)
if (l[1]-l[0])%2!=0:#最小と真ん中の値を偶数差にする
    l[1]+=1
    l[2]+=1
    ans+=1
#print(l)
x=(l[1]-l[0])//2#l[0]を2足す回数
l[0]+=(2*x)
ans+=x
#print(l)
y=(l[2]-l[1])
ans+=y
print(ans)

Submission status: Accepted

Solution code:
def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    #a, b, c = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    A = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    cnt = 0
    while not (A[0] == A[1] and A[0] == A[2]):
        A = sorted(A)
        if A[2] - A[0] >=2:
            A[0] += 2
        else:
            A[0] += 1
            A[1] += 1
        cnt += 1

    print(cnt)


resolve()

Submission status: Accepted

Solution code:
num_list = [int(i) for i in input().split()]
max_num = max(num_list)
res = 0
for i,n in enumerate(num_list):
  while max_num >= num_list[i]+2:
    num_list[i] +=2
    res +=1
min_num = min(num_list)
mins = len([x for x in num_list if x==min_num])
if mins==3:
  print(res)
elif mins==2:
  print(res+1)
else:
  print(res+2)

Submission status: Accepted

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

if a == b and b == c:
  ans += 0
elif a == b and b != c:
  ans += 1
else:
  ans += 2

print(ans)

Submission status: Accepted

Solution code:
def  main():
  A = list(map(int, input().split()))
  A = sorted(A)
  if A[0] %2 == A[1] % 2:
    print(A[2]-max(A[0], A[1])+abs(A[0]-A[1])//2)
  else:
    print(1+A[2]-max(A[0], A[1])+(abs(A[0]-A[1])+1)//2)
if __name__ == "__main__":
  main()

Submission status: Accepted

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

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

ans = 0

while ABC_lis[0] < ABC_lis[1]:
    ABC_lis[0]=  ABC_lis[0] + 2
    ans = ans + 1

if ABC_lis[0] > ABC_lis[1]:
    ABC_lis[1] = ABC_lis[1] + 1
    ABC_lis[2] = ABC_lis[2] + 1
    ans = ans + 1

while ABC_lis[1] < ABC_lis[2]:
    ABC_lis[0] = ABC_lis[0] + 1
    ABC_lis[1] = ABC_lis[1] + 1
    ans = ans + 1

print(ans)

Submission status: Accepted

Solution code:
ABC = list(map(int,input().split()))
count = 0
while True:
    ABC = list(sorted(ABC))
    if ABC[0] +2 <= ABC[2]:
        ABC[0] += 2
        count += 1
    elif ABC[0] < ABC[2]:
        ABC[0] += 1
        ABC[1] += 1
        count += 1
    if max(ABC) == min(ABC):
        break
print(count)

Submission status: Accepted

Solution code:
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
ABC = list(map(int,input().split()))

d = max(ABC)*3 - sum(ABC)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
while True:
  diff = max(l) - min(l)
  if diff == 0:
    break
  elif diff % 2 == 0:
    l[l.index(min(l))] += 2
    ans += 1
  else:
    add_nums = [i for i in range(3) if i != l.index(max(l))]
    for num in add_nums:
      l[num] += 1
    ans += 1

print(ans)

Submission status: Accepted

Solution code:
A = list(map(int, input().split()))
A.sort()
c = 0
a1 = A[2] - A[1]
a2 = A[2] - A[0]
if (a2 - a1) % 2 != 0:
    c += 1
    A[2] += 1
    if a1 < a2:
        A[0] += 1
    else:
        A[1] += 1
a1 = A[2] - A[1]
a2 = A[2] - A[0]
if a1 < a2:
    c += a1
    c += (a2 - a1) / 2
else:
    c += a2
    c += (a1 - a2) / 2
print(int(c))

Submission status: Accepted

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

#a = [7,17,19]

a = sorted(a)

ans = 0

if a[2] - a[1] >= 2 :
  x = int( (a[2]-a[1]) / 2 )
  ans += x
  a[1] += 2*x

if a[1] - a[0] >= 2 :
  x = int( (a[1]-a[0]) / 2 )
  ans += x
  a[0] += 2*x

b = [0] * 3
b[2] = a[2] - a[0]
b[1] = a[1] - a[0]
b[0] = 0

if b == [0,0,2]:
  ans += 2
elif b == [0,0,1]:
  ans += 1
elif b == [0,1,2]:
  ans += 3
elif b == [0,1,1]:
  ans += 2

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

tmp = max([A, B, C]) * 3 - A - B - C

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

Submission status: Accepted

Solution code:
import math
import copy

a,b,c = map(int,input().split())
if (a > b)and(a > c):
    mx = a
    if b > c:
        md = b
        mn = c
    else:
        md = c
        mn = b
elif (a > b)or(a > c):
    md = a
    if b > c:
        mx = b
        mn = c
    else:
        mx = c
        mn = b
else:
    mn = a
    if b > c:
        mx = b
        md = c
    else:
        mx = c
        md = b
neko = mx-md
if mx != mn+neko:
    nya = mx - (mn+neko)
    neko += math.ceil(nya/2) + nya%2
print(neko)

Submission status: Accepted

Solution code:
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

lis=sorted(LI())
count=0
while lis[0]+2<lis[2]:
    lis[0]+=2
    count+=1
while lis[1]+2<lis[2]:
    lis[1]+=2
    count+=1
#print(count)
#print(lis)
u=lis[0]
for i in range(3):
    lis[i]-=u
#print(lis)
ad=3
if lis==[0,0,0]:
    ad=0
elif lis==[0,0,1]:
    ad=1
elif lis==[0,1,1]:
    ad=2
elif lis==[0,1,2]:
    ad=3
elif lis==[0,0,2]:
    ad=2
elif lis==[0,2,2]:
    ad=1
print(count+ad)

Submission status: Accepted

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

diff1 = c - b
a += diff1
diff2 = c - a
if diff2 % 2 == 0:
    diff2 //= 2
else:
    diff2 += 1
    diff2 //= 2
    diff2 += 1

print(diff1 + diff2)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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

    ABC = [A, B, C]
    ABC.sort()

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
L = list(map(int, input().split()))
odd = L[0] % 2 + L[1] % 2 + L[2] % 2
if odd == 0 or odd == 3:
    ans = (max(L) * 3 - sum(L)) // 2
elif odd == 1:
    if max(L) % 2 == 1:
        ans = (max(L) * 3 - (sum(L) + 2)) // 2 + 1
    else:
        ans = ((max(L) + 1) * 3 - (sum(L) + 2)) // 2 + 1
else:
    if max(L) % 2 == 0:
        ans = (max(L) * 3 - (sum(L) + 2)) // 2 + 1
    else:
        ans = ((max(L) + 1) * 3 - (sum(L) + 2)) // 2 + 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

m = max(A, B, C)
div_a, mod_a = divmod((m - A), 2)
div_b, mod_b = divmod((m - B), 2)
div_c, mod_c = divmod((m - C), 2)

count = sum((div_a, div_b, div_c))
mod = sum((mod_a, mod_b, mod_c))

if mod == 1:
    count += 2
elif mod == 2:
    count += 1

print(count)

Submission status: Accepted

Solution code:
# coding: utf-8
import re
import math
from collections import defaultdict
from collections import deque
import itertools
from copy import deepcopy
import random
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
#@lru_cache(maxsize=None)
readline=sys.stdin.readline
sys.setrecursionlimit(2000000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_pow(a,b):#aはbの累乗数か
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def get_facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:return num
def get_primes(n,type="int"):
    if n==0:
        if type=="int":return []
        else:return [False]
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=1):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=""):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def floor_(n,x=1):
    return x*(n//x)
def ceil_(n,x=1):
    return x*((n+x-1)//x)
    return ret
def seifu(x):
    return x//abs(x)
######################################################################################################
def main():
    A,B,C=map(int,input().split())
    mmax=max([A,B,C])
    ssum=A+B+C
    n=mmax*3-ssum
    if n%2==1:
        mmax+=1
    print((mmax*3-ssum)//2)
main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import queue
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1

arr = readInts()
gu_num = arr[0]%2+arr[1]%2+arr[2]%2

ans = 0

if gu_num not in [0,3]:
	ans+=1
	if gu_num==1:
		if arr[0]%2==1:
			arr[1]+=1
			arr[2]+=1
		elif arr[1]%2==1:
			arr[0]+=1
			arr[2]+=1
		else:
			arr[0]+=1
			arr[1]+=1
	else:
		if arr[0]%2==0:
			arr[1]+=1
			arr[2]+=1
		elif arr[1]%2==0:
			arr[0]+=1
			arr[2]+=1
		else:
			arr[0]+=1
			arr[1]+=1


while not(arr[0]==arr[1] and arr[1]==arr[2]):
	arr[arr.index(min(arr))]+=2
	ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


def input(): return sys.stdin.readline().strip()


def resolve():
    l = list(map(int, input().split()))
    l.sort(reverse=True)
    x=(l[0]-l[1])+(l[0]-l[2])
    if x%2==0:
        print(x//2)
    else:
        print(x//2+2)
resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A= list(map(int,input().split()))
B=len([i for i in A if i%2==1])
ans=0
if B==1 or B==2:
    if B==1:
        A=[i+1 if i%2==0 else i for i in A]
    else:
        A=[i+1 if i%2==1 else i for i in A]
    A.sort(reverse=True)
    maximum=A[0]
    ans+=1+(maximum-A[1])//2+(maximum-A[2])//2
    print(ans)
elif B== 3 or B==0:
    A.sort(reverse=True)
    maximum=A[0]
    print((maximum-A[1])//2+(maximum-A[2])//2)

Submission status: Accepted

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

t = sorted(t)

op1 = (t[1]-t[0])//2+(t[1]-t[0])%2

t[2] += (t[1]-t[0])%2

op2 = t[2]-t[1]

print(op1+op2)