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:
abc = sorted(list(map(int,input().split())))
dsta = abc[2]-abc[0]
dstb = abc[2]-abc[1]
if dsta%2 == dstb%2 :
    print((dsta+dstb)//2)
else:
    print(1+(dsta+dstb+1)//2)

Submission status: Accepted

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


def main():
    a, b, c = map(int, input().split())
    max_number = max(a, b, c)

    while True:
        diff = 3 * max_number - sum([a, b, c])

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    a, b, c = sorted(map(int, input().split()))
    x = c - b
    a += x
    b += x
    while a < b:
        a += 2
        x += 1
    print(x + int(a != b))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

count = 0
max_num = max(l)
l2 = []
for n in l:
  c = (max_num-n)//2
  count += c
  l2.append(n+2*c)

m = max(l2)
count += l2.count(m) % 3


print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A = [int(x) for x in input().split()]
M = max(A)
cnt = 0
d = 0
for i in range(3):
  c = (M - A[i]) // 2
  cnt += c
  A[i] += 2 * c
  if A[i] != M:
    d += 1
cnt += (3 - d) % 3
print(cnt)

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
ds = [abs(e - max(a)) for e in a if e-max(a) != 0]

if len(ds) == 1:
    if ds[0] % 2 == 0:
        res = ds[0] // 2
    else:
        res = (ds[0]-1) // 2 + 2
elif len(ds) > 1:
    base = min(ds) - 1
    rem = max(ds) - base
    if rem == 1:
        res = base + 1
    elif rem % 2 == 0:
        res = base + (rem - 2) // 2 + 3
    elif rem % 2 != 0:
        res = base + (rem - 1) // 2 + 1
else:
    res = 0

print(res)

Submission status: Accepted

Solution code:
import sys
a,b,c=map(int,input().split())
if a==b==c:
    print(0)
    sys.exit()
if a%2 == b%2 == c%2:
    m = max([a,b,c])
    print((m-a)//2+(m-b)//2+(m-c)//2)
else:
    if a%2==b%2:
        a+=1
        b+=1
        m = max([a,b,c])
        print((m-a)//2+(m-b)//2+(m-c)//2+1)
    elif b%2==c%2:
        b+=1
        c+=1
        m = max([a,b,c])
        print((m-a)//2+(m-b)//2+(m-c)//2+1)
    else:
        c+=1
        a+=1
        m = max([a,b,c])
        print((m-a)//2+(m-b)//2+(m-c)//2+1)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Some Integers
li = sorted(list(map(int, input().split())))
count = 0
while li[1] < li[2]:
    li[0] += 1
    li[1] += 1
    count += 1
while li[0] < li[1]:
    li[0] += 2
    count += 1
if li[0] > li[1]:
    li[1] += 1
    li[2] += 1
    count += 1
print(count)

Submission status: Accepted

Solution code:
# encoding: utf-8
ABC = sorted(map(int, input().split()))

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

Submission status: Accepted

Solution code:
x = list(map(int, input().split()))
ans = 0
while x[0] != x[1] or x[1] != x[2]:
    ans += 1
    m = min(x)
    if x.count(m) == 1:
        for i in range(3):
            if x[i] == m:
                x[i] += 2
                break
    else:
        for i in range(3):
            if x[i] == m:
                x[i] += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

l.sort()
lm = max(l)
ll = [lm - i for i in l]

ans = int(ll[0] / 2) + int(ll[1] / 2)

if(ll[0] % 2 + ll[1] % 2 ) ==2:
    ans +=1
elif(ll[0] % 2 + ll[1] % 2 ) ==1:
    ans +=2

print(ans)

Submission status: Accepted

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

arr.sort(reverse=True)

arr2 = list(arr)
count = 0

for i in range(3):
    arr2[i] = arr[0] - arr2[i] 

for j in range(3):
    if (arr2[j] != 0) and (arr2[j] % 2 == 1):
        count += 1

if (count == 0) or (count == 2):
    print(int(sum(arr2) / 2))
else:
    print(int(sum(arr2) // 2 + 2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A=list(map(int,input().split()))
A.sort()
count=0
while(1):
    i=0
    j=0
    if(A[1]+2<=A[2]):
        A[1]+=2
        count+=1
        i=1
    if(A[0]+2<=A[2]):
        A[0]+=2
        count+=1
        j=1
    if(i==0 and j==0):    break
    
if(A[0]==A[1] and A[0]!=A[2]):    print(count+1) #(0,0,1)
elif(A[0]!=A[1]):    print(count+2) ##(0,1,1)
else:    print(count) #(0,0,0)

Submission status: Accepted

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

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

if (numbers[2] - numbers[0]) % 2 == 0:
  answer += (numbers[2] - numbers[0]) // 2
else:
  answer += (numbers[2] - numbers[0] + 1) // 2 + 1

print(answer)

Submission status: Accepted

Solution code:
# encoding: utf-8
ABC = sorted(list(map(int, input().split())))

diff0 = ABC[-1] - ABC[0]
diff1 = ABC[-1] - ABC[1]

# +2 only
if diff0 % 2 == diff1 % 2 == 0: ans = (diff0 + diff1) // 2
# +1 (ABC[0], ABC[1]) once and +2
elif diff0 % 2 == diff1 % 2 == 1: ans = (diff0 + diff1) // 2
# +1 (ABC[{0, 1}], ABC[2]) once and +2)
else: ans = 1 + (diff0 + diff1 + 2) // 2

print(ans)

Submission status: Accepted

Solution code:
a=list(map(int,input().split()))
b=[0 for i in range(3)]
a.sort()
for i in range(3):
  b[i]=a[i]%2
flag=0

count=0
if(b[0]==b[1]) and (b[1]==b[2]):
  flag=1
  while(a[1]<a[2]):
    a[1]=a[1]+2
    count+=1
  while(a[0]<a[2]):
    a[0]=a[0]+2
    count+=1
    
if (b[0]==b[1]) and flag==0:
  a[0]=a[0]+1
  a[1]=a[1]+1
  count+=1
  while(a[1]<a[2]):
    a[1]=a[1]+2
    count+=1
  while(a[0]<a[2]):
    a[0]=a[0]+2
    count+=1

if (b[0]==b[2]) and flag==0:
  a[0]=a[0]+1
  a[2]=a[2]+1
  count+=1
  while(a[1]<a[2]):
    a[1]=a[1]+2
    count+=1
  while(a[0]<a[2]):
    a[0]=a[0]+2
    count+=1
    
if (b[1]==b[2]) and flag==0:
  a[1]=a[1]+1
  a[2]=a[2]+1
  count+=1
  while(a[1]<a[2]):
    a[1]=a[1]+2
    count+=1
  while(a[0]<a[2]):
    a[0]=a[0]+2
    count+=1

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A, B, C = sorted([int(_) for _ in input().split()])
A, B, C = [0, C - B, C - A]
if B % 2 and C % 2:
    print(1 + (B - 1) // 2 + (C - 1) // 2)
elif B % 2:
    print(1 + (B + 1) // 2 + C // 2)
elif C % 2:
    print(1 + (C + 1) // 2 + B // 2)
else:
    print(B // 2 + C // 2)

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
x=0
while a!=b or b!=c or c!=a:
  if a%2==b%2==c%2:
    if min(a,b,c)==a:a+=2
    elif min(a,b,c)==b:b+=2
    else:c+=2
  else:
    if a%2==b%2:
      a+=1
      b+=1
    elif b%2==c%2:
      b+=1
      c+=1
    else:
      c+=1
      a+=1
  x+=1
print(x)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
aA = [int(_) for _ in input().split()]
iM = min(aA)
i0,i1,i2 = sorted([a - iM for a in aA])

if i1 % 2 :
    print((i1+1)//2 + i2-i1 + 1)
else:
    print( i2-i1 //2)

Submission status: Accepted

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

l=list(map(int,input().split()))
a,b,c=sorted(l)
#print(a,b,c)
if a%2==b%2 and a%2==c%2:
    print((2*c-a-b)//2)
elif a%2==b%2:
    print((2*c-2-a-b)//2+1)
else:
    print((2*c+1-a-b)//2+1)

Submission status: Accepted

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

if (nums[1] - nums[0]) % 2 == 1:
    nums[0] += 1
    nums[2] += 1
    ans += 1
while nums[0] != nums[1]:
    nums[0] += 2
    ans += 1
while nums[0] != nums[2]:
    nums[0] += 1
    nums[1] += 1
    ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c = map(int, input().split())
ar = [a,b,c]
ar.sort()
t = ar[2]#max
u = ar[1]
v = ar[0]#min
tu = t - u
tv = t - v
count = 0
if tu % 2 == 0 and tv % 2 == 0:
  count += tu
  count += int((tv - tu) / 2)
elif tu % 2 != 0 and tv % 2 != 0:
  count += tu
  count += int((tv - tu) / 2)
else:
  count += tu
  count += int((tv - tu - 1) / 2) + 2

print(count)

Submission status: Accepted

Solution code:
a,b,c = map(int,input().split())
if max(a,b,c) % 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:
n = [int(i) for i in input().split()]
n = sorted(n)
d = (n[2]-n[0])+(n[2]-n[1])
e = divmod(d, 2)
print(e[0]) if e[1]==0 else print(e[0]+2)

Submission status: Accepted

Solution code:
import math

def main():
    a, b, c = map(int, input().split())
    
    li = [a, b, c]
    top = max(li)
    top_index = li.index(top)
    bot = min(li)
    bot_index = li.index(bot)
    mid_index = calc_mid_index(top_index, bot_index)
    mid = li[mid_index]
    count = 0
    
    count = top - mid
    bot += count
    mid += count
    
    if (top - bot) % 2 == 0:
        count += (top - bot) / 2 
    else:
        count += math.ceil((top - bot) / 2) + 1
        
    print(int(count))

def calc_mid_index(top_index, bot_index):
    for i in range(3):
        if i != top_index and i != bot_index:
            return i



if __name__ == '__main__':
    main()

Submission status: Accepted

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

count = 0
while a != 0 and b != 0:
    a -= 1
    b -= 1
    count += 1

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

if b == 1:
    count += 2

print(count)

Submission status: Accepted

Solution code:
A,B,C = map(int,input().split(" "))
num1 = max(A,B,C)
num3 = min(A,B,C)
num2 = A+B+C-num1-num3
if (num1*2-num2-num3)%2 == 1:
    print((num1*2-num2-num3)//2+2)
else:
    print((num1*2-num2-num3)//2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5)
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())
 
a,b,c = li()
 
a,b,c = sorted([a,b,c])
 
cnt = 0
while a != b or b != c:
    if a != b:
        a += 2
        
    else:
        a += 1
        b += 1
        
    a,b,c = sorted([a,b,c])
        
    cnt += 1
    
    
print(cnt)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

a,b,c = li()

a,b,c = sorted([a,b,c])

cnt = 0
while a != b or b != c:
    if a != b:
        a += 2
        
    else:
        a += 1
        b += 1
        
    a,b,c = sorted([a,b,c])
        
    cnt += 1
    
    
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l = [int(_) for _ in input().split()]
a, b, c = sorted(l, reverse=True)
if a % 2 == 1:
    if b % 2 == 1:
        if c % 2 == 1:
            ans = (a-b)//2 + (a-c)//2
        else:
            ans = 1 + (a+1-c)//2 + (a-b)//2
    else:
        if c % 2 == 1:
            ans = 1 + (a+1-b)//2 + (a-c)//2
        else:
            ans = 1 + (a-b-1)//2 + (a-c-1)//2
else:
    if b % 2 == 1:
        if c % 2 == 1:
            ans = 1 + (a-b-1)//2 + (a-c-1)//2
        else:
            ans = 1 + (a+1-b)//2 + (a-c)//2
    else:
        if c % 2 == 1:
            ans = 1 + (a-b)//2 + (a+1-c)//2
        else:
            ans = (a-b)//2 + (a-c)//2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
A,B,C = map(int, input().split())
l = sorted([A,B,C])

cnt = 0
#1 低２を同じ値にする
if l[0] != l[1]:
    if (l[1]-l[0])%2 == 0:
        cnt += (l[1]-l[0])//2
        l[0] = l[1]
    else:
        cnt += (l[1]-l[0]+1)//2
        l[0] = l[1] + 1
        cnt += 1
        l[1] += 1
        l[2] += 1

#2 低２を高１まで増やす
cnt += l[2] - l[1]
l[0] += l[2] - l[1]
l[1] += l[2] - l[1]

print(cnt)
# print(l)

Submission status: Accepted

Solution code:
"""
C - Same Integers
"""

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

odd_cnt = 0
parities = []
for n in numbers:
    p = n % 2
    parities.append(p)
    odd_cnt += p

process_cnt = 0

# 修正が必要
if odd_cnt == 1:
    process_cnt += 1
    # evenに対して操作1
    for i in range(3):
        if parities[i] == 0:
            numbers[i] += 1
elif odd_cnt == 2:
    process_cnt += 1
    # oddに対して操作1
    for i in range(3):
        if parities[i] != 0:
            numbers[i] += 1

# あとは数を合わせるだけ 操作2
numbers_max = max(numbers)
for n in numbers:
    process_cnt += (numbers_max - n) // 2

print(process_cnt)

Submission status: Accepted

Solution code:
nums = list(map(int,input().split()))
nums.sort()
diff = (nums[-1]-nums[1]) + (nums[-1]-nums[0])
a,b = divmod(diff,2)
print(a+b*2)

Submission status: Accepted

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

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

Submission status: Accepted

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

while 1:
    if len(set(a)) == 1:
        print(cnt)
        break
    elif len(set(a)) ==2:
        if a.count(min(a)) == 2:
            cnt += max(a)-min(a)
            print(cnt)
            break
        else:
            if (max(a)-min(a))%2==0:
                cnt += (max(a)-min(a))//2
                print(cnt)
                break
            else:
                cnt += (max(a)-min(a))//2 + 2
                print(cnt)
                break
    else:
        a.sort()
        a[0] += 2
        cnt += 1

Submission status: Accepted

Solution code:
from collections import deque

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

def bfs(a, b, c):
    cnt = 0
    queue = deque([[a, b, c, cnt]])

    while queue:
        a, b, c, cnt = queue.popleft()
        if a == b and b == c:
            return cnt
        if a >= 60 or b >= 60 or c >= 60:
            return cnt

        if b > a and b > c:
            queue.append([a+1, b, c+1, cnt+1])
        elif a > b and a > c:
            queue.append([a, b+1, c+1, cnt+1])
        elif c > a and c > b:
            queue.append([a+1, b+1, c, cnt+1])
        elif a < b:
            queue.append([a+2, b, c, cnt+1])
        elif b < c:
            queue.append([a, b+2, c, cnt+1])
        elif c < a:
            queue.append([a, b, c+2, cnt+1])

print(bfs(a, b, c))

Submission status: Accepted

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

Submission status: Accepted

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

if a%2==b%2==c%2:
	x = max(a,b,c)
	print((3*x-a-b-c)//2)
elif a%2==b%2!=c%2:
	x = max(a+1,b+1,c)
	print((3*x-a-b-c-2)//2+1)
elif a%2!=b%2==c%2:
	x = max(a,b+1,c+1)
	print((3*x-a-b-c-2)//2+1)
elif a%2==c%2!=b%2:
	x = max(a+1,b,c+1)
	print((3*x-a-b-c-2)//2+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
minV, midV, maxV = min(A,B,C), A + B + C - min(A,B,C) - max(A,B,C),max(A,B,C)
cnt = 0
work1 = (maxV - minV) // 2
minV = minV + 2 * work1
work2 = (maxV - midV) // 2
midV = midV + 2 * work2
cnt += work1 + work2

if minV == midV == maxV:
    print(cnt)
elif midV == minV:
    print(cnt + 1)
else:
    print(cnt + 2)

Submission status: Accepted

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

Submission status: Accepted

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

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

N = list(map(int, Input().split()))
count = 0

while not all(map(lambda x: x == N[0], N)):
    N.sort()
    while N[0]+1 < N[2]:
        N[0] += 2
        count += 1
    if N[0] != N[2]:
        N[0] += 1
        N[1] += 1
        count += 1

print(count)

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
count = 0
# 全てを奇数or偶数(マイナー)に揃える
if a % 2 == 0 and b % 2 == 0 and c % 2 == 1:
    a += 1
    b += 1
    count += 1
elif a % 2 == 0 and b % 2 == 1 and c % 2 == 0:
    a += 1
    c += 1
    count += 1
elif a % 2 == 0 and b % 2 == 1 and c % 2 == 1:
    b += 1
    c += 1
    count += 1
elif a % 2 == 1 and b % 2 == 0 and c % 2 == 0:
    b += 1
    c += 1
    count += 1
elif a % 2 == 1 and b % 2 == 0 and c % 2 == 1:
    a += 1
    c += 1
    count += 1
elif a % 2 == 1 and b % 2 == 1 and c % 2 == 0:
    a += 1
    b += 1
    count += 1

# ソートして同じになるまでカウント
data_list = [a, b, c]
data_list.sort()
while data_list[0] != data_list[2]:
    data_list[0] += 2
    count += 1
while data_list[1] != data_list[2]:
    data_list[1] += 2
    count += 1
print(count)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
import math


def main():
    a, b, c = sorted([int(a) for a in input().split()])

    add = 0
    if a % 2 == 0:
        if b % 2 == 0:
            if c % 2 == 0:
                pass
            else:
                add = 1
                b += 1
                a += 1
        else:
            if c % 2 == 0:
                add = 1
                a += 1
                c += 1
            else:
                add = 1
                b += 1
                c += 1
    else:
        if b % 2 == 0:
            if c % 2 == 0:
                add = 1
                b += 1
                c += 1
            else:
                add = 1
                a += 1
                c += 1
        else:
            if c % 2 == 0:
                add = 1
                a += 1
                b += 1
            else:
                pass

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = 0

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

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

if abc[0] != abc[2]:
    ans += 2

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

abc.sort()

count = 0

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

print(int(count))

Submission status: Accepted

Solution code:
A, B, C = list(map(int, input().split()))
ABC = [A, B, C]
ABC.sort()
A = ABC[0]
B = ABC[1]
C = ABC[2]
ans = 0

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

ans=x-y
y=x
z+=ans

if (x-z)%2==0:
    ans+=(x-z)/2
else:
    x+=1
    ans+=1
    ans+=(x-z)/2

print(int(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = list(map(int, input().split()))
X.sort()
d1 = X[2] - X[1]
d2, m = divmod(X[2] - X[0] - d1, 2)
if m == 1:
    print(d1 + d2 + 2)
else:
    print(d1 + d2)

Submission status: Accepted

Solution code:
# coding:utf-8


def inpl(): return list(map(int, input().split()))


M = inpl()
M.sort()

sub1 = M[2] - M[1]
sub2 = M[1] - M[0]

if sub2 % 2 == 0:
	ans = sub1 + sub2 // 2
else:
	ans = sub1 + (sub2 + 1) // 2 + 1

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
d = list(map(int, input().split()))
d.sort()
a,b,c=d
r = 0
while a<b:
    a += 2
    r += 1
if a > b:
    r += 1
    b += 1
    c += 1
if a == b:
    r += c - a
    a  = c
    b  = c
print(r)

Submission status: Accepted

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

a.sort()

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

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

Submission status: Accepted

Solution code:
a, b, c = map(int, raw_input().split())
max_value = max([a,b,c])

target_value = max_value
while True:
    if (target_value*3 - (a+b+c)) % 2 == 0:
        break
    target_value += 1

diff_a = (target_value - a)
diff_b = (target_value - b)
diff_c = (target_value - c)

if diff_a % 2 == 0 and diff_b % 2 == 0 and diff_c % 2 == 0:
    count = diff_a / 2 + diff_b / 2 + diff_c / 2
    print(count)
else:
    count = diff_a / 2 + diff_b / 2 + diff_c / 2 + 1
    print(count)

Submission status: Accepted

Solution code:
min, mid, max = sorted([int(i) for i in input().split()])

ope1 = max - mid    # この回数「midとminに1を足す」を行うと、maxとmidが同じ数になる

diff = (max - (ope1 + min))  # その上で、minをそろえるためにあといくつ増やさなければならないか
ope2 = diff // 2             # minに2を足す回数

if diff % 2 != 0:
    ope1 = ope1 + 1          # minを増やす数が奇数の場合、ope1を一度増やして差を偶数にする。
    ope2 = ope2 + 1          # 差が2になったので、ope2をもう一度

print(ope1 + ope2)

Submission status: Accepted

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

a.sort()

ans =0

while a[0]<=a[2]-2:
    a[0]+=2
    ans +=1

while a[1]<=a[2]-2:
    a[1]+=2
    ans+=1

if a[0]==a[1] and a[1]!=a[2]:
    ans +=1
elif a[0]==a[1] and a[1]==a[2]:
    ans +=0
else:
    ans +=2

print(ans)

Submission status: Accepted

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

ABC.sort()
# print(ABC)

ans = 0

dif_AB = ABC[2] - ABC[0]
dif_AC = ABC[2] - ABC[1]

if dif_AB % 2 == 0:
    ABC[0] = ABC[2]
else:
    ABC[0] = ABC[2] - 1
ans += dif_AB // 2

if dif_AC % 2 == 0:
    ABC[1] = ABC[2]
else:
    ABC[1] = ABC[2] - 1
ans += dif_AC // 2

# print(ABC)
# print(ans)

dif_AB = ABC[2] - ABC[0]
dif_AC = ABC[2] - ABC[1]

if ABC[0] == ABC[1] and ABC[1] == ABC[2]:
    pass
elif dif_AB == 1 and dif_AC == 1:
    ans += 1
else:
    ans += 2
print(ans)

Submission status: Accepted

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

P.sort()

A, B, C = P

r = 0

while A < B:
    A += 2
    r += 1

if A > B:
    r += 1
    B += 1
    C += 1

if A == B:
    r += C - A
    A  = C
    B  = C

print(r)

Submission status: Accepted

Solution code:
abc = list(map(int, input().split()))
abc_even = [x % 2 == 0 for x in abc]
ans = 0
if abc_even.count(True) == 2:
  abc = [x + 1 if x_flg == True else x for x,x_flg in zip(abc,abc_even)]
  ans += 1
elif abc_even.count(False) == 2:
  abc = [x + 1 if x_flg == False else x for x, x_flg in zip(abc, abc_even)]
  ans += 1
mx = max(abc)
for i in range(len(abc)):
  while abc[i] < mx:
    abc[i] += 2
    ans += 1
print(ans)

Submission status: Accepted

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

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

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

ans = 0

ans += max - mid

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

print(int(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
input_list = list(map(int, input().split()))
input_list.sort()
max_num = input_list[2]
second = input_list[1]
min_num = input_list[0]

count = 0
margin = max_num - second
margin2 = max_num - min_num

if margin % 2 == 0:
    count += margin / 2

else:
    count += margin // 2
    if margin2 % 2 == 0:
        count += 1
        margin2 -= 1

    else:
        count += 1
        margin2 -= 1

if margin2 % 2 ==0:
    count += margin2 / 2

else:
    count += margin2 // 2
    count += 2

print(int(count))

Submission status: Accepted

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