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

Solution (Python):
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()

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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(ret)

Solution (Python):
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())

Solution (Python):
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

Solution (Python):
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()

Solution (Python):
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))

Solution (Python):
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:
		
		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)

Solution (Python):
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

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):

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

Solution (Python):
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)

Solution (Python):
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))

Solution (Python):
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)

Solution (Python):
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

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

cnt = 0

f_a = a
f_b = b
f_c = c

while(a%2==0 and b%2==0 and c%2==0):
    t_a = a
    t_b = b
    t_c = c
    a = (t_b+t_c)/2
    b = (t_c+t_a)/2
    c = (t_a+t_b)/2
    cnt += 1
    if (a == f_a and b == f_b and c == f_c):
        cnt = -1
        break


print(cnt)

Solution (Python):
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()

Solution (Python):

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)

Solution (Python):

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
    
    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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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

Solution (Python):
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)

Solution (Python):


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)

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


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")

Solution (Python):
from collections import *
from contextlib import *
from functools import *
from itertools import *

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





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)

Solution (Python):
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)

Solution (Python):
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

Solution (Python):
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

Solution (Python):
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)

Solution (Python):
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

Solution (Python):


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

Solution (Python):


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()

Solution (Python):
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

Solution (Python):
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

Solution (Python):



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))

Solution (Python):
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

Solution (Python):
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

Solution (Python):
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)

Solution (Python):


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)

Solution (Python):
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

Solution (Python):
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

Solution (Python):
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)

Solution (Python):
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

Solution (Python):
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())