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):
L = list(map(int, input().split()))
odd = L[0] % 2 + L[1] % 2 + L[2] % 2
if odd == 0 or odd == 3:
    ans = (max(L) * 3 - sum(L)) // 2
elif odd == 1:
    if max(L) % 2 == 1:
        ans = (max(L) * 3 - (sum(L) + 2)) // 2 + 1
    else:
        ans = ((max(L) + 1) * 3 - (sum(L) + 2)) // 2 + 1
else:
    if max(L) % 2 == 0:
        ans = (max(L) * 3 - (sum(L) + 2)) // 2 + 1
    else:
        ans = ((max(L) + 1) * 3 - (sum(L) + 2)) // 2 + 1
print(ans)

Solution (Python):
a,b,c = map(int,input().split())
m1 = max(a,b,c)
m3 = min(a,b,c)
m2 = a+b+c-m1-m3
m = m2-m3
n = m1-m2
if m%2 == 0:
  print((m+2*n)//2)
else:
  print((m+2*n+3)//2)

Solution (Python):
def resolve():
	seq = list(map(int, input().split()))
	m = max(seq)
	if (3*m - sum(seq)) % 2 == 0:
		print((3*m - sum(seq))//2)
	else:
		print((3*(m+1) - (sum(seq)+2))//2 + 1)
resolve()

Solution (Python):
a = list(map(int,input().split()))
count = 0
while max(a)-min(a) >= 2:
    count += (max(a)-min(a))//2
    a =sorted(a)
    if (a[-1]-a[0])%2 == 0:
        a[0] = a[-1]
    else:
        a[0] = a[-1] - 1
while max(a)!=min(a):
    a =sorted(a)
    a[0] += 1
    a[1] += 1
    count += 1
print(count)

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

m = max(A, B, C)
div_a, mod_a = divmod((m - A), 2)
div_b, mod_b = divmod((m - B), 2)
div_c, mod_c = divmod((m - C), 2)

count = sum((div_a, div_b, div_c))
mod = sum((mod_a, mod_b, mod_c))

if mod == 1:
    count += 2
elif mod == 2:
    count += 1

print(count)

Solution (Python):

import re
import math
from collections import defaultdict
from collections import deque
import itertools
from copy import deepcopy
import random
import time
import os
import queue
import sys
import datetime
from functools import lru_cache

readline=sys.stdin.readline
sys.setrecursionlimit(2000000)

alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_pow(a,b):
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def get_facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:return num
def get_primes(n,type="int"):
    if n==0:
        if type=="int":return []
        else:return [False]
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=1):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=""):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def floor_(n,x=1):
    return x*(n//x)
def ceil_(n,x=1):
    return x*((n+x-1)//x)
    return ret
def seifu(x):
    return x//abs(x)

def main():
    A,B,C=map(int,input().split())
    mmax=max([A,B,C])
    ssum=A+B+C
    n=mmax*3-ssum
    if n%2==1:
        mmax+=1
    print((mmax*3-ssum)//2)
main()

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

Solution (Python):
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): 
		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): 
		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()} 
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): 
			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 not in [0,3]:
	ans+=1
	if gu_num==1:
		if arr[0]%2==1:
			arr[1]+=1
			arr[2]+=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[2]+=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)

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

Solution (Python):
import sys


def input(): return sys.stdin.readline().strip()


def resolve():
    l = list(map(int, input().split()))
    l.sort(reverse=True)
    x=(l[0]-l[1])+(l[0]-l[2])
    if x%2==0:
        print(x//2)
    else:
        print(x//2+2)
resolve()

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

Solution (Python):
A= list(map(int,input().split()))
B=len([i for i in A if i%2==1])
ans=0
if B==1 or B==2:
    if B==1:
        A=[i+1 if i%2==0 else i for i in A]
    else:
        A=[i+1 if i%2==1 else i for i in A]
    A.sort(reverse=True)
    maximum=A[0]
    ans+=1+(maximum-A[1])//2+(maximum-A[2])//2
    print(ans)
elif B== 3 or B==0:
    A.sort(reverse=True)
    maximum=A[0]
    print((maximum-A[1])//2+(maximum-A[2])//2)

Solution (Python):
t = tuple(map(int,input().split()))

t = sorted(t)

op1 = (t[1]-t[0])//2+(t[1]-t[0])%2

t[2] += (t[1]-t[0])%2

op2 = t[2]-t[1]

print(op1+op2)

Solution (Python):
ABC = list(map(int, input().split()))
ans = 0

while ABC[0] != ABC[1] or ABC[1] != ABC[2] or ABC[2] != ABC[0]:
    max_ABC = ABC.index(max(ABC))
    min_ABC = ABC.index(min(ABC))

    if ABC[max_ABC] - ABC[min_ABC] > 1:
        ABC[min_ABC] += 2
        ans += 1
    else:
        ABC[min_ABC] += 1
        for i in range(3):
            if i != min_ABC and i != max_ABC:
                ABC[i] += 1
        ans += 1

print(ans)

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

Solution (Python):
from sys import stdin
def main():
    
    readline=stdin.readline
    a,b,c=map(int,readline().split())

    li=[a,b,c]
    li.sort()
    x=li[0]
    y=li[1]
    z=li[2]

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

    print(cnt)
if __name__=="__main__":
    main()

Solution (Python):
from statistics import median


from fractions import gcd
from itertools import combinations 
from collections import deque
from collections import defaultdict
import bisect










import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    a,b,c = readInts()
    d = max(a,b,c)*3 - a - b - c
    if d % 2 == 0:
        print(d//2)
    else:
        print(d//2 + 2)

if __name__ == '__main__':
  main()

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    def main():

        l = sorted(list(map(int, input().split())))
        even = 0
        for i in range(3):
            if l[i] % 2 == 0:
                even += 1
        cnt = 0
        if even == 0 or even == 3:
            for i in range(3):
                cnt += (l[2]-l[i])//2
            return cnt
        elif even == 1:
            cnt += 1
            for i in range(3):
                if l[i] % 2 == 1:
                    l[i] += 1
            for i in range(3):
                cnt += (max(l)-l[i])//2
            return cnt
        else:
            cnt += 1
            for i in range(3):
                if l[i] % 2 == 0:
                    l[i] += 1
            for i in range(3):
                cnt += (max(l)-l[i])//2
            return cnt
    print(int(main()))



resolve()

Solution (Python):
import sys

def solve():
    input = sys.stdin.readline
    L = [int(i) for i in input().split()]
    count = 0
    L.sort()
    addMin = (L[2] - L[0]) // 2  
    addMid = (L[2] - L[1]) // 2
    count = addMin + addMid
    L[0] += addMin * 2
    L[1] += addMid * 2
    if L[0] < L[2] and L[1] < L[2]: print(count + 1)
    elif L[0] == L[1] == L[2]: print(count)
    else: print(count + 2)
    

    return 0

if __name__ == "__main__":
    solve()

Solution (Python):
def main():
    num = list(map(int, input().split()))
    num.sort()
    answer = 0
    a = num[2] - num[0]
    b = num[2] - num[1]
    if a % 2 == b % 2:
        answer = a // 2 + b // 2 + a % 2
    elif a % 2 != b % 2:
        answer = a // 2 + b // 2 + 2
    print(answer)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    a, b, c = map(int, input().split())
    l = [a, b, c]
    l.sort()
    ans = 0
    ans += l[2] - l[1]
    ans += (l[1] - l[0] + 1) // 2
    if ((l[1] - l[0]) % 2 == 1):
        ans += 1

    print(ans)


main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    l=list(map(int,input().split()))
    l.sort(reverse=True)
    cnt=0
    if l[0]>l[1]:
        cnt+=l[0]-l[1]
        l[2] = l[2] + cnt
        l[1]=l[1]+cnt

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

resolve()

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

Solution (Python):
L = list(map(int, input().split()))
L = sorted(L)
A = L[0]
B = L[1]
C = L[2]
cnt = 0
while A < B-1:
    cnt += 1
    A += 2
if A == B:
    cnt += (C-A)
else:
    cnt += (C-A+1)
print(cnt)

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

p = [i%2 for i in N]

ans = 0

if sum(p) == 0 or sum(p) == 3:
    m = max(N)
    for i in N:
        ans += (m-i)//2
elif sum(p) == 1:
    for i in range(3):
        if N[i]%2 == 0:
            N[i] += 1
    ans += 1
    m = max(N)
    for j in N:
        ans += (m-j)//2
else:
    for i in range(3):
        if N[i]%2 == 1:
            N[i] += 1
    ans += 1
    m = max(N)
    for j in N:
        ans += (m-j)//2

print(ans)

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

ans=0

ans+=c-b
c+-(c-b)
a+=(c-b)

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

Solution (Python):


import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))

def resolve():
    A=list(pin())
    A.sort()
    ans=0
    x,y,z=A
    if (y-x)%2:
        y+=1
        z+=1
        ans+=1
    ans+=(y-x)//2
    x=y
    ans+=z-x
    print(ans)
    
            

resolve()

Solution (Python):
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right


from functools import reduce
from pprint import pprint

INF = float("inf")

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

a,b,c = myinput()
l = [a,b,c]
M = max(l)
g = M*3
sa = g - sum(l)

if sa%2==0:
    ans = sa//2
else:
    g = (M+1)*3
    ans = (g-sum(l))//2
    
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline

a = [int(x) for x in input().split()]
cnt = 0
a.sort()
cnt += a[-1] - a[1]
a[0] += cnt
if (a[-1] - a[0]) % 2 == 1:
    cnt += 1
    a[-1] += 1
cnt += (a[-1] - a[0]) // 2
print(cnt)

Solution (Python):
def resolve():
  a = list(map(int, input().split()))
  a.sort()
  ans = 0
  ans += a[2] - a[1]
  a[1] = a[2]
  a[0] += ans
  ans += (a[2] - a[0]) // 2
  a[0] += ((a[2] - a[0]) // 2) * 2
  if a[0] != a[2]:
    ans += 2
  print(ans)

  return

if __name__ == "__main__":
  resolve()

Solution (Python):
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math
 
a,b,c = map(int,input().split())
li = [a,b,c]
li.sort()
cnt = 0
while li[2] != li[1]:
    li[0] += 1
    li[1] += 1
    cnt+=1
cnt += (li[1]-li[0])//2
if (li[1]-li[0])%2 != 0:
    cnt += 2
print(cnt)

Solution (Python):
import sys
input = sys.stdin.readline
from collections import *

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

if M%2==(A+B+C)%2:
    print((3*M-A-B-C)//2)
else:
    print((3*(M+1)-A-B-C)//2)

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

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

ans = 0

d1 = (c - a) // 2
ans += d1
a += d1 * 2

d2 = (c - b) // 2
ans += d2
b += d2 * 2

a, b, c = sorted([a, b, c])
if a == b and b < c:
    ans += 1
elif a < b and b == c:
    ans += 2
print(ans)

Solution (Python):
def main():
    A = [int(i) for i in input().split()]
    A.sort()
    B = [A[2] - A[0], A[2] - A[1]]
    ans = 0
    if B[0] % 2 == B[1] % 2:
        ans = (B[0]+B[1])//2
    else:
        ans = 0--(B[0]+B[1])//2 + 1
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
a, b, c = map(int, input().split())
abc = [a, b, c]
abc.sort()
sho, chu, dai = abc[0], abc[1], abc[2]

huyasu = dai-chu + dai-sho
if huyasu % 2 == 1:
    huyasu += 3
print(huyasu//2)

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

ABC = list(map(int, input().split()))
ABC.sort()

tmp = ABC[2] - ABC[1]
ans = tmp
ABC[0] += tmp

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

print (ans)

Solution (Python):
a,b,c=map(int,input().split())
s=max(a,b,c)*3-a-b-c
if s&1:s+=3
print(s//2)

Solution (Python):
sorted_list = list(map(int, input().strip().split()))

count = 0
while True:
    sorted_list = sorted(sorted_list, reverse=True)
    if sorted_list[0] == sorted_list[1] and sorted_list[1] == sorted_list[2]:
        break

    count += 1
    if sorted_list[0] > sorted_list[1]:
        sorted_list[1] += 1
        sorted_list[2] += 1
    else:
        sorted_list[2] += 2


print(count)

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

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    l=list(map(int,input().split()))
    m=max(l)
    for i in range(3):
        l[i]-=m
    ans=0
    for i in range(3):
        ans+=l[i]//(-2)
        l[i]+=l[i]//(-2)*2
    if sum(l)==-2:
        ans+=1
    elif sum(l)==-1:
        ans+=2
    print(ans)

if __name__ == '__main__':
    main()

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

Solution (Python):
def main():
    A,B,C=map(int,input().split())
    M=max(A,B,C)
    A,B,C=M-A,M-B,M-C
    S=sum([A,B,C])
    if S%2==0:
        print(S//2)
    else:
        print(S//2 + 2)

main()

Solution (Python):
X = list(map(int, input().split()))
midle = sum(X)-min(X)-max(X)
dif_1 = max(X)-midle
new_min = min(X)+dif_1
dif_2 = max(X)-new_min
if dif_2%2 == 0:
    print(dif_1+dif_2//2)
else:
    print(dif_1+(dif_2//2)+2)

Solution (Python):
l = list(map(int, input().split()))
ref = max(l)*3 - sum(l) 

if ref%2 == 0:
    ans = ref//2
else:
    ans = ref//2 + 2

print(ans)

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

ABC.sort()

sum = ABC[2]-ABC[0]+ABC[2]-ABC[1]

result=0

if sum%2==0:
    result = sum/2
else:
    result = sum/2+2

print(int(result))

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

Solution (Python):
a=list(map(int,input().split()))
cnt=0
ans=0
for i in range(3):
    if a[i]%2!=0:
        cnt+=1
if cnt==1:
    for i in range(3):
        if a[i] % 2 == 0:
            a[i] += 1
    ans+=1
elif cnt==2:
    for i in range(3):
        if a[i] % 2 != 0:
            a[i] += 1
    ans+=1
a.sort()
ans+=(a[2]-a[0])//2+(a[2]-a[1])//2
print(ans)

Solution (Python):
A, B, C = map(int, input().split())
l = [A, B, C]
l = sorted(l)
d1 = l[1] - l[0]
d2 = l[2] - l[1]

if d1 % 2 == 0:
    print(d1//2 + d2)
else:
    print((d1-1)//2 + d2 + 2)

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

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

ans=d2
if d1%2==0:
    ans+=d1//2
else:
    ans+=(d1+1)//2+1
print(ans)

Solution (Python):
import sys
import math

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

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

d=max(a,b,c)*3
e=a+b+c

if d%2 == e%2:
    print((d-e)//2)
else:
    print((d+3-e)//2)

Solution (Python):
abc = list(map(int, input().split()))
is_even = [0] * 3
ans = 0
for i in range(3):
    is_even[i] = True if abc[i] % 2 == 0 else False
if is_even.count(True) == 1:
    for i in range(3):
        if not is_even[i]:
            abc[i] += 1
    ans += 1
if is_even.count(True) == 2:
    for i in range(3):
        if is_even[i]:
            abc[i] += 1
    ans += 1
abc.sort()
ans += (abc[2] - abc[1]) // 2
ans += (abc[2] - abc[0]) // 2
print(ans)

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

Solution (Python):
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    A,B,C = list(map(int,_in[0].split(' ')))  
    
    cnt = 0
    if [A%2,B%2,C%2] in [[0,0,0],[1,1,1]]:
        pass
    else:
        if [A%2,B%2,C%2] in [[0,1,1],[1,0,0]]:
            B+=1
            C+=1
        elif [A%2,B%2,C%2] in [[1,0,1],[0,1,0]]:
            A+=1
            C+=1
        elif [A%2,B%2,C%2] in [[1,1,0],[0,0,1]]:
            A+=1
            B+=1
        cnt += 1
    arr = sorted([A,B,C])
    cnt += abs(arr[2]-arr[0])//2
    cnt += abs(arr[2]-arr[1])//2
    
    print(cnt)

Solution (Python):
s = list(map(int,input().split()))
ans = 0

if s[0]%2 == 0:
    if s[1]%2 == 0:
        if s[2]%2 == 1:
            s[0] += 1
            s[1] += 1
            ans += 1
    else:
        if s[2]%2 == 0:
            s[0] += 1
            s[2] += 1
            ans += 1
        else:
            s[1] += 1
            s[2] += 1
            ans += 1
else:
    if s[1]%2 == 0:
        if s[2]%2 == 0:
            s[1] += 1
            s[2] += 1
            ans += 1
        else:
            s[0] += 1
            s[2] += 1
            ans += 1
    else:
        if s[2]%2 == 0:
            s[0] += 1
            s[1] += 1
            ans += 1

ms = max(s)
for i in range(3):
    ans += (ms-s[i])//2

print(ans)

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

Solution (Python):
def main():
    *a, = map(int, input().split())
    f = max(a) % 2 == 0
    g = sum(a) % 2 == 0
    if f == g:
        m = max(a)
    else:
        m = max(a) + 1

    ans = (3 * m - sum(a)) // 2
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
l=list(map(int, input().split()))
l.sort()
cnt=0
while l[0]!=l[1] or l[0]!=l[2] or l[1]!=l[2]:
    l.sort()
    
    if l[1] == l[2]:
        l[0] += 2
    else:
        l[0] += 1
        l[1] += 1
    cnt+=1

print(cnt)

Solution (Python):
a, b, c = map(int, input().split())
diff_max = 3*max(a, b, c) - sum([a, b, c])
if diff_max % 2:
    print((diff_max + 3) // 2)
else:
    print(diff_max // 2)

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

Solution (Python):



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

num_li = sorted([a,b,c])
gap1 = num_li[1]-num_li[0]
gap2 = num_li[2]-num_li[1]
ans = (gap1+1)//2+gap1%2+gap2
print(ans)

Solution (Python):
a,b,c = map(int,input().split())
s = -(a+b+c) + 3 * max(a,b,c)
ans = s//2 + s%2 * 2
print(ans)

Solution (Python):
nlist=list(map(int,input().split()))
count=0
while max(nlist)-min(nlist)!=0:
    if max(nlist)-min(nlist)>=2:
        
        minindex=nlist.index(min(nlist))
        nlist[minindex]+=2
        
        
        count+=1
        
    else:
        
        nlist.sort()
        if nlist[0]==nlist[1]:
            nlist[0]+=1
            nlist[1]+=1
            
        else:
            nlist[1]+=1
            nlist[2]+=1
            
        
        
        count+=1
        

print(count)

Solution (Python):
nums = [int(i) for i in input().split()]

nums = sorted(nums, reverse=True)
diff_2_3 = nums[1] - nums[2]

if diff_2_3 == 0:
    cnt = 0
else :
    q, r = divmod(diff_2_3, 2)
    cnt = q + r
    if r == 1:
        cnt +=1

cnt += nums[0] - nums[1]

print(cnt)

Solution (Python):
a = list(map(int, input().split()))
a.sort()
ans = 0
while a[0]+1<a[2]:
    a[0] += 2
    ans += 1
    a.sort()
if a[0]==a[1]==a[2]:
    print(ans)
elif a[0]==a[1]:
    print(ans+1)
else:
    print(ans+2)

Solution (Python):
from sys import stdin
def main():
    
    readline=stdin.readline
    a,b,c=map(int,readline().split())

    count=0
    li=[a,b,c]
    li.sort()

    count+=li[2]-li[1]
    li[0]+=li[2]-li[1]
    li[1]+=li[2]-li[1]

    count+=(li[2]-li[0])//2
    li[0]+=((li[2]-li[0])//2)*2

    if li[0]==li[2]:
        print(count)
    else:
        print(count+2)
        
if __name__=="__main__":
    main()

Solution (Python):
abc = sorted([int(x) for x in input().split()])
eo = [x%2 == 0 for x in abc]
n = eo.count(True)
cnt = 0
if n == 1:
  for i in range(3):
    if not eo[i]:
      abc[i] += 1
  cnt += 1
elif n == 2:
  for i in range(3):
    if eo[i]:
      abc[i] += 1
  cnt += 1
cnt += (abc[2]*2 - abc[0] - abc[1])//2
print(cnt)

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

m = (a+b+c)
n = max(a, max(b, c))

if m % 2 == n % 2:
  print((n*3-m)//2)
else:
  print(((n+1)*3-m)//2)

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

Solution (Python):
l=list(map(int, input().split()))
l.sort()
ans=0

if l[2]%2==l[1]%2 and l[2]%2==l[0]%2:
    ans+=(l[2]-l[1])//2 +(l[2]-l[0])//2

elif l[2]%2==0 and l[1]%2==1 and l[0]%2==1:
    l[1]+=1
    l[0]+=1
    ans+=1
    ans+=(l[2]-l[1])//2 +(l[2]-l[0])//2

elif l[2]%2==1 and l[1]%2==0 and l[0]%2==0:
    l[1]+=1
    l[0]+=1
    ans+=1
    ans+=(l[2]-l[1])//2 +(l[2]-l[0])//2

elif l[2]%2==0 and l[1]%2==1 and l[0]%2==0:
    l[2]+=1
    l[0]+=1
    ans+=1
    ans+=(l[2]-l[1])//2 +(l[2]-l[0])//2

elif l[2]%2==1 and l[1]%2==0 and l[0]%2==1:
    l[2]+=1
    l[0]+=1
    ans+=1
    ans+=(l[2]-l[1])//2 +(l[2]-l[0])//2

elif l[2]%2==1 and l[1]%2==1 and l[0]%2==0:
    l[2]+=1
    l[1]+=1
    ans+=1
    ans+=(l[2]-l[1])//2 +(l[2]-l[0])//2

elif l[2]%2==0 and l[1]%2==0 and l[0]%2==1:
    l[2]+=1
    l[1]+=1
    ans+=1
    ans+=(l[2]-l[1])//2 +(l[2]-l[0])//2



print(ans)

Solution (Python):
a, b, c = sorted(map(int, input().split()))
ans = c-b
a += ans
ans += (c-a)//2 + (c-a)%2*2
print(ans)

Solution (Python):
a, b, c = list(map(int, input().split()))
m = max(a, b, c)
if (3*m - (a+b+c)) % 2 == 1:
    m += 1
print((3*m-(a+b+c))//2)

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


ans = 0
M = max(numbers)
if 3*M%2 == sum(numbers)%2:
    
    ans += (M-numbers[0])
    ans += (M-numbers[1])
    ans += (M-numbers[2])


else:
    
    ans += (M+1-numbers[0])
    ans += (M+1-numbers[1])
    ans += (M+1-numbers[2])

print(ans//2)

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

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

print(ans)

Solution (Python):
a, b, c = list(map(int, input().split()))
count = 0
l = sorted([a, b, c])
dif = l[2]-l[1]
l[0] += dif
l[1] += dif
count += dif
if (l[2]-l[0]) % 2 == 0:
    count += (l[2]-l[0])//2
else:
    count += (l[2]-l[0])//2 + 2

print(count)

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

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

Solution (Python):
L=list(map(int,input().split()))
count=0
L=sorted(L)
while(1):
	if L[1]!=L[2]:
		L[0]+=1
		L[1]+=1
		count+=1
	else:
		if L[0]==L[1]:
			print(count)
			exit()
		elif L[1]-L[0]>1:
			L[0]+=2
			count+=1
		elif L[1]-L[0]==1:
			print(count+2)
			exit()

Solution (Python):
lst = list(map(int,input().split()))
lst2 = list(map(lambda x: max(lst) - x, lst))
lst2.remove(0)
if lst2[0] % 2 == lst2[1] % 2:
    print(sum(lst2) // 2)
else:
    print((sum(lst2) + 3) // 2)