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: Wrong Answer

Solution code:
a = [0,0,0]
s = input().split()
a[0] = int(s[0])
a[1] = int(s[1])
a[2] = int(s[2])

#a_min = min(a)
#a[0] -= a_min
#a[1] -= a_min
#a[2] -= a_min

count = 0
while(True):
    if a[0] == a[1] and a[1] == a[2]:
        #print(count)
        break
    a.sort()
    if a[2] >= a[0]+2:
        a[0] += 2
        count += 1
    elif a[2] == a[1] +1:
        a[2] -= 1
        count += 1
    elif a[1] == a[0] +1:
        a[1] -= 1
        count += 1
    elif a[1] == a[0] +2:
        a[0] += 2
        count += 1
    print(a)
print(count)

Submission status: Wrong Answer

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

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    a, b, c = list(map(int, input().split()))
    count = 0

    i = 0

    while i < 1000:
        if (b - a >= 2):
            a += 2
            count += 1
        if (b - c >= 2):
            c += 2
            count += 1
        if (c - b >= 2):
            b += 2
            count += 1
        if (a - b >= 2):
            b += 2
            count += 1
        if (b - c >= 2):
            c += 2
            count += 1
        if (a - c >= 2):
            c += 2
            count += 1

        if (abs(a - b) > 2 and abs(b - c) > 2) or (abs(b - c) > 2 and abs(c - a) > 2) or (abs(c - a) > 2 and abs(a - b) > 2):
            break

        if a == b == c:
            print(count)
            break

        i += 1

    j = 0

    while j < 1000:
        if a == b and abs(b - c) == 1:
            a += 1
            b += 1
            count += 1
        elif b == c and abs(c - a) == 1:
            b += 1
            c += 1
            count += 1
        else:
            c += 1
            a += 1
            count += 1

        if a == b == c:
            print(count)
            break

        j += 1

Submission status: Wrong Answer

Solution code:
import numpy as np

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

while queue:
    now = queue.pop(0)
    print(now)

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

    min = np.argmin(now[:3])
    
    if(np.max(now[:3])-np.min(now[:3]) > 2):
        now[min] += 2
        now[3] += 1
        queue.append(now)

    else:
        queue.append(now+[1, 1, 0, 1])
        queue.append(now+[1, 0, 1, 1])
        queue.append(now+[1, 1, 0, 1])
        queue.append(now+[0, 1, 1, 1])
        queue.append(now+[1, 0, 1, 1])
        queue.append(now+[0, 1, 1, 1])

Submission status: Wrong Answer

Solution code:
import numpy as np

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

while queue:
    now = queue.pop(0)
    print(now)

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

    min = np.argmin(now[:3])
    
    if(np.max(now[:3])-np.min(now[:3])):
        now[min] += 2
        now[3] += 1
        queue.append(now)

    
    else:
        queue.append(now+[1, 1, 0, 1])
        queue.append(now+[1, 0, 1, 1])
        queue.append(now+[1, 1, 0, 1])
        queue.append(now+[0, 1, 1, 1])
        queue.append(now+[1, 0, 1, 1])
        queue.append(now+[0, 1, 1, 1])

Submission status: Wrong Answer

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

Number=0
count =0

for i in range (50):
    MAX=max(A,B,C)
    Number=0
    if MAX==A:
        Number=Number+1
    if MAX==B:
        Number=Number+1
    if MAX==C:
        Number=Number+1

    if Number ==1:
        MAX=max(A,B,C)
        if MAX!=A:
            A=A+1
        if MAX!=B:
            B=B+1
        if MAX!=C:
            C=C+1
        count=count +1
        Number=0

    if Number ==2:
        MAX=max(A,B,C)
        if MAX!=A:
            A=A+2
        if MAX!=B:
            B=B+2
        if MAX!=C:
            C=C+2
        count=count +1
        Number=0
    
    if Number ==3:
        print('%d'%(count))
        break

Submission status: Wrong Answer

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

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    a, b, c = list(map(int, input().split()))
    count = 0

    i = 0

    while i < 1000:
        if (b - a >= 2):
            a += 2
            count += 1
        if (b - c >= 2):
            c += 2
            count += 1
        if (c - b >= 2):
            b += 2
            count += 1
        if (a - b >= 2):
            b += 2
            count += 1
        if (b - c >= 2):
            c += 2
            count += 1
        if (a - c >= 2):
            c += 2
            count += 1

        if abs(a - b) == 1 and abs(b - c) == 1 and abs(c - a) == 1:
            break

        if a == b == c:
            print(count)
            break

        i += 1

    j = 0

    while j < 1000:
        if a == b and abs(b - c) == 1:
            a += 1
            b += 1
            count += 1
        elif b == c and abs(c - a) == 1:
            b += 1
            c += 1
            count += 1
        else:
            c += 1
            a += 1
            count += 1

        if a == b == c:
            print(count)
            break

        j += 1

Submission status: Wrong Answer

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

l = sorted(m)
a = l[0]
b = l[1]
c = l[2]

if a == b and b ==c:
    print(0)
elif a == b <= c:
    print(abs(c - b))
elif a <= b == c:
    if (b-a)%2 ==0:
        print((b-a)//2)
    else:
        print((b-a)//2 + 2)
else:
    counter_1 = 0
    counter_2 = 0
    aa = a
    bb = b
    cc = c
    aaa = a
    bbb = b
    ccc = c
    
    while bb != cc:
        counter_1 = counter_1 + 1
        aa = aa + 1
        bb = bb + 1
    if (bb-aa)%2 ==0:
        counter_1 = counter_1 + (bb-aa)//2
    else:
        couter_1 = (bb-aa)//2 + 2 + counter_1
    
    while bbb <=ccc:
        counter_2 = counter_2 + 2
        bbb = bbb + 2
        aaa = aaa + 2
    if (bbb-aaa)%2 ==0:
        counter_2 = counter_2 + (bbb-aaa)//2
    else:
        couter_2 = (bbb-aaa)//2 + 2 + counter_2
    
    print(min(counter_1,counter_2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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)
print(inp)
dif = inp[2] - inp[0] + inp[2] - inp[1]
if dif%2 == 0:
    print(dif//2)
else:
    print((dif+3)//2)

Submission status: Wrong Answer

Solution code:
S = input()
s_2 = [int(x) for x in S.split()]

counter = 0

s = sorted(s_2)

if s[0] == s[1] == s[2]:
    pass

elif s[0] == s[1]:
    counter += s[2]-s[1]

elif s[1] == s[2]:
    if (s[1]-s[0])%2 ==0:
        counter += (s[1]-s[0])/2
    else:
        counter += ((s[1]-s[0]+1)/2 +1)

else:
    counter += (s[2]-s[1])
    num = s[0]+counter
    if (s[2]-num)%2 ==0:
        counter += (s[2]-num)/2
    else:
        counter += ((s[2]-num +1)/2 +1)

print(counter)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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: Wrong Answer

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(distance/2)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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 or np.sum(Srt % 2) == 3: a = 0
elif np.sum(Srt % 2) == 1 or np.sum(Srt % 2) == 2: a = 1

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()
s_2 = [int(x) for x in S.split()]

counter = 0

s = sorted(s_2)

if s[0] == s[1] == s[2]:
    pass

elif s[1] == s[2]:
    if (s[1]-s[0])%2 ==0:
        counter += (s[1]-s[0])/2
    else:
        counter += ((s[1]-s[0]+1)/2 +1)

else:
    counter += (s[2]-s[1])
    num = s[0]+counter
    if (s[2]-num)%2 ==0:
        counter += (s[2]-num)/2
    else:
        counter += ((s[2]-num +1)/2 +1)

print(counter)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    A, B, C = map(int, input().split())
    sum = A + B + C
    i = 1
    while 1:
        sum = sum + 2
        if(sum % 3 == 0):
            print(i)
            break;
        i = i + 1

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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
while tmp2<mintmp:
    tmp2+=2
    ans+=1
if tmp2!=mintmp:
    ans+=1
print(ans)

Submission status: Wrong Answer

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 or np.sum(Srt % 2) == 3: a = 0
elif np.sum(Srt % 2) == 1 or np.sum(Srt % 2) == 2: a = 1

num = a + np.sum(Srt[2] // 2 - (Srt // 2))

print(num)

Submission status: Wrong Answer

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

if (C - B) % 2 == 0:
    num+= (C - B) // 2
else:
    num += 1 + (C - B + 1) // 2
    C += 1
    A += 1

if (C - A) % 2 == 0:
    num += (C - A) // 2
else:
    num += 1 + (C - A + 1) // 2

print(num)

Submission status: Wrong Answer

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
count = 0
if a == 0:
    ma = 0
    count += 1
if b == 0:
    mb = 0
    count += 1
if c == 0:
    mc = 0
    count += 1
if count > 1:
    print(max_abc)
elif (ma+mb+mc)%2 == 0:
    print(int(ma+mb+mc))
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: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
 
N = list(map(int, input().split()))
 
N.sort()

if (N[2]-N[1]) % 2 == 0:
    plus1 =int((N[2]-N[1]) / 2)
    for i in range(0,plus1):
        N[1] = N[1] + 2
else:
    plus1 = N[2]-N[1] 
    for i in range(0,plus1):
        N[1] = N[1] + 1
        N[0] = N[0] + 1
 
if (N[2] - N[0]) % 2 == 0:
    plus2 = int((N[2] - N[0]) / 2)
    num = plus1 + plus2
    print(num)
else:
    plus2 = (N[2] - N[0]) + 1
    num = plus1 + plus2
    print(num)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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))
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: Wrong Answer

Solution code:
l = sorted(map(int, input().split()))
maxv = l[-1]
a, b, c = l
cnt = 0
if maxv % 2:
    if a % 2 and b % 2 == 0:
        # 1 4 5
        a += 1
        c += 1
        cnt = (c-b) // 2 + (c-a) // 2
    elif a % 2 and b % 2:
        # 1 3 5
        cnt = (c-b) // 2 + (c-a) // 2
    else:
        # 2 4 5
        tmp = c - b
        cnt += tmp
        a += tmp
        cnt += (c - a) // 2
else:
    if a % 2 and b % 2 == 0:
        # 1 4 6
        a += 1
        c += 1
        # 2 4 7
        tmp = c - b
        cnt += tmp
        a += tmp
        cnt += (c - a) // 2
    elif a % 2 and b % 2:
        # 1 3 6
        tmp = c - b
        cnt += tmp
        a += tmp
        cnt += (c - a) // 2
    else:
        cnt = (c-b)//2+(c-a)//2
print(cnt)

Submission status: Wrong Answer

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))
else:
    print(int(diff/2))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from copy import deepcopy
N = list(map(int, input().split()))
M = deepcopy(N)
N.sort()
M.sort()

plus1 = N[2]-N[1]

for i in range(0,plus1):
    N[1] = N[1] + 1
    N[0] = N[0] + 1

if (N[2] - N[0]) % 2 == 0:
    plus2 = int((N[2] - N[0]) / 2)
    num1 = plus1 + plus2
#    print(num)
else:
    plus2 = (N[2] - N[0]) + 1
    num1 = plus1 + plus2
#    print(num)


plus1 = M[2]-M[0]

for i in range(0,plus1):
    M[1] = M[1] + 1
    M[0] = M[0] + 1

if (M[2] - M[1]) % 2 == 0:
    plus2 = int((M[2] - M[1]) / 2)
    num2 = plus1 + plus2

else:
    plus2 = (M[2] - M[1]) + 1
    num2 = plus1 + plus2

if num1 < num2:
    print(num1)
else:
    print(num2)

Submission status: Wrong Answer

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:
	count += ((lists[2]-1)-lists[0])/2
	count += ((lists[2]-1)-lists[1])/2
else :
	count += ((lists[0])-lists[0])/2
	count += ((lists[0])-lists[1])/2
print(int(count))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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: Wrong Answer

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

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

N.sort()

plus1 = N[2]-N[1]

for i in range(0,plus1):
    N[1] = N[1] + 1
    N[0] = N[0] + 1

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

Submission status: Wrong Answer

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

ans = C - B
A += ans
if (C - A) // 2 != 0:
    ans += (C-A)//2
else:
    ans += (C-A)//2 + 2
print(ans)

Submission status: Wrong Answer

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


while not(a[0] == a[1] == a[2]):
    a.sort()
    if a[2] - a[0] >= 2:
        a[0] += 2
        cnt += 1
        
    a.sort()
    if a[2] - a[0] >= 1 or a[2] - a[1] >= 1:
        a[0] += 1
        a[1] += 1
        cnt += 1

print(cnt)

Submission status: Wrong Answer

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

dA = C - A
dB = C - B

ans = 0
if dA%2==0 and dB%2!=0:
    A += 1
    C += 1
    ans += 1
elif dA%2!=0 and dA%2==0:
    B += 1
    C += 1
    ans += 1
elif dA%2!=0 and dB%2!=0:
    A += 1
    B += 1
    ans += 1

dA = C - A
dB = C - B
ans += dA//2 + dB//2

print(ans)

Submission status: Wrong Answer

Solution code:
vals = [int(s) for s in input().split()]

rs = [v%2 for v in vals]

def f(vs):
    m = max(vs)
    ans = sum([(m-x)//2 for x in vs])
    return ans

add = 0
if not (sum(rs)==0 or sum(rs)==3):
    add = 1
    if rs[0]==rs[1]:
        vals[0] += 1
        vals[1] += 1
    if rs[1]==rs[2]:
        vals[1] += 1
        vals[2] += 1
    if rs[2]==rs[0]:
        vals[2] += 1
        vals[0] += 1

Submission status: Wrong Answer

Solution code:
a,b,c=list(map(int,input().split()))
mi=min([a,b,c])
ma=max([a,b,c])
mid=a+b+c-mi-ma
ans=0

if (mid-mi)%2==1:
  ans+=1
  ma+=1
  mi+=1
  ans+=(mid-mi)/2
  ans+=ma-mid
else:
  ans+=(mid-mi)/2
  ans+=ma-mid

print(ans)

Submission status: Wrong Answer

Solution code:
a,b,c=list(map(int,input().split()))
mi=min([a,b,c])
ma=max([a,b,c])
mid=a+b+c-mi-ma
ans=0

if (mid-mi)%2==1:
  ans+=1
  ma+=1
  mi+=1
  ans+=(mid-mi)/2
  ans+=ma-mid
else:
  ans+=(mid-mi)/2
  ans+=ma-mid

Submission status: Time Limit Exceeded

Solution code:
a = list(map(int, input().split()))
s, m, b = sorted(a)
cnt = 0
while not b == m == s:
    m_s = m - s
    b_m = b - m
    if m_s % 2 == 0 and m < b and m_s != 0:
        cnt += m_s // 2
        s += m_s
    elif m_s % 2 == 1 and m < b:
        cnt += 1
        s += 1
        b += 1
    elif m_s == 0 and m < b:
        cnt += b_m
        break
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
n = list(map(int, input().split()))
b, m, s = sorted(n)[::-1]
cnt = 0
while not b == m == s:
    m_s = m - s
    b_m = b - m
    if m_s % 2 == 0 and m < b and m_s != 0:
        cnt += m_s // 2
        s += m_s
    elif m_s % 2 == 1 and m < b:
        cnt += 1
        s += 1
        b += 1
    elif m_s == 0 and m < b:
        cnt += b_m
        m += b_m
        s += b_m
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
n = list(map(int, input().split()))
b, m, s = sorted(n)[::-1]
cnt = 0
while b != m or m != s or s != b:
    m_s = m - s
    b_m = b - m
    if m_s % 2 == 0 and m < b and m_s != 0:
        cnt += m_s // 2
        s += m_s
    elif m_s % 2 == 1 and m < b:
        cnt += 1
        s += 1
        b += 1
    elif m_s == 0 and m < b:
        cnt += b_m
        m += b_m
        s += b_m
print(cnt)

Submission status: Time Limit Exceeded

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

a = list(map(int,input().split()))
a.sort(reverse=True)

cnt = 0
while True:
	if a[0] == a[1] == a[2]:
		break
	elif a[0] == a[1] > a[2]:
		if (a[0] - a[2])%2 == 0:
			cnt += (a[0] - a[2])//2
			a[2] = a[0]
		else:
			cnt += (a[0]+1 - a[2])//2
			cnt += 1
			a[0] += 1
			a[1] += 1
			a[2] = a[0]
	elif a[0] > a[1] > a[2]:
		a[1] += 1
		a[2] += 1
		cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
import queue
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1

arr = readInts()
gu_num = arr[0]%2+arr[1]%2+arr[2]%2

ans = 0

if gu_num in [0,3]:
	while not(arr[0]==arr[1] and arr[1]==arr[2]):
		arr[arr.index(min(arr))]+=2
		ans+=1
	print(ans)
else:
	ans+=1
	if gu_num==1:
		if arr[0]%2==1:
			arr[1]+=1
			arr[1]+=1
		elif arr[1]%2==1:
			arr[0]+=1
			arr[2]+=1
		else:
			arr[0]+=1
			arr[1]+=1
	else:
		if arr[0]%2==0:
			arr[1]+=1
			arr[1]+=1
		elif arr[1]%2==0:
			arr[0]+=1
			arr[2]+=1
		else:
			arr[0]+=1
			arr[1]+=1
	while not(arr[0]==arr[1] and arr[1]==arr[2]):
		arr[arr.index(min(arr))]+=2
		ans+=1
	print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

def search(a,b,c):
    lst = [0,0,0]
    if a%2 == b%2:
        lst = [1,1,0]
        if a%2==c%2:
            lst = [1,1,1]
    elif a%2 == c%2:
        lst = [1,0,1]
    else:
        lst = [0,1,1]
    return lst


def make(a,b,c):
    lst = [a,b,c]
    lst.sort()
    lst[0] += 2
    return lst[0],lst[1],lst[2]

if __name__ == "__main__":
    ans = 0
    l = search(a,b,c)
    if sum(l) == 3:
        pass
    else:
        ans += 1
        for i,j in zip(l,[a,b,c]):
            j += i
    while a != b or a != c:
        a,b,c = make(a,b,c)
        ans += 1
    print(ans)

Submission status: Time Limit Exceeded

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

import numpy as np
import scipy

#N = int(input())
#C = [[0 for i in range(3)] for j in range(3)]
#for i in range(3):
#    C[i] = list(map(int, input().split()))
S = list(map(int, input().split()))
#A, B, C = map(int, input().split())

def plus1(X, Y):
    return X+1, Y+1

def plus2(Z):
    return Z+2

c = 0
S = sorted(S)

while True:
    S[0], S[1] = plus1(S[0], S[1])
    c += 1
    if S[1] == S[2]:
        break

if (S[1] - S[0])%2 != 0:
    S[1], S[2] = plus1(S[1], S[2])
    c += 1

while True:
    S[0] = plus2(S[0])
    c += 1
    if S[0] == S[1]:
        break

print(c)

Submission status: Time Limit Exceeded

Solution code:
A,B,C = map(int,input().split())
maxi = max(A,B,C)
mini = min(A,B,C)
mid = sum([A,B,C]) - (maxi+mini)
i,j,k,l = 0,0,0,0
if mini%2 != mid%2:
    #midだけ偶奇が違うとき
    if maxi%2 == mini%2 and maxi%2 != mid%2:
        while mid - maxi != 1:
            mid += 2
            i += 1
    #miniだけ偶奇が違うとき
    if maxi%2 != mini%2 and maxi%2 == mid%2:
        while mini - maxi != 1:
            mid += 2
            j += 1
while maxi - mini > 1:
    mini += 2
    k += 1
while maxi - mid > 1:
    mid += 2
    l += 1
if maxi == mini and maxi == mid:
    print(i+j+k+l)
else:
    print(i+j+k+l+1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
if __name__ == "__main__":
    A, B, C = map(int, input().split())
    
    max_v = max(A, B, C)
    min_v = min(A, B, C)
    
    num_list = [A, B, C]
    num_list.remove(max_v)
    if len(num_list) == 2:
        num_list.remove(min_v)
        if len(num_list) == 1:
            mid_v = num_list[0]
        else:
            mid_v = min_v
    else:
        mid_v = max_v
    
    ans = 0
    while True:
        if mid_v < max_v:
            ans += max_v - mid_v
            min_v += max_v - mid_v
            mid_v = max_v
            #print("aaa", min_v, mid_v, max_v)
        else:#mid_v = max_v
            if min_v < max_v:
                if (max_v - min_v) % 2 == 0:
                    #min_v = max_v
                    ans += (max_v - min_v) / 2
                    #print("bbb", min_v, mid_v, max_v)
                    break
                else:
                    #min_v = max_v
                    #max_v += 1
                    #mid_v += 1
                    ans += (max_v + 1 - min_v) / 2
                    ans += 1
                    #print("ccc", min_v, mid_v, max_v)
                    break
    
    print(int(ans))

Submission status: Time Limit Exceeded

Solution code:
A, B, C = map(int, raw_input().split())
memo = [[A, B, C]]
queue = [[0, [A, B, C]]]
while queue != []:
	now = queue.pop(0)
	if now[1][0] == now[1][1] and now[1][0] == now[1][2]:
		print now[0]
		break
	next = []
	for i in range(0, 3):
		lst1 = [now[1][0], now[1][1], now[1][2]]
		lst2 = [now[1][0]+1, now[1][1]+1, now[1][2]+1]
		lst1[i] += 2
		lst2[i] -= 1
		next.append(lst1)
		next.append(lst2)
	for i in range(0, 6):
		if next[i] not in memo:
			memo.append(next[i])
			queue.append([now[0]+1, next[i]])

Submission status: Time Limit Exceeded

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

def dfs(a, b, c, count):
    if a == b == c:
        return count
    elif a > 51 or b > 51 or c > 51:
        return 1000
    count = min(dfs(a+1, b+1, c, count+1), dfs(a, b+1, c+1, count+1),\
            dfs(a+1, b, c+1, count+1), dfs(a+2, b, c, count+1),      \
            dfs(a, b+2, c, count+1), dfs(a, b, c+2, count+1))

    return count

count = dfs(A, B, C, count)

print(count)

Submission status: Time Limit Exceeded

Solution code:
A,B,C = map(int,input().split())
 
counter = 0
 
while not A == B == C:
    if max([A,B,C])-min([A,B,C]) > 1:
        if A < B and A < C:
            A += 2
        elif B < A and B < C:
            B += 2
        else:
            C += 2
        counter += 1
    else:
        if A < C and B < C:
            A += 1
            B += 1
        elif A < B and C < B:
            A += 1
            C += 1
        else:
            B += 1
            C += 1
        counter += 1
        
print(counter)

Submission status: Time Limit Exceeded

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

counter = 0

while A != B or B != C or A != C:
    if A - B > 1 or A - C > 1 or B - A > 1 or B - C > 1 or C - A > 1 or C - B > 1:
        if A < B and A < C:
            A += 2
        elif B < A and B < C:
            B += 2
        else:
            C += 2
        counter += 1
    else:
        if A < C and B < C:
            A += 1
            B += 1
        elif A < B and C < B:
            A += 1
            C += 1
        else:
            B += 1
            C += 1
        counter += 1

print(counter)

Submission status: Time Limit Exceeded

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

counter = 0

while A != B or B != C or A != C:
    if max([A,B,C])-min([A,B,C]) > 1:
        if A < B and A < C:
            A += 2
        elif B < A and B < C:
            B += 2
        else:
            C += 2
        counter += 1
    else:
        if A < C and B < C:
            A += 1
            B += 1
        elif A < B and C < B:
            A += 1
            C += 1
        else:
            B += 1
            C += 1
        counter += 1

print(counter)