Problem:


Score : 300 points

Problem Statement

You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:

Choose two among A, B and C, then increase both by 1.

Choose one among A, B and C, then increase it by 2.

It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Constraints

0 \leq A,B,C \leq 50

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B C

Output

Print the minimum number of operations required to make A, B and C all equal.

Sample Input 1

2 5 4

Sample Output 1

2

We can make A, B and C all equal by the following operations:

Increase A and C by 1. Now, A, B, C are 3, 5, 5, respectively.

Increase A by 2. Now, A, B, C are 5, 5, 5, respectively.

Sample Input 2

2 6 3

Sample Output 2

5

Sample Input 3

31 41 5

Sample Output 3

23



Sample input:
2 5 4


Sample output:
2

Submission status: Accepted

Solution code:
a = sorted(list(map(int, input().split())))
ans = 0
while a[2] - a[0] > 0 and a[2] - a[1] > 0:
    a[0] += 1
    a[1] += 1
    ans += 1
if (a[2] - min(a[0],a[1])) & 1:
    ans += -((-(a[2] - min(a[0], a[1])) // 2)) + 1
else:
    ans += (a[2] - min(a[0], a[1])) // 2
print(ans)

Submission status: Accepted

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

M3 = 3 * M

if sum([A, B, C]) % 2 == M3 % 2:
    flg = True
    moku = M
else:
    flg = False
    moku = M+1

mokusum = moku * 3
print((mokusum - sum([A, B, C])) // 2)

Submission status: Accepted

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

ans = 50 * 10

for i in range(-100, 101):
  if a > i:
    ac = abs(a - i)
  else:
    ac = (abs(a - i) - 1) // 2 + 1 + abs(a - i) % 2 

  if b > i:
    bc = abs(b - i)
  else:
    bc = (abs(b - i) - 1) // 2 + 1 + abs(b - i) % 2 
    
  if c > i:
    cc = abs(c - i)
  else:
    cc = (abs(c - i) - 1) // 2 + 1 + abs(c - i) % 2 

  ans = min(ans, ac + bc + cc)
  
print(ans)

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
max_value = max(a, b, c)
l = []
d = [a, b, c]
ans = 0
for i in d:
    if max_value-i != 0:
        l.append(max_value-i)
if len(l) == 0:
    print(ans)
    exit()
if len(l) == 1:
    if l[0] % 2 == 0:
        ans = l[0]//2
        print(ans)
        exit()
    else:
        ans = l[0]//2 + 2
        print(ans)
        exit()
if len(l) == 2:
    if sum(l) % 2 == 0:
        print(sum(l)//2)
        exit()
    if sum(l) % 2 == 1:
        print(sum(l)//2+2)
        exit()

Submission status: Accepted

Solution code:

def resolve():
    L=list(map(int,input().split()))
    LL=[0]*len(L)
    for i in range(len(L)):
        LL[i]=L[i]%2
    val=0
    if sum(LL)==0 or sum(LL)==3:
        for i in range(len(L)):
            val+=max(L)-L[i]
        val//=2
    elif sum(LL)==1:
        for i in range(len(LL)):
            if LL[i] == 0:
                L[i]+=1
        for i in range(len(L)):
            val += max(L) - L[i]
        val//=2
        val+=1
    else:
        for i in range(len(LL)):
            if LL[i] == 1:
                L[i]+=1
        for i in range(len(L)):
            val += max(L) - L[i]
        val//=2
        val+=1


    print(val)


resolve()

Submission status: Accepted

Solution code:
def main():
    num = list(map(int, input().split()))
    max_num = max(num)
    answer = 0
    for i in range(3):
        answer += (max_num - num[i]) // 2
        num[i] += ((max_num - num[i]) // 2) * 2
    num.sort()
    if num[0] == num[1] and num[1] != num[2]:
        answer += 1
    elif num[1] == num[0] + 1:
        answer += 2
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

A, B, C = sorted((A, B, C))
ans = 0

if sum([C % 2 == a % 2 for a in (A, B, C)]) == 2:
    ans += 1
    if A % 2 == C % 2:
        A += 1
    else:
        B += 1
    C += 1

ans += sum([C - a for a in (A, B, C)]) // 2
print(ans)

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
l = [a, b, c]
l.sort()
ans = l[2]-l[1]
l_ = [l[0]+ l[2]-l[1], l[2], l[2]]

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

print(ans)

Submission status: Accepted

Solution code:
a,b,c=map(int, input().split())
mx=max((a,b,c))
sm=sum((a,b,c))
d=mx*3-sm
print((d+3)//2 if d&1 else d//2)

Submission status: Accepted

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

sum = (a+b+c)

if a == b == c:
    print(0)
    exit()
else:
    for i in range(max(a,b,c)*3, 200, 3):
        if (i - sum) % 2 == 0:
            print((i - sum)//2)
            exit()

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

a = [int(x) for x in input().split()]

a.sort()

a, b, c = a

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

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

print(ans)

Submission status: Accepted

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

odd = len([a for a in A if a % 2 == 1])
even = 3 - odd

ans = 0
if odd == 3 or even == 3:
    pass
elif odd == 1:
    A = [a + 1 if (a % 2 == 0) else a for a in A]
    ans += 1
elif even == 1:
    A = [a + 1 if (a % 2 == 1) else a for a in A]
    ans += 1

MAXA = max(A)
for a in A:
    ans += (MAXA - a) // 2

print(ans)

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

a = LIST()
ans = 0
a.sort()
m = a[-1]
d = 0
if 3 * m % 2 == sum(a) % 2:
    d = m
else:
    d = m + 1
ans = 0
while not a[0] == a[1] == a[2]:
    if a[0] < d and a[1] < d:
        ans += 1
        a[0] += 1
        a[1] += 1
    elif a[0] < m:
        ans += 1
        a[0] += 2
    else:
        ans += 1
        a[1] += 2
    if a[0] > d or a[1] > d:
        break
    debug(a)
print(ans)

Submission status: Accepted

Solution code:
A=list(map(int,input().split()))
ans=int(0)
m=max(A)
for i in range(3):
    now=int((m-A[i])/2)
    ans+=now
    A[i]+=2*now

check=int(0)
for i in range(3):
    check+=m-A[i]
if check==0:
    print(ans)
elif check==2:
    print(ans+1)
else:
    print(ans+2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    L = [int(i) for i in input().split()]
    L.sort()
    odd, even = 0, 0
    for l in L:
        if l % 2 == 0: even += 1
        else: odd += 1
    count = 0
    if even == 3 or odd == 3: count = 0
    elif even == 2:
        count += 1
        for i in range(3):
            if L[i] % 2 == 0: L[i] += 1
    elif odd == 2:
        count += 1
        for i in range(3):
            if L[i] % 2 == 1: L[i] += 1
    count += (L[2] - L[0]) // 2 + (L[2] - L[1]) // 2
    print(count)

    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:

def main():
    a = list(map(int, input().split()))

    ans = 0
    while True:
        a.sort()
        if a[0] == a[1] and a[1] == a[2]:
            break
        elif a[1] < a[2]:
            a[0] += 1
            a[1] += 1
        else:
            a[0] += 2
        ans += 1

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A = sorted(list(map(int, input().split())))
d = 2*A[-1]-A[0]-A[1]
print(d//2) if d%2 == 0 else print(d//2+2)

Submission status: Accepted

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

abc.sort()
ans = 0

while True:
    if abc[0] == abc[1] and abc[1] == abc[2]:
        print(ans)
        break

    if abc[1] != abc[2]:
        abc[0] += 1
        abc[1] += 1
        ans += 1
    elif abc[1] == abc[2] and abc[1] + 1 == abc[0]:
        abc[1] += 1
        abc[2] += 1
        ans += 1
    else:
        abc[0] += 2
        ans += 1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
abc=list(map(int,input().split()))
abc.sort()
ans=0

while 1:
    if abc[0]==abc[1]==abc[2]:
        print(ans)
        exit()

        
    if abc[1]!=abc[2]:
        abc[0]+=1
        abc[1]+=1
        ans+=1
    elif abc[1]==abc[2] and abc[1]+1==abc[0]:
        abc[1]+=1
        abc[2]+=1
        ans+=1
    else:
        abc[0]+=2
        ans+=1

Submission status: Accepted

Solution code:
abc = sorted(list(map(int, input().split())))
res = 0
res += abc[2] - abc[1]
diff = abc[2] - (abc[0] + (abc[2] - abc[1]))
res += diff // 2
if diff % 2 != 0:
    res += 2
print(res)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
# int(input()) # 入力が1つ
a, b, c = map(int, input().split()) # 入力が複数
nums = sorted([a, b, c])

ans = 0
if (nums[1] - nums[0]) % 2 != 0:
    nums[2] += 1
    nums[1] += 1
    ans += 1
ans += (nums[1] - nums[0]) // 2
ans += nums[2] - nums[1]
print(ans)

Submission status: Accepted

Solution code:
n_list = list(map(int,input().split()))
n_list.sort()
num = 2 * n_list[2]
dummy = num - (n_list[0] + n_list[1])
#print(dummy)
a,b = divmod(dummy,2)
if b == 0:
  print(a)
else:
  print(a+2)

Submission status: Accepted

Solution code:

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

abc.sort()
def calc(a, b):
    if (a + b) % 2 == 0:
        return (b - a) // 2
    else:
        return -(-(b - a) // 2) + 1


print(calc(abc[0], abc[1]) + (abc[2] - abc[1]))

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
p=a%2!=b%2 or b%2!=c%2
a,b,c=[a+((a%2==b%2)^(a%2==c%2)),b+((b%2==a%2)^(b%2==c%2)),c+((c%2==a%2)^(c%2==b%2))]
a,b,c=sorted([a,b,c])
print((c-a)//2+(c-b)//2+p)

Submission status: Accepted

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

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

print(int(ans))

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
if a%2==b%2 and b%2==c%2:
    a,b,c=sorted([a,b,c])
    ans=(c-a)//2+(c-b)//2
else:
    ax=a+(a%2==b%2 or a%2==c%2)
    bx=b+(b%2==a%2 or b%2==c%2)
    cx=c+(c%2==a%2 or c%2==b%2)
    a,b,c=sorted([ax,bx,cx])
    ans=(c-a)//2+(c-b)//2+1
print(ans)

Submission status: Accepted

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

if max(ABC)%2==sum(ABC)%2:
  print((3*max(ABC)-sum(ABC))//2)
else:
  print((3*(max(ABC)+1)-sum(ABC))//2)

Submission status: Accepted

Solution code:
import numpy as np

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

num = np.array(num)

ans = 0
for i in range(51):
    num = np.sort(num)
    if num[1] == num[2]:
        break

    else:
        num[0]+=1
        num[1]+=1
        ans+=1

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


if (num[1] - num[0])%2 == 0:
    print(ans)
else:
    print(ans+2)

Submission status: Accepted

Solution code:
nums = sorted(list(map(int,input().split())))
x = min(nums)
y = nums[1]
z = max(nums)
gap1 = z - y
gap2 = z - x - gap1
answer = 0
if gap2 % 2 == 0:
  answer = gap1 + gap2//2
else:
  answer = gap1 + gap2//2 + 2
print(answer)

Submission status: Accepted

Solution code:
n_list = list(map(int,input().split()))
n_list.sort()
num = 2 * n_list[2]
dummy = num - (n_list[0] + n_list[1])
a,b = divmod(dummy,2)
if b == 0:
  print(a)
else:
  print(a+2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

a = na()
m = max(a)
b = [abs(i - m) for i in a]
print(sum(b) // 2 + sum(b) % 2 * 2)

Submission status: Accepted

Solution code:
def solve():
    ABC = list(sorted(map(int, input().split())))

    # 最初にプラス1で近づける
    A, B, C = ABC[0], ABC[1], ABC[2]

    a, amod = divmod((C-A),2)
    b, bmod = divmod((C-B),2)
    A += a * 2
    B += b * 2

    if C == A and C == B:
        return a + b
    elif C > A and C > B:
        return a + b + 1
    elif C > A and C == B:
        return a + b + 2
    elif C > B and C == A :
        return a + b + 2

def main():
    print(solve())

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
d = (a % 2) + (b % 2) + (c % 2)
m = max(a, b, c)
s = a + b + c
ans1 = (3 * m - s) // 2
ans2 = (3 * (m + 1) - s) // 2
if d == 0 or d == 3:
    ans = ans1
elif d == 1:
    if m % 2 == 1:
        ans = ans1
    else:
        ans = ans2
else:
    if m % 2 == 0:
        ans = ans1
    else:
        ans = ans2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
M=max(A,B,C)
abc=sorted([M-A, M-B, M-C], reverse=True)[:2]
#print(abc)

if sum(abc)%2==0:
    print(sum(abc)//2)
else:
    print(sum(abc)//2+2)

Submission status: Accepted

Solution code:
import sys

# import bisect
# from collections import Counter, deque, defaultdict
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter

# import math

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, c = list(map(int,readline().split()))

    ans = 0

    ap = a % 2
    bp = b % 2
    cp = c % 2

    if not(ap == bp == cp):
        ans += 1
        if ap == bp:
            a += 1
            b += 1
        elif bp == cp:
            b += 1
            c += 1
        else:
            c += 1
            a += 1

    ans += ((max(a, b, c) * 3) - (a + b + c)) // 2
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a=sorted(list(map(int, input().split())))
b=0
while(True):
    if a[0]==a[1] and a[1]==a[2]:
        print(b)
        exit()
    elif a[0]==a[1]:
        a[0]+=1
        a[1]+=1
    else:
        a[0]+=2
    b+=1
    a=sorted(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
l=[]
l.append(a)
l.append(b)
l.append(c)
l.sort()
ans=0
if (3*l[2])%2==(sum(l))%2:
    print((3*l[2]-sum(l))//2)
else:
    print((3*(l[2]+1)-sum(l))//2)
'''
while max(l[0],l[1])<l[2]:
    l[0]+=1
    l[1]+=1
    ans+=1
if (l[2]-l[0])%2==0:
    ans+=(l[2]-l[0])//2
    print(ans)
else:
    print(ans+2)
'''

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

a, b, c = map(int, input().split())
sum_abc = a + b + c
    
flag = True
cnt = 0
while flag:
    if sum_abc//3 >= max(a, b, c):
        break
    else:
        sum_abc += 2
        cnt += 1


if (abs(3*max(a,b,c) - sum_abc)%2 == 1):
    cnt += 1

print("{}".format(cnt))

Submission status: Accepted

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

import numpy as np
ABC = np.array([A, B, C])
#min_ = min(ABC)
cnt = 0

while True:
    #min_ = min(ABC)
    if np.sum(ABC == np.min(ABC)) == 3:#ABC.count(min_) == 3:
        print(cnt)
        break
    elif np.sum(ABC == np.min(ABC)) == 2:
        index = np.where(ABC == min(ABC))
        ABC[index] += 1
        cnt += 1
    else: #ABC.count(min_) == 1:
        ABC[np.argmin(ABC)] += 2
        cnt += 1

Submission status: Accepted

Solution code:
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():

    L=list(map(int,input().split()))
    l=[0,0,0]

    for i in range(3):
        if L[i]%2!=0:
            l[i]=1
    cnt=0
    if l.count(0)==2:
        index_num = [n for n, v in enumerate(l) if v %2==0]
        for j in index_num:
            L[j]+=1
        cnt+=1
    elif l.count(0)==1:
        index_num = [n for n, v in enumerate(l) if v %2==1]
        for j in index_num:
            L[j]+=1
        cnt+=1

    L.sort()
    print(cnt+(L[-1]-L[0])//2+(L[-1]-L[1])//2)



resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,C=map(int,input().split())
ans = 1
if (A%2 != B%2) and (A%2 == C%2):
  A += 1
  C += 1
elif (A%2 == B%2) and (A%2 != C%2):
  A += 1
  B += 1
elif (A%2 != B%2) and (B%2 == C%2):
  C += 1
  B += 1
else:
  ans = 0
L = [A,B,C]
L.sort()
ans += (L[2]-L[1])//2 + (L[2]-L[0])//2
print( ans )

Submission status: Accepted

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

ans = vec[2]-vec[1]
vec[0] += ans
vec[1] += ans

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0

while True:
    n.sort()
    a, b, c = n[0], n[1], n[2]
    if a == b == c:
        break
    if a + 2 <= c:
        a += 2
    else:
        a += 1
        b += 1
    cnt += 1
    n[0], n[1], n[2] = a, b, c
print(cnt)

Submission status: Accepted

Solution code:
A,B,C=sorted(list(map(int,input().split(' '))))
if (C-A)%2==(C-B)%2:
    print(C-(A+B)//2)
else:
    print(C-(A+B)//2+1)

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

maxi=max(A,B,C)
mini=min(A,B,C)
midi=(A+B+C)-maxi-mini
s = (maxi-midi)+(maxi-mini)

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

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
x=max(a,b,c)
z=min(a,b,c)
y=a+b+c-x-z
print((x-y)+(y-z)//2+(y-z)%2*2)

Submission status: Accepted

Solution code:
a = sorted(list(map(int, input().split())))
ans = 0
max_mid = a[2] - a[1]
ans += max_mid
a[0] += max_mid

div, mod = divmod(a[2]-a[0], 2)
if mod == 1:
    mod += 1
print(ans + div + mod)

Submission status: Accepted

Solution code:
import sys
a,b,c = map(int, input().split())
if a == b and b == c:
    count=0
    print(count)
    sys.exit()
    
ls = [a,b,c]
ls.sort(reverse=True)
count = 0

if (ls[1]-ls[2])%2 != 0:
    ls[2] = ls[2]+1
    ls[0] = ls[0]+1
    count +=1

while ls[1] - ls[2] >= 2:
    ls[2] += 2
    count += 1

if ls[1] - ls[2] == 1:
    ls[2] += 1
    count +=1

dif = ls[0] - ls[1]
count = count + dif

print(count)

Submission status: Accepted

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

x=ma-(a+b+c-ma-mi)
y=(ma-x-mi)%2
z=((ma+y)-(x+mi))//2
print(x+y+z)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    ABC = list(map(int, input().split()))
    ABC.sort()
    if (ABC[-1] * 3 - sum(ABC)) % 2 == 0:
        print((ABC[-1] * 3 - sum(ABC)) // 2)
    else:
        print(((ABC[-1] + 1) * 3 - sum(ABC)) // 2)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
a,b,c=sorted(map(int,input().split()))
x=0
loopcounter=0
while a!=b or b!=c or c!=a:
    if a+1<=c and b+1<=c:
        a+=1
        b+=1
        x+=1
    elif a+2<=c:
        a+=2
        x+=1
    elif b+2<=c:
        b+=2
        x+=1       
    elif a!=b and b==c:
        a+=2
        b+=1
        c+=1
        x+=2
    if loopcounter>100000:
        break
    loopcounter+=1
print(x)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def Same_Integers(abc):

    ans = 0
    abc.sort()
    count = abc[2]*3 - abc[0] - abc[1] - abc[2]

    if count % 2 == 0:
        ans = int(count / 2)
    else:
        ans = int((count + 3) // 2)

    return ans

def main():
    abc = list(map(int , input().split()))
    print(Same_Integers(abc))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

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

a,b,c = na()
d = max(a,b,c)*3-(a+b+c)
e = d//2 if d%2==0 else (d+3)//2

print(e)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = list(map(int, input().split()))
p = max(X)
q = sum(X)
if (3 * p) % 2 != q % 2:
    p += 1

print(((3 * p) - q) // 2)

Submission status: Accepted

Solution code:
X = list(map(int, input().split()))
X.sort()
A, B, C = X
a, b, c = [x % 2 for x in X]

cnt = 0
if a == b:
    ope1 = C - B
    cnt += ope1
    B += ope1
    A += ope1
    cnt += (C - A) // 2
else:
    if c == a:
        C += 1
        A += 1
        cnt += 1

        cnt += (C - B) // 2
        cnt += (C - A) // 2
    else:
        C += 1
        B += 1
        cnt += 1

        cnt += (C - B) // 2
        cnt += (C - A) // 2

print(cnt)

Submission status: Accepted

Solution code:
a,b,c = map(int,input().split())
abc = sorted([a,b,c])
plus = abc[-1]-abc[-2]+abc[-1]-abc[-3]
if plus % 2 == 0:
  print(plus // 2)
else:
  print(plus // 2 +2)

Submission status: Accepted

Solution code:
data = input().split()
tab = [int(data[0]), int(data[1]),int(data[2])]
tab = sorted(tab)
a, b, c = tab[0], tab[1], tab[2]
res = 0
res += c - b
a += res
b += res

while (a < b):
    res += 1
    a += 2

if (a > b):
    print( res+1)
else:
    print(res)

Submission status: Accepted

Solution code:
import math
def mid(a,b,c):
  if (a<=b and b<=c) or (c<=b and b<=a): # a<b<c or c<b<a
    return b
  elif (b<=a and a<=c) or (c<=a and a<=b): # b<a<c or c<a<b
    return a
  elif (a<=c and c<=b) or (b<=c and c<=a): # b<c<a or a<c<b
    return c
A,B,C = map(int,input().split())
middle = mid(A,B,C)
minimum = min(A,B,C)
m = max(A,B,C)
ans = m - middle
minimum += max(A,B,C) - middle
if (m - minimum)%2==0:
  ans += (m - minimum)//2
else:
  ans += math.ceil((m - minimum)/2)+1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
A,B,C=map(int,input().split())
s=[A,B,C]
t=sorted(s)
u=(t[2]-t[0],t[2]-t[1],0)
if u[0]%2==0 and u[1]%2==0:
    print(round(((u[0]+u[1])/2)))
elif u[0]%2==1 and u[1]%2==1:
    print(round((1+u[0]//2+u[1]//2)))
elif u[0]%2==1 and u[1]%2==0:
    print(round(((u[0]+1)/2+u[1]/2+1)))
else:
    print(round(((u[1]+1)/2+u[0]/2+1)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
li = [int(x) for x in input().split()]
li.sort()
tmp = li[2] * 3
buf = sum(li)

if buf%2 != tmp%2:
    ans = ((li[2] + 1) * 3 - buf) //2
else:
    ans = (li[2] * 3 - buf) // 2

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

num_delta = (nums[2] - nums[1]) + (nums[2] - nums[0])
if num_delta % 2 == 0:
    print(num_delta//2)
else:
    print((num_delta+3)//2)

Submission status: Accepted

Solution code:
import numpy as np

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

def calculate(a, b, c):

    arr = np.array([a,b,c])

    maxIndex = np.argmax(arr)
    maxValue = arr[maxIndex]

    sl = []
    for index,ar in enumerate(arr):
        if index == maxIndex:
            continue
        sl.append(maxValue - ar)

    if np.sum(sl) % 2 == 1:
        maxValue = maxValue + 1


    brr = np.array([maxValue-a,maxValue-b,maxValue-c])

    s = brr % 2
    print(np.sum(brr//2) + np.sum(s % 2) // 2)

calculate(A, B, C)

Submission status: Accepted

Solution code:
a = [int(i) for i in input().split()]
a.sort()
dif = [a[2] - a[0], a[2] - a[1]]
s = sum(dif)
if s % 2 == 0: print(s // 2)
else: print((s + 3) // 2)

Submission status: Accepted

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

s = 0
if len(set(a)) == 1 :
  print(0)
elif a[0] == a[1]:
  print(a[2] -a[1])
else :
  if a[0]+1<a[1]:
    s +=(a[1]-a[0])//2
    a[0] = 2*s+a[0]
    if a[0] == a[1]:
      s+= a[2] -a[1]
    else :
      s+= a[2]-a[1] +2
  else :
      s+= a[2]-a[1] +2
  print(s)

Submission status: Accepted

Solution code:
# coding:utf-8
import sys 
def main():
    input_list = list(map(int, input().split()))
    input_list.sort(reverse=True)
    
    diff = input_list[0] - input_list[1] + input_list[0] - input_list[2]
    ans = diff /2
    if diff % 2 == True:
        ans += 2

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

Submission status: Accepted

Solution code:
#pypyは内包表記使わない
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    l = list(map(int, input().split()))
    l.sort()
    total = l[2]*2 - l[0] - l[1]
    if total % 2:
        print((total-1)//2+2)
    else:
        print(total//2)
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#abc093 c
a,b,c=map(int,input().split())
X=max(a,b,c)
if X%2^(a+b+c)%2:
    X+=1
ans=int((3*X-(a+b+c))/2)
print(ans)

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
S = A + B + C
M = max(A, B, C)
if S%2 != M%2:
  M = M + 1
print((3*M-S)//2)

Submission status: Accepted

Solution code:
l=list(map(int,input().split()))
cnt=0
while True:
    l=sorted(l)
    if l[0]==l[1]==l[2]:break
    if l[0]==l[1]:
        l[0]+=1
        l[1]+=1
    else:l[0]+=2
    cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
abc = list(map(int, input().split()))
abc.sort()
max_n = abc[2]
mid_n = abc[1]
min_n = abc[0]

cnt = max_n - mid_n
if (max_n - min_n - cnt)%2 == 1:
    cnt += (max_n - min_n - cnt)//2 + 2
else:
    cnt += (max_n - min_n - cnt)//2
print(cnt)