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:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/16
Solved on 2019/3/
@author: shinjisu
"""


# ABC 093 C Same Integer
#import math
#import numpy as np

def getInt(): return int(input())

def getIntList(): return [int(x) for x in input().split()]
# def getIntList(): return np.array(input().split(), dtype=np.longlong)

def zeros(n): return [0]*n
# def zeros(n): return np.zeros(n, dtype=np.longlong)

def getIntLines(n): return [int(input()) for i in range(n)]
"""
def getIntLines(n):
    data = zeros(n)
    for i in range(n):
        data[i] = getInt()
    return data
"""

def zeros2(n, m): return [zeros(m)]*n # obsoleted zeros((n, m))で代替

def getIntMat(n, m):  # n行に渡って、1行にm個の整数
    #mat = zeros((n, m))
    mat = zeros2(n, m)
    for i in range(n):
        mat[i] = getIntList()
    return mat

ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**18

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


def prob():
    d = Debug()
    d.off()
    PATTERN = {(0,0,1):1, (0,1,1):2, (0,0,2):2, (0,1,2):3,
               (0,2,2):1, (1,1,2):1, (1,2,2):2, (0,0,0):0,}
    a = getIntList()
    d.dmp((a),'a')
    a.sort()
    b = zeros(3)
    b[0] =  (a[-1]-a[0]) // 2
    b[1] =  (a[-1]-a[1]) // 2
    d.dmp(b, 'b')
    a[0] +=  b[0]*2
    a[1] +=  b[1]*2
    mina = min(a)
    a.sort()
    d.dmp((a),'a')
    for i in range(3):
        a[i] -= mina
    d.dmp((a),'a')
    c = a[0], a[1], a[2]
    d.dmp(c, 'c')
    count = sum(b) + PATTERN[c]
    d.dmp(count, 'count')
    return count


ans = prob()
if ans is None:
    pass
elif type(ans) == tuple and ans[0] == 1:  # 1,ans
    for elm in ans[1]:
        print(elm)
else:
    print(ans)

Submission status: Accepted

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


def main():
    print((2 * C - A - B) // 2 + 2 if (2 * C - A - B) % 2 else
          (2 * C - A - B) // 2)
    return


main()

Submission status: Accepted

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

Submission status: Accepted

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

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

if a[0] != a[1]:
    a[0] += 1
    a[2] += 1
    count += 1

count += a[2]-a[0]
print(count)

Submission status: Accepted

Solution code:
T=list(map(int,input().split()))
T.sort()
L1=T[0]
L2=T[1]
L3=T[2]
ans=0
ans+=L3-L2
ans+=(L3-ans-L1+1)//2+(L3-L1-ans)%2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def same_integers(A: int, B: int, C: int) -> int:
    A, B, C = sorted([A, B, C])
    count = (C-A)//2 + (C-B)//2
    A = A + 2 * ((C-A)//2)
    B = B + 2 * ((C-B)//2)

    A, B, C = sorted([A, B, C])
    # (A,B,C)は以下のいづれか
    # 1.(C, C, C)
    # 終了
    if A == C and B == C:
        return count
    # 2.(C-1, C, C)
    # A に 2 を足して、B, C に 1 を足す。
    if B == C:
        return count + 2
    # 3.(C-1,C-1,C)
    # A, B に 1 を足す。
    return count + 1


if __name__ == "__main__":
    A, B, C = map(int, input().split())
    ans = same_integers(A, B, C)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
a=np.array(list(map(int,input().split())))

def f(m,n):
    ret=abs(m-n)/2
    if ret==int(ret):
        return ret
    return int(ret+1)

def solve(a):
    count=0
    a=np.sort(a)
    
    diff=a[2]-a[1]
    a[1]=a[2]
    a[0]+=diff
    count+=diff
    
    diff2=f(a[0],a[1])
    a[0]+=2*diff2
    count+=diff2
    
    if a[0]!=a[1]:
        count+=1
    
    return count

print(int(solve(a)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

import itertools
import collections
import bisect

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

    z = [A, B, C].count(0)
    if z == 3:
        print(0)
    elif z == 2:
        print(max(A, B, C))
    else:
        D = A if A != 0 else B
        E = C if C != 0 else B
        # print("D = {}, E = {}".format(D, E))
        count = min(D, E) // 2
        min_de = (min(D, E) // 2) * 2
        D -= min_de
        E -= min_de
        # print("{}, {}, min = {}".format(D, E, min_de))
        count += D + E
        print(count)


if __name__ == '__main__':
    main()



# 1 -> -1
# 2 -> -2

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
abc = [int(i) for i in input().split()]
ans = (max(abc)*3 - sum(abc))
if ans % 2 == 0:
  print(ans//2)
else:
  print((ans+3)//2)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar  5 20:10:22 2019

@author: yuta
"""

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

def same(a,b,c):
    x = [a,b,c]
    x_sort = sorted(x)
    dif = x_sort[1] - x_sort[0]
    if dif % 2 == 0:
        count = dif/2 + x_sort[2] - x_sort[1]
    else:
        x_sort[0] += 1
        x_sort[2] += 1
        dif2 = x_sort[1] - x_sort[0]
        count = 1 + dif2/2 + x_sort[2] - x_sort[1]
    print(int(count))
same(A,B,C)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = sorted(list(map(int, input().split())))
cnt = 0
flag = True
while flag:
    if (x[1] - x[0]) == 0:
        while x[0] < x[2]:
            x[0] += 1
            x[1] += 1
            cnt += 1
    elif ((x[1] - x[0])%2) == 0:
        while x[0] < x[1]:
            x[0] += 2
            cnt += 1
    elif ((x[1] - x[0])%2) != 0:
        x[0] += 1
        x[2] += 1
        cnt += 1
    if x[0] == x[1] == x[2]:
        flag = False
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def main():
  input = sys.stdin.readline
  A = list(map(int, input().split()))
  A = sorted(A)
  a = A[2] - A[0]
  b = A[2] - A[1]
  if a%2 == 0 and b%2 == 0:
    ans = a // 2 + b // 2
  elif a%2 == 1 and b%2 == 1:
    ans = a // 2 + b // 2 + 1
  else:
    ans = a // 2 + b // 2 + 2
  print(ans)


if __name__ == '__main__':
  main()

Submission status: Accepted

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

Submission status: Accepted

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

print(answer)

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
maxn = max(a, b, c) * 3
total = a+b+c
while maxn != total:
    total += 2
    if maxn < total:
        maxn += 3
print((maxn-a-b-c) // 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A = list(map(int, input().split()))
B = []
counter = 0
ans = 0
for X in A:
    B.append(X % 2)
    if X % 2:
        counter += 1
if counter == 1:
    ans += 1
    for i in range(3):
        if not B[i]:
            A[i] += 1

if counter == 2:
    ans += 1
    for i in range(3):
        if B[i]:
            A[i] += 1

for X in A:
    ans += (max(A)-X)//2

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    X = list(map(int, lines.pop(0).split(' ')))
    X.sort(reverse=True)
    sum_x  = X[0] - X[1]
    sum_x += X[0] - X[2]
    if sum_x % 2 == 0:
        print(sum_x // 2)
    else:
        print((sum_x // 2) + 2)

#
# main
#
lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

resa = c - a
resb = c - b

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

print(ans)

Submission status: Accepted

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

resa = c - a
resb = c - b

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

print(ans)

Submission status: Accepted

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

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

ans=0
for i in range(3):
    if A[i%3]%2==A[(i+1)%3]%2 and A[(i+1)%3]%2!=A[(i+2)%3]%2 :
        A[i%3]+=1
        A[(i+1)%3]+=1
        ans+=1

A.sort
ans+=(A[2]-A[1])//2+(A[2]-A[0])//2
print(ans)

Submission status: Accepted

Solution code:
#ABC093C
abc=list(map(int,input().split()))
check=[x%2 for x in abc]
z=check.count(0)
ans=0
if z!=0 and z!=3:
	ans+=1
	for i in range(3):
		if check[i]==2-z:
			abc[i]+=1
m=max(abc)
for x in abc:
	ans+=(m-x)//2
print(ans)

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:
a,b,c=sorted(map(int,input().split()))
print(c-b+(b-a+1)//2+((b-a)&1))

Submission status: Accepted

Solution code:
a=list(map(int,input().split()))
s=max(a)*3-sum(a);print([s//2+2,s//2][s%2<1])

Submission status: Accepted

Solution code:
A,B,C=map(int,input().split())
if B>=A and B>=C:
    D=A
    A=B
    B=D
elif C>=A and C>=B:
    D=A
    A=C
    C=D
R=(A-B)%2-(A-C)%2
if R==0:
    print(A+(-B-C)//2)
else:
    print(A+(-B-C+3)//2)

Submission status: Accepted

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

X=[a,b,c]
X.sort()
x=X[2]
y=X[1]
z=X[0]


sabun1=x-y
sabun2=x-z

if sabun1%2==0 and sabun2%2==0:
    res=(sabun1+sabun2)/2
elif sabun1%2==1 and sabun2%2==1:
    res=(sabun1//2+sabun2//2)+1
elif sabun1%2==0 and sabun2%2==1:
    res=(sabun1/2)+(sabun2//2)+2
else:
    res=(sabun1//2)+(sabun2/2)+2

print(int(res))

Submission status: Accepted

Solution code:
a,b,c = map(int,input().split())
s = sorted([a,b,c])
x,y = s[:-1]
m = s[-1]

xym = m-x + m-y
if xym % 2 == 0:
    print(xym//2)
else:
    print(xym//2+2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c = map(int,input().split())
d = [a,b,c]
d.sort()
x,y = d[:-1]
m = d[-1]

cnt = m-y
x += cnt
y += cnt
if (y-x) % 2 == 1:
    cnt += (y+1-x)//2 + 1
else:
    cnt += (y-x)//2
    
print(cnt)

Submission status: Accepted

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

ABC.sort()

max = ABC[2]
mid = ABC[1]
min = ABC[0]

if (max-mid) % 2 == 0:
    if (max-min) % 2 == 0:
        print((max-mid)+(mid-min)//2)
    else:
        print((max-mid)+1+(mid-min)//2 + 1)
else:
    if (max-min) % 2 == 0:
        print((max-mid)+1 + (mid-min)//2 + 1)
    else:
        print((max-mid) + (mid-min)//2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
a, b, c = map(int, input().split())
li = np.array([])

m = max(a, b, c)
if abs(a-m) != 0:
    li = np.append(li, abs(a-m))
if abs(b-m) != 0:
    li = np.append(li, abs(b-m))
if abs(c-m) != 0:
    li = np.append(li, abs(c-m))

if sum(li) % 2 == 0:
    print(int(sum(li)/2))
else:
    print(int((sum(li)+1)/2+1))

Submission status: Accepted

Solution code:
import numpy as np

def input_numbers():
    temp = list(map(int, input().split()))
    return temp

def GCD(a, b):
    if(a < b):
        temp = a
        a = b
        b = temp
    a = a % b
    if(a == 0):
        return b
    else:
        return GCD(a, b)

numbers = input_numbers()

numbers.sort()

count = 0

count += numbers[2] - numbers[1]
numbers[0] += numbers[2] - numbers[1]
numbers[1] = numbers[2]

diff = numbers[2] - numbers[0]

if(diff % 2 == 0):
    count += (diff // 2)

else:
    numbers[1] += 1
    numbers[2] += 1
    count += 1

    diff = numbers[2] - numbers[0]
    count += (diff // 2)

print(count)

Submission status: Accepted

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

goal = max(a, b, c) * 3
now = a + b + c
diff = goal - now
if diff % 2 == 1:
  diff += 3
print(diff // 2)

Submission status: Accepted

Solution code:
# encoding:utf-8

import copy
import numpy as np
import random

nums = [int(i) for i in input().split()]
ans = 0
even = 0

for i in range(3):
    if nums[i]%2 == 0:
        even+=1

if even==3:
    pass
elif even==2:
    for i in range(3):
        if nums[i]%2==0:
            nums[i]+=1
    ans+=1

elif even==1:
    for i in range(3):
        if nums[i]%2==1:
            nums[i]+=1
    ans+=1
else:
    pass

goal_num = max(nums)
ans += (3*goal_num-sum(nums))//2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = sorted(list(map(int, input().split())))
plus = 0
if a[0] % 2 == a[1] % 2 and a[1] % 2 == a[2] % 2:
    pass
else:
    plus = 1
    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(a[-1] - (a[0] + a[1]) // 2 + plus)

Submission status: Accepted

Solution code:
import math
ans = 0
n = list(map(int, input().split()))
n.sort()
if not (n[0] % 2 == n[2] % 2) or not(n[1] % 2 == n[2] % 2):
    ans += 1
    if (n[0] % 2) != (n[2] % 2):
        if (n[1] % 2) != (n[2] % 2):
            n[0] += 1
            n[1] += 1
        else:
            n[1] += 1
            n[2] += 1
    else:
        if (n[1] % 2) != (n[2] % 2):
            n[0] += 1
            n[2] += 1
for i in range(2):
    ans += int((n[2] - n[i]) / 2)
print(ans)

Submission status: Accepted

Solution code:
def main():
    A, B, C = map(int, input().split())
    k = max(A, B, C)
    while True:
        if (3 * k - (A + B + C)) % 2 != 0:
            k += 1
            continue
        break
    print((3 * k - (A + B + C)) // 2)


main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
abc = [int(i) for i in input().split()]
abc_sort = sorted(abc)
check = abc_sort[2] - abc_sort[1]
ans = 0

abc_sort[1] += check
abc_sort[0] += check 
ans += check

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

score = 0

if (max(ABC) + ABC[0] + ABC[1] + ABC[2]) % 2 == 0:
    score = (max(ABC) * 3 - ABC[0] - ABC[1] - ABC[2])
else:
    score = ((max(ABC) + 1) * 3 - ABC[0] - ABC[1] - ABC[2])

print(math.floor(score/2))

Submission status: Accepted

Solution code:

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

abc.sort()

dis = 2*abc[2] - abc[0] - abc[1]

count = 0
if dis%2!=0:
    count += 1
    dis += 1

count += dis // 2

print(count)

#print(abc)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(A, B, C):
    A, B, C = max(A, B, C), sum([A, B, C]) - max(A, B, C) - min(A, B, C), min(A, B, C)
    if A % 2 == B % 2 == C % 2:
        ans = 0
    else:
        ans = 1
        if B % 2 == C % 2:
            B += 1
            C += 1
        elif A % 2 == B % 2:
            A += 1
            B += 1
        else:
            A += 1
            C += 1
    ans += (A - B) // 2 + (A - C) // 2
    return ans


if __name__ == "__main__":
    A, B, C = tuple(map(int, input().split(" ")))
    print(solve(A, B, C))

Submission status: Accepted

Solution code:
x = sorted(list(map(int,input().split())),reverse=True)

count = 0
if (x[1]-x[2])%2 == 1:
    count += 1
    x[0] += 1
    x[2] += 1
count = count + (x[1]-x[2])/2 + (x[0]-x[1])

print(int(count))

Submission status: Accepted

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

a.sort()

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A,B,C = sorted(map(int,input().split()))
count = 0
while C != B:
    A += 1
    B += 1
    count += 1
while A < B:
    A += 2
    count += 1
if A == B:
    print(count)
else:
    print(count+1)

Submission status: Accepted

Solution code:
data=[int(_) for _ in input().split()]

data.sort()
A=data[2]
B=data[1]
C=data[0]
count=0

while A!=B:

    B+=1
    C+=1
    count+=1


while C<B:
    C+=2
    count+=1


if B==C:
    print(count)
else:
    print(count+1)

Submission status: Accepted

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


def main():
    a, b, c = map(int, input().split())
    maximum = max(a, b, c)
    summed = sum([a, b, c])

    while True:
        diff = maximum * 3 - summed

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def count(base, ref):
    if base > ref:
        if (base - ref) % 2:
            return (base - ref) // 2 + 2
        else:
            return (base - ref) // 2
    else:
        return ref - base

def func(base, x, y):
    return count(base, x) + count(base, y)

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans=0
max_num=max(a,b,c)
min_num=min(a,b,c)
mid_num=a+b+c-max_num-min_num

ans += max_num-mid_num

mid_num= max_num
min_num= min_num + ans

if (max_num-min_num)%2==0:
  ans += (max_num-min_num)//2
else:
  ans += (max_num-min_num)//2+2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A = [int(i) for i in input().split()]
mid = sum(A) - max(A) - min(A)
count = 0

count += max(A) - mid
mini = min(A) + count

while max(A) - mini >= 2:
    mini += 2
    count += 1

if max(A) - mini == 1:
    count += 2
    
print(count)

Submission status: Accepted

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

oddcnt = 0
sub = [A,B,C]
sub2 = [i - min(sub) for i in sub]
sub2 = sorted(sub2)[1:3]
# print(sub2)
for i in sub2:
    if i%2 != 0:
        oddcnt += 1

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

Submission status: Accepted

Solution code:
X = [int(i) for i in input().split()]
t = sum([(max(X)-Xi)//2 for Xi in X])
tmp = sum([(max(X)-Xi)%2 for Xi in X])
if tmp == 1:
    t+=2
elif tmp == 2:
    t+=1
print(t)

Submission status: Accepted

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

Submission status: Accepted

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

max_num = max(a, b, c)
min_num = min(a, b, c)
mid_num = a+b+c-max_num - min_num

ans  = max_num - min_num + max_num - mid_num
if(ans%2==0):
    print(int(ans/2))
else:
    print(int(ans/2)+2)

Submission status: Accepted

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

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

    na.sort()

    r = 0
    k = int((na[2] - na[0]) / 2)
    r += k
    na[0] += k * 2
    k = int((na[2] - na[1]) / 2)
    r += k
    na[1] += k * 2

    if na[0] < na[2] and na[1] < na[2]:
        r += 1
    elif na[0] < na[2]:
        r += 2
    elif na[1] < na[2]:
        r += 2


    print(r)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    A, B, C = il()
    m = max([A, B, C])
    diff = [m - A, m - B, m - C]
    c = 0
    for i, d in enumerate(diff):
        div_2 = d // 2
        if div_2 > 0:
            c += d // 2
            diff[i] -= 2 * div_2
    num_of_1 = diff.count(1)
    if num_of_1 == 1:
        c += 2
    elif num_of_1 == 2:
        c += 1
    return c


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

Submission status: Accepted

Solution code:
s = list(map(int,input().split()))
s.sort()
count = 0
while True:
    if s[1] != s[2]:
        s[0] += 1
        s[1] += 1
        count += 1
    if s[1] == s[2]:
        break

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

Submission status: Accepted

Solution code:
number = list(map(int, input().split()))
ans = 0
number.sort()

a = (number[1] - number[0]) // 2
ans += a
number[0] += 2 * a

ans += abs(number[2]-number[0]) + abs(number[1]-number[0])
print(ans)

Submission status: Accepted

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

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

ans=0

if (A+B)%2==1:
    A+=1
    C+=1
    ans+=1

while A!=B or B!=C:
    if A<B:
        A+=2
    else:
        A+=1
        B+=1
    ans+=1

print(ans)

Submission status: Accepted

Solution code:
A = [int(i) for i in input().split()]
maxA = max(A)
minA = min(A)
midA = sum(A) - maxA - minA

count = maxA - midA
minA += count

while maxA - minA > 1:
    count += 1
    minA += 2
if maxA - minA == 1:
    count += 2
    
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A = [int(i) for i in input().split()]
maxA = max(A)
minA = min(A)
midA = sum(A) - maxA - minA

ans = maxA - midA
diff = maxA - (minA + ans)
if diff == 1:
    ans += 2
elif diff == 2:
    ans += 1
elif diff > 2:
    ans += diff // 2
    if diff % 2 == 1:
        ans += 2
        
print(ans)

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
ans = 0
max_ABC = max(A, B, C)

if max_ABC != A:
    ans += (max_ABC - A) // 2
    A += 2 * ((max_ABC-A) // 2)

if max_ABC != B:
    ans += (max_ABC - B) // 2
    B +=  2 * ((max_ABC-B) // 2)

if max_ABC != C:
    ans += (max_ABC - C) // 2
    C += 2 * ((max_ABC-C) // 2)

if 3 * max_ABC - (A+B+C) == 2:
    ans += 1
elif 3 * max_ABC - (A+B+C) == 1:
    ans += 2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

A.sort()

ans=0

ans+=A[2]-A[1]
A[0]+=ans
A[1]+=ans

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

Submission status: Accepted

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

midA = sum(A) - max(A) - min(A)
count = 0

count += max(A) - midA
diff = max(A) - (min(A) + count) 

while diff > 1:
    diff -= 2
    count += 1

if diff == 1:
    count += 2

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A = list(map(int, input().split()))
maxA = max(A)
minA = min(A)
midA = sum(A) - maxA - minA
count = 0

count = maxA - midA
minA += count

while minA < maxA - 1:
    minA += 2
    count += 1
    
if minA == maxA:
    print(count)
else:
    print(count + 2)

Submission status: Accepted

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