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

n = int(input())
nn = [x for x in range(n)]
p = list(map(int,input().split()))
check = []
for i in nn:
    for j in range(0,i+1):
        if p[i] > p[j]:
            check.append(i)
            continue
print(n-len(set(check)))

### FIXED CODE ###

n = int(input())
p = list(map(int,input().split()))
ans = 0
mini = n
for i in p:
    if i <= mini:
        ans += 1
        mini = i 
print(ans)
### BUGGY CODE ###

S = list(input())
Q = int(input())

for i in range(Q):
    que = list(input().split())
    if que[0] == str(1):
        S = S[::-1]
    else:
        if int(que[1]) == 1:
            S.insert(0, que[2])
        else:
            S.append(que[2])

print(''.join(S))


### FIXED CODE ###

from collections import deque

S = deque(input())
Q = int(input())

d = 1
c = 1
for i in range(Q):
    que = list(input().split())
    if que[0] == str(1):
        d += c
        c *= -1
    else:
        if (int(que[1]) ^ d) == 0:
            S.appendleft(que[2])
        else:
            S.append(que[2])

print(''.join(S) if d == 1 else ''.join(S)[::-1])
### BUGGY CODE ###

import bisect

n = int(input())
a = list(map(int, input().split()))
a.sort()
k = len(a)
ok = [0] * k
for i in range(k):
    if i < k - 1 and a[i] == a[i + 1]:
        ok[i] = 1
        ok[i+1] = 1;
        continue

    if a[i] < 2 * 100:
        for j in range(i + 1, k):
            if a[j] % a[i] == 0:
                ok[j] = 1
    else:   
        times = 2
        while a[i] * times <= a[-1]:
            r = bisect.bisect_left(a, a[i] * times + 1)
            l = bisect.bisect_left(a, a[i] * times)
            if r != l:
                for idx in range(l, r):
                    ok[idx] = 1
            times += 1
print(len([i for i in ok if i == 0]))
# print(ok) WAはどこ？


### FIXED CODE ###

import bisect

n = int(input())
a = list(map(int, input().split()))
a.sort()
k = len(a)
ok = [0] * k
for i in range(k):
    if i < k - 1 and a[i] == a[i + 1]:
        ok[i] = 1
        ok[i+1] = 1;
        continue

    if a[i] < 2 * 100:
        for j in range(i + 1, k):
            if a[j] % a[i] == 0:
                ok[j] = 1
    else:   
        times = 2
        while a[i] * times <= a[-1]:
            r = bisect.bisect_left(a, a[i] * times + 1)
            l = bisect.bisect_left(a, a[i] * times)
            if r != l:
                for idx in range(l, r):
                    ok[idx] = 1
            times += 1
print(len([i for i in ok if i == 0]))
# print(ok) WAはどこ？
### BUGGY CODE ###

import sys
input = sys.stdin.readline
N, C = map(int, input().split())
dic = [[] for _ in range(C + 1)]
for _ in range(N):
    s, t, c = map(int, input().split())
    dic[c].append([s, t])
for c in range(C + 1):
    dic[c] = sorted(dic[c])
    l = len(dic[c])
    i = 0
    while i < l - 1:
        if i < l - 1 and dic[c][i][1] == dic[c][i + 1][0]:
            dic[c][i + 1][0] = dic[c][i][0]
            dic[c].pop(i)
            l -= 1
        else:
            i += 1
f = [0 for _ in range(100002)]
for c in range(C + 1):
    for t in dic[c]:
        f[t[0]] += 1
        f[t[1] + 1] -= 1

ans = 0
for i in range(1, 100001):
    f[i] += f[i - 1]
    if ans < f[i]:
        ans = f[i]
print(ans)


### FIXED CODE ###

import sys

def main():
    input = sys.stdin.readline
    N, C = map(int, input().split())
    dic = [[] for _ in range(C + 1)]
    for _ in range(N):
        s, t, c = input().split()
        dic[int(c)].append([int(s), int(t)])
    for c in range(C + 1):
        l = len(dic[c])
        if l == 1:
            continue
        dic[c] = sorted(dic[c])
        i = 0
        while i < l - 1:
            if i < l - 1 and dic[c][i][1] == dic[c][i + 1][0]:
                dic[c][i + 1][0] += 1
            else:
                i += 1
    f = [0 for _ in range(100002)]
    for c in range(C + 1):
        for t in dic[c]:
            f[t[0]] += 1
            f[t[1] + 1] -= 1
    ans = 0
    for i in range(1, 100001):
        f[i] += f[i - 1]
        if ans < f[i]:
            ans = f[i]
    print(ans)

if __name__ == "__main__":
    main()
### BUGGY CODE ###

import collections
K = int(input())
Q = collections.deque([(1, 1)])
searched = set()
while True:
    n, d = Q.popleft()
    r = n % K
    if not r in searched:
        if r == 0:
            break
        else:
            searched.add(r)
            Q.append((n + 1, d + 1))
            Q.appendleft((n * 10, d))
print(d)
# https://img.atcoder.jp/arc084/editorial.pdf


### FIXED CODE ###

import collections
K = int(input())
Q = collections.deque([(1, 1)])
searched = set()
while True:
    n, d = Q.popleft()
    r = n % K
    if not r in searched:
        if r == 0:
            break
        else:
            searched.add(r)
            Q.append((n + 1, d + 1))
            Q.appendleft((n * 10 % K, d))
print(d)
# https://img.atcoder.jp/arc084/editorial.pdf
### BUGGY CODE ###

from collections import defaultdict


def calc_parents(N, adj_nodes, root=0):
    parents = [-1 for _ in range(N)]
    frontier = [root]
    parents[root] = root
    while len(frontier) > 0:
        node = frontier.pop()
        for child in adj_nodes[node]:
            if parents[child] >= 0:
                continue
            frontier.append(child)
            parents[child] = node
    return parents


def sum_counts(N, parents, counter_roots):
    counter = [0 for _ in range(N)]
    for node in range(N):
        current_node = node
        parent_node = parents[current_node]
        s = counter_roots[current_node]
        while current_node != parent_node:
            current_node = parent_node
            parent_node = parents[current_node]
            s += counter_roots[current_node]
        counter[node] += s
    return counter


def main():
    N, Q = list(map(int, input().split(' ')))
    adj_nodes = defaultdict(list)
    for _ in range(N - 1):
        a, b = list(map(int, input().split(' ')))
        a -= 1
        b -= 1
        adj_nodes[a].append(b)
        adj_nodes[b].append(a)
    parents = calc_parents(N, adj_nodes)
    counter_roots = [0 for _ in range(N)]
    for _ in range(Q):
        p, x = list(map(int, input().split(' ')))
        p -= 1
        counter_roots[p] += x
    counter = sum_counts(N, parents, counter_roots)
    print(' '.join(map(str, counter)))


if __name__ == '__main__':
    main()

### FIXED CODE ###

from collections import defaultdict


def sum_counter(N, adj_nodes, counter_roots, root=0):
    parents = [-1 for _ in range(N)]
    counter = [0 for _ in range(N)]
    frontier = [root]
    counter[root] += counter_roots[root]
    parents[root] = root
    while len(frontier) > 0:
        parent = frontier.pop()
        for child in adj_nodes[parent]:
            if parents[child] >= 0:
                continue
            frontier.append(child)
            parents[child] = parent
            counter[child] += counter[parent] + counter_roots[child]
    return counter


def main():
    N, Q = list(map(int, input().split(' ')))
    adj_nodes = defaultdict(list)
    for _ in range(N - 1):
        a, b = list(map(int, input().split(' ')))
        a -= 1
        b -= 1
        adj_nodes[a].append(b)
        adj_nodes[b].append(a)
    counter_roots = [0 for _ in range(N)]
    for _ in range(Q):
        p, x = list(map(int, input().split(' ')))
        p -= 1
        counter_roots[p] += x
    c = sum_counter(N, adj_nodes, counter_roots)
    print(' '.join(map(str, c)))


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

import sys


def tran(A):
    temp = []
    for i in range(len(A)):
        if i == 0:
            temp += [A[i]]
        elif A[i] != A[i - 1]:
            temp += [A[i]]
    return temp


def find(A):
    # assume consecutive elements
    dp = [1] * len(A) + [1]

    current_dic = {}

    MOD = 10**9 + 7

    for i in range(len(A)):

        if i == 0:
            current_dic[A[i]] = [i]
        else:
            temp = dp[i - 1]
            if A[i] in current_dic:
                for x in current_dic[A[i]]:
                    temp += dp[x - 1]
                    temp %= MOD
                current_dic[A[i]] += [i]
            else:
                current_dic[A[i]] = [i]

            dp[i] = temp
    # print(dp)
    return dp[-2] % MOD


N=int(input())
A=[]
for i in range(N):
    A+=[int(input())]


print(find(tran(A)))


### FIXED CODE ###

import sys


def tran(A):
    temp = []
    for i in range(len(A)):
        if i == 0:
            temp += [A[i]]
        elif A[i] != A[i - 1]:
            temp += [A[i]]
    return temp


def find(A):
    # assume consecutive elements
    dp = [1] * len(A) + [1]

    current_dic = {}

    MOD = 10**9 + 7

    for i in range(len(A)):

        if i == 0:
            current_dic[A[i]] = 1
        else:
            temp = dp[i - 1]
            if A[i] in current_dic:
                temp += current_dic[A[i]]
                temp %= MOD
                current_dic[A[i]] += dp[i - 1]
                current_dic[A[i]] %= MOD
            else:
                current_dic[A[i]] = dp[i - 1]

            dp[i] = temp
    # print(dp)
    return dp[-2] % MOD


N = int(input())
A = []
for i in range(N):
    A += [int(input())]



print(find(tran(A)))
### BUGGY CODE ###

from bisect import bisect_right
import math
N,D,A = map(int,input().split())
X = sorted([list(map(int,input().split())) for _ in range(N)],key=lambda x:x[0])
X.insert(0,[-1,-1])
def update(m,i,j,a):  #ノード値の更新 i<=x<j
    l,r = T[m][0]
    if r<=i or l>=j:
        return 
    if i<=l and r<=j:
        T[m][1] -= a*(r-l)
    else:
        update(2*m,i,j,a)
        update(2*m+1,i,j,a)
def find(m,i):  #node[i]の評価
    l,r = T[m][0]
    if l==i and r==i+1:
        return T[m][1]
    if l<=i and r>=i+1:
        T[2*m][1] += T[m][1]//2
        T[2*m+1][1] += T[m][1]//2
        T[m][1] = 0
        l1,r1 = T[2*m][0]
        if l1<=i and r1>=i+1:
            return find(2*m,i)
        else:
            return find(2*m+1,i)

k = 0
n = N
while 2**k<N:
    k += 1
N = 2**k  #一番下の層のノード数
T = [[] for _ in range(2*N)]  #木の初期化　意図は1-origin
for i in range(N,2*N):
    T[i] = [[i-(N-1),i-(N-1)+1],X[i-(N-1)][1] if i-(N-1)<n+1 else 0]  #区間の右端は含まない
m = N//2
while m>0:
    for i in range(m,2*m):
        T[i] = [[T[2*i][0][0],T[2*i+1][0][1]],0]  #各ノードは区間とノードの値を持つ．
    m = m//2  #ルートはT[1]
Pos = [X[i][0] for i in range(n+1)]  
cur = 1
cnt = 0
while cur<n+1:
    x = X[cur][0]+D
    k = math.ceil(X[cur][1]/A)
    indr = bisect_right(Pos,x+D)
    cnt += k
    update(1,cur,indr,k*A)
    flag = 0
    for i in range(cur,n+1):
        X[i][1] = find(1,i)
        if X[i][1]>0:
            cur = i
            flag = 1
            break
    if flag==0:break
print(cnt)

### FIXED CODE ###

from bisect import bisect_right
N,D,A = map(int,input().split())
X = sorted([list(map(int,input().split())) for _ in range(N)],key=lambda x:x[0])
B = [0 for _ in range(N+1)]
cnt = 0
cur = 0
delta = 0
flag = 0
while cur<N:
    x = X[cur][0]
    h = X[cur][1]+delta
    if h%A==0:
        n = h//A
    else:
        n = h//A+1
    ind = bisect_right(X,[x+2*D,10**9+1])
    B[cur] += -n*A
    B[ind] += n*A
    cnt += n
    flag = 0
    for i in range(cur,N):
        delta += B[i]
        B[i] = 0
        if X[i][1]+delta>0:
            cur = i
            flag = 1
            break
    if flag==0:
        cur = N
print(cnt)
### BUGGY CODE ###

import sys
#大きすぎるとダメ
sys.setrecursionlimit(2505)
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
inf=1000000000000000
d=[[inf]*w for i in range(h)]


def dfs(i,j):
    global h,w,s
    nex=[(0,-1),(0,1),(-1,0),(1,0)]
    for k in range(4):
        l,m=i+nex[k][0],j+nex[k][1]
        if 0<=i+nex[k][0]<h and 0<=j+nex[k][1]<w:
            if s[l][m]=="." and d[l][m]>d[i][j]+1:
                d[l][m]=d[i][j]+1
                dfs(l,m)
d[0][0]=0
dfs(0,0)
ans=0
for i in range(h):
    for j in range(w):
        if s[i][j]==".":
            ans+=1
if d[h-1][w-1]==inf:
    print(-1)
else:
    print(ans-d[h-1][w-1]-1)




### FIXED CODE ###

#一個だけRE、わからねえ
#解答見る
import sys
sys.setrecursionlimit(1005)
h,w=map(int,input().split())

def go_next(I,J,n):
    n+=1
    global dp,w,h
    if n>1000:
        return
    if 0<=I<h-1:
        if x[I+1][J]=="." and dp[I+1][J]>dp[I][J]+1:
            dp[I+1][J]=dp[I][J]+1
            go_next(I+1,J,n)
    if 0<I<=h-1:
        if x[I-1][J]=="." and dp[I-1][J]>dp[I][J]+1:
            dp[I-1][J]=dp[I][J]+1
            go_next(I-1,J,n)
    if 0<=J<w-1:
        if x[I][J+1]=="." and dp[I][J+1]>dp[I][J]+1:
            dp[I][J+1]=dp[I][J]+1
            go_next(I,J+1,n)
    if 0<J<=w-1:
        if x[I][J-1]=="." and dp[I][J-1]>dp[I][J]+1:
            dp[I][J-1]=dp[I][J]+1
            go_next(I,J-1,n)

x=[]
for i in range(h):
    x.append(list(input()))
#print(x)
c=0
for i in range(h):
    for j in range(w):
        if x[i][j]==".":
            c+=1
dp=[[10000000000 for i in range(w)]for j in range(h)]
dp[0][0]=1
go_next(0,0,0)
if dp[h-1][w-1]==10000000000:
    print(-1)
else:
    print(c-dp[h-1][w-1])
### BUGGY CODE ###

s = input()
q = int(input())
hanten = True
atm = ""
kts = ""
for i in range(q):
    l = input().split()
    if l[0] == "1":
        hanten = not hanten
    else:
        if l[1] == "1":
            if hanten == True:
                atm = l[2] + atm
            else:
                kts = kts + l[2]
        else:
            if hanten == True:
                kts = kts + l[2]
            else:
                atm = l[2] + atm

ans = atm + s + kts
if hanten == False:
    print(ans[::-1])
else:
    print(ans)

### FIXED CODE ###

s = input()
q = int(input())
hanten = True
atm = ""
kts = ""
for i in range(q):
    l = input().split()
    if l[0] == "1":
        hanten = not hanten
    else:
        if l[1] == "1":
            if hanten:
                atm = l[2] + atm
            else:
                kts = kts + l[2]
        else:
            if hanten:
                kts = kts + l[2]
            else:
                atm = l[2] + atm

ans = atm + s + kts
if hanten == False:
    print(ans[::-1])
else:
    print(ans)
### BUGGY CODE ###

n = int(input())

for k in range(n):
    a = input()
    b = input()
    len_a, len_b = len(a), len(b)
    table = [[0] * (len_b +1) for i in range(len_a + 1)]
    
    for i in range(len_a):
        a_i = a[i]
        table_i = table[i]
        for j in range(len_b):
            if a_i == b[j]:
                table[i+1][j+1] = table_i[j] + 1
            else:
                table[i+1][j+1] = max(table_i[j+1],table[i+1][j])
    print(table[len_a][len_b])

### FIXED CODE ###

def Ics(X, Y):
    m = len(X)
    n = len(Y)
    c1 = [0] * (n + 1)
    for i in range(m):
        d = X[i]
        c2 = c1[:]
        for j in range(n):
            if (d == Y[j]):
                c1[j + 1] = c2[j] + 1
            elif (c1[j + 1] < c1[j]):
                c1[j + 1] = c1[j]
    return (c1[-1])
 
q = int(input().rstrip())
t = []
for i in range(q):
    s1 = input().rstrip()
    s2 = input().rstrip()
    t.append(Ics(s1, s2))
print(*t, sep = "\n")
### BUGGY CODE ###

s = input()

arr = s[1:len(s)-1].split("LR")
arr = ["R"+i+"L" for i in arr]
solution_array = []

for i in arr:
    l = len(i)
    count = 1
    for j in range(l):
        if i[j] == "L":
            count = j
            break
    if count%2 != 0:        
        rcount = l - l//2
        lcount = l//2
    else:
        rcount = l//2
        lcount = l - l//2
    tmparray = [0]*l
    tmparray[count-1] = rcount
    tmparray[count] = lcount
    solution_array = solution_array + tmparray

print(" ".join(map(str, solution_array)))

### FIXED CODE ###

s = input()
l = len(s)

arr = [1]*l

for i in range(l-2):
    if s[i] == "R":
        if s[i+1] == "R":
            arr[i+2] += arr[i]
            arr[i] = 0
        
for i in range(l-1,1,-1):
    if s[i] == "L":
        if s[i-1] == "L":
            arr[i-2] += arr[i]
            arr[i] = 0
        
print(*arr)
### BUGGY CODE ###

import sys
from collections import deque
if sys.platform =='win32':
  sys.stdin=open('./input.txt')
input = sys.stdin.readline
def MAP(): return [int(x) for x in input().split()]

dy = [-1,0,1,0]
dx = [0,-1,0,1]

H, W = [int(s) for s in input().split()]

M = []

for i in range(H):
	M.append([s for s in input().rstrip()]) 

syx = []
for i in range(H):
	for j in range(W):
		if M[i][j] == '#': syx.append([i,j])
# print(syx)

dist = [[-1 for _ in range(W)] for _ in range(H)]
queue = deque()

for s in syx:
	dist[s[0]][s[1]] = 0

queue.append(syx)

while queue:
	nodelist = queue.popleft()
	# print(nodelist)
	nextnode = []

	for node in nodelist:
		y, x = node
		# print(y,x)
		
		for i in range(4):
			ny = y+dy[i]
			nx = x+dx[i]
			# print(ny, nx)
			
			if ny>=H or ny<0 or nx>=W or nx<0:
				continue
			if dist[ny][nx] != -1:
				continue
			
			if M[ny][nx] == '.':
				dist[ny][nx] = dist[y][x]+1
				nextnode.append([ny,nx])

	# print(nextnode)
	if nextnode:
		queue.append(nextnode)

ans = 0
for d in dist:
  ans = max(ans, max(d))
print(ans)

### FIXED CODE ###

import sys
from collections import deque
if sys.platform =='win32':
  sys.stdin=open('./input.txt')
input = sys.stdin.readline
def MAP(): return [int(x) for x in input().split()]

dy = [-1,0,1,0]
dx = [0,-1,0,1]

H, W = [int(s) for s in input().split()]

M = []

for i in range(H):
	M.append([s for s in input().rstrip()]) 

syx = []
for i in range(H):
	for j in range(W):
		if M[i][j] == '#': syx.append([i,j])
# print(syx)

dist = [[-1 for _ in range(W)] for _ in range(H)]
queue = deque()

for s in syx:
	dist[s[0]][s[1]] = 0

queue.append(syx)

while queue:
	nodelist = queue.popleft()
	# print(nodelist)
	nextnode = []

	for node in nodelist:
		y, x = node
		# print(y,x)
		
		for i in range(4):
			ny = y+dy[i]
			nx = x+dx[i]
			# print(ny, nx)
			
			if ny>=H or ny<0 or nx>=W or nx<0:
				continue
			if dist[ny][nx] != -1:
				continue
			
			if M[ny][nx] == '.':
				dist[ny][nx] = dist[y][x]+1
				nextnode.append([ny,nx])

	# print(nextnode)
	if len(nextnode)!=0:
		queue.append(nextnode)

ans = 0
for d in dist:
  ans = max(ans, max(d))
print(ans)
### BUGGY CODE ###

n,k=map(int,input().split())
ans=float('inf')
if k == 1:
    print(0)
    exit()
elif n < k :
    print(min(n,k-n))
else:
    for i in range(n):
        n=abs(n-k)
        ans=min(ans,n)
    
    print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
print(min(n%k,k-n%k))
### BUGGY CODE ###

from collections import deque
import numpy as np

H, W = map(int, input().rstrip().split())
checked = [[-1]*W for i in range(H)]

queue = deque([])

# 初期化
# 0 => 黒、 -1 => 白
for i in range(H):
    row = input().rstrip()
    for j in range(W):
        if row[j] == "#":
            checked[i][j] = 0
            queue.append((i, j))


directions = [(0, 1), (0, -1), (1, 0), (-1, 0)]
# 黒の周辺4方向のうち、白だったら黒にする
while queue:
    x, y = queue.popleft()

    # 周囲探索
    for dx, dy in directions:
        xx = x + dx
        yy = y + dy
        if xx < 0 or xx >= H:
            continue

        if yy < 0 or yy >= W:
            continue

        if checked[xx][yy] == -1:
            checked[xx][yy] = checked[x][y] + 1
            queue.append((xx, yy))

ans = 0
for i in range(H):
    for j in range(W):
        if ans < checked[i][j]:
            ans = checked[i][j]

print(np.max(checked))


### FIXED CODE ###

H, W = map(int, input().rstrip().split())
checked = [[True]*(W+2)]
checked += [[True] + [ch == "#" for ch in input().rstrip()] + [True]
            for i in range(H)]
checked.append([True]*(W+2))

black_list = []
# 初期化
# 0 => 黒、 -1 => 白
for i in range(1, H+1):
    for j in range(1, W+1):
        if checked[i][j]:
            black_list.append((i, j))

# 黒の周辺4方向のうち、白だったら黒にする
ans = -1
while black_list:
    ans += 1
    tmp = []
    for x, y in black_list:
        # 上
        if not checked[x-1][y]:
            checked[x-1][y] = True
            tmp.append((x-1, y))
        # 下
        if not checked[x+1][y]:
            checked[x+1][y] = True
            tmp.append((x+1, y))
        # 左
        if not checked[x][y-1]:
            checked[x][y-1] = True
            tmp.append((x, y-1))

        # 右
        if not checked[x][y+1]:
            checked[x][y+1] = True
            tmp.append((x, y+1))

    black_list = tmp

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

s = input()
s_len = len(s)
ans = ""
for i in range(s_len):
    if s[i] == "?":
        ans += "D"
    else:
        ans += s[i]
print(ans)

### FIXED CODE ###

s = input()
s_len = len(s)
li = [0]*s_len
for i in range(s_len):
    if s[i] == "?":
        li[i] = "D"
    else:
        li[i] = s[i]
print("".join(li))
### BUGGY CODE ###


import queue as que



def main():
    h, w = map(int, input().split())

    ahw = [input() for _ in range(h)]

    board = [[0]*w for _ in range(h)]


    q = [(-1,-1)]
    
    for hi in range(h):
        for wi in range(w):
            if ahw[hi][wi] == '#':

                board[hi][wi] = 1
                
                q.append( (hi,wi) )

#    print(q)
#    print(board)
    if len(q) == w*h:
        print(0)
        return 
    

    def exec(h_,w_):
        if board[h_][w_] == 0:
            q.append((h_,w_))
            board[h_][w_] = 1
   
           
    ans = 0
    while q:
        t = q.pop(0)
#        print(t)
        th = t[0]; tw = t[1]
        if th == tw and tw==-1:
            if not q:
                continue

            q.append((-1,-1))
            ans += 1
            continue

        if 0<th:
            exec(th-1, tw)
        if th+1 <h:
            exec(th+1, tw)
        if 0<tw:
            exec(th, tw-1)
        if tw +1 <w:
            exec(th, tw+1)

    print(ans-1)

main()

### FIXED CODE ###


# 遅い…？
import queue as que

from collections import deque 

def main():
    h, w = map(int, input().split())

    ahw = [input() for _ in range(h)]

    board = [[0]*w for _ in range(h)]

    q = deque()
    q.append((-1,-1))
#    q = [(-1,-1)]
    
    for hi in range(h):
        for wi in range(w):
            if ahw[hi][wi] == '#':

                board[hi][wi] = 1
                
                q.append((hi,wi) )

#    print(q)
#    print(board)
    if len(q) == h*w+1:
        print(0)
        return 
    

    def exec(h_,w_):
        if board[h_][w_] == 0:
            q.append((h_,w_))
            board[h_][w_] = 1
   
           
    ans = 0
    while q:
        t = q.popleft()
#        print(t)
        th = t[0]; tw = t[1]

        if th == tw and tw == -1:
            if not q:
                break

            q.append((-1,-1))
            ans += 1
            continue

        if 0<th:
            exec(th-1, tw)
        if th+1 <h:
            exec(th+1, tw)
        if 0<tw:
            exec(th, tw-1)
        if tw +1 <w:
            exec(th, tw+1)

    print(ans-1)

main()
### BUGGY CODE ###

n=int(input())
a=[int(z) for z in input().split()]
x=1
for i in range(n):
    x*=a[i]
if x>10**18:
    print("-1")
else:
    print(x)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
 
mul=1
if 0 in A:print("0")
else:
    for i in range(N):
        mul*=A[i]
        if mul>pow(10,18):
            print("-1")
            break
        elif i==N-1:print(mul)
### BUGGY CODE ###

import math


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

for i in range(1, math.floor(m/n) + 1):
    if m % i == 0:
        ans = i

print(ans)

### FIXED CODE ###

import math


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

for i in range(math.floor(m/n), 0, -1):
    if m % i == 0:
        ans = i
        break

print(ans)