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:
from copy import *
from sys import *
import math
import queue
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


def main():
	o = list(map(int,input().split()))
	m = max(o)
	o.remove(m)
	diff = 2*m - sum(o)
	if(diff%2==0):
		print(diff//2)
	else:
		m+=1
		o[0]+=1
		print((2*m-sum(o))//2 + 1)


def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(m,n):
	x = max(m,n)
	y = min(m,n)
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	return y

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# ABC 93, C - same integers
import itertools

A = [int(el) for el in input().split(' ')]

y = max(A)
for x in itertools.count(max(A)):
    if (3*x - sum(A)) % 2 == 0:
        y = x
        break

k = (3*x - sum(A))/2
print(int(k))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C = map(int, 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)

Submission status: Accepted

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

X.sort()

A, B, C = X
k = 2*C - A - B
ans = k // 2
if k % 2 != 0:
    ans += 2

print(ans)

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
count = max(a, b, c)*3 - a - b - c

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

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
max_num = max(A, B, C)
count = A + B + C
ans = 0
while True:
    if count % 3 == 0 and count / 3 >= max_num:
        break
    else:
        count += 2
        ans += 1
print(ans)

Submission status: Accepted

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

flg = True
cnt = a + b + c
cnt_max = max(a, b, c)
ans = 0
while(flg):
    if cnt % 3 == 0 and cnt / 3 >= cnt_max:
        flg = False
    else:
        cnt += 2
        ans += 1

print(ans)

Submission status: Accepted

Solution code:

# 操作1はひとつ選んで1減らす　と同じ。
# 基本的には最大値に操作1を適用、操作2はひとつだけ2足りない時のみ適用。
# 差が2のとき、最大値に操作1 x2回 = 最小値と中間値にそれぞれ操作2

# sort -> A<B<C
# AをBに一致させる cnt+=差を2で割った商+2*余り
# CをBに一致させる cnt+=C-B

X=list(map(int,input().split()))
X.sort()
q=(X[1]-X[0])//2
r=(X[1]-X[0])%2
ans=q+2*r+(X[2]-X[1])
print(ans)

Submission status: Accepted

Solution code:
def diff(a):
    m = min(a)
    return sum(map(lambda x: x - m, a))

a, b, c = map(int, input().split())
cnt = 0
while a != b or b != c:
    next = []
    next.append([a + 2, b, c])
    next.append([a, b + 2, c])
    next.append([a, b, c + 2])
    next.append([a + 1, b + 1, c])
    next.append([a + 1, b, c + 1])
    next.append([a, b + 1, c + 1])
    d = list(map(lambda x: diff(x), next))
    m = min(d)
    i = d.index(m)
    a, b, c = tuple(next[i])
    # print(a, b, c)
    cnt += 1
    # if m == 0:
    #     break
print(cnt)

Submission status: Accepted

Solution code:
import math
buff = list(map(int, input().split()))










# buff = [A, B, C]

buff.sort()
med = buff[2]-buff[1]

buff[0] = buff[0]+med
tyuk = buff[2]-buff[0]

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

Submission status: Accepted

Solution code:
A,B,C=map(int, input().split())
odd=[]
even=[]
for x in [A,B,C]:
    if x%2==0:
        even.append(x)
    else:
        odd.append(x)
cnt = 0
ns = []
if len(even) == 2:
    for x in even:
        cnt = 1
        ns.append(x+1)
else:
    ns.extend(even)
if len(odd) == 2:
    for x in odd:
        cnt = 1
        ns.append(x+1)
else:
    ns.extend(odd)

ns.sort()
max_v = max(ns)
for x in ns:
    cnt += (max_v-x) // 2

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys

sys.setrecursionlimit(10**7)


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h() if m > 1 else typ(input()) for _ in range(n)]


def main():
    A, B, C = read_h()

    m3 = max(A, B, C) * 3
    sm = sum((A, B, C))
    if m3 % 2 == sm % 2:
        print((m3 - sm) // 2)
    else:
        print((m3 + 3 - sm) // 2)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

E = [a for a in A if a % 2 == 0]
O = [a for a in A if a % 2 == 1]

ans = 0

if len(E) == 2:
    ans += 1
    E = [e + 1 for e in E]
    A = E + O

if len(O) == 2:
    ans += 1
    O = [o + 1 for o in O]
    A = E + O

biggest = max(A)
A = [biggest - a for a in A]
print(ans + sum(A) // 2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np
import statistics
from statistics import mean, median,variance,stdev
import math

def main():
	A, B, C = map(int, input().split(" "))
	
	ans = 0
	todo = 0
	base = max(A,B,C)
	
	if base > A:
		tmp = (base - A) // 2
		ans += tmp
		if (base - A) % 2 == 1:
			todo += 1
	if base > B:
		tmp = (base - B) // 2
		ans += tmp
		if (base - B) % 2 == 1:
			todo += 1
	if base > C:
		tmp = (base - C) // 2
		ans += tmp
		if (base - C) % 2 == 1:
			todo += 1
			
	if todo == 2:
		ans += 1
	if todo == 1:
		ans += 2
		
	print(ans)
			
	
if __name__ == "__main__":
	main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c = map(int, raw_input().split())
t = 0
while a != b or b != c or c != a:
    a, b, c = sorted([a, b, c])
    t += (c-a)/2
    a += (c-a)/2 * 2
    t += (c-b)/2
    b += (c-b)/2 * 2
    a, b, c = sorted([a, b, c])
    if a == b and a == c - 1:
        a += 1
        b += 1
        t += 1
    elif b == c and a == b - 1:
        a += 2
        t += 1
print t

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c = map(int, input().split())
di = 3*max(a,b,c) - (a+b+c)

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

Submission status: Accepted

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

Submission status: Accepted

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

li.sort()

a = li[1] - li[0]
b = li[2] - li[1]
c = li[2] - li[0]

cnt = 0

while True:
    if a != 0:
        if a % 2 == 0:
            a -= 2
            c -= 2
            cnt += 1
        else:
            a -= 1
            b += 1
            cnt += 1
    else:
        cnt += b
        break
    
print(cnt)

Submission status: Accepted

Solution code:
# a<=b<=cとしてc-aとc-bの差が偶数なら2で割ればいいし奇数ならceil+1
a, b, c = sorted(list(map(int, input().split())))
if (c - a + c - b) % 2 == 0:
    print((c - a + c - b) // 2)
else:
    print((c - a + c - b) // 2 + 2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

abc.sort()
dif1 = abc[2] - abc[1]
dif2 = abc[1] - abc[0]
if dif2 % 2 == 0:
    print(dif1 + dif2//2)
else:
    print(dif1 + (dif2+1)//2 + 1)

Submission status: Accepted

Solution code:
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]
    a = list(int(_) for _ in input().split())
    a.sort()
    A = a[0]
    B = a[2]
    C = a[1]    
    if (C-A)%2 == 0:
        print((B-C)+math.ceil((C-A)/2))
    else:
        print((B-C)+math.ceil((C-A)/2)+1)
        
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

L.sort()

cnt = 0
while L[1] != L[2]:
    L[0] += 1
    L[1] += 1
    cnt += 1

if (L[1] - L[0]) % 2 == 1:
    L[1] += 1
    L[2] += 1
    cnt += 1

cnt += (L[1] - L[0])//2

print(cnt)

Submission status: Accepted

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

count = 0
flag = 0

while flag == 0:
    if a_s[0] == a_s[1] and a_s[1] == a_s[2]:
        flag = 1
        break
    a_s = sorted(a_s)
    count += 1
    if a_s[2] > a_s[1] and a_s[2] > a_s[0]:
        a_s[0] += 1
        a_s[1] += 1
    else:
        a_s[0] += 2

print(count)

Submission status: Accepted

Solution code:

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

lis.sort()


if (lis[2] % 2 == lis[1] % 2 and lis[2] % 2 != lis[0] % 2 ) or (lis[2] % 2 == lis[0] % 2 and lis[2] % 2 != lis[1] % 2 ):
    tall = lis[2] + 1

else:
    tall = lis[2]

print ((3*tall - lis[0] - lis[1] - lis[2]) // 2)

Submission status: Accepted

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

if (max(a)-a[0])%2==0 and (max(a)-a[1])%2==0:
    print(int((max(a)*3-sum(a))/2))
elif (a[2]-a[0])%2==1 and (a[2]-a[1])%2==1:
    print(int((max(a)*3-sum(a))/2))
else:
    print(int((max(a)*3-sum(a))/2)+2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c = map(int, input().split())
aa,bb,cc = a%2, b%2, c%2
res = 0
if aa==0 and bb == 1 and cc == 0:
    res += 1
    a,c = a+1, c+1
elif aa==1 and bb == 0 and cc == 0:
    res += 1
    b,c = b+1, c+1
elif aa == 0 and bb == 0 and cc == 1:
    res += 1
    b, a = b + 1, a + 1
elif aa==0 and bb == 1 and cc == 1:
    res += 1
    b,c = b+1, c+1
elif aa==1 and bb == 0 and cc == 1:
    res += 1
    a,c = a+1, c+1
elif aa == 1 and bb == 1 and cc == 0:
    res += 1
    b, a = b + 1, a + 1
l = [a,b,c]
l.sort()
res += (l[2] - l[1]) // 2
res += (l[2] - l[0]) // 2
print(res)

Submission status: Accepted

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

sorted_num = sorted(numbers)

maximum = max(numbers)
second_max = sorted_num[1]
minimum = min(numbers)

first_step = (maximum - second_max) // 2
second_step = (maximum - minimum) // 2

if (maximum - second_max) % 2 == 1 and (maximum - minimum) % 2 == 1:
    first_step += 1
if (maximum - second_max) % 2 == 1 and (maximum - minimum) % 2 == 0:
    first_step += 2
if (maximum - second_max) % 2 == 0 and (maximum - minimum) % 2 == 1:
    first_step += 2
print(first_step + second_step)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
b = input().split()
a = []
for i in b:
    a.append(int(i))

a.sort()
#print(a)
x1 = int(a[2]) -  int(a[0])
x2 = int(a[2]) -  int(a[1])

#print(x1)
#print(x2)

d1 = divmod(x1,2)
d2 = divmod(x2,2)

total = 0
amari = 0

if d1[1] == 0:
    total += d1[0]
else:
    total += d1[0]
    amari += d1[1]

if d2[1] == 0:
    total += d2[0]
else:
    total += d2[0]
    amari += d2[1]

#print(total)

if amari != 0:
    if amari % 2 == 0:
        total += 1
    else:
        total += 2

print(total)

Submission status: Accepted

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

ABC_mod = [i%2 for i in ABC]
ABC_plus_1 = []
if ABC_mod.count(1) == 1 or ABC_mod.count(1) == 3:
  for i in range(3):
    ABC_plus_1.append(1-ABC_mod[i])
else:
  ABC_plus_1 = ABC_mod
for i in range(3):
  ABC[i] = ABC[i] + ABC_plus_1[i]

ABC.sort()
ABC_plus_2 = (ABC[-1]-ABC[0])//2 + (ABC[-1]-ABC[1])//2

ans = sum(ABC_plus_1)//2 + ABC_plus_2
print(ans)

Submission status: Accepted

Solution code:
A,B,C = map(int,input().split())
L = [A,B,C]
t = 0
L.sort()
if L[0] == L[1] == L[2]:
  print(0)
else:
  for i in range(3):
    if L[i]%2 == 0:
      t += 1
  if t == 3 or t == 0:
    print((L[2]-L[0])//2+(L[2]-L[1])//2)
  elif t == 2:
    if L[0]%2 != 0:
      L[1] += 1
      L[2] += 1
      print(1+(L[2]-L[0])//2+(L[2]-L[1])//2)
    elif L[1]%2 != 0:
      L[0] += 1
      L[2] += 1
      print(1+(L[2]-L[0])//2+(L[2]-L[1])//2)
    else:
      L[0] += 1
      L[1] += 1
      print(1+(L[2]-L[0])//2+(L[2]-L[1])//2)
  else:
    if L[0]%2 == 0:
      L[1] += 1
      L[2] += 1
      print(1+(L[2]-L[0])//2+(L[2]-L[1])//2)
    elif L[1]%2 == 0:
      L[0] += 1
      L[2] += 1
      print(1+(L[2]-L[0])//2+(L[2]-L[1])//2)
    else:
      L[0] += 1
      L[1] += 1
      print(1+(L[2]-L[0])//2+(L[2]-L[1])//2)

Submission status: Accepted

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

if a%2 == b%2 and b%2 == c%2:
    x = sorted([a,b,c])
    print((2*x[2]-x[1]-x[0])//2)
else:
    x = [a,b,c]
    cnt = 0
    for i in range(3):
        if x[i] % 2 == 0:
            cnt += 1
    if cnt == 1:
        for i in range(3):
            if x[i] % 2 == 1:
                x[i] += 1
        x.sort()
        print((2*x[2]-x[1]-x[0])//2 +1)
    else:
        for i in range(3):
            if x[i] % 2 == 0:
                x[i] += 1
        x.sort()
        print((2*x[2]-x[1]-x[0])//2 +1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
ans=0
[a,b,c]=sorted([a,b,c],reverse=True)
d,e,f=a%2,b%2,c%2
if d==e and e==f:
  case=0
  print((2*a-b-c)//2)
elif (d!=e or d!=f) and e==f:
  case=1
  print((2*a-b-c)//2)
else:
  case=2
  print(1+((a+1)*2-1-b-c)//2)

Submission status: Accepted

Solution code:
nums = [int(i) for i in input().split()]
ans = 0
jud = [i%2 for i in nums]
if jud != [1,1,1] and jud != [0,0,0]:
    if jud.count(0)>jud.count(1):
        for i,a in enumerate(jud):
            if a == 0:  nums[i] += 1
    else:
        for i,a in enumerate(jud):
            if a == 1:  nums[i] += 1
    ans += 1

mn = max(nums)
#print(nums)
for num in nums:
    ans += (mn-num)//2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l = sorted(list(map(int, input().split())))
aq = (l[2] - l[0]) // 2
ar = (l[2] - l[0]) % 2
bq = (l[2] - l[1]) // 2
br = (l[2] - l[1]) % 2
cnt = aq + bq

if ar == 1 and br == 1:
    print(cnt + 1)
elif ar == 1 or br == 1:
    print(cnt+2)
else:
    print(cnt)

Submission status: Accepted

Solution code:
N = input().split()
NN = []
for i in range(3):
    NN.append(int(N[i]))
NN.sort()
A = NN[0]
B = NN[1]
C = NN[2]

count = 0

if A == B:
    count = 0
elif A%2 != B%2:
    A = A+1
    C = C+1
    count = count +1
while(A != B):
    A = A+2
    count = count+1
count = count + (C-A)
print(count)

Submission status: Accepted

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

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

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

while b < c-1:
    b += 2
    cnt += 1

if a == c and b == c:
    print(cnt)
elif a == c or b == c:
    print(cnt+2)
else:
    print(cnt+1)

Submission status: Accepted

Solution code:
abc = list(map(int, input().split()))
m = max(abc)
t = sum(abc)

if (m * 3) % 2 != t % 2:
    m = m + 1

print(int((m * 3 - t) / 2))

Submission status: Accepted

Solution code:
num = [int(x) for x in input().split()]
ans = 0

while((num[0] == num[1] and num[1] == num[2]) == 0):
    ans += 1
    num.sort()
    if num[1] == num[2]:
        num[0] += 2
    else :
        num[0] += 1
        num[1] += 1
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

abc = list(map(int, input().split()))
cnt = 0
abc.sort()
if (abc[1]%2 == 1 and abc[0]%2 == 0) or (abc[0]%2 == 1 and abc[1]%2 == 0):
    cnt += 1
    abc[1] += 1
    abc[2] += 1
cnt += abc[2]-abc[1] + math.floor((abc[1]-abc[0])/2)
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num = list(map(int,input().split()))
a = 0
for i in num:
    a += max(num) - i
if a % 2 == 0:
    print((max(num)*3-sum(num))//2)
else:
    print(((max(num)+1)*3-sum(num))//2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  l=LI()
  l.sort()

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

  if a%2==0:
    return a//2
  return a//2+2

print(main())

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
while not (A == B == C):
    A, B, C = sorted([A, B, C])
    if A + 2 <= C:
        A += 2
    else:
        A += 1
        B += 1
    ans += 1

print(ans)

Submission status: Accepted

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

def solve(A, B, C):
    # C - A, C - B
    # odd    even
    # even   even
    # even   odd
    count = 0

    if A < B:
        if (B-A)% 2 == 0:
            count += (B-A)//2
            A = B
            # A == B <= C
        else:
            A += 1
            assert (B-A) % 2 == 0
            C += 1
            count += 1
            count += (B-A)//2
            A = B
    assert A == B
    if B < C:
        count += (C-B)

    return count

print(solve(A, B, C))

Submission status: Accepted

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

max_number = max(abc)
abc.remove(max_number)
others = abc

count = 0
count += (max_number - max(others))

gap = (max_number - (min(others) + count))
if gap % 2 == 0:
  count += gap / 2
else: 
  count += ((gap + 1) / 2) + 1

print(int(count))

Submission status: Accepted

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

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

ans = 0
while 1:
    if tmp[0] == tmp[1] and tmp[1] == tmp[2]:
        break
    else:
        if tmp[1] != tmp[2]:
            tmp[0] += 1
            tmp[1] += 1
            ans += 1
        elif tmp[2] - tmp[0] > 1:
            tmp[0] += 2
            ans += 1
        else:
            tmp[1] += 1
            tmp[0] += 1
            ans += 1
        tmp.sort()
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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&1:
  y += 3
answer = y//2
print(answer)

Submission status: Accepted

Solution code:
a,b,c = map(int,input().split())
max_ = max([a,b,c])
ls = [a,b,c]

if ls[0]%2 == ls[1]%2 == ls[2]%2:
    cnt = 3*max_- sum(ls)
    print(int(cnt/2))


else:
    ls.remove(max_)
    if ls[0]%2 == ls[1]%2:
        cnt = 2*max_- sum(ls) -2
        print(int(cnt/2 +1))    
    else:
        cnt = 2*max_- sum(ls) + 1
        print(int(cnt/2 +1))

Submission status: Accepted

Solution code:
a=list(map(int,input().split()))
m=max(a)
for i in range(3):
     a[i]-=m
s=-sum(a)
if s%2==0:
     print(s//2)
else:
     print(s//2+2)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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


def solve(A: int, B: int, C: int):
    L = [A,B,C]
    L.sort()
    res = L[2]*2 - L[0] - L[1]
    if res % 2 == 1:
        res += 3

    print(res//2)



# Generated by 1.1.4 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()))
ans = 0
a.sort()
while a[0]+2 <= a[2]:
  a[0] = a[0] + 2
  a.sort()
  ans += 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
inpt = map(int, raw_input().split())
inpt.sort()
A = inpt[0]
B = inpt[1]
C = inpt[2]
tmp1 = (C-A)/2
tmp2 = (C-B)/2
A += tmp1*2
B += tmp2*2
memo = []
queue = [[tmp1+tmp2, [A, B, C]]]
while queue != []:
	now = queue.pop(0)
	if now[1][0] == now[1][1] and now[1][0] == now[1][2]:
		print now[0]
		break
	next = []
	for i in range(0, 3):
		lst1 = [now[1][0], now[1][1], now[1][2]]
		lst2 = [now[1][0]+1, now[1][1]+1, now[1][2]+1]
		lst1[i] += 2
		lst2[i] -= 1
		next.append(lst1)
		next.append(lst2)
	for i in range(0, 6):
		if next[i] not in memo:
			queue.append([now[0]+1, next[i]])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num1, num2, num3 = input().split(" ")
numList = [int(num1),int(num2),int(num3)]
numList.sort(reverse=True)
maxNum = numList[0]
midNum = numList[1]
minNum = numList[2]

count = 0

if midNum % 2 == 0 and minNum % 2 == 0:
    count += (midNum - minNum) // 2
    count += (maxNum - midNum)
elif midNum % 2 == 1 and minNum % 2 == 1:
    if maxNum % 2 == 0:
        maxNum += 2
        midNum += 2
        midNum += 2
        count += (midNum - minNum) // 2
        count += (maxNum - midNum)
        count += 2
    else:
        count += (midNum - minNum) // 2
        count += (maxNum - midNum)
else:
    if midNum % 2 == 0:
        maxNum += 1
        minNum += 1
        count += (midNum - minNum) // 2
        count += (maxNum - midNum)
        count += 1
    else:
        maxNum += 1
        midNum += 1
        count += (midNum - minNum) // 2
        count += (maxNum - midNum)
        count += 1
print(count)