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:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    A=list(map(int,input().split()))
    even=[False]*3
    for i in range(3):
        if A[i]%2==0:
            even[i]=True
    cnt=0
    if even.count(True)==2:
        for i in range(3):
            if A[i] % 2 == 0:
                A[i]+=1
        cnt+=1
    elif even.count(True)==1:
        for i in range(3):
            if A[i] % 2 == 1:
                A[i]+=1
        cnt+=1
    ma=max(A)
    for i in range(3):
        cnt+=(ma-A[i])// 2

    print(cnt)
#
resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
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))
#%%code
def resolve():
    A=list(pin())
    A.sort()
    a=0
    if A[0]%2!=A[1]%2:
        A[1]+=1
        A[2]+=1
        a+=1
    a+=(A[2]*2-A[0]-A[1])//2
    print(a)
    
#%%submit!
resolve()

Submission status: Accepted

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

max_ = max(a, b, c)
ans = 0
ans += (max_ - a) // 2
a += ((max_ - a) // 2) * 2

ans += (max_ - b) // 2
b += ((max_ - b) // 2) * 2

ans += (max_ - c) // 2
c += ((max_ - c) // 2) * 2

if [a, b, c].count(max(a, b, c)) == 3:
    print(ans)
elif [a, b, c].count(max(a, b, c)) == 2:
    print(ans + 2)
elif [a, b, c].count(max(a, b, c)) == 1:
    print(ans + 1)

Submission status: Accepted

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

ABC.sort()

count = ABC[2] - ABC[1]

ABC[0] += count
ABC[1] += count

#ここまでで a, C, cとなっているはず

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

print (count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
*I,=map(int, input().split())
sm=sum(I)
mx=max(I)
h=(3*mx-sm)
print(h//2 if h&1==0 else (h+3)//2)

Submission status: Accepted

Solution code:
def main():
    A = [int(i) for i in input().split()]
    A.sort()
    B = [A[2]-A[1], A[2]-A[0]]
    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()

Submission status: Accepted

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

while True:
  diff = sum([target - x for x in ABC])
  if diff % 2 == 0:
    print(diff//2)
    quit()
  else:
    target += 1

Submission status: Accepted

Solution code:
import numpy as np

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

l = np.array(list(multi_input()))
l = np.abs(l - max(l))
l.sort()

ans = 0
if (l[2] - l[1]) % 2 == 0:
    ans += l[1] + (l[2] - l[1]) // 2
else:
    t = (l[2] - l[1] - 1) // 2
    ans += t + (l[2] - 2 * t + 1)  
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
a, b, c = sorted(map(int, input().split()))
d = b - a
print(c - b + d//2 + d%2*2)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
l = list(map(int, input().split()))
M = max(l)
wa = sum(l)
if M % 2 == wa % 2:
    print((3 * M - wa) // 2)
else:
    print((3 * (M + 1) - wa) // 2)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A = LIST()
A.sort()

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

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

print(ans)

Submission status: Accepted

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

count  = (b - a) // 2
count += 2 if (a + count * 2) != b else 0
count += c - b
print(count)

Submission status: Accepted

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

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

ans = 0
for i in range(2):
    cnt = (li[2] - li[i]) // 2
    li[i] += 2 * cnt
    ans += cnt

ans += li.count(max(li)) % 3
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
A =np.array(sorted(list(map(int,input().split()))))
a = max(A)
b = a -A

if abs(b[1]-b[0]) %2 == 0:
    print(sum(b)//2)
else :
    print(sum(b)//2 + 2)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    A, B, C = map(int, readline().split())
    a = min(A,B,C)
    c = max(A,B,C)
    b = (A+B+C)-(a+c)
    if a==b:
        ans = c-a
    else:
        ans = (b-a)//2
        a += ((b-a)//2)*2
        ans += c-a
        b += c - a
        a = c
        if a!=b:
            ans += 1
    print(ans)



if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

while num[0]<num[1]:
    ans += 1
    num[0] += 2
    
if num[0] != num[1]:
    ans += 1
    
print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:

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

m=max(a,b,c)

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

Submission status: Accepted

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

Submission status: Accepted

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

C = sorted(list([a, b, c]))

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

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

Submission status: Accepted

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

Submission status: Accepted

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

    if abs(A-B) % 2 == 0:
        while A != B:
            A += 2
            cnt += 1

        while A != C and B != C:
            A += 1
            B += 1
            cnt += 1

        print(cnt)
    else:
        while B != C:
            A += 1
            B += 1
            cnt += 1

        while A < B:
            A += 2
            cnt += 1

        while A != C:
            B += 1
            C += 1
            cnt += 1

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

Submission status: Accepted

Solution code:
# AtCoder
X = list(map(int, input().split()))

mx = max(X)
sm = sum(X)

if 3*mx % 2 == sm % 2:
    N = (3*mx-sm)/2
else:
    N = (3*(mx+1)-sm)/2
print(int(N))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A = [int(i) for i in input().split()]
A.sort()
s,m,l = A
count = 0
ls = l-s
lm = l-m
count += ls//2
count += lm//2
if ls%2 == 0 and lm%2 == 0:
  print(count)
  exit()
elif ls%2 == 1 and lm%2 == 1:
  count += 1
  print(count)
else:
  count += 2
  print(count)

Submission status: Accepted

Solution code:
number=[int(i) for i in input().split()]
number.sort()
a,b,c=number

#aを何回操作すればｃかc-1にできるか
anum=(c-a)//2
amari=(c-a)%2

bnum=(c-b)//2
bamari=(c-b)%2
c=amari+bamari

if c==0:
    plus=0
elif c==1:
    plus=2
else:
    plus=1
print(anum+bnum+plus)

Submission status: Accepted

Solution code:
from sys import stdin
import sys
import math

def isOdd(n):
    return n % 2 == 1

def isPair(n):
    return n % 2 == 0


A, B, C = list(map(int, stdin.readline().rstrip().split()))

l, m, n = sorted([A, B, C], reverse=True)

count = 0


while l > m or l > n:
    if isOdd(l) and isOdd(m) and isPair(n) or isPair(l) and isPair(m) and isOdd(n):
        l += 1
        m += 1
        count += 1
    elif isOdd(l) and isPair(m) and isOdd(n) or isPair(l) and isOdd(m) and isPair(n):
        l += 1
        n += 1
        count += 1
    elif isPair(l) and isOdd(m) and isOdd(n) or isOdd(l) and isPair(m) and isPair(n):
        m += 1
        n += 1
        count += 1
    else:
        if l > m:
            count += (l - m) // 2
            m += (l - m)
        if l > n:
            count += (l - n) // 2
            n += (l - n)

print(count)

Submission status: Accepted

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

X = max(A,B,C)

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

print(ans//2)

Submission status: Accepted

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

X = max(A,B,C)

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

print(ans//2)

Submission status: Accepted

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

Submission status: Accepted

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

if (x*3-sum(li))%2 == 1: #目標までの差が奇数なら
    x += 1 #目標を1増やす

print((x*3-sum(li)+1)//2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A = list(map(int, input().split()))
m3, suma = max(A)*3, sum(A)
print((m3-suma)//2 if (m3-suma)%2==0 else (m3-suma)//2 + 2)

Submission status: Accepted

Solution code:
li = list(map(int, input().split()))
even_count = sum([l % 2 for l in li])
ans = 1
if even_count == 1:
    li = [l + 1 if l % 2 == 0 else l for l in li]
elif even_count == 2:
    li = [l + 1 if l % 2 == 1 else l for l in li]
else:
    ans = 0
ans += sum([(max(li) - l) // 2 for l in li])
print(ans)

Submission status: Accepted

Solution code:
a=[int(i) for i in input().split()]
a.sort()
ans=0
while a[1]!=a[2]:
    a[1]+=1
    a[0]+=1
    ans+=1
if a[1]%2==a[0]%2:
    ans+=(a[1]-a[0])//2
else:
    ans+=1
    a[1]+=1
    ans+=(a[1]-a[0])//2
print(ans)

Submission status: Accepted

Solution code:
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    a, b, c = nm()

    a, b, c = sorted([a, b, c])

    op1 = c - b
    op2 =  math.ceil((c - (a + op1)) / 2)

    if a + op1 + 2*op2 > c:
        op1 += 1

    print(op1 + op2)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

# https://atcoder.jp/contests/abc093/tasks/arc094_a
# 14:55-15:03


def main():
    a, b, c = map(int, input().split())
    a, b, c = sorted([a, b, c], reverse=True)

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


print(main())

Submission status: Accepted

Solution code:
abc = list(map(int,input().split()))
guki = [abc[0] % 2,abc[1] % 2,abc[2] % 2]
cnt_gusu = 0
cnt = 0
for i in abc:
    if i % 2 == 0:
        cnt_gusu += 1
if cnt_gusu == 2:
    cnt += 1
    for i in range(3):
        if abc[i] % 2 == 0:
            abc[i] += 1
elif cnt_gusu == 1:
    cnt += 1
    for i in range(3):
        if abc[i] % 2 == 1:
            abc[i] += 1
set_abc = set(abc)
abc.sort()
if len(set_abc) == 1:
    print(cnt)
elif len(set_abc) == 2:
    maxv = max(abc)
    jud = 0
    for i in abc:
        if i == maxv:
            jud += 1
    if jud == 2:
        cnt += (abc[2] - abc[0]) // 2
    else:
        cnt += (abc[2] - abc[0])
    print(cnt)
else:
    zouka = abc[2] - abc[1]
    cnt += zouka + ((abc[2] - (abc[0]+zouka) ) // 2)
    print(cnt)

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from itertools import combinations # (string,3) 3回
#from collections import deque
#import collections.defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000)
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)
        # 1回で2個
    else:#奇数なら、
        print(d//2 + 2)
        # 条件1, 条件2を結局1回ずつ増やす
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
n = list(map(int, input().split()))
n.sort()
sum = 0
k1 = n[2] - n[1]
n[0] += 1
n[1] += 1
sa = n[1] - n[0]
m,d = divmod(sa,2)
if d == 1:
    sum += 2
sum += k1 + m
print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,C=map(int,input().split())
M=[A,B,C]
M.sort()
kaisuu1=M[2]-M[1]
M[0]+=kaisuu1
M[1]+=kaisuu1
nokori=M[1]-M[0]
q,r=divmod(nokori,2)
sum_kaisuu=kaisuu1+q
if r==1:
    sum_kaisuu+=2
print(sum_kaisuu)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    L=list(map(int,input().split()))
    even=[False]*3
    ans=0
    for i in range(3):
        if L[i]%2==0:
            even[i]=True

    M=L.index(max(L))
    if even.count(even[M]) in [1,3]:
        ans+=(max(L)*3-sum(L))//2
    else:
        ans+=1
        ans+=((max(L)+1)*3-(sum(L)+2))//2


    print(ans)






resolve()

Submission status: Accepted

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

if not (A % 2 == B % 2 == C % 2):
    G = [[], []]
    for n in (A, B, C):
        G[n % 2].append(n)
    G.sort(key=lambda a: len(a))

    G[1][0] += 1
    G[1][1] += 1

    A, B, C = G[0][0], G[1][0], G[1][1]
    ans += 1

mx = max(A, B, C)
ans += (mx - A) // 2 + (mx - B) // 2 + (mx - C) // 2
print(ans)

Submission status: Accepted

Solution code:
ABC = list(map(int, input().split()))
n_odd = sum([Xi % 2 for Xi in ABC])

ans = 0
if n_odd == 1:
    ans += 1
    ABC[0] += int(ABC[0] % 2 == 0)
    ABC[1] += int(ABC[1] % 2 == 0)
    ABC[2] += int(ABC[2] % 2 == 0)
elif n_odd == 2:
    ans += 1
    ABC[0] += int(ABC[0] % 2 == 1)
    ABC[1] += int(ABC[1] % 2 == 1)
    ABC[2] += int(ABC[2] % 2 == 1)

ABC.sort()
ans += (ABC[2] - ABC[0]) // 2
ans += (ABC[2] - ABC[1]) // 2

print(ans)

Submission status: Accepted

Solution code:

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

d = C - B
A += d
B += d


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

Submission status: Accepted

Solution code:
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)
    #print(L)

    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
n = []
for i in range(len(a)):
  if a[i] % 2 == 0: n.append(i+1)
if len(n) == 3:
  a.sort()
  ans = (a[2]-a[0]) // 2 + (a[2] - a[1]) // 2
elif len(n) == 2:
  N = 3 - sum(n) - 1 #奇数
  ans = 0
  if a[N] != max(a):
    while a[N] < max(a):
      a[N] += 2
      ans += 1
  a.sort()
  ans += (a[1] - a[0]) // 2 + a[2] - a[1]
elif len(n) == 1:
  for i in range(len(a)):
    if a[i] % 2 != 0:
      a[i] += 1
  a.sort()
  ans = (a[2] - a[0]) // 2 + (a[2] - a[1]) // 2 + 1
else:
  a.sort()
  ans = (a[2] - a[0]) // 2 + (a[2] - a[1]) // 2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
lis = list(map(int,input().split()))
lis.sort()
ans = 0
while True:
    if lis[0] == lis[2]:
        print(ans)
        exit()
    if lis[0] == lis[1]:
        lis[0] += 1
        lis[1] += 1
    else:
        lis[0] += 2
    ans += 1
    lis.sort()

Submission status: Accepted

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


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

    if abc.count(max(abc)) >= 2:
        abc[abc.index(min(abc))] += 2
    else:
        if abc[0] != max(abc):
            abc[0] += 1
        if abc[1] != max(abc):
            abc[1] += 1
        if abc[2] != max(abc):
            abc[2] += 1
    ans += 1

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

lst = [A, B, C]
lst.sort(reverse = True)
ctr = 0

while lst[0] > lst[1]:
    lst[1] += 1
    lst[2] += 1
    ctr += 1

while lst[1] > lst[2]:
    lst[2] += 2
    ctr += 1

if lst[2] > lst[1]:
    ctr += 1

print(ctr)

Submission status: Accepted

Solution code:
def resolve():
  l = list(map(int, input().split()))
  l.sort()
  a, b, c = l[0], l[1], l[2]
  ans = 0
  ans += c - b
  a += ans
  while a < c:
    a += 2
    ans += 1
  if a > c:
    ans += 1
  print(ans)

  return

if __name__ == "__main__":
  resolve()

Submission status: Accepted

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    a,b,c=MI()
    t=max(a,b,c)
    temp=3*t-(a+b+c)
    if temp%2==1:
        temp+=3
    print(temp//2)

main()

Submission status: Accepted

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

Submission status: Accepted

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

max_v = l[2]
mid_v = l[1]
min_v = l[0]

count = max_v - mid_v
mid_v = max_v
min_v = min_v + count
diff = max_v - min_v

if diff == 0:
    count = count
elif diff == 1:
    count += 2  # ope2 and ope1
elif diff > 1 and diff % 2 == 0:
    count += diff / 2
elif diff > 1 and diff % 2 == 1:
    count += int(diff / 2)
    count += 2
else:
    print("Error")
print(int(count))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num = [int(i) for i in input().split()]
sorted_num = sorted(num)

if sorted_num[0] % 2 == sorted_num[1] % 2:
    count = sorted_num[2] - (sorted_num[0] + sorted_num[1])/2
elif sorted_num[0] % 2 != sorted_num[1] % 2:
    count = ((sorted_num[2] + 1) - (sorted_num[0] + sorted_num[1] + 1)/2) + 1

print(int(count))

Submission status: Accepted

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

x = max(a)
while (3 * x) % 2 != sum(a) % 2:
    x += 1
ans = (3 * x - sum(a)) // 2
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
a = [int(i) for i in input().split()]

x = max(a)
if (3 * x) % 2 != sum(a) % 2:
    x += 1
ans = (3 * x - sum(a)) // 2
print(ans)

Submission status: Accepted

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

S = A + B + C
b = 0

while S % 3 != 0:
    S += 2
    b += 1

while (S // 3) < max(A,B,C):
    S += 6
    b += 3

print(b)

Submission status: Accepted

Solution code:
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
A,B,C = map(int,input().split())
lis = [A,B,C]
lis.sort()
cnt_1 = lis[2]-lis[1]
nokori = lis[2]-lis[0]-cnt_1
if (lis[2]-lis[0]-cnt_1)%2 == 0:
    cnt_2 = nokori//2
else:
    cnt_2 = (nokori+1)//2 + 1

ans = cnt_1+cnt_2
print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

Solution code:
# solution

import io
import sys

array = sorted(list(map(int,input().split())))

nim = array[2]*2 - array[0] - array[1]

if nim%2 == 1:
    nim += 3

print(nim//2)

Submission status: Accepted

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

m = max(a,b,c)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C = sorted(map(int, input().split()), reverse=True)
gap = 2 * A - B - C

print(gap // 2 + gap % 2 * 2)

Submission status: Accepted

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

ans += sa // 2
if sa & 1:
    ans += 2
print(ans)

Submission status: Accepted

Solution code:

def myAnswer(A:int,B:int,C:int) -> int:
   MAX = max(A,B,C)
   ABC = sorted([A,B,C])
   counter = 0
   while ABC[0] != ABC[1] or ABC[1] != ABC[2]:
      if(ABC[1] == ABC[2]):
         ABC[0] += 2
         ABC.sort()
         counter +=1
      else:
         ABC[0] += 1
         ABC[1] += 1
         ABC.sort()
         counter += 1
   return counter


def modelAnswer():
   tmp=1
def main():
   A,B,C = map(int,input().split())
   print(myAnswer(A,B,C))
if __name__ == '__main__':
   main()

Submission status: Accepted

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

def main():
    A, B, C = map(int, readline().rstrip().split())

    m = max(A, B, C)
    if m == A:
        ma = max(B, C)
        ans = m - ma
        B += ans
        C += ans
    elif m == B:
        ma = max(C, A)
        ans = m - ma
        C += ans
        A += ans
    else:
        ma = max(A, B)
        ans = m - ma
        A += ans
        B += ans
    
    b = (max(A, B, C) - min(A, B, C)) % 2
    ans += (max(A, B, C) - min(A, B, C)) // 2 + b * 2
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
l = [a, b, c]
l.sort()
a, b, c = l[0], l[1], l[2]
cnt = 0
while not (a == b and b == c and a == c):
    a, b, c = l[0], l[1], l[2]
    if a+2 <= c:
        a += 2
    elif b+2 <= c:
        c += 2
    else:
        a += 1
        b += 1
    l[0] = a
    l[1] = b
    l[2] = c
    l.sort()
    cnt += 1
print(cnt)

Submission status: Accepted

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


def solve(A: int, B: int, C: int):
    x = 3 * max([A, B, C]) - A - B - C
    print(x // 2 + x % 2 * 2)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ax = (s[2] - s[0]) // 2
bx = (s[2] - s[1]) // 2

s[0] += ax * 2
s[1] += bx * 2

if s[0] == s[1] and s[0] != s[2]:
    print(ax + bx + 1)
if (s[0] != s[1] and s[0] == s[2]) or (s[0] != s[1] and s[1] == s[2]):
    print(ax + bx + 2)
if s[0] == s[1] and s[1] == s[2] and s[0] == s[1]:
    print(ax+bx)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc093/tasks/arc094_a

A = list(map(int, input().split()))
A.sort()
ans = A[2] - A[1]
sa = A[2] - (A[0] + ans)

ans += sa // 2
if sa & 1:
    ans += 2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

dist = (s_lst[2]-s_lst[1]) + (s_lst[2]-s_lst[0])

if(dist%2==0):
  print(int(dist/2))
else:
  print(int((dist + 3)/2))

Submission status: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

N = sorted(iil(),reverse=True)
ans = N[0]-N[1]
#print(ans)
if (N[0]-N[2]-ans)%2 == 0:
    ans += (N[0]-N[2]-ans)//2
else:
    ans += (N[0]-N[2]-ans)//2 + 2


print(ans)

Submission status: Accepted

Solution code:
A = list(map(int, input().split()))
A_sort = sorted(A)
max_A = A_sort[2]

if (max_A - A_sort[0])%2 == 0 and (max_A - A_sort[1])%2 == 0:
    print((max_A - A_sort[0])//2+(max_A - A_sort[1])//2)
elif (max_A - A_sort[0])%2 == 1 and (max_A - A_sort[1])%2 == 1:
    print((max_A - A_sort[1])//2+(max_A - A_sort[0])//2+1)
elif (max_A - A_sort[0])%2 == 1 or (max_A - A_sort[1])%2 == 1:
    print((max_A - A_sort[1])//2+(max_A - A_sort[0])//2+2)

Submission status: Accepted

Solution code:
L1 = list(map(int,input().split()))
L1.sort()
L2 = [L1[-1] - L1[i] for i in range(2)]
L2.sort()
P = L2[0]
Q = L2[1]
ans = P
Q -= P
ans += Q // 2
Q %= 2
ans += Q * 2
print(ans)

Submission status: Accepted

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

count = (base[2]-base[0])//2 + (base[2]-base[1])//2
base[0] = base[2] - (base[2]-base[0])%2
base[1] = base[2] - (base[2]-base[1])%2

judge_0 = base[2]-base[0]
judge_1 = base[2]-base[1]
#print(judge_0,judge_1)
if (judge_0 == 0) and (judge_1 == 0):
  ans = count
elif (judge_0 == 0) and (judge_1 == 1):
  ans = count + 2
elif (judge_0 == 1) and (judge_1 == 0):
  ans = count + 2
elif (judge_0 == 1) and (judge_1 == 1):
  ans = count + 1
  
print(ans)