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:
aa = list(sorted(map(int, input().split())))
nn = sum(map(lambda x: x % 2, aa))
ans = 0
if nn == 1:
    ans += 1
    for i in range(3):
        if aa[i] % 2 == 0:
            aa[i] += 1
elif nn == 2:
    ans += 1
    for i in range(3):
        if aa[i] % 2 == 1:
            aa[i] += 1
ans += (aa[2] - aa[0]) // 2
ans += (aa[2] - aa[1]) // 2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def judge1(lst):
    flag = False
    if lst[-1] == lst[-2]:
        flag = True
    return flag


def main():
    lst = list(map(int, input().split()))
    lst.sort()
    count = 0

    while True:
        if judge1(lst):
            break

        lst[0] += 1
        lst[1] += 1
        count += 1

    while lst[2] - lst[0] >= 2:
        lst[0] += 2
        count += 1

    if lst[2] - lst[0] == 1:
        count += 2

    print(count)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

abc.sort()

diff1 = abc[2]-abc[0]
diff2 = abc[2]-abc[1]

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

Submission status: Accepted

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

s = a+b+c
m = max(a,b,c)

if s%2==m%2:
    ans = (3*m-s)//2
else:
    ans = (3*(m+1)-s)//2
    
print(ans)

Submission status: Accepted

Solution code:
num = list(map(int,input().split()))
num.sort(reverse=True)
M = max(num)
l = [M-i for i in num]
gap = l[2] - l[1]
ans = 0

if gap % 2 == 0:
    ans = l[1] + int(gap/2)
else:
    ans = l[1] + int(gap/2)+2
print(ans)

Submission status: Accepted

Solution code:
# coding=utf-8
import math

if __name__ == '__main__':
    A, B, C = map(int, input().split())

    MV = max(A, B, C) * 3
    SumABC = A + B + C

    if MV % 2 == 0 and SumABC % 2 == 0:
        ans = (MV - SumABC) / 2

    elif MV % 2 == 1 and SumABC % 2 == 1:
        ans = math.ceil(MV - SumABC) / 2

    else:
        ans = math.ceil((MV - SumABC) / 2) + 1

    print(int(ans))

Submission status: Accepted

Solution code:
#C - Same Integers
ABC = list(map(int,input().split()))
ABC = sorted(ABC,reverse = True)
A = ABC[0]#max
B = ABC[1]
C = ABC[2]#min
count = 0
while A != B:
    C += 1
    B += 1
    count += 1
while (B - C)%2 == 1:
    A += 1
    B += 1
    count += 1
while A!=C:
    C += 2
    count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
if (abc[1]-abc[0])%2 == 1:
  ans += 1
  abc[1] += 1
  abc[2] += 1

ans += (abc[1]-abc[0])//2
abc[0] += abc[1]-abc[0]
ans += abc[2]-abc[1]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if A[1]-A[0]>=2:
  cnt += (A[1]-A[0])//2
  A[0]+= cnt*2

if A[0]==A[1] and A[1]==A[2]:
  print(cnt)
  exit()

  
while(True):
  cnt+=1
  A = sorted(A)
  A[0]+=1
  A[1]+=1
  #print(A)
  if A[0]==A[1] and A[1]==A[2]:
    break

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

ans = A[2] - A[1]

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
A,B,C=map(int,input().split())
SUM=A+B+C
MAX=max(A,B,C)*3
if (MAX-SUM)%2==0:
    count=(MAX-SUM)/2
else:
    count=(MAX-SUM)/2+2
print(int(count))

Submission status: Accepted

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

Submission status: Accepted

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

for n in range(50):
  if A==B==C:
    break
  elif A<C and B<C:
    A+=1
    B+=1
    ans+=1
  elif A<C and B==C:
    A+=2
    ans+=1
  else:
    B+=1
    C+=1
    ans+=1
    
print(ans)

Submission status: Accepted

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

diff1 = a[0] - a[1]
diff2 = a[0] - a[2]
cnt1 = diff1 // 2
cnt2 = diff2 // 2
result = sum([cnt1, cnt2])

diff1 -= cnt1 * 2
diff2 -= cnt2 * 2

s = sum([diff1, diff2])
if s & 1:
  print(result + 2)
else:
  print(result + s // 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# no matter what in every operation u will be adding two to the sum of all the numbers
# check when 2*i is divisible by 3 and each no should be greater than the maximum
def main():
	a, b , c = map(int , input().split())
	if a==b and b==c:
		print(0)
	else:
		tot=0
		tot = tot+(a+b+c)
		mx = max(a, max(b, c))
		i = 0
		f=0
		while f==0:
			if((tot+2*i)%3==0):
				p = ((tot+2*i))//3
				if p>=mx:
					f=1
			i = i+1
		print(i-1)
if __name__=="__main__":
	main()

Submission status: Accepted

Solution code:

def main():
	a, b , c = map(int , input().split())
	if a==b and b==c:
		print(0)
	else:
		tot=0
		tot = tot+(a+b+c)
		mx = max(a, max(b, c))
		i = 0
		f=0
		while f==0:
			if((tot+2*i)%3==0):
				p = ((tot+2*i))//3
				if p>=mx:
					f=1
			i = i+1
		print(i-1)
if __name__=="__main__":
	main()

Submission status: Accepted

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

Submission status: Accepted

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

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




if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ABC = list(map(int, input().split()))
cnt = 0
while len(set(ABC))!=1:
    A = sorted(ABC)[0]
    B = sorted(ABC)[1]
    C = sorted(ABC)[2]
    if ABC[0]%2==ABC[1]%2==ABC[2]%2:
        A += 2
        cnt += 1
    else:
        A += 1
        B += 1
        cnt += 1
    ABC = A,B,C
print(cnt)

Submission status: Accepted

Solution code:
'''
Created on 2020/08/17

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  A=list(map(int,pin().split()))
  A.sort()
  t=A[2]
  ans=0
  if A[0]%2!=A[1]%2:
    ans+=1
    A[1]+=1
    A[2]+=1
  ans+=A[2]-A[1]+(A[1]-A[0])//2
  print(ans)
  return 

main()

Submission status: Accepted

Solution code:
#
# abc093 c
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2 5 4"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2 6 3"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """31 41 5"""
        output = """23"""
        self.assertIO(input, output)


def resolve():
    I = list(map(int, input().split()))
    I.sort()

    t = 2*I[2]-I[0]-I[1]
    # X = max(A, B, C)
    if t % 2 == 0:
        print(t//2)
    # X = max(A, B, C) + 1
    else:
        print((t+3)//2)


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def solve():

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

    X = sorted(X, reverse=True)

    X_max = max(X) #A~Cの内、最大のもの
    n = 0

    while X[0] > X[1]:
        X[1] += 1
        n += 1
    while X[0] > X[2]:
        X[2] += 1
        n += 1
    if n%2 == 1:
        n += 3

    ans =int(n / 2)

   # print(X)
    print(ans)
    
    

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
def main():
    A, B, C = map(int, input().split())
    max_num = max(A, B, C)
    t = 3 * max_num - A - B - C
    ans = 0

    if t % 2 == 0:
        ans = int(t / 2)
    else:
        ans = int((t + 3) / 2)

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

    cnt = 0
    while True:
        if abs(abc[2] - abc[0]) <= 1 and abs(abc[2] - abc[0]) <= 1:
            break
        abc[0] += 2
        abc = sorted(abc)
        cnt += 1
    ans = cnt
    if abc[0] == abc[1] and abc[1] == abc[2]:
        ans = cnt
    elif abc[2] == abc[1]:
        ans += 2
    elif abc[0] == abc[1]:
        ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

while C - A >= 2:
    A += 2
    ans += 1

while C - B >= 2:
    B += 2
    ans += 1


if A == B == C:
    print(ans)
elif C - A == 1 and C - B == 1:
    ans += 1
    print(ans)
else:
    ans += 2
    print(ans)

Submission status: Accepted

Solution code:
A = list(map(int, input().split()))
A.sort()
g=0
k=0
cnt=0
for i in A:
    if i%2==0:
        g+=1
if g==0 or g==3:
    cnt=(2*A[2]-A[0]-A[1])/2
elif g==1:
    for i in range(3):
        if A[i]%2==1:
            A[i]+=1
    cnt=(2*A[2]-A[0]-A[1])/2+1
elif g==2:
    for i in range(3):
        if A[i]%2==0:
            A[i]+=1
    cnt=(2*A[2]-A[0]-A[1])/2+1
    
print(int(cnt))

Submission status: Accepted

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

cnt = 0
if a%2 != b%2:
    c += 1
    a += 1
    cnt += 1

while True:
    if a == c or b == c:
        break
    a += 1
    b += 1
    cnt += 1
if a == c:
    print(cnt)
else:
    print(cnt+(c-a)//2)

Submission status: Accepted

Solution code:
X = list(map(lambda x: int(x), input().split(" ")))
X.sort()

print(X[2] - X[1] + int((X[1] - X[0]) / 2) + 2 * ((X[1] - X[0]) % 2))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

else:
    if c%2==1:
        print((c*3+3-sum([a,b,c]))//2);exit()
    else:
        print((c*3-sum([a,b,c]))//2)
        exit()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

    ans= 0
    even = []
    odd = []
    for i in [a, b, c]:
        if i % 2== 0:
            even.append(i)
        else:
            odd.append(i)
    if len(even) == 1:
        ans += 1 #奇数に+1
        odd[0] += 1
        odd[1] += 1
        m = max(max(even), odd[0]+1)
        even.extend(odd)
        for i in even:
            ans += (m-i)//2
    elif len(even) == 2:
        ans += 1 #偶数に+１
        even[0] += 1
        even[1] += 1
        m = max(max(even),odd[0])
        even.extend(odd)
        for i in even:
            ans += (m-i)//2
    elif len(even) == 3 or len(odd) == 3:
        m = max(max(even, odd))
        for i in max(even, odd):
            ans += (m-i)//2
    print(ans)
resolve()

Submission status: Accepted

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

Submission status: Accepted

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

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

print(int(ans))

Submission status: Accepted

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

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

if (abc[2]-abc[0])%2 == 1:
  abc[1] += 1
  abc[2] += 1
  ans += 1

ans += (abc[2]-abc[0])//2
print(ans)

Submission status: Accepted

Solution code:
ABC= list(map(int, input().split()))
M = max(ABC)
ans = 0
for i in range(3):
    ABC[i] = M - ABC[i]
    ans += ABC[i] // 2
    ABC[i] = ABC[i] % 2

if sum(ABC) == 2:
    ans += 1
elif sum(ABC) == 1:
    ans += 2
else:
    ans += 0
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A = list(map(int, readline().split()))

    Asum = sum(A)
    Amax = max(A)

    if Asum % 2 == 3 * Amax % 2:
        ans = (3 * Amax - Asum) // 2
    else:
        ans = (3 * (Amax + 1) - Asum) // 2

    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A = list(map(int, readline().split()))

    A.sort()

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

    if A[0] == A[1]:
        if A[0] < A[2]:
            ans += 1
    else:
        ans += 2

    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

A.sort()

t1 = A[2] - A[1]
t2 = A[1] - A[0]

if t2 % 2 == 0:
    print(t1 + t2 // 2)

else:
    print(t1 + t2 // 2 + 2)

Submission status: Accepted

Solution code:
A,B,C = map(int,input().split())
ans = 0
Aj = 0
Bj = 0
Cj = 0
if(A % 2 == 1):
  Aj = 1
if(B % 2 == 1):
  Bj = 1
if(C % 2 == 1):
  Cj = 1
if(Aj == Bj and Bj == Cj):
  pass
else:
  if(Aj == Bj):
    A += 1
    B += 1
    ans += 1
  if(Bj == Cj):
    B += 1
    C += 1
    ans += 1
  if(Aj == Cj):
    A += 1
    C += 1
    ans += 1
mokuhyo = max(A,B,C)
while(A != mokuhyo):
  A += 2
  ans += 1
while(B != mokuhyo):
  B += 2
  ans += 1
while(C != mokuhyo):
  C += 2
  ans += 1
print(str(ans))

Submission status: Accepted

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

a,b,c = sorted(lis)

bc = c-b
ab = b-a

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if d1==d2:print(d1)
elif (d1-d2)%2==1:print(d2+(d1-d2+1)//2+1)
else:print(d2+(d1-d2)//2)

Submission status: Accepted

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

Submission status: Accepted

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

a = abs(l[0]-l[1])%2
b = abs(l[1]-l[2])%2
c = abs(l[0]-l[2])%2

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

Submission status: Accepted

Solution code:
def f(abc,c):
    m = max(abc)
    a = 0
    for i in abc:
        a += (i < m)
    if a == 0:
        return c
    c += 1
    if a <= 1:
        for i,x in enumerate(abc):
            if x < m:
                abc[i] += 2
                break
        return f(abc,c)
    else:
        for i,x in enumerate(abc):
            if x < m:
                abc[i] += 1
        return f(abc,c)


abc = list(map(int, input().split()))
print(f(abc,0))

Submission status: Accepted

Solution code:
l = sorted(list(map(int,input().split())))
x = abs(l[2]-l[0])
y = abs(l[2]-l[1])

if (x%2 == 0 and y%2 == 0): # 差が ぐぐ
    ans = x//2 + y//2
elif (x%2 == 1 and y%2 == 1): #差が きき
    ans = x//2 + y//2 + 1
else: # 差が ぐき or きぐ
    ans = x//2 + y//2 + 2

print (ans)

Submission status: Accepted

Solution code:
abc=sorted(list(map(int,input().split())))
abc[1]-=abc[0]
abc[2]-=abc[0]
abc[0]=0

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

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

ans = 0
if C % 2 == 0:
    if A % 2 == 0 and B % 2 == 1:
        ans += 1
        A += 1
        C += 1
    elif A % 2 == 1 and B % 2 == 0:
        ans += 1
        B += 1
        C += 1
    elif A % 2 == 1 and B % 2 == 1:
        ans += 1
        A += 1
        B += 1
else:
    if A % 2 == 0 and B % 2 == 1:
        ans += 1
        B += 1
        C += 1
    elif A % 2 == 1 and B % 2 == 0:
        ans += 1
        A += 1
        C += 1
    elif A % 2 == 0 and B % 2 == 0:
        ans += 1
        A += 1
        B += 1

while C > A:
    A += 2
    ans += 1

while C > B:
    B += 2
    ans += 1

print(ans)

Submission status: Accepted

Solution code:
A,B,C=map(int,input().split())
odd = A%2+B%2+C%2
answer = 0
if odd == 1:
  answer = 1
  if not A%2:
    A += 1
  if not B%2:
    B += 1
  if not C%2:
    C += 1
elif odd == 2:
  answer = 1
  if A%2:
    A += 1
  if B%2:
    B += 1
  if C%2:
    C += 1
D = sorted([A,B,C])
answer += (D[2]-D[0])//2+(D[2]-D[1])//2
print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=list(map(int,input().split()))
a.sort()
#print(a)
b1=a[2]-a[0]
b2=a[2]-a[1]

if b1%2==0 and b2%2==0:
    print(b1//2+b2//2)
elif b1%2==1 and b2%2==1:
    print(b1//2+b2//2+1)
else:
    print(b1//2+b2//2+2)

Submission status: Accepted

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

if all([i % 2 == 0 for i in A]) or all([i % 2 == 1 for i in A]):
    print((A[0] - A[1] + A[0] - A[2]) // 2)
else:
    if [i % 2 == 0 for i in A].count(True) == 2:
        for i in range(3):
            if A[i] % 2 == 0:
                A[i] += 1
        print((A[0] - A[1] + A[0] - A[2]) // 2 + 1)
    else:
        for i in range(3):
            if A[i] % 2 == 1:
                A[i] += 1
        print((A[0] - A[1] + A[0] - A[2]) // 2 + 1)

Submission status: Accepted

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

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

Submission status: Accepted

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

max_num = max(a,b,c)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
ans = 0
lst = sorted([a, b, c])
while not lst[0]==lst[1]==lst[2]:
    ans += 1
    if lst[0] == lst[1]:
        lst[0] += 1
        lst[1] += 1
    elif lst[1] == lst[2]:
        if lst[2]-lst[0] >= 2:
            lst[0] += 2
        else:
            lst[1] += 1
            lst[2] += 1
    else:
        lst[0] += 2
        lst.sort()

print(ans)

Submission status: Accepted

Solution code:
li = list(map(int,input().split()))
su = sum(li)
ma = max(li)

if su%2 == ma%2:print(int((ma*2-(su-ma))/2))
else:print(int(((ma+1)*2-(su-ma)+1)/2))

Submission status: Accepted

Solution code:
# ABC093 C - Same Integers

def is_eaven(n):
    if n%2==0:
        return 1
    else:
        return 0

L=list(map(int,input().split()))
# templ=[l for l in L if is_eaven(l)]
# templ=[lambda l: l%2==0 for l in L ]
ans=0

tempL=[]

if L[0]==L[1]==L[2]:
    print(ans)
    exit()

for l in L:
    tempL.append(is_eaven(l))
if all (tempL) or not any(tempL):   #全て偶数or全て奇数の場合はpass
    pass
elif tempL.count(0)==2:
    for i in range (2):
        if tempL[i]==0:
            L[i]+=1
    ans+=1
elif tempL.count(1)==2:
    for i in range (2):
        if tempL[i]==1:
            L[i]+=1
    ans+=1
else:
    pass

if L[0]==L[1]==L[2]:
    print(ans)
    exit()

L.sort()

ans+=(L[2]-L[0])//2

if L[0]==L[1]==L[2]:
    print(ans)
    exit()

ans+=(L[2]-L[1])//2
print(ans)

Submission status: Accepted

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

porpose = max(A)
if (3*porpose-sum(A))%2 == 1:
    porpose+=1

print((3*porpose-sum(A))//2)

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
x=sorted([a,b,c])
count=0
if sum(x)%2==x[2]%2:
    while True:
        if x[1]==x[2] and x[0]==x[2]:
            break
        elif x[1]==x[2] and x[0]!=x[2]:
            x[0]+=2
        else:
            x[1]+=1
            x[0]+=1
        count+=1

else:
    x[2]+=1
    x[0]+=1
    count+=1
    while True:
        if x[1]==x[2] and x[0]==x[2]:
                break
        elif x[1]==x[2] and x[0]!=x[2]:
            x[0]+=2
        else:
            x[1]+=1
            x[0]+=1
        count+=1
print(count)

Submission status: Accepted

Solution code:
from collections import Counter
abc = list(map(int, input().split()))

ans = 0
m = max(abc)
for i in range(len(abc)):
    count = (m-abc[i])//2
    ans += count
    abc[i] = abc[i]+2*count

abc = Counter(abc)

if len(abc)==1:
    print(ans)
else:
    key = [k for k, v in abc.items() if v == 2][0]
    if key == m:
        print(ans+2)
    else:
        print(ans+1)

Submission status: Accepted

Solution code:
# coding:utf-8
a, b, c = map(int, input().split())
m = max(a, b, c)
s = a + b + c
diff = 3 * m - s

if diff % 2 == 0:
    ans = diff // 2
else:
    ans = (diff // 2) + 2

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=list(map(int,input().split()))
b=0
if a[0]==a[1]==a[2]:
  f=False
else:
  f=True
  
while f:
  if max(a)-min(a)>1:
    a.sort()
    a[0]+=2
    b+=1
  else:
    a.sort()
    a[0]+=1
    a[1]+=1
    b+=1
  if a[0]==a[1]==a[2]:
    f=False

print(b)

Submission status: Accepted

Solution code:
arr = list(int(a) for a in input().split())

# 最小値ベースに直して
# ２つ選んで２減らす
# １つ選んで１減らす

arr.sort()
A = 0
B = arr[1] - arr[0]
C = arr[2] - arr[0]

# 2で何回割り切れるか
ans = B // 2

# 残りがいくつあるか
B -= ans * 2
C -= ans * 2
ans += B + C

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,C = sorted(int(X) for X in input().split())
Count = 0
if A!=C and B!=C:
    Count += C-B
    A += C-B
if A!=C:
    Count += (C-A)//2 + 2*((C-A)%2!=0)
print(Count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
if (a+b+c)%2 :
    if a%2 and b%2 and c%2 :
        total = a + b + c
        mx = max(a,b,c)
        diff = 3*mx - total
        print(diff//2)
    else :
        if not a%2 :
            a += 1
        if not b%2 :
            b += 1
        if not c%2 :
            c += 1
        total = a + b + c
        mx = max(a,b,c)
        diff = 3*mx -total
        ans = 1 + diff//2
        print(ans)
else :
    if not (a%2 or b%2 or c%2) :
        total = a + b + c
        mx = max(a,b,c)
        diff = 3*mx -total
        print(diff//2)
    else :
        if a%2 :
            a += 1
        if b%2 :
            b += 1
        if c%2 :
            c += 1
        total = a + b + c
        mx = max(a,b,c)
        diff = 3*mx - total
        ans = 1 + diff//2
        print(ans)

Submission status: Accepted

Solution code:
import statistics
import math
abc = list(map(int,input().split()))
max = max(abc)
med = statistics.median(abc)
min = min(abc)
cop = (max-med)+(max-min)
if cop%2 == 0:
	print(cop//2)
else:
	print(math.ceil(cop/2)+1)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    a, b, c = map(int, input().split())
    r = 0
    if a % 2 == b % 2 == c % 2:
        pass
    else:
        # 奇数が１つ → 偶数に+1
        if (a + b + c) % 2 == 1:
            a += 1 if a % 2 == 0 else 0
            b += 1 if b % 2 == 0 else 0
            c += 1 if c % 2 == 0 else 0
        # 奇数が２つ → 奇数に+1
        else:
            a += 1 if a % 2 == 1 else 0
            b += 1 if b % 2 == 1 else 0
            c += 1 if c % 2 == 1 else 0
        r += 1
    r += ((max(a, b, c) * 3 - (a + b + c)) // 2)
    print(r)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
t = sum(a)
ans = 0
while t%3 > 0 or t < max(a)*3:
    ans, t = ans+1, t+2

print(ans)

Submission status: Accepted

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

dist1=a[2]-a[0]
dist2=a[2]-a[1]

if (dist1%2)==0 and (dist2%2)==0:
  ans=(dist1+dist2)//2
  print(ans)
  
elif (dist1%2)==1 and (dist2%2)==1:
  ans=(dist1+dist2)//2
  print(ans)
  
elif (dist1%2)==0 and (dist2%2)==1:
  ans=(dist1//2)+(dist2+1)//2
  print(ans+1)
  
else:
  ans=(dist2//2)+(dist1+1)//2
  print(ans+1)