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:
num1, num2, num3 = input().split(" ")
numList = [int(num1),int(num2),int(num3)]
numList.sort(reverse=True)
maxNum = numList[0]
midNum = numList[1]
minNum = numList[2]

count = 0
if maxNum % 2 == 0:
    if midNum % 2 == 0 and minNum % 2 == 0:
        count += (midNum - minNum) // 2
        count += (maxNum - midNum)
    elif midNum % 2 == 1 and minNum % 2 == 1:
        maxNum += 2
        midNum += 2
        midNum += 2
        count += (midNum - minNum) // 2
        count += (maxNum - midNum)
        count += 2
    else:
        if midNum % 2 == 0:
            maxNum += 1
            minNum += 1
            count += (midNum - minNum) // 2
            count += (maxNum - midNum)
            count += 1
        else:
            maxNum += 1
            midNum += 1
            count += (midNum - minNum) // 2
            count += (maxNum - midNum)
            count += 1
else:
    if midNum % 2 == 0 and minNum % 2 == 0:
        count += (midNum - minNum) // 2
        count += (maxNum - midNum)
    elif midNum % 2 == 1 and minNum % 2 == 1:
        count += (midNum - minNum) // 2
        count += (maxNum - midNum)
    else:
        if midNum % 2 == 0:
            maxNum += 1
            minNum += 1
            count += (midNum - minNum) // 2
            count += (maxNum - midNum)
            count += 1
        else:
            maxNum += 1
            midNum += 1
            count += (midNum - minNum) // 2
            count += (maxNum - midNum)
            count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

m = max(A, B, C)
diff = (m - A) + (m - B) + (m - C)

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

print(ans)

Submission status: Accepted

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

lst.sort()

A, B, C = lst[0], lst[1], lst[2]

sa = (C-A) + (C-B)
if sa%2 == 1:
    ans = 1
    sa += 1
else:
    ans = 0

ans =ans + sa//2

print (ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
max_v = max(A,B,C)
temp = (max_v - A) + (max_v - B) + (max_v - C)
ans = 0

if temp % 2 == 0:
    ans = temp/2
else:
    ans = (temp+1)/2 + 1
    
print(int(ans))

Submission status: Accepted

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


def solve(A: int, B: int, C: int):
    mx = max(A, B, C)
    tmp = 0
    tmp += mx - A
    tmp += mx - B
    tmp += mx - C
    if tmp % 2 == 0:
        ret = tmp // 2
    else:
        ret = (tmp + 3) // 2
    print(ret)
    return


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:
#!/usr/bin/env python3
 
import re
 
n = input()
n = re.split(" ",n)
for i in range(3):
    n[i] = int(n[i])
n.sort()
a = int(n[2]) - int(n[0])
b = int(n[2]) - int(n[1])
 
#a,bともに奇数
if(a % 2 == 1 and b % 2 == 1):
    print(int(a/2)+int(b/2) + 1)
#a,bともに偶数
elif(a % 2 == 0 and b % 2 == 0):
    print(int(a/2) + int(b/2))
#それ以外
else:
    print(int(a/2) + int(b/2) + 2)

Submission status: Accepted

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

cnt = 0



while not(l[0] == l[1] == l[2]):
    l = sorted(l)
    
    if l[0]+2 <= l[2]:
        l[0] += 2
        cnt += 1
    
    else:
        l[0] += 1
        l[1] += 1
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
# ABC093C - Same Integers
a, b, c = sorted(list(map(int, input().rstrip().split())), reverse=True)
cnt = 0
while (a + b + c + cnt * 2) % 3 != 0 or (b + c + cnt * 2) / 2 < a:
    cnt += 1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

L=[A,B,C]
L=sorted(L)
ans+=L[2]-L[1] #この操作によってL[0]の値はL[0]+ans
if (L[2]-L[0]-ans)%2==0:
    ans+=(L[2]-L[0]-ans)//2
else:
    ans+=(L[2]-L[0]-ans)//2
    ans+=2
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


class UnionFind:

    def __init__(self, n):
        self.parent = [i for i in range(n)]

    def root(self, i):
        if self.parent[i] == i:
            return i
        self.parent[i] = self.root(self.parent[i])
        return self.parent[i]

    def unite(self, i, j):
        rooti = self.root(i)
        rootj = self.root(j)
        if rooti == rootj:
            return
        if rooti < rootj:
            self.parent[rootj] = rooti
        else:
            self.parent[rooti] = rootj

    def same(self, i, j):
        return self.root(i) == self.root(j)


###############################################################################


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

    abc = [a, b, c]
    abc.sort()
    ans = 0

    while len(set(abc)) != 1:
        if abc[1] < abc[2]:
            abc[0] += 1
            abc[1] += 1
            ans += 1
            continue
        if abc[0] < abc[1]:
            abc[0] += 2
            ans += 1
            continue
        if abc[0] > abc[1]:
            abc[1] += 1
            abc[2] += 1
            ans += 1
            continue

    print(ans)



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
L = sorted(list(map(int,input().split(' '))))
A,B,C = L[0],L[1],L[2]
X = C - A
Y = C - B

if X % 2 == 0 and Y % 2 == 0:
  print(int(X/2 + Y/2))
elif X % 2 == 1 and Y % 2 == 1:
  print(int(abs(X-Y)/2 + min(X,Y)))
else:
  print(int(math.ceil(X/2)+math.ceil(Y/2) + 1))

Submission status: Accepted

Solution code:
import math

A, B, C = map(int, input().split())
N = [A, B, C]
N.sort()

minN = N[0]
midN = N[1]
maxN = N[2]
diff1 = maxN - midN
diff2 = maxN - minN

if (diff1 % 2 == 0 and diff2 % 2 == 0) or (diff1 % 2 != 0 and diff2 % 2 != 0):
    print((diff1 + diff2) // 2)
else:
    print(math.ceil((diff1 + diff2) / 2) + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ABC093-C
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
Bar=IL()
Bar.sort()
ans=0
for i in range(2):
    while Bar[i]+2<=Bar[2]:
        Bar[i]+=2
        ans+=1
if Bar[0]==Bar[1] and Bar[1]==Bar[2]:
    print(ans)
elif Bar[0]==Bar[1]:
    print(ans+1)
else:
    print(ans+2)

Submission status: Accepted

Solution code:
a=list(map(int,input().split()));s=sum(a);m=max(a);print(int((3*m-s+1)/2)+(s-m)%2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
am, bm, cm = a%2, b%2, c%2
ans = 1

if am == bm and bm == cm:
    ans -= 1
elif am == bm and bm != cm:
    a += 1
    b += 1
elif bm == cm and cm != am:
    b += 1
    c += 1
elif cm == am and am != bm:
    c += 1
    a += 1

m = max(a, b, c)
ans += int((m-a)/2+(m-b)/2+(m-c)/2)
print(ans)

Submission status: Accepted

Solution code:
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


#n = ip()                                     #入力整数1つ
#x,y,z= (int(i) for i in input().split())       #入力整数横2つ以上
a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しに4 3sum変数使用はsum関数使用できないので注意
a.sort()
s = 0
s+=a[2]-a[1]
a[1]+=s
a[0]+=s
#print(a)
if (a[2]-a[0])%2:
    s+=(a[2]-a[0]+1)//2+1
else :
    s+=(a[2]-a[0])//2
print(s)

Submission status: Accepted

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

k = A[0]
l = A[1]
m = A[2]

if (2*m - k - l) % 2 == 0:
    print(int(m - (l+k)/2))
else:
    print(int(1 + m - (l + k - 1)/2))

Submission status: Accepted

Solution code:
A, B, C = map(int,input().split())
li = [A,B,C]
count = 0
while li[0]!=li[1] or li[0]!=li[2] or li[1]!=li[2]:
    li.sort(reverse=True)
    if li[2]+2 < li[0]:
        count += 1
        li[2] += 2

    elif li[2]+1 <= li[0] and li[1]+1 <= li[0]:
        count += 1
        li[1] += 1
        li[2] += 1

    else:
        count += 1
        li[2] += 2

print(count)

Submission status: Accepted

Solution code:
import numpy as np

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

lst = sorted(lst, reverse=True)
lst_odd = list(map(lambda x: x%2, lst))
ans = 0

# 二つに1を足す操作は多くとも一回しか使わないことに注意
# まず全ての数を lst[0]-1 <= x <= lst[0] の範囲に入れる

n_plus2_1 = (lst[0] - lst[1]) // 2
lst[1] += 2 * n_plus2_1
ans += n_plus2_1
n_plus2_2 = (lst[0] - lst[2]) // 2
lst[2] += 2 * n_plus2_2
ans += n_plus2_2

# 全ての数を一致させる
if lst.count(lst[0]) == 1:
  ans += 1
elif lst.count(lst[0]) == 2:
  ans += 2

print(int(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = [int(i) for i in input().split()]
S.sort()
A = S[2]
B = S[1]
C = S[0]

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

Submission status: Accepted

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

Submission status: Accepted

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

l = sorted([A, B, C])
c = 0
while l[1] != l[2]:
	#print(l)
	c += 1
	l[0] += 1
	l[1] += 1

#print(l)

if (l[0] == l[1] == l[2]):
	print(c)
	exit()

print(c + (l[1] - l[0] + 1) // 2 + (l[1] - l[0]) % 2)

Submission status: Accepted

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

p = max(A)
ans = 0
flag = 1
for i in range(3):
    A[i] = abs(A[i]-p)
    if A[i]%2 == 0:
        ans += A[i]/2
    else:
        ans += (A[i]+1)/2+flag
        if flag:
            flag = 0
        else:
            flag = 1
            ans -= 2
print(int(ans))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
max_n=max([a,b,c])
diff=3*max_n-a-b-c

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

Submission status: Accepted

Solution code:

import bisect





def main():
    a, b, c = map(int, input().split())
    ans = 0
    data = [a, b, c]
    data.sort()
    while 1:
        if data[0] == data[1] and data[0] == data[2]:
            break
        if data[2] > data[1] and data[2] > data[0]:
            data[1] += 1
            data[0] += 1
        else:
            data[0] += 2
        ans += 1
        data.sort()

    print(ans)







if __name__ == '__main__':
    main()

Submission status: Accepted

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

counter = (b - a) // 2

if (b - a) % 2 == 1:
    counter += 1
    c += 1
    
counter += (c - b)

print(counter)

Submission status: Accepted

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

m = max(A)
l = []
for a in A:
    if a != m:
        l.append(m - a)

if len(l) == 0:
    print(0)
    exit()
if len(l) == 1:
    if l[0] % 2 == 0:
        print(l[0] // 2)
    else:
        print(l[0] // 2 + 2)
    exit()

l.sort()

ans = 0

tmp = l[1] - l[0]

if tmp % 2 == 0:
    ans += tmp // 2 + l[0]
else:
    ans += tmp // 2 + 2 + l[0]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

abc = [A,B,C]
ieven = []
iodd = []
for i in range(3):
    if abc[i] % 2 == 0:
        ieven += [i]
    else:
        iodd += [i]
        
if len(ieven) == 3 or len(iodd) == 3:
    abc.sort()
    ans = (abc[2]-abc[1])//2 + (abc[2]-abc[0])//2
else:
    if len(ieven) > len(iodd):
        abc[ieven[0]] += 1
        abc[ieven[1]] += 1
        abc.sort()
        ans = 1 + (abc[2]-abc[1])//2 + (abc[2]-abc[0])//2
    else:
        abc[iodd[0]] += 1
        abc[iodd[1]] += 1
        abc.sort()
        ans = 1 + (abc[2]-abc[1])//2 + (abc[2]-abc[0])//2
        
print(ans)

Submission status: Accepted

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    a = f()
    a = sorted(a, reverse = True)

    b = a[0] - a[1] #xiao
    c = a[0] - a[2] #da


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




solve()

Submission status: Accepted

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

Submission status: Accepted

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

x.sort()

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

import math
tmp = []

def inc(i, j):
    if i % 2 == j % 2:
        return int((j - i) / 2)
    else:
        return int(math.ceil((j - i) / 2) + 1)

# target: a
tmp.append(c - a + b - a)

# target: b
tmp.append(inc(a, b) + c - b)

# target: c
tmp.append(inc(a, c) + inc(b, c))

print(min(tmp))

Submission status: Accepted

Solution code:
nums = sorted(list(map(int,input().split())))
group1 = []
group2 = []
ans = 0
for i in range(3):
 if nums[i] % 2==0:
     group1.append(i)
 else:
     group2.append(i)
max_len = max(len(group1),len(group2))
if max_len != 3:
    ans += 1
    if len(group1) == 2:
        for i in group1:
            nums[i] += 1
    else:
        for i in group2:
            nums[i] += 1
ans += (nums[2]-nums[0])//2 + (nums[2]-nums[1])//2
print(ans)

Submission status: Accepted

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

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

counter = 0
while (l[0] != l[1]) or (l[1] != l[2]):
    mi = min(l)
    ma = max(l)
    
    if ma - mi < 2:
        c = len([v for v in l if v == mi])
        if c == 2:
            counter += 1
        else:
            counter += 2
        break
    else:
        counter += (ma - mi) // 2
        for i in range(3):
            if l[i] == mi:
                l[i] += (ma - mi) // 2 * 2
                break
    
print(counter)

Submission status: Accepted

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

for i in a:
    if i%2 == 0:
        temp.append(0)
    else:
        temp.append(1)
        
if temp.count(1) == 2:
    for i in range(len(a)):
        if temp[i] == 1:
            a[i] += 1
    ans +=1
elif temp.count(0) == 2:
    for i in range(len(a)):
        if temp[i] == 0:
            a[i] += 1
    ans +=1

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

print(ans)

Submission status: Accepted

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

m = max(a)
s = sum(a)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:


def read_input():
    a, b, c = map(int, input().split())
    return a, b, c


def submit():
    a, b, c = read_input()

    top = max(a, b, c)
    buttom = min(a, b, c)
    mid = a + b + c - top - buttom

    ones = top - mid
    doubles = (top - (buttom + ones)) // 2

    if (top - (buttom + ones)) % 2 == 0:
        print(ones + doubles)
    else:
        print(ones + doubles + 2)

if __name__ == '__main__':
    submit()

Submission status: Accepted

Solution code:
from math import ceil
A, B, C = map(int, input().split())
ABC = [A, B, C]
big = max(ABC)
smal = min(ABC)
mid = sum(ABC) - big - smal

ans = big - mid
smal += ans
if (big - smal) % 2 == 0:
    ans += (big - smal) / 2
else:
    ans += (big - smal) / 2 + 1.5
print(int(ans))

Submission status: Accepted

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

F = [
    lambda x:x,
    lambda x:[x[0]+1,x[1]+1,x[2]  ],
    lambda x:[x[0]  ,x[1]+1,x[2]+1],
    lambda x:[x[0]+1,x[1]  ,x[2]+1],
    lambda x:[x[0]+2,x[1]+1,x[2]+1],
    lambda x:[x[0]+1,x[1]+2,x[2]+1],
    lambda x:[x[0]+1,x[1]+1,x[2]+2]
    ]

T = [0,1,1,1,2,2,2]

o = []
for i in range(7):
    f = F[i]
    r = sorted(f([A,B,C]))
    if (r[2] - r[0])%2:
        continue
    if (r[2] - r[1])%2:
        continue
    o.append(T[i]+(r[2]-r[0])//2+(r[2]-r[1])//2)

print(min(o))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
li = [int(x) for x in input().split()]
ans = 0
bar = 0
odd = []
for ind,i in enumerate(li):
    bar+=i%2
    if(i%2==1):
        odd.append(ind)
if(bar == 0 or bar == 3):
    ans = 0
elif(bar == 1):
    for ind,i in enumerate(li):
        if(not ind in odd):
            li[ind]+=1
    ans = 1
else:
    for ind,i in enumerate(li):
        if(ind in odd):
            li[ind]+=1
    ans = 1
li.sort()
ans += (2*li[2]-li[0]-li[1])//2
print(ans)

Submission status: Accepted

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

L.sort(reverse = True)
d0 = L[0]%2
d1 = L[1]%2
d2 = L[2]%2

S = 2*L[0]-L[1]-L[2]

if d1==d2:
    print(int(S/2))

else:
    print(int((S+1)/2+1))

Submission status: Accepted

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

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

count += c - b

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
ABC = list(map(int, input().split()))
max_num = max(ABC)
abs_list = [abs(max_num-i) for i in ABC]
if sum(abs_list) % 2 == 0:
        res = int(sum(abs_list) / 2)
else:
        res = int((sum(abs_list)) / 2) + 2

print(res)

Submission status: Accepted

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

tmp = 0
def calc(ABC, tmp):
        max_num = max(ABC)
        abs_list = [abs(max_num-i) for i in ABC]
        if all(i % 2 == 0 for i in abs_list):
                return int(sum(abs_list) / 2) + tmp
        else:
                cnt = 0
                for i, v in enumerate(abs_list):
                        if v % 2 == 0:
                                continue
                        else:
                                ABC[i] += 1
                                cnt += 1
                if cnt <= 1:
                        for i, v in enumerate(ABC):
                                if max_num == v:
                                        ABC[i] += 1
                                        break
                return calc(ABC, tmp+1)


                        

print(calc(ABC, 0))

Submission status: Accepted

Solution code:
#093 C

a =[int(j) for j in input().split()]
a.sort()
if abs(a[0]-a[1])%2==0 and abs(a[2]-a[1])%2==0 and abs(a[2]-a[0])%2==0:
    cnt=0
    cnt+=(a[2]-a[1])//2 +(a[2]-a[0])//2
    
elif abs(a[0]-a[1])%2==0:
    cnt=1
    cnt+=(a[2]-a[1])//2 +(a[2]-a[0])//2

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

Submission status: Accepted

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

Submission status: Accepted

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

hoge.sort()

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

Submission status: Accepted

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

count = 0
oe = [A%2, B%2, C%2]

if sum(oe) == 2:
    count += 1
    if A%2 == 0:
        B += 1
        C += 1
    elif B%2 == 0:
        A += 1
        C += 1
    else:
        A += 1
        B += 1
elif sum(oe) == 1:
    count += 1
    if A%2 == 1:
        B += 1
        C += 1
    elif B%2 == 1:
        A += 1
        C += 1
    else:
        A += 1
        B += 1
lst = sorted([A, B, C])
count += int((lst[1] - lst[0]) / 2)
count += int(lst[2] - lst[1])
print(count)

Submission status: Accepted

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

if x[2] % 2 == x[1] % 2 == x[0] % 2:
  ans = (x[2] - x[1]) // 2 + (x[2] - x[0]) // 2
elif (x[2] % 2 == x[1] % 2 and x[2] % 2 != x[0] % 2) or (x[2] % 2 == x[0] % 2 and x[2] % 2 != x[1] % 2):
  ans = (x[2] - x[1]) // 2 + (x[2] - x[0]) // 2 + 2
else:
  ans = (x[2] - x[1]) // 2 + (x[2] - x[0]) // 2 + 1
  
print(ans)

Submission status: Accepted

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

max = max([A,B,C])
dif_sum = 3*max -A-B-C

cnt=0
if dif_sum % 2 == 0:
    cnt = dif_sum / 2
else:
    cnt = (dif_sum+1) / 2
    cnt += 1
print(int(cnt))

Submission status: Accepted

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

def get_num(n,x):
    if n>=x:
        return n-x
    else:
        return (x-n+1)//2 + (x-n)%2
ans = 10**9
for x in range(min(A,B,C),max(A,B,C)+2):
    ans = min(ans,get_num(A,x)+get_num(B,x)+get_num(C,x))
print(ans)

Submission status: Accepted

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

X = max(A, B, C)
K = A + B + C

if (3*X - K) % 2:
    print((3*(X+1) - K) // 2)
else:
    print((3*X - K) // 2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

if A%2 == B%2 == C%2:
    ans = (3*Max-A-B-C) // 2
else:
    ABC = [A, B, C]
    ABC.sort()
    A, B, C = ABC[0], ABC[1], ABC[2]
    if A % 2 == B % 2:
        ans = (2*C-A-B-2) // 2 + 1
    else:
        ans = (2*(C+1)-A-B-1) // 2 + 1
print(ans)

Submission status: Accepted

Solution code:
a=list(map(int,input().split()))
b=sum(a)
if b%2>0:
  if max(a)%2>0:
    g=max(a)
  else:
    g=max(a)+1
else:
  if max(a)%2>0:
    g=max(a)+1
  else:
    g=max(a)
print((g*3-b)//2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=[int(i) for i in input().split()]
N.sort()
a=N[0]
b=N[1]
c=N[2]
count=0
if (b-a)%2!=0:
  b+=1
  c+=1
  count=1
print(c-b+(b-a)//2+count)

Submission status: Accepted

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

Submission status: Accepted

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