Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
xlst = list(map(int, input().split()))
minus = []
plus = []
for x in xlst:
    if x < 0:
        minus.append(-1 * x)
    elif x > 0:
        plus.append(x)
    else:
        k -= 1
if k == 0:
    print(0)
    exit()
minus.append(0)
minus = minus[::-1]
plus = [0] + plus
ans = 10 ** 20
ml = len(minus)
pl = len(plus)

pos = min(k, ml)
while 1:
    mm = minus[pos - 1]
    pp = plus[k - pos + 1]
    ans_tmp = max(mm, pp) + min(mm, pp) * 2
    ans = min(ans, ans_tmp)
    pos -= 1
    if pos == 0 or k - pos + 1 == pl:
        break
print(ans)

Fixed submission:
n, k = map(int, input().split())
xlst = list(map(int, input().split()))
minus = []
plus = []
for x in xlst:
    if x < 0:
        minus.append(-1 * x)
    elif x > 0:
        plus.append(x)
    else:
        k -= 1
if k == 0:
    print(0)
    exit()
minus.append(0)
minus = minus[::-1]
plus = [0] + plus
ans = 10 ** 20
ml = len(minus)
pl = len(plus)

pos = min(k, ml - 1)
while 1:
    mm = minus[pos]
    pp = plus[k - pos]
    ans_tmp = max(mm, pp) + min(mm, pp) * 2
    ans = min(ans, ans_tmp)
    pos -= 1
    if pos == -1 or k - pos == pl:
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m,q=map(int,input().split())
alist=[]
for i in range(m):
    l,r=map(int,input().split())
    alist.append([l,r])
alist.sort()
for t in range(q):
    count=0
    blist=[]
    p,q=map(int,input().split())
    for j in range (len(alist)):
        if p<=alist[0][0]:
            alist.sort(key=lambda x:x[1])
            break
        blist.append(alist[0])
        alist.remove(alist[0])
    for j in range (len(alist)):
        if q>=alist[j][1]:
            count+=1
        else:
            break
    for k in blist:
        alist.append(k)
    print(count)
    alist.sort(key=lambda x:x[0])

Fixed submission:
a,b=map(int,input().split())
print((a-1)*(b-1))
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a=list(map(int,input().split()))
count=0
for i in range(n//2):
    k=sum(a[i:n-i])
    if k%m==0:
        count+=1
    s=a[i]
    if s%m==0:
        count+=1
    if (k-s)%m==0:
        count+=1
    for j in range(i+1,n-i-1):
        s+=a[j]
        if s%m==0:
            count+=1
        if (k-s)%m==0:
            count+=1
if n%2==1:
    if a[n//2]%m==0:
        count+=1
print(count)

Fixed submission:
n,m=map(int,input().split())
a=list(map(int,input().split()))
count=0
sum=0
alist=[0]
for i in a:
    sum+=i
    alist.append(sum%m)
alist.sort()
k=-1
n=0
for j in alist:
    if k!=j:
        count+=(n*(n-1)/2)
        n=0
    n+=1
    k=j
count+=(n*(n-1)/2)
print(int(count))

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a=list(map(int,input().split()))
count=0
for i in range(n):
    for j in range(i,n):
        s=sum(a[i:j+1])
        if s%m==0:
            count+=1
print(count)

Fixed submission:
n,m=map(int,input().split())
a=list(map(int,input().split()))
count=0
sum=0
alist=[0]
for i in a:
    sum+=i
    alist.append(sum%m)
alist.sort()
k=-1
n=0
for j in alist:
    if k!=j:
        count+=(n*(n-1)/2)
        n=0
    n+=1
    k=j
count+=(n*(n-1)/2)
print(int(count))
Buggy python submission (verdict: Runtime Error):
s=input()
count=0
for i in range(len(s)):
    if s[i]=="A" or s[i]=="?":
        for j in range(len(s)-1,i+1,-1):
            if s[j]=="C" or s[j]=="?":
                k=s[i+1:j]
                bb=k.count("B")
                dd=k.count("?")
                count=((count+bb*3**dd+dd*3**(dd-1))/(10**9+7))
print(int(count))

Fixed submission:
import sys
input = sys.stdin.readline
MOD = 10 ** 9 + 7

def main():
    string = input().strip()
    n = len(string)
    dp = [[0, 0, 0, 0] for _ in range(n + 1)]
    dp[0][0] = 1
    for i, s in enumerate(string):
        if s == "A":
            dp[i + 1][0] = dp[i][0]
            dp[i + 1][1] = dp[i][1] + dp[i][0]
            dp[i + 1][2] = dp[i][2]
            dp[i + 1][3] = dp[i][3]
        elif s == "B":
            dp[i + 1][0] = dp[i][0]
            dp[i + 1][1] = dp[i][1]
            dp[i + 1][2] = dp[i][2] + dp[i][1]
            dp[i + 1][3] = dp[i][3]
        elif s == "C":
            dp[i + 1][0] = dp[i][0]
            dp[i + 1][1] = dp[i][1]
            dp[i + 1][2] = dp[i][2]
            dp[i + 1][3] = dp[i][3] + dp[i][2]
        else:
            dp[i + 1][0] = 3 * dp[i][0]
            dp[i + 1][1] = 3 * dp[i][1] + dp[i][0]
            dp[i + 1][2] = 3 * dp[i][2] + dp[i][1]
            dp[i + 1][3] = 3 * dp[i][3] + dp[i][2]
        for j in range(4):
            dp[i + 1][j] %= MOD
    print(dp[-1][-1] % MOD)
    
main()

Buggy python submission (verdict: Runtime Error):
s=input()
count=0
for i in range(len(s)):
    if s[i]=="A" or s[i]=="?":
        for j in range(len(s)-1,i,-1):
            if s[j]=="C" or s[j]=="?":
                k=s[i+1:j]
                bb=k.count("B")
                dd=k.count("?")
                count=(count+bb*3**dd+dd*3**(dd-1))%(10**9+7)
print(count)

Fixed submission:
import sys
input = sys.stdin.readline
MOD = 10 ** 9 + 7

def main():
    string = input().strip()
    n = len(string)
    dp = [[0, 0, 0, 0] for _ in range(n + 1)]
    dp[0][0] = 1
    for i, s in enumerate(string):
        if s == "A":
            dp[i + 1][0] = dp[i][0]
            dp[i + 1][1] = dp[i][1] + dp[i][0]
            dp[i + 1][2] = dp[i][2]
            dp[i + 1][3] = dp[i][3]
        elif s == "B":
            dp[i + 1][0] = dp[i][0]
            dp[i + 1][1] = dp[i][1]
            dp[i + 1][2] = dp[i][2] + dp[i][1]
            dp[i + 1][3] = dp[i][3]
        elif s == "C":
            dp[i + 1][0] = dp[i][0]
            dp[i + 1][1] = dp[i][1]
            dp[i + 1][2] = dp[i][2]
            dp[i + 1][3] = dp[i][3] + dp[i][2]
        else:
            dp[i + 1][0] = 3 * dp[i][0]
            dp[i + 1][1] = 3 * dp[i][1] + dp[i][0]
            dp[i + 1][2] = 3 * dp[i][2] + dp[i][1]
            dp[i + 1][3] = 3 * dp[i][3] + dp[i][2]
        for j in range(4):
            dp[i + 1][j] %= MOD
    print(dp[-1][-1] % MOD)
    
main()
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
t=1
b=10**15
c=-(10**15)
for i in a:
    k=i-t
    b=min(b,k)
    c=max(c,k)
    t+=1
v=10**15
for i in range(b,c+1):
    t=1
    k=0
    for j in a:
        k+=abs(j-(i+t))
        if t==n:
            v=min(v,k)
        t+=1
print(v)

Fixed submission:
n=int(input())
a=map(int,input().split())
import statistics
t=1
b=10**15
c=-(10**15)
d=[]
for i in a:
    e=i-t
    d.append(e)
    t+=1
i=int(statistics.median(d))
k=0
for j in d:
    k+=abs(j-i)
print(k)
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
z=1
n=1
while z<=k:
    a=1
    l=len(str(n))
    s = str(n)
    x = list(map(int, list(s)))
    while a<=l:
        if x[0]==1 and l>3:
            if l-a-1==0:
                print(n)
                a=a+100
                z=z+1
            elif n==19:
                print(19)
                a=a+100
                z=z+1
            elif x[l-a]==9:
                a=a+1
            else:
                a=a+100
        else:
            if a-l==0:
                print(n)
                a=a+100
                z=z+1
            elif n==19:
                print(19)
                a=a+100
                z=z+1
            elif x[l-a]==9:
                a=a+1
            else:
                a=a+100
    n=n+1

Fixed submission:
k = int(input())
n=0
a=1
b=0
if a==1 and n<9:
    while n<9 and b<k:
        n+=1
        print(n)
        b+=1
    a+=1
if a==2:
    while n<90 and b<k:
        n+=10
        print(n)
        b+=1
    a+=1
while b<k:
    n+=10**(a-1)
    print(n)
    b+=1
    if (n>((a-1)*10**a-10**(a-1)) and a<12) or (n>((a-2)*10**a-10**(a-1)) and a>=12):
        a+=1
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
o=99999
for a in range(0,n+1,59049):
    if n-a>=0:
        na=n-a
        for b in range(0,na+1,46656):
            if na-b>=0:
                nb=na-b
                for c in range(0,nb+1,7776):
                    if nb-c>=0:
                        nc=nb-c
                        for d in range(0,nc+1,6561):
                            if nc-d>=0:
                                nd=nc-d
                                for e in range(0,nd+1,1296):
                                    if nd-e>=0:
                                        ne=nd-e
                                        for f in range(0,ne+1,729):
                                            if ne-f>=0:
                                                nf=ne-f
                                                for g in range(0,nf+1,216):
                                                    if nf-g>=0:
                                                        ng=nf-g
                                                        for h in range(0,ng+1,81):
                                                            if ng-h>=0:
                                                                nh=ng-h
                                                                for i in range(0,nh+1,36):
                                                                    if nh-i>=0:
                                                                        ni=nh-i
                                                                        for j in range(0,ni+1,9):
                                                                            if ni-j>=0:
                                                                                nj=ni-j
                                                                                for k in range(0,nj+1,6):
                                                                                    if nj-k>=0:
                                                                                        nk=nj-k
                                                                                        for l in range(0,nk+1,1):
                                                                                            if nk-l==0:
                                                                                                m=((a/59049)+(b/46656)+(c/7776)+(d/6561)+(e/1296)+(f/729)+(g/216)+(h/81)+(i/36)+(j/9)+(k/6)+l)
                                                                                                o=min(o,m)
print(int(o))

Fixed submission:
n=int(input())
def zzz(k,m):
    r=0
    while k:
        r=r+k%m
        k=k//m
    return r
a=99999
for i in range(n+1):
    a=min(a,zzz(i,6)+zzz(n-i,9))
print(a)
Buggy python submission (verdict: Runtime Error):
n = input()
num = 0
for num in n:
    ans += int(num)
if ans == 1:
    ans = 10
print(ans)

Fixed submission:
n = input()
ans = 0
for num in n:
    ans += int(num)
if ans == 1:
    ans = 10
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,a,b,k=map(int,input().split())
def kai(n):
    k=1
    s=1
    while k<=n:
        s=(s*k)%998244353
        k=k+1
    return int(s%998244353)

def com(n,m):
    l=((kai(n)%998244353)/((kai(m)%998244353)*(kai(n-m)%998244353)))%998244353
    return int(l)

def rbg(n,a,b,k):
    x=0
    while x<=b:
        if (a*x)%b==k%b:
            y=(k-a*x)/b
            s=0
            while y>=0:
                    c=x+y
                    if c<=n:
                        d=0
                    else:
                        d=c-n
                    e=min(x,y)
                    z=0
                    while d<=e:
                        z=(z+(com(n,d)%998244353)*(com(n-d,x-d)%998244353)*(com(n-x,y-d)%998244353))%998244353
                        d=d+1
                    s=(s+z)%998244353
                    x=x+b
                    y=y-a
            return(s%998244353)
        x=x+1
    return False
print(rbg(n,a,b,k))

Fixed submission:
n, a, b, kk = map(int, input().split())

MOD = 998244353
N = n + 10
fact = [0 for _ in range(N)]
invfact = [0 for _ in range(N)]
fact[0] = 1
for i in range(1, N):
    fact[i] = fact[i - 1] * i % MOD

invfact[N - 1] = pow(fact[N - 1], MOD - 2, MOD)

for i in range(N - 2, -1, -1):
    invfact[i] = invfact[i + 1] * (i + 1) % MOD
def nCk(n, k):
    if k < 0 or n < k:
        return 0
    else:
        return fact[n] * invfact[k] * invfact[n - k] % MOD
        
ans = 0
for i in range(n + 1):
    j = (kk - a * i)
    if j % b != 0:
        continue
    ans += nCk(n, i) * nCk(n, j // b)
    ans %= MOD
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
x=[]
y=list(s)
m=999999
for i in range(n):
    del y[0]
    xn=x.count('W')
    yn=y.count('E')
    z=xn+yn
    m=min(m,z)
    x.append(s[i])
print(m)

Fixed submission:
n=int(input())
s=input()
y=s.count('E')
x=0
m=(x+y)
for i in range(n):
    if s[i]==('W'):
        x+=1
    else:
        y-=1
    m=min(m,x+y)
print(m)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
def xor(b,c):
    if b==c:
        return(b)
    k=0
    s=0
    while b>=1 or c>=1:
        if b%2!=c%2:
            k+=2**s
        b//=2
        c//=2
        s+=1
    return(k)
z=0
for i in range(n):
    x=a[i]
    y=a[i]
    for j in range(i,n):
        q=a[j]
        if i!=j:
            x=xor(x,q)
            y+=q
            if x==y:
                z+=1
        else:
            z+=1
print(z)

Fixed submission:
n = int(input())
alst = list(map(int, input().split()))

total = alst[0]
xor = alst[0]
ans = 0
l = 0
r = 0
while 1:
    if xor == total:
        ans += r - l + 1
        r += 1
        if r == n:
            break
        total += alst[r]
        xor ^= alst[r]
    else:
        total -= alst[l]
        xor ^= alst[l]
        l += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
x=int(input())
def beki(n):
    for i in range(2,10000):
        if n%i==0:
            t=
            while n>=1:
                n/=i
                if n==1 and t>=1:
                    return True
                if n<1:
                    return False
                t+=1
y=1
for i in range (1,x+1):
    if beki(i)==True:
        y=i
print(y)

Fixed submission:
x=int(input())
def beki(n):
    for i in range(2,32):
        k=n
        if k%i==0:
            t=0
            while k>=1:
                k/=i
                if k==1 and t>=1:
                    return True
                t+=1
y=1
for i in range (1,x+1):
    if beki(i)==True:
        y=i
print(y)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
lst = set()
l = len(s)
for i in range(l):
    for j in range(i, l):
        lst.add(s[i:j+1])
lst = list(lst)
lst.sort()
print(lst[int(input()) - 1])

Fixed submission:
def main():
    s = input()
    k = int(input())
    lst = set()
    l = len(s)
    for i in range(l):
        for j in range(i, i + k):
            lst.add(s[i:j+1])
    lst = list(lst)
    lst.sort()
    print(lst[k - 1])
main()

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
lst = set()
l = len(s)
for i in range(l):
    for j in range(i, l):
        lst.add(s[i:j+1])
lst = list(lst)
lst.sort()
print(lst[int(input()) - 1])

Fixed submission:
def main():
    s = input()
    k = int(input())
    lst = set()
    l = len(s)
    for i in range(l):
        for j in range(i, i + k):
            lst.add(s[i:j+1])
    lst = list(lst)
    lst.sort()
    print(lst[k - 1])
main()
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
x=list(map(int,input().split()))
import statistics
for i in range(n):
    y=x[i]
    x.pop(i)
    print(statistics.median(x))
    x.insert(i,y)

Fixed submission:
n = int(input())
x = list(map(int, input().split()))

lst = sorted(x)
small_med = lst[n // 2 - 1]
big_med = lst[n // 2]

for num in x:
    if num > small_med:
        print(small_med)
    else:
        print(big_med)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))


for i in range(n):
    count = 0
    before = 0
    for j, num in enumerate(a):
        if i == j:
            continue
        count += abs(before - num)
        before = num
    print(count + abs(before))
    
        

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.append(0)

lst = []
before = 0
for num in a:
    lst.append(abs(num - before))
    before = num
total = sum(lst)
for i in range(n):
    if i == 0:
        print(total - lst[i] - lst[i + 1] + abs(a[i+1]))
    else:
        print(total - lst[i] - lst[i + 1] + abs(a[i - 1] - a[i + 1]))
Buggy python submission (verdict: Time Limit Exceeded):
string = input()
x, y = map(int, input().split())

xy = True
x_s = []
y_s = []
cnt = 0
for s in string:
    if s == "F":
        cnt += 1
    else:
        if xy:
            x_s.append(cnt)
            xy = False
        else:
            y_s.append(cnt)
            xy = True
        cnt = 0
if xy:
    x_s.append(cnt)
    xy = False
else:
    y_s.append(cnt)
    xy = True
x_can = [False for _ in range(8001)]
y_can = [False for _ in range(8001)]

x_can[x_s[0]] = True
for xx in x_s[1:]:
    for i in range(8000, xx - 1, -1):
        if x_can[i - xx]:
            x_can[i] = True

y_can[0] = True
for yy in y_s:
    for i in range(8000, yy - 1, -1):
        if y_can[i - yy]:
            y_can[i] = True
            
x_pos = (x + sum(x_s))
y_pos = (y + sum(y_s))
if x_pos % 2 == 1 or y_pos % 2 == 1:
    print("No")
elif x_can[x_pos // 2] and y_can[y_pos // 2]:
    print("Yes")
else:
    print("No")



Fixed submission:
string = input()
x, y = map(int, input().split())

xy = True
x_s = []
y_s = []
cnt = 0
for s in string:
    if s == "F":
        cnt += 1
    else:
        if xy:
            x_s.append(cnt)
            xy = False
        else:
            y_s.append(cnt)
            xy = True
        cnt = 0
if xy:
    x_s.append(cnt)
    xy = False
else:
    y_s.append(cnt)
    xy = True
x_can = [False for _ in range(8001)]
y_can = [False for _ in range(8001)]

x_can[x_s[0]] = True
for xx in x_s[1:]:
    for i in range(8000, xx - 1, -1):
        if x_can[i - xx]:
            x_can[i] = True

y_can[0] = True
for yy in y_s:
    for i in range(8000, yy - 1, -1):
        if y_can[i - yy]:
            y_can[i] = True
            
x_pos = (x + sum(x_s))
y_pos = (y + sum(y_s))
if x_pos % 2 == 1 or y_pos % 2 == 1:
    print("No")
elif x_can[x_pos // 2] and y_can[y_pos // 2]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        numera = 4 * h * n - n * N - h * N
        denomi = h * n * N
        if numera <= 0:
            continue
        elif denomi % numera != 0:
            continue
        w = denomi // numera
        print(h, n, w)
        exit()

Fixed submission:
N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        numera = 4 * h * n - n * N - h * N
        denomi = h * n * N
        if numera <= 0:
            continue
        elif denomi % numera != 0:
            continue
        w = denomi // numera
        print(h, n, w)
        exit()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_s = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for a in a_s:
    ans += sum(a)

for i in range(n):
    for j in range(n):
        if i == j:
            continue
        for k in range(n):
            if i == k or j == k:
                continue
            if a_s[i][j] > a_s[i][k] + a_s[j][k]:
                print(-1)
                exit()
            if a_s[i][j] == a_s[i][k] + a_s[j][k]:
                ans -= a_s[i][j]

ans //= 2
print(ans)

Fixed submission:
n = int(input())
a_s = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for a in a_s:
    ans += sum(a)

for i in range(n):
    for j in range(n):
        if i == j:
            continue
        for k in range(n):
            if i == k or j == k:
                continue
            if a_s[i][j] > a_s[i][k] + a_s[j][k]:
                print(-1)
                exit()
            if a_s[i][j] == a_s[i][k] + a_s[j][k]:
                ans -= a_s[i][j]
                break

ans //= 2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
one_next = []
n_next = []
for _ in range(m):
    a, b = map(int, input().split())
    if a == 1:
        one_next.append(b)
    elif b == n:
        n_next.append(a)

for num in one_next:
    if num in n_next:
        print("POSSIBLE")
        break
else:
     print("IMPOSSIBLE")       

Fixed submission:
n, m = map(int, input().split())
ans = [0 for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    if a == 1:
        ans[b - 1] += 1
    elif b == n:
        ans[a - 1] += 1

if 2 in ans:
    print("POSSIBLE")
else:
     print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
g = []
for _ in range(m):
    a, b, c = map(int, input().split())
    g.append([a - 1, b - 1, -c])

def bellman_ford(s):
    d = [float('inf')]*n # 各頂点への最小コスト
    d[s] = 0 # 自身への距離は0
    for i in range(n):
        update = False # 更新が行われたか
        for x, y, z in g:
            if d[y] > d[x] + z:
                d[y] = d[x] + z
                update = True
        if not update:
            break
        if i == n - 1:
            inf_flg = d[-1]
            flg = True
    if flg:
        for i in range(n):
            update = False # 更新が行われたか
            for x, y, z in g:
                if d[y] > d[x] + z:
                    d[y] = d[x] + z
                    update = True
            if not update:
                break
            if i == n - 1:
                if inf_flg != d[-1]:
                    return "inf"
    return -1 * d[-1]

print(bellman_ford(0))

Fixed submission:
n, m = map(int, input().split())
g = []
for _ in range(m):
    a, b, c = map(int, input().split())
    g.append([a - 1, b - 1, -c])

def bellman_ford(s):
    d = [float('inf')]*n # 各頂点への最小コスト
    d[s] = 0 # 自身への距離は0
    flg = False
    for i in range(n):
        update = False # 更新が行われたか
        for x, y, z in g:
            if d[y] > d[x] + z:
                d[y] = d[x] + z
                update = True
        if not update:
            break
        if i == n - 1:
            inf_flg = d[-1]
            flg = True
    if flg:
        for i in range(n):
            update = False # 更新が行われたか
            for x, y, z in g:
                if d[y] > d[x] + z:
                    d[y] = d[x] + z
                    update = True
            if not update:
                break
            if i == n - 1:
                if inf_flg != d[-1]:
                    return "inf"
    return -1 * d[-1]

print(bellman_ford(0))
Buggy python submission (verdict: Runtime Error):
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:
        print(-1)
        exit()
    a, b, c = (b + c) // 2, (c + a) // 2, (a + b) // 2
    ans += 1
print(ans)


Fixed submission:
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:
        print(-1)
        exit()
    a, b, c = (b + c) // 2, (c + a) // 2, (a + b) // 2
    ans += 1
print(ans)