Harryxun/stf_run huggingface dataset:
K = input()
S = 7
i = 1
if (1 <= K) and (K <= (10 ** 6)):
    while True:
        if int(S) % K != 0:
            S = S * 10 + 7
            i += 1
        else:
            print(i)
            break

        if i > K:
            print('-1')
            break

### FIXED CODE ###

K = int(input())
if K % 2 == 0:
    print(-1)
elif K % 5 == 0:
    print(-1)
else:
    S = 7
    for i in range(K+1):
        if S % K == 0:
            print(i+1)
            break
        else:
            S = S % K
            S = S * 10 + 7
    else:
        print(-1)
import sys

n, a, b = map(int, sys.stdin.readline().split())
s = 'b'*a + 'r'*b

x = n // (a+b)
y = n % (a+b)

z = s[:y].count('b')
print(x*a + z)


### FIXED CODE ###

import sys

n, a, b = map(int, sys.stdin.readline().split())

x = n // (a+b)
y = min(a, (n % (a+b)))

print(x*a + y)
import math
n,a,b=map(int,input().split())

count=0
mod=10**9+7

def C(n,a):
    x=1
    y=1
    for i in range(a):
        x*=n-i
        y*=i+1
    return x/y

count+=pow(2,n,mod)
#print(count)
count-=1
count-=C(n,a)
#print(count)
count-=C(n,b)

print(int(count%mod))

### FIXED CODE ###

import math
n,a,b=map(int,input().split())

count=0
mod=1000000007

def C(n,a):
    x=1
    y=1
    for i in range(a):
        x*=n-i
        y*=i+1
        x%=mod
        y%=mod
    return x*pow(y,mod-2,mod)%mod

count+=pow(2,n,mod)
#print(count)
count-=1
count-=C(n,a)
#print(count)
count-=C(n,b)

print(max(0,(count)%mod))
s = int(input())
k=[s]
i = 1
while 1:
	if k[-1]%2 == 0:
  		x = int(k[-1]/2)
	else:
  		x = 3*k[-1]+1
    if x in k:
        print(i+1)
        break
    else:
        k.append(x)
        i+=1

### FIXED CODE ###

s = int(input())
ans_list = [s]
i = 1
while 1:
    if ans_list[-1]%2 == 0:
        a = int(ans_list[-1]/2)
    else:
        a = 3 * ans_list[-1] + 1
    if a in ans_list:
        print(i+1)
        break
    else:
        ans_list.append(a)
        i += 1
import numpy as np
X,N = map(int, input().split())
p = list(map(int, input().split()))
p = sorted(p)
lista = list(range(1,101))
for i in p:
    if i in lista:
        lista.remove(i)
def getNearestValue(list, num):
    """
    概要: リストからある値に最も近い値を返却する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """
    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    print(list[idx])
if N == 0:
    print(X)
else:
    getNearestValue(lista, X)

### FIXED CODE ###

import numpy as np
X,N = map(int, input().split())
p = list(map(int, input().split()))
p = sorted(p)
lista = list(range(-100,200))
for i in p:
    if i in lista:
        lista.remove(i)
def getNearestValue(list, num):
    """
    概要: リストからある値に最も近い値を返却する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """
    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    print(list[idx])
if N == 0:
    print(X)
else:
    getNearestValue(lista, X)
import sys

for line in sys.stdin:
    count = 0
    n = int(line)
    
    nums = range(2, n+1)
    
    while True:
        if len(nums) == 1:
            count += 1
            break
        else:
            count += 1
            m = nums[0]
            numsCandidate = [1:]
            nums = [ for x in numsCandidate if x % m != 0 ]
    print count

### FIXED CODE ###

import math
import sys

n = 999999
nums = [1] * (n+1)
nums[:2] = [0,0]
    
cnt = 0
while cnt <= math.sqrt(n):
    flg = nums[cnt]
    if flg == 1:
        k = 2
        while k*cnt <= n:
            nums[k*cnt] = 0
            k += 1
    cnt += 1


for line in sys.stdin:
    n = int(line)
    print sum(nums[:n+1])
N,D=list(map(int,input().split()))
print(N//(1+2D))

### FIXED CODE ###

N,D=list(map(int,input().split()))
if N%(1+2*D)==0:
  print(N//(1+2*D))
else:
  print(N//(1+2*D)+1)
N,K=map(int,input().split())
height_list=list(map(int,input().split()))
score_list=[ 0, abs(height_list[0]-height_list[1]) ]



for i in range(2,N):
    tmp_list = []
    for k in range(K):
        tmp_list.append(abs(height_list[i]-height_list[i-k-1])+score_list[i-k-1])
    score_list.append(min(tmp_list))

print(score_list[N-1])



### FIXED CODE ###

import sys
import numpy as np
# inputを高速化する。
input = sys.stdin.readline
n, k = map(int, input().split())
h = [int(i) for i in input().split()]
# dpの配列を作る。
dp = np.zeros(n, dtype=int)
# hの配列を作る。
h = np.array(h)
for i in range(1, n):
    # start は負になることはない。
    start = max(0, i-k)
    # 行列として足し算できるのでforを使う必要がない。
    dp[i] = min(dp[start: i] + np.abs(h[i] - h[start: i]))
print(dp[n-1])
n = int(input())
 
if n%2 == 0:
    print(0.5)    #整数Nが偶数のとき
else:
    s = (n-1)/2    #偶数の数を確認
    s /= n　　　#nで割って偶数の確率を求める
    print(1-s)    #全体から偶数の確率を引いて奇数の確率を求める

### FIXED CODE ###

n = int(input())

if n%2 == 0:
    print(0.5)
else:
    print(1-(n-1)/2/n)
#!/usr/bin/env python3
import sys
 
MOD = 1000000007  # type: int
 
def solve(N: int, M: int, a: "List[int]"):
    i = 2
    arr = [1, 1]
    seek = 0
    while a[seek]==1:
        arr[1] = 0
        seek+=1
    while i<=N:
        if seek < len(a) and i == a[seek]:
            arr[0], arr[1] = arr[1], 0
            seek+=1
        else:
            arr[0], arr[1] = arr[1], (arr[0]+arr[1])%MOD
        i+=1
    print(arr[1])
 
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(M) ]  # type: "List[int]"
    solve(N, M, a)
 
if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def solve(N: int, M: int, a: "List[int]"):
    i = 2
    arr = [1, 1]
    seek = 0
    while seek < len(a) and a[seek]==1:
        arr[1] = 0
        seek+=1
    while i<=N:
        if seek < len(a) and i == a[seek]:
            arr[0], arr[1] = arr[1], 0
            seek+=1
        else:
            arr[0], arr[1] = arr[1], (arr[0]+arr[1])%MOD
        i+=1
    print(arr[1])

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(M) ]  # type: "List[int]"
    solve(N, M, a)

if __name__ == '__main__':
    main()
import collections
s = list(input())
Ans = 0
c = collections.Counter(s)
d = c['B']
for i in range(len(s)):
    if s[i] == 'B':
        for j in range(len(s)-i-1):
            if s[i+j+1]=='W':
                Ans += j+1
                s[i] = 'W'
                s[i+1] = 'B'
                s[i+j+1] = 'B'
                break
    if i = d:
        break
print(Ans)

### FIXED CODE ###

s = list(input())
Ans = 0
W_put_place = 0
for i in range(len(s)):
    if s[i] == 'W':
        Ans += i - W_put_place
        W_put_place += 1
print(Ans)
s=input()
n=input()
a=[]
for i in range(0,len(s),n):
	a.append(s[i])
print(*a,sep="")

### FIXED CODE ###

s=input()
n=int(input())
a=[]
for i in range(0,len(s),n):
	a.append(s[i])
print(*a,sep="")
n,x = map(int,input().split())
l = list(map(int,input().split()))
i=0
suml=0
if sum(l)<x:
    print(len(l))
else:
    while suml<=x:
        suml=suml+l[i]
        i=i+1
        print(i)

### FIXED CODE ###

n,x = map(int,input().split())
l = list(map(int,input().split()))
i=0
suml=0
if sum(l)<=x:
    print(len(l)+1)
else:
    while suml<=x:
        suml=suml+l[i]
        i=i+1
    print(i)
import math
a, b = map(str, input().split())
a = int(a)
b = float(b)

b = int(b * 100)
ans = a * b // 100

ans = int(math.floor(ans))
print(ans)

### FIXED CODE ###

n = int(input())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
                
            arr.append(cnt)

    if temp != 1:
        arr.append(1)
        
    if arr==[] and n != 1:
        arr.append(1)

    return arr
  
lst = factorization(n)
ans = 0
if not lst:
  print(ans)
else:
  mx = max(lst)
  for _ in lst:
    for i in range(1, mx+1):
      if _ - i >= 0:
      	_ -= i
      	ans += 1
      else:
      	break
  print(ans)
n = input()
m = 0

if n[-1] == "1":
    m = 7
elif n[-1] == "3":
    m = 9
elif n[-1] == "7":
    m = 1
elif n[-1] == "9":
    m = 3
else:
    print(-1)
    exit()

n = int(n)

for i in range(1, k):
    if len(set(list(str(n * m)))) == 1:
        break
    m = int(str(i) + str(m)[-1])
    if len(str(n * m)) >= k:
        print(-1)
        exit()

print(len(str(n * m)))


### FIXED CODE ###

k = int(input())
m = 0

for i in range(k):
    m = (m * 10 + 7) % k
    if m == 0:
        break
    elif i == k - 1:
        print(-1)
        exit()

print(i + 1)
N = int(input())
x = list(map(int, input().split()))
mn_lst = []
for i in x:
    cnt = 0
    while i % 2 == 0:
        cnt += 1
        i >>= 1
    mn_lst.append(cnt)
    
print(min(mn_list))

### FIXED CODE ###

N = int(input())
x = list(map(int, input().split()))
mn_lst = []
for i in x:
    cnt = 0
    while i % 2 == 0:
        cnt += 1
        i >>= 1
    mn_lst.append(cnt)
    
print(min(mn_lst))
n,k=map(int,input().split())
l=list(map(int,input().split()))
l.sort()
mod=10**9+7
if k==1:
    print("0")
if n==2:
    print((l[1]-l[0])%mod)
total=0
from math import factorial
for i in range(n-k+1):
   f=int((factorial(n-i-1)/factorial(k-1)/factorial(n-k-i)))%mod
   total+=int((l[n-i-1]-l[i])*f)
   total%=mod
print(total)

### FIXED CODE ###

n,k=map(int,input().split())
l=list(map(int,input().split()))
l.sort()
mod=10**9+7
n_max=2*10**5
F,FI=[0]*(n_max+1),[0]*(n_max+1)
F[0],FI[0]=1,1
for i in range(n_max):
  F[i+1]=(F[i]*(i+1))%mod
  FI[i+1]=pow(F[i+1],mod-2,mod)
def comb(x,y):
  return (F[x]*FI[x-y]*FI[y])%mod
total=0
for i in range(n-k+1):
   f=comb(n-i-1,k-1)%mod
   total+=int((l[n-i-1]-l[i])*f)
   total%=mod
print(total)
#!/usr/bin/env python3
# atcoder 
# Türkçe konuşyorum
# Türkler var mı
# memnün oldum

K = int(input())
S = input()


slen = len(S)
if(slen < K):
    print(S)
else: 
    pr = S[:K]
    change = S[K:K+3]
    #print(change)
    for i in range(3):
        change = change.replace(change[i], ".")
    print(pr + change)



### FIXED CODE ###

#!/usr/bin/env python3
# atcoder 
# Türkçe konuşyorum
# Türkler var mı
# memnün oldum

K = int(input())
S = input()



if(len(S) <= K):
    print(S)
else:
    print(S[:K] + '.' * 3)
    #for i in range(3):
    #    change = change.replace(change[i], '.')
    #print(S[:K] + change[:3])
a,b,c,d=map(int,input().split())
def gcd(x,y):
  if x%y==0:
    return y
  else:
    return gcd(x%y,y)
    
r=gcd(c,d)    
s=(b//c)-((a-1)//c)
t=(b//d)-((a-1)//d)
u=(b//r)-((a-1)//r)

print(b-a+1-s-t+u)


### FIXED CODE ###

a,b,c,d=map(int,input().split())
def gcd(x,y):
  if x%y==0:
    return y
  else:
    return gcd(y,x%y)
    
r=int((c*d)/gcd(c,d)) 
s=(b//c)-((a-1)//c)
t=(b//d)-((a-1)//d)
u=(b//r)-((a-1)//r)

print(int(b-a+1-s-t+u))
s=list(input())
ans=0
for i in range(4):
    id s[i]=='2':
        ans+=1
print(ans)

### FIXED CODE ###

s=list(str(input()))
ans=0
for i in range(4):
    if s[i]=='2':
        ans+=1
print(ans)
N = int(input())
array = []

for i in N-1:
  input = input().split(' ')
  array.append((input[0], input[1]))

for i in N-1:
  time = array[i][0] + array[i][1]
  for j in range(i+1, N-1):
    if array[j][1] > time:
      time = array[j][1]
    time = time + array[j][0]
  print(time)


print(0)

### FIXED CODE ###

N = int(input())
array = []

for i in range(N-1):
  _input = str(input().replace('\r','')).split(' ')
  array.append((int(_input[0]), int(_input[1]), int(_input[2])))

for i in range(N-1):
  time = array[i][0] + array[i][1]
  for j in range(i+1, N-1):
    if array[j][1] > time:
      time = array[j][1]
    elif time % array[j][2] != 0:
      time = time - time % array[j][2] + array[j][2]
    time = time + array[j][0]
  print(time)

print(0)
import math
n,d=map(int,raw_input())
print int( math.ceil(float(n)/(2*d+1)))


### FIXED CODE ###

import math
n,d=map(int,raw_input().split())
print int( math.ceil(float(n)/(2*d+1)))
from collections import defaultdict
S = input()
N = len(S)

D=defaultdict()
prev=0
ans=0
for i,s in enumerate(reversed(S)):
    cur=prev+pow(10,i,2019)*int(s)%2019
    ans+=D[cur]
    D[cur]+=1
    prev=cur
print(ans)


### FIXED CODE ###

from collections import defaultdict
S = input()
N = len(S)

DP=[0]*(N+1)
for i,s in enumerate(reversed(S)):
    DP[i+1]=(DP[i]+pow(10,i,2019)*int(s))%2019

D=defaultdict(int)
for dp in DP:
    D[dp]+=1

ans=0
for dp in D.values():
    ans += dp*(dp-1)//2

print(ans)
#順番考えなくていいかとりあえず試す
m = int(input())
nm = [(0,0)]
for i in range(m):
    di,ci = map(int, input().split( ))
    nm.append((di,ci))
cnt = 0
tmp = 0
while nm:
    ci,di = nm.pop()
    if di>100:
        tmpy = 1
        tmpz = 1
        tmpx = ci*2
        if tmpx>=10:
            tmpx = str(tmpx)
            tmp2 = int(tmpx[0])+int(tmpx[1])
            tmpy += 1
        while tmpx != ci:
            tmpx += ci
            tmpy +=1
            tmpz +=1
            if tmpx>=10:
                tmpx = str(tmpx)
                tmp2 = int(tmpx[0])+int(tmpx[1])
                tmpy += 1
        cnt += tmpz*(di//tmpy)
        di -= (di//tmpy)*tmpy

    while di:
        cnt += 1
        #print(di,cnt)
        tmp += ci
        di-=1
        if tmp>=10:
            tmp = str(tmp)
            tmp2 = int(tmp[0])+int(tmp[1])
            cnt += 1
            #print(di,cnt)
            tmp = tmp2
print(cnt-1)
    

### FIXED CODE ###

#繰り上がりごとに各桁の総和は9減る
#9*最初の桁数+最初の総和がそれで減る
#それは順番によらない

m = int(input())
sm=  0
d = []
c = []
for i in range(m):
    di,ci = map(int, input().split( ))
    d.append(di)
    c.append(ci)
    sm += di*ci

x = sum(c)*9 + sm
y =  x%9
if y==0:
    y = 9
    
print((x-y)//9-1)
import sys
from collections import deque
sys.setrecursionlimit(20000000)
input = sys.stdin.readline


def main():
    N, Q = map(int, input().split())
    ans = [[0, deque()] for _ in range(N)]

    for _ in range(N - 1):
        p, c = map(int, input().split())
        ans[p-1][1].append(c-1)
        ans[c-1][1].append(p-1)

    for _ in range(Q):
        p, v = map(int, input().split())
        ans[p-1][0] += v

    def add_value(node, parent):
        val = ans[node][0]
        children = ans[node][1]
        for child in children:
            if child == parent:
                continue
            ans[child][0] += val
            add_value(child, node)

    add_value(0, -1)

    print(' '.join([str(x[0]) for x in ans]))


if __name__ == '__main__':
    main()



### FIXED CODE ###

n = int(input())
s = input()

if n >= 3200:
  print(s)
else:
  print('red')
import sys
from collections import Counter

n, *S = sys.stdin.read().split()
n = int(n)

def main():
    t = [''.join(sorted(t)) for t in s]
    c = Counter(t)
    cnt = 0
    for v in c.values():
        cnt += v*(v-1)
    print(cnt//2)

main()

### FIXED CODE ###

import sys
from collections import Counter

n, *S = sys.stdin.read().split()
n = int(n)

def main():
    t = [''.join(sorted(t)) for t in S]
    c = Counter(t)
    cnt = 0
    for v in c.values():
        cnt += v*(v-1)
    print(cnt//2)

main()
from fractions import gcd
from math import factorial

def is_prime(x):
    return factorial(x - 1)  % x == x - 1

a, b = [int(x) for x in input().split(' ')]
i = 0
k = gcd(a, b)
for x in range(1, k): 
    if k % x == 0 and is_prime(x):
        i += 1
        
print(i)

### FIXED CODE ###

n = int(input())

if n % 2 == 0:
    print(1 / 2)
else:
    print((((n - 1) / 2) + 1) / n)
N,M=map(int,input().split())
L=[list(map(int,input().split())) for i in range(N)]
class UnionFind:
    def __init__(self,N):
        self.Parent=[-1]*N
    def unite(self,m,n):
        rm=self.root(m)
        rn=self.root(n)
        if rm==rn:
            return False
        else:
            if self.size(rm)<self.size(rn):
                rm,rn=rn,rm
            self.Parent[rm]+=self.Parent[rn]
            self.Parent[rn]=rm
            return True
    def root(self,n):
        if self.Parent[n]<0:
            return n
        else:
            self.Parent[n]=self.root(self.Parent[n])
            return self.Parent[n]
    def size(self,n):
        return -self.Parent[self.root(n)]
u=UnionFind(M)
used=[0]*M
for _,*l in L:
    used[l[0]-1]=1
    for i in range(len(l)-1):
        used[l[i+1]-1]=1
        u.unite(l[i]-1,l[i+1]-1)
print(['NO','YES'][u.size(L[0][1])==sum(used)])

### FIXED CODE ###

N,M=map(int,input().split())
L=[list(map(int,input().split())) for i in range(N)]
class UnionFind:
    def __init__(self,N):
        self.Parent=[-1]*N
    def unite(self,m,n):
        rm=self.root(m)
        rn=self.root(n)
        if rm==rn:
            return False
        else:
            if self.size(rm)<self.size(rn):
                rm,rn=rn,rm
            self.Parent[rm]+=self.Parent[rn]
            self.Parent[rn]=rm
            return True
    def root(self,n):
        if self.Parent[n]<0:
            return n
        else:
            self.Parent[n]=self.root(self.Parent[n])
            return self.Parent[n]
    def size(self,n):
        return -self.Parent[self.root(n)]
u=UnionFind(M)
used=[0]*M
for x,*l in L:
    used[l[0]-1]=1
    for i in range(x-1):
        used[l[i+1]-1]=1
        u.unite(l[i]-1,l[i+1]-1)
print(['NO','YES'][u.size(L[0][1]-1)==sum(used)])
def d_pairs():
    # 参考: https://maspypy.com/atcoder-参加感想-2019-02-16abc-155
    import numpy as np
    N, K = [int(i) for i in input().split()]
    A = np.array([int(i) for i in input().split()], np.int64)

    A = np.sort(A)
    zero = A[A == 0]
    positive = A[A > 0]
    negative = A[A < 0]

    def f(c):
        """数列 A から 2 要素を選んで積を取ったとき、c 以下となるようなペアの選び方"""
        count_pair = 0

        # a (数列の要素) == 0 かつ c >= 0 なら、a * x <= c となる x は数列の任意の要素
        if c >= 0:
            count_pair += len(zero) * N
        # a > 0 の場合
        count_pair += np.searchsorted(A, c // positive, side='right').sum()
        # a < 0 の場合 (全体から引くようにすると、見通しがよい)
        count_pair += (N - np.searchsorted(A, (-c - 1) // (-negative), side='right')).sum()
        # 添字の順序に制約があることを反映する
        count_pair -= np.count_nonzero(A * A <= c)  # 「添字が同じ要素を 2 度選んだ場合」を引く
        return count_pair // 2

    # 数列から要素を 2 個選んで積を取ったとき、制約からあり得る値の範囲
    lower, upper = -10 ** 18, 10 ** 18
    while upper - lower > 1:
        x = (lower + upper) // 2
        if f(x) >= K:
            upper = x
        else:
            lower = x
    return upper

print(d_pairs())

### FIXED CODE ###

def d_pairs():
    # 参考: https://maspypy.com/atcoder-参加感想-2019-02-16abc-155
    import numpy as np
    N, K = [int(i) for i in input().split()]
    A = np.array([int(i) for i in input().split()], np.int64)

    A = np.sort(A)
    zero = A[A == 0]
    positive = A[A > 0]
    negative = A[A < 0]

    def f(c):
        """数列 A から 2 要素を選んで積を取ったとき、c 以下となるようなペアの選び方"""
        count_pair = 0

        # a (数列の要素) == 0 かつ c >= 0 なら、a * x <= c となる x は数列の任意の要素
        if c >= 0:
            count_pair += len(zero) * N
        # a > 0 の場合
        count_pair += np.searchsorted(A, c // positive, side='right').sum()
        # a < 0 の場合 (全体から引くようにすると、見通しがよい)
        count_pair += (N - np.searchsorted(A, (-c - 1) // (-negative), side='right')).sum()
        # 添字の順序に制約があることを反映する
        count_pair -= np.count_nonzero(A * A <= c)  # 「添字が同じ要素を 2 度選んだ場合」を引く
        return count_pair // 2

    # 数列から要素を 2 個選んで積を取ったとき、制約からあり得る値の範囲
    lower, upper = -10 ** 18, 10 ** 18
    while upper - lower > 1:
        x = (lower + upper) // 2
        if f(x) >= K:
            upper = x
        else:
            lower = x
    return upper

print(d_pairs())
print(sum(map(int, raw_input().split()).sort()[:2]))

### FIXED CODE ###

a,b,c = map(int, raw_input().split())
if a >=b and a>=c:
  print b+c
elif b>=a and b>=c:
  print a+c
else:
  print a+b
N, A = map(int,input().split())

print(N ** 2 - A)

### FIXED CODE ###

N = int(input())
A = int(input())

print(N ** 2 - A)
import numpy as np

x, y = map(int, input().split())
if abs(x) == abs(y):
    print(1)
elif np.sign(x) == np.sign():
    if x < y:
        print(y - x)
    else:
        print(x - y + 2)
else:
    print(x + y + 1)

### FIXED CODE ###

x, y = map(int, input().split())
res = float("inf")
if x <= y:  # xx
    res = min(res, y - x)
if -x <= y:  # ox
    res = min(res, y + x + 1)
if x <= -y:  # xo
    res = min(res, -y - x + 1)
if -x <= -y:  # oo
    res = min(res, -y + x + 2)
print(res)
n, m = map(int, input().split())
li = []
seitou = 0
penalty = 0

if m == 0:
    print(0, 0)

else:
    for x in range(m):
        i, j = map(str, input().split())
        if i in li:
            pass
        else:
            if j == "WA":
                penalty += 1
            if j == "AC":
                li.append(i)
                seitou += 1

    print(seitou, penalty)

### FIXED CODE ###

x = str(input())
alph = 'abcdefghijklmnopqrstuvwxyz'
a = alph.find(x) + 1
b = alph[a]
print(b)
N, M = map(int, input().split())
A, B = [], []
for _ in range(N):
    a, b = list(map(int, input().split()))
    A.append(a)
    B.append(b)
    
import numpy as np
dp = np.zeros([N+1, max(max(A), M)+1])
    
for i in range(1, N+1):
    for j in range(min(A[i-1], M+1), M+1):
        dp[i][j] = B[i-1]

ans = 0
for j in range(1, M+1):
    i = np.argmax(dp[:, j])
    ans += dp[i, j]
    dp[i, :] = 0
print(int(ans))

### FIXED CODE ###

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
AB = sorted(AB, key=lambda x: x[0])  # sort by days

import heapq
que = []
heapq.heapify(que)

ans = 0
i = 0
for day in range(1, M+1):
    while i < len(AB) and AB[i][0] <= day:
        heapq.heappush(que, (-1)*AB[i][1])
        i += 1
    if que:
        ans += (-1)*heapq.heappop(que)
print(ans)
n = int(input())
# for i in range(n):
#     print('0', end='')
# print(flush=True)
x_str = input()
x = int(x_str, base=2)
popcount = x_str.count('1')
y_zero = x % (popcount + 1)
y_one = x % (popcount - 1)
dp = [-1] * n
dp[0] = 0


def calc(y):
    if dp[y] != -1:
        return dp[y]
    dp[y] = 1 + calc(y % bin(y).count('1'))
    return dp[y]


ans = [0] * n
rem_zero = 1
rem_one = popcount - 2
for i in range(n):
    if x_str[n - 1 - i] == '0':
        ans[n - 1 - i] = 1 + calc((y_zero + rem_zero) % (popcount + 1))
    else:
        ans[n - 1 - i] = 1 + calc((y_one + rem_one) % (popcount - 1))
    rem_zero = rem_zero * 2 % (popcount + 1)
    rem_one = rem_one * 2 % (popcount - 1)
for i in range(n):
    print(ans[i])

### FIXED CODE ###

n = int(input())
# for i in range(n):
#     print('0', end='')
# print(flush=True)
s = input()
x = int(s, base=2)
popcount = s.count('1')
y_zero = x % (popcount + 1)
if popcount > 1:
    y_one = x % (popcount - 1)
dp = [-1] * n
dp[0] = 0


def calc(y):
    if dp[y] != -1:
        return dp[y]
    dp[y] = 1 + calc(y % bin(y).count('1'))
    return dp[y]


ans = [0] * n
rem_zero = 1
if popcount > 1:
    rem_one = popcount - 2
for i in range(n):
    if s[n - 1 - i] == '0':
        ans[n - 1 - i] = 1 + calc((y_zero + rem_zero) % (popcount + 1))
    elif popcount > 1:
        ans[n - 1 - i] = 1 + calc((y_one + rem_one) % (popcount - 1))
    else:
        ans[n - 1 - i] = 0
    rem_zero = rem_zero * 2 % (popcount + 1)
    if popcount > 1:
        rem_one = rem_one * 2 % (popcount - 1)
for i in range(n):
    print(ans[i])
N = int(input())
    A = list(map(int,input().split()))

    if 0 in A:
        print(0)

    prod = 1
    for a in A:
        prod *= a
        if prod > 10**18:
            print(-1)

    print(prod)

### FIXED CODE ###


def main ():
    N = int(input())
    A = list(map(int,input().split()))

    if 0 in A:
        print(0)
        return

    prod = 1
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return

    print(prod)
    return

main ()
print(input().conut("1"))

### FIXED CODE ###

print(input().count("1"))