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:
L = sorted(list(map(int, input().split())))
cnt = 0
while L[0]<L[2]-2:
    cnt+=1
    L[0]+=2
while L[1]<L[2]-2:
    cnt+=1
    L[1]+=2
if L[0]%2 == L[1]%2 and L[1]%2 == L[2]%2:
    if(L[0]<L[2]):
        cnt += 1
    if(L[1]<L[2]):
        cnt += 1
else:
    if L[0]==L[1]:
        cnt+=1
    elif L[1]==L[2]: 
        cnt+=2
    else:
        cnt+=3


print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

m = max(a, b, c)
sub = 3 * m - a - b - c

if sub % 2 != 0:
    sub += 3

print(sub // 2)

Submission status: Accepted

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

D.sort()

A=D[2]-D[1]
D[1]+=A
D[0]+=A
result=A

if (D[1]-D[0])%2==0:
    result+=(D[1]-D[0])//2
else:
    result+=(D[1]-D[0])//2+2

print(result)

Submission status: Accepted

Solution code:
l = list(map(int, input().split()))
ref = max(l)*3 - sum(l)

if ref%2 == 0:
    ans = ref//2
else:
    ans = ref//2 + 2

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = [int(x) for x in input().split()]
list.sort(X,reverse=True)
A,B,C = X[0],X[1],X[2]
count = 0

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

print(count)

Submission status: Accepted

Solution code:
#!python3

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


def main():
    m = max(A, B, C)
    s = sum([m - A, m - B, m - C])
    ans = (s + 1) // 2
    if s % 2 == 1:
        ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

count = 0
while not (a == b == c):
    count += 1
    a, b, c = sorted([a, b, c])
    if a == b:
        a += 1
        b += 1
    else:
        a += 2
print(count)

Submission status: Accepted

Solution code:
def solve():
    A = list(map(int, input().split()))
    A.sort(reverse=True)
    diff_0_1 = A[0] - A[1]
    A[1] += diff_0_1
    A[2] += diff_0_1
    cnt = diff_0_1

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

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
#解説参照
a = list(map(int, input().split( )))
a.sort(reverse = True)
ans = 0
ans += a[0]-a[1]
a[1]+=ans
a[2] += ans
ans += (a[0]-a[2])//2
ans += ((a[0]-a[2])%2)*2###これ
print(ans)

Submission status: Accepted

Solution code:


import numpy as np
a,b,c = map(int,input().split())
L = np.array([a,b,c])
d = (L%2).sum()

def calc(a,b,c):
    e = a+b+c
    max1 = max(a,b,c)
    min1 = min(a,b,c)
    mid = e - max1 - min1
    return (max1*2 - mid - min1)//2
    
if d == 3 or d == 0:
    print(calc(a,b,c))
elif d == 1:
    if a%2 ==1:
        b +=1
        c +=1
        print(calc(a,b,c)+1)
    elif b%2 == 1:
        a +=1
        c +=1
        print(calc(a,b,c)+1)
    elif c%2 == 1:
        a +=1
        b +=1
        print(calc(a,b,c)+1)
elif d == 2:
    if a%2 == 0:
        b +=1
        c +=1
        print(calc(a,b,c)+1)
    elif b%2 == 0:
        a +=1
        c +=1
        print(calc(a,b,c)+1)
    elif c%2 == 0:
        a +=1
        b +=1
        print(calc(a,b,c)+1)

Submission status: Accepted

Solution code:
A = list(map(int, input().split()))
A.sort()
ans = 0
count = [0, 0]
for a in A:
    if a & 1:
        count[1] += 1
    else:
        count[0] += 1
if (count[0] == 0)or(count[1] == 0):
    m = A[2]
    ans += (3*m-sum(A))
    ans //= 2
else:
    if (A[1]-A[0]) & 1:
        m = A[2]+1
        ans += (3*m-sum(A))
        ans //= 2
    else:
        m = A[2]
        ans += (3*m-sum(A))
        ans //= 2
print(ans)

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C = sorted(map(int, input().split()))
a,b=divmod(2*C-A-B,2)
print(a+b*2)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect


class Scanner():
    def int():
        return int(sys.stdin.readline().rstrip())

    def string():
        return sys.stdin.readline().rstrip()

    def map_int():
        return [int(x) for x in Scanner.string().split()]

    def string_list(n):
        return [input() for i in range(n)]

    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

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

    def roundUp(a, b):
        return -(-a // b)

    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    def toLowerMultiple(a, x):
        return (a // x) * x

    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


MOD = int(1e09) + 7


def main():
    # sys.stdin = open("sample.txt")
    A, B, C = Scanner.map_int()
    ans = 0
    if not A % 2 == B % 2 == C % 2:
        ans += 1
        if A % 2 == B % 2:
            A += 1
            B += 1
        elif B % 2 == C % 2:
            B += 1
            C += 1
        else:
            A += 1
            C += 1
    D = max(A, B, C)
    ans += (D-A)//2
    ans += (D-B)//2
    ans += (D-C)//2
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

count=numSort[2]-numSort[1]
count+=(numSort[2]-(numSort[0]+count))/2
count=int(count) if count.is_integer() else int(count+1.5)

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def examC():
    ABC = LI(); ABC.sort()
    judge = ABC[2]*2-ABC[1]-ABC[0]
    ans = judge//2 + (judge%2)*2
    print(ans)
    return

def examD():
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = 10**18

if __name__ == '__main__':
    examC()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c=sorted(list(map(int,input().split())))
cnt=0
while b<c:
    a+=1
    b+=1
    cnt+=1
while a<c:
    a+=2
    cnt+=1
print(cnt if a==c else cnt+1)

Submission status: Accepted

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


def solve(A: int, B: int, C: int):
    a = sorted([A, B, C])
    o = sum([x & 1 for x in a])
    c = 0 < o and o < 3
    if o == 2:
        for i in range(3):
            a[i] += a[i] & 1
    elif o == 1:
        for i in range(3):
            a[i] += 1 - (a[i] & 1)
    print((2*a[2] - a[1] - a[0]) // 2 + c)


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

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

    abc.sort()

print(ans)

Submission status: Accepted

Solution code:
import numpy as np

abc = np.array([int(a) for a in input().split()])
abc = abc - np.array([np.min(abc)] * 3)
abc = np.sort(abc)
ans = 0
if abc[1] == 0:
    ans = abc[2]
elif abc[1] % 2 == 0:
    ans += abc[1] // 2
    ans += abc[2] - abc[1]
else:
    ans += 1
    abc[0] += 1
    abc[2] += 1
    ans += (abc[1] - abc[0]) // 2
    ans += abc[2] - abc[1]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
maximam = max(A, B, C)
count = (maximam-A)//2 + ( maximam-B)//2 + (maximam-C)//2
A +=((maximam-A)//2*2)
B +=((maximam-B)//2*2)
C +=((maximam-C)//2*2)
if A==B and B == C:
  print(count)
elif (A==B and A==maximam) or (C==B and C==maximam) or (A==C and C==maximam):
  print(count+2)
else:
  print(count+1)

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
c = 0
if A == B == C:
  print(0)
else:
  while(True):
    if max(A, B, C) >= 2 + min(A, B, C):
      A, B, C = max(A, B, C), A + B + C - max(A, B, C) - min(A, B, C), min(A, B, C) + 2
    else:
      A, B, C = max(A, B, C), A + B + C - max(A, B, C) - min(A, B, C) + 1, min(A, B, C) + 1
    c += 1
    if A == B == C:
      break
  print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
ans=0
while 1:
    if a==b and b==c:
        print(ans)
        break
    ans+=1
    if a==min(a,b,c):
        a+=1
        if a==min(a,b,c):
            a+=1
        elif b==min(a,b,c):
            b+=1
        else :
            c+=1
    elif b==min(a,b,c):
        b+=1
        if a==min(a,b,c):
            a+=1
        elif b==min(a,b,c):
            b+=1
        else :
            c+=1
    else :
        c+=1
        if a==min(a,b,c):
            a+=1
        elif b==min(a,b,c):
            b+=1
        else :
            c+=1

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
#ARC094C
import copy
import sys
import math

#n = int(input())
tmp = input().split()
a,b,c = list(map(lambda a: int(a), tmp))

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

Submission status: Accepted

Solution code:
A, B, C = list(map(int,input().split()))
sum_l = A + B + C
max_l = max(A, B, C)

dif = 3*max_l - sum_l
if dif % 2 == 0:
    print(dif // 2)
else:
    print((dif // 2) + 2)

Submission status: Accepted

Solution code:
A,B,C = sorted(map(int,input().split()))
#1減らす or 2増やす
C -= A
B -= A
ans = 0
ans += C%2
C -= C%2
ans += B%2
B -= B%2
ans += 2*(C//2)
ans -= B//2
print(ans)

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
a1 = max(a,b,c)
c1 = min(a,b,c)
b1 = a+b+c-a1-c1

if b1%2 ==c1%2:
    print(int((2*a1-c1-b1)/2))
else:
    print(int((2*(a1+1)-c1-b1)/2)+1)

Submission status: Accepted

Solution code:
a=sorted(list(map(int,input().split())))
x=0
i=(a[1]-a[0])//2
x+=i
a[1]-=i*2
a[2]-=i*2
i=(a[2]-a[1])
a[2]-=i
x+=i
print(x+sum(a)-a[0]*3)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X,Y,Z=sorted(list(map(int,input().split(' '))))
print((Z-Y)+(Y-X)//2+2*((X-Y)%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:
n=list(map(int, input().split()))
n.sort(reverse = True)
count=0
while True:
    if n[1]>=n[0]:
        break
    n[1]+=2
    count+=1
while True:
    if n[2]>=n[0]:
        break
    n[2]+=2
    count+=1
n.sort(reverse=True)
if len(set(n))==1:
    print(count)
elif n.count(n[0])==2:
    print(count-1)
else:
    print(count+1)

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
wa = A+B+C
maxnum = max(A, B, C)

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

Submission status: Accepted

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

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

x = C - B
y = C - A
def func(x, y):
  return ((y-x)//2 + x)

if ((x-y) % 2) == 1:
  print(1 + func(x, y+1))
else:
  print(func(x, y))

Submission status: Accepted

Solution code:
tin = [int(i) for i in input().split(' ') ]
A,B,C = tin[0],tin[1],tin[2]
if (A+B+C - max(A,B,C)) % 2 == 0:
  print(int((3*max(A,B,C) - A - B - C)/2))
else:
  print( int( (3*max(A,B,C) - A - B - C - 1)/2 + 2 ) )

Submission status: Accepted

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

c=a[0]%2+a[1]%2+a[2]%2
ans=0
if(c==0 or c==3):
    ans+=a[2]-a[0]+a[2]-a[1]
    ans//=2
else:
    if(c==1):
        for i in range(3):
            if(a[i]%2==0):
                a[i]+=1
    elif(c==2):
        for i in range(3):
            if(a[i]%2!=0):
                a[i]+=1
    ans+=1
    ans+=(a[2]-a[0]+a[2]-a[1])//2

print(ans)

Submission status: Accepted

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

#parity=set(list(map(lambda x: x % 2,[a,b,c])))
parity=list(map(lambda x: x % 2,[a,b,c]))

if len(set(parity))==1:
    print(int((3*max(a,b,c)-a-b-c)/2))
else:
    if (b-a)%2==0:
        ex=1
    else:
        ex=2
    print(int((max(a,b,c)-a)/2)+int((max(a,b,c)-b)/2)+int((max(a,b,c)-c)/2) + ex)

Submission status: Accepted

Solution code:
temp = list(map(int, input().split()))
temp.sort()
a, b, c = temp[0], temp[1], temp[2]

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

Submission status: Accepted

Solution code:
temp = list(map(int, input().split()))
temp.sort()
a, b, c = temp[0], temp[1], temp[2]
count = 0

while(c - b > 1):
    b += 2
    count += 1

while(b - a > 1):
    a += 2
    count += 1

if a == b == c: print(count)
elif c - b == 1 and b - a == 1: print(count + 3)
elif c - b == 1 and b - a == 0: print(count + 1)
else: print(count + 2)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

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

nums.sort()

ans = 0
while nums[0] != nums[-1]:
    if nums[0] < nums[1]:
        nums[0] += 2
    else:
        nums[0] += 1
        nums[1] += 1
    ans += 1
    nums.sort()
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ABC = map(int, raw_input().split())
max_num = max(ABC)
res = 0
rest = 0
for v in ABC:
    res += (max_num - v) / 2
    rest += (max_num - v) % 2
sum_num = max_num * 3 - rest
while sum_num % 3 != 0:
    sum_num += 2
    res += 1
print res

Submission status: Accepted

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

Submission status: Accepted

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

ret = 0

m = A % 2 + B % 2 + C % 2

if m == 3 or m == 0:
    pass
else:
    ret += 1
    if m == 2:
        if A % 2 == 0:
            B += 1
            C += 1
        elif B % 2 == 0:
            A += 1
            C += 1
        else:
            A += 1
            B += 1
    else:
        if A % 2 == 1:
            B += 1
            C += 1
        elif B % 2 == 1:
            A += 1
            C += 1
        else:
            A += 1
            B += 1

print(ret + (C - B) // 2 + (C - A) // 2)

Submission status: Accepted

Solution code:
def main():
    num = [int(i) for i in input().split()]
    num.sort()
    ans = 0
    ans += (num[2]-num[1])
    ans+=(num[1]-num[0])//2
    if (num[1]-num[0])%2==1:
        ans+=2
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def inpl(): return [int(i) for i in input().split()]
C, B, A = sorted(inpl())
if (B-C)%2 == 0:
    print((2*A -B -C)//2)
else:
    print((2*A -B -C +3)//2)

Submission status: Accepted

Solution code:
def inpl(): return [int(i) for i in input().split()]
A, B, C = inpl()
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 == 0:
    print((2*A -B -C)//2)
else:
    print((2*A -B -C +3)//2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

count = 0
while B - A >= 2 or C - A >= 2:
    A += 2
    count += 1

while A - B >= 2 or C - B >= 2:
    B += 2
    count += 1

while B - C >= 2 or A - C >= 2:
    C += 2
    count += 1


t = sorted([A, B, C])
if t[0] == t[2]:
    print(count)
elif t[0] == t[1]:
    print(count + 1)
else:
    print(count+2)

Submission status: Accepted

Solution code:
N=1
for t in range(N):
    x, y, z = list(map(int, input().split()))
    if (x == y and y == z):
        print(0)
        continue
    cost = 0
    l = sorted([x, y, z])

    cost += (l[2] - l[1])

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

    if (l[2] - a)%2 == 0:
        cost += (l[2] - a)//2
    else:
        cost += ((l[2] - a)//2 + 2)

    print(cost)

Submission status: Accepted

Solution code:
#t=int(input())
t=1
for i in range(t):
	x,y,z=map(int,input().split())
	ma=max(x,y,z)
	mi=min(x,y,z)
	if(x==ma):
		if(y<z):
			m=x-y
			n=x-z
		else:
			m=x-z
			n=x-y
	elif(y==ma):
		if(x<z):
			m=y-x
			n=y-z
		else:
			m=y-z
			n=y-x
	else:
		if(x<y):
			m=z-x
			n=z-y
		else:
			m=z-y
			n=z-x
	ans=n+(m-n)//2
	if((m-n)%2==1):
		ans+=2
	print(ans)

Submission status: Accepted

Solution code:
def noofrupees(x,y,z):
    if(x==y and x==z):
        return 0
    elif(x==y):
        if(x<z):
            return z-x
        else:
            if(x%2==0 and z%2==0):
                return int((x-z)/2)
            elif(x%2!=0 and z%2!=0):
                return int((x-z)/2)
            else:
                z = z-1
                return int((x-z)/2)+1
    elif(x==z):
        if(x<y):
            return y-x
        else:
            if(x%2==0 and y%2==0):
                return int((x-y)/2)
            elif(x%2!=0 and y%2!=0):
                return int((x-y)/2)
            else:
                y = y-1
                return int((x-y)/2)+1
    elif(y==z):
        if(y<x):
            return x-y
        else:
            if(y%2==0 and x%2==0):
                return int((y-x)/2)
            elif(y%2!=0 and x%2!=0):
                return int((y-x)/2)
            else:
                x = x-1
                return int((y-x)/2)+1
    
#t= int(input())
t=1;
for v in range(t):
    x,y,z = map(int,input().split())
    if(x!=y and x!=z and y!=z):
        list1 = [x,y,z]
        list1.sort()
        s = list1[2] - list1[1]
        list1[0]+=s
        list1[1]+=s
        print(s+noofrupees(list1[0],list1[1],list1[2]))
    else:
        print(noofrupees(x,y,z))

Submission status: Accepted

Solution code:
#N = int(input())
lis = []
N=1
for T in range(N):
	c = list(map(int, input().split()))
	maxi = max(c)
	sum = 0
	for i in c:
		sum = sum + (maxi - i)
	if sum%2 == 0:
		lis.append(sum//2)
	else:
		lis.append((sum+3)//2)
for i in lis:
	print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def ans(a,b,c):
    return c - (a + b) / 2

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

odd = 0
even = 0

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

if abs(even - odd) == 3:
    l.sort()
    print(int(ans(l[0], l[1], l[2])))

elif even - odd == 1:
    for i in range(3):
        if l[i] % 2 == 0:
            l[i] = l[i] + 1
    
    l.sort()
    print(int(1 + ans(l[0], l[1], l[2])))

elif odd - even == 1:
    for i in range(3):
        if l[i] % 2 == 1:
            l[i] = l[i] + 1
    
    l.sort()
    print(int(1 + ans(l[0], l[1], l[2])))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

a.sort()
B=a[1]
A=a[0]
C=a[2]
count=0
if (B-A)%2==0:
    count+=(B-A)/2
else:
    count+=(B-A+1)/2+1

count+=C-B

print count

Submission status: Accepted

Solution code:

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

hoge = l[2] - l[1]
ans = hoge

l[0] += hoge
fuga = l[2] - l[0]

if fuga % 2 == 0:
    ans += fuga // 2
else:
    ans += fuga // 2 + 2

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
a,b,c = sorted([int(x) for x in input().split()])
ret = (c-a)//2 + (c-b)//2
a = a + 2*((c-a)//2)
b = b + 2*((c-b)//2)

if a==b and b==c:
    print(ret)
elif a<c and b<c:
    print(ret+1)
else:
    print(ret+2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

l1 = sys.stdin.readline().strip()
l1 = [int(x.strip()) for x in l1.split()]

A, B, C = sorted(l1)

rA, sA = divmod((C-A), 2)
rB, sB = divmod((C-B), 2)
s = [sA, sB]

res = rA + rB

if s == [0, 0]:
  res += 0
elif s == [1, 1]:
  res += 1
else:
  res += 2

print(res)

Submission status: Accepted

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

a.sort()

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

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

Submission status: Accepted

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

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

print(int(count))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c = [int(i) for i in input().split(" ")]
A = [a,b,c]
A.sort()
a, b, c = A[0], A[1], A[2]

s = sum(A)
if 3*c%2 == s%2:
    print((3*c - a - b - c)//2)
else:
    print((3*c-a-b-c+3)//2)

Submission status: Accepted

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

diff=3*max(A,B,C)-A-B-C
answer=0

big=max(A,B,C)
small=min(A,B,C)
median=A+B+C-big-small

if diff%2==1:
  big=max(A,B,C)+1
  small=min(A,B,C)+1
  answer+=1

while(big!=small):
  if(median!=big and small!=big):
    median+=1
    small+=1
    answer+=1
  elif(small!=big):
    small+=2
    answer+=1
  
print(answer)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

def gain(x, y):
	if (y - x) % 2 == 0:
		return (y - x) // 2
	else:
		return (y - x) // 2 + 2

ans1 = b + c - (2 * a)
ans2 = gain(a, b) + c - b
ans3 = gain(a, c) + gain(b, c)

print(min(ans1, ans2, ans3))

Submission status: Accepted

Solution code:
A,B,C=map(int,input().split())
L=[A,B,C]
L.sort()
ans=0
s=(L[-1]-L[0])//2
L[0]=L[0]+2*s
t=(L[-1]-L[1])//2
L[1]=L[1]+2*t
L.sort()
a=0
if L[0]!=L[1]:
    a=2
elif L[1]!=L[2]:
    a=1
print(s+t+a)