Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

def gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a

N,M = map(int,input().split(" "))
S = input()
T = input()
x = gcd(len(S),len(T))
Answer = int(len(S)*len(T)/x)
X = [0 for i in range(Answer)]

if (x == 1)and(S[0] == T[0]):
    print(Answer)
    exit()

for i in range(len(S)):
    X[int(i*Answer/len(S))] = S[i]

for i in range(len(T)):
    if (X[int(i*Answer/len(T))] == 0)or(X[int(i*Answer/len(T))] == T[i]):
        continue
    else:
        print(-1)
        exit()
print(Answer)


### FIXED CODE ###

def gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a

N,M = map(int,input().split(" "))
S = input()
T = input()
N = len(S)
M = len(T)
x = gcd(N,M)
y = int(N*M/x)

for i in range(x):
    if S[int(i*y/M)] == T[int(i*y/N)]:
        continue
    else:
        print(-1)
        exit()
print(y)
### BUGGY CODE ###

X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

C = sorted(C, reverse=True)
AB = sorted([a + b for a in A for b in B], reverse=True)

ABC_k = sorted([ab + c for ab in AB[:K] for c in C], reverse=True)

for ans in ABC_k[:K]:
    print(ans)

### FIXED CODE ###

X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

C = sorted(C, reverse=True)
AB = sorted([a + b for a in A for b in B], reverse=True)

ABC_k = sorted([ab + c for ab in AB[:K] for c in C], reverse=True)

for ans in ABC_k[:K]:
    print(ans)
### BUGGY CODE ###

import numpy as np


def LI(): return list(map(int, input().split()))
def LI_(): return list(map(lambda x: int(x) - 1, input().split()))


def cumulative_sum_ref(d1_array):
    for i in range(1, len(d1_array)):
        d1_array[i] += d1_array[i-1]


def cumulative_sum_val(d1_array):
    tmp = d1_array.copy()
    for i in range(1, len(tmp)):
        tmp[i] += tmp[i-1]
    return tmp


if __name__ == "__main__":
    N, M, Q = LI()
    LR = np.zeros((N+1, N+1), dtype='uint32')
    for i in range(M):
        l, r = LI()
        LR[l][r] += 1
    # LR = np.zeros((N + 1, N + 1), dtype='uint32')
    # LR[2][3] = 1
    # LR[3][5] = 1
    # 二次元累積和
    for i in range(1, N+1):
        for j in range(2, N+1):
            LR[i][j] += LR[i][j-1]
    for i in range(1, N+1):
        for j in range(2, N+1):
            LR[j][i] += LR[j-1][i]

    for _ in range(Q):
        p, q = LI()
        p -= 1
        result = LR[q][q] - LR[p][q] - LR[q][p] + LR[p][p]
        print(result)


### FIXED CODE ###

def LI(): return list(map(int, input().split()))
def LI_(): return list(map(lambda x: int(x) - 1, input().split()))


if __name__ == "__main__":
    N, M, Q = LI()
    LR = [[0]*(N+1) for _ in range(N+1)]
    for i in range(M):
        l, r = LI()
        LR[l][r] += 1

    # 二次元累積和
    for i in range(1, N+1):
        for j in range(1, N+1):
            LR[i][j] += LR[i][j-1]
            LR[i][j] += LR[i-1][j]
            LR[i][j] -= LR[i-1][j-1]

    for _ in range(Q):
        p, q = LI()
        p -= 1
        result = LR[q][q] - LR[p][q] - LR[q][p] + LR[p][p]
        print(result)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

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

    max_t = 0
    for i in range(N-K+1):

        if max_t < sum(P[i:i+K]):
            max_t = sum(P[i:i+K])

    print((max_t + K) / 2)

main()

### FIXED CODE ###

import sys
input = sys.stdin.readline

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

    tmp_max = sum(P[:K])
    tmp = sum(P[:K])
    for i in range(N-K):
        tmp += P[i+K]
        tmp -= P[i]

        if tmp > tmp_max:
            tmp_max = tmp

    print((tmp_max + K) / 2)

main()
### BUGGY CODE ###

s=input()
q=int(input())
x=y=z=""
i=0
for _ in range(q):
    a=list(input().split())
    if a[0]=="1":
        i+=1
        x,z=z[::-1],x[::-1]
    else:
        if a[1]=="1":x="".join([a[2],x])
        else:z="".join([z,a[2]])
print(x+s[::-1]+z if i%2 else x+s+z)

### FIXED CODE ###

s=input()
q=int(input())
i=0
x=z=""
for _ in range(q):
    a=list(input().split())
    if a[0]=="1":
        i+=1
    else:
        if a[1]=="1" and i%2==1:
            z=z+a[2]
        elif a[1]=="1" and i%2==0:     
            x=a[2]+x
        elif a[1]=="2" and i%2==1:  
            x=a[2]+x
        else:
            z=z+a[2]
print(z[::-1]+s[::-1]+x[::-1] if i%2 else x+s+z)
### BUGGY CODE ###

import numpy as np
N, K = map(int, input().split())
pi = list(map(int, input().split()))
K_sum = []
for i in range(N-K+1):
    K_sum.append(sum(pi[i:i+K])) 
index = K_sum.index(max(K_sum))
array_max = (np.array(pi[index:index+K])-1) *0.5 + 1
print(array_max.sum())

### FIXED CODE ###

N, K = map(int, input().split())
pi = list(map(int,input().split()))
def EV(x):
    return 1+(x-1)*0.5
for i in range(N):
    pi[i] = EV(pi[i])

ruisekiwa = sum(pi[0:K])
max_EV = ruisekiwa

for i in range(N-K):
    ruisekiwa = ruisekiwa + pi[i+K]-pi[i]
    if ruisekiwa > max_EV:
        max_EV = ruisekiwa
print(max_EV)
### BUGGY CODE ###

num = int(input())
hoge = list(map(int, input().split()))
fuga = 0
for i in range(num - 1):
  count = 0
  for j in range(fuga, num - 1):
    if hoge[j] == i + 1:
      count += 1
  fuga += count
  print(count)
print(0)

### FIXED CODE ###

num = int(input())
hoge = list(map(int, input().split()))

fuga = [0] * num

for i in hoge:
  fuga[i - 1] += 1
for i in fuga:
  print(i)
### BUGGY CODE ###

import collections

n, k = map(int, input().split())
a = list(map(int, input().split()))

c = collections.Counter(a)
count = 0

for i in range(len(c)):
    if i >= k:
        count += c.most_common()[i][1]

print(count)

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
count = 1
b = []

for i in range(n-1):
    if a[i] != a[i+1]:
        b.append(count)
        count = 1
    else:
        count += 1

b.append(count)

b.sort(reverse=True)

count = 0
if k < len(b):
    for i in range(k, len(b)):
        count += b[i]

print(count)
### BUGGY CODE ###

n=int(input())
from bisect import bisect_left as bl,bisect_right as br
a=list(map(int,input().split()))
l=[-a[0]]
ans=0
for i in range(1,n):
    ans+=br(l,a[i]-i)-bl(l,a[i]-i)
    l.append(-i-a[i])
    l.sort()
print(ans)

### FIXED CODE ###

n=int(input())
f={}
h=list(map(int,input().split()))
ans=0
for i in range(n):
    if i-h[i] in f:
        ans+=f[i-h[i]]
    if i+h[i] in f:
        f[i+h[i]]+=1
    else:f[i+h[i]]=1
print(ans)
### BUGGY CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
cost=[float('inf') for i in range(n)]
cost[0]=0
for i in range(n):
  for j in range(1,k+1):
    if i+j==n:
      break
    cost[i+j]=min(cost[i]+abs(h[i]-h[i+j]),cost[i+j])
print(cost[-1])

### FIXED CODE ###

import numpy as np
n,k=map(int,input().split())
h=np.array(list(map(int,input().split())),dtype=np.int64)
dp=np.full(n,10**10,dtype=np.int64)
dp[0]=0
for i in range(n-1):
  cost=np.abs(h[i]-h[i+1:i+k+1])
  np.minimum(dp[i+1:i+k+1],dp[i]+cost,out=dp[i+1:i+k+1])
print(dp[-1])
### BUGGY CODE ###

n,m,k=map(int,input().split())
ans=0
INF=10**9+7
if n<=m:
    M=-(m-1)*m*(2*m-1)//3+m*m*(m-1)
    Ms=m*m*(m-1)//2-(m-1)*m*(2*m-1)//6
    M=M%INF
    Ms=Ms%INF
    for i in range(1,n+1):
        for j in range(i,n+1):
            if i==j:
                ans=ans+Ms
            else:
                d=j-i
                ans=ans+d*m**2+M
            ans=ans%INF
else:
    (n,m)=(m,n)
    M=-(m-1)*m*(2*m-1)//3+m*m*(m-1)
    Ms=m*m*(m-1)//2-(m-1)*m*(2*m-1)//6
    M=M%INF
    Ms=Ms%INF
    for i in range(1,n+1):
        for j in range(i,n+1):
            if i==j:
                ans=ans+Ms
            else:
                d=j-i
                ans=ans+d*m**2+M
            ans=ans%INF
a=1
b=1
c=n*m-2
x=min(c,k-2)
for i in range(x):
    a=a*(c-i)
    b=b*(i+1)
ans=(ans*a//b)%INF
print(ans)


### FIXED CODE ###

n,m,k=map(int,input().split())
ans=0
INF=10**9+7
if n<=m:
    M=(m-1)*m*(2*m-1)//3
    for i in range(1,n+1):
        for j in range(i,n+1):
            if i==j:
                ans=ans+m*m*(m-1)//2-(m-1)*m*(2*m-1)//6
            else:
                d=j-i
                ans=ans+d*m+(m+d)*m*(m-1)-M
            ans=ans%INF
else:
    (n,m)=(m,n)
    M=(m-1)*m*(2*m-1)//3
    for i in range(1,n+1):
        for j in range(i,n+1):
            if i==j:
                ans=ans+m*m*(m-1)//2-(m-1)*m*(2*m-1)//6
            else:
                d=j-i
                ans=ans+d*m+(m+d)*m*(m-1)-M
            ans=ans%INF
import math
ans=(math.factorial(n*m-2)//(math.factorial(n*m-k)*math.factorial(k-2)))*ans
ans=ans%INF
print(ans)
### BUGGY CODE ###

# https://atcoder.jp/contests/abc138/submissions/7971841

n, q = map(int, input().split())

g = [set() for _ in range(n)]
for _ in range(n - 1):
    a, b = (int(x) - 1 for x in input().split())
    g[a].add(b)
    g[b].add(a)

ctr = [0] * n
for _ in range(q):
    it = map(int, input().split())
    p = next(it) - 1
    x = next(it)
    ctr[p] += x

st = [0]
par = [-1] * n
while st:
    v = st.pop()
    for u in g[v]:
        if u == par[v]: continue
        par[u] = v
        ctr[u] += ctr[v]
        st.append(u)
print(*ctr)


### FIXED CODE ###

n, q = map(int, input().split())

g = [set() for _ in range(n)]
for _ in range(n - 1):
    a, b = (int(x) - 1 for x in input().split())
    g[a].add(b)
    g[b].add(a)

ctr = [0] * n
for _ in range(q):
    it = map(int, input().split())
    p = next(it) - 1
    x = next(it)
    ctr[p] += x

st = [(0, -1)]
while st:
    v, par = st.pop()
    for u in g[v]:
        if u == par: continue
        ctr[u] += ctr[v]
        st.append((u, v))
print(*ctr)
### BUGGY CODE ###

n = int(input())
arr = []
for i in range(n):
    a = list(map(ord,list(input())))
    arr.append(a)

import numpy as np
# print(np.array(arr))

ans = 0

for i in range(n):
    ok = True
    for j in range(n):
        for k in range(n):
            if j == k:
                continue
            l = j + i
            if l > n-1:
                l = l-n
                
            m = k + i
            if m > n-1:
                m = m-n
            # print(l,k,i)
            # print(arr[l][k],arr[k][l])
            if arr[l][k] != arr[m][j]:
                ok = False
                break

    # print("####")
    if ok:
        ans += n



print(ans)

### FIXED CODE ###

n = int(input())
arr = []
for i in range(n):
    a = list(map(ord,list(input())))
    arr.append(a)


ans = 0

for i in range(n):
    ok = True
    for j in range(n):
        for k in range(n):
            if j == k:
                continue
            l = j + i
            if l > n-1:
                l = l-n

            m = k + i
            if m > n-1:
                m = m-n
            # print(l,k,i)
            # print(arr[l][k],arr[k][l])
            if arr[l][k] != arr[m][j]:
                ok = False
                break

    # print("####")
    if ok:
        ans += n



print(ans)
### BUGGY CODE ###

from collections import deque

H, W = map(int, input().split())
H += 2; W += 2
grid = []
grid.append(["#" * W])
for h in range(H-2):
  grid.append(["#" + input() + "#"])
grid.append(["#" * W])

INF = 10**9
ans = 0
for h in range(1, H-1):
  for w in range(1, W-1):
    
    if grid[h][0][w]=="#": continue

    dist = [[INF]*W for i in range(H)]
    dist[h][w] = 0 
    q = deque([(h,w)])

    while(q):
      v_h, v_w = q.popleft()
      d_v = dist[v_h][v_w]
      for n_h, n_w in ((v_h, v_w-1),(v_h, v_w+1),(v_h-1, v_w),(v_h+1, v_w)):
        if grid[n_h][0][n_w]=="#": continue
        d_n = d_v + 1
        if d_n > dist[n_h][n_w]:
          continue
        dist[n_h][n_w] = d_n
        q.append((n_h,n_w))

      new_dist =[]
      for l in dist:
        new_dist.append([x for x in l if x < INF])
      #print(new_dist)
      LL = [max(l) if len(l)>0 else 0 for l in new_dist]
      #print(LL)
      ans = max(ans, max(LL))

print(ans)

      


    

### FIXED CODE ###

from collections import deque
import numpy as np

H,W = map(int,input().split())
maze = [input() for _ in range(H)]

ans = 0
for x in range(H):
    for y in range(W):
        #壁からはスタートできない
        if maze[x][y] == "#":
            continue

        #初期化
        distance = [[0]*W for _ in range(H)]
        #start位置
        stack = deque([[x,y]])

        while stack:
            h,w = stack.popleft()
            for i,j in [[1,0],[-1,0],[0,1],[0,-1]]:
                new_h, new_w = h+i, w+j
                if new_h < 0 or new_w < 0 or new_h >= H or new_w >= W:
                    continue
                elif maze[new_h][new_w] != "#" and distance[new_h][new_w] == 0:
                    distance[new_h][new_w] = distance[h][w]+1
                    stack.append([new_h, new_w])

        #start位置は0で初期化
        distance[x][y] = 0
        ans = max(ans, np.max(distance))

print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
q = int(input())
l = []

for _ in range(q):
    b, c = map(int, input().split())
    if b not in a:
        l.append(a)
        continue
    a = [c if e == b else e for e in a]
    l.append(a)

for a in l:
    print(sum(a))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
q = int(input())

l = [0] * 100001
for i in a:
    l[i] += 1

s = sum(a)

for _ in range(q):
    b, c = map(int, input().split())
    s += (c - b) * l[b]
    l[c] += l[b]
    l[b] = 0
    print(s)
### BUGGY CODE ###

n, k = map(int, input().split())
l = list(map(int, input().split()))
 
dp = [float('inf') for _ in range(n)]
dp[0] = 0

def frog_2(N, K):
    for i in range(n-1):
        for j in range(1, k+1):
            if i+j <= n-1:
                temp = dp[i] + abs(l[i+j] - l[i])
                if temp < dp[i+j]:
                    dp[i+j] = temp
     
    print(dp[-1])

frog_2(n, k)

### FIXED CODE ###

n, k = map(int, input().split())
l = list(map(int, input().split()))

dp = [float('inf') for _ in range(n)]
dp[0] = 0

for i in range(n-1):
    for j in range(1, k+1):
        if i+j <= n-1:
            temp = dp[i] + abs(l[i+j] - l[i])
            if temp < dp[i+j]:
                dp[i+j] = temp

print(dp[-1])
### BUGGY CODE ###

N = str(input())
l=len(N)
count :int=0
ll=l
i :int=0
while i<int(ll)-3:
  span :int=4
  while span<int(l)+1:
    if int(N[i:i+span])%2019==0:
      count+=1
    span+=1
  i+=1
  l-=1

print(count)

### FIXED CODE ###

import time

s = input()[::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d%= 2019
    counts[num] += 1

#start = time.time()#計測始
ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans) # 答えの出力
#end = time.time()#計測終
#print(f"{end-start}sec.")#計測出力
### BUGGY CODE ###

K,S = map(int, input().split())

ans = 0
if K*3<S:
  print(0)
  exit()

for x in range(K, -1, -1):
  if x >S:
    continue
  for y in range(K, -1, -1):
    if x+y >S:
      continue
    for z in range(K, -1, -1):
      if x+y+z==S:
        ans+=1
      elif x+y+z<S:
        break

print(ans)

### FIXED CODE ###

K,S = map(int, input().split())

ans = 0
if K*3<S:
  print(0)
  exit()

for x in range(K, -1, -1):
  if x >S:
    continue
  for y in range(min(S-x, K), -1, -1):
    if x+y >S:
      continue
    for z in range(min(S-x-y, K), -1, -1):
      if x+y+z==S:
        ans+=1
      elif x+y+z<S:
        break

print(ans)
### BUGGY CODE ###

n, m = map(int,input().split())

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

a = {}

for _ in range(m):
    x1, x2 = map(int,input().split())

    if a.get(x1) is None:
        a[x1] = {x2}
    else:
        temp = a[x1].copy()
        temp.add(x2)
        a[x1] = temp
    
    if a.get(x2) is None:
        a[x2] = {x1}
    else:
        temp = a[x2].copy()
        temp.add(x1)
        a[x2] = temp

res = 0

for i in range(n):
    if a.get(i + 1) is None:
        res += 1
        continue

    flag = True

    temp = a[i + 1].copy()

    for j in temp:
        if h[i] <= h[j - 1]:
            flag = False

    if flag:
        res += 1

print(res)

### FIXED CODE ###

n, m = map(int,input().split())

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

res =  [True] * n

for _ in range(m):
    x1, x2 = map(int,input().split())

    if h[x1 - 1] <= h[x2 - 1]:
        res[x1 - 1] = False
    if h[x2 - 1] <= h[x1 - 1]:
        res[x2 - 1] = False

print(sum(res))
### BUGGY CODE ###

def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A

def digits2int(c, L, MOD):
    base = 0
    for i in range(L):
        factor = (1 << i) % MOD
        for j in range(c[i]):
            base = (base + factor) % MOD
    return base


def solve(N, A, L=60, MOD=10**9+7):
    # j桁目のビットが1であるものの数を、累積和として記憶
    count_ones = [[0 for j in range(L+1)] for i in range(N+1)]
    for i in range(N):
        for j in range(L):
            count_ones[i+1][j] = count_ones[i][j] + ((A[i] >> j) & 1)
    # A[i] と A[j] (i<j) のxorをとる
    modsum = 0
    for i in range(N-1):
        c = [0 for j in range(L)]
        for j in range(L):
            if ((A[i] >> j) & 1) == 0:
                c[j] = count_ones[N][j] - count_ones[i+1][j]
            else:
                c[j] = (N-i-1) - (count_ones[N][j] - count_ones[i+1][j])
        modsum = (modsum + digits2int(c, L, MOD)) % MOD
    return modsum


if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))

### FIXED CODE ###

def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A


def solve(N, A, L=60, MOD=10**9+7):
    modsum = 0
    for j in range(L):
        count_ones = sum([1 for a in A if (a >> j) & 1])
        # count_ones = sum([(A[i] >> j) & 1 for i in range(N)])
        count_zeros = N - count_ones
        # MODは一度にとる
        modsum +=  (1<<j) * count_zeros * count_ones
        modsum %= MOD
    return modsum


if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))
### BUGGY CODE ###

from itertools import combinations
N = int(input())
As = list(map(int,input().split()))
MOD = 7+10**9
print(sum([(Ai*Aj)%MOD for Ai,Aj in combinations(As,2)])%MOD)

### FIXED CODE ###

N = int(input())
As = list(map(int,input().split()))
MOD = 7+10**9
ans = 0
Asum = sum(As)
for i in range(N-1):
  Asum -= As[i]
  ans = (ans+As[i]*Asum)%MOD
print(ans)
### BUGGY CODE ###

import copy
N = int(input())
A = [int(input()) for i in range(N)]

for i in range(N):
    A_copy = copy.deepcopy(A)
    A_copy.pop(i)
    print(max(A_copy))


### FIXED CODE ###

import copy
N = int(input())
A = [int(input()) for i in range(N)]
set_A = list(set(A))
set_A.sort(reverse=True)
A_copy = copy.deepcopy(A)
A_copy.sort(reverse=True)
Max = max(A)
cnt = 0
for i in range(N):
    if A[i] == Max:
        cnt += 1
for i in range(N):
    if A[i] == Max:
        if cnt > 1:
            print(Max)
        else:
            print(set_A[1])
    else:
        print(Max)
### BUGGY CODE ###

import sys
from collections import deque

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
AB = [lr() for _ in range(N)]
#Bが報酬
AB = [(a, b) for a, b in AB if a<=M]
AB.sort(reverse=True, key=lambda x: x[1])
AB = deque(AB)
answer = 0
used = set()
while AB:
    x, y = AB.popleft()
    if x > M:
        continue
    else:
        while x in used:
            x += 1
        if x > M:
            continue
        used.add(x)
        answer += y

print(answer)
        

### FIXED CODE ###

import heapq

n,m=map(int,input().split())
jobs=[[] for _ in range(m)]
for i in range(n):
    d,r=map(int,input().split())
    if d-1<m:
        jobs[d-1].append(-r)
rewards=0
heap=[]
for i in range(m):
    for reward in jobs[i]:
        heapq.heappush(heap,reward)
    if len(heap)>0:
        rewards+=-heapq.heappop(heap)

print(rewards)
### BUGGY CODE ###

import sys
import numpy as np

def is_enough(H, A, B, T):
    H = H - (B * T)
    H = H[(H > 0)]

    cnt = 0
    diff = A - B
    for h in H:
        cnt += (h + diff - 1) // diff
        if cnt > T:
            return False

    return True


def main():
    input = sys.stdin.readline
    N, A, B = map(int, input().split())
    H = np.array([int(input()) for _ in range(N)])

    R = (H.max() + B - 1) // B
    L = 0
    while R - L > 1:
        c = (R + L) // 2
        if is_enough(H,  A, B, c):
            R = c
        else:
            L = c

    return R


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


### FIXED CODE ###

import sys

def is_enough(H, A, B, T):
    cnt = 0
    diff = A - B
    base = B * T
    for h in H:
        if h <= base:
            continue

        cnt += (h - base + diff - 1) // diff
        if cnt > T:
            return False

    return True


def main():
    input = sys.stdin.readline
    N, A, B = map(int, input().split())
    H = [int(input()) for _ in range(N)]

    R = (max(H) + B - 1) // B
    L = (min(H) + A - 1) // A
    while R != L:
        c = (R + L) // 2
        if is_enough(H,  A, B, c):
            R = c
        else:
            L = c + 1

    return L


if __name__ == '__main__':
    print(main())
### BUGGY CODE ###

N,M = map(int,input().split())
a = M//N
c = True
while c:
    if M%a == 0:
        c = False
    else:
        a -= 1
print(a)


### FIXED CODE ###

from bisect import bisect_right

def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    ass.sort()
    return ass 


N,M = map(int,input().split())
a = M//N
c = True

li = divisor(M)

x = bisect_right(li,a)

print(li[x-1])
### BUGGY CODE ###

N = int(input())

P = [int(i) for i in input().split()]

cnt = 0
for i in range(1, N + 1):
  target = P[:i]
  if target[-1] == min(target):
    cnt += 1
  
print(cnt)

### FIXED CODE ###

N = int(input())

P = [int(i) for i in input().split()]

cnt = 0
min_num = P[0]
for num in P:
  if num == min_num:
    cnt += 1
  elif num < min_num:
    cnt += 1
    min_num = num
  
print(cnt)
### BUGGY CODE ###

n, k, *p = map(int, open(0).read().split())

for i, p_i in enumerate(p):
  p[i] = (1+p_i)/2

e_v = []
for j in range(n-k+1):
  e_v.append(sum(p[j:j+k]))

print(max(e_v))



### FIXED CODE ###

n, k, *p = map(int, open(0).read().split())

q = []
for p_i in p:
  q.append((p_i+1)/2)
  
s = [0]
pre_s = 0
for q_i in q:
  pre_s += q_i
  s.append(pre_s)

ans = 0
for i in range(n-k+1):
  if ans < (s[i+k] - s[i]):
    ans = s[i+k] - s[i]
    
print(ans)
### BUGGY CODE ###

n, s = map(int, input().split())
a = list(map(int, input().split()))
mod = 998244353
dp = [[0] * (s + 1) for i in range(n + 1)]
dp[0][0] = 1
for i in range(1, n + 1):
    for j in range(s + 1):
        dp[i][j] += dp[i - 1][j] * 2
        dp[i][j] %= mod
        if a[i - 1] + j <= s:
            dp[i][a[i - 1] + j] += dp[i - 1][j]
            dp[i][a[i - 1] + j] %= mod
print(dp[n][s])

### FIXED CODE ###

n, s = map(int, input().split())
a = list(map(int, input().split()))
mod = 998244353
dp = [[0] * (s + 1) for i in range(n + 1)]
dp[0][0] = 1
for i in range(1, n + 1):
    for j in range(s + 1):
        dp[i][j] += dp[i - 1][j] * 2
        dp[i][j] %= mod
        if a[i - 1] + j <= s:
            dp[i][a[i - 1] + j] += dp[i - 1][j]
            dp[i][a[i - 1] + j] %= mod
print(dp[n][s])
### BUGGY CODE ###

over = 10**18

n = int(input())
a = list(map(int, input().split()))
ans = 1;
for i in range(n):
  ans = ans * a[i]
  if ans > over:
    ans = -1
if ans < 0:
  print(-1)
else:
  print(ans)


### FIXED CODE ###

over = 10**18

n = int(input())
a = list(map(int, input().split()))
ans = 1;

for i in range(n):
  if a[i] == 0:
    ans = 0
if not ans == 0:
  for i in range(n):
    ans = ans * a[i]
    if ans > over:
      ans = -1
      break
if ans < 0:
  print(-1)
else:
  print(ans)