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:
A,B,C=map(int,input().split())

t=0
while(True):
    if(A%2==1 or B%2==1 or C%2==1) :
        break
    a=(A+B)/2
    b=(B+C)/2
    c=(C+A)/2
    if(A==a and B==b and C==c):
        print(-1)
        exit()
    A=a
    B=b
    C=c
    t+=1
print(t)

Submission status: Accepted

Solution code:
from sys import stdin

a,b,c = [int(x) for x in stdin.readline().rstrip().split()]
count = 0
num = 0

while True:
    if a%2 == 1 or b%2 == 1 or c%2 == 1:
        print(count)
        exit()
    elif a==b==c:
        print(-1)
        exit()
    else:
        a,b,c = b//2+c//2,c//2+a//2,a//2+b//2
        count += 1
    num += 1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c = map(int,input().split())
loop = [[a,b,c]]
count = 0
for i in range(200):
    if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
        break
    x = a // 2
    y = b // 2
    z = c // 2
    a = y + z
    b = x + z
    c = x + y
    count += 1
    if [a,b,c] in loop:
        count = -1 
        break
    loop.append([a,b,c])
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)

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

if a%2==0 and b%2==0 and c%2==0 and (a == b == c):
	print(-1)
	sys.exit()
cnt = 0
while True:
	if a%2==1 or b%2==1 or c%2==1:
		break
	a,b,c = (b+c)//2,(a+c)//2,(b+c)//2
	cnt += 1

print(cnt)

Submission status: Accepted

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

def all_even(a,b,c):
	if a%2 == 0 and b%2 == 0 and c%2 == 0:
		return True
	else:
		return False

cnt = 0

while all_even(A,B,C):
	if A == B == C:
		cnt = -1
		break
	cnt+=1
	A,B,C = (B+C)//2, (A+C)//2, (A+B)//2
	
print(cnt)

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
for i in range(100):
    if A%2 == 0 and B%2 == 0 and C%2 == 0:
        A, B, C = B+C>>1, C+A>>1, A+B>>1
    else:
        print(i)
        break
else:
    print(-1)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    a, b, c = LI()
    d = defaultdict(int)
    d[(a, b, c)] = 1
    ans = 0
    while 1:
        if a & 1 or b & 1 or c & 1: break
        a, b, c = (b + c) // 2, (a + c) // 2, (a + b) // 2
        ans += 1
        if d[(a, b, c)]:
            print(-1)
            return
        d[(a, b, c)] = 1
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
A,B,C = map(int,input().split())
if A%2==1 or B%2==1 or C%2==1:
    print(0)
elif A==B and A==C:
    print(-1)
else:
    a = 0
    while A%2==0:
        A //= 2
        a += 1
    b = 0
    while B%2==0:
        B //= 2
        b += 1
    c = 0
    while C%2==0:
        C //= 2
        c += 1
    cnt = min(a,b,c)
    if [a,b,c].count(cnt)<3:
        print(cnt)
    else:
        print(cnt+1)

Submission status: Accepted

Solution code:
A,B,C=map(int,input().split())
cnt=0
while True:
    if A % 2 == B % 2 == C % 2 == 1:
        break
    elif A==B==C:
        cnt-=1
        break
    elif A%2==B%2==C%2==0:
        hA=A//2
        hB=B//2
        hC=C//2
        A=hB+hC
        B=hA+hC
        C=hA+hB
        cnt+=1
    else:
        break

print(cnt)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	A = MAP()
	if A[0] % 2 or A[1] % 2 or A[2] % 2:
		print(0)
	elif A[0] == A[1] and A[0] == A[2]:
		print(-1)
	else:
		cnt = 0
		while all(a%2 == 0 for a in A):
			a = A[0]//2 + A[1]//2
			b = A[1]//2 + A[2]//2
			c = A[0]//2 + A[2]//2
			A[0] = a
			A[1] = b
			A[2] = c
			cnt += 1
			# A.sort()
			# print(A)

		print(cnt)

if __name__ == '__main__':
	main()

Submission status: Accepted

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

# 指数的に平均に収束する。よって適当な回数試せばよい

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

for t in range(500):
    if A&1 or B&1 or C&1:
        break
    A,B,C = A//2,B//2,C//2
    A,B,C = B+C,C+A,A+B

answer = t if t < 400 else -1
print(answer)

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
if a%2!=0 or b%2!=0 or c%2!=0:
    print(0)
else:
    a1=0
    a2=0
    a3=0
    c1=0
    c2=0
    c3=0
    ans=0
    for i in range(2*10**5):
        if a%2!=0:
            c1=1        
        if b%2!=0:
            c2=1        
        if c%2!=0:
            c3=1
        if c1==1 or c3==1 or c2==1:
            ans=i
            break
        else:
            a3=(a+b)//2
            a2=(a+c)//2
            a1=(b+c)//2
            a=a1
            b=a2
            c=a3
        #print(a,b,c)
        if i==199999:
            ans=-1
    print(ans)

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
for i in range(10**6):
  if a%2==1 or b%2==1 or c%2==1:
    print(i)
    exit()
  a,b,c=(b+c)//2,(c+a)//2,(a+b)//2
print(-1)

Submission status: Accepted

Solution code:
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    a, b, c = list(map(int, input().rstrip('\n').split()))
    if a == b == c:
        if a == b == c == 1:
            print(0)
        else:
            print(-1)
    else:
        if a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
            cnt = 0
            while True:
                if a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
                    cnt += 1
                    a, b, c = (b + c) // 2, (a + c) // 2, (a + b) // 2
                else:
                    break
            print(cnt)
        else:
            print(0)


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

a2,b2,c2 = a,b,c
cnt = 0
while True:
    if a2%2 or b2%2 or c2%2:
        print(cnt)
        exit()
    else:
        a = (b2+c2)//2
        b = (c2+a2)//2
        c = (a2+b2)//2
        
        cnt += 1
        if {a,b,c}=={a2,b2,c2}:
            print(-1)
            exit()
        a2 = a
        b2 = b
        c2 = c

Submission status: Accepted

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

if a == b == c and total % 2 == 0: 
    print(-1)
elif a == b == c and total % 2 == 1:
    print(0)
else:
    while True:
        a = (total - a)/2
        b = (total - b) /2
        c = (total - c) /2
        
        if a.is_integer() and b.is_integer() and c.is_integer():
            ct += 1
        else:
            break
        
    print(ct)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
A, B, C = map(int, input().split(' '))

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

ans = 0
while True:
    A, B, C = B // 2 + C // 2, A // 2 + C // 2, A // 2 + B // 2
    ans += 1

    if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
        break

    if ans > 50:
        ans = -1
        break
    # print(A, B, C)

print(ans)

Submission status: Accepted

Solution code:
from fractions import gcd
a,b,c=map(int,input().split())
if a%2 or b%2 or c%2:
  print(0)
  exit()
if a==b==c:
  print(-1)
  exit()
x=abs(a-b)
y=abs(b-c)
z=abs(c-a)
t=gcd(gcd(x,y),z)
for i in range(1,100):
  if t%2:
    print(i-1)
    break
  else:
    t=t//2

Submission status: Accepted

Solution code:
A, B, C = map(int, input().split())
dA, dB, dC = B - C, C - A, A - B
Ex = 0
if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
  Ex = 0
elif A == B and B == C:
  Ex = -1
else:
  while dA % 2 == 0 and dB % 2 == 0 and dC % 2 == 0:
    dA //= 2
    dB //= 2
    dC //= 2
    Ex += 1
print(Ex)

Submission status: Accepted

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

  print(ret)

Submission status: Accepted

Solution code:
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    a, b, c = list(map(int, readline().split()))
    if a == b == c:
        if a == b == c == 1:
            print(0)
        else:
            print(-1)
    else:
        cnt = 0
        while True:
            if a % 2 == b % 2 == c % 2 == 0:
                cnt += 1
                a, b, c = (b + c) // 2, (a + c) // 2, (a + b) // 2
            else:
                print(cnt)
                exit()


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(A: int, B: int, C: int):

    ans = 0
    while(A%2 == 0 and B%2 == 0 and C%2 == 0):
        oA, oB, oC = A, B, C
        A2, B2, C2 = A//2, B//2, C//2
        A = B2 + C2
        B = A2 + C2
        C = A2 + B2
        if A == oA and B == oB and C == oC:
            print('-1')
            exit()
        ans += 1

    print(ans)

    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:
A,B,C= map(int,input().split())
if A==B and B==C and A%2==0:
  print(-1)
else:
  ans = 0
  while A%2==0 and B%2==0 and C%2==0:
    tmpA = A//2
    tmpB = B//2
    tmpC = C//2
    A = tmpB + tmpC
    B = tmpA + tmpC
    C = tmpA + tmpB
    ans += 1
  print(ans)

Submission status: Accepted

Solution code:

import sys

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

if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
    print (0)
    sys.exit()


for i in range(100000):

    na = A
    nb = B
    nc = C

    A = (nb+nc) // 2
    B = (na+nc) // 2
    C = (na+nb) // 2

    if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
        print (i+1)
        sys.exit()

print (-1)

Submission status: Accepted

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

ans = 0
while tmpA%2 == 0 and tmpB%2 == 0 and tmpC%2 == 0:
    ans += 1
    nxtA = (tmpB + tmpC) // 2
    nxtB = (tmpA + tmpC) // 2
    nxtC = (tmpA + tmpB) // 2
    tmpA, tmpB, tmpC = nxtA, nxtB, nxtC
    if nxtA == A and nxtB == B and nxtC == C:
        ans = -1
        break

print(ans)

Submission status: Accepted

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

ans = 0
while a%2 == 0 and b%2 == 0 and c%2 == 0:
    if a == b == c:
        ans = -1
        break

    a, b, c = int(b/2)+int(c/2), int(a/2)+int(c/2), int(a/2)+int(b/2)
    ans += 1

print(ans)

Submission status: Accepted

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

ans = 0
while 1:
    if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
        print(ans)
        exit()
    if a == b == c:
        print(-1)
        exit()
    else:
        a, b, c = b // 2 + c // 2, a // 2 + c // 2, a //2 + b //2
        ans += 1

Submission status: Accepted

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

if any((a%2==1,b%2==1,c%2==1)):
    print(0)
    exit()
    
cnt = 0
while cnt <= 100:
    a,b,c = (b+c)/2, (a+c)/2,(a+b)/2
    cnt += 1
    if any((a%1!=0,b%1!=0,c%1!=0)):
        print(cnt-1)
        exit()
print(-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
if a%2==1 or b%2==1 or c%2==1:
 print(0)
 exit()
cnt=1
while True:
 aa=a
 bb=b
 cc=c
 a=(bb+cc)/2
 b=(cc+aa)/2
 c=(aa+bb)/2
 if a%2==1 or b%2==1 or c%2==1:
  print(cnt)
  exit()
 elif a==b==c:
  print(-1)
  exit()
 else:
  cnt+=1

Submission status: Accepted

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

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

ans = 0
while True:
    if a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
        ans += 1
        a, b, c = (b + c) // 2, (a + c) // 2, (a + b) // 2
    else:
        break

print(ans)

Submission status: Accepted

Solution code:
import sys
a,b,c=map(int,input().split())
i=0
while a%2==0 and b%2==0 and c%2==0:
    a,b,c=(b+c)//2,(a+c)//2,(a+b)//2
    i+=1
    if i==10000:
        print(-1)
        sys.exit()
print(i)

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0
for i in range(50000000):
    if a%2 + b%2 + c%2 >= 1:
        print(cnt)
        break
    new_a = (b + c) // 2
    new_b = (c + a) // 2
    new_c = (a + b) // 2
    a, b, c = new_a, new_b, new_c
    cnt += 1
else:
    print(-1)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

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

count = 0
while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
    a, b, c = (b + c) // 2, (a + c) // 2, (a + b) // 2
    count += 1
print(count)

Submission status: Accepted

Solution code:
def examA():
    A, B, C = LI()
    S = A+B+C
    cur = 0
    for i in range(32):
        if A%2==1 or B%2==1 or C%2==1:
            break
        A = (S-A)//2
        B = (S-B)//2
        C = (S-C)//2
        cur +=1
    if cur==32:
        ans = -1
    else:
        ans = cur
    print(ans)

import sys,copy,bisect,itertools,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
if a == b == c and a%2==0:
  print("-1")
else:
  ans = 0
  while True:
    if a%2 or b%2 or c%2:
      print(ans)
      break
    at, bt, ct = a, b, c
    a = bt//2 + ct//2
    b = ct//2 + at//2
    c = at//2 + bt//2
    ans += 1

Submission status: Accepted

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

def checkIfInfinite(tar):
  tar=sorted(tar)
  for i in range(len(tar)):
    if tar[i]!=START[i]:
      return False
  return True

def checkIfEnd(tar):
  for t in tar:
    if t%2==1:
      return True
    
ans=0
while True:
  if checkIfEnd(target):
    print(ans)
    exit(0)
  Ahalf=target[0]//2
  Bhalf=target[1]//2
  Chalf=target[2]//2
  target[0]=Bhalf+Chalf
  target[1]=Chalf+Ahalf
  target[2]=Ahalf+Bhalf
  ans+=1
  if checkIfInfinite(target):
    print(-1)
    exit(0)

Submission status: Accepted

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

Submission status: Accepted

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

a = inpl()
cnt = 0
for i in a:
    if i%2:
        print(cnt)
        quit()
if a[0] == a[1] == a[2]:
    print(-1)
else:
    while True:
        for i in a:
            if i%2:
                print(cnt)
                quit()
        b = [0] * 3
        b[0] = (a[1] + a[2]) // 2
        b[1] = (a[0] + a[2]) // 2
        b[2] = (a[1] + a[0]) // 2
        cnt += 1
        a[::] = b[::]

Submission status: Accepted

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


if A % 2 != 0 or B % 2 != 0 or C % 2 != 0:
    print(0)
    exit()
else:
    if A == B and B == C:
        print(-1)
        exit()
    else:
        ans = 0
        while True:        

            ans += 1

            a = (B+C)/2
            b = (A+C)/2
            c = (A+B)/2

            if a % 2 != 0 or b % 2 != 0 or c % 2 != 0:
                print(ans)
                exit()
            
            A = a
            B = b
            C = c

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
ans=0
for _ in range(10**6):
    if sum(i%2 for i in [a,b,c])==0:
        A=b//2+c//2
        B=c//2+a//2
        C=a//2+b//2
        ans+=1
        a,b,c=A,B,C
    else:
        print(ans)    
        exit()
print(-1)

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
if a%2!=0 or b%2!=0 or c%2!=0:
    print(0)
else:
    a1=0
    a2=0
    a3=0
    c1=0
    c2=0
    c3=0
    ans=0
    for i in range(2*10**5):
        if a%2!=0:
            c1=1        
        if b%2!=0:
            c2=1        
        if c%2!=0:
            c3=1
        if c1==1 or c3==1 or c2==1:
            ans=i
            break
        else:
            a3=(a+b)//2
            a2=(a+c)//2
            a1=(b+c)//2
            a=a1
            b=a2
            c=a3
        #print(a,b,c)
        if i==199999:
            ans=-1
    print(ans)

Submission status: Accepted

Solution code:
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


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

ans = 0
while not (A & 1 or B & 1 or C & 1):
    A, B, C = B // 2 + C // 2, A // 2 + C // 2, A // 2 + B // 2
    ans += 1
    if ans >= 1000000:
        print(-1)
        exit()
print(ans)

Submission status: Accepted

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

while True:
    if a%2 == 0 and b%2 == 0 and c%2 == 0:
        pass
    else:
        print(ans)
        exit()
    
    last_a = a
    last_b = b
    last_c = c
    a,b,c = (b+c)//2, (a+c)//2, (a+b)//2
    
    ans += 1
    
    if last_a == a and last_b == b and last_c == c:
        print(-1)
        exit()

Submission status: Accepted

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

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


def is_continue(x_list):
    for x in x_list:
        if x % 2 == 1:
            return False
    return True


count = 0

while is_continue([A, B, C]):
    if A == B and B == C:
        count = -1
        break
    a, b, c = A, B, C
    a = B // 2 + C // 2
    b = A // 2 + C // 2
    c = A // 2 + B // 2
    A, B, C = a, b, c
    count += 1

ans = count
print(ans)

Submission status: Accepted

Solution code:
# AGC014
A, B, C = map(int, input().split())
ans = 1
if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
    print(0)
    exit()

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

ans = 1
while 1:
    a = B // 2 + C // 2
    b = C // 2 + A // 2
    c = A // 2 + B // 2
    if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
        break
    else:
        A = a
        B = b
        C = c
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
import sys
if a%2+b%2+c%2>0:
    print(0)
    sys.exit()
e=0

while e<10000:
    a,b,c=b//2+c//2,a//2+c//2,a//2+b//2
    e+=1
    if a%2+b%2+c%2>0:
        break

if e==10000:
    print(-1)
else:
    print(e)

Submission status: Accepted

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

    cnt = 0
    while a % 2 == 0 and b % 2 == 0 and c % 2 == 0 and cnt < 100:
        a, b, c = (b + c) // 2, (c + a) // 2, (a + b) // 2
        cnt += 1

    if cnt == 100:
        cnt = -1

    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import numpy as np

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

ans = 0
T = A + B + C
s = np.array([A, B, C])
while all(s % 2 == 0):
    if A == B == C:
        print(-1)
        exit(0)
    s = (T - s) // 2
    ans += 1

print(ans)

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
if a==1 and b==1 and c==1:
    print(0)
    exit()
if a==b==c:
    print(-1)
    exit()
v=[a,b,c]
v.sort()
tmp=[b-a,c-a,c-b]
ans=10**10
for i in range(len(tmp)):
    cnt=0
    while(tmp[i]%2==0):
        tmp[i]=tmp[i]//2
        cnt+=1
    ans=min(ans,cnt)

print(ans)

Submission status: Accepted

Solution code:
def main():
    a, b, c = (int(i) for i in input().split())
    ans = 0
    finite = True
    while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
        next_a = b//2 + c//2
        next_b = a//2 + c//2
        next_c = a//2 + b//2
        if next_a == a and next_b == b and next_c == c:
            print(-1)
            finite = False
            break
        ans += 1
        a = next_a
        b = next_b
        c = next_c
    if finite:
        print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

result = 0

while(True):
  A = (b + c) / 2
  B = (c + a) / 2
  C = (a + b) / 2
  if((b - a) % 2 > 0 or (c - b) % 2 > 0 or (a - c) % 2 > 0):
    print(result)
    break
  a, b, c = A, B, C
  result += 1

Submission status: Accepted

Solution code:
abc=sorted(list(map(int,input().split())))
pabc=abc[:]
ans=0
while True:
    if abc[0]%2==1 or abc[1]%2==1 or abc[2]%2==1:
        print(ans)
        exit()
    ans+=1
    abc[0]=pabc[1]//2+pabc[2]//2
    abc[1]=pabc[0]//2+pabc[2]//2
    abc[2]=pabc[0]//2+pabc[1]//2
    abc=sorted(abc)
    if abc[0]==pabc[0] and abc[1]==pabc[1] and abc[2]==pabc[2]:
        print(-1)
        exit()
    pabc=abc[:]

Submission status: Accepted

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

ans = 0
flag = False
while True:
    if a == b == c and a % 2 == 0:
        flag = True
        break
    elif a % 2 == b % 2 == c % 2 == 0:
        a, b, c = b//2 + c//2, c//2 + a//2, a//2 + b//2
        ans += 1
    else:
        break

if flag:
    print(-1)
else:
    print(ans)

Submission status: Accepted

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

ans = 0
while a % 2 != 1 and b % 2 != 1 and c % 2 != 1:
    if a == (b+c)//2 and b == (a+c)//2 and c == (a+b)//2:
        ans = -1
        break
    a, b, c = (b+c)//2, (a+c)//2, (a+b)//2
    ans += 1

print(ans)

Submission status: Accepted

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

for i in range(3):
    if l[i]%2==1:
        print(0)
        exit()

if l.count(l[0])==3:
    if l[0]%2==0:
        print(-1)
        exit()
    else:
        print(0)
        exit()

count=0
while True:
    temp=list(map(lambda x:x%2,l))
    all=sum(temp)
    if all==3:
        print(count+1)
        exit()
    elif all==2:
        print(count)
        exit()
    elif all==1:
        print(count)
        exit()
    l=list(map(lambda x:x//2,l))
    count+=1

Submission status: Accepted

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

if l.count(l[0])==3:
    if l[0]%2==0:
        print(-1)
        exit()
    else:
        print(0)
        exit()

count=0
while True:
    temp=list(map(lambda x:x%2,l))
    all=sum(temp)
    if all==3:
        print(count+1)
        exit()
    elif all==2:
        print(count)
        exit()
    elif all==1:
        print(count)
        exit()
    l=list(map(lambda x:x//2,l))
    count+=1

Submission status: Accepted

Solution code:
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)
    else:
        print(0)
else:
    ans = 0
    while True:
        if a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
            ans += 1
            A = b / 2 + c / 2
            B = c / 2 + a / 2
            C = a / 2 + b / 2
            a = A
            b = B
            c = C
        else:
            break
    print(ans)

Submission status: Accepted

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

def aa():
    if a == b and a == c:
        if a % 2 == 0:
            return -1
        else:
            return 0
    else:
        A = [a-b, b-c, c-a]
        j = 0
        while True:
            for i in range(3):
                if A[i] % 2 == 1:
                    return j
                else:
                    A[i] //= 2
            j += 1

print(aa())

Submission status: Accepted

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

for i in range(10000):
    if a == b and b == c and a % 2 == 0:
        n -= 1
        break
    elif a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
        break
    else:
        a , b , c = (b + c) / 2 , (c + a) / 2 , (a + b) / 2
        n += 1
        if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
            break

print(n)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def change(a,b,c):
    a1=b//2+c//2
    b1=a//2+c//2
    c1=a//2+b//2
    return a1,b1,c1
a,b,c = map(int,input().split())
if a==b and b==c and a%2==0:
    print(-1)
    exit()
cnt=0
while a%2==0 and b%2==0 and c%2==0:
    a,b,c=change(a,b,c)
    cnt+=1
    if a==b and b==c and a%2==0:
        print(-1)
        exit()
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    a, b, c = list(map(int, input().rstrip('\n').split()))
    cnt = 0
    if a == b == c:
        if a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
            print(-1)
        else:
            print(0)
    else:
        while True:
            if a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
                a, b, c = (b + c) // 2, (a + c) // 2, (a + b) // 2
                cnt += 1
            else:
                print(cnt)
                exit()


if __name__ == '__main__':
    slove()

Submission status: Accepted

Solution code:
import math


def resolve():
    a, b, c = map(int, input().split())
    if a == b == c:
        if a % 2:
            print(0)
        else:
            print(-1)
        return 0
    for i in range(int(math.log2(10 ** 9)) + 1):
        if a % 2 or b % 2 or c % 2:
            print(i)
            return 0
        a_new, b_new, c_new = (b + c) // 2, (a + c) // 2, (a + b) // 2,
        a, b, c = a_new, b_new, c_new
    print(-1)


if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
import time
t1=time.time()
a,b,c=map(int,input().split())
cnt=0
while a%2==0 and b%2==0 and c%2==0:
	a,b,c=b//2+c//2,a//2+c//2,a//2+b//2
	cnt+=1
	t2=time.time()
	if t2-t1>1.97:
		print(-1)
		exit()
print(cnt)

Submission status: Accepted

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

for i in range(10 ** 9):
    if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
        print(i)
        exit()
    if a == b == c:
        print(-1)
        exit()
    a, b, c = (b + c) // 2, (c + a) // 2, (a + b) // 2

Submission status: Accepted

Solution code:
ABC = list(map(int, input().split()))
cnt = 0
while all(map(lambda x: x % 2 == 0, ABC)) == True:
  ABC = [(ABC[1] + ABC[2]) // 2, (ABC[2] + ABC[0]) // 2, (ABC[0] + ABC[1]) // 2]
  cnt += 1
  if len(set(ABC)) == 1:
    print(-1)
    exit()
print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A,B,C=map(int,input().split());d=0
if A%2:print(0);quit()
if A==B==C:print(-1);quit()
while A%2==B%2==C%2==0:A,B,C=B//2+C//2,C//2+A//2,A//2+B//2;d+=1
print(d)