Problem:


Score : 300 points

Problem Statement

Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:

Each person simultaneously divides his cookies in half and gives one half to each of the other two persons.

This action will be repeated until there is a person with odd number of cookies in hand.

How many times will they repeat this action?
Note that the answer may not be finite.

Constraints

1 ≤ A,B,C ≤ 10^9

Input

Input is given from Standard Input in the following format:

A B C

Output

Print the number of times the action will be performed by the three people, if this number is finite.
If it is infinite, print -1 instead.

Sample Input 1

4 12 20

Sample Output 1

3

Initially, Takahashi, Aoki and Snuke have 4, 12 and 20 cookies. Then,

After the first action, they have 16, 12 and 8.

After the second action, they have 10, 12 and 14.

After the third action, they have 13, 12 and 11.

Now, Takahashi and Snuke have odd number of cookies, and therefore the answer is 3.

Sample Input 2

14 14 14

Sample Output 2

-1

Sample Input 3

454 414 444

Sample Output 3

1



Sample input:
4 12 20


Sample output:
3

Submission status: Accepted

Solution code:
import copy

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

ABC.sort()
ABC0=copy.deepcopy(ABC)


def check(x_list):
    sum=0
    for i in x_list:
        sum+=(i%2)
    if sum>0:
        return False
    else:
        return True

def ido(x_list):
    new_list=[x/2 for x in x_list]
    r_list=[]
    for i in range(3):
        r_list.append(new_list[i%3]+new_list[(i+1)%3])
    r_list.sort()
    return r_list

    
count =0    

while check(ABC0):
    ABC0=ido(ABC0)
    count+=1
    if ABC==ABC0:
        count=-1
        break
print(count)

Submission status: Accepted

Solution code:
a,b,c=map(int,raw_input().split())
z=0
if a%2==1 or b%2==1 or c%2==1:
    z=0
else:
 while a!=b or b!=c or a!=c:
    l=[a,b,c]
    l.sort()
    if a%2==1 or b%2==1 or c%2==1:
        break
    else:
        an=b/2+c/2
        bn=a/2+c/2
        cn=a/2+b/2
        ln=[an,bn,cn]
        ln.sort()
        if ln==l:
            z=-1
            break
        else:
            a,b,c=ln
            z+=1
 if a==b and a==c:
    z=-1
print z

Submission status: Accepted

Solution code:
### A - Cookie Exchanges
a = [ int(i) for i in input().split() ]

cnt=0
if a[0] % 2 == 1 or a[1] % 2 == 1 or a[2] % 2 == 1:
    pass
elif a[0] == a[1] and a[1] == a[2]:
    cnt=-1
else:
    while True:
        if a[0] % 2 == 1 or a[1] % 2 == 1 or a[2] % 2 == 1: break
        cnt += 1
        a[0], a[1], a[2] = (a[1]+a[2])/2 , (a[0]+a[2])/2, (a[0]+a[1])/2

print(cnt)

Submission status: Accepted

Solution code:
A1,B1,C1=list(map(int,input().split()))
ki=0
A=A1
B=B1
C=C1
while A%2==0 and B%2==0 and C%2==0:
    ki+=1
    ka=A
    kb=B
    A=(B+C)/2
    B=(ka+C)/2
    C=(ka+kb)/2
    if A==A1 and B==B1 and C==C1:
        ki=-1
        A=1
print(ki)

Submission status: Accepted

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

init = [A, B, C]
current = [A, B, C]

if A & 1 or B & 1 or C & 1:
    print(0)
elif (A == B and B == C):
    print(-1)
else:
    answer = 0
    while True:
        answer += 1
        a = current[0] / 2
        b = current[1] / 2
        c = current[2] / 2
        current = [b + c, a + c, b + c]
        if current[0]&1 or current[1]&1 or current[2]&1:
            break
    print(answer)

Submission status: Accepted

Solution code:
from enum import Enum


class Judge(Enum):
    OK        = 1
    END_ODD   = 2
    END_INF   = 3


def judge_cookie(X):
    if X % 2 == 0:
        result = True
    else:
        result = False

    return result


def devide_cookie(X):
    return X//2


def exchange_cookie(A, B, C):
    if judge_cookie(A) and judge_cookie(B) and judge_cookie(C):
        # OK
        AA = devide_cookie(B) + devide_cookie(C)
        BB = devide_cookie(A) + devide_cookie(C)
        CC = devide_cookie(A) + devide_cookie(B)

        if A == AA and B == BB and C == CC:
            result = Judge.END_INF
        else:
            result = Judge.OK

    else:
        # NG
        AA = BB = CC = 0
        result = Judge.END_ODD

    return result, AA, BB, CC


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

Count = 0
while True:
    J, AA, BB, CC = exchange_cookie(A, B, C)
    if J == Judge.OK:
        Count += 1
        A = AA
        B = BB
        C = CC
    elif J == Judge.END_INF:
        Ans = -1
        break
    else:
        Ans = Count
        break

print(Ans)

Submission status: Accepted

Solution code:
def sort(n1, n2, n3):
	n=[n1, n2, n3]
	t=len(n)
	for i in range(t-1):
		for j in range(i+1, t):
			if n[i] > n[j]:
				n[i],n[j] = n[j],n[i]
	return n

if __name__ == '__main__':
	A, B, C=map(int, input().split())
	N=0
	arr=[]
	flag=1
	if(A%2==1 or B%2==1 or C%2==1):
		flag=0

	while(flag):
		A, B, C = sort(A,B,C)
		arr.append([A,B,C])
		sum = A+B+C
		A=(sum-A)/2
		B=(sum-B)/2
		C=(sum-C)/2
		N+=1
		if(A%2==1 or B%2==1 or C%2==1):
			flag=0
		for i in range(len(arr)-1):
			if(arr[i] == [A,B,C]):
				flag = 0
				N=-1
	print(N)

Submission status: Accepted

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

count = 0
while num[0]%2==0 and num[1]%2==0 and num[2]%2==0:
    a = num[0]//2
    b = num[1]//2
    c = num[2]//2

    num[0] = b + c
    num[1] = c + a
    num[2] = a + b
    num.sort()

    if num == first_num:
        count = -1
        break
    else:
        count += 1

print(count)

Submission status: Accepted

Solution code:
def gcd(a, b):
	while b % a:
		b %= a
		a, b = (b, a)
	return a

C = [int(i) for i in input().split()]
m = min(C)
for i in range(3):
	if C[i]%2:
		print(0)
		exit()
	C[i] -= m

C.sort()
if C[2] == 0:
	print(-1)
	exit()
t = C[2]
for c in C:
	t = gcd(t, c)
ans = 0
while not t%2:
	ans += 1
	t //= 2
print(ans)

Submission status: Accepted

Solution code:

def dot_v(a,b):
    sum=0
    for i in range(len(a)):
        sum+=a[i]*b[i]
    return sum

def dot(A,x):
    xx=[0]*len(x)
    for i in range(len(A)):
        xx[i]=dot_v(A[i],x)

    return xx


x=list(map(int,input().split(" ")))
A=[[0,0.5,0.5],[0.5,0,0.5],[0.5,0.5,0]]
count=0
flg=False
equal=False
for i in range(10**6):
    if x[0]==x[1] and x[1]==x[2]:
        if x[0]%2==0:
            equal=True
            break
    for sx in x:
        if (sx%2)!=0:
            flg=True
            break
    if flg:
        break
    count+=1
    x=dot(A,x)
    #print(x)
    if i==10**6-1:
        equal=True


if equal:
    print(-1)
else:
    print(count)

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
a = [0]
b = [0]
c = [0]
i = 0
flag = 0

a[0] = A
b[0] = B
c[0] = C

if A == B and B == C and A % 2 == 0:
	print(-1)
else:
	while flag == 0:
		if a[i] % 2 == 0 and b[i] % 2 == 0 and c[i] % 2 == 0:
			x = (b[i] + c[i]) / 2
			y = (a[i] + c[i]) / 2
			z = (b[i] + a[i]) / 2
			a.append(x)
			b.append(y)
			c.append(z)
			i += 1
		else:
			flag = 1
	print(i)

Submission status: Accepted

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

    a = A
    b = B
    c = C
    i = 0
    while True:
        if a % 2 > 0 or b % 2 > 0 or c % 2 > 0:
            break
        elif A == B == C:
            i = -1
            break
        else:
            now_a = (b + c) / 2
            now_b = (a + c) / 2
            now_c = (a + b) / 2
            a = now_a
            b = now_b
            c = now_c
            i += 1
    print(i)

main()

Submission status: Accepted

Solution code:
def solve(a, b, c):
    memo = set()

    cnt = 0
    while all(x % 2 == 0 for x in (a, b, c)):
        if (a, b, c) in memo: return -1
        memo.add((a, b, c))

        t = a + b + c
        a, b, c = ((t - x) // 2 for x in (a, b, c))
        cnt += 1

    return cnt


if __name__ == '__main__':
    ht = {}

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

Submission status: Accepted

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

if A % 2 != 0 or B % 2 != 0 or C % 2 != 0:
    print(0)
    exit()


def check(n):
    x = 2 ** n
    y = x // 3
    if x % 3 == 1:
        for i in range(3):
            adds = [y] * 3
            adds[i] += 1
            tmp = (A * adds[0] + B * adds[1] + C * adds[2]) / x
            if int(tmp) != tmp:
                return False
    else:
        for i in range(3):
            adds = [y] * 3
            adds[i] += 1
            adds[(i + 1) % 3] += 1
            tmp = (A * adds[0] + B * adds[1] + C * adds[2]) / x
            if int(tmp) != tmp:
                return False
    return True


for i in range(1, 1000):
    if not check(i):
        print(i - 1)
        exit()
print(-1)

Submission status: Accepted

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

if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
    print '0'
elif A == B and B == C:
    print '-1'
else:
    i = 0
    while True:
        _A = (B + C)/2
        _B = (C + A)/2
        _C = (A + B)/2

        A = _A
        B = _B
        C = _C

        i += 1
        if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
            print '%d' % i
            break

Submission status: Accepted

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

cnt = 0
while cnt < 27:
    if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
        break
    tmpA = int(B / 2) + int(C / 2)
    tmpB = int(A / 2) + int(C / 2)
    tmpC = int(A / 2) + int(B / 2)

    cnt += 1
    if tmpA == A and tmpB == B and tmpC == C:
        print("-1")
        quit()
    A = tmpA
    B = tmpB
    C = tmpC

if cnt == 28:
    print("-1")
else:
    print(str(cnt))

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
def cookies(a, b, c):
    return [(b+c)/2, (c+a)/2, (a+b)/2]

if A == B and B == C and (A%2) == 0:
    print('-1')
else:
    count = 0
    while True:
        if (A%2) or (B%2) or (C%2):
            break
        A, B, C = cookies(A, B, C)
        count += 1
    print(count)

Submission status: Accepted

Solution code:
# coding: utf-8

a, b, c = map(int, raw_input().split())
cnt = 0

if a == b and b == c:
    if a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
        print -1
    else:
        print 0
    exit()

while True:
    if a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
        cnt += 1
        a_t = a / 2
        b_t = b / 2
        c_t = c / 2
        a = b_t + c_t
        b = a_t + c_t
        c = a_t + b_t
    else:
        break

print cnt

Submission status: Accepted

Solution code:
import sys

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

    if (a & 1) or (b & 1) or (c & 1):
        print(0)
        return

    if a == b and b == c:
        print(-1)
        return

    cnt = 0

    while True:
        if (a & 1) or (b & 1) or (c & 1):
            print(cnt)
            return

        a, b, c = (b + c) >> 1, (a + c) >> 1, (a + b) >> 1
        cnt += 1

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
A, B, C = list(map(int, input().split()))
count = 0
while True:
	if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
		break
	else:
		AA = int((B + C) / 2)
		BB = int((C + A) / 2)
		CC = int((A + B) / 2)
		if AA == BB and BB == CC:
			count = -1
			break
		else:
			A = AA
			B = BB
			C = CC
			count += 1
print(count)

Submission status: Accepted

Solution code:
A,B,C = list(map(int,input().split()))
count = 0
while A%2==0 and B%2==0 and C%2==0:
	_A = A//2
	_B = B//2
	_C = C//2
	A = _B + _C
	B = _A + _C
	C = _A + _B
	if A == B and B == C:
		print(-1)
		quit()
	count += 1
print(count)

Submission status: Accepted

Solution code:
def even(n: int) -> bool:
    return n % 2 == 0


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

if (A == B == C) and (even(A) and even(B) and even(C)):
    print(-1)
    exit(0)

ret = 0
while even(A) and even(B) and even(C):
    a, b, c = A, B, C
    ret += 1
    A = (b + c) / 2
    B = (a + c) / 2
    C = (a + b) / 2
    # print(A, B, C)

print(ret)

Submission status: Accepted

Solution code:
def main():
    a, b, c = [int(_) for _ in raw_input().split()]
    if a == b == c:
        if a & 1:
            return 0
        return -1

    ans = 0
    while True:
        if a & 1 or b & 1 or c & 1:
            return ans
        a, b, c = (b + c) / 2, (c + a) / 2, (a + b) / 2
        ans += 1

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

Submission status: Accepted

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

if A==B and B==C:
    if A%2==0 and B%2==0 and C%2==0:
        print -1
    else:
        print 0
else:
    for i in range(1000):
        if A%2==1 or B%2==1 or C%2==1:
            print i
            break
        newA = B/2 + C/2
        newB = C/2 + A/2
        newC = A/2 + B/2
        A = newA
        B = newB
        C = newC

Submission status: Accepted

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

    seen = set()
    ans = 0
    while all(x % 2 == 0 for x in (a, b, c)):
        if (a, b, c) in seen:
            ans = -1
            break

        seen.add((a, b, c))
        a, b, c = b // 2 + c // 2, a // 2 + c // 2, a // 2 + b // 2
        ans += 1

    print(ans)

main()

Submission status: Accepted

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

pattern = list()
i = 0
while True:
    if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
        print(i)
        break
    tmp_A = A
    tmp_B = B
    A = (B + C) / 2
    B = (C + tmp_A) / 2
    C = (tmp_B + tmp_A) / 2

    i += 1

    if (A, B, C) in pattern:
        print(-1)
        break
    pattern.append((A, B, C))

Submission status: Accepted

Solution code:
import copy
temp=input().split()
A=int(temp[0])
B=int(temp[1])
C=int(temp[2])

setT=[A,B,C]
setT.sort()
allSet=[]
allSet.append(setT)
ans=0
def distribute(x,y,z):
	temp=[y+z,z+x,x+y]
	for i in range(len(temp)):
		if temp[i]%4==0:
			temp[i]/=2
		else:
			return [0]
	return temp

setNext=copy.deepcopy(setT)
for i in setT:
	if i%2==1:
		break
else:
	setNext=distribute(setT[0],setT[1],setT[2])
	ans+=1
	while len(setNext)==3:
		#print(setNext)
		ans+=1
		setT=copy.deepcopy(setNext)
		setNext=distribute(setT[0],setT[1],setT[2])
		setNext.sort()
		if setNext in allSet:
			ans=-1
			break
		else:
			allSet.append(setNext)
print(ans)

Submission status: Accepted

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

for i in range(100000000):
    
    if A%2!=0 or B%2!=0 or C%2!=0:
        print(counter)
        break
    if A==B and B==C:
        print('-1')
        break
    
    AA=B/2+C/2
    BB=A/2+C/2
    CC=A/2+B/2
    counter=counter+1
    if AA%2!=0 or BB%2!=0 or CC%2!=0:
        print(counter)
        break
    A=AA
    B=BB
    C=CC

Submission status: Accepted

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

count=0
while True:
    if a%2==0 and b%2==0 and c%2==0: pass
    else: break
    if a==b==c: count=-1; break
    a,b,c=b//2+c//2,c//2+a//2,a//2+b//2
    count+=1

print(count)

Submission status: Accepted

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


def is_even(a, b, c):
    if a % 2 != 0:
        return False
    if b % 2 != 0:
        return False
    if c % 2 != 0:
        return False
    return True

count = 0
rem = []

flag = True

while is_even(a, b, c) and flag:
    a, b, c = (b + c) / 2, (a + c) / 2, (a + b) / 2
    count += 1
    if (a, b, c) in rem:
        print("-1")
        flag = False
        break
    rem.append((a, b, c))


if flag is True:
    print(count)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
# 整数の入力
A, B, C= map(int, input().split())
# 出力
if A==B and B==C:
 if A%2 ==0 and B%2==0 and C%2==0:
  print(-1)
  sys.exit()
count=0
while True:
 if A%2 ==1 or B%2==1 or C%2==1:
  print(count)
  sys.exit()
 else:
  A_a=B/2+C/2
  B_a=A/2+C/2
  C_a=A/2+B/2
  A=A_a
  B=B_a
  C=C_a
  count+=1

Submission status: Accepted

Solution code:
store = [int(i) for i in input().split()]
sum_store = sum(store)
store = [store]
while True:
    if any([i%2 for i in store[-1]]):
        print(len(store)-1)
        break
    else:
        new_store = [(sum_store - i ) //2 for i in store[-1]]
        if new_store in store:
            print(-1)
            break
        store.append(new_store)

Submission status: Accepted

Solution code:
def cookies_exchanges(a, b, c):
    counter = 0

    olds = []
    while int(a%2) is 0 and int(b%2) is 0 and int(c%2) is 0:
        if (a, b, c) in olds:
            return -1

        olds.append((a,b,c))
        o_a, o_b, o_c = olds[counter]
        a = o_b/2 + o_c/2
        b = o_a/2 + o_c/2
        c = o_a/2 + o_b/2
        counter += 1

    return counter

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

Submission status: Accepted

Solution code:
def exchange(_A, _B, _C, _count):
    if _A % 2 == 1 or _B % 2 == 1 or _C % 2 == 1:
        return _count

    _count += 1
    tmp1 = _A / 2
    tmp2 = _B / 2
    tmp3 = _C / 2
    return exchange(tmp2 + tmp3, tmp1 + tmp3, tmp1 + tmp2, _count)


A, B, C = list(map(int, input().split()))
if A % 2 == 0 and A == B and B == C:
    print("-1")
else:
    count = 0
    ans = exchange(A, B, C, count)

    print(ans)

Submission status: Accepted

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

result = 0
for i in range(100):
    if a & 1 or b & 1 or c & 1:
        print(result)
        break
    a, b, c = (b + c) // 2, (a + c) // 2, (a + b) // 2
    if a == ca and b == cb and c == cc:
        print(-1)
        break
    result += 1

Submission status: Accepted

Solution code:
def main():
    a, b, c = map(int, input().split())
    if a == b == c:
        print(0 if a & 1 else -1)
        return
    count = 0
    while (a | b | c) & 1 == 0:
        a, b, c = (b + c) >> 1, (c + a) >> 1, (a + b) >> 1
        count += 1
    
    print(count)
 
main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys

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

history = {}
result = 0

while A%2 == 0 and B%2 == 0 and C%2 == 0:
    key = " ".join(map(str,[A,B,C]))
    if key in history:
        result=-1
        break
    history[key] = 1
    a = (B+C)//2
    b = (A+C)//2
    c = (A+B)//2
    A = a
    B = b
    C = c

    result = result +1

print(result)

Submission status: Accepted

Solution code:
#! -*- coding:utf-8 -*-
a,b,c = map(int,input().split())

count = 0
flag = 0
while True:
    at = (b+c)/2
    bt = (a+c)/2
    ct = (b+a)/2

    if flag == 0 and (a % 2 == 1 or b % 2 == 1 or c % 2 == 1):
        flag = 1
        break
    if flag == 1 and at == a and bt == b and ct == c:
        flag = 0
        break
    
    a = at
    b = bt
    c = ct
    #print(a,b,c)
    count += 1
    flag = 1
    if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
        break

if flag == 0:
    print(-1)
else:
    print(count)

Submission status: Accepted

Solution code:
a,b,c = map(int,input().split())
i = 0
flag = 0
while a % 2 == b % 2 == c % 2 == 0:
	if a == b == c:
		print(-1)
		flag = 1
		break
	i = i + 1
	a2 = b // 2 + c // 2
	b2 = c // 2 + a // 2
	c2 = a // 2 + b // 2
	a,b,c = a2,b2,c2
if flag == 0:
	print(i)

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
ans = 0
if A == B and B == C and A % 2 == 0:
    ans = -1
else:
    while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
        ans += 1
        AA, BB, CC = A // 2, B // 2, C // 2
        A = BB + CC
        B = CC + AA
        C = AA + BB
print(ans)

Submission status: Accepted

Solution code:
a,b,c = map(int,input().split())
count = 0
while 1:
    if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
        print(count)
        break
    if a == b and b == c:
        print(-1)
        break
    
    a_a = b / 2 + c / 2
    b_a = a / 2 + c / 2
    c_a = a / 2 + b / 2
    a = a_a
    b = b_a
    c = c_a
    count = count + 1

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
dict = {}
ans = 0
while ans < 1000000:
    tpl = tuple(sorted([A, B, C]))
    if tpl in dict:
        ans = -1
        break
    elif A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
        break
    dict[tpl] = True
    A, B, C = (B + C) // 2, (C + A) // 2, (A + B) // 2
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys
import os

A, B, C = map(int, input().split())
last_list = sorted([A, B, C])

swap_num = 0
while True:
    if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
        break

    A_temp = B // 2 + C // 2
    B_temp = A // 2 + C // 2
    C_temp = A // 2 + B // 2

    A = A_temp
    B = B_temp
    C = C_temp

    swap_num += 1

    current_list = sorted([A, B, C])
    if last_list == current_list:
        print(-1)
        exit()
print(swap_num)

Submission status: Accepted

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

def foo(A,B,C):
	return((B+C)//2,(A+C)//2,(A+B)//2)

c = 0
for i in range(10**6):
	if A%2 == 0 and B%2 == 0 and C%2 == 0:
		A,B,C = foo(A,B,C)
		c+=1
	else:
		print(c)
		break
else:
	print("-1")

Submission status: Accepted

Solution code:
from collections import *
from contextlib import *
from functools import *
from itertools import *

a,b,c = [int(x) for x in input().strip().split()]

#if a%4 == b%4 and a%4 == c%4:
#    print(-1)
#    raise SystemExit

n = 0
while 1:
    if a%2 or b%2 or c%2:
        break
    a, b, c = (b+c)//2, (c+a)//2, (a+b)//2
    n += 1
    if n > 10000:
        print(-1)
        raise SystemExit
print(n)

Submission status: Accepted

Solution code:
A,B,C=list(map(int,input().split()))
prev_set=set([A,B,C])
count=0
while True:
    if A%2!=0 or B%2!=0 or C%2!=0:break
    nA=int(0.5*(B+C))
    nB=int(0.5*(A+C))
    nC=int(0.5*(A+B))
    new_set=set([nA,nB,nC])
    if prev_set==new_set:
        count=-1
        break
    A=nA;B=nB;C=nC
    count+=1
print(count)

Submission status: Accepted

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

S = set()
S.add(tuple(sorted([A,B,C])))

cnt = 0
while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
    a = B/2 + C/2
    b = C/2 + A/2
    c = A/2 + B/2
    A, B, C = a, b, c
    cnt += 1
    if tuple(sorted([A, B, C])) in S:
        print -1
        exit()
print cnt

Submission status: Accepted

Solution code:
a, b, c = map(int, raw_input().split())
s = a + b + c
if a % 2 == 1 or b % 2 == 1or c % 2 == 1:
    print 0
    exit()

mem = set()
ans = 0
while True:
    a, b, c = sorted((a, b, c))
    if a % 2 == 1 or b % 2 == 1or c % 2 == 1:
        break
    if (a, b, c) in mem:
        print -1
        exit()
    mem.add((a, b, c))
    na = b / 2 + c / 2
    nb = a / 2 + c / 2
    nc = a / 2 + b / 2
    a, b, c = na, nb, nc
    ans += 1
print ans

Submission status: Accepted

Solution code:
a,b,c = list(map(int, input().split()))
a_init = a
b_init = b
c_init = c
a_temp = 0
b_temp = 0
c_temp = 0
count = 0
while a % 2 != 1 and b % 2 != 1 and c % 2 != 1:
    a_temp = a/2
    b_temp = b/2
    c_temp = c/2
    a = b_temp + c_temp
    b = c_temp + a_temp
    c = a_temp + b_temp
    count+= 1
    if a ==a_init and b == b_init and c == c_init:
        count = -1
        break
print(count)

Submission status: Accepted

Solution code:
A,B,C=map(int,raw_input().split());
i=0
f=((A%2)==0)and((B%2)==0)and((C%2)==0)
while(f):
	da=A;db=B;dc=C
	A=(db+dc)/2
	B=(da+dc)/2
	C=(dc+da)/2
	i+=1
	f=((A%2)==0)and((B%2)==0)and((C%2)==0)
	if (da==A)and(db==B)and(dc==C):
		f=0
		i=-1
print i

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

A, B, C = map(int, raw_input().split())

ans = 0
while not (A%2 or B%2 or C%2 or A == B == C):
    A, B, C = (B + C)/2, (C + A)/2, (A + B)/2
    ans += 1
print ans if not A == B == C else -1 if A%2 == 0 else 0

Submission status: Accepted

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

import itertools


def solve(a, b, c):
    for i in itertools.count():
        da, ma = divmod(a, 2)
        db, mb = divmod(b, 2)
        dc, mc = divmod(c, 2)
        if ma == 1 or mb == 1 or mc == 1:
            return i
        elif a == b == c:
            return -1
        a = db + dc
        b = dc + da
        c = da + db


def main():
    a, b, c = (int(x) for x in input().split())
    print(solve(a, b, c))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a,b,c=map(int,raw_input().split())
if a%2==1 or b%2==1 or c%2==1:
    print 0
    exit()
if a==b==c:
    print -1
    exit()
tmpa=0;tmpb=0;tmpc=0;
ans=0
while 1:
    tmpa=b/2+c/2
    tmpb=a/2+c/2
    tmpc=a/2+b/2
    ans+=1
    if tmpa%2==1 or tmpb%2==1 or tmpc%2==1:
        break
    if tmpa==tmpb==tmpc:
        break
    a=tmpa;b=tmpb;c=tmpc;
print ans

Submission status: Accepted

Solution code:
a,b,c = map(int, raw_input().split())
ans = 0
while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
  newa = b/2 + c/2
  newb = a/2 + c/2
  newc = a/2 + b/2
  if a == b == c == newa == newb == newc:
    print '-1'
    exit()
  a = newa
  b = newb
  c = newc
  ans += 1

print ans

Submission status: Accepted

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

from random import *
from functools import reduce,partial
from time import time
from pprint import pprint

def readln():
    return list(map(int,input().split(' ')))

def identity(x):
    """Return the input itself."""
    return x

def constant(c):
    """Return an function which always
    returns the input constant c."""
    def const_function(const,*args):
        return const
    return partial(const_function,c)

def inc(c = 1):
    """Return a function which reads an input x and returns x + c as output.
    By default, c equals 1."""
    return lambda x: x + c

def add(*args):
    """Return the sum of the input."""
    def add2(x,y): return x + y
    return reduce(add2,args)

def mapv(f,*lst):
    """Return a vector of the result of map."""
    return list(map(f,*lst))

def vector(*args):
    """Return a vector of input parameters."""
    return args

def sequence(n,f = constant(0)):
    """Return a vector of length n, and initialize the i'th
    item with f(i).By default the vector will initialized with 0."""
    return [f(i) for i in range(0,n)]

def matrix(n,m,f = constant(0)):
    """Return a 2-dim vector which contains n vectors with length m.
    The j's item of vector i will be initialized by f(i,j).By default,
    the vector will be initialized with 0."""
    return [[f(i,j) for j in range(0,m)] for i in range(0,n)]

def flat(v):
    """Return a flat vector which contains the elements of v in their
    origin order.If the input is not a vector, return a vector which
    only contains the input."""
    if not isinstance(v,list): return [v]
    if not v: return []
    return reduce(add,mapv(flat,v))

def partition(v,f = identity):
    """Partition vector v by f(v[i]).
    e.g. partition([1,2,3,1,2,3],identity()) == {1:[1,1,1], 2:[2,2], 3:[3]}
    By default, the vector will be partitioned by identity function."""
    result = {}
    for item in v:
        key = f(item)
        s = result.get(key)
        if s:
            s.append(item)
        else:
            result.update({key:[item]})
    return result

def getValue(key):
    """Return a function which returns the value of key in a hash-map.
    If the key do not exist, it will throw an error."""
    return lambda x: x[key]

def mapValue(f,m):
    """Replace each value in hash-map m with f(value).
    Return the new hash-map."""
    res = {}
    for key in m:
        res.update({key: f(m[key])})
    return res

p = 1000000000 + 7

def existOdd(a):
    for item in a:
        if item % 2 == 1:
            return True
    return False

def calc(a):
    ans = 0
    if existOdd(a): return 0
    if a[0] == a[1] and a[1] == a[2]:
        return -1
    while True:
        s = sum(a) >> 1
        b = [s - (item >> 1) for item in a]
        ans = ans + 1
        if existOdd(b):
            break
        else:
            a = b[:]
    return ans

a = readln()
print(calc(a))

Submission status: Accepted

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

def hoge(a, b, c):
    a, b, c = (b + c) / 2, (a + c) / 2, (a + b) / 2
    return a, b, c

for i in xrange(108000):
    if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
        print i
        exit()
    a, b, c = hoge(a, b, c)

print -1

Submission status: Accepted

Solution code:
A,B,C = map(int, raw_input().split())
ans = 0
for i in range(1000):
    if A%2!=0 or B%2!=0 or C%2!=0:
        break
    A,B,C = B/2+C/2,C/2+A/2,A/2+B/2
    ans += 1
print ans if ans < 1000 else -1

Submission status: Accepted

Solution code:
a,b,c = map(int, input().split())
cnt = 0
memo = set()
while a%2 == 0 and b%2 == 0 and c % 2 == 0:
    a, b, c = (b+c)//2, (a+c)//2, (b+c)//2
    if (a, b, c) in memo:
        print(-1)
        exit()
    else:
        memo.add((a,b,c))
    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
A,B,C = map(int, input().split())

cnt = 0
while A % 2 == B % 2 == C % 2 == 0:
    cnt += 1
    A, B, C = B // 2 + C // 2, A // 2 + C // 2, A //2 + B // 2
    if cnt == int(1e6):
        break
if cnt == 1e6:
    print(-1)
else:
    print(cnt)

Submission status: Accepted

Solution code:
a, b, c = map(int, raw_input().split())
for i in xrange(1000):
    if a %2 or b % 2 or c % 2:
        print i
        quit()
    a, b, c = b / 2 + c / 2, a / 2 + c / 2, a / 2 + b / 2
print -1

Submission status: Accepted

Solution code:
a, b, c = map(int, raw_input().split())
ans = 0
used = {(a, b, c)}
while a%2+b%2+c%2 == 0:
    a, b, c = b/2+c/2, c/2+a/2, a/2+b/2
    ans += 1
    if (a, b, c) in used:
        print -1
        break
    used.add((a, b, c))
else:
    print ans

Submission status: Accepted

Solution code:
a,b,c = list(map(int, input().split()))
ans = 0
while a % 2 == 0 and b % 2 == 0 and c % 2 == 0 and ans < 100000:
    a, b, c = (b + c) >> 1, (a + c) >> 1, (a + b) >> 1
    ans += 1
if ans < 100000:
    print(ans)
else:
    print(-1)

Submission status: Accepted

Solution code:
from sys import stdin
rr = lambda: stdin.readline().strip()
rrM = lambda: map(int, rr().split())

A,B,C = rrM()
ans = 0
while A%2==B%2==C%2==0 and ans < 10000:
    ans += 1
    A,B,C = sorted([(A+B)/2,(B+C)/2,(C+A)/2])

if ans == 10000: ans = -1
print ans

Submission status: Accepted

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

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
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 main():
    s = set()
    a = LI()
    i = 0
    while True:
        if a[0] % 2 == 1 or a[1] % 2 == 1 or a[2] % 2 == 1:
            return i
        i += 1
        k = tuple(a)
        if k in s:
            return -1
        s.add(k)
        a = [a[0]//2+a[1]//2, a[1]//2+a[2]//2, a[0]//2+a[2]//2]


print(main())

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
A,B,C =map(int,input().split())
con = 0
if A % 2 == 1 or B % 2 == 1 or C % 1 == 1:
  print(0)
  exit()
if A == B and B == C:
  print(-1)
  exit()
while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
  con += 1
  D = A / 2
  E = B / 2
  F = C / 2
  A = E + F
  B = D + F
  C = D + E
  
print(con)
A,B,C =map(int,input().split())
con = 0
if A % 2 == 1 or B % 2 == 1 or C % 1 == 0:
  print(0)
  exit()
if A == B and B == C:
  print(-1)
  exit()
while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
  con += 1
  D = A / 2
  E = B / 2
  F = C / 2
  A = E + F
  B = D + F
  C = D + E
  
print(con)