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

Solution (Python):
A, B, C = map(int, input().split())
ans = 0
while((A==B==C) == False):
    if A == B:
        if A > C:   
            C += 2
        else:
            A += 1
            B += 1

    elif B == C:
        if B > A:   
            A += 2
        else:
            B += 1
            C += 1

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

Solution (Python):
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)

Solution (Python):
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()

Solution (Python):
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

Solution (Python):
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()

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

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

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



ans = 0
i = c - b

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



i = (b-a)//2

a += i*2
ans += i



if a!=b:
	ans += 2

print(ans)

Solution (Python):
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

Solution (Python):
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;


Add = (Srt + ad) % 2
newSrt = Srt + Add




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

Solution (Python):

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()))))

Solution (Python):
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))

Solution (Python):
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))

Solution (Python):
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))

Solution (Python):
a = sorted(int(i) for i in input().split()) 
print((a[1] - a[0]+1) // 2 + a[2] - a[1] + (a[1] - a[0]) % 2)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):

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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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))

Solution (Python):

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);

Solution (Python):
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))

Solution (Python):
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)

Solution (Python):



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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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))

Solution (Python):
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)

Solution (Python):
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()

Solution (Python):
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)

Solution (Python):
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()

Solution (Python):
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

Solution (Python):
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)))

Solution (Python):
A=list(map(int, input().rstrip().split())) 
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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))

Solution (Python):


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:
        
        
        
        count+=int(sa1/2)+int(sa2/2)

    print(count)

        


    



    
  

    

if __name__ == '__main__':
    main()

Solution (Python):
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+2,b,c,count+1])
        
        
        elif b < c:
            queue.append([a,b+2,c,count+1])
            

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


        






print(bfs(a,b,c))

Solution (Python):
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)

Solution (Python):
ns = [int(n) for n in input().split()]
ans = 0
while True:
    ns = sorted(ns)
    a = ns[0]
    b = ns[1]
    c = ns[2]
    if a == b and b == c:
        break
    elif a == b:
        if abs(a - c) >= 2:
            ns[1] = a + 2
        else:
            ns[0] = a + 1
            ns[1] = a + 1
        ans = ans + 1
    elif b == c:
        if abs(a - b) == 1:
            ans = ans + 2
            break
        else:
            ns[0] = a + 2
            ans = ans + 1
    else:
        ns[0] = a + 2
        ans = ans + 1
print(ans)

Solution (Python):
a,b,c = [int(i) for i in input().split()]
num_list = sorted([a,b,c])

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)

Solution (Python):
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)

Solution (Python):
def main():

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




    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     


    print(cnt)


if __name__ == "__main__":
    main()

Solution (Python):
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))

Solution (Python):
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)

Solution (Python):
import sys

s_args = sys.stdin.read().splitlines()

s_args = s_args[0].split(' ')

a = int(s_args[0])
b = int(s_args[1])
c = int(s_args[2])

eo = []
res = 0

if a % 2 == 0:
    eo.append('a')
if b % 2 == 0:
    eo.append('b')
if c % 2 == 0:
    eo.append('c')

if len(eo) != 0 and len(eo) != 3:
    res += 1
    if len(eo) == 1:
        if not 'a' in eo:
            a += 1
        if not 'b' in eo:
            b += 1
        if not 'c' in eo:
            c += 1
    elif len(eo) == 2:
        if 'a' in eo:
            a += 1
        if 'b' in eo:
            b += 1
        if 'c' in eo:
            c += 1

n = [a, b, c]
n.sort()
res += (n[2] - n[0]) // 2
res += (n[2] - n[1]) // 2

print(res)

Solution (Python):
inLine = list(map(int,input().split()))
ret = 0
inLine.sort(reverse = True)
if (inLine[1]-inLine[2]) % 2 != 0 :
    inLine[0] += 1
    inLine[2] += 1
    ret += 1
while inLine[0] != inLine[1]:
    inLine[1] += 1
    inLine[2] += 1
    ret += 1
while inLine[0] != inLine[2]:
    inLine[2] += 2
    ret += 1
print(ret)

Solution (Python):
text = input()

a = int(text.split(' ')[0])
b = int(text.split(' ')[1])
c = int(text.split(' ')[2])

x, y, z = sorted([a, b, c])

cnt = z - y
y = z
x += cnt

cnt += int((y - x) / 2)
x += int((y - x) / 2) * 2

if y - x == 1:
    print(cnt+2)
else:
    print(cnt)

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

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

Solution (Python):
def get_next_int():
    return int(float(input()))


def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])


def get_next_str():
    return input()


def get_next_strs(delim=" "):
    return tuple(input().split(delim))


def get_next_by_types(*value_types, delim=" "):
    return tuple([t(x) for t, x in zip(value_types, input().split(delim))])


def solve():
    A, B, C = get_next_ints()
    parity = (A % 2 + B % 2 + C % 2)
    ans = 0
    if parity == 1:
        A += 1 if A % 2 == 0 else 0
        B += 1 if B % 2 == 0 else 0
        C += 1 if C % 2 == 0 else 0
        ans += 1
    if parity == 2:
        A += 1 if A % 2 != 0 else 0
        B += 1 if B % 2 != 0 else 0
        C += 1 if C % 2 != 0 else 0
        ans += 1
    max_val = max(A, B, C)
    ans += int((max_val - A) / 2 + (max_val - B) / 2 + (max_val - C) / 2)
    print(ans)

solve()

Solution (Python):
L=list(map(int,input().split()))
L.sort()
S=0
S+=(L[2]-L[1])
D=L[2]-(L[0]+S)
if D%2==0:
	S+=(D//2)
else:
	S+=(D//2)+2
print(S)

Solution (Python):
l = list(map(int, input().split()))
l_2 = list(i % 2 for i in l)
cnt = 0

for r in (0, 1):
    if l_2.count(r) == 2:
        cnt += 1
        for i in range(len(l)):
            if l[i] % 2 == r:
               l[i] += 1


l_d = list(abs(i - max(l)) // 2 for i in l)


cnt += sum(l_d)
print(cnt)

Solution (Python):




def main(input_str):
    a, b, c = list(map(int, input_str.split(' ')))
    max_val = max([a, b, c])
    counter = 0
    for i in [a, b, c]:
        counter += max_val - i

    if 1 == counter % 2:
        counter -= 1
        print(int(counter/2 + 2))
        return
    else:
        print(int(counter/2))
        
if __name__ == '__main__':
    try:
        main(input().strip())
    except EOFError:
        pass

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

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

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

Solution (Python):
raw_a, raw_b, raw_c = map(int, input().split())









a_guuki = raw_a % 2
b_guuki = raw_b % 2
c_guuki = raw_c % 2

if a_guuki == b_guuki == c_guuki:
    a = raw_a
    b = raw_b
    c = raw_c
    if a == b == c:
        print(0)
        exit()
    max_number = max(a, b, c)
    if max_number == a:
        print((a-b)//2 + (a-c)//2)
        exit()
    if max_number == b:
        print((b-a)//2 + (b-c)//2)
        exit()
    if max_number == c:
        print((c-a)//2 + (c-b)//2)
        exit()

elif a_guuki == b_guuki:
    a = raw_a
    b = raw_b
    c = raw_c
elif a_guuki == c_guuki:
    a = raw_a
    b = raw_c
    c = raw_b
elif b_guuki == c_guuki:
    a = raw_b
    b = raw_c
    c = raw_a

ans = 0

ans += abs(a-b)//2 + 1  

ans += (max(a, b)+1 - c) // 2  

print(ans)

Solution (Python):
import sys

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


def sousa1():
	global count
	global l
	x_min=l.index(min(l))
	x_max=l.index(max(l))
	x_else = 0 if x_min+x_max==3 else 1 if x_min+x_max==2 else 2
	count+=l[x_max]-l[x_else]

	l[x_min]+=l[x_max]-l[x_else]
	l[x_else]=l[x_max]
	

def sousa1_2():
	global count
	global l
	x_min=l.index(min(l))
	x_max=l.index(max(l))
	x_else = 0 if x_min+x_max==3 else 1 if x_min+x_max==2 else 2

	count+=1
	l[x_else]+=1
	l[x_max]+=1

def sousa2():
	global count
	global l
	x_min=l.index(min(l))
	x_max=l.index(max(l))
	count+=(l[x_max]-l[x_min])/2
	l[x_min]=l[x_max]


def judge():
	x_min=l.index(min(l))
	x_max=l.index(max(l))
	x_else = 0 if x_min+x_max==3 else 1 if x_min+x_max==2 else 2
	if l[x_max]!=l[x_else]:
		return 0
	elif (l[x_max]-l[x_min])%2==0:
		return 1
	else:
		return 2

while not(l[0]==l[1] and l[1]==l[2] and l[0]==l[2]):
	hoge=judge()
	if hoge==0:
		sousa1()
	elif hoge==1:
		sousa2()
	else:
		sousa1_2()

print(int(count))

Solution (Python):
from sys import stdin


def main():
    abc = [int(x) for x in stdin.readline().rstrip().split()]
    count = 0
    while True:
        abc.sort()
        if abc[0] == abc[1] == abc[2]:
            print('{}'.format(count))
            return
        if abc[1] == abc[2]:
            abc[0] += 2
        else:
            abc[0] += 1
            abc[1] += 1
        count += 1


if __name__ == '__main__':
    main()

Solution (Python):

def exec():
    arr = map(int, input().split())
    a,b,c = sorted(arr)

    t1 = c - b
    t2 = c - (t1+a)
    if t2 % 2 == 0:
        t1 += int(t2/2)
    else:
        t1 += int(t2/2) + 1 + 1
    print(t1)


if __name__ == "__main__":
    exec()

Solution (Python):
def mod2(n):
    return n%2

def f(L): 
    L2 = list(map(mod2, L))
    num0 = L2.count(0)
    if num0 == 0 or num0 == 3:
        L.sort()
        L.reverse()
        return (L[0] * 2 -L[2] - L[1]) //2
    else:
        d = 0 if num0 == 1 else 1
        m = {0, 1, 2} - {L2.index(d)}
        Lnext = [L[n] + 1 if n in m else L[n] for n in range(3)]
        return 1 + f(Lnext)
        
print(f(list(map(int, input().split()))))

Solution (Python):

import numpy as np
inputs = np.array(input().split(), dtype = 'float')

diff = inputs.max() * 3 - inputs.sum()
if diff % 2 == 0:
    print(int(diff / 2.0))
else:
    print(int(np.floor(diff / 2.0)) + 2)

Solution (Python):
a = list(map(int,input().split()))
count = 0
a.sort()
sub = a[0]
for i in range(3):
	a[i] -= sub
while a[0] < a[1]-1:
	count += 1
	a[0] += 2
if a[0] == a[1]:
	count += a[2]-a[1]
else:
	count += 2 + a[2] - a[1]
print(count)

Solution (Python):
A, B, C = map(int, raw_input().split())

num = 0

while (A != B or B != C or C != A):
    if max(A,B,C) == A and A != B and A != C:
        B += 1
        C += 1
    elif max(A,B,C) == A and A == B and A != C:
        C += 2
    elif max(A,B,C) == A and A != B and A == C:
        B += 2
    elif max(A,B,C) == B and B != A and B != C:
        A += 1
        C += 1
    elif max(A,B,C) == B and B != A and B == C:
        A += 2
    elif max(A,B,C) == B and B == A and B != C:
        C += 2
    elif max(A,B,C) == C and C != A and C != B:
        A += 1
        B += 1
    
    
    
    
    
    
    else:
        print "unexpect"

    num += 1


print num

Solution (Python):
def c_same_integers(A, B, C):
    max_value = max(A, B, C)
    t = []
    ans = 0
    for e in [A, B, C]:
        if e == max_value:
            t.append(max_value)
            continue
        if e % 2 == max_value % 2:
            t.append(max_value)
        else:
            t.append(max_value - 1)
        ans += (max_value - e) // 2
    t.sort(reverse=True)
    x, y, z = t
    if x == y == z:
        pass
    elif x == y:
        ans += 2
    elif y == z:
        ans += 1
    return ans

A,B,C = [int(i) for i in input().split()]
print(c_same_integers(A, B, C))

Solution (Python):
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)

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

rs = [v%2 for v in vals]

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

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

print(f(vals) + add)

Solution (Python):
num=list(map(int,input().split()))
num.sort()
a,b,c=num[0],num[1],num[2]
sum = a+b+c
if (c*3-sum)%2==0: ans = (c*3-sum)//2
else: ans = (c*3+3-sum)//2

print(ans)

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

d1 = a[2] - a[1]
d2 = a[2] - a[0]

print(d1 + (d2 - d1) // 2 + ((d2 - d1) % 2) * 2)

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