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 numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

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

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

Submission status: Accepted

Solution code:
a = list(map(int , input().split()))
maxa = max(a)
x = sum(map(lambda x: maxa-x, a))

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

Submission status: Accepted

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

Submission status: Accepted

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

    cnt = 0
    if (nums[1] - nums[2]) % 2 == 0:
        cnt += (nums[1] - nums[2]) // 2
        cnt += nums[0] - nums[1]

    else:
        cnt += 1
        cnt += (nums[1] - nums[2] + 1) // 2
        cnt += nums[0] - nums[1]

    print(cnt)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c=sorted(map(int,input().split()))
#print(a,b,c)
cnt=0
if a%2==b%2==c%2:
    cnt=0
elif a%2==b%2:
    cnt+=1
    a+=1
    b+=1
elif b%2==c%2:
    cnt+=1
    b+=1
    c+=1
elif a%2==c%2:
    cnt+=1
    a+=1
    c+=1
#print(cnt,a,b,c)
cnt+=(c-a)//2+(c-b)//2
print(cnt)

Submission status: Accepted

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

diff = 2*abc[2] - abc[0] - abc[1]

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

Submission status: Accepted

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

Submission status: Accepted

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

# In[30]:


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


# In[32]:


abc_s = sorted(abc)
ones = abc_s[2] - abc_s[1]
twos = -(-(abc_s[2] - (abc_s[0]+ones))//2) + (abc_s[2] - (abc_s[0]+ones))%2
print(ones+twos)


# In[ ]:

Submission status: Accepted

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

    if A == B and A == C:
        return 0

    ans = 0
    sum = A+B+C
    while True:
        sum += 2
        if (sum % 3) == 0 and A<=(sum/3) and B<=(sum/3) and C<=(sum/3):
            break

    m = sum/3
    while True:
        if (m - A) >= 2:
            A += 2
            ans += 1
        else:
            break

    while True:
        if (m - B) >= 2:
            B += 2
            ans += 1
        else:
            break

    while True:
        if (m - C) >= 2:
            C += 2
            ans += 1
        else:
            break

    if A != m or B != m or C != m:
        ans += 1
    return ans

print(main())

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
l=[a,b,c]
l.sort()
cnt=l[2]-l[1]
sa=l[2]-(l[0]+cnt)
cnt+=sa//2
if sa%2!=0:
  cnt+=2
print(cnt)

Submission status: Accepted

Solution code:
a,b,c = sorted(list(map(int, input().split())))
# 同じ数が2つできるまで、小さい2つの数に１を足す
ans=0
if b!=c:
    b+=ans
    ans+=c-b
a+=ans
q,r = divmod(c-a, 2)
ans+=q
if r>0:
    ans+=2
print(ans)

Submission status: Accepted

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

max_num = max(nums)
sum_num = sum(nums)

if max_num * 3 % 2 != sum_num % 2:
    max_num += 1

ans = (max_num * 3 - sum_num) // 2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#和を求める解法
a,b,c = map(int,input().split(" "))
sum = a+b+c
max = max(a,b,c)
if (sum - max)%2 == 0:
    print(int((max*3 - sum)/2))
else:
    print(int(((max+1)*3 - sum)/2))

Submission status: Accepted

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

Submission status: Accepted

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

a = num[2] - num[1]
b = (num[2] - a - num[0]) % 2
c = (num[2] - a - num[0]) // 2

if b == 1:
    print(a + c + 2)
else:
    print(a + c)

Submission status: Accepted

Solution code:
## C - Same Integers
X = list(map(int, input().split()))
cnt = 0
if sum([x%2 for x in X]) == 2:
    for i in range(3):
        X[i] = X[i] + 1 if X[i]%2 == 1 else X[i]
        cnt = 1
elif sum([x%2 for x in X]) == 1:
    for i in range(3):
        X[i] = X[i] + 1 if X[i]%2 == 0 else X[i]
        cnt = 1
Max = max(X)
X.remove(Max)
print( (2 * Max - sum(X) )//2 + cnt )

Submission status: Accepted

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

Submission status: Accepted

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

parity = (a + b + c) % 2 # 総和の偶奇
m3 = (a*3) % 2 # 最大値×3の偶奇

if parity == m3:
    x = a
else:
    x = a + 1

print((x*3 - (a+b+c)) // 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
def main():
    num = list(map(int, input().split()))
    MAX = max(num)
    CNT = 0
    for i in range(3):
        num[i] -= MAX
        CNT -= num[i]
    if CNT%2 == 0:
        ans = CNT//2
        print(ans)
    else:
        ans = CNT//2 + 2
        print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ABC = list(map(int, input().split()))
ABC = sorted(ABC)[::-1]

diff1 = ABC[0]-ABC[1]
diff2 = ABC[1]-ABC[2]

cnt2 = 0

if diff2 % 2 ==0:
  cnt2 = diff2 /2
else:
  cnt2 = 2 + diff2 /2

ans = int(diff1 + cnt2)
print(ans)

Submission status: Accepted

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

M = max(a, b, c)

if (a+b+c)%2 != (M* 3) % 2:
    M += 1


diff = 3 * M - a - b - c
print(diff // 2)

Submission status: Accepted

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

x = max([a,b,c])
tmp = 1
while tmp % 2 == 1:
    tmp = x - a + x - b + x - c
    x += 1

print(tmp // 2)

Submission status: Accepted

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

abc = list(map(int, readline().split()))
abc.sort()

ans = abc[2]-abc[1]
res = abc[1]-abc[0]
if res % 2 == 0:
    ans += res // 2
else:
    ans += res // 2 + 2

print(ans)

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
num1=max(a,b,c)
if num1==a:
    num2=a-b
    num3=a-c
elif num1==b:
    num2=b-a
    num3=b-c
else:
    num2=c-a
    num3=c-b
num4=abs(num2-num3)
if num4%2==0:
    print((num2+num3)//2)
else:
    print((num2+num3)//2+2)

Submission status: Accepted

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

while n.count(n[0]) != len(n):
    n.sort()
    if n[0] == n[1]:
        n[0] += 1
        n[1] += 1
    else:
        n[0] += 2
    cnt += 1
print(cnt)

Submission status: Accepted

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

while n.count(n[0]) != len(n):
    n.sort()
    if n[0] == n[1]:
        n[0] += 1
        n[1] += 1
    else:
        n[0] += 2
    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
z=list(map(int,input().split()))
list.sort(z, reverse=True)
c=z[0]
b=z[1]
a=z[2]
x=(c-b)//2 + (c-a)//2

if((c-b)%2==1):
  if((c-a)%2==1):
    x+=1
  else:
    x+=2
elif((c-a)%2==1):
  x+=2
print(x)

Submission status: Accepted

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

a.sort()

answer=((a[2]-a[1])+(a[2]-a[0]))/2
if ((a[2]-a[1])+(a[2]-a[0]))%2!=0:
    answer+=1.5

print(int(answer))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
a=list(map(int,input().split()))
a.sort()
l0=a[0]-a[2]
l1=a[1]-a[2]
l2=0
c=0
while(c<1000):
    if l2==l1 and l2==l0:
        print(c)
        break
    elif l1==l0:
        l1+=1
        l0+=1
    elif (l1-l0)%2==0:
        l0+=2
    else:
        l0+=1
        l2+=1
    c+=1

Submission status: Accepted

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

Submission status: Accepted

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

m=num[2]*3

if sum(num)%2==m%2:
    print((m-sum(num))//2)
else:
    print((m-sum(num))//2+2)

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    abc = map(int, input().split())
    a, b, c = sorted(abc)
    if (b - a) % 2 == 0:
        print((2 * c - a - b) // 2)
    else:
        print((2 * (c + 1) - a - b - 1) // 2 + 1)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
abc = list(map(int, input().split()))
abc.sort()
abc2 = abc[:]

if sum(abc) % 2 != 3 * abc[2] % 2:
    abc2[2] += 1

print((abc2[2] * 3 - sum(abc)) // 2)

Submission status: Accepted

Solution code:
def main():
    a, b, c = map(int, input().split())
    m = max(a, b, c)
    d = m * 3 - sum([a, b, c])
    ans = d // 2
    if d % 2 == 0:
        print(ans)
    else:
        print(ans + 2)
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

lin = li[:]

if sum(li)%2 != 3*li[2]%2:
    lin[2] += 1

print((lin[2]*3-sum(li))//2)

Submission status: Accepted

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

    ps = tuple(set() for _ in range(2))
    for i, x in enumerate(A):
        ps[x % 2].add(i)

    ret = 0
    for j in range(2):
        if len(ps[j]) == 2:
            for i in ps[j]:
                A[i] += 1
            ret += 1

    ma = max(A)
    ret += (ma * 3 - sum(A)) // 2

    print(ret)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

cnt = 0
while max(abc) - min(abc) > 1:
    abc[0] += 2
    abc.sort()
    cnt += 1

if abc[0] == abc[1] == abc[2]:
    cnt += 0
elif abc[0] == abc[1]:
    cnt += 1
else:
    cnt += 2

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
l=[a,b,c]
l.sort()
m=l[-1]
from math import ceil
ans=0
if (l[0]+l[1])%2==1:
  ans+=ceil((m-l[0])/2)
  ans+=ceil((m-l[1])/2)
  ans+=1
else:
  ans+=(2*m-l[0]-l[1])//2
print(ans)

Submission status: Accepted

Solution code:
a,b,c = map(int,input().split())
ans = 0
l = [a,b,c]
maa = max(l)
l.remove(maa)
maa2 = max(l)
l.remove(maa2)
maa3 = l[0]
for i in range(maa-maa2):
    maa3 += 1
    maa2 += 1
    ans += 1
if (maa-maa3)%2 == 0:
    ans += (maa-maa3)/2
    print(int(ans))
else:
    ans += (maa-maa3+1)/2
    print(int(ans+1))

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
sum_abc=a+b+c
ans=max(a,b,c)

if (ans-sum_abc)%2==0:
  print((ans*3-sum_abc)//2)
else:
  print( ( (ans+1)*3-sum_abc)//2)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

    print(ans)

resolve()

Submission status: Accepted

Solution code:
A, B, C = map(int,input().split())
L = [A%2,B%2,C%2]
ALL = [A,B,C]
cnt = 0

if L.count(0) == 3 or L.count(0) == 0:
    cnt += 0
elif L.count(0) == 2:
    for i in range(3):
        if L[i] == 0:
            ALL[i] += 1
    cnt += 1
elif L.count(0) == 1:
    for i in range(3):
        if L[i] == 1:
            ALL[i] += 1
    cnt += 1

ans = 3*max(ALL)- sum(ALL)

print(ans//2+cnt)

Submission status: Accepted

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

a = All[0]
b = All[1]
c = All[2]
aa = a%2
bb=b%2
cc =c%2

if aa == bb and aa == cc: #偶奇がすべて一致
  ans = (c-b)//2+(c-a)//2
elif aa==bb:
  a+=1
  b+=1
  ans = 1+ (c-b)//2+(c-a)//2
elif aa == cc:
  a+=1
  c+=1
  ans = 1+ (c-b)//2+(c-a)//2
elif bb == cc:
  b+=1
  c+=1
  ans = 1+ (c-b)//2+(c-a)//2
print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    ABC = sorted(list(map(int, input().split())))

    res = 0
    ABC[0] += ABC[2] - ABC[1]
    res += ABC[2] - ABC[1]
    res += (ABC[2] - ABC[0]) // 2 if (ABC[2] - ABC[0]) % 2 == 0 else (ABC[2] - ABC[0]) // 2 + 2
    print(res)


if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
n = list(map(int, input().split()))
n.sort()
cnt = 0
if (n[1]-n[0])%2 != 0:
  if (n[0]%2==0 and n[2]%2==0) or (n[0]%2!=0 and n[2]%2!=0):
    cnt += 1
    n[0] += 1
    n[2] += 1
  elif (n[1]%2==0 and n[2]%2==0) or (n[1]%2!=0 and n[2]%2!=0):
    cnt += 1
    n[1] += 1
    n[2] += 1
n.sort()
if (n[1]-n[0])%2 ==0:
  cnt += (n[1]-n[0])//2
  n[0] = n[1]
  print(cnt+n[2]-n[1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
  a = list(map(int, input().split()))
  a.sort()
  ans = 0
  while a[1] < a[2]:
    ans += 1
    a[1] += 1
    a[0] += 1

  while a[0] < a[2]:
    ans += 1
    a[0] += 2

  if a[0] != a[1]:
    ans += 1

  print(ans)
  return

if __name__ == "__main__":
  resolve()

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,copy
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

x = inpl()
a,b,c = sorted(x)
n = c-a; m = c-b
res = n//2 + m//2
if n%2 != m%2:
    res += 2
elif n%2 == 1 and n%2 == 1:
    res += 1
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

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==0:
    print(rem//2)
else:
    rem += 3
    print(rem//2)

Submission status: Accepted

Solution code:
In = sorted([int(i) for i in input().split(" ")])
Max = max(In)
# print(Max)
count = Max - In[1]
In[0] += count
In[1] += count

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

Submission status: Accepted

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

import sys
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)



def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1             # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())

    def preprocess(a, b, c):
        tmp = (c - a) // 2
        a += 2 * tmp
        tmp2 = (c - b) // 2
        b += 2 * tmp2
        return (a, b), tmp + tmp2
    
    
    a, b, c = sorted(lmi())
    cnt = 0
    (a, b), op_num = preprocess(a, b, c)
    cnt += op_num

    if a == c and b == c:
        print(cnt)
    elif a == c - 1 and b == c - 1:
        print(cnt + 1)
    else:
        print(cnt + 2)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
a, b, c = map(int, input().strip().split(" "))
m = max(a, b, c)

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

M -= (a+b+c)
print(M//2)

Submission status: Accepted

Solution code:
# Problem C - Same Integers

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

# initialization
num_list = sorted([A, B, C])
sa = num_list[2] - num_list[1]
count = sa

# count 1
for i in range(3):
    if num_list[i]<num_list[2]:
        num_list[i] += sa

# count 2
num_list = sorted(num_list)
if num_list[0]<num_list[1] and num_list[0]<num_list[2]:
    if (num_list[1]-num_list[0])%2==0:
        count += (num_list[1]-num_list[0])// 2
    else:
        count += (num_list[1]-num_list[0])// 2 + 2
elif num_list[2]>num_list[0] and num_list[2]>num_list[1]:
    count += 1

# output
print(count)

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 fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

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

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

Submission status: Accepted

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

ans = 0
if A % 2 != B % 2 == C % 2:
    B += 1
    C += 1
    ans += 1
elif B % 2 != C % 2 == A % 2:
    C += 1
    A += 1
    ans += 1
elif C % 2 != A % 2 == B % 2:
    A += 1
    B += 1
    ans += 1

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

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

Submission status: Accepted

Solution code:
L = sorted(list(map(int,input().split())))
ans = 0
while L[0] != L[1] or L[1] != L[2]:
    ans += 1
    if L[0]+2 <= L[2]:
        L[0] += 2
    else:
        L[0] += 1
        L[1] += 1
    L = sorted(L)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
a.sort()
cnt = 0
if (a[0]%2==0 and a[1]%2!=0 and a[2]%2==0) or (a[0]%2!=0 and a[1]%2==0 and a[2]%2!=0):
  while a[2] > a[1]:
    a[1] += 2
    cnt += 1
  a.sort()
elif (a[0]%2!=0 and a[1]%2==0 and a[2]%2==0) or (a[0]%2==0 and a[1]%2!=0 and a[2]%2!=0):
  while a[2] > a[0]:
    a[0]+= 2
    cnt += 1
  a.sort()

if (a[0]%2!=0 and a[1]%2!=0) or (a[0]%2==0 and a[1]%2==0):
  cnt += (a[1]-a[0])//2
  a[0] = a[1]
  cnt += a[2]-a[1]
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

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:
*i, = map(int, input().split())
mx = max(i)
sm = sum(i)
print((3 * mx - sm) // 2 if (mx + sm) % 2 == 0 else (3 * mx + 3 - sm) // 2)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    a = sorted(LI())
    r = 0
    while a[0] != a[2]:
        r += 1
        if a[1] == a[0]:
            a[0] += 1
            a[1] += 1
        else:
            a[0] += 2
        a.sort()

    return r

print(main())

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(A):
    A = sorted(A)
    ma = min(A)
    for i in range(3):
        A[i] -= ma
    if A == [0, 0, 0]:
        return 0
    elif A == [0, 0, 1]:
        return 1
    elif A == [0, 1, 1]:
        return 2

A = list(map(int,input().split()))
A = sorted(A)
ca = (A[2] - A[0]) // 2
A[0] += 2 * ca
cb = (A[2] - A[1]) // 2
A[1] += 2 * cb
ans = ca + cb + solve(A)
print(ans)

Submission status: Accepted

Solution code:
A,B,C = map(int,input().split())
if (A+B+C)%2 == 0:
    candidates = [i for i in range(0,151,6)]
else:
    candidates = [i for i in range(3,154,6)]
for i in candidates:
    x = i/3
    if A<= x and B<= x and C<=x and ((x-A)+(x-B)+(x-C))%2==0:
        print(int((i-(A+B+C))/2))
        break

Submission status: Accepted

Solution code:
# C - Same Integers
# https://atcoder.jp/contests/abc093/tasks/arc094_a

nums = list(map(int,input().split()))
abc= sum(nums)
X = max(nums)


if X%2 != abc%2:
    X += 1
print((3*X - abc)//2)


# 増加させるかず -> 3X - abc
# 捜査回数      -> (3X - abc) //2