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: Time Limit Exceeded

Solution code:
state = list(map(int,input().strip().split(' ')))
states = [state]
flag=True
counterlist=[]
counterlist.append(0)

def procedure1(s,c):
    #case1
    states.append([s[0]+1, s[1]+1, s[2]])
    counterlist.append(c+1)
    
    #case2
    states.append([s[0]+1, s[1], s[2]+1])
    counterlist.append(c+1)
    
    #case3
    states.append([s[0], s[1]+1, s[2]+1])
    counterlist.append(c+1)
    
def procedure2(s,c):
    #case1
    states.append([s[0]+2, s[1], s[2]])
    counterlist.append(c+1)
    
    #case2
    states.append([s[0], s[1]+2, s[2]])
    counterlist.append(c+1)
    
    #case3
    states.append([s[0], s[1], s[2]+2])
    counterlist.append(c+1)

while flag:
    s = states.pop(0) 
    c = counterlist.pop(0)
    if s[0]==s[1] and s[1]==s[2]:
        flag=False
        print(c)

    procedure1(s,c)
    procedure2(s,c)

Submission status: Time Limit Exceeded

Solution code:
A, B, C = map(int, input().split())
count = 0
ABC_list = [A, B, C]
D = max(ABC_list)
ABC_list.remove(max(ABC_list))
E = max(ABC_list)
F = min(ABC_list)
while True:
    if D == E == F:
        break
    while D > E:
        E += 2
        count += 1
    while D > F:
        F += 2
        count += 1
    if D != E == F:
        E += 1
        F += 1
        count += 1
    
print(count)

Submission status: Time Limit Exceeded

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

max_num = master_list[2]
first_n = master_list[0]
secon_n = master_list[1]

count = 0

while True:
    if max_num == first_n == secon_n:
        break

    if max_num != first_n and max_num != secon_n:
        first_n += 1
        secon_n += 1
        count += 1
    elif max_num == first_n:
            secon_n += 2
            count += 1
    else:
        first_n += 2
        count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
import random

data = list(map(int, input().split()))
lst = data[:]
n = 0
minimum = 1000000

for i in range(1000):
    while True:
        if data[0] == data[1] and data[1] == data[2]:
            data = lst[:]
            if n < minimum:
                minimum = n
            n = 0
            break

        f = random.randint(0, 1)
        if f == 0:
            lst[random.randint(0, 2)] += 1
            lst[random.randint(0, 2)] += 1
        else:
            lst[random.randint(0, 2)] += 2
        n += 1

print(minimum)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

g = np.array([
    [1, 1, 1, 0],
    [1, 1, 0, 1],
    [1, 0, 1, 1],
    [1, 2, 0, 0],
    [1, 0, 2, 0],
    [1, 0, 0, 2]
])

queue = [np.array([0] + [ int(n) for n in input().split() ])]

while queue:
    r = queue.pop(0)

    if r[1] == r[2] == r[3]:
        print(r[0])
        break

    queue.extend(np.tile(r,(6,1))+g)

Submission status: Time Limit Exceeded

Solution code:

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

x.sort()
count=0

x[0]=x[2]-x[0]
x[1]=x[2]-x[1]


while not(x[0]==1 or x[0]==2):
    x[0]=x[0]-2
    count+=1

while not(x[1]==1 or x[1]==2):
    x[1]=x[1]-2
    count+=1

if (x[0]==1 and x[1]==1):
    print(count+1)
    quit()

if (x[0]==2 and x[1]==2):
    print(count+2)
    quit()

if (x[0]*x[1]==2):
    print(count+3)
    quit()

Submission status: Time Limit Exceeded

Solution code:
a,b,c=map(int, input().split(" "))
ans=0
while not a==b==c:
    if (a==b or b==c or c==a):
        if a==b and a<c:
            a += 1
            b += 1
            ans += 1
        elif a==b and a>c:
            c += 2
            ans += 1
        elif a == c and a < b:
            c += 1
            a += 1
            ans += 1
        elif a == c and a > b:
            b += 2
            ans += 1
        elif b == c and a < b:
            a += 2
            ans += 1
        elif b == c and a < b:
            b += 1
            c += 1
            ans += 1
    else:
        if a<b and a<c:
            a+=2
            ans+=1
        elif b<c:
            b+=2
            ans+=1
        else:
            c+=2
            ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

s = a+b+c
cnt = 0
while not (s%3==0 and s//3 >= a and s//3 >= b and s//3>= c):
    s += 2
    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:

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

l.sort()

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

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

print(int(ans))

Submission status: Accepted

Solution code:
# coding: utf-8

def main():
    N = sorted(list(map(int, input().split())))
    ans = N[2] - N[1]
    d = N[1] - N[0]
    if d % 2 != 0:
        ans += 2
    ans += d // 2
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-09-26 23:35:00 +0900
# LastModified: 2020-09-26 23:50:15 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    L = list(map(int, input().split()))
    ans = 0
    max_idx = L.index(max(L))
    min_idx = L.index(min(L))
    for i in range(len(L)):
        if i == max_idx or i == min_idx:
            pass
        else:
            medium_idx = i
    ans += (L[max_idx] - L[medium_idx])
    L[medium_idx] = L[max_idx]
    L[min_idx] += ans
    if (L[max_idx]-L[min_idx]) % 2 == 0:
        print(ans + (L[max_idx]-L[min_idx])//2)
    else:
        print(ans + (L[max_idx]-L[min_idx]+1)//2 + 1)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N_List = sorted(list(map(int,input().split())))
cnt = 0
if N_List[0] + 2 <= N_List[2]:
    cnt += (N_List[2] - N_List[0])//2
    N_List[0] += ((N_List[2] - N_List[0])//2) * 2

if N_List[1] + 2 <= N_List[2]:
    cnt += (N_List[2] - N_List[1])//2
    N_List[1] += ((N_List[2] - N_List[1])//2) * 2

if N_List.count(max(N_List)) == 2:
    cnt += 2
elif N_List.count(max(N_List)) == 1:
    cnt += 1
else:
    cnt += 0
print(cnt)

Submission status: Accepted

Solution code:
a,b,c = [int(x) for x in input().split()]
res = 3 * max(a,b,c) - (a + b + c)
if res % 2 == 1:
  res += 3
print(res // 2)

Submission status: Accepted

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

x = max(a,b,c)
z = min(a,b,c)
y = a + b + c - x - z

cnt = 0

if z % 2 == y % 2:
    cnt += (y - z) / 2
    cnt += (x - y)
elif z % 2 != y % 2 and z % 2 == x % 2:
    cnt += (x - z) / 2
    if y % 2 == x % 2:
        cnt += (x - y)
    else:
        cnt += ((x + 1)- y) / 2
        cnt += 1
elif z % 2 != y % 2 and z % 2 != x % 2:
    cnt += (x - y) / 2
    cnt += ((x + 1)- z) / 2
    cnt += 1

print(int(cnt))

Submission status: Accepted

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

li = [A, B, C]

diff = max(li) * 3 - sum(li)
if diff % 2 == 0:
    print(int(diff / 2))
else:
    print(int((diff + 3) / 2))

Submission status: Accepted

Solution code:
l = sorted(map(int, input().split()))
p = (l[0]%2 != l[1]%2) or (l[1]%2 != l[2]%2)

p=(l[0]%2!=l[1]%2)or(l[1]%2!=l[2]%2)
l[0],l[1],l[2]=sorted([l[0]+((l[0]%2==l[1]%2)^(l[0]%2==l[2]%2)),l[1]+((l[1]%2==l[0]%2)^(l[1]%2==l[2]%2)),l[2]+((l[2]%2==l[0]%2)^(l[2]%2==l[1]%2))])
print((l[2]-l[0])//2+(l[2]-l[1])//2+p)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 20 23:06:24 2020

@author: liang
"""
num = [int(x) for x in input().split()]
M = max(num)
S = sum(num)
if M*3%2 == S%2:
    print((3*M-S)//2)
else:
    print((3*(M+1)-S)//2)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 20 22:44:27 2020

@author: liang
"""

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

if A > B:
    if B > C:
        m1,m2,m3 = A, B, C
    else:
        if A > C:
            m1,m2,m3 = A, C, B
        else:
            m1,m2,m3 = C, A, B
else:
    if A > C:
        m1,m2,m3 = B, A, C
    else:
        if B > C:
            m1,m2,m3 = B, C, A
        else:
            m1,m2,m3 = C, B, A
ans = 0
ans += m1 - m2
ans += (m2-m3)//2
if (m2-m3)%2 == 1:
    ans += 2
print(ans)

Submission status: Accepted

Solution code:
def solve():
    L = [int(i) for i in input().split()]
    L.sort()
    a, b, c = L
    ans = 0
    while b < c:
        a += 1
        b += 1
        ans += 1
    while a < b:
        a += 2
        ans += 1
    print(ans if a == b else ans + 1)


if __name__ == "__main__":
    solve()

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    a,b,c = i_map()
    ra = a%2
    rb = b%2
    rc = c%2
    if ra == rb == rc:
        m = max(a,b,c)
        ans = 0
        for i in [a,b,c]:
            ans += (m-i)//2
        print(ans)
    else:
        if ra == rb:
            a += 1
            b += 1
        elif ra == rc:
            a += 1
            c += 1
        else:
            b += 1
            c += 1
        ans = 1
        m = max(a,b,c)
        for i in [a,b,c]:
            ans += (m-i)//2
        print(ans)


if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
abc=[int(x) for x in input().split()]
abc.sort()
a=abc[0]
b=abc[1]
c=abc[2]

ans=float('inf')
for i in range(a,100):
  for j in range(b,100):
    for k in range(c,100):
      now=0
      if i==j and j==k and i==k:
        now=i-a+j-b+k-c
        if now%2==0:
          ans=min(now//2,ans)
          break
        
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

ans = 0
while not (a % 2 == b % 2 == c % 2):
    if a % 2 == b % 2:
        a += 1
        b += 1
    elif a % 2 == c % 2:
        a += 1
        c += 1
    elif b % 2 == c % 2:
        b += 1
        c += 1
    ans += 1

print(ans + (c - a) // 2 + (c - b) // 2)

Submission status: Accepted

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

Submission status: Accepted

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

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

s = A + B + C
M = max(A,B,C)
if M % 2 == 0 and s % 2 != 0:
    M += 1
elif M % 2 != 0 and s % 2 == 0:
    M += 1

ans = (3 * M - s) / 2
print(int(ans))

Submission status: Accepted

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

def count(data):
    even = odd = 0
    for val in data:
        if val % 2 == 0:
            even += 1
        else:
            odd += 1

    return even,odd

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

ans = 0
even,odd = count([A, B, C])
if even == 2:
    ans += 1
    if A % 2 == 0:
        A += 1
    if B % 2 == 0:
        B += 1
    if C % 2 == 0:
        C += 1
elif odd == 2:
    ans += 1
    if A % 2 != 0:
        A += 1
    if B % 2 != 0:
        B += 1
    if C % 2 != 0:
        C += 1

max_val = max(A,B,C)

ans += (max_val - A) / 2
ans += (max_val - B) / 2
ans += (max_val - C) / 2
print(int(ans))

Submission status: Accepted

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

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

Submission status: Accepted

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

num = list(map(int,input().split()))
num.sort()
dif1 = num[2] - num[1]
dif2 = num[2] - num[0]

if (dif2 - dif1) % 2 == 0:
    ans = dif1 + (dif2-dif1)//2
else:
    ans = dif1 + (dif2-dif1+1)//2 + 1

print(ans)

Submission status: Accepted

Solution code:
z=input().split()
a=int(z[0])
b=int(z[1])
c=int(z[2])
goukei=a+b+c
count = 0
if a == b and b == c:
    print(0)
    exit()
while 1:
  count += 1
  
  goukei = goukei + 2
#   print(str(count)+':'+str(goukei))
  if goukei>=max([a,b,c])*3 and goukei%3 == 0:
    print(count)
    break

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+3)//2)

Submission status: Accepted

Solution code:

def resolve():
    import sys
    input = sys.stdin.readline

    a, b, c = [int(x) for x in input().rstrip().split(" ")]

    max_num = max([a, b, c]) if (sum([a, b, c]) + max([a, b, c])) % 2 == 0 else max([a, b, c]) + 1

    print(int((max_num * 3 - sum([a, b, c])) / 2))




if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

ans = ABC[2]-ABC[1]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
p = max(a,b,c)
q = min(a,b,c)
r = a+b+c-(p+q)
x =(p-q)//2+(p-r)//2
q +=((p-q)//2)*2
r +=((p-r)//2)*2
if p == q and p == r:
        print(x)
elif p != q and p != r:
        print(x+1)
else:
        print(x+2)

Submission status: Accepted

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

Submission status: Accepted

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

ABC_sort = sorted(ABC,reverse=True)
AB = ABC_sort[0] - ABC_sort[1]
BC = ABC_sort[1] - ABC_sort[2]
time = 0
if BC % 2 == 0:
    time += BC // 2
    time += AB
else:
    AB += 1
    BC += 1
    time += BC // 2
    time += AB
print(time)

Submission status: Accepted

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

Submission status: Accepted

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

cnt = ll[2] + ll[2] - ll[1] - ll[0]

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

Submission status: Accepted

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

cnt = 0
A,B,C = sorted([A,B,C])
i = C - B
cnt += i
B += i
A += i

j = C - A
if j % 2 == 0:
  cnt += j // 2
else:
  cnt += j // 2 + 2
  
print(cnt)

Submission status: Accepted

Solution code:
abc = list(map(int,input().split()))
maxnum = max(abc)
parity = maxnum%2
ans = 0
for i in abc:
    if i%2==parity:
        ans+=(maxnum-i)//2+1
    else:
        ans+=(maxnum-1-i)//2
if abc[0]%2==abc[1]%2 and abc[1]%2==abc[2]%2:
    ans-=3
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
nums = list(map(int, input().split()))
total_diff = 0
max_num = max(nums)
for i in range(3):
    total_diff += max_num - nums[i]

if total_diff % 2 == 1:
    max_num += 1

print(int((max_num * 3 - sum(nums)) / 2))

Submission status: Accepted

Solution code:
A,B,C = [int(i) for i in input().split()]
M = max(A,B,C)
S = A + B + C
ans = 0
if S%2 != M%2:
  ans += 2
ans += int((3*M - S) / 2)
print(ans)

Submission status: Accepted

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

else:
  print(x // 2 + 2)

Submission status: Accepted

Solution code:
from math import ceil
a = list(map(int, input().split()))
a.sort()
kisu_cnt = 0
ans = 0
for _a in a:
    if _a % 2 == 1:
        kisu_cnt += 1
if kisu_cnt == 3 or kisu_cnt == 0:
    ans += (a[-1] - a[1]) // 2
    ans += (a[-1] - a[0]) // 2
    print(ans)
    exit()
else:
    if kisu_cnt == 1:
        for i in range(3):
            if a[i] % 2 == 0:
                a[i] += 1
    else:
        for i in range(3):
            if a[i] % 2 == 1:
                a[i] += 1
a.sort()
ans += 1
ans += (a[-1] - a[1]) // 2
ans += (a[-1] - a[0]) // 2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

a.sort(reverse=True)

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

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

Submission status: Accepted

Solution code:
a, b, c = map(int,input().split())
count = 0
#偶奇を一致させる
if a % 2 == b % 2 == c % 2:
    count = 0

elif a % 2 == b % 2 != c % 2:
    count += 1
    a += 1
    b += 1

elif b % 2 == c % 2 != a % 2:
    count += 1
    b += 1
    c += 1

elif a % 2 == c % 2 != b % 2:
    count += 1
    a += 1
    c += 1
maxnum = max(a, b, c)

while a < maxnum:
    a += 2
    count += 1

while b < maxnum:
    b += 2
    count += 1

while c < maxnum:
    c += 2
    count += 1

print(count)

Submission status: Accepted

Solution code:
# vim: fileencoding=utf-8

import math


def main():
    li = list(map(int, input().split()))
    li.sort(reverse=True)
    m = li[0] - li[1]
    n = li[0] - li[2]
    p = n - m
    ans = m + math.ceil(p / 2) + (p % 2)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

max_v = max(arr)
sum_arr = sum(arr)

if (max_v*3 - sum_arr) % 2:
    # 奇数の場合
    print(((max_v+1)*3 - sum_arr) // 2)
else:
    # 偶数の場合
    print((max_v*3 - sum_arr) // 2)

Submission status: Accepted

Solution code:
data=list(map(int,input().split()))
data.sort()
a=data[0]
b=data[1]
c=data[2]
if a == b == c:
    print(0)
elif b == c:
    count=0
    while a < c:
        a += 2
        count += 1
    if a > c:
        print(count+1)
    else:
        print(count)
else:
    count=0
    while a < c and b < c:
        a += 1
        b += 1
        count += 1
    if a == b == c:
        print(count)
    else:
        while a < c:
            a += 2
            count += 1
        if a > c:
            print(count+1)
        else:
            print(count)

Submission status: Accepted

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

a_L = list(sorted(a_L))

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


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

Submission status: Accepted

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

Submission status: Accepted

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

l.sort()

ans = 0

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

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

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    X=list(mi())

    X.sort()

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







if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

X = max([A, B, C])
X = X if (3 * X - (A + B + C)) % 2 == 0 else X + 1
diff = 3 * X - (A + B + C)

print(diff // 2)

Submission status: Accepted

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

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

if (L[0] % 2 == 1 and L[1] % 2 == 0) or (L[1] % 2 == 1 and L[0] % 2 == 0):
  ans = ans + 1.5
print(int(ans))

Submission status: Accepted

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

if A == B and A == C:
    print(0)
    exit()
cnt = 0
cnt += (C - A) // 2
A = ((C - A) // 2) * 2 + A
cnt += (C - B) // 2
B = ((C - B) // 2) * 2 + B

if A == B and A == C:
    print(cnt)
elif A == B and A != C:
    print(cnt+1)
else:
    print(cnt+2)

Submission status: Accepted

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

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

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

if l[0] > l[1]:
    ans += 1

print(ans)

Submission status: Accepted

Solution code:
import math
A,B,C = map(int,input().split())
ns = sorted([A,B,C])
diff32 = ns[2]-ns[1]
diff21 = ns[1]-ns[0]
ans = diff32+math.ceil(diff21/2)
if diff21 % 2 == 1:
    ans += 1
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

res = 0
if ac % 2 == 0 and bc % 2 == 0:
    res = ac // 2 + bc // 2
elif ac % 2 == 1 and bc % 2 == 1:
    res = 1 + ac // 2 + bc // 2
else:
    res = 2 + ac // 2 + bc // 2

print(res)

Submission status: Accepted

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

l.sort()
x=l[2]-l[1]+(l[1]-l[0])//2
ans=x if (l[1]-l[0])%2==0 else x+2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
A = a % 2
B = b % 2
C = c % 2
cnt = 0
s = [a,b,c]
flag = [0,0,0,0]
if A == B == C:
    t = [a,b,c]
    t.sort()
    cnt = cnt + (t[2]-t[1])//2 + (t[2]-t[0])//2
    flag[0] += 1
elif A == B:
    cnt = cnt + 1
    a = a + 1
    b = b + 1
    t = [a,b,c]
    t.sort()
    cnt = cnt + (t[2]-t[1])//2 + (t[2]-t[0])//2
    flag[1] += 1
elif B == C:
    cnt = cnt + 1
    b = b + 1
    c = c + 1
    t = [a,b,c]
    t.sort()
    cnt = cnt + (t[2]-t[1])//2 + (t[2]-t[0])//2
    flag[2] += 1
elif C == A:
    cnt = cnt + 1
    c = c + 1
    a = a + 1
    t = [a,b,c]
    t.sort()
    cnt = cnt + (t[2]-t[1])//2 + (t[2]-t[0])//2
    flag[3] += 1
print(cnt)
# print(t)
# print(flag)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

arr.sort()

a, b, c = arr

k = (c - a) + (c - b)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=list(map(int,input().split()))
a=sorted(a)
cnt=0
if a[0]==a[1] and a[1]==a[2]:
	print(0)
elif a[0]==a[1]:
	while True:
		a[0]+=1
		a[1]+=1
		cnt+=1
		if a[0]==a[2]:
			print(cnt)
			break
elif a[1]==a[2]:
	while True:
		a[0]+=2
		cnt+=1
		if a[0]==a[2]:
			print(cnt)
			break
		elif a[0]>a[2]:
			print(cnt+1)
			break
else:
	while True:
		a[0]+=1
		a[1]+=1
		cnt+=1
		if a[2]==a[1]:
			break
	while True:
		a[0]+=2
		cnt+=1
		if a[0]==a[2]:
			print(cnt)
			break
		elif a[0]>a[2]:
			print(cnt+1)
			break

Submission status: Accepted

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

あ = b // 2 + c // 2
ばいく = b % 2 + c % 2
if ばいく == 1:
    あ += 2
elif ばいく == 2:
    あ += 1
print(あ)

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math

#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
a,b,c = readInts()
ma = max(a,b,c)
sa = (ma-a) + (ma-b) + (ma-c)
if sa%2 == 0:
    print(sa//2)
else:
    print(sa//2 + 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c = sorted([int(i)for i in input().split()])
ans = 0
ma, mb, mc = [a % 2, b % 2, c % 2]

if ma == mb == mc:
    pass
elif ma != mb and mb == mc:
    b += 1
    c += 1
    ans += 1
elif ma == mc and ma != mb:
    a += 1
    c += 1
    ans += 1
elif ma == mb and mb != mc:
    a += 1
    b += 1
    ans += 1

ans += (c - b) // 2
ans += (c - a) // 2

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math
A,B,C = map(int,input().split())
k = [A,B,C]
k.sort()
k.reverse()
ans = 0
ans += k[0]-k[1]
now = k[2]
now += ans
if (k[0]-now)%2 == 0:
    ans += math.ceil((k[0]-now)/2)
    print(ans)
else:
    ans += math.ceil((k[0]-now)/2)
    ans += 1
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = list(map(int, input().split()))
Y = sorted(X)
ans = 0
if Y[0]%2==Y[1]%2 and Y[1]%2 != Y[2]%2:
  ans +=1
  Y = [Y[0]+1,Y[1]+1,Y[2]]
elif Y[1]%2==Y[2]%2 and Y[2]%2 != Y[0]%2:
  ans +=1
  Y = [Y[0], Y[1]+1,Y[2]+1]
elif Y[2]%2==Y[0]%2 and Y[0]%2 != Y[1]%2:
  ans +=1
  Y = [Y[0]+1, Y[1], Y[2]+1]

A = Y[2]-Y[0]
B = Y[2]-Y[1]
C = min(A,B)
D = max(A,B)
ans += C + (D-C)//2
print(ans)

Submission status: Accepted

Solution code:
def LI():
    return list(map(int, input().split()))


N = LI()
N.sort()
A, B, C = N
a = (C-A)//2
A += a*2
b = (C-B)//2
B += b*2
if A == B == C:
    ans = a+b
elif A == B:
    ans = a+b+1
else:
    ans = a+b+2
print(ans)

Submission status: Accepted

Solution code:
a = sorted(list(map(int, input().split())))
even = []
No = []
for i in range(3):
    if a[i] % 2 == 0:
        even.append(a[i])
    else: No.append(a[i])

if len(even) == 0 or len(even) == 3:
    ans = (a[1] - a[0])//2 + a[2]-a[1]
elif len(even) == 1:
    ans = 1
    a = sorted(even+ [No[0]+1, No[1]+1])
    ans += (a[1]-a[0])//2 + a[2]-a[1]
elif len(even) == 2:
    ans = 1
    a = sorted(No + [even[0]+ 1, even[1]+1])
    ans += (a[1]-a[0])//2 + a[2]-a[1]
print(ans)