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

N = int(input())
P = list(map(float, input().split()))

dp = [[0]*(N+1) for _ in range(N+1)] # dp[i][j]：i枚で表がj枚になる確率
dp[0][0] = 1
for i in range(N):
  for j in range(i+1):
    #dp[i][j] = dp[i-1][j-1] * P[i-1] + dp[i-1][j] * (1-P[i-1])
    dp[i+1][j+1] += dp[i][j] * P[i]
    dp[i+1][j] += dp[i][j] * (1-P[i])

print(sum(dp[N][(N+1)//2:]))

### FIXED CODE ###

# dp[i][j]：i枚で表がj枚になる確率
# 1 - sum(:dp[N][(N+1)//2])を求めればいいため，dp[N][(N+1)//2:]は求める必要が無い
# jが大きい順に更新すればdp[i][j]のjを保持する必要はない

N = int(input())
P = list(map(float, input().split()))
overhalf_N = (N+1)//2
underhalf_N = overhalf_N - 1

dp = [0]*(N+1) # dp[N][j]：N枚で表がj枚になる確率

dp[0] = 1
for i in range(overhalf_N):
  pc = 1 - P[i]
  for j in range(i+1, 0, -1):
    dp[j] = dp[j-1] * P[i] + dp[j] * pc
  dp[0] = dp[0] * pc

for i in range(overhalf_N,N):
  pc = 1 - P[i]
  for j in range(underhalf_N, 0, -1):
    dp[j] = dp[j-1] * P[i] + dp[j] * pc
  dp[0] = dp[0] * pc

print(1-sum(dp[:overhalf_N]))
### BUGGY CODE ###

T = int(input())

for i in range(T):
  a, b, c, d = map(int, input().split())

  #dがbより小さければ減り続けるのでNo
  #aがbより小さければいきなり買えない
  if d<b or a<b:
    print('No')
    continue

  #cがb-1以上だと足りないときは常に補ってくれる
  if b-1<=c:
    print('Yes')
    continue
  
  #d補充した分からbずつ買って余りが出る、かつそれがアンラッキーゾーンより狭いと必ず買えない日が出てくる
  if d%b<b-c and d%b!=0:
    print('No')
    continue

  #在庫がc以上を保った最小の
  for j in range(c):
    if a>c:
      a = c+(a-c)%b
    if a>c and a<b:
      print('No')
      break
    else:
      if a==c:
        a = a-b
    if d%b!=0:
      if b%(d%b)==0 and b-(b-a)%(d%b)<=c:
        print('Yes')
        break
    a+=d
    if j==c-1:
      print('Yes')




### FIXED CODE ###

import fractions
T = int(input())

for i in range(T):
  a, b, c, d = map(int, input().split())

  if d<b or a<b:
    print('No')
    continue

  if b-1<=c:
    print('Yes')
    continue

  gcd=fractions.gcd(d,b)
  e=b-gcd+a%gcd
  if e>c:
    print('No')
  else:
    print('Yes')
### BUGGY CODE ###

n = int(input())
used = []
for i in range(n):
    s = input()
    if not s in used:
        used.append(s)
print(len(used))

### FIXED CODE ###

n = int(input())
s = set([input() for i in range(n)])
print(len(s))
### BUGGY CODE ###

from fractions import gcd
from itertools import combinations
from functools import reduce
import random

N = int(input())
a_list = list(map(int, input().split()))

origina_gcd = reduce(gcd, a_list)

n_1_combis = combinations(a_list, N - 1)

max_gcd = 1
for combi in n_1_combis:
    tmp_gcd = reduce(gcd, combi)
    max_gcd = max(max_gcd, tmp_gcd)
print(max_gcd)

### FIXED CODE ###

from fractions import gcd

N = int(input())
AAA = list(map(int, input().split()))

# +1 shifted
dp_l = [0] * (N + 1)
dp_r = [0] * (N + 1)

dp_l[0] = 0
dp_r[0] = 0

for i in range(1, N):
    dp_l[i] = gcd(dp_l[i - 1], AAA[i - 1])
    dp_r[i] = gcd(dp_r[i - 1], AAA[-i])

max_gcd = 0
for i in range(N + 1):
    gcd_cand = gcd(dp_l[i], dp_r[N - i - 1])
    max_gcd = max(gcd_cand, max_gcd)

print(max_gcd)
### BUGGY CODE ###

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

def gcd(a,b):
    a,b=max(a,b),min(a,b)
    while b>=1:
        a,b=b,a%b
    return a

def multigcd(list):
    L=list[:]
    for _ in range(len(list)-1):
        L=[gcd(L[0],L[1])]+L[2:]
    return L[0]

print(multigcd(A))

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
ans=[A[0]]

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

i=1
while i<=N-1:
    ans.append(gcd(A[i],ans[-1]))
    i+=1

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

n = int(input())
a=list(map(int,input().split()))
b_=list(map(int,input().split()))
ans=0
from bisect import bisect_left as bl
def helper(l,r,b):
    return bl(b,r)-bl(b,l)

for i in range(29):
    T = pow(2,i)
    tmp = 0
    b=sorted([x%(2*T) for x in b_])
    for ai in a:
        ai%=2*T
        tmp += helper(T-ai,2*T-ai,b)
        tmp += helper(3*T-ai,4*T-ai,b)
    ans += T*(tmp%2)
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline


n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
l = [[] for i in range(29)]
for i in range(29):
    mod = 2**(i+1)
    for j in b:
        l[i].append(j%mod)
    l[i].sort()

ans = 0
for i in range(29):
    al = []
    count = 0
    mod = 2**i
    for j in a:
        al.append(j%(2*mod))
    al.sort(reverse = True)
    r1 = r2 = r3 = 0
    for j in al:
        while r1 < n and l[i][r1]+j < mod:
            r1 += 1
        while r2 < n and l[i][r2]+j < 2*mod:
            r2 += 1
        while r3 < n and l[i][r3]+j < 3*mod:
            r3 += 1
        count += n-r3+r2-r1
    ans += (count%2) << i
print(ans)
### BUGGY CODE ###

S = input()
N = len(S)
cnt = 0

for i in range(N):
    for j in range(i+4, N+1):
        if int(S[i:j]) % 2019 == 0:
            cnt += 1
print(cnt)



### FIXED CODE ###

s = list(input())
mods = [0]*(len(s))
countRemainder = [0] * 2019
cnt = 0


m = 1
mod = 0
for i in range(len(s)):
    mod += int(s[len(s) - i - 1]) * m

    mod %= 2019
    m *= 10
    m %= 2019

    countRemainder[mod] += 1

countRemainder[0] += 1

for i in range(2019):
    cnt += int(countRemainder[i] * (countRemainder[i] - 1) / 2)

print(cnt)
### BUGGY CODE ###

count = int(input())
nums = input().split(" ")

product = 1

for i in range(count):
    product *= int(nums[i])

if (product > 10**18):
    print("-1")
else:
    print(product)

### FIXED CODE ###

count = int(input())
nums = input().split(" ")

product = 1

if ("0" in nums):
    print(0)
else:
    for i in nums:
        product *= int(i)
        if (product > 10**18):
            print(-1)
            exit()
    print(product)
### BUGGY CODE ###

def main():
	n=int(input())
	a=list(map(int, input().split()))
	count=[0]*n
	while sum(count)==0:
		for i in range(n):
			count[i] = a.count(a[i])-1
	if sum(count)==0:
		print('YES')
	else:
		print('NO')
main()

### FIXED CODE ###

def main():
	n=int(input())
	a=list(map(int, input().split()))
	a.sort()
	c=0
	for i in range(n-1):
		if a[i] == a[i+1]:
			print('NO')
			c+=1
			break
	if c==0:
		print('YES')
main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline
k, q = map(int, input().split())
d = list(map(int, input().split()))

query = [list(map(int, input().split())) for i in range(q)]

def answer_query(n, x, m):
    l = [i%m for i in d]
    zero = l.count(0)
    count = n // k
    zero_total = zero*count
    rem = n % k
    s = sum(l)
    total = s%m * count + x%m
    for i in range(rem):
        total += l[i]
        if l[i] == 0:
            zero_total += 1

    total //= m
    total += s//m * count

    print(n-total-zero_total)


for n, x, m in query:
    answer_query(n-1, x, m)


### FIXED CODE ###

import sys
input = sys.stdin.readline
k, q = map(int, input().split())
d = list(map(int, input().split()))
query = [None]*q
for i in range(q):
    query[i] = list(map(int, input().split()))

def answer_query(n, x, m):
    l = [m if i%m == 0 else i%m for i in d]
    count = n // k
    rem = n % k
    s = sum(l)
    total = s%m * count + x%m
    for i in range(rem):
        total += l[i]

    total //= m
    total += s//m * count

    print(n-total)


for n, x, m in query:
    answer_query(n-1, x, m)
### BUGGY CODE ###

n=int(input())
from heapq import heappush,heappop
qqq=[[10**15 for _ in range(n)]for _ in range(n)]
for i in range(n-1):
	x,y,z=map(int,input().split())
	qqq[x-1][y-1]=z
	qqq[y-1][x-1]=z
dis=[10**15 for _ in range(n)]
qq,k=map(int,input().split())
dis[k-1]=0
s=set()
for i in range(n):
	q=10**15
	for j in range(n):
		if (j not in s) and q>dis[j]:
			q=dis[j]
			lit=j
	s.add(lit)
	for j in range(n):
		if j not in s:
			if dis[j]>dis[lit]+qqq[lit][j]:
				dis[j]=dis[lit]+qqq[lit][j]
for i in range(qq):
	r,t=map(int,input().split())
	print(dis[r-1]+dis[t-1])



### FIXED CODE ###

n=int(input())
cd=[[]for _ in range(n)]
for i in range(n-1):
	a,b,c=map(int,input().split())
	cd[a-1].append([b,c])
	cd[b-1].append([a,c])
q,k=map(int,input().split())
from collections import deque
dis=[-1]*n
dis[k-1]=0
stack=deque([k])
while stack:
	p=stack.popleft()
	for i in range(len(cd[p-1])):
		if dis[cd[p-1][i][0]-1]==-1:
			dis[cd[p-1][i][0]-1]=dis[p-1]+cd[p-1][i][1]
			stack.append(cd[p-1][i][0])
for i in range(q):
	x,y=map(int,input().split())
	print(dis[x-1]+dis[y-1])
### BUGGY CODE ###

n, m = map(int,input().split())
n_lis = [i+1 for i in range(n)]
 
for j in range(m):
  l, r = map(int,input().split())
  n_lis = [k for k in n_lis if k >= l and k <= r]
 
print(len(n_lis),flush=True)

### FIXED CODE ###

n, m = map(int,input().split())
 
l_p = 1
r_p = n
 
for j in range(m):
  l, r = map(int,input().split())
  if l > l_p:
    l_p = l
  if r < r_p:
    r_p = r

a = r_p - l_p + 1

if a > 0:
  print(a)
else:
  print(0)
### BUGGY CODE ###

def push(lists, d, x):
    if d == 0:
        lists.insert(0, x)
    else:
        lists.insert(len(lists), x)

    return lists

def randomAccess(lists, p):
    print(lists[p])

def pop(lists, d):
    if d == 0:
        lists.pop(0)
    else:
        lists.pop(len(lists) - 1)
    return lists

if __name__ == '__main__':
    l = list()
    n = int(input())
    for i in range(n):
        j= input().split()

        if int(j[0]) == 0:
            push(l, int(j[1]), int(j[2]))
        elif int(j[0]) == 1:
            randomAccess(l, int(j[1]))
        else:
            pop(l, int(j[1]))


### FIXED CODE ###

from collections import deque

def push(duque, d, x):
    if d == 1:
        duque.append(x)
    else:
        duque.appendleft(x)
    return duque

def randomAccess(duque, p):
    print(duque[p])

def pop(duque, d):
    if d == 1:
        duque.pop()
    else:
        duque.popleft()
    return duque

if __name__ == '__main__':
    l = deque([])
    n = int(input())
    for i in range(n):
        j= input().split()

        if int(j[0]) == 0:
            push(l, int(j[1]), int(j[2]))
        elif int(j[0]) == 1:
            randomAccess(l, int(j[1]))
        else:
            pop(l, int(j[1]))
### BUGGY CODE ###

n=int(input())
xyh=[list(map(int,input().split())) for _ in range(n)]
hs=[xyh[i][-1] for i in range(n)]
mh=min(hs)
if mh==0:
    mh=1
for cx in range(101):
    for cy in range(101):
        for h in range(mh,mh+201):
            j=True
            for i in range(n):
                if max(h-abs(xyh[i][0]-cx)-abs(xyh[i][1]-cy),0)!=xyh[i][2]:
                    j=False
            if j:
                print(cx,cy,h)
                break


### FIXED CODE ###

n=int(input())
xyh=[list(map(int,input().split())) for _ in range(n)]
hs=[xyh[i][-1] for i in range(n)]
mh=max(hs)
if mh==0:
    mh=1
for cx in range(101):
    for cy in range(101):
        for h in range(mh,mh+101):
            j=True
            for i in range(n):
                if max(h-abs(xyh[i][0]-cx)-abs(xyh[i][1]-cy),0)!=xyh[i][2]:
                    j=False
            if j:
                print(cx,cy,h)
                break
### BUGGY CODE ###

import math, sys

N, M = list(map(int, input().split()))

d = math.floor(M/N)

if M%N == 0:
	print(d)
	sys.exit()

for i in range(d):
	if M%(d-i) == 0:
		print(d-i)
		sys.exit()

### FIXED CODE ###

import math, sys, random

N, M = list(map(int,input().split()))
# N, M = 1111, 1000000000

def is_prime(n):
    if n == 2: return True
    if n == 1 or n & 1 == 0: return False

    d = (n - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    for k in range(100):
        a = random.randint(1, n - 1)
        t = d
        y = pow(a, t, n)

        while t != n - 1 and y != 1 and y != n - 1:
            y = (y * y) % n
            t <<= 1

        if y != n - 1 and t & 1 == 0:
            return False

    return True

d = int(math.floor(M/N))

if M%N == 0:
	print(d)
	sys.exit()

i = 0
f = False
while True:
	if M%(N+i+1) == 0:
		print(int(M/(N+i+1)))
		sys.exit()
	i += 1
	if i == 100000 and is_prime(M):
		print(1)
		sys.exit()
### BUGGY CODE ###

N = int(input())
As = list(map(lambda x: int(x), input().split(" ")))

result = 0
MOD = 10**9+7

for i in range(len(As)-1):
    tmp = As[i] * (sum(As[i+1:]) % MOD)
    result += tmp
    result %= MOD

print(result)



### FIXED CODE ###

N = int(input())
As = list(map(lambda x: int(x), input().split(" ")))

result = 0
MOD = 10**9+7

S = sum(As)

for i in range(len(As)-1):
    S -= As[i]
    tmp = As[i] * S
    result += tmp
    result %= MOD

print(result)
### BUGGY CODE ###

S=input()
p=0
ans=set()
while(p!=(len(S)//2+1)):
    for i in range(p+3,len(S)+1):
        if int(S[p:i])%2019==0:
            ans.add((p,i))
        if int(S[len(S)-i:len(S)-p])%2019==0:
            ans.add((len(S)-i,len(S)-p))
    p+=1
print(len(ans))

### FIXED CODE ###

s=input()
mod=2019
dp=[0]*mod
k=0
t=1
for x in map(int,s[::-1]):
    k+=t*x
    k%=mod
    dp[k]+=1
    t*=10
    t%=mod
print(sum(i*(i-1)//2 for i in dp)+dp[0])
### BUGGY CODE ###

# 初期入力
N= int(input())
S =input()

from collections import Counter
c = Counter(S)
count_all =c["R"] * c["G"] * c["B"]
count =0
for i,v in enumerate(S):
    for j in range(1,i+1):
        if  0<=i-j and i+j <N: 
            if S[i-j]=="R" and S[i] =="G" and S[i+j] =="B":
                #print(i-j,i,i+j)
                count +=1
            elif S[i-j]=="R" and S[i] =="B" and S[i+j] =="G":
                #print(i-j,i,i+j)
                count +=1
            elif S[i-j]=="G" and S[i] =="R" and S[i+j] =="B":
                #print(i-j,i,i+j)
                count +=1
            elif S[i-j]=="G" and S[i] =="B" and S[i+j] =="R":
                #print(i-j,i,i+j)
                count +=1
            elif S[i-j]=="B" and S[i] =="G" and S[i+j] =="R":
                #print(i-j,i,i+j)
                count +=1
            elif S[i-j]=="B" and S[i] =="R" and S[i+j] =="G":
                count +=1
                #print(i-j,i,i+j)

print(count_all - count)    

### FIXED CODE ###

# 初期入力
N= int(input())
S =input()


#
R_index=[]
G_index=[]
B_index=[]
for i,v in enumerate(S):
    if v =="R":
        R_index.append(i)
    if v =="G":
        G_index.append(i)
    if v =="B":
        B_index.append(i)

# 例　R_index各要素から等距離離れたところに左にG、右にBがあればOK
R_B =[]
B_G =[]
count_ij_jk_onaji =0
for r in R_index:
    for g in G_index:
        if 0<=g-(r-g) and g-(r-g)<N  :
            #if S[g-(r-g)]=="B" and r<g:
            if S[g-(r-g)]=="B" :
                count_ij_jk_onaji +=1
               # print(r,g,g-(r-g),"B")
for b in B_index:
    for r in R_index:
        if 0<=r-(b-r) and r-(b-r)<N :
            #if S[r-(b-r)] == "G" and b<r:
            if S[r-(b-r)] == "G" :
                count_ij_jk_onaji +=1
                #print(r,b,r-(b-r),"G")
for g in G_index:
    for b in B_index:
        if 0<=b-(g-b) and b-(g-b)<N :
            #if S[b-(g-b)] =="R" and g<b:
            if S[b-(g-b)] =="R":
                count_ij_jk_onaji +=1
                #print(b,g,b-(g-b),"R")

            
#3つとも異なる文字=all
kotae_all = len(R_index) * len(G_index) * len(B_index) 
print(kotae_all -count_ij_jk_onaji)
### BUGGY CODE ###

import collections
from collections import defaultdict
N = int(input())
edges = []
vertexes = []
parent = {}
childs = defaultdict(list)
color_dict = defaultdict(dict)
for i in range(N-1):
  a, b = map(int, input().split())
  parent[b] = a
  childs[a].append(b)
  edges.append((a,b))
  vertexes.append(a)
  vertexes.append(b)
  
#print(edges)
#print(vertexes)
#print(parent)
#childs = dict(childs)
#print(childs)

c = collections.Counter(vertexes)
max_color = c.most_common()[0][1]
print(max_color)

parent_color = {1: -1}
for i in range(1, N):
  pc = parent_color[i]
  allowed_colors = [j for j in range(max_color) if j != pc]
  for child, color in zip(sorted(childs[i]), allowed_colors):
    color_dict[i][child] = color
    parent_color[child] = color
    
#print(color_dict)

for e in edges:
  print(color_dict[e[0]][e[1]]+1)

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
m = map(int,read().split())
AB = list(zip(m,m))

# make graph
# graph(x): xと繋がっている頂点（番号）のリスト
graph = [[] for _ in range(N+1)]
for a,b in AB:
  graph[a].append(b)
  graph[b].append(a)

# 深さ優先探索で、頂点の探索順序を作成
root = 1
parent = [0] * (N+1) # parent[x]: xの親の番号
order = [] # 深さ優先探索の順序リスト
stack = [root]
while stack:
  x = stack.pop()
  order.append(x)
  for y in graph[x]:
    if y == parent[x]:
      continue
    parent[y] = x
    stack.append(y)

# color[i]: 頂点iとその親の間の辺の色
color = [-1] * (N+1)

# 頂点の探索順ごとに、頂点とその子の間の辺の色を決定
for x in order:
  ng = color[x] # 頂点xとxの親との間の辺の色
  c = 1
  # 頂点xとつながっている頂点のリストを取得し、辺の色を1から順に割り当てる
  for y in graph[x]:
    if y == parent[x]: # xの親の頂点の場合は何もしない
      continue
    if c == ng: # xとその親との間の辺の色は割り当てないようにする
      c += 1
    color[y] = c
    c += 1

# 回答作成
answer = []
for a,b in AB:
  # aがbの子ならcolor[a]を、逆の場合はcolor[b]を出力する
  if parent[a] == b:
    answer.append(color[a])
  else:
    # 今回の場合、a_i < b_iで、番号の小さい方が親になるように木を作っているので、
    # こちらの条件のほうにしか引っかからないはず
    answer.append(color[b])

K = max(answer) # 色の番号の中で最も大きいものがK
print(K)
print('\n'.join(map(str,answer)))
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=[]
for i in range(n):
    if i%2==1:
        ans.append(a[i])
    else:
        ans.insert(0,a[i])
if n%2==0:
    ans.reverse()
for i in ans:
    print(i,end=" ")

### FIXED CODE ###

from collections import deque
n=int(input())
a=list(map(int,input().split()))
ans=deque()
for i in range(n):
    if i%2!=n%2:
        ans.appendleft(a[i])
    else:
        ans.append(a[i])
for i in ans:
    print(i,end=" ")
### BUGGY CODE ###

from collections import Counter
n = int(input())
v = list(map(int,input().split()))
v1 = v[0::2]
v2 = v[1::2]
count1 = Counter(v1)
count2 = Counter(v2)
count1[0] = 0
MAX = 0
for i in count1.keys():
    for j in count2.keys():
        if i != j and MAX < count1[i] + count2[j]:
            MAX = count1[i] + count2[j]
print(n - MAX)

### FIXED CODE ###

from collections import Counter
n = int(input())
v = list(map(int,input().split()))
v1 = v[0::2]
v2 = v[1::2]
count1 = Counter(v1)
count2 = Counter(v2)
count1[0] = 0
count2[0] = 0
items1 = []
items2 = []
key1 = max(count1.keys(), key = count1.get)
items1.append([key1, count1[key1]])
del count1[key1]
key1 = max(count1.keys(), key = count1.get)
items1.append([key1, count1[key1]])

key2 = max(count2.keys(), key = count2.get)
items2.append([key2, count2[key2]])
del count2[key2]
key2 = max(count2.keys(), key = count2.get)
items2.append([key2, count2[key2]])

if items1[0][0] != items2[0][0]:
    m = items1[0][1] + items2[0][1]
else:
    m = max(items1[0][1] + items2[1][1], items1[1][1] + items2[0][1])
print(n - m)
### BUGGY CODE ###

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

exp_sum = []
sum_max = 0
exp1 = 0
for j in range(0,len(p)-k+1):
    sum_each = 0
    exp1 = 0
    sum1 = 0
    for i in range(j,j + k):
        sum1 += p[i]
        sum_max = max(sum1,sum_max)
        if sum1 >= sum_max:
            break
    if sum_max <= sum1:
        for i in range(j,j + k):
            sum_each = 0.5 * p[i] * (p[i] + 1)
            exp1 += sum_each/p[i]
        exp_sum.append(exp1)
print(max(exp_sum))

### FIXED CODE ###

import sys

def LI(): return list(map(int, sys.stdin.readline().split()))
N, K = LI()
p = LI()
ps = []
for i in range(N):
    ps.append((p[i] + 1) / 2)
 
anss = []
tmp = 0
for i in range(N):
    tmp += ps[i]
    if i > K - 1:
        tmp -= ps[i - K]
    anss.append(tmp)
 
print(max(anss))
### BUGGY CODE ###

N, S = map(int, input().split())
As = list(map(int, input().split()))
mod = 998244353
dp = [[2**i%mod]+[0]*(S) for i in range(N+1)]

for i in range(1, N+1):
    a = As[i-1]
    for s in range(1, S+1):
        if s-a>=0:
            dp[i][s] += dp[i-1][s-a] + dp[i-1][s]*2
        else:
            dp[i][s] += dp[i-1][s]*2
        dp[i][s] %= mod
print(dp[-1][-1]%mod)

### FIXED CODE ###

N, S = map(int, input().split())
As = 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):
    a = As[i-1]
    for s in range(S+1):
        if s-a>=0:
            dp[i][s] += dp[i-1][s-a] + dp[i-1][s]*2
        else:
            dp[i][s] += dp[i-1][s]*2
        dp[i][s] %= mod
print(dp[-1][-1]%mod)
### BUGGY CODE ###

n = int(input())
s = input()
temp = []
temp2 = []
c = 0
pitem = ''
s2 = s + 'a'
for item in s2:
    if pitem == '' or item == pitem:
        c += 1
        pitem = item
    if item != pitem:
        temp.append(c)
        temp2.append(pitem)
        c = 1
        pitem = item
        continue

# print(temp)
# print(temp2)

ck = [0]
cs = [0]
c = 0
for i in range(len(temp2)):
    if temp2[i] == '#':
        c += temp[i]
    cs.append(c)
c = 0

for i in range(len(temp2))[::-1]:
    if temp2[i] == '.':
        c +=  temp[i]
    ck.insert(0, c)
ck.insert(0, 0)

cost = [cs[i] + ck[i+1] for i in range(len(temp2)+1)]

print(min(cost))


### FIXED CODE ###

n = int(input())
s = input()
temp = []
c = 0
pitem = ''
s2 = '.' + s + 'a'
for item in s2:
    if pitem == '' or item == pitem:
        c += 1
        pitem = item
    if item != pitem:
        temp.append(c)
        c = 1
        pitem = item
        continue

# print(temp)
# print(temp2)

t = s2.count('.')
c = 0
c2 = 0
cs = []
for i in range(len(temp)):
    c2 += temp[i]
    if i % 2 == 1:
        c += temp[i]
    cs.append(c + t - (c2 - c))
print(min(cs))
### BUGGY CODE ###

s=[]
for _ in range(int(input())):
 e=input()
 if'i'==e[0]:s=[e.split()[1]]+s
 else:
  if' '==e[6]:
   m=e.split()[1]
   if m in s:s.remove(m)
  elif len(e)%2:s=s[1:]
  else:s.pop()
print(*s)


### FIXED CODE ###

import collections,sys
def s():
 d=collections.deque()
 input()
 for e in sys.stdin:
  if'i'==e[0]:d.appendleft(e[7:-1])
  else:
   if' '==e[6]:
    m=e[7:-1]
    if m in d:d.remove(m)
   elif'i'==e[7]:d.popleft()
   else:d.pop()
 print(*d)
if'__main__'==__name__:s()
### BUGGY CODE ###

sum = 1
for i in range(1,int(input())+1):
    sum *= i
print(sum%1000000007)


### FIXED CODE ###

sum = 1
for i in range(1,int(input())+1):
    sum *= i
    sum %= 1000000007
print(sum)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
 
#input
N = int(input())
A = list(map(int, input().split()))

from collections import Counter
import numpy as np
 
l = Counter(A).most_common()
l = [b for a, b in l]
l = np.array(l)

maximum_operation = [0] * N
for K in range(len(l)):
    l = Counter(A).most_common()
    l = [b for a, b in l]
    l = np.array(l)
    while l[K] > 0:
        l[0:K+1] -= 1
        l = np.sort(l)[::-1]
        maximum_operation[K] += 1
 
for m in maximum_operation:
    print(m)

### FIXED CODE ###

import sys
input = sys.stdin.readline

#input
N = int(input())
A = list(map(int, input().split()))

#output
from collections import Counter
import bisect

l = Counter(A).most_common()
l = [b for a, b in l]
M = len(l)
l.sort()
p = sum(l)

maximum_operation = [0] * N

ll = []
for x in reversed(range(1, N+1)):
    a = bisect.bisect_left(l, x)
    if a == 0:
        b = M*x
        c = 0
    elif a >= M:
        b = 0
        c = p
    else:
        b = (M-a)*x
        c = sum(l[0:a]) 
    ll.append((b + c)/x)

for K in range(M):
    maximum_operation[K] = N - bisect.bisect_left(ll, K+1)

for m in maximum_operation:
    print(m)
### BUGGY CODE ###

# ANSHUL GAUTAM
# IIIT-D

from math import *
from string import *
from itertools import *
from copy import *

N,M = map(int, input().split())
for i in range(M//N,0,-1):
	if(M%i == 0):
		print(i)
		break

### FIXED CODE ###

def solve():
    n, m = map(int, input().split())
    for i in range(m//n,0,-1):
        if m % i == 0:
            break
    print(i)
 
solve()