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:
def main():
    a, b, c = map(int, input().split())

    print(solve(a, b, c))


def solve(a, b, c):
    a, b, c = sorted([a, b, c])
    x = a % 2
    y = b % 2
    z = c % 2

    if x == y == z:
        return ((c - a) // 2) + ((c - b) // 2)
    
    if x == y:
        return solve(a + 1, b + 1, c) + 1
    
    if x == z:
        return solve(a + 1, b, c + 1) + 1
    
    if y == z:
        return solve(a, b + 1, c + 1) + 1


def evens(*args):
    n = 0
    for i in args:
        if i % 2 == 0:
            n += 1
    return n

main()

Submission status: Accepted

Solution code:
ip=[int(x) for x in input().split()]
ip.sort()
cnt=0
while ip[1]<ip[2]:
  cnt=cnt+1
  ip[0]+=1
  ip[1]+=1
  
if (ip[1]-ip[0])%2!=0:
  cnt+=1
  ip[1]+=1
  ip[0]+=1
  while ip[0]<ip[1]:
    ip[0]+=2
    cnt+=1
else:
  cnt=cnt+(ip[1]-ip[0])/2
print(int(cnt))

Submission status: Accepted

Solution code:
import math

number_list = [int(i) for i in input().split()]

even_counter = 0

for i in number_list:
        if i % 2 == 0:
                even_counter = even_counter + 1

def even_checker(n_list):
        for i in n_list:
                if i % 2 == 0:
                        return i

def odd_checker(n_list):
        for i in n_list:
                if i % 2 == 1:
                        return i

if even_counter == 3 or even_counter == 0:
        goal = max(number_list)
        number_list.remove(goal)
        bigger = max(number_list)
        smaller = min(number_list)
        first_count = 0
else:
        if even_counter == 2:
                alone = odd_checker(number_list)
        elif even_counter == 1:
                alone = even_checker(number_list)
        number_list.remove(alone)
        bigger = max(number_list)
        smaller = min(number_list)
        if bigger > alone:
                first_count = math.ceil((bigger - alone)/2)
                goal = alone + first_count * 2
        else:
                first_count = 0
                goal = alone

second_count = goal - bigger
third_count = int((goal - (smaller + second_count))/2)

print(first_count+second_count+third_count)

Submission status: Accepted

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

s = [A,B,C]
s.sort()

count = 0
a = s[2] - s[1]
count = count + a

s[0] = s[0] + a
#print(s[0],count)
b = s[2] - s[0]

if b % 2 == 0:
    count = count + (b // 2)
    print(count)

else:
    count = count + (b // 2) + 2
    print(count)

Submission status: Accepted

Solution code:
a=input().split()
for i in range(3):
  a[i]=int(a[i])
a.sort()
A=int(a[0])
B=int(a[1])
C=int(a[2])
A0=A%2
B0=B%2
C0=C%2
ans=0

if( (A0==B0)and(A0==C0) ):
   ans=ans+int((C-B)/2)+int((C-A)/2)
   print(ans)
else:
  if(A0==C0):#B0!=C0
    ans=ans+int((C-B)/2)+int((C-A)/2)+2
    print(ans)
    #偶奇違う一つに ＋２＞他二つに＋１＋１の二回を足す
  if(B0==C0):#A0!=C0
    ans=ans+int((C-B)/2)+int((C-A)/2)+2
    print(ans)
  if((A0!=C0)and(B0!=C0)):
    ans=ans+int((C-B)/2)+int((C-A)/2)+1
    print(ans)
    #A,B　C-1まで行く＞ A,B+1+1

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
lst=[a,b,c]
lst.sort()
x=lst[0]
y=lst[1]
z=lst[2]

if (z-x)%2==(z-y)%2==1:
    print(1+int((2*z-x-y-2)/2))
elif (z-x)%2==(z-y)%2==0:
    print(int((2*z-x-y)/2))
elif z%2==x%2:
    z+=1
    x+=1
    print(1+int((2*z-x-y)/2))
else:
    z+=1
    y+=1
    print(1+int((2*z-x-y)/2))

Submission status: Accepted

Solution code:
a,b,c = map(int, input().split())
l = sorted([a,b,c],reverse=True)
ans = 0
def all_same(items):
    return all(x == items[0] for x in items)

while not all_same(l):
    d = l[0] - l[1]
    l[1] += d
    l[2] += d
    ans += d
    d = l[1] - l[2]
    l[2] += 2 * (d//2)
    ans += d // 2
    if l[1] - l[2] == 1:
        l[2] += 2
        ans += 1
    l = sorted(l,reverse=True)    
print(ans)

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
count = 0

def main():
    A = list(map(int,input().split()))
    b1 = max(A)
    A.remove(b1)
    b2 = max(A)
    A.remove(b2)
    b3 = max(A)
    global count
    if b2 % 2 == b3 % 2:
        cal(b1,b2,b3)
    else:
        b1 += 1
        b2 += 1
        count += 1
        cal(b1,b2,b3)

def cal(b1,b2,b3):
    global count
    for _ in range(b2,b1):
        b2 += 1
        b3 += 1
        count += 1
    while b3 < b1:
        b3 += 2
        count += 1
    print(count)

main()

Submission status: Accepted

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

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

print(b)

Submission status: Accepted

Solution code:
num = [int(x) for x in input().split()]
ans = 0

#A
r = [x%2 for x in num]
if 2 == len(set(r)):
    ans += 1
    if sum(r) == 1:
        r = [1-x for x in r]

num = [num[i] + r[i] for i in range(len(num))]

#B
df = [max(num) - num[i] for i in range(len(num))]
ans += sum([x/2 for x in df])

print(int(ans))

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
list=[a,b,c]
x=max(list)
y=min(list)
list.sort()
z=list[1]
if a==b==c:
    print("0")
elif a==b==x or b==c==x or c==a==x:
    if (x-y)%2==0:
        print(int((x-y)/2))
    else:
        print(int((x+1-y)/2)+1)
elif a==b==y or b==c==y or c==a==y:
    print(x-y)
else:
    if (z-y)%2==0:
        print(int((z-y)/2)+x-z)
    else:
        v=x+1
        w=z+1
        print(1+int((w-y)/2)+v-w)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
mini = min(a, b, c)
new_list = [ a - mini, b - mini, c - mini]
new_list2 = sorted(new_list)
ans2 = 0

maxi = max(new_list)
mid = new_list2[1]

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

print(int(ans2 + maxi - mid))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    l= [int(i) for i in input().split()]
    k = 0
    while(l.count(max(l)) < 3):
        l.sort()
        if max(l) - min(l) > 1:
            l[0] += 2
        else:
            l[1] += 1
            l[0] += 1
        k += 1
    print(k)
        

main()

Submission status: Accepted

Solution code:
import numpy as np

abc=list(map(int,input().split()))
abc=np.array(abc)
abc=np.sort(abc)

abc=abc-abc[0]

b=abc[1]
k=abc[2]-b

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

else:
    ans=k+2+(b-1)//2
    print(ans)

Submission status: Accepted

Solution code:
l = list(map(int, input().split()))
ma = max(l)
c = 0

for i in l:
    c += int((ma - i)/2)
    l[l.index(i)] += int((ma - i)/2) * 2

if l.count(ma-1) == 2:
    c += 1
elif l.count(ma-1) == 1:
    c += 2

print(c)

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

a = na()
b = sorted(a)

ff = b[2]-b[0]
fg = b[2]-b[1]
f = min(ff, fg)
if ff > fg:
    for i in range(f):
        b[0] += 1
        b[1] += 1

    g = b[2] - b[0]
    if g % 2 == 0:
        ans = g // 2
        print(f + ans)
    else:
        ans = g // 2 + 2
        print(f + ans)
elif ff < fg:
    for i in range(f):
        b[0] += 1
        b[1] += 1

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

Submission status: Accepted

Solution code:
ipt = sorted(map(int,input().split()))
X = ipt[0]
Y = ipt[1]
MAX = ipt[2]
cnt = 0

if X%2!=Y%2:
    X = X +1
    MAX = MAX +1
    cnt = cnt +1
#    print("aaaaa")

n = int((MAX - X) / 2)
m = int((MAX - Y) / 2)

cnt = cnt + n + m + (MAX-X)%2
print(cnt)

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
ans = 0
while((A==B==C) == False):
    if A == B:
        if A > C:   # AとBが同じでかつCが最小
            C += 2
        else:
            A += 1
            B += 1

    elif B == C:
        if B > A:   # BとCが同じでかつAが最小
            A += 2
        else:
            B += 1
            C += 1

    elif C == A:
        if C > B:   # CとAが同じでかつBが最小
            B += 2
        else:
            C += 1
            A += 1
    else :           # 3つの変数がバラバラの時
        if A > B > C or A > C > B:
            B += 1
            C += 1
        elif B > A > C or B > C > A:
            A += 1
            C += 1
        else:
            A += 1
            B += 1
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
data = list(map(int,input().split()))
da = [0,0,0]
even = 0
odd = 0
max = 0
min = 50
for i in range(3):
  if max < data[i]:
    max = data[i]
  if min >= data[i]:
    min = data[i]
  if data[i]%2 == 0:
    da[i] = 1
    even += 1
  else:
    odd += 1
if even == 3 or odd == 3:
  print(((max * 3) - (data[0] + data[1] + data[2]))//2)
elif even == 2:
  for i in range(3):
    if da[i] == 1:
      if max == data[i]:
        max += 1
      data[i] += 1
  print(((max * 3) - (data[0] + data[1] + data[2]))//2 + 1)
else:
  for i in range(3):
    if da[i] == 0:
      if max == data[i]:
        max  += 1
      data[i] += 1
  print(((max * 3) - (data[0] + data[1] + data[2]))//2 + 1)

Submission status: Accepted

Solution code:
def main():
    num = [int(i) for i in input().split()]
    iter_num = 0

    while True:
        if (num[0] == num[1]) and (num[1] == num[2]) and (num[2] == num[0]):
            break
        num = sorted(num)
        if num.count(num[2]) == 1:
            num[0] += 1
            num[1] += 1
            iter_num += 1
            continue

        if num.count(num[2]) == 2:
            num[0] += 2
            iter_num += 1
            continue

    print(iter_num)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

cnt=0
diff=a[0]-a[1]
cnt+=diff
a[1]=a[0]
a[2]=a[2]+diff

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

print cnt

Submission status: Accepted

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

x.sort()
count=0

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

if x[0]%2==0:
    count+=int(x[0]/2)-1
    x[0]=2
else:
    count+=int(x[0]/2)
    x[0]=1
    
if x[1]%2==0:
    count+=int(x[1]/2)-1
    x[1]=2
else:
    count+=int(x[1]/2)
    x[1]=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: Accepted

Solution code:
a, b, c = map(int, input().split())		# 5 7 2

l = [a,b,c]
l.sort()
a = l[0]
b = l[1]
c = l[2]

c = c - a
b = b - a
a = a - a

#print(a,b,c)

ans = 0
i = c - b

b += i
a += i
ans += i

#print(a,b,c, ans)

i = (b-a)//2

a += i*2
ans += i

#print(a,b,c, ans)

if a!=b:
	ans += 2

print(ans)

Submission status: Accepted

Solution code:
def check(l, c):
    if l[0] == l[1] == l[2]:
        print(c)
        return True
    return False

n = [int(x) for x in input().split()]
n = sorted(n)
count = 0

if not check(n, count):
    while True:
        if n[1] < n[2]:
            n[0] += 1
            n[1] += 1
            count += 1
            n = sorted(n)
            if check(n, count):
                break
        if n[1] == n[2]:
            n[0] += 2
            count += 1
            n = sorted(n)
            if check(n, count):
                break

Submission status: Accepted

Solution code:
import numpy as np
A, B, C = map(int,input().split(' '))

Srt = np.sort([A,B,C])

if np.sum(Srt % 2) == 0: a = 0; ad = 0;
elif np.sum(Srt % 2) == 1: a = 1; ad = 1;
elif np.sum(Srt % 2) == 2: a = 1; ad = 0;
elif np.sum(Srt % 2) == 3: a = 0; ad = 1;

#num = a + np.sum(Srt[2] // 2 - (Srt // 2))
Add = (Srt + ad) % 2
newSrt = Srt + Add

#print(a)
#print(newSrt)

print(int(a + np.sum((newSrt[2]- newSrt)/2)))

Submission status: Accepted

Solution code:

def equalize(arr):
    idx = 0
    parity = []

    for i in arr:
        parity.append(i%2)

    s = sum(parity)

    if s == 1:
        arr[parity.index(1)] -=1
        idx+=1
    elif s == 2:
        arr[parity.index(0)] -=1
        idx+=1

    arr.sort()

    while arr[0] != arr[2]:
        arr[0] += 2
        arr.sort()
        idx+=1

    return idx

print(equalize(list(map(int, input().split()))))

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
max_abc = max(a, b, c)
ma = (max_abc - a) / 2
mb = (max_abc - b) / 2
mc = (max_abc - c) / 2
if (ma+mb+mc)%2 == 0:
    print(int(ma+mb+mc))
elif (ma+mb+mc) == max_abc:
    print(max_abc)
else:
    total = int(ma) + int(mb) + int(mc) + ((ma-int(ma))*4) + ((mb-int(mb))*4) + ((mc-int(mc))*4)
    print(int(total))

Submission status: Accepted

Solution code:
from math import ceil
a, b, c = map(int, input().split())

MAX = max(max(a,b),c)

distance = (MAX-a) + (MAX-b) + (MAX-c)

if distance % 2 == 0:
    print(int(distance/2))

elif distance % 2 == 1:
    print(int(ceil(distance/2) + 1))

Submission status: Accepted

Solution code:
li = list(map(int,input().split()))
X,Y,Z = map(int,sorted(li))

W = (Z-X) + (Z-Y)

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

Submission status: Accepted

Solution code:
LL = list(map(int,input().split()))
LL.sort()
import numpy as np
LL = np.array(LL)
c = 0
if(sum(LL%2) == 2):
    LL = LL + LL%2
    c += 1
elif(sum(LL%2) == 1):
    LL = LL - LL%2
    c += 1
c += int((LL[2]-LL[1])/2)
c += int((LL[2]-LL[0])/2)
print(c)

Submission status: Accepted

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

def calculate(P, Q, R):
    num = 0
    if abs(P - Q) % 2 == 0:
        num += abs(P - Q) // 2
    else:
        num += 1 + (abs(P - Q) + 1) // 2
        P += 1
        R += 1

    if P - R >= 0:
        if abs(P - R) % 2 == 0:
            num += abs(P - R) // 2
        else:
            num += 1 + (abs(P - R) + 1) // 2

    else:
        num += abs(P - R)

    return num

ans = min(calculate(C, B, A), calculate(C, A, B), calculate(B, A, C))

print(ans)

Submission status: Accepted

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

def doubleplus(x,y):
    return x+1, y+1
def oneplus(x):
    return x+2
while SORT[1] != SORT[2]:
    t += 1
    SORT[0], SORT[1] = doubleplus(SORT[0], SORT[1])
if (SORT[2]-SORT[0])%2 == 0:
    while SORT[0] != SORT[2]:
        t+=1
        SORT[0] =oneplus(SORT[0])
else:
    t +=2
    SORT[0], SORT[1] = doubleplus(SORT[0], SORT[1])
    SORT[0], SORT[2] = doubleplus(SORT[0], SORT[2])
    while SORT[0] != SORT[2]:
        t+=1
        SORT[0] =oneplus(SORT[0])


print(t)

Submission status: Accepted

Solution code:
A,B,C=map(int,input().split())
A2=A%2
B2=B%2
C2=C%2
max_num=max(A,B,C)
swich=A2+B2+C2

if swich==0 or swich==3:
    ans=(max_num*3-A-B-C)//2
else:
    if swich==1:
        if max_num%2==1:
            ans=(max_num*3-2-A-B-C)//2+1
        else:
            ans=(max_num*3+1-A-B-C)//2+1
    if swich==2:
        if max_num%2==0:
            ans=(max_num*3-2-A-B-C)//2+1
        else:
            ans=(max_num*3+1-A-B-C)//2+1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
def cntData(num,MaxData):
    if num == MaxData:
        return 0;
    ans = MaxData - num;
    
    return int(ans/2);
    

data = input().split(" ");
A = int(data[0]);
B = int(data[1]);
C = int(data[2]);
cnt = 0;

if not( (A%2==0 and B%2==0 and C%2==0) or (A%2==1 and B%2==1 and C%2==1) ):
    if (A%2==0 and B%2==0) or (A%2==1 and B%2==1):
        A+=1;
        B+=1;
    elif (A%2==0 and C%2==0) or (A%2==1 and C%2==1):
        A+=1;
        C+=1;
    else:
        B+=1;
        C+=1;
    cnt+=1;
    
MaxData = max(A,B,C);

cnt += cntData(A,MaxData);
cnt += cntData(B,MaxData);
cnt += cntData(C,MaxData);
print(cnt);

Submission status: Accepted

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

def loss(a):
    maxItem = max(a)
    s = 0
    for i in a:
        s+=abs(i-maxItem)
    return s

def inctwo(a):
    maxidx = a.index(max(a))
    copy = list(a)
    for i in range(3):
        if i!=maxidx:
            copy[i]+=1
    return [copy,loss(copy)]

def incone(a):
    minItem = a.index(min(a))
    copy = list(a)
    copy[minItem]+=2
    return [copy,loss(copy)]

def solve(a,ans):
    if loss(a)==0:
        return ans
    one = inctwo(a)
    two = incone(a)
    if one[1]==0 or two[1]==0:
        return ans+1
    if one[1]>two[1]:
        return solve(two[0],ans+1)
    else:
        return solve(one[0],ans+1)

print(solve(a,0))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding=utf-8


if __name__ == '__main__':
    counter = 0
    number_list = list(map(int, input().split()))
    number_list.sort()
    minimum, middle, maximum = number_list[0], number_list[1], number_list[2]
    if (middle - minimum) % 2 == 0:
        counter += (middle-minimum)//2
    else:
        counter += ((middle-minimum)//2 + 2)
    counter += (maximum-middle)
    print(counter)

Submission status: Accepted

Solution code:
lst = [int(i) for i in input().split()]
lst.sort()
count = 0
while (lst[0] != lst[2]):
    if lst[1] < lst[2]:
        lst[0] += 1
        lst[1] += 1
    elif lst[1] - lst[0] < 2:
        lst[1] += 1
        lst[2] += 1
    else:
        lst[0] += 2
    lst.sort()
    count += 1
print(count)

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
cnt = 0
while True:
    keys = [i for i,k in enumerate(a) if k==min(a)]
    if len(keys) == 1:
        a[keys[0]] += 2
    elif len(keys) == 2:
        a[keys[0]] += 1
        a[keys[1]] += 1
    else:
        break
    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
ans=0
atmp=a
if a%2==0:
    if b%2==0:
        tmp1=b
        tmp2=c
    elif c%2==0:
        tmp1=c
        tmp2=b
    else:
        atmp=b
        tmp1=c
        tmp2=a
else:
    if b%2==1:
        tmp1=b
        tmp2=c
    elif c%2==1:
        tmp1=c
        tmp2=b
    else:
        atmp,tmp1,tmp2=b,c,a
maxtmp,mintmp=max(atmp,tmp1),min(atmp,tmp1)
while mintmp<maxtmp:
    mintmp+=2
    ans+=1
if tmp2<mintmp:
    while tmp2<mintmp:
        tmp2+=2
        ans+=1
else:
    while mintmp<tmp2:
        mintmp+=1
        ans+=1
if tmp2!=mintmp:
    ans+=1
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

data.sort()

xxx = sum([data[2]-data[0],data[2]-data[1]])

if xxx % 2 == 1:
   xxx += 3
   
print(xxx//2)

Submission status: Accepted

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

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    Nums = map(int, input().split())
    
    SortedNums = sorted(Nums)
    MaxMidDiff = SortedNums[2] - SortedNums[1]
    MaxMinDiff = SortedNums[2] - SortedNums[0]
    
    if((MaxMidDiff - MaxMinDiff)%2 == 0):
        if(MaxMidDiff%2 == 0):
            print(int(MaxMidDiff/2 + MaxMinDiff/2))
        else:
            print(int(MaxMidDiff/2) + int(MaxMinDiff/2) + 1)
    else:
        if(MaxMidDiff%2 == 0):
            MaxMinDiff += 1
        else:
            MaxMidDiff += 1
        print(int(MaxMidDiff/2 + MaxMinDiff/2) + 1 )
        
    
if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
import re
import sys

if __name__ == '__main__':
    l = map(int, raw_input().split())
    l.sort()
    count = 0
    while l[2] != l[1] or l[1] != l[0]:
        while l[0] == l[1]:
            count += 1
            l[0] += 1
            l[1] += 1
            if l[2] == l[1] and l[1] == l[0]:
                break
        l.sort()
        while l[2] - l[0] > 1:
            count += 1
            l[0] += 2
        if l[2] == l[1] and l[1] == l[0]:
            break
        while l[2] - l[1] > 1:
            count += 1
            l[1] += 2
        if l[2] == l[1] and l[1] == l[0]:
            break
        l.sort()
        if l[1] == l[2]:
            count += 1
            l[0] += 2

    print count

Submission status: Accepted

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

def score(a,b,c):
  return (abs(a-b)+abs(b-c)+abs(c-a))


x = [(a,b,c,0,score(a,b,c))]

while True:
  x = sorted(x, key=lambda x: x[4])
  aa,bb,cc,ii,ss = x.pop(0)

  if aa==bb and bb==cc:
    print(ii)
    break

  x.append((aa+1,bb+1,cc,ii+1,score(aa+1,bb+1,cc)))
  x.append((aa+1,bb,cc+1,ii+1,score(aa+1,bb,cc+1)))
  x.append((aa,bb+1,cc+1,ii+1,score(aa,bb+1,cc+1)))

  x.append((aa+2,bb,cc,ii+1,score(aa+2,bb,cc)))
  x.append((aa,bb+2,cc,ii+1,score(aa,bb+2,cc)))
  x.append((aa,bb,cc+2,ii+1,score(aa,bb,cc+2)))

Submission status: Accepted

Solution code:
A=list(map(int, input().rstrip().split())) #input parameters\
count=int(0)
A.sort()
while A[0]+1<A[1]:
    A[0]+=2
    count+=1
while A[0]!=A[2]:
    A[0]+=1
    A[1]+=1
    A.sort()
    count+=1
print(count)

Submission status: Accepted

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


k = 0
ans = [a, b, c]
p = max(a, b, c)

for i in range(len(ans)):
    ans[i] = p - ans[i]

count = 0


while count != 3:
    count = 0

    for j in range(len(ans)):
        if ans[j] == 0:
            count = count + 1
    
    
    if count == 1:
        for i in range(len(ans)):
            if ans[i] != 0:
                ans[i] = ans[i] - 1

        k = k + 1
    
    elif count == 2:
        for i in range(len(ans)):
            if ans[i] > 0:
                ans[i] = ans[i] - 2
                
            elif ans[i] < 0:
                ans[i] = ans[i] + 1
                
        k = k + 1
    else:
        break
    
print(k)

Submission status: Accepted

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

p = (C - A) % 2
q = (C - B) % 2

if p == 0 and q == 0:
    print(int((C-A)/2 + (C-B)/2))
elif p != 0 and q != 0:
    A += 1
    B += 1
    print(int((C-A)/2 + (C-B)/2) + 1)
elif p != 0 and q == 0:
    C += 1
    A += 2
    B += 1
    print(int((C-A)/2 + (C-B)/2) + 2)
else:
    C += 1
    A += 1
    B += 2
    print(int((C-A)/2 + (C-B)/2) + 2)

Submission status: Accepted

Solution code:
ans = 0
A = [int(i) for i in input().split()]
A.sort()
A = [A[0]-A[2],A[1]-A[2]]
ans += abs(A[1])
a = abs(A[0] - A[1])

ans += a // 2

if a % 2 == 1:
    ans += 2
    
print(ans)

Submission status: Accepted

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

if (n[0]-n[1]) % 2 == 0 and (n[0]-n[2]) % 2 == 0:
    print(int((2*n[0] - n[1] - n[2]) / 2))
elif (n[0]-n[1]) % 2 == 1 and (n[0]-n[2]) % 2 == 1:
    print(int((2*n[0] - n[1] - n[2]) / 2))
else :
    temp1 = n[1] % 2
    temp2 = n[2] % 2
    if n[0] % 2 == temp1:
        print(int((2*(n[0]+1) - (n[1]+1) - n[2])/2)+1)
    else :
        print(int((2*(n[0]+1) - (n[2]+1) - n[1])/2)+1)

Submission status: Accepted

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

a.sort()

ab = a[1] - a[0]

if ab%2 is 0:
    print(ab // 2 + a[2] -a[1])

else:
    print(ab // 2 + a[2] -a[1] +2)

Submission status: Accepted

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

ans = 0

def countEven(a, b, c):
    n = 0
    if a % 2 == 0:
        n += 1
    if b % 2 == 0:
        n += 1
    if c % 2 == 0:
        n += 1
    return n

if countEven(A, B, C) == 3 or countEven(A, B, C) == 0:
    ans += (C * 2 - (B + A)) / 2
elif countEven(A, B, C) == 1:
    ans += 1
    for i in range(3):
        if a[i] % 2 == 1:
            a[i] += 1
    ans += (a[2] * 2 - (a[1] + a[0])) / 2
elif countEven(A, B, C) == 2:
    ans += 1
    for i in  range(3):
        if a[i] % 2 == 0:
            a[i] += 1
    ans += (a[2] * 2 - (a[1] + a[0])) / 2

print(int(ans))

Submission status: Accepted

Solution code:


import numpy as np

def main():
    count=0
    temp=input()
    l=list(map(int,list(temp.split(" "))))
    l.sort()
    
    sa1=l[2]-l[0]
    sa2=l[2]-l[1]
    if sa1%2==1 and sa2%2==1:
        sa1-=1
        sa2-=1
        count+=1
        count+=int(sa1/2)+int(sa2/2)
    elif sa1%2==1 and sa2%2==0:
        sa1+=1
        count+=1
        count+=int(sa1/2)+int(sa2/2)
    
    elif sa1%2==0 and sa2%2==1:
        sa2+=1
        count+=1
        count+=int(sa1/2)+int(sa2/2)
    
    elif sa1%2==0 and sa2%2==0:
        # sa1-=1
        # sa2-=1
        # count+=1
        count+=int(sa1/2)+int(sa2/2)

    print(count)

        


    



    
  

    

if __name__ == '__main__':
    main()

Submission status: Accepted

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



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

    while queue:
        a,b,c,count = queue.pop(0)


        if a == b and b == c:
            return count
        
        if b > a and b > c:
            queue.append([a+1,b,c+1,count+1])

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

        elif c < a:
            # queue.append([a+1,b,c+1,count+1])
            queue.append([a,b,c+2,count+1])


        






print(bfs(a,b,c))

Submission status: Accepted

Solution code:
s = [int(i) for i in input().split()]
s.sort(reverse=True)
if s[0] == s[1] and s[1] == s[2]:
    print(0)
elif s[0] == s[1]:
    if (s[0] - s[2])%2 == 0:
        print((s[0]-s[2])//2)
    else:
        print(1+(s[0]+1-s[2])//2)
elif s[1] == s[2]:
    print(s[0]-s[2])
else:
    if (s[1] - s[2])%2 == 0:
        print(s[0]-s[1]+(s[1]-s[2])//2)
    else:
        print(s[0]-s[1]+1+(s[1]-s[2]+1)//2)

Submission status: Accepted

Solution code:
a,b,c = [int(i) for i in input().split()]
num_list = sorted([a,b,c])
#print(num_list)
min = int((num_list[2]-num_list[0])/2)+int((num_list[2]-num_list[1])/2)
if (num_list[2]-num_list[0])%2==0 and(num_list[2]-num_list[1])%2==0:
    print(min)
elif (num_list[2]-num_list[0])%2!=0 and(num_list[2]-num_list[1])%2!=0:
    print(min+1)
else:
    print(min+2)

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
d=max(a,b,c)
count=0
while (d>=(a+2)):
    a+=2
    count+=1
while d>=(b+2):
    b+=2
    count+=1
while d>=(c+2):
    c+=2
    count+=1
if a+b+c==3*d-2:
    print(count+1)
elif a+b+c==3*d-1:
    print(count+2)
elif a+b+c==3*d:
    print(count)

Submission status: Accepted

Solution code:
def main():
#1. input
    A, B, C = map(int, input().split())

#2. if min<mid => min+2
#    if min==mid => min+1, mid+1
#    else break
    cnt = 0
    nums = sorted([A,B,C])
    min_num = nums[0]
    mid_num = nums[1]
    max_num = nums[2]
    
    while 1:
        nums = sorted([min_num, mid_num, max_num])
        min_num = nums[0]
        mid_num = nums[1]
        max_num = nums[2]

        if (min_num == mid_num) and (mid_num == max_num):
            break
        elif min_num == mid_num:
            min_num += 1
            mid_num += 1
        else:
            min_num += 2
        
        cnt += 1     

#3. output
    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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