Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# ABC134-D

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  a=1
  ind=0
  ad=l[0]
  while True:
    if ind+a<n:
      ind+=a
      ad+=l[ind]
    else:
      if ad%2!=l[a-1]:
        # print(ad,l[a-1])
        print(-1)
        exit()
      else:
        a+=1
        ad=0
        ind=a-1
        if a==n:
          break

  ans=[]
  for i,x in enumerate(l):
    if x==1:
      ans.append(i+1)

  print(len(ans))
  if len(ans)==0:
    exit()
  print(' '.join([str(x) for x in ans]))

main()
# print(main())


Fixed submission:
import math,itertools,fractions,heapq,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  ans=[0]*n

  ind=n
  for i in range(n):
    sm=0
    for j in range(2,n+1):
      if ind*j>n:
        break
      else:
        sm+=ans[ind*j-1]
    ans[ind-1]=(l[ind-1]+sm)%2
    ind-=1
    # print(ans,ind)

  # print(ans)

  _ans=[]
  for i,x in enumerate(ans):
    if x==1:
      _ans.append(i+1)

  ln=len(_ans)
  print(ln)
  if ln!=0:
    print(' '.join([str(x) for x in _ans]))

main()
# print(main())
Buggy python submission (verdict: Time Limit Exceeded):
# ABC133-D

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy,numpy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  left=[]
  a=[0]*n
  for i in range(n):
    b=copy.deepcopy(a)
    b[i]=1
    b[(i+1)%n]=1
    left.append(b)

  right=[]
  for x in l:
    right.append(x*2)

  return ' '.join(str(int(x)) for x in list(numpy.linalg.solve(left,right)))

print(main())


Fixed submission:
import sys,collections

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  # a1=(x1+x2)/2,a2=(x2+x3)/2,...,an=(xn+x1)/2
  # 2a1=x1+x2,2a2=x2+x3,...,2an=xn+x1
  # x1=S-(x2+x3+...+xn)
  # x1=S-2(a2+a4+...+an-1)
  # x2=2a1-x1
  # x3=2a2-x2
  # ...

  sm=sum(l)
  ans=[]
  tmp=0
  for i,x in enumerate(l):
    if i%2==1:
      tmp+=x
  x1=sm-2*tmp
  ans.append(x1)

  for ai in l[:-1]:
    xp=2*ai-x1
    ans.append(xp)
    x1=xp

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

# main()
print(main())
Buggy python submission (verdict: Runtime Error):
# D問題
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# nCr
def nCr(n,r):
  return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))

def main():
  n,k=LI()

  # 隙間
  a=n-k+1

  for i in range(1,k+1):
    print(nCr(a,i)*nCr(k-1,i-1)%mod)

main()


Fixed submission:
# D問題
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# nCr
def nCr(n,r):
  return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))

def main():
  n,k=LI()

  # 隙間
  a=n-k+1

  for i in range(1,k+1):
    if a<i or k-1<i-1:
      print(0)
    else:
      print(nCr(a,i)*nCr(k-1,i-1)%mod)

main()

Buggy python submission (verdict: Runtime Error):
# D問題
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# nCr
def nCr(n,r):
  return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))

def main():
  n,k=LI()

  # 隙間
  a=n-k+1

  for i in range(1,k+1):
    print(nCr(a,i)*nCr(k-1,i-1)%mod)

main()


Fixed submission:
# D問題
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# nCr
def nCr(n,r):
  return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))

def main():
  n,k=LI()

  # 隙間
  a=n-k+1

  for i in range(1,k+1):
    if a<i or k-1<i-1:
      print(0)
    else:
      print(nCr(a,i)*nCr(k-1,i-1)%mod)

main()
Buggy python submission (verdict: Time Limit Exceeded):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,m=LI()
  l=[I() for _ in range(m)]

  dp=[0 for _ in range(n+1)]
  dp[0]=1
  for i in range(n):
    for j in range(1,3):
      if i+j<=n and i not in l:
        dp[i+j]+=dp[i]

  # print(dp)
  return dp[n]%mod

# main()
print(main())


Fixed submission:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  dp=[0]*100010

  n,m=LI()

  dp[0]=1
  dp[1]=1

  for _ in range(m):
    dp[I()]=-1

  for i in range(2,n+1):
    if dp[i]==-1:
      continue

    if dp[i-2]!=-1:
      dp[i]+=dp[i-2]
    if dp[i-1]!=-1:
      dp[i]+=dp[i-1]

    dp[i]%=mod

  return dp[n]%mod

print(main())
Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n=map(int,input().split())
c=0
for i in range(-(-n//r)+1):
  for j in range(-(-n//g)+1):
    x=n-(i*r+j*g)
    if x>=0 and x%b==0:
      c+=1
print(c)

Fixed submission:
r,g,b,n=map(int,input().split())
c=0
for i in range(-(-n//r)+1):
  for j in range(-(-n//g)+1):
    x=n-(i*r+j*g)
    if x<0:
      break
    elif x%b==0:
      c+=1
print(c)
Buggy python submission (verdict: Runtime Error):
# GCD
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x

# struct
class struct:
  def __init__(self,a,b,c):
    self.a=a
    self.b=b
    self.c=c

n=int(input())
if n==2:
  a,b=map(int,input().split())
  print(max(a,b))
  exit()
elif n==3:
  a,b,c=map(int,input().split())
  print(max(gcd(a,b),gcd(a,c),gcd(b,c)))
  exit()
else:
  l=list(map(int,input().split()))
  a=l[0]
  b=l[1]
  c=l[2]
  d=l[3]
  l2=[]
  l2.append(struct(a,b,gcd(a,b)))
  l2.append(struct(a,c,gcd(a,c)))
  l2.append(struct(a,d,gcd(a,d)))
  l2.append(struct(b,c,gcd(b,c)))
  l2.append(struct(b,d,gcd(b,d)))
  l2.append(struct(c,d,gcd(c,d)))
  l2=sorted(l2,key=lambda x:(x.c,x.a,x.b))
  aa=l2[0].a
  l3=[l2[0].c,l2[1].c,l2[2].c,l2[3].c,l2[4].c,l2[5].c]
  l3=list(set(l3))
  bb=l3[1]
  for x in l:
    xx=gcd(bb,x)
    yy=gcd(bb,aa)
    if xx<yy:
      aa=x
      bb=yy
  print(bb)

Fixed submission:
# GCD
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x

# struct
class struct:
  def __init__(self,a,b,c):
    self.a=a
    self.b=b
    self.c=c

n=int(input())
if n==2:
  a,b=map(int,input().split())
  print(max(a,b))
  exit()
elif n==3:
  a,b,c=map(int,input().split())
  print(max(gcd(a,b),gcd(a,c),gcd(b,c)))
  exit()
else:
  l=list(map(int,input().split()))
  a=l[0]
  b=l[1]
  c=l[2]
  d=l[3]
  l2=[]
  l2.append(struct(a,b,gcd(a,b)))
  l2.append(struct(a,c,gcd(a,c)))
  l2.append(struct(a,d,gcd(a,d)))
  l2.append(struct(b,c,gcd(b,c)))
  l2.append(struct(b,d,gcd(b,d)))
  l2.append(struct(c,d,gcd(c,d)))
  l2=sorted(l2,key=lambda x:(x.c,x.a,x.b))
  l3=[l2[0].a,l2[0].b,l2[1].a,l2[1].b]
  jama=10000000000000000
  if l3.count(l3[0])>1:
    jama=l3[0]
  if l3.count(l3[1])>1:
    jama=l3[1]
  if l3.count(l3[2])>1:
    jama=l3[2]
  if l3.count(l3[3])>1:
    jama=l3[3]
  mein=100000000000000000
  if jama==a:
    mein=gcd(gcd(b,c),d)
  if jama==b:
    mein=gcd(gcd(a,c),d)
  if jama==c:
    mein=gcd(gcd(a,c),d)
  if jama==d:
    mein=gcd(gcd(b,c),a)
  for x in l[4:]:
    xx=gcd(mein,x)
    yy=gcd(mein,jama)
    if xx<yy:
      jama=x
      mein=yy
    else:
      mein=xx
  print(mein)
Buggy python submission (verdict: Time Limit Exceeded):
N,Q=map(int,input().split())
S=input()
lst=[]
for i in range(Q):
  l,r=map(int,input().split())
  x=S[l-1:r]
  lst.append(x.count('AC'))
for i in lst:
  print(i)

Fixed submission:
N,Q=map(int,input().split())
S=input()
lst=[0]*(N-1)
x=0
for i in range(len(S)-1):
  if S[i:i+2]=='AC':
    x+=1
  lst[i]=x
lst=[0]+lst
lst2=[]
for i in range(Q):
  l,r=map(int,input().split())
  lst2.append(lst[r-1]-lst[l-1])
for i in lst2:
  print(i)
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
def gcd_list(numbers):
  return reduce(math.gcd, numbers)
n=int(input())
l=list(map(int,input().split()))
print(gcd_list(l))

Fixed submission:
def gcd(a, b):
  while b != 0:
    a, b = b, a % b
  return a
n=int(input())
l=list(map(int,input().split()))
ans=l[0]
l.remove(ans)
for i in l:
  ans=gcd(ans,i)
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=list(map(int,input().split()))
if m==1:
  print(0)
  exit()
l.sort()
l2=[]
for i in range(len(l)-1):
  l2.append(l[i+1]-l[i])
for i in range(n-1):
  l2.remove(max(l2))
print(sum(l2))

Fixed submission:
n,m=map(int,input().split())
l=list(map(int,input().split()))
if m==1:
  print(0)
  exit()
l.sort()
l2=[]
x0=l[0]
l.remove(x0)
for x in l:
  l2.append(x-x0)
  x0=x
l2.sort()
if n==1:
  print(sum(l2))
else:
  print(sum(l2[:-(n-1)]))
Buggy python submission (verdict: Runtime Error):
s=input()
x='keyence'
if s==x:
  print('YES')
  exit()
if s.count(x)>0:
  p=s.split('keyence')
  if p[0]=='' or p[1]=='':
    print('YES')
    exit()
  elif p[0]+p[1]=='keyence':
    print('YES')
    exit()
for i in range(1,len(x)):
  a=x[:i]
  b=x[i:]
  if s.index(a)==0 and s[len(s)-len(b):]==b:
    print('YES')
    exit()
  else:
    continue
print('NO')


Fixed submission:
s=input()
x='keyence'
if s==x:
  print('YES')
  exit()
if s.count(x)>0:
  p=s.split('keyence')
  if p[0]=='' or p[1]=='':
    print('YES')
    exit()
  elif p[0]+p[1]=='keyence':
    print('YES')
    exit()
for i in range(1,len(x)):
  a=x[:i]
  b=x[i:]
  if s.count(a)>0 and (s.index(a)==0 and s[len(s)-len(b):]==b):
    print('YES')
    exit()
  else:
    continue
print('NO')
Buggy python submission (verdict: Runtime Error):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  dp=[inf]*10
  dp[0]=0
  dp[1]=0
  dp[2]=abs(l[1]-l[0])

  for i in range(2,n):
    dp[i+1]=min(dp[i-1]+abs(l[i]-l[i-2]),dp[i]+abs(l[i]-l[i-1]))

  return dp[n]

print(main())


Fixed submission:
class struct:
  def __init__(self,a,b):
    self.a=a
    self.b=b

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

l2=[struct(0,0) for _ in range(n)]
l2[0].a=l[0]
l2[1].a=l[1]
l2[1].b=abs(l[0]-l[1])

i=2
for x in l[2:]:
  l2[i].a=x
  l2[i].b=min(abs(l2[i-2].a-x)+l2[i-2].b,
    abs(l2[i-1].a-x)+l2[i-1].b)
  i+=1

print(l2[-1].b)

Buggy python submission (verdict: Runtime Error):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  dp=[0]*110

  dp[1]=0
  dp[2]=abs(l[0]-l[1])
  for i in range(2,n):
    dp[i+1]=min(dp[i]+abs(l[i]-l[i-1]),dp[i-1]+abs(l[i]-l[i-2]))

  return dp[n]

print(main())


Fixed submission:
class struct:
  def __init__(self,a,b):
    self.a=a
    self.b=b

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

l2=[struct(0,0) for _ in range(n)]
l2[0].a=l[0]
l2[1].a=l[1]
l2[1].b=abs(l[0]-l[1])

i=2
for x in l[2:]:
  l2[i].a=x
  l2[i].b=min(abs(l2[i-2].a-x)+l2[i-2].b,
    abs(l2[i-1].a-x)+l2[i-1].b)
  i+=1

print(l2[-1].b)

Buggy python submission (verdict: Runtime Error):
class struct:
  def __init__(self,a,b):
    self.a=a
    self.b=b

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

l2=[struct(0,0) for _ in 3]
l2[0].a=l[0]
l2[1].a=l[1]
l2[1].b=abs(l[0]-l[1])

for x in l[2:]:
  l[0]=l[1]
  l[1]=l[2]
  l2[2].a=x
  l2[2].b=min(abs(l2[0].a-x)+l2[0].b,
    abs(l2[1].a-x)+l2[1].b)

print(l2[2].b)

Fixed submission:
class struct:
  def __init__(self,a,b):
    self.a=a
    self.b=b

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

l2=[struct(0,0) for _ in range(n)]
l2[0].a=l[0]
l2[1].a=l[1]
l2[1].b=abs(l[0]-l[1])

i=2
for x in l[2:]:
  l2[i].a=x
  l2[i].b=min(abs(l2[i-2].a-x)+l2[i-2].b,
    abs(l2[i-1].a-x)+l2[i-1].b)
  i+=1

print(l2[-1].b)
Buggy python submission (verdict: Time Limit Exceeded):
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

dp=[-1]*100100
G=[[] for _ in range(100100)]

def dfs(v):
  if dp[v]!=-1:
    return dp[v]

  x=0
  for w in G[v]:
    r=dfs(w)+1
    x=max(x,r)

  return x

def main():
  n,k=LI()
  for _ in range(k):
    a,b=LI()
    a-=1
    b-=1
    G[a].append(b)

  ans=0
  for i in range(n):
    ans=max(ans,dfs(i))

  return ans

print(main())
# main()


Fixed submission:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

dp=[-1]*100100
G=[[] for _ in range(100100)]

def dfs(v):
  if dp[v]!=-1:
    return dp[v]
  dp[v]=r=max(dfs(w) for w in G[v])+ 1 if G[v] else 0
  return r

def main():
  n,k=LI()

  for _ in range(k):
    a,b=LI()
    a-=1
    b-=1
    G[a].append(b)

  return max(dfs(v) for v in range(n))

# main()
print(main())
Buggy python submission (verdict: Time Limit Exceeded):
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  p=LF()
  p=[0]+p

  dp=[[0]*(n+1) for _ in range(n+1)]
  dp[0][0]=1

  # dp[i][j]=i個目までに表がj回出る確率
  for i in range(1,n+1):
    for j in range(n+1):
      if j>0:
        dp[i][j]=dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i]
      else:
        dp[i][j]=dp[i-1][j]*(1-p[i])

  ans=0
  for j in range(n//2+1,n+1):
    ans+=dp[n][j]
  return ans

# main()
print(main())


Fixed submission:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  p=LF()
  p=[0]+p

  dp=[[0]*(n+1) for _ in range(n+1)]
  dp[0][0]=1

  # dp[i][j]=i個目までに表がj回出る確率
  for i in range(1,n+1):
    for j in range(n+1):
      if j>0:
        dp[i][j]=dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i]
      else:
        dp[i][j]=dp[i-1][j]*(1-p[i])

  ans=0
  for j in range(n//2+1,n+1):
    ans+=dp[n][j]
  return ans

# main()
print(main())
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
c=0
while True:
  a=s.count('BW')
  if a:
    c+=a
    s=s.replace('BW','WB')
  else:
    break
print(c)

Fixed submission:
s=list(input())
c=0
b=0
for i in s:
  if i=='B':
    b+=1
  if i=='W':
    c+=b
print(c)
Buggy python submission (verdict: Runtime Error):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=[LI() for _ in range(n)]

  l=sorted(l,key=lambda x:x[2],reverse=True)

  ans=[]
  for Cx in range(101):
    for Cy in range(101):
      H=l[0][2]+abs(l[0][0]-Cx)+abs(l[0][1]-Cy)
      f=True
      for x,y,h in l[1:]:
        if h==0:
          continue
        if h!=H-abs(x-Cx)-abs(y-Cy):
          f=False
          break
      if f:
        ans.append(str(Cx)+' '+str(Cy)+' '+str(H))
  if len(ans)==1:
    return ans[0]
  else:
    aaa

# main()
print(main())


Fixed submission:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=[LI() for _ in range(n)]

  l=sorted(l,key=lambda x:x[2],reverse=True)

  ans=[]
  for Cx in range(101):
    for Cy in range(101):
      H=l[0][2]+abs(l[0][0]-Cx)+abs(l[0][1]-Cy)
      f=True
      for x,y,h in l[1:]:
        if h!=max(H-abs(x-Cx)-abs(y-Cy),0):
          f=False
          break
      if f:
        ans.append(str(Cx)+' '+str(Cy)+' '+str(H))
  if len(ans)==1:
    return ans[0]

# main()
print(main())
Buggy python submission (verdict: Time Limit Exceeded):
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,m=LI()
  if m%n==0:
    return m//n

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

# main()
print(main())


Fixed submission:
import math,itertools,fractions,heapq,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,m=LI()

  if n==1:
    return m

  a=0
  for i in range(1,int(math.sqrt(m))+1):
    if m%i==0:
      if m>=i*n:
        a=max(a,i)
      if m>=m//i*n:
        a=max(a,m//i)

  return a

# main()
print(main())