Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
P=list(map(int,input().split()))
ans = 0
for i in range(N):
    if i == 0:
        ans += 1
    else:
        #print(P[0:i+1],P[i],min(P[0:i+1]),i)
        if min(P[0:i+1]) == P[i]:
            ans += 1
print(ans)


Fixed submission:
N=int(input())
P=list(map(int,input().split()))
ans = 0
for i in range(N):
    if i == 0:
        ans += 1
        mini = P[0]
    else:
        if mini >= P[i]:
            mini = P[i]
            ans += 1
        #print(P[0:i+1],P[i],min(P[0:i+1]),i)
        #if min(P[0:i+1]) == P[i]:
            #ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
P=list(map(int,input().split()))
ans = 0
for i in range(N):
    if i == 0:
        ans += 1
    else:
        #print(P[0:i+1],P[i],min(P[0:i+1]),i)
        if min(P[0:i+1]) == P[i]:
            ans += 1
print(ans)


Fixed submission:
N=int(input())
P=list(map(int,input().split()))
ans = 0
for i in range(N):
    if i == 0:
        ans += 1
        mini = P[0]
    else:
        if mini >= P[i]:
            mini = P[i]
            ans += 1
        #print(P[0:i+1],P[i],min(P[0:i+1]),i)
        #if min(P[0:i+1]) == P[i]:
            #ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
p = [0]*M
S = [0]*M
ans_AC = [0]*N
ans_WA = [0]*N
for i in range(M):
    p[i],S[i] = map(str,input().split())


for i in range(M):
    pi = int(p[i])
    if S[i] == "AC":
        if ans_AC[pi] != 1:
            ans_AC[pi] = 1
    else:
        if ans_AC[pi] != 1:
            ans_WA[pi] += 1
print(sum(ans_AC),sum(ans_WA))


Fixed submission:
N,M = map(int,input().split())

AC = [0]*N
WA = [0]*N
AC_cnt = 0
WA_cnt = 0

p = [0]*M
S = [0]*M

for i in range(M):
    p[i],S[i] = map(str, input().split())

for i in range(M):
    q_num = int(p[i])
    if AC[q_num-1] == 0:
        if S[i] == "AC":
            AC[q_num-1] = 1
        else:
            WA[q_num-1] += 1

for i in range(N):
    if AC[i] == 1:
        WA_cnt += WA[i]
        AC_cnt += 1

print(AC_cnt,WA_cnt)
Buggy python submission (verdict: Runtime Error):
N = int(input())

for i in range(1,9):
    for j in range(1,9):
        if N % i == 0 and N % j == 0:
            print("Yes")
            break
        else:
            print("No")
            break
    break


Fixed submission:
A,B=map(int,input().split())
if A <= 9 and B <= 9:
    print(A*B)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input())
K = []
S = []
for i in range(M):
    list = input().split()
    K.append(int(list[0]))
    S.append(map(int,list[1::]))
p = list(map(int,input().split()))
anss = 0
for i in range(2**n):
    for j in range(M):
        ans = 0
        for k in range(N):
            if i >> k & 1 and k in K[j]:
                ans += 1
        if ans % 2 != p[j]:
            break
        else:
            anss += 1
print(ans) 


Fixed submission:
N,M=map(int,input().split())
ls=[]
cnt,cnt2,ans=0,0,0
for i in range(M):
    ls1=list(map(int,input().split()))
    ls.append(list(ls1))
    ls1.clear()
lsp = list(map(int,input().split()))
#print(ls)
#print(lsp)
for i in range(2**N):
    flg = True
    for j in range(M):
        cnt = 0
        for k in range(1,len(ls[j])):
            if i >> ls[j][k]-1 & 1:
                cnt += 1
        if cnt%2 != lsp[j]:
            flg = False
    if flg:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
count = 0
count2 = 0
for i in range(1,N+1):
    #print(i,"i")
    for j in range(1,N+1):
        #print(j,"k")
        if i % j == 0 :
            count += 1
            #print(count,"count")
    if count == 8 and i%2 != 0:
        count2 += 1
        ans = count2
    count = 0
    count2 = 0
print(ans)


Fixed submission:
N=int(input())
count = 0
count2 = 0
for i in range(1,N+1):
    #print(i,"i")
    for j in range(1,N+1):
        #print(j,"k")
        if i % j == 0 :
            count += 1
            #print(count,"count")
    if count == 8 and i%2 != 0:
        count2 += 1
    ans = count2
    count = 0
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
list = []
flg = True
for A in range(1,int((N+1)**0.5)):
    for B in range(int((N+1)**0.5),N+1):
        if A*B==N:
            list.append(len(str(B)))
list.sort()
print((list[0]))


Fixed submission:
N = int(input())
ans = len(str(N))
for i in range(1,int(N**0.5)+1):
    if N % i == 0:
        #print(i)
        #print("leng",len(str(N/i)))
        #print(ans,len(str(i)),len(str(N//i)),len(str(int(N/i))))
        ans = min(ans,max(len(str(i)),len(str(N//i))))
print(ans)

Buggy python submission (verdict: Runtime Error):
N=int(input())
list = []
flg = True
for A in range(1,int((N+1)**0.5)):
    for B in range(1,N+1):
        if A*B==N:
            if len(str(A)) > len(str(B)):
                list.append(len(str(A)))
                print(list)
            else:
                list.append(len(str(B)))

        #print(list)
list.sort()
print((list[0]))


Fixed submission:
N = int(input())
ans = len(str(N))
for i in range(1,int(N**0.5)+1):
    if N % i == 0:
        #print(i)
        #print("leng",len(str(N/i)))
        #print(ans,len(str(i)),len(str(N//i)),len(str(int(N/i))))
        ans = min(ans,max(len(str(i)),len(str(N//i))))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a,b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
l=[]
for i in range(0,(a-b)+1):
    p=1
    for j in range(i,i+b):
        p=p*c[j]
    l.append(p)
    if(len(l)==1):
        pass
    else:
        if(l[len(l)-1]>l[len(l)-2]):
            print('Yes')
        else:
            print('No')

Fixed submission:
n, k = [int(x) for x in input().strip().split()]
arr = [int(x) for x in input().strip().split()]


last = 0
for i in range(k):
    last += arr[i]

for i in range(k, len(arr)):
    curr = (last + arr[i]) - arr[i-k]
    if curr>last:
        print('Yes')
    else:
        print('No')
    last= curr

Buggy python submission (verdict: Time Limit Exceeded):
a,b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
l=[]
for i in range(0,(a-b)+1):
    p=1
    for j in range(i,i+b):
        p=p*c[j]
    l.append(p)
for i in range(1,len(l)):
    if(l[i]>l[i-1]):
        print('Yes')
    else:
        print('No')

Fixed submission:
n, k = [int(x) for x in input().strip().split()]
arr = [int(x) for x in input().strip().split()]


last = 0
for i in range(k):
    last += arr[i]

for i in range(k, len(arr)):
    curr = (last + arr[i]) - arr[i-k]
    if curr>last:
        print('Yes')
    else:
        print('No')
    last= curr
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
for i in range(1,n+1):
    e=0
    for j in range(1,51):
        if(j*j>=n):
            break
        for k in range(1,51):
            if(k*k>=n):
                break
            for l in range(1,51):
                if(l*l>=n):
                    break
                if((j*j)+(k*k)+(l*l)+(j*k)+(k*l)+(l*j)==i):
                    e=e+1
    print(e)

Fixed submission:
from math import sqrt, floor

N = int(input())
d = [0] * (N+1)

k = floor(sqrt(N))
for x in range(1, k):
    for y in range(1, k):
        for z in range(1, k):
            c = x*x + y*y + z*z + x*y + y*z + z*x
            if 1 <= c <= N:
                d[c] += 1


for i in range(1, N+1):
    print(d[i])

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
for i in range(1,n+1):
    e=0
    for j in range(1,101):
        if(j*j>=n):
            break
        for k in range(1,101):
            if(k*k>=n):
                break
            for l in range(1,101):
                if(l*l>=n):
                    break
                if((j*j)+(k*k)+(l*l)+(j*k)+(k*l)+(l*j)==i):
                    e=e+1
    print(e)

Fixed submission:
from math import sqrt, floor

N = int(input())
d = [0] * (N+1)

k = floor(sqrt(N))
for x in range(1, k):
    for y in range(1, k):
        for z in range(1, k):
            c = x*x + y*y + z*z + x*y + y*z + z*x
            if 1 <= c <= N:
                d[c] += 1


for i in range(1, N+1):
    print(d[i])

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
for i in range(1,n+1):
    e=0
    for j in range(1,101):
        for k in range(1,101):
            for l in range(1,101):
                if((j*j)+(k*k)+(l*l)+(j*k)+(k*l)+(l*j)==i):
                    e=e+1
    print(e)

Fixed submission:
from math import sqrt, floor

N = int(input())
d = [0] * (N+1)

k = floor(sqrt(N))
for x in range(1, k):
    for y in range(1, k):
        for z in range(1, k):
            c = x*x + y*y + z*z + x*y + y*z + z*x
            if 1 <= c <= N:
                d[c] += 1


for i in range(1, N+1):
    print(d[i])
Buggy python submission (verdict: Runtime Error):
n=int(input())
d={'AC':0,"WA":0,'TLE':0,'RE':0}
for i in range(n):
    s=str(input())
    if(s=='AC'):
        d['AC']=d['AC']+1
    elif(s=='WA'):
        d['WA']=d['WA']+1
    elif(s=='RE'):
        d['RE']=d['RE']+1
    elif(s=='TLE'):
        d['TLE']=d['TLE']+1
print('AC'+" "+"*"+" "+str(d['AC']))
print('WA'+" "+"*"+" "+d['WA'])
print('TLE'+" "+"*"+" "+d['TLE'])
print('RE'+" "+"*"+" "+d['RE'])

Fixed submission:
n=int(input())
d={'AC':0,"WA":0,'TLE':0,'RE':0}
for i in range(n):
    s=str(input())
    if(s=='AC'):
        d['AC']=d['AC']+1
    elif(s=='WA'):
        d['WA']=d['WA']+1
    elif(s=='RE'):
        d['RE']=d['RE']+1
    elif(s=='TLE'):
        d['TLE']=d['TLE']+1
print("AC x"+' '+str(d['AC']))
print('WA x'+' '+str(d['WA']))
print('TLE x'+' '+str(d['TLE']))
print('RE x'+' '+str(d['RE']))
Buggy python submission (verdict: Runtime Error):
n=int(input())
d={}
for i in range(n):
    s=str(input())
    d.add(s)
print(len(d))

Fixed submission:
n=int(input())
d=set()
for i in range(n):
    s=str(input())
    d.add(s)
print(len(d))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=[]
c=0
for i in range(n):
    s=str(input())
    if(s not in l):
        l.append(s)
        c=c+1
print(c)

Fixed submission:
n=int(input())
d=set()
for i in range(n):
    s=str(input())
    d.add(s)
print(len(d))
Buggy python submission (verdict: Runtime Error):
a,b,c=[int(i) for i in input().split()]
if(len(set(a))==2):
    print('Yes')
else:
    print('No')

Fixed submission:
a=[int(i) for i in input().split()]
if(len(set(a))==2):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
from collections import OrderedDict 
n=int(input())
d={}
for i in range(n):
    s=str(input())
    if(s not in d):
        d[s]=1
    else:
        d[s]=d[s]+1
d = OrderedDict(sorted(d.items()))
for j,k in d.items():
    if (k==max(d.values())):
        print(j)

Fixed submission:
N = int(input())
dic = {}
for i in range(N):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
max_val = max(dic.values())
rst = [ key for key, val in dic.items() if val == max_val ]
[ print(i) for i in sorted(rst) ]
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[int(i) for i in input().split()]
if(len(set(a)==n)):
    print('YES')
else:
    print('NO')

Fixed submission:
n=int(input())
a=[int(i) for i in input().split()]
if(len(set(a))==n):
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[int(i) for i in input().split()]
e=a[0]
l=[]
for i in range(0,len(a)-1):
    f=0
    for j in range(i,len(a)-1):
        if(a[j+1]<=a[j]):
            f=f+1
        else:
            break
    l.append(f)
print(max(l))

Fixed submission:
n = int(input())
h = list(map(int,input().split()))

ans = []
now = 0

for i in range(1,n):
    if h[i-1] >= h[i]:
        now += 1
    else:
        ans.append(now)
        now = 0

ans.append(now)

print(max(ans))
Buggy python submission (verdict: Runtime Error):
n,m=[int(i) for i in input().split()]
l=[]
c=[input() for i in range(n)]
l=sorted(c)
b=l[0:m]
maxs=max(b)-min(b)
for i in range(0,(n-m)):
    b.pop(0)
    b.append(l[i+m])
    f=(max(b)-min(b))
    if(f<maxs):
        maxs=f
print(maxs)

Fixed submission:
N, K = map(int, input().split())
h = sorted([int(input()) for i in range(N)])

hmax = 0
hmin = 0
ans = 10**10
for i in range(N - K + 1):
    hmax = h[i + K - 1]
    hmin = h[i]
    if hmax - hmin < ans:
        ans = hmax - hmin
print(ans)

Buggy python submission (verdict: Runtime Error):
n,m=[int(i) for i in input().split()]
l=[]
c=[input() for i in range(n)]
l=sorted(c)
b=l[0:m]
maxs=max(b)-min(b)
for i in range(0,(n-m)):
    b.pop(0)
    b.append(l[i+m])
    c=(max(b)-min(b))
    if(c<maxs):
        maxs=c
print(maxs)

Fixed submission:
N, K = map(int, input().split())
h = sorted([int(input()) for i in range(N)])

hmax = 0
hmin = 0
ans = 10**10
for i in range(N - K + 1):
    hmax = h[i + K - 1]
    hmin = h[i]
    if hmax - hmin < ans:
        ans = hmax - hmin
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m=[int(i) for i in input().split()]
l=[]
for i in range(n):
    a=int(input())
    l.append(a)
l=sorted(l)
b=l[0:m]
maxs=max(b)-min(b)
for i in range(0,(n-m)):
    b.pop(0)
    b.append(l[i+m])
    c=(max(b)-min(b))
    if(c<maxs):
        maxs=c
print(maxs)

Fixed submission:
N, K = map(int, input().split())
h = sorted([int(input()) for i in range(N)])

hmax = 0
hmin = 0
ans = 10**10
for i in range(N - K + 1):
    hmax = h[i + K - 1]
    hmin = h[i]
    if hmax - hmin < ans:
        ans = hmax - hmin
print(ans)

Buggy python submission (verdict: Runtime Error):
n,m=[int(i) for i in input().split()]
l=[]
for i in range(n):
    a=int(input())
    l.append(a)
l=sorted(l)
b=l[0:m]
print(b)
max=10**9
for i in range(0,(n-m)):
    b.pop(0)
    b.append(l[i+m])
    c=(max(b)-min(b))
    if(c<max):
        max=c
print(max)

Fixed submission:
N, K = map(int, input().split())
h = sorted([int(input()) for i in range(N)])

hmax = 0
hmin = 0
ans = 10**10
for i in range(N - K + 1):
    hmax = h[i + K - 1]
    hmin = h[i]
    if hmax - hmin < ans:
        ans = hmax - hmin
print(ans)
Buggy python submission (verdict: Runtime Error):
n,k =map(int,input().split())
a=[int(x ) for x in input().split()]
for i in range(k,n):
    if a[i-k]>a[i-1]:
        print("Yes")
    else:
        print("No")


Fixed submission:
x=int(input())
if x in range(400,600):
    p=8
elif x in range(600,800):
    p=7
elif x in range(800,1000):
    p=6
elif x in range(1000,1200):
    p=5
elif x in range(1200,1400):
    p=4
elif x in range(1400,1600):
    p=3
elif x in range(1600,1800):
    p=2
elif x in range(1800,2000):
    p=1
print(p)
Buggy python submission (verdict: Runtime Error):
s = list(input())
t = list(input())
n=0
for i in range(len(s)):
    if s[i]!=t[i]:
        
        n+=1
print(n)

Fixed submission:
a = int(input())
print(a+a**2 +a**3)
Buggy python submission (verdict: Runtime Error):
n= int(input())
p =[int(x) for x in range(int(input()))]
dp = [[0 for i in range(n+1)]for j in range(n+1)]

dp[0][0]=1
for i in range(n):
    for j in range(n):
        dp[i+1][j+1]+=dp[i][j]*p[i]
        dp[i+1][j]+=dp[i][j]*(1-p[i])
an=0
for i in range((n+1)//2,n+1):
    an+=dp[n][i]
print(an)

Fixed submission:
INT_MAX= 100000000
n=int(input())
dp  = [INT_MAX]*(100001)
h=[int(X) for X in input().split()]
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):

    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i-2]-h[i]))

print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin,stdout
INT_MAX= 100000000
n,k=map(int,stdin.readline().split())
dp  = [INT_MAX]*(n)
h=[int(X) for X in stdin.readline().split()]
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    p=1
    while(p<k+1 or i-p>=0):
        dp[i]= min(dp[i-p+1]+abs(h[i-p+1]-h[i]),dp[i])
        p+=1
stdout.write(str(dp[n-1])+"\n")

Fixed submission:
from sys import stdin,stdout
INT_MAX= 10**18
n,k=map(int,stdin.readline().split())
dp  = [INT_MAX]*(n)
h=[int(X) for X in stdin.readline().split()]
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    p=1
    while(p<k+1 and (i-p)>=0):
        dp[i]= min(dp[i-p]+abs(h[i-p]-h[i]),dp[i])
        p+=1
stdout.write(str(dp[n-1])+"\n")

Buggy python submission (verdict: Time Limit Exceeded):
INT_MAX= 100000000
n,k=map(int,input().split())
dp  = [INT_MAX]*(n)
h=[int(X) for X in input().split()]
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    p=1
    while(p<k+1 or i-p>=0):
        dp[i]= min(dp[i-p+1]+abs(h[i-p+1]-h[i]),dp[i])
        p+=1
print(dp[n-1])

Fixed submission:
from sys import stdin,stdout
INT_MAX= 10**18
n,k=map(int,stdin.readline().split())
dp  = [INT_MAX]*(n)
h=[int(X) for X in stdin.readline().split()]
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    p=1
    while(p<k+1 and (i-p)>=0):
        dp[i]= min(dp[i-p]+abs(h[i-p]-h[i]),dp[i])
        p+=1
stdout.write(str(dp[n-1])+"\n")
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin,stdout


def knapsack(i,w):
    if dp[i][w]!=-1:
        return dp[i][w]
    else:
        if w-wi[i]>=0:
            dp[i][w] = max(knapsack(i-1,w-wi[i])+v[i],knapsack(i-1,w))
        else:
            dp[i][w] = knapsack(i-1,w)
        return dp[i][w]
n,w= map(int,input().split())
wi=[0]
v=[0]
for i in range(n):
    x,y= map(int,stdin.readline().split())

    wi.append(x)
    v.append(y)
dp = [[-1 for i in range(w+1)] for j in range(n+1)]
for i in range(w+1):
    dp[0][i]=0
for j in range(n+1):
    dp[j][0]=0
stdout.write(str(knapsack(n,w)) + "\n")
#print(dp)

Fixed submission:
N,W=map(int,input().split())
dp=[-1]*(W+1)
dp[0]=0
for _ in range(N):
    w,v=map(int,input().split())
    for i in range(W+1)[::-1]:
        if dp[i]!=-1 and i+w<=W:
            dp[i+w]=max(dp[i+w],dp[i]+v)
print(max(dp))

Buggy python submission (verdict: Time Limit Exceeded):
def knapsack(i,w):
    if dp[i][w]!=-1:
        return dp[i][w]
    else:
        if w-wi[i]>=0:
            dp[i][w] = max(knapsack(i-1,w-wi[i])+v[i],knapsack(i-1,w))
        else:
            dp[i][w] = knapsack(i-1,w)
        return dp[i][w]
n,w= map(int,input().split())
wi=[0]
v=[0]
for i in range(n):
    x,y= map(int,input().split())

    wi.append(x)
    v.append(y)
dp = [[-1 for i in range(w+1)] for j in range(n+1)]
for i in range(w+1):
    dp[0][i]=0
for j in range(n+1):
    dp[j][0]=0
print(knapsack(n,w))
#print(dp)

Fixed submission:
N,W=map(int,input().split())
dp=[-1]*(W+1)
dp[0]=0
for _ in range(N):
    w,v=map(int,input().split())
    for i in range(W+1)[::-1]:
        if dp[i]!=-1 and i+w<=W:
            dp[i+w]=max(dp[i+w],dp[i]+v)
print(max(dp))
Buggy python submission (verdict: Runtime Error):
N,W=map(int,input().split())
dp=[-1]*(W+1)
dp[0]=0
for _ in range(N):
    w,v=map(int,input().split())
    for i in range(W+1)[::-1]:
        if dp[i]!=-1 and i+w<=W:
            dp[i+w]=max(dp[i+w],dp[i]+v)
print(max(dp))    


Fixed submission:
n, w = map(int, input().split())
INF = float('inf')
P = []
for _ in range(n):
    iw, iv = map(int, input().split())
    P.append([iw, iv])

dp = [[INF for i in range(10 ** 5 + 1)] for j in range(n + 1)]
dp[0][0] = 0
for i in range(1, n + 1):
    for j in range(10 ** 5 + 1):
        if j - P[i - 1][1] >= 0:
            dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - P[i - 1][1]] + P[i - 1][0])
        else:
            dp[i][j] = dp[i - 1][j]

ans = 10 ** 5
while dp[n][ans] > w:
    ans -= 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n= int(input())
p =[float(x) for x in range(int(input()))]
dp = [[0 for i in range(n+1)]for j in range(n+1)]
dp[0][0]=1.0

for i in range(n):
    for j in range(n):
        dp[i+1][j+1]+=dp[i][j]*p[i]
        dp[i+1][j]+=dp[i][j]*(1-p[i])
an=0
for i in range((n+1)//2,n+1):
    an+=dp[n][i]
print(an)

Fixed submission:
n= int(input())
p =[float(x) for x in input().split()]
dp = [[0 for i in range(n+1)]for j in range(n+1)]
dp[0][0]=1.0

for i in range(n):
    for j in range(n):
        dp[i+1][j+1]+=dp[i][j]*p[i]
        dp[i+1][j]+=dp[i][j]*(1-p[i])
an=0
for i in range((n+1)//2,n+1):
    an+=dp[n][i]
print(an)

Buggy python submission (verdict: Runtime Error):
n= int(input())
p =[int(x) for x in range(int(input()))]
q= [1-int(x) for x in range(int(input()))]
dp = [[0 for i in range(n+1)]for j in range(n+1)]

dp[0][0]=1
for i in range(n):
    for j in range(n):
        dp[i+1][j+1]+=dp[i][j]*p[i]
        dp[i+1][j]+=dp[i][j]*(1-p[i])
an=0
for i in range((n+1)//2,n+1):
    an+=dp[n][i]
print(an)

Fixed submission:
n= int(input())
p =[float(x) for x in input().split()]
dp = [[0 for i in range(n+1)]for j in range(n+1)]
dp[0][0]=1.0

for i in range(n):
    for j in range(n):
        dp[i+1][j+1]+=dp[i][j]*p[i]
        dp[i+1][j]+=dp[i][j]*(1-p[i])
an=0
for i in range((n+1)//2,n+1):
    an+=dp[n][i]
print(an)
Buggy python submission (verdict: Runtime Error):
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

OFS=20
KK = 41
n = inn()
d = [[0]*KK for i in range(KK)]
for i in range(n):
    a = ins()
    p = a.find('.')
    if p<0:
        v = int(a)
        k = 0
    else:
        b = a[:p]+a[p+1:]
        v = int(b)
        k = len(a)-1-p
    x2 = 0
    while v%2==0:
        x2 += 1
        v //= 2
    x5 = 0
    while v%5==0:
        x5 += 1
        v //= 5
    d[x2-k+OFS][x5-k+OFS] += 1

#if DBG:
#    for i in range(KK):
#        for j in range(KK):
#            if d[i][j]!=0:
#                ddprint(f"i {i-OFS} j {j-OFS} {d[i][j]}")

ans = 0
h = {}
for p in range(KK):
    for q in range(KK):
        sm = 0 if p<OFS or q<OFS else (d[p][q]*(d[p][q]-1)//2)
        #if sm>0:
        #ddprint(f"p {p-OFS} q {q-OFS} d {d[p][q]} {sm=}")
        for r in range(-p+2*OFS,KK):
            #if r==p:
            #    continue
            for s in range(-q+2*OFS,KK):
                if (r,s)==(p,q) or (r,s,p,q) in h:
                    continue
                h[(p,q,r,s)] = 1
                sm += d[p][q]*d[r][s]
                #if d[p][q]*d[r][s]>0:
                #    ddprint(f"p {p-OFS} q {q-OFS} r {r-OFS} s {s-OFS} d {d[p][q]} {d[r][s]}")
        ans += sm
print(ans)


Fixed submission:
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

OFS=20
KK = 41
n = inn()
d = [[0]*KK for i in range(KK)]
for i in range(n):
    a = ins()
    p = a.find('.')
    if p<0:
        v = int(a)
        k = 0
    else:
        b = a[:p]+a[p+1:]
        v = int(b)
        k = len(a)-1-p
    x2 = 0
    while v%2==0:
        x2 += 1
        v //= 2
    x2 = min(x2,OFS)
    x5 = 0
    while v%5==0:
        x5 += 1
        v //= 5
    x5 = min(x5,OFS)
    d[x2-k+OFS][x5-k+OFS] += 1

#if DBG:
#    for i in range(KK):
#        for j in range(KK):
#            if d[i][j]!=0:
#                ddprint(f"i {i-OFS} j {j-OFS} {d[i][j]}")

ans = 0
h = {}
for p in range(KK):
    for q in range(KK):
        sm = 0 if p<OFS or q<OFS else (d[p][q]*(d[p][q]-1)//2)
        #if sm>0:
        #ddprint(f"p {p-OFS} q {q-OFS} d {d[p][q]} {sm=}")
        for r in range(-p+2*OFS,KK):
            #if r==p:
            #    continue
            for s in range(-q+2*OFS,KK):
                if (r,s)==(p,q) or (r,s,p,q) in h:
                    continue
                h[(p,q,r,s)] = 1
                sm += d[p][q]*d[r][s]
                #if d[p][q]*d[r][s]>0:
                #    ddprint(f"p {p-OFS} q {q-OFS} r {r-OFS} s {s-OFS} d {d[p][q]} {d[r][s]}")
        ans += sm
print(ans)