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 = map(int,input().split())

m = max([A,B,C])
a = m*3 - (A+B+C)
if a%2 == 0:
    print(int(a/2))
else:
    print(int((a+3)/2))

Submission status: Accepted

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

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

Submission status: Accepted

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

a, b, c = sorted(l)[::-1]

diff_1 = a - b
diff_2 = a - c
diff = diff_1 + diff_2

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

else:
    print((diff + 3) // 2)

Submission status: Accepted

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

# maxのeven/oddが他の2つとあってれば、2ずつ進めればOK
# maxのeven/oddが他の2つと完全相違（他の2つは一致）なら、その2つを1ずつ増加させて上に帰着
# maxのeven/oddが他の2つのうち片方とあってたら、maxと合致した2つを1ずつ増加させて上に帰着
# というか整理するとmax/min関係なく、まず3つの偶奇をそろえる
# その上でmaxとの距離を2ずつ進める
cnt = 0

p,q,r = A%2, B%2, C%2

if p+q+r == 1:
  if p == 0:
    A += 1
  if q == 0:
    B += 1
  if r == 0:
    C += 1
  cnt += 1

if p+q+r == 2:
  if p == 1:
    A += 1
  if q == 1:
    B += 1
  if r == 1:
    C += 1
  cnt += 1

maxn = max(A,B,C)

cnt += (3*maxn - (A+B+C))//2

print(cnt)

Submission status: Accepted

Solution code:
A = list(map(int, input().split()))
 
even = 0
odd = 0
for a in A:
  if(a%2==0):
    even += 1
 
for i in range(len(A)):
  if(A[i]%2==0 and even == 2):
    A[i] += 1
  elif(A[i]%2==1 and even == 1):
    A[i] += 1
 
if(even == 2 or even == 1):
  ans = 1
else:
  ans = 0
 
for a in A:
  ans += (max(A) - a) // 2
 
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    l = list(sorted(list(map(int, input().split()))))
    ans = 0
    while l[1] < l[2]:
        l[0] += 1
        l[1] += 1
        ans += 1

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

    if l[0] != l[1]:
        ans += 1
    print(ans)



if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
  t = input().split(" ")
  A, B, C = int(t[0]), int(t[1]), int(t[2])
  M = max(A, B, C)
  n = (M-A)//2 + (M-B)//2 + (M-C)//2
  r = (M-A)%2 + (M-B)%2 + (M-C)%2
  if r == 1:
    n += 2
  elif r == 2:
    n += 1
  print(n)
main()

Submission status: Accepted

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

def is_even(n):
  if n % 2 == 0:
    return True
  else:
    return False

def f(a,b,c_max):
  return (2 * c_max - a - b) // 2

num_even = sum(1 for n in nums if is_even(n))

if num_even == 0 or num_even == 3:
  result = f(*nums)
elif num_even == 1:
  if is_even(nums[2]):
    result = f(nums[0]+1, nums[1]+1, nums[2]) + 1
  else:
    result = f(nums[0], nums[1], nums[2]+1)+1
elif num_even == 2:
  if not is_even(nums[2]):
    result = f(nums[0]+1, nums[1]+1, nums[2]) + 1
  else:
    result = f(nums[0], nums[1], nums[2]+1)+1

print(result)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Aug  8 12:24:08 2018

@author: Yuki
"""

A, B, C = map(int, input().split())
min_of_int = min(min(A, B), C)
A -= min_of_int
B -= min_of_int
C -= min_of_int

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

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

Submission status: Accepted

Solution code:
import numpy as np

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

# 0 <= A, B, C <= 50

max_v = max(max(A, B), C)

res = 3 * max_v - (A + B + C)
if res % 2 == 0:
    f = int(res / 2)
    print(f)
else:
    res += 3
    f = int(res / 2)
    print(f)

Submission status: Accepted

Solution code:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output


def chkprint(*args):
    names = {id(v): k for k, v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg), '???')+' = '+repr(arg) for arg in args))

# Binary converter


def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]

# --------------------------------------------


dp = None


def main():
    t = 0
    A = li_input()

    while max(A) - min(A) > 1:
        t += 1
        A[A.index(min(A))] += 2

    if A.count(max(A)) == 2:
        t += 2
    elif A.count(max(A)) == 1:
        t += 1

    print(t)


main()

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
cou = 0
abc = []
for i in a, b, c:
    m = (max(a, b, c) - i) // 2
    cou += m
    abc.append(2 * m + i)
if abc.count(max(abc)) == 2:
    cou += 2
elif abc.count(max(abc)) == 1:
    cou += 1


print(cou)

Submission status: Accepted

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

count = 0
while True:
	abc.sort()

	if abc[0] == abc[1] == abc[2]:
		break
	elif abc[0] == abc[1]:
		abc[0] += 1
		abc[1] += 1	
		count += 1
	else:
		abc[0] += 2
		count += 1

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

ABC = [A,B,C]

ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
for i in range(max(a,b,c),1000):
    ans=3*i-(a+b+c)
    if 0<=ans and ans%2==0:
        print(ans//2)
        exit()

Submission status: Accepted

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

if s[0] % 2 == 0 and s[1] % 2 == 0 :
    if s[2] % 2 == 0 :
        print((s[2] - s[0]) // 2 + (s[2] - s[1]) // 2)
    else :
        print((s[2] - s[0]) // 2 + (s[2] - s[1]) // 2 + 1)
elif s[0] % 2 != 0 and s[1] % 2 != 0 :
    if s[2] % 2 == 0 :
        print((s[2] - s[0]) // 2 + (s[2] - s[1]) // 2 + 1)
    else :
        print((s[2] - s[0]) // 2 + (s[2] - s[1]) // 2)
else :
    print((s[2] - s[0]) // 2 + (s[2] - s[1]) // 2 + 2)

Submission status: Accepted

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

cnt = 0
while A!=B or B!=C or C!=A:
    A,B,C = sorted([A,B,C])
    
    if A==B:
        A += 1
        B += 1
        cnt += 1
        
    else:
        A += 2
        cnt += 1
        
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a,b,c = input().split()
nums = []
nums.append(a)
nums.append(b)
nums.append(c)

nums = list(map(int,nums))

nums.sort()
count = 0

while(not (nums[0]==nums[1] and nums[1]==nums[2])):
	if(nums[1] == nums[0]):
		sa = nums[2]-nums[1]
		nums[1] += sa
		nums[0] += sa
		count += sa
		break
	elif(nums[1] - nums[0] >= 2):
		nums[0] += 2
		count += 1
		nums.sort()

	elif(nums[1] - nums[0] ==1):
		sa = nums[2] - nums[1]
		nums[1] += sa
		nums[0] += sa
		count += sa
		nums[0] += 2
		count += 1
		nums.sort()

print(count)

Submission status: Accepted

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

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

    if (max(abc) % 2 == 0 and sum(abc) % 2 == 0) or (max(abc) % 2 != 0 and sum(abc) % 2 != 0):
        M = max(abc)
    else:
        M = max(abc) + 1

    print((3 * M - sum(abc)) // 2)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict 
import sys,heapq,bisect,math,itertools,string

sys.setrecursionlimit(10**8)

#N:頂点数   M:辺数
A,B,C = map(int,input().split())

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


ans = 0

while aa[2]-aa[0] > 1:
	aa[0] += 2
	ans += 1
	
	
while aa[2]-aa[1] > 1:
	aa[1] += 2
	ans += 1
	
nn = aa[2]*2 - aa[1] - aa[0]	
	
if nn == 2:
	print(ans+1)
elif nn == 1:
	print(ans+2)
else:
	print(ans)

Submission status: Accepted

Solution code:

a = []

A = input().split()
for f in range(0,3):
    a.append(int(A[f]))

c = 0


while a[0] != a[1] or a[1] != a[2] or a[0] != a[2]:
    a.sort()
    b = []
    for i in range(0,3):
        d = a[i]%2
        if d == 0:
            b.append("o")
        else:
            b.append("e")
    if b.count("o") == 3 or b.count("e") == 3:
        a[0] = a[0] +2
        c = c + 1
        continue
    elif b.count("o") == 2:
        n = b.index("e")
        if n == 2:
            a[0] = a[0] + 1
            a[1] = a[1] + 1
            c = c+1
        elif n == 0:
            a[2] = a[2] + 1
            a[1] = a[1] + 1
            c = c+1
        elif n == 1:
            a[0] = a[0] + 1
            a[2] = a[2] + 1
            c = c+1
    elif b.count("e") == 2:
        n = b.index("o")
        if n == 2:
            a[0] = a[0] + 1
            a[1] = a[1] + 1
            c = c+1
        elif n == 0:
            a[2] = a[2] + 1
            a[1] = a[1] + 1
            c = c+1
        elif n == 1:
            a[0] = a[0] + 1
            a[2] = a[2] + 1
            c = c+1        

print(c)

Submission status: Accepted

Solution code:
# your code goes here
l = list(map(int,input().split()))
l.sort()

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

if a == b:
	print(int((l[1]-l[0])/2)+int(l[2]-l[1]))
elif a == c:
	l[0] = l[0]+1
	l[2] = l[2]+1
	print(int((l[1]-l[0])/2)+int(l[2]-l[1])+1)
else:
	l[1] = l[1] +1
	l[2] = l[2] + 1
	print(int((l[1]-l[0])/2)+int(l[2]-l[1])+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c = list(map(int, input().split()))
ans = 0
if a%2==b%2==c%2:
  pass
elif a%2==b%2:
  a, b = a+1, b+1
  ans += 1
elif a%2==c%2:
  a, c = a+1, c+1
  ans += 1
else:
  b, c = b+1, c+1
  ans += 1

t = max(a, b, c)
ans += abs(t-a)//2+abs(t-b)//2+abs(t-c)//2
print(ans)

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
A, B, C = sorted([A, B, C])
count1 = C - B
count2 = (C - (A + count1)) // 2
if A + count1 + count2 * 2 < C:
    count1 += 2
print(count1 + count2)

Submission status: Accepted

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

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

maxABC = max(ABC)
sumABC = sum(ABC)

# 常に合計は+2されていくので偶奇が変化しないことを活用する
if maxABC % 2 != sumABC % 2:
	# 偶奇が合わない時は最大値でぴったりいかないので+1
	maxABC += 1

ans = 0
ans += maxABC - ABC[0]
ans += maxABC - ABC[1]
ans += maxABC - ABC[2]

print(ans // 2)

Submission status: Accepted

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

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

# ABCのどれなのかは関係ないので昇順ソートしとく
ABC.sort()
# まず、少ないやつを差が1になるまで+2していく
cnt = 0
while ABC[0] <= ABC[2] - 2:
	ABC[0] += 2
	cnt += 1
while ABC[1] <= ABC[2] - 2:
	ABC[1] += 2
	cnt += 1
# あとは3つのパターンから場合分け
if ABC[0] == ABC[1] == ABC[2]:
	print(cnt)
	exit()
elif ABC[0] == ABC[2] or ABC[1] == ABC[2]:
	cnt += 2
	print(cnt)
	exit()
elif ABC[0] == ABC[1]:
	cnt += 1
	print(cnt)
	exit()

Submission status: Accepted

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


def solve(m):
    ans = 0
    while True:
        m = sorted(m)
        if m[0] == m[1] == m[2]:
            print(ans)
            return

        if m[-1] >= m[0] + 2:
            m[0] += 2
            ans += 1
        else:
            m[0] += 1
            m[1] += 1
            ans += 1


solve(n)

Submission status: Accepted

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

a.sort()

n0 = abs(a[2]-a[0])//2 + abs(a[2]-a[1])//2
if a[2] % 2 == 1 and a[0] % 2 == 0 and a[1] % 2 == 0:
  n0 += 1
elif a[2] % 2 == 0 and a[0] % 2 == 1 and a[1] % 2 == 1:
  n0 += 2
elif a[2] % 2 == 1 and a[0] % 2 == 1 and a[1] % 2 == 1:
  pass
elif a[2] % 2 == 0 and a[0] % 2 == 0 and a[1] % 2 == 0:
  pass
else:
  n0 += 2
  
print(n0)

Submission status: Accepted

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

a.sort()

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

Submission status: Accepted

Solution code:
a,b,c  = map(int,input().split())
list_sort = sorted([a,b,c])
i = 0
while ((list_sort[0]!=list_sort[2]) and (list_sort[1]!=list_sort[2])):
    i += 1
    list_sort[0] = list_sort[0]+1
    list_sort[1] = list_sort[1]+1
import math
if (list_sort[1] - list_sort[0]) % 2 == 0:
    i += int((list_sort[1] - list_sort[0]) / 2)
else:
    i += math.floor((list_sort[1] - list_sort[0]) / 2)
    i += 2
print(i)

Submission status: Accepted

Solution code:
x = input().split()

a = int(x[0])
b = int(x[1])
c = int(x[2])
count = 0

x = [a,b,c]

Max = max(x)
x.remove(max(x))

if x[0]%2 != x[1]%2:
	Max += 1
	x[0] += 1
	count += 1

x = [Max - x[0], Max - x[1]]


count += sum(x)/2
print(int(count));

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
ans = 0
while True:
	if A == B == C:
		break
	A, B, C = sorted([A, B, C])
	if C - A > 1:
		A += 2
	else:
		A += 1
		B += 1
	ans += 1
print(ans)

Submission status: Accepted

Solution code:

def main():
    a = [int(i) for i in input().split()]

    a.sort()

    op0 = (a[2] - a[0])//2
    a[0] += 2 * op0

    op1 = (a[2] - a[1])//2
    a[1] += 2 * op1

    if a[0] == a[2] and a[1] == a[2]:
        print(op0+op1)
    elif a[0] < a[2] and a[1] == a[2]:
        print(op0+op1+2)
    elif a[0] == a[2] and a[1] < a[2]:
        print(op0+op1+2)
    elif a[0] < a[2] and a[1] < a[2]:
        print(op0+op1+1)


if __name__ == '__main__':
    main()

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 C - A > 1:
		A += 2
	else:
		A += 1
		B += 1
	ans += 1
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 C - A > 1:
		A += 2
	else:
		A += 1
		B += 1
	ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ct = 0
while True:
    if a.count(max(a)) == 3:
        break
    if max(a) == min(a) + 1 and a.count(max(a)) == 1:
        ct += 1
        break
    tmp = min(a)
    tmp += 2
    a.remove(min(a))
    a.append(tmp)
    ct += 1
print(ct)

Submission status: Accepted

Solution code:
A,B,C = (int(i) for i in input().split())

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

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

print(int(ans))

Submission status: Accepted

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

sum_n = A + B + C
M = max(A, B, C) * 3

if sum_n % 2 == M % 2:
    print((M - sum_n) // 2)
else:
    print((M - sum_n) // 2 + 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
d=max(a,b,c)
ad=d-a
bd=d-b
cd=d-c
ope=0
ope+=int(ad/2)+int(bd/2)+int(cd/2)
if ad%2==0 and bd%2==0 and cd%2==0:
  print(ope)
elif ad%2 + bd%2 + cd%2 == 1:
  print(ope+2)
else:
  print(ope+1)

Submission status: Accepted

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

max_n = max(ls)


ls = list(map(lambda x:max_n-x, ls))

sum_n = sum(ls)

if sum_n % 2 == 0:
    print(sum_n//2)

else:
    print(sum_n//2 + 2)

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
count = 0
while not A == B == C:
	A, B, C = sorted([A, B, C])
	if C - A > 1:
		A += 2
		count += 1
	else:
		A += 1
		B += 1
		count += 1
print(count)

Submission status: Accepted

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

x = c - b
y, z = divmod(b - a, 2)
print(x + y + z * 2)

Submission status: Accepted

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

def main():
    list = [A, B, C]
    list.sort()

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

    d = d1 + d2
    
    if d % 2 == 0:
        ans = d // 2
    else:
        ans = d // 2 + 2

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
A,B,C = map(int, input().split())
d = [A,B,C]
d.sort()
n = 0
while d[0]+2 <= d[2]:
  d[0] += 2
  n += 1
while d[1]+2 <= d[2]:
  d[1] += 2
  n += 1
if d[0] == d[1] and d[0] != d[2]:
  print(n+1)
elif d[0] == d[1] and d[0] == d[2]:
  print(n)
else:
  print(n+2)

Submission status: Accepted

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

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

T = C*2 - A - B

if T%2 == 1:
  print(int(T/2)+2)

else:
  print(int(T/2))

Submission status: Accepted

Solution code:
n = list(map(int,input().split()))
counter = 0
while True:
	n = sorted(n)
	if n[2] - n[0] == 1:
		n[0] += 1
		n[1] += 1
		counter += 1
	if n[2] - n[0] > 1:
		n[0] += 2
		counter += 1
	if n[0] == n[1] == n[2]:
		break
print(counter)

Submission status: Accepted

Solution code:
A,B,C = map(int,input().split())
 
counter = 0
 
while not A == B == C:
    A,B,C = sorted([A,B,C])
    if C - A > 1:
        A += 2
        counter += 1
    else:
        A += 1
        B += 1
        counter += 1
        
print(counter)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(map(int, input().split()))
M = max(S)
r = sum(M - i for i in S)
print((r + 3 * (r % 2)) // 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
def kaisuu(hoge):
	a = sorted(hoge)
	A = a[2]
	B = a[1]
	C = a[0]
	return math.floor(A-((B+C)/2))


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

count = 0
for i in X:
	if i % 2 == 0:
		count+=1

if count == 0 or count == 3:
	print(kaisuu(X))
elif count == 1:
	for i in range(3):
		if X[i] % 2 == 1:
			X[i]+=1
	print(kaisuu(X)+1)
else:
	for i in range(3):
		if X[i] % 2 == 0:
			X[i]+=1
	print(kaisuu(X)+1)

Submission status: Accepted

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

num_list = sorted([a,b,c], reverse=True)

subd1 = num_list[0] - num_list[1]
subd2 = num_list[0] - num_list[2]

if subd1 % 2 == subd2 % 2:
    ret = (subd1+ subd2) // 2
else:
    ret = (subd1+ subd2 + 1) // 2 + 1

print(ret)

Submission status: Accepted

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

x = (a[1]-a[0])//2
y = (a[1]-a[0])%2
if y == 1:
    a[2]+=1
counter +=x+y
z = (a[2]-a[1])//2
s = (a[2]-a[1])%2
counter += (z*2)+s

print(int(counter))

Submission status: Accepted

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

if (N[1] - N[0])%2 == 0:
    result = int((N[1] - N[0])/2) + N[2] - N[1]

else:
    result = int((N[1] - N[0])/2) + N[2] - N[1] + 2 

print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
a.sort()
first, second, third = a[2], a[1], a[0]

x, y = first - second, first - third

res = 0
res += min(x, y) + abs(x - y) // 2

if abs(x - y) % 2 == 0:
    print(res)
else:
    print(res + 2)

Submission status: Accepted

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

X.sort()

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,C=map(int,input().split())
saidai=max(A,B,C)
saishou=min(A,B,C)
count=0

if  saidai==saishou:
    print(0)
    exit()


if (saidai*3-(A+B+C))%2==0:
    count=int((saidai*3-(A+B+C))/2)
else:
    count=2+int((saidai*3-(A+B+C))/2)

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
min_v, med_v, max_v = sorted([A, B, C])
count = 0
i = 0
while i != 10:
    i += 1
    #print(max_v, med_v, min_v, count)
    if min_v == med_v and med_v == max_v:
        print(count)
        break
    elif min_v != med_v and med_v != max_v and max_v != min_v:
        count += max_v - med_v
        min_v += max_v - med_v
        med_v = max_v
    elif min_v == med_v:
        count += max_v - med_v
        min_v = max_v
        med_v = max_v
    elif med_v == max_v and max_v - min_v != 1:
        count += int((max_v - min_v) / 2)
        min_v += int((max_v - min_v) / 2) * 2
    else:
        count += 1
        min_v = max_v
        max_v += 1

Submission status: Accepted

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

v1 = data[2] - data[1]
v2 = data[0] + v1

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

Submission status: Accepted

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

abc = sorted(abc)
ans = 0
while abc[0] != abc[2]:
    if abc[2] - abc[0] >= 2:
        abc[0] += 2
    else:
        abc[0] += 1
        abc[1] += 1
    abc = sorted(abc)
    ans += 1
print(ans)

Submission status: Accepted

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

B = [A[0]-min(A),A[1]-min(A),A[2]-min(A)]
B.sort()

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

print(int(ans + sum(B)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ope = 0

while T[1]!=T[0]:
    ope += 1
    T[1] += 1
    T[2] += 1
    
while T[2]<T[0]:
    ope += 1
    T[2] += 2

if T[0]==T[2]:
    print(ope)
    
else:print(ope+1)

Submission status: Accepted

Solution code:
import math
A, B, C = map(int, input().split(' '))
diff = max([A, B, C]) * 3 - A - B - C
if diff % 2 == 1:
    print(math.ceil(diff / 2) + 1)
else:
    print(math.ceil(diff / 2))

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def abc093c():
    abc = sorted(list(map(int, input().split())))
    return abc[2] - abc[1] + (abc[1] - abc[0]) // 2 + 2 * ((abc[1] - abc[0]) % 2)


print(abc093c())

Submission status: Accepted

Solution code:
import numpy as np

n = np.array(list(map(int, input().split())))
neven = len(np.where(n % 2 == 0)[0])

if neven == 3 or neven == 0:
    n = np.sort(n)
    print(int((n[2] - n[1]) / 2 + (n[2] - n[0]) / 2))
elif neven == 2:
    no = n[n % 2 != 0]
    ne = n[n % 2 == 0]
    ne = ne + 1
    n = np.sort(np.concatenate([no, ne]))
    print(1 + int((n[2] - n[1]) / 2 + (n[2] - n[0]) / 2))
elif neven == 1:
    no = n[n % 2 != 0]
    ne = n[n % 2 == 0]
    no = no + 1
    n = np.sort(np.concatenate([no, ne]))
    print(1 + int((n[2] - n[1]) / 2 + (n[2] - n[0]) / 2))

Submission status: Accepted

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

# Check odd numbers
odd_num = 0
for i in numbers:
    if i % 2 != 0:
        odd_num += 1

max_ = max(numbers)
numbers.remove(max_)
min_ = min(numbers)
numbers.remove(min_)
middle = numbers[0]

def even(a, b, c, count=0): # a <= b <= c
    count += (c - b) // 2 + (c - a) // 2
    print(count)
    
# # of odd is 0
if odd_num == 0:
    even(min_, middle, max_)

# # of odd is 1    
elif odd_num == 1:
    if max_ % 2 == 0:
        max_ += 1
    if middle % 2 == 0:
        middle += 1
    if min_ % 2 == 0:
        min_ += 1
    even(min_, middle, max_, 1)

# # of odd is 2
elif odd_num == 2:
    if max_ % 2 != 0:
        max_ += 1
    if middle % 2 != 0:
        middle += 1
    if min_ % 2 != 0:
        min_ += 1
    even(min_, middle, max_, 1) 

# # of odd is 3
else:
    even(min_, middle, max_)

Submission status: Accepted

Solution code:
def c_same_integers(A, B, C):
    # A,B,Cの和と、これらのうち最大のもの(Mとする)の3倍との
    # 偶奇が一致するなら、最終的に3つの整数はMとなる
    # 偶奇が一致しないなら、最終的に3つの整数はM+1となる
    m = max(A, B, C)
    initial_total = A + B + C  # 初期状態での整数の和

    parity = 3 * m % 2 == initial_total % 2
    final_value = m if parity else m + 1  # 整数はこの値で等しくなる
    # 3数の和は1回の操作で2増えるため,ans回の操作が必要
    ans = (3 * final_value - initial_total) // 2
    return ans

A,B,C = [int(i) for i in input().split()]
print(c_same_integers(A, B, C))

Submission status: Accepted

Solution code:
l = list(map(int, input().split()))
count = 0
while True:
  if l[0] == l[1] == l[2]:
    print(count)
    break
  
  l = sorted(l)

  if l[1] == l[2] and not l[0] == l[1]:
    l[0] += 2
  else:
    l[0] += 1
    l[1] += 1
  
  count += 1

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

max_num = max(a,b,c)
diff = max_num * 3 - sum([a,b,c])

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

Submission status: Accepted

Solution code:
A, B, C = sorted(map(int, input().split()))
x, y = C - A, C - B
ans, a, b = x // 2 + y // 2, x % 2 == 1, y % 2 == 1
ans += (a & b) + 2*(a ^ b)
print(ans)

Submission status: Accepted

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

def double_puls():
    a[0] += 1
    a[1] += 1
    

while True:
    a.sort()
    if a[0] == a[1] and a[1] == a[2]:
        break
    if a[2] >= a[1]+1:
        double_puls()
        count += 1
    elif a[1] == a[2]:
        a[0] += 2
        count += 1
    elif a[0] == a[1]:
        double_puls()
        count += 1

print(count)

Submission status: Accepted

Solution code:

a,b,c=map(int,input().split())
x=max(a,b,c)
total=a+b+c
for i in range(x,100):
    ans=3*i-total
    if ans%2==0:
        print(ans//2)
        exit()