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:
lst = list(map(int, input().split()))

mval = max(lst)
sval = sum(lst)
cn = mval + sval % 2
n = (cn * 3 - sval-mval) // 2
print(n)

Submission status: Wrong Answer

Solution code:
# A, B, C = [11, 12, 15]
lst = list(map(int, input().split()))

mval = max(lst)
sval = sum(lst)
cn = mval + sval % 2
n = (cn * 3 - sval) // 2
print(n)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
lst = list(map(int,input().split()))
print(lst)
lst.sort()
count = 0
while len(set(lst)) != 1:
    for i in range(len(lst)-2):
        if lst[i] <= lst[i+1]-2:
            lst[i] += 2
        elif lst[i] <= lst[i+2] and lst[i+1] <= lst[i-1]:
            lst[i] += 1
            lst[i+1] += 1
    count += 1
    lst.sort()
    #print(lst)
print(count)

Submission status: Wrong Answer

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

a.sort(reverse = True)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a.sort()

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

Submission status: Wrong Answer

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

a.sort()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a=list(map(int,input().split()))
t=max(a)*3-sum(a)
print(t+(t%2)*3)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A, B, C = map(int, input().split())
c = 0
while(True):
  if max(A, B, C) >= 2 + min(A, B, C):
    A, B, C = max(A, B, C), A + B + C - max(A, B, C) - min(A, B, C), min(A, B, C) + 2
  else:
    A, B, C = max(A, B, C), A + B + C - max(A, B, C) - min(A, B, C) + 1, min(A, B, C) + 1
  c += 1
  if A == B == C:
    break
print(c)

Submission status: Wrong Answer

Solution code:
a,b,c=map(int,input().split())
ans=0
while 1:
    ans+=1
    if a==min(a,b,c):
        a+=1
        if a==min(a,b,c):
            a+=1
        elif b==min(a,b,c):
            b+=1
        else :
            c+=1
    elif b==min(a,b,c):
        b+=1
        if a==min(a,b,c):
            a+=1
        elif b==min(a,b,c):
            b+=1
        else :
            c+=1
    else :
        c+=1
        if a==min(a,b,c):
            a+=1
        elif b==min(a,b,c):
            b+=1
        else :
            c+=1
    if a==b and b==c:
        print(ans)
        break

Submission status: Wrong Answer

Solution code:
n=list(map(int, input().split()))
n.sort(reverse = True)
count=0
while True:
    if n[1]>=n[0]:
        break
    n[1]+=2
    count+=1
while True:
    if n[2]>=n[0]:
        break
    n[2]+=2
    count+=1
n.sort(reverse=True)
if len(set(n))==1:
    print(count)
elif n.count(n[0])==2:
    print(count-1)
elif n[0]%2!=0:
    print(count+1)
else:
    print(count+3)

Submission status: Wrong Answer

Solution code:
n=list(map(int, input().split()))
n.sort(reverse = True)
count=0
while True:
    if n[1]>=n[0]:
        break
    n[1]+=2
    count+=1
while True:
    if n[2]>=n[0]:
        break
    n[2]+=2
    count+=1
n.sort(reverse=True)
if len(set(n))==1:
    print(count)
elif n.count(n[0])==2:
    print(count-1)
elif n[0]%2!=0:
    print(count+1)
else:
    print(count+2)

Submission status: Wrong Answer

Solution code:
s = list(input())

n = len(s)

a = [0] * n

MOD = 998244353

for i in range(n):
    a[i] = ord(s[i]) - ord('a')

if max(a) == min(a):
    print(1)
    exit()
elif n == 3:
    def solver(m):
        x = m // 100
        y = ( m % 100 ) // 10
        z = m % 10
        if x != y:
            c = (3 - x - y) % 3
            temp = c * 110 + z
            if temp not in ans:
                ans.add(temp)
                solver(temp)
        if y != z:
            c = (3 - y - z) % 3
            temp = x * 100 + c * 11
            if temp not in ans:
                ans.add(temp)
                solver(temp)

    t = a[0] * 100 + a[1] * 10 + a[2]
    ans = set()
    ans.add(t)
    solver(t)
    print(len(ans))
    exit()
elif n == 2:
    print(2)
    exit()

dp = [[0,0,0] for _ in range(3)]

dp[0][0] = 1
dp[1][1] = 1
dp[2][2] = 1

for i in range(n-1):
    T = [[0,0,0] for _ in range(3)]
    T[0][0] = (dp[1][0] + dp[2][0]) % MOD
    T[0][1] = (dp[1][1] + dp[2][1]) % MOD
    T[0][2] = (dp[1][2] + dp[2][2]) % MOD
    T[1][0] = (dp[0][2] + dp[2][2]) % MOD
    T[1][1] = (dp[0][0] + dp[2][0]) % MOD
    T[1][2] = (dp[0][1] + dp[2][1]) % MOD
    T[2][0] = (dp[0][1] + dp[1][1]) % MOD
    T[2][1] = (dp[0][2] + dp[1][2]) % MOD
    T[2][2] = (dp[0][0] + dp[1][0]) % MOD
    dp, T = T, dp

m = sum(a) % 3

ans = 3 ** (n-1) - (dp[0][m] + dp[1][m] + dp[2][m])

check = 1
for i in range(n-1):
    if a[i] == a[i+1]:
        check = 0
        break

ans += check

#print(dp, 2 ** (n-1))

print(ans % MOD)

Submission status: Wrong Answer

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

#parity=set(list(map(lambda x: x % 2,[a,b,c])))
parity=list(map(lambda x: x % 2,[a,b,c]))

if len(set(parity))==1:
    print(int((3*max(a,b,c)-a-b-c)/2))
else:
    if (b-c)%2==0:
        ex=1
    else:
        ex=2
    print(int((max(a,b,c)-a)/2)+int((max(a,b,c)-b)/2)+int((max(a,b,c)-c)/2) + ex)

Submission status: Wrong Answer

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

#parity=set(list(map(lambda x: x % 2,[a,b,c])))
parity=list(map(lambda x: x % 2,[a,b,c]))

if len(set(parity))==1:
    print(int((3*max(a,b,c)-a-b-c)/2))
else:
    if len(set(list(map(lambda x: x % 2,  set([a,b,c])-set([max(a,b,c)]) ))))==1:
        ex=1
    else:
        ex=2
    print(int((max(a,b,c)-a)/2)+int((max(a,b,c)-b)/2)+int((max(a,b,c)-c)/2) + ex)

Submission status: Wrong Answer

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

#parity=set(list(map(lambda x: x % 2,[a,b,c])))
parity=list(map(lambda x: x % 2,[a,b,c]))

if len(set(parity))==1:
    print(int((3*max(a,b,c)-a-b-c)/2))
else:
    if len(set(list(map(lambda x: x % 2,  set([a,b,c])-set([max(a,b,c)]) ))))==1:
        ex=1
    else:
        ex=2
    print(int((3*max(a,b,c)-a-b-c)/2) + ex)

Submission status: Wrong Answer

Solution code:
def main():
    num = [int(i) for i in input().split()]
    num.sort()
    ans = 0
    ans+=((num[2]-num[1])//2)
    num[1]+=(num[2]-num[1])//2*2
    ans+=((num[2]-num[0])//2)
    num[0]+=(num[2]-num[0])//2*2
    if not (num[0]==num[1] and num[1]==num[2] and num[0]==num[2]):
        ans += 2
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
abc=[int(i) for i in input().split(" ")]
abc=sorted(abc)
a,b,c=abc[0],abc[1],abc[2]
if a==b:
    print(str(c-a))
else:
    if (a-b)%2==0:
        print(str(int((b-a)/2+c-b)))
    else:
        print(str(int((b-a-1)/2+c+1-b)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
def getinputdata():

    array_result = []
    
    array_result.append(input().split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()

arr = sorted([int(x) for x in arr_data[0]])

mindata = int(arr[0])
middledata = int(arr[1])
maxdata = int(arr[2])

sabun01 = middledata-mindata
sabun02 = maxdata-middledata
sabun03 = maxdata-mindata

#print(sabun01,sabun02,sabun03)

#minをmiddleに寄せてから　middleをmax
if sabun01 % 2 == 0 and sabun02 % 2 == 0:
    
    cnt01 = (sabun01 // 2) + sabun02
    
elif sabun01 % 2 == 0 and sabun02 % 2 != 0:
    
    cnt01 = (sabun01 // 2) + sabun02 

elif sabun01 % 2 != 0 and sabun02 % 2 != 0:

    cnt01 = (sabun01 // 2) + 1 + 2 + sabun02-1

elif sabun01 % 2 != 0 and sabun02 % 2 == 0:
    
    cnt01 = (sabun01 // 2) + 1 + 1 + sabun02


#middleをmaxに寄せてから　minをmax
if sabun02 % 2 == 0 and sabun03 % 2 == 0:
    cnt02 = (sabun02 // 2) + sabun03
    
elif sabun02 % 2 == 0 and sabun03 % 2 != 0:
    cnt02 = (sabun02 // 2) + sabun03
    
    
elif sabun02 % 2 != 0 and sabun03 % 2 != 0:
    
    cnt02 = (sabun02 // 2) + 1  + 2 + sabun03-1
    
elif sabun02 % 2 != 0 and sabun03 % 2 == 0:
    
    cnt02 = (sabun02 // 2) + 1 + 1+ sabun03

print(min(cnt01,cnt02))

Submission status: Wrong Answer

Solution code:
from collections import Counter
def getinputdata():

    array_result = []
    
    array_result.append(input().split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()

arr = sorted([int(x) for x in arr_data[0]])

mindata = int(arr[0])
middledata = int(arr[1])
maxdata = int(arr[2])

sabun01 = middledata-mindata
sabun02 = maxdata-middledata
sabun03 = maxdata-mindata

print(sabun01,sabun02,sabun03)

#minをmiddleに寄せてから　middleをmax
if sabun01 % 2 == 0 and sabun02 % 2 == 0:
    
    cnt01 = (sabun01 // 2) + sabun02
    
elif sabun01 % 2 == 0 and sabun02 % 2 != 0:
    
    cnt01 = (sabun01 // 2) + sabun02 

elif sabun01 % 2 != 0 and sabun02 % 2 != 0:

    cnt01 = (sabun01 // 2) + 1 + 2 + sabun02-1

elif sabun01 % 2 != 0 and sabun02 % 2 == 0:
    
    cnt01 = (sabun01 // 2) + 1 + 1 + sabun02


#middleをmaxに寄せてから　minをmax
if sabun02 % 2 == 0 and sabun03 % 2 == 0:
    cnt02 = (sabun02 // 2) + sabun03
    
elif sabun02 % 2 == 0 and sabun03 % 2 != 0:
    cnt02 = (sabun02 // 2) + sabun03
    
    
elif sabun02 % 2 != 0 and sabun03 % 2 != 0:
    
    cnt02 = (sabun02 // 2) + 1  + 2 + sabun03-1
    
elif sabun02 % 2 != 0 and sabun03 % 2 == 0:
    
    cnt02 = (sabun02 // 2) + 1 + 1+ sabun03

print(min(cnt01,cnt02))

Submission status: Wrong Answer

Solution code:
li = [int(i) for i in input().split()]
count = 0
while True:
    li.sort(reverse=True)
    dif_1 = li[0] - li[1]
    dif_2 = li[1] - li[2]
    if dif_1 == 0 and dif_2 == 0:
        break
    if dif_1 == 1 and dif_2 == 0:
        li[1] += 1
        li[2] += 1
        count += 1
        continue
    else:
        li[2] += 2
        count += 1
print(li)

Submission status: Wrong Answer

Solution code:
x = sorted(list(map(int, input().split())))
count = 0
while(x[0] != x[2]):
    if(x[1] != x[2]):
        x[0] += 1
        x[1] += 1
    else:
        x[0] += 2
    count += 1
    x = sorted(x)

Submission status: Wrong Answer

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

M = sorted([A,B,C])
ans = 0

#Step 1
ans += M[2]-M[1]
M[0] += M[2]-M[1]
M[1] += M[2]-M[1]

#Step 2
ans += (M[2]-M[0])//2
if (M[2]-M[0])%2==0:
    M[0] += M[2]-M[0]
else:
    M[0] += M[2]-M[0]+1
    M[1] += 1
    M[2] += 1
    ans += 2
    
print(M,ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

a=np.vectorize(int)(input().split())

cnt2=np.vectorize(lambda x: int((np.max(a)-x)/2))(a)
cnt1=np.max(a)-a-2*cnt2
print(a)
print(sum(cnt2)+[0,2,1][sum(cnt1)])

Submission status: Wrong Answer

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

c = 0
for i in a:
    c += b - i
print(c // 2 + c % 2)

Submission status: Wrong Answer

Solution code:
A, B, C = map(int, input().split(" "))
sumABC = sum([A, B, C])
maxABC = max([A, B, C])

if maxABC%2 == sumABC%2:
    print((maxABC*3 - sumABC) // 2)
else:
    if (maxABC*3 + 1 - sumABC) % 2 == 0:
        print((maxABC*3 + 1 - sumABC) // 2)
    else:
        assert ValueError

Submission status: Wrong Answer

Solution code:
A, B, C = map(int, input().split(" "))
sumABC = sum([A, B, C])
maxABC = max([A, B, C])

if maxABC%2 == sumABC%2:
    print((maxABC*3 - sumABC) // 2)
else:
    print((maxABC*3 + 1 - sumABC) // 2)

Submission status: Wrong Answer

Solution code:
A, B, C = map(int, input().split(" "))
sumABC = sum([A, B, C])
maxABC = max([A, B, C])

if maxABC%2 == 0 and sumABC%2 == 0:
    print((maxABC*3 - sumABC) // 2)
else:
    print((maxABC*3 + 1 - sumABC) // 2)

Submission status: Wrong Answer

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

debug_mode = True if len(sys.argv) > 1 and sys.argv[1] == "-d" else False
if debug_mode:
    import os
    infile = open(os.path.basename(__file__).replace(".py", ".in"))

    def input():
        return infile.readline()


# ==============================================================


def main():
    a, b, c = list(map(int, input().strip().split()))
    s = sum((a, b, c))
    x = min(a, b, c)
    steps = 0
    while True:
        if s + steps * 2 == 3 * x:
            break
        elif s + steps * 2 < 3 * x:
            steps += 1
        elif s + steps * 2 > 3 * x:
            x += 1
    print(steps)


main()

# ==============================================================

if debug_mode:
    infile.close()

Submission status: Wrong Answer

Solution code:
a, b, c = map(int, input().split())
 
odd = 0
even = 0
 
max_val = max(a, b, c)
cnt = 0
 
for x in [a, b, c]:
    if x & 1:
        odd += 1
    else:
        even += 1
 
if odd == 0 or even == 0:
    for x in [a, b, c]:
        if x != max_val:
            cnt += int((max_val - x) / 2)
else:
    if (odd == 2 and max_val & 1) or (even == 2 and max_val & 0):
        cnt += 3
    else:
        cnt += 1
    for x in [a, b, c]:
        if x != max_val:
            cnt += int((max_val - x) / 2)
 
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b, c = sorted(map(int, input().split()))
a = c-a; b = c-b
p = a%2; q = b%2
if p and q:
    print(a//2+b//2)
elif p or q:
    print(a//2+b//2+2)
else:
    print(a//2+b//2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def twoNumIncrement(n, m):
    return n+1, m+1

def doubleIncrement(n):
    return n+1

def equal(A, B, C):
    return A==B and B==C

def evenEven(d1, d2):
    return d1//2 + d2//2

# tmpInput = "2 6 3\n"
# inDatas = tmpInput.strip('\n').split(' ')
inDatas = input().strip('\n').split(' ')

inDatas = list(map(int, inDatas))
inDatas.sort()
A = inDatas[0]
B = inDatas[1]
C = inDatas[2]

diff1 = C - A
diff2 = C - B

procCount = 0

if not diff1%2 and not diff2%2:
    print(evenEven(diff1, diff2))
elif diff1%2 or diff2%2:
    print(2+evenEven(diff1, diff2))
else:
    print(1+evenEven(diff1, diff2))

Submission status: Wrong Answer

Solution code:
def twoNumIncrement(n, m):
    return n+1, m+1

def doubleIncrement(n):
    return n+1

def equal(A, B, C):
    return A==B and B==C

def evenEven(d1, d2):
    return d1//2 + d2//2

# tmpInput = "5 4 2\n"
# inDatas = tmpInput.strip('\n').split(' ')
inDatas = input().strip('\n').split(' ')

inDatas = list(map(int, inDatas))
inDatas.sort()
A = inDatas[0]
B = inDatas[1]
C = inDatas[2]

diff1 = C - A
diff2 = C - B

procCount = 0

if not diff1%2 and not diff2%2:
    print(evenEven(diff1, diff2))
else:
    print(1+evenEven(diff1, diff2))

Submission status: Wrong Answer

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

def main():
    A, B, C = list(map(int, input().split()))
    M = max(A, B, C)

    if not M % 2:
        M += 1

    print(int((3*M - (A+B+C))/2))
        

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

a,b,c=map(int,input().split())
num=[a,b,c]
num.sort()
ans=((num[2]*3)-(num[0]+num[1]+num[2]))/2
ans=math.floor(ans)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#-*- coding:utf-8 -*-
from heapq import heappush, heappop
func1 = lambda A,B,C: [(A+1,B+1,C),(A,B+1,C+1),(A+1,B,C+1)]
func2 = lambda A,B,C: [(A+2,B,C),(A,B+2,C),(A,B,C+2)]
def cost_func(A,B,C):
	return abs(A-B)+abs(A-C)+abs(B-C)
def makeNode(alphabets,count):
	A,B,C = alphabets
	return cost_func(A,B,C),A,B,C,count+1

A,B,C = [int(n) for n in input().split()]
first_cost = cost_func(A,B,C)
nodes = [(first_cost,A,B,C,0)]
check = set()
check.add((A,B,C))
while len(nodes)!=0:
	cost,A,B,C,count = heappop(nodes)
	if cost == 0:
		print(count)
		break
	for alphabets in func1(A,B,C) + func2(A,B,C):
		A,B,C = alphabets
		cost = cost_func(A,B,C)
		if first_cost > cost and alphabets not in check:
			check.add(alphabets)
			heappush(nodes,(cost,A,B,C,count+1))

Submission status: Wrong Answer

Solution code:
import numpy as np
def main(A, B, C):
    count = 0
    zlist = [A,B,C]
    zlist.sort(reverse=True)
    b = zlist[0]-zlist[1]
    c = zlist[1]-zlist[2]
    if c % 2 == 0:
        count = b + c/2
    else:
        count = b + (c + 1)/2 + 1    
    return count

Submission status: Wrong Answer

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

is_even = []
max_num = 0
max_num_idx = 0
for i, a_i in enumerate(a):
    if a_i % 2 == 0:
        is_even.append(i)
    if max_num < a_i:
        max_num = a_i
        max_num_idx = i

count = 0
offset = 0
if len(is_even) == 0 or len(is_even) == 3:
    for i, a_i in enumerate(a):
        if i == max_num_idx:
            continue
        offset += (max_num - a_i)
    count += offset // 2
    print(count)
elif len(is_even) == 1:
    if max_num_idx not in is_even:
        max_num += 1
        count += 1
        offset -= 1
    for i, a_i in enumerate(a):
        if i == max_num_idx:
            continue
        offset += (max_num - a_i)
    count += (offset - 1) // 2
    print(count)
else:
    if max_num_idx in is_even:
        max_num += 1
        count += 1
        offset -= 1
    for i, a_i in enumerate(a):
        if i == max_num_idx:
            continue
        offset += (max_num - a_i)
    count += (offset) // 2
    print(count)

Submission status: Wrong Answer

Solution code:
li1 = [int(x) for x in input().split()]
if li1[0]==li1[1] and li1[1]==li1[2]:
    print(0)
m1 = min(li1)
li1.remove(m1)
m2 = min(li1)
li1.remove(m2)
m3 = min(li1)
if (m2 -m1) % 2 == 0:
    print(int((m2 - m1)/2 + (m3 - m2)))
else:
    print(int((m2 - m1)//2 +(m3 -m2) + 2))

Submission status: Wrong Answer

Solution code:
def same_integers():
    li1 = [int(x) for x in input().split()]
    if li1[0]==li1[1] and li1[1]==li1[2]:
        return 0
    m1 = min(li1)
    li1.remove(m1)
    m2 = min(li1)
    li1.remove(m2)
    m3 = min(li1)
    if (m2 -m1) % 2 == 0:
        return int((m2 - m1)/2 + (m3 - m2))
    else:
        return int((m2 - m1)//2 +(m3 -m2) + 2)

Submission status: Wrong Answer

Solution code:
num = [int(x) for x in input().split()]
num.sort()
cnt = 0
while True:
    if num[0] == num[1] and num[1] == num[2]:
        break
    cnt += 1
    if num[1] < num[2]:
        num[0] += 1
        num[1] += 1
    else:
        if num[0] < num[1]:
            num[0] += 2
        else:
            num[1] += 1
            num[2] += 1
    if num[0] == num[1]:
        break
print(cnt)

Submission status: Wrong Answer

Solution code:
num = [int(x) for x in input().split()]
num.sort()
cnt = 0
step = 0
while True:
    cnt += 1
    if num[1] < num[2]:
        num[0] += 1
        num[1] += 1
    else:
        if num[0] < num[1]:
            num[0] += 2
        else:
            num[1] += 1
            num[2] += 1
    if num[0] == num[1]:
        break
print(cnt)

Submission status: Wrong Answer

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

    L = [A, B, C]
    L.sort()
    c = 0

    while L[0] != L[1] and L[0] != L[2]:
        if L[1] < L[2]:
            L[0] += 1
            L[1] += 1
        elif L[0] < L[2]:
            L[0] += 2
        elif L[0] > L[1]:
            L[1] += 1
            L[2] += 1
        c += 1

    return c


if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

Solution code:
# encoding:utf-8

import itertools as it

def main():
	values = list(map(int, input().split()))
	values.sort()
	
	i = 0
	while True:
		values[0] += 1
		values[1] += 1
		i += 1
		if values[1] == values[2]:
			break

	while True:
		values[0] += 2
		i += 1
		if values[0] == values[2]:
			break
		elif values[0] > values[2]:
			i += 1
			break

	print(i)

if __name__ == '__main__':
	main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
X = [int(x) for x in input().split()]
list.sort(X,reverse=True)
A,B,C = X[0],X[1],X[2]
count = 0

while A!=B or B!=C or C!=A:
    if (B-C)%2 == 1:
        A=A+1
        B=B+1
        count = count + 1
    
    elif B!=C and (B-C)%2 == 0:
        while B!=C and B < A and C < A:
            C = C + 2
            count = count + 1
    else:
        B = B + 1
        C = C + 1
        count = count + 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10**5)
a, b, c = map(int, input().split())

M = 100
memo = {}
def dfs(a, b, c):
    if (a, b, c) in memo:
        return memo[a,b,c]
    if a == b == c:
        return 0
    res = 10**9+7
    if a < M:
        res = min(res, dfs(a+2, b, c) + 1)
    if b < M:
        res = min(res, dfs(a, b+2, c) + 1)
    if c < M:
        res = min(res, dfs(a, b, c+2) + 1)
    if a < M and b < M:
        res = min(res, dfs(a+1, b+1, c) + 1)
    if b < M and c < M:
        res = min(res, dfs(a, b+1, c+1) + 1)
    if a < M and c < M:
        res = min(res, dfs(a+1, b, c+1) + 1)
    memo[a, b, c] = res
    return res
print(dfs(a, b, c))

Submission status: Accepted

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

int_list_min = sorted(int_list)

max_diff = int_list_min[2] - int_list_min[0]
min_diff = int_list_min[2] - int_list_min[1]
ans = 0

if (max_diff + min_diff)%2 == 1:
    ans += 1
    min_diff += 1

ans += (max_diff - min_diff)//2 + min_diff
print(ans)

Submission status: Accepted

Solution code:
# author:  Taichicchi
# created: 27.09.2020 18:22:26

import sys

ls = list(map(int, input().split()))
ls.sort()
cnt = 0

for i in [0, 1]:
    c = (ls[2] - ls[i]) // 2
    cnt += c
    ls[i] += 2 * c


if (ls[0] == ls[1]) & ((ls[2] - 1) == ls[1]):
    cnt += 1
elif (ls[0] == (ls[2] - 1)) | (ls[1] == (ls[2] - 1)):
    cnt += 2

print(cnt)

Submission status: Accepted

Solution code:
def solve(a,b,c):
	ans = 0
	if (a&1) != (b&1) and (a&1) != (c&1):
		ans += 1
		b += 1
		c += 1
	elif (b&1) != (a&1) and (b&1) != (c&1):
		ans += 1
		a += 1
		c += 1
	elif (c&1) != (a&1) and (c&1) != (b&1):
		ans += 1
		a += 1
		b += 1

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

print(solve(*sorted(map(int,input().split()))))

Submission status: Accepted

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

mval = lst[-1]
sval = sum(lst)
cn = mval + (sval-mval) % 2
n = (cn * 3 - sval) // 2
print(n)

Submission status: Accepted

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

mval = max(lst)
sval = sum(lst)
cn = mval + (sval-mval) % 2
n = (cn * 3 - sval) // 2
print(n)

Submission status: Accepted

Solution code:
import numpy as np

# A, B, C = [11, 12, 15]
A, B, C = list(map(int, input().split()))


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

sumval = vals.sum()



cn = vals[-1] + np.sum(vals[:2]) % 2

n = (3 * cn - sumval) // 2

print(n)

Submission status: Accepted

Solution code:
a,b,c = map(int,input().split())
ans = 100000
for i in range(-10,60):
    cnt = 0
    for x in [a,b,c]:
        while(x < i):
            x += 2
            cnt += 1
        cnt += x-i
    ans = min(ans,cnt)
print(ans)

Submission status: Accepted

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

n = abs(max - b) + abs(max - c) + abs(max - a)
if n % 2 == 0:
    print(n//2)
else:
    print((n+3) // 2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

a = sorted(inl())
n = a[2] - a[1] + a[2] - a[0]
print((n + 2 - 1) // 2 + 1 if n % 2 else n//2)

Submission status: Accepted

Solution code:
ABC = list(map(int, input().split()))
odds = [x for x in ABC if x % 2]
evens = [x for x in ABC if x % 2 == 0]

ans = 0
if len(odds) == 2:
    odds[0] += 1
    odds[1] += 1
    ans += 1
elif len(evens) == 2:
    evens[0] += 1
    evens[1] += 1
    ans += 1
ABC = sorted(odds + evens)
ans += (ABC[2] - ABC[0]) // 2 + (ABC[2] - ABC[1]) // 2
print(ans)

Submission status: Accepted

Solution code:
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq

abc = lma()
abc.sort()
b = abc[2] - abc[0]
c = abc[2]  -abc[1]
if b%2 == 0 and c%2 == 0:
    ans = b//2+c//2
elif b%2==1 and c%2 ==1:
    ans = (b-1)//2 + (c-1)//2 +1
else:
    ans = b//2 + c//2 +2   
print(ans)

Submission status: Accepted

Solution code:
mod = 1000000007
eps = 10**-9


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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

A.sort()
a_max = A[2]
a_middle = A[1]
a_min = A[0]
ans = 0

if sum(A)%2 != (3*a_max)%2: #偶奇が等しいならば
    ans += 1
    a_max += 1
    a_middle += 1

ans += a_max-a_middle
ans += (a_max-(a_min+(a_max-a_middle)))//2

print(ans)

Submission status: Accepted

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

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

ans = 0

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

Submission status: Accepted

Solution code:

lst = list(map(int,input().split()))
#print(lst)
lst.sort()
count = 0
while len(set(lst)) != 1:
    for i in range(len(lst)-2):
        if lst[i] <= lst[i+1]-2:
            lst[i] += 2
        elif lst[i] <= lst[i+2] and lst[i+1] <= lst[i-1]:
            lst[i] += 1
            lst[i+1] += 1
    count += 1
    lst.sort()
    #print(lst)
print(count)

Submission status: Accepted

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

cnt = 0

cnt += N[2] - N[1]
x, y = divmod(N[1] - N[0], 2)
cnt += x + y * 2

print(cnt)

Submission status: Accepted

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

count = 0

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

while A!= B or B!= C or C!= A:
  if(C- A>= 2):
    lista[0]+= 2
  else:
    lista[0]+= 1
    lista[1]+= 1
  lista.sort()
  A = lista[0]
  B = lista[1]
  C = lista[2]
  count+= 1
  
print(count)

Submission status: Accepted

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