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,b,c = map(int,input().split())
li = [a,b,c]
li.sort()
x = li[0]
y = li[1]
z = li[2]
count_list = []

def search(target,origin):
    tmp = 0
    if target > origin and (target-origin)%2 == 0:
        tmp += (target-origin)//2
    elif target > origin and (target-origin)%2 == 1:
        tmp += (target-origin)//2 + 2
    elif origin > target:
        tmp += origin - target
    return tmp

for t in range(x,z+1):
    tmp = 0
    tmp += search(t,x)
    tmp += search(t,y)
    tmp += search(t,z)
    count_list.append(tmp)
    #print(t)

#print(count_list)
print(min(count_list))

Submission status: Accepted

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

cnt=A[2]-A[1]
a=A[0]+cnt

cnt+=(A[2]-(a))//2

if (A[2]-(a))%2==1:
    cnt+=2

print(cnt)

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 = True

a = LIST()
to = max(a)
sm = sum(a)

if (sm - to) % 2:
    to += 1
ans = 0
for i in range(3):
    ans += to - a[i]
ans //= 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 = True

a = LIST()
to = max(a)
sm = sum(a)

if to % 2 != sm % 2:
    to += 1
ans = 0
for i in range(3):
    ans += to - a[i]
ans //= 2
print(ans)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
array = [A, B, C]
count = 0
if (A % 2 == 1 and B % 2 == 0 and C % 2 == 0) or (A % 2 == 0 and B % 2 == 1 and C % 2 == 1):
    count += 1
    B += 1
    C += 1
elif (A % 2 == 0 and B % 2 == 1 and C % 2 == 0) or (A % 2 == 1 and B % 2 == 0 and C % 2 == 1):
    count += 1
    A += 1
    C += 1
elif (A % 2 == 0 and B % 2 == 0 and C % 2 == 1) or (A % 2 == 1 and B % 2 == 1 and C % 2 == 0):
    count += 1
    A += 1
    B += 1
if max(A, B, C) == A:
    count = count + (A - B) // 2 + (A - C) // 2
elif max(A, B, C) == B:
    count = count + (B - A) // 2 + (B - C) // 2
else:
    count = count + (C - A) // 2 + (C - B) // 2
print(count)

Submission status: Accepted

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

if (a[1]-a[0])%2==0:
    count+=(a[1]-a[0])//2
else:
    count+=(a[1]-a[0])//2+2

print(count)

Submission status: Accepted

Solution code:
#全然わからん
a, b, c = map(int, input().split())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = sorted(list(map(int, input().split())))
c = 0
while a[1] != a[2]:
    c += 1
    a[0] += 1
    a[1] += 1
if a[0] == a[1]:
    pass
elif (a[1] - a[0]) & 1:
    c += 2 + (a[1] - a[0]) // 2
else:
    c += (a[1] - a[0]) // 2
print(c)

Submission status: Accepted

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

c = a[0] - a[1]
b = a[0] - a[2]

ans = c // 2 + b // 2
c %= 2
b %= 2

if c == 0 and b == 0:
    print(ans)
elif c == 1 and b == 1:
    print(ans + 1)
else:
    print(ans + 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

a = sorted([int(x) for x in sys.stdin.readline().split()])

def main():
    d = a[-1] * 2 - a[0] - a[1]
    if d & 1: d += 3
    print(d // 2)

if __name__ ==  '__main__':
    main()

Submission status: Accepted

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

c = max(abc)
abc.remove(c)
a = abc[0]
b = abc[1]

#%%
d_ca = c - a
d_cb = c - b
if d_ca%2 == 0 and d_cb%2 == 0:
    ans = d_ca // 2 + d_cb // 2
elif d_ca%2 == 1 and d_cb%2 == 1:
    ans = d_ca // 2 + d_cb // 2 + 1
else:
    ans = d_ca // 2 + 1 + d_cb // 2 + 1

print(ans)

Submission status: Accepted

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

if (a[1]-a[0])%2==0:
    count+=(a[1]-a[0])//2
else:
    count+=(a[1]-a[0])//2+2

print(count)

Submission status: Accepted

Solution code:
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    abc = MII()
    abc.sort()
    c = abc[2]
    a = c-abc[0]
    b = c-abc[1]
    cnt = (-(-(a-b)//2))+b
    if (a-b)%2==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)
s = (maxi - a) + (maxi - b) + (maxi - c)
if (s % 2) == 0:
  print(int(s / 2))
else:
  sd = s + 1
  print(int(sd / 2) + 1)

Submission status: Accepted

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

cnt = 0
A, B, C = sorted([A, B, C])

while A < C:
    A += 2
    cnt += 1
if (A > C):
    A -= 2
    cnt -= 1

while B < C:
    B += 2
    cnt += 1
if (B > C):
    B -= 2
    cnt -= 1

if (A == C and B == C):
    print(cnt)
elif (A == C and B != C) or (A != C and B == C):
    print(cnt + 2)
else:
    print(cnt + 1)

Submission status: Accepted

Solution code:
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    a,b,c = readInts()
    if (max(a,b,c)*3 - a - b - c) % 2 == 0:# 3 4 5  5 * 3 = 15 15 - 12 = 3
        print((max(a,b,c)*3 - a - b - c)//2)
    else:
        print(((max(a,b,c)*3 - a - b - c) //2)+2) # 3 4 5 (1+2) 
if __name__ == '__main__':
  main()

Submission status: Accepted

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

answer=0
while(A!=B or B!=C):
  if C-B>=2:
    B+=2
  elif B-A>=2:
    A+=2
  elif C-B==1 and B-A==1:
    B+=1
    C+=1
  elif C-B==0 and B-A==1:
    B+=1
    C+=1
  elif C-B==1 and B-A==0:
    A+=1
    B+=1
  answer+=1

#print(A,B,C)
print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
answer = 0
while not (a == b == c):
    a, b, c = sorted([ a, b, c ])
    if a + 2 <= c:
        a += 2
    else:
        a += 1
        b += 1
    answer += 1
print(answer)

Submission status: Accepted

Solution code:

url = "https://atcoder.jp//contests/abc093/tasks/arc094_a"

def main():
    t = list(map(int, input().split()))
    ind = t.index(max(t))
    count = 0
    for i in range(len(t)):
        if ind == i:
            continue
        while t[i] < t[ind] - 1:
            t[i] += 2
            count += 1
    tmp = set(t)
    if len(tmp) == 1:
        print(count)
    elif len(tmp) == 2:
        if t.count(max(tmp)) == 2:
            print(count + 2)
        else:
            print(count + 1)



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

def main():
    X = list(map(int, input().split()))
    if max(X) % 2 == sum(X) % 2:
        print((max(X) * 3 - sum(X))//2)
    else:
        print(((max(X)+1) * 3 - sum(X))//2)
    
    

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
def cal(n, i):
    if n-i>=0:
        return n-i
    else:
        if (i-n)%2 == 1:
            return (i-n)//2+2
        else:
            return (i-n)//2
cnt = float('inf')
for i in range(51):
    cnt = min(cnt, cal(a,i)+cal(b,i)+cal(c,i))
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

    diff = 0
    for i in range(len(A)):
        diff += max(A)-A[i]
    if diff%2 == 0:
        print(diff//2)
    else:
        print(diff//2+2)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10000)
def resolve():
    A, B, C = list(map(int, input().split(" ")))
    print(rec(A, B, C, 0))

def rec(A, B, C, cnt):
    if A == B and B == C:
        return cnt
    
    MAX, MIN = max([A, B, C]), min([A, B, C])
    MID = A + B + C - MAX - MIN

    if MID - MIN >= 2:
        if MIN == A:
            res = rec(A+2, B, C, cnt+1)
        if MIN == B:
            res = rec(A, B+2, C, cnt+1)
        if MIN == C:
            res = rec(A, B, C+2, cnt+1)
    else:
        if MAX == C:
            res = rec(A+1, B+1, C, cnt+1)
        if MAX == A:
            res = rec(A, B+1, C+1, cnt+1)
        if MAX == B:
            res = rec(A+1, B, C+1, cnt+1)
    return res


    
if '__main__' == __name__:
    resolve()

Submission status: Accepted

Solution code:
a,s,d=sorted(list(map(int,input().split())))
b,c=s-a,d-a
if (b%2,c%2) in {(0,0),(0,1)}:print((2*c-b)//2)
else:print((2*c+3-b)//2)

Submission status: Accepted

Solution code:
import math
A,B,C = map(int,input().split())
k = [A,B,C]
k.sort()
k.reverse()
ans = 0
ans += k[0]-k[1]
now = k[2]
now += ans
if (k[0]-now)%2 == 0:
    ans += math.ceil((k[0]-now)/2)
    print(ans)
else:
    ans += math.ceil((k[0]-now)/2)
    ans += 1
    print(ans)

Submission status: Accepted

Solution code:
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


A, B, C = MI()
m = max(A, B, C)

ans = (m - A) // 2
A += (m - A) // 2 * 2
ans += (m - B) // 2
B += (m - B) // 2 * 2
ans += (m - C) // 2
C += (m - C) // 2 * 2

d = 3 * m - (A + B + C)
if d == 0:
    print(ans)
elif d == 1:
    print(ans + 2)
else:
    print(ans + 1)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    *a, = map(int, input().split())

    a.sort()
    ma = a[-1]

    if (a[0] - a[1]) % 2 == 1:
        # 収束値がmaになるには
        # ma以外の2要素の偶奇が一致していなければならない
        # ma in oddsの場合だと
        # odds=[ma],evens=[a0,a1]
        # odds=[ma,a0,a1],evens=[]
        # の2パターン
        ma += 1
    ans = (ma * 3 - sum(a)) // 2

    print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())

Submission status: Accepted

Solution code:
def main():
    *a, = map(int, input().split())
    evens = [x for x in a if x % 2 == 0]
    odds = [x for x in a if x % 2 == 1]

    if evens:
        if odds:
            ans = 1
            if len(evens) > len(odds):
                evens = (x + 1 for x in evens)
                odds.extend(evens)
                ma = max(odds)
                ans += sum((ma - x) // 2 for x in odds)
            else:
                odds = (x + 1 for x in odds)
                evens.extend(odds)
                ma = max(evens)
                ans += sum((ma - x) // 2 for x in evens)
        else:
            ma = max(evens)
            ans = sum((ma - x) // 2 for x in evens)
    else:
        ma = max(odds)
        ans = sum((ma - x) // 2 for x in odds)

    print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())

Submission status: Accepted

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

sum_li = sum(li)

max_li = max(li)

j = 3 * max_li - sum_li

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

print(ans)

Submission status: Accepted

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

x=max(num)
s=sum(num)

t=(3*x-s)
ans=t//2
if t%2!=0:
    ans=(t+3)//2
print(ans)

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
t=max(a,b,c)
aa=t-a
bb=t-b
cc=t-c
if aa==0:
    ans=min(bb,cc)+(max(bb,cc)-min(bb,cc))//2
    if bb%2!=cc%2:
        print(ans+2)
    else:
        print(ans)
elif bb==0:
    ans=min(aa,cc)+((max(aa,cc)-min(aa,cc))//2)
    #print(ans)
    if aa%2!=cc%2:
        print(ans+2)
    else:
        print(ans)
else:
    ans=min(bb,aa)+(max(bb,aa)-min(bb,aa))//2
    if bb%2!=aa%2:
        print(ans+2)
    else:
        print(ans)

Submission status: Accepted

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

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

    max_n = max(li)
    max_i = li.index(max_n)

    diff = 0

    for i in range(3):
        if i == max_i:
            continue

        diff += max_n - li[i]

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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


print(ans)

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]]
    B.sort(key=lambda p: p % 2)
    ans = 0
    if B[0] % 2 == B[1] % 2:
        ans += B[0]//2 + B[1]//2
        if B[0] % 2 == 1:
            ans += 1
    else:
        ans += B[0]//2 + (B[1]+1)//2 + 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

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

Submission status: Accepted

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

odd = 0
even = 0

for n in nums:
    if n % 2 == 0:
        even += 1
    else:
        odd += 1

ans = 0

if odd != 3 and even != 3:
    for i in range(3):
        if odd > even and nums[i] % 2 == 1:
            nums[i] += 1
        elif even > odd and nums[i] % 2 == 0:
            nums[i] += 1
    ans += 1

m = max(nums)
for n in nums:
    ans += (m - n) // 2

print(ans)

Submission status: Accepted

Solution code:
def resolve():
    a = list(map(int, input().split()))
    a = sorted(a)
    x = a[0]
    y = a[1]
    z = a[2]
    ans = z-y
    if (z-(ans+x)) % 2 == 0:
        ans += (z-(ans+x)) // 2
        print(ans)
    else:
        ans += (z - (ans + x)) // 2
        print(ans+2)
resolve()

Submission status: Accepted

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

l = sorted(l)

a = l[0]
b = l[1]
c = l[2]

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

Submission status: Accepted

Solution code:
a = list(map(int,input().split()))
e = 0
o = 0
ans = 1
for i in a:
    if i%2==0:
        e += 1
    else:
        o += 1
if o==3 or e==3:
    ans = 0
elif e > o:
    for i in range(3):
        if a[i]%2==0:
            a[i] += 1
else:
    for i in range(3):
        if a[i]%2==1:
            a[i] += 1
a = sorted(a,reverse=True)
ans += (a[0]-a[1])//2 + (a[0]-a[2])//2
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
x = list(map(int,input().split()))
x.sort()
a,b,c = x
ret = 0
while c > b:
    a+=1
    b+=1
    ret+=1
while a < b:
    a+=2
    ret+=1
if a!=b:
    ret+=1
print(ret)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c = map(int,input().split())
if a%2 == b%2 and b%2 == c%2:
    if a == max([a,b,c]):
        p = min(b,c)
        q = max(b,c)
        ans = abs(a-p)//2+abs(a-q)//2
    elif b == max([a,b,c]):
        p = min(a,c)
        q = max(a,c)
        ans = abs(b-p)//2+abs(b-q)//2
    elif c == max([a,b,c]):
        p = min(a,b)
        q = max(a,b)
        ans = abs(c-p)//2+abs(c-q)//2
else:
    even = []
    odd = []
    if a%2:odd.append(a)
    else:even.append(a)
    if b%2:odd.append(b)
    else:even.append(b)
    if c%2:odd.append(c)
    else:even.append(c)
    if len(even) > len(odd):
        ans = 1
        even[0] +=1
        even[1]+=1
        ans += abs(max(even)-min(even))//2+abs(odd[0]-max(even))//2
    
    else:
        ans = 1
        odd[0]+=1
        odd[1]+=1
        ans += abs(max(odd)-min(odd))//2+abs(even[0]-max(odd))//2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
L = sorted([A,B,C])
Min = L[0]
Med = L[1]
Max = L[2]

cnt = 0
while Max-Min > 1:
    cnt += 1
    Min += 2
while Max-Med >1:
    cnt += 1
    Med += 2
if Min == Max and Max == Med:
    print(cnt)
elif Min+1 == Max and Med+1 == Max:
    print(cnt+1)
else:
    print(cnt+2)

Submission status: Accepted

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

m = max(A, B, C)
ans = 0
ans += (m-A)//2
A += (m-A)//2*2
ans += (m-B)//2
B += (m-B)//2*2
ans += (m-C)//2
C += (m-C)//2*2


s = sum([a == m for a in (A, B, C)])
if s == 3:
    pass
elif s == 1:
    ans += 1
else:
    ans += 2
print(ans)

Submission status: Accepted

Solution code:
nums=list(map(int,input().split()))
k=max(nums)*3-sum(nums)

if k&1:
    ans=(k+3)//2
else:
    ans=k//2

print(ans)

Submission status: Accepted

Solution code:
from math import ceil
a,b,c=map(int,input().split())
l=[]
l.append(a)
l.append(b)
l.append(c)
l.sort()

v=2*l[-1]-l[0]-l[1]
if l[0]%2==l[1]%2:
    print(int(v/2))
else:
    print(ceil(v/2)+1)

Submission status: Accepted

Solution code:
def examA():
    O = SI()
    E = SI()
    ans = ""
    for i in range(len(O)+len(E)):
        if i%2==0:
            ans += O[i//2]
        else:
            ans += E[i//2]
    print(ans)
    return

def examB():
    A = LI()
    A.sort()
    ans = (A[2] - A[0]) // 2 + (A[2] - A[1]) // 2
    if (A[2]-A[0])%2==1:
        ans += 1
        if (A[2]-A[1])%2==0:
            ans += 1
    elif (A[2]-A[1])%2==1:
        ans += 2
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examB()

"""

"""

Submission status: Accepted

Solution code:
A, B, C = sorted(list(map(int, input().split())))
ans = 0
if A % 2 == B % 2 and A % 2 != C % 2:
    A += 1
    B += 1
    ans += 1
if A % 2 == C % 2 and A % 2 != B % 2:
    A += 1
    C += 1
    ans += 1
if B % 2 == C % 2 and B % 2 != A % 2:
    B += 1
    C += 1
    ans += 1
ans += (C - A) // 2 + (C - B) // 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()
a.sort()
to = a[-1]
if 3 * to % 2 != sum(a) % 2:
    to += 1
plus = [0, 0, 0]
for i in range(3):
    plus[i] = to - a[i]
debug(plus)
ans = 0
if plus[2]:
    ans += 1
    plus[2] = 0
    mx = max(plus[:2])
    plus[plus.index(mx)] -= 1
debug(plus)
plus = plus[:2]
ans += min(plus) + (max(plus) - min(plus)) // 2
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
a = list(map(int, input().split()))
mx = max(a)
sm = sum(a)
if ((mx * 3 - sm) % 2):
  print(((mx + 1) * 3 - sm) // 2)
else:
  print((mx * 3 - sm) // 2)

Submission status: Accepted

Solution code:
def main():
    numbers = list(map(int, input().split()))
    numbers.sort()
    answer = 0
    diff = [numbers[2] - numbers[0], numbers[2] - numbers[1]]
    if diff[0] % 2 == diff[1] % 2:
        answer += diff[0] // 2 + diff[1] // 2
        if diff[0] % 2:
            answer += 1
    else:
        answer += (diff[0] + 1) // 2 + (diff[1] + 1) // 2
        answer += 1
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

l = [A, B, C]
A, B, C = sorted(l)

res = 0
if ((C - A) % 2 == 0 and (C - B) % 2 == 0):
    res += (C - A) // 2 + (C - B) // 2
elif (C - A) % 2 != (C - B) % 2:
    res += (C - A) // 2 + (C - B) // 2 + 2
else:
    res += (C - A) // 2 + (C - B) // 2 + 1

print(res)

Submission status: Accepted

Solution code:
import math
a = sorted(list(map(int,input().split())))
print(a[2] - a[1] + math.ceil((a[1] - a[0]) / 2) + ((a[1] - a[0]) % 2 == 1))

Submission status: Accepted

Solution code:
A,B,C = (int(i) for i in input().split())

ans = 0

max_num = max(A,B,C)

ans += (max_num - A)//2
ans += (max_num - B)//2
ans += (max_num - C)//2

A = A + ((max_num - A)//2) * 2 - max_num
B = B + ((max_num - B)//2) * 2 - max_num
C = C + ((max_num - C)//2) * 2 - max_num

nums = [A,B,C]
if A==B and B==C:
  print(ans)
elif nums.count(-1) == 2:
  print(ans+1)
else:
  print(ans+2)

Submission status: Accepted

Solution code:
A = list(map(int, input().split()))
B = [a%2 for a in A]
if len(set(B))==1:
    ans = (max(A)*3-sum(A))//2
elif B.count(0)==1:
    ind = B.index(0)
    if A[ind] == max(A):
        ans = (max(A)*3-2-sum(A))//2+1
    else:
        ans = (max(A)*3-sum(A)+1)//2+1
else:
    ind = B.index(1)
    if A[ind] == max(A):
        ans = (max(A)*3-2-sum(A))//2+1
    else:
        ans = (max(A)*3-sum(A)+1)//2+1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

    if abc.count(min(abc)) == 2:
        if abc.count(abc[0]) == 2 and abc.count(abc[1]) == 2:
            abc[0] += 1
            abc[1] += 1
        if abc.count(abc[0]) == 2 and abc.count(abc[2]) == 2:
            abc[0] += 1
            abc[2] += 1
        if abc.count(abc[1]) == 2 and abc.count(abc[2]) == 2:
            abc[1] += 1
            abc[2] += 1
    else:
        abc[abc.index(min(abc))] += 2
    cnt += 1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c = map(int,(input().split()))
ans = 0
if a%2 + b%2 + c%2 == 1:
    if a%2 == 0:
        a += 1
    if b%2 == 0:
        b += 1
    if c%2 == 0:
        c += 1
    ans += 1
if a%2 + b%2 + c%2 == 2:
    if a%2 == 1:
        a += 1
    if b%2 == 1:
        b += 1
    if c%2 == 1:
        c += 1
    ans += 1

A = max(a,b,c) -a
B = max(a,b,c)- b
C = max(a,b,c) -c

print(ans+(A+B+C)//2)

Submission status: Accepted

Solution code:
A,B,C = map(int,input().split())
list = [A, B, C]
list.sort(reverse = True)

a = list[0]
b = list[1]
c = list[2]
ans = (a -b) + (b-c)//2

if (b - c) % 2 == 0:
  print(ans)
else:
  ans += 2
  print(ans)

Submission status: Accepted

Solution code:
from math import ceil
a,b,c=map(int,input().split())
l=[]
l.append(a)
l.append(b)
l.append(c)
l.sort()

val=2*l[-1]-l[0]-l[1]
if l[0]%2==l[1]%2:
    print(int(val/2))
else:
    print(ceil(val/2)+1)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc093/tasks/arc094_a
a, b, c = map(int, input().split())

nums = [a, b, c]
nums.sort()

ans = 0
if (nums[1] - nums[0]) % 2 == 1:
    # 小さい2つの差が奇数の場合、偶数になるように
    # 小さい2つの数字両方にならないように、1を足す。
    # ここでは、二番目に大きいのと、最大の数に1を足す。
    nums[1] += 1
    nums[2] += 1
    ans += 1
ans += (nums[1] - nums[0]) // 2 # 一番小さい数が、二番目に大きい数に追いつくようにする。それには2ずつ足すのが良い。
ans += (nums[2] - nums[1]) # 一番目も二番目も同じかずになったので、両方に１つづ足していき、最大の数と同じになる様にする。
print(ans)

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
work = sorted([a, b, c])
modu = list(map(lambda x:x%2, work))
if modu[0]==modu[1]:
    result = (2*work[2]-work[1]-work[0])//2
else:
    result = (2*work[2]-work[1]-work[0]+1)//2 + 1
print(result)

Submission status: Accepted

Solution code:
def main():
    a,b,c = map(int,input().split())
    cnt = 0
    if a == b == c:
        print(0)
        return
    ary = [a,b,c]
    while True:
        ary.sort()
        if ary[0] == ary[1] == ary[2]:
             print(cnt)
             return
        elif ary[1] == ary[0] :
            cnt += ary[2] - ary[0]
            print(cnt)
            return


        ary[0] += 2
        cnt += 1



if __name__ =='__main__':
    main()

Submission status: Accepted

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