Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02818 (python)

Fixed submission:
a,b,k = input().split()
a = int(a)
b = int(b)
k = int(k)
if a >= k:
    print(a-k, b)
elif a < k  and b+a-k >=0 :
    print(0, b+a-k)
else:
    print(0, 0)

Buggy submission (verdict: Runtime Error):
a,b,k = input().split()
a = int(a)
b = int(b)
k = int(k)
if a => k:
    print(a-k, b)
elif a < k  and b+(a-k) >=0 :
    print(0, b+(a-k))
else:
    print(0, 0)

Buggy submission (verdict: Runtime Error):
a,b,k = input().split()
a = int(a)
b = int(b)
k = int(k)
if a - k < 0 and a+b-k <0
    print(0, 0)
elif a - k < 0:
    print(0, a+b-k)
else:
    print(a-k, b)
Problem p02946 (python)

Fixed submission:
k,x = map(int,input().split())

li = [str(i) for i in range(x-k+1,x+k)]

print(' '.join(li))

Buggy submission (verdict: Runtime Error):
k,x = map(int,input().split())

li = [i for i in range(x-k+1,x+k)]

print(' '.join(li))
Problem p03000 (python)

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

count = 0
d = 0

for i in range(n):
  d += l[count]
  count += 1
  if d >= x:
    if d == x:
      count += 1
    break

print(count) if d>=x else print(count+1)

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))

count = 0
d = 0

while d < x and count <= n:
  d += l[count]
  count += 1
  if d == x:
    count += 1

print(count)
Problem p02842 (python)

Fixed submission:
import math
N=int(input())
n=math.floor(N/1.08)
N1=math.floor(1.08*n)
N2=math.floor(1.08*(n+1))
 
if N==N1:
  print(n)
elif N==N2:
  print(n+1)
else:
  print(':(')

Buggy submission (verdict: Runtime Error):
import math
N=input()
n=math.floor(N/1.08)
N1=math.floor(1.08*n)
N2=math.floor(1.08*(n+1))

if N==N1 or N==N2:
  print(n)
else:
  print(':(')
Problem p02843 (python)

Fixed submission:
N=int(input())
r=N%100
d=int((N-r)/100)
 
if r>5*d:
  print(0)
else:
  print(1)

Buggy submission (verdict: Runtime Error):
N=int(imput())
r=N%100
d=int((N-r)/100)

if r>5*d:
  print(0)
else:
  primt(1)
Problem p03076 (python)

Fixed submission:
t = [int(input()) for i in range(5)]
t1 = 0
t2 = []
for a in t:
  if a % 10 == 0:
    t1 += a
  else:  
    t1 += (a//10 + 1)*10
    t2.append(a % 10)
if t2 == []:
  print(t1)
else:
  print(t1 + min(t2) - 10)

Buggy submission (verdict: Runtime Error):
t = [int(input()) for i in range(5)]
t1 = 0
t2 = []
for a in t:
  if a % 10 == 0:
    t1 += a
  else:  
    t1 += (a//10 + 1)*10
    t2.append(a % 10)
print(t1 + min(t2) - 10)
Problem p03146 (python)

Fixed submission:
s = int(input())
def f(n):
    if n % 2 == 0:
        return int(n/2)
    else:
        return 3*n + 1

def a(i):
    if i == 1:
        return s
    else:
        return f(a(i-1))

list = []
for i in range(1,1000000):
    list.append(a(i))
    if len(list) != len(set(list)):
        print(i)
        break

Buggy submission (verdict: Runtime Error):
s = int(input())
a = [s]

while len(a) - len(set(a)) != 0:
  for i in range(1000000):
    m = i+1
    if a[i] % 2 == 0:
      a.append(int(a[i]/2))
    else:
      a.append(3*a[i] + 1)
      
print(m)
Problem p03210 (python)

Fixed submission:
x = input()
x = int(x)
if x == 7 or x == 5 or x == 3:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
x = input()
x = int(x)
if x = 7 or x = 5 or x = 3:
  print('YES')
else:
  print('NO')
Problem p03351 (python)

Fixed submission:
a,b,c,d = map(int,input().split())

if abs(a-c) <= d:
  print("Yes")
elif abs(a-b) <= d and abs(b-c) <= d:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())

if abs(a,c) <= d:
  print("Yes")
elif abs(a,b) <= d and abs(b,c) <= d:
  print("Yes")
else:
  print("No")
Problem p03415 (python)

Fixed submission:
c = [list(input()) for i in range(3)]
s = ""
for j in range(3):
  s += str(c[j][j])
print(s)

Buggy submission (verdict: Runtime Error):
c = [list(input()) for i in range(3)]
s = ""
for j in range(3):
  s += str(c[i][i])
print(s)

Buggy submission (verdict: Runtime Error):
c = [list(input()) for i in range(3)]
s = ""
for j in range(3):
  s += c[i][i]
print(s)

Buggy submission (verdict: Runtime Error):
c = [list(input()) for i in range(3)]
s = 0
for j in range(3):
  s += c[i][i]
print(s)
Problem p03455 (python)

Fixed submission:
a,b = map( int , input().split() )
c = ( a * b ) % 2

if c == 1 :
  print('Odd')
else :
  print('Even')

Buggy submission (verdict: Runtime Error):
a , b =input().split()
c = ( a * b ) % 2
if c == 1 :
  print('Odd')
else :
  print('Even')

Buggy submission (verdict: Runtime Error):
a = input()
b = input()

n = a * b

if n % 2 == 1 :
  print('Odd')
if n % 2 == 0 :
  print('Even')

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
n = a * b

if n % 2 == 1 :
  print('Odd')
else :
  print('Even')
Problem p03658 (python)

Fixed submission:
n,k = map(int,input().split())
l = list(map(int,input().split()))
l.sort(reverse = True)
s = 0
for i in range(k):
  s += l[i]
print(s)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
l = list(map(int,input().split())).sort()
s = 0
for i in range(k):
  s += l[i]
print(s)
Problem p02761 (python)

Fixed submission:
def main():
    N, M = [int(x) for x in input().split()]
    expected_num_ary = [1] + [0] * (N - 1)

    if N == 1 and M == 0:
        print("0")
        return

    inputted_digit = []
    for _ in range(M):
        d, v = [int(x) for x in input().split()]
        if d > N:
            print("-1")
            return
        if d in inputted_digit and expected_num_ary[d - 1] != v:
            print("-1")
            return
        if d == 1 and v == 0 and N > 1:
            print("-1")
            return
        expected_num_ary[d - 1] = v
        inputted_digit.append(d)

    num_str = ""
    for num in expected_num_ary:
        num_str += str(num)
    print(num_str)



if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N, M = [int(x) for x in input().split()]
    expected_num_ary = [0] * N

    inputted_digit = []
    for _ in range(M):
        d, v = [int(x) for x in input().split()]
        if d > N:
            print("-1")
            return
        if d in inputted_digit and expected_num_ary[d - 1] != v:
            print("-1")
            return
        if d == 1 and v == 0:
            # 明示的に桁数をズラシに来ているケース
            print("-1")
            return
        expected_num_ary[d - 1] = v if v != 0 else 10
        inputted_digit.append(d)

    num_str = ""
    for num in expected_num_ary:
        num_str += str(num) if num != 10 else "X"

    tester = num_str.lstrip("0").replace("X", "0")

    if tester == "" and N == 1:
        print(0)
    elif N > len(tester):
        print("1%0*d" % (N - 1, int(tester)))
    else:
        print(tester)



if __name__ == '__main__':
    main()
Problem p02921 (python)

Fixed submission:
fore = input()
real = input()

ct = 0
for i in range(len(fore)):
  if fore[i] == real[i]:
    ct += 1
 
print(ct)

Buggy submission (verdict: Runtime Error):
fore, real = input().split()

ct = 0
for i in range(len(fore)):
  if fore[i] == real[i]:
    ct += 1

print(ct)
Problem p02934 (python)

Fixed submission:
_ = int(input())
print(1/sum([1/int(x) for x in input().split()]))

Buggy submission (verdict: Runtime Error):
N = int(input())

d = []
for _ in range(N):
  d.append(int(input()))

sm = 0
for i in range(N):
  sm += 1/d

print(1/sm)
Problem p02981 (python)

Fixed submission:
elem = input().split(" ")
tx = int(elem[0]) * int(elem[1])
print(tx if tx < int(elem[2]) else int(elem[2]))

Buggy submission (verdict: Runtime Error):
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = asc.nextInt();
    if(n*a>=b){
      System.out.println(b);
    }else{
      System.out.println(n*a);
    }
  }
}
Problem p03106 (python)

Fixed submission:
import math

def main():
    a, b, k = [int(x) for x in input().split()]

    p = []
    for i in range(1, max(a, b) + 1):
        if a % i == 0 and b % i == 0:
            p.append(i)

    print(p[len(p) - k])



if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import math

def main():
    a, b, k = [int(x) for x in input().split()]

    p = []
    for i in range(1, max(a, b) - 1):
        if a % i == 0 and b % i == 0:
            print(i)
            p.append(i)

    print(p[len(p) - k])



if __name__ == "__main__":
    main()
Problem p03624 (python)

Fixed submission:
alpha = list("abcdefghijklmnopqrstuvwxyz")
s = input()

found = False
for chr in s:
    if chr in alpha:
        del alpha[alpha.index(chr)]

if len(alpha) == 0:
    print("None")
else:
    print(alpha[0])

Buggy submission (verdict: Runtime Error):
alpha = list("abcdefghijklmnopqrstuvwxyz")
s = input()

found = False
for chr in s:
    del alpha[alpha.index(chr)]

if len(alpha) == 0:
    print("None")
else:
    print(alpha[0])
Problem p03658 (python)

Fixed submission:
N, K = [int(x) for x in input().split()]
lens = [int(x) for x in input().split()]

lens = sorted(lens)[::-1]

if len(lens) <= K:
    print(sum(lens))
else:
    print(sum(lens[:K]))

Buggy submission (verdict: Runtime Error):
N, K = [int(x) for x in input().split()]
lens = [int(x) for x in input().split()]

lens = sorted(lens).reverse()

if len(lens) >= K:
    print(sum(lens))
else:
    print(sum(lens[:K]))
Problem p02909 (python)

Fixed submission:
s=input()
if s=="Sunny":
  print ("Cloudy")
elif s=="Cloudy":
  print ("Rainy")
else:
  print ("Sunny")

Buggy submission (verdict: Runtime Error):
import math
N,M=map(int,input().split())
#print(N,M)
a = list(map(float,input().split()))
#print(a)
a.sort(reverse=True)
#print(a)
k=0
maxa=a[0]/2
while M>0:
#  print(M,k,maxa,a)
  if a[k]>=maxa:
    a[k]=a[k]/2
    M=M-1
  if k==len(a)-1:
    a.sort(reverse=True)
    k=0
    maxa=a[0]
    if maxa<1:
      break
    continue
  if a[k]<a[k+1]:
    if maxa<a[k]:
      maxa=a[k]
    k=k+1
  elif a[k]<maxa:
    if maxa<a[k]:
      maxa=a[k]
    k=k+1
#print(a)
total=0
for t in a:
  total+=int(t)
#  print(t,total)
print(total)
Problem p02882 (python)

Fixed submission:
import math


def main():
    a, b, x = map(int, input().split())
    y = x / a
    s = a * b
    if y == s:
        print('0.0')
    elif y >= s / 2:
        y = (a * b) - (x / a)
        b_temp = 2 * y / a
        angle = math.atan(a / b_temp)
        print(90 - math.degrees(angle))
    else:
        a_temp = 2 * y / b
        angle = math.atan(b / a_temp)
        print(math.degrees(angle))



if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math


def main():
    a, b, x = map(int, input().split())
    y = x / a
    s = a * b
    if y >= s / 2:
        y = (a * b) - (x / a)
        # a, b = b, a
        b_temp = 2 * y / a
        angle = math.atan(a / b_temp)
        print(90 - math.degrees(angle))
    else:
        a_temp = 2 * y / b
        angle = math.atan(b / a_temp)
        print(math.degrees(angle))



if __name__ == '__main__':
    main()
Problem p02947 (python)

Fixed submission:
import collections
from operator import mul
from functools import reduce


def cmb(n, r):
    if n < r:
        return 0
    r = min(n-r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


def main():
    n = int(input())
    s_list = []
    for i in range(n):
        temp_s = sorted(list(input()))
        s_list.append(''.join(temp_s))

    counter = collections.Counter(s_list)
    ans = 0
    for key, value in counter.items():
        temp = cmb(value, 2)
        ans += temp


    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import collections
# 再帰制限に引っかかった場合に外す
import sys
sys.setrecursionlimit(100000)

nCr = {}


def cmb(n, r):
    if r == 0 or r == n:
        return 1
    elif r == 1:
        return n
    elif n < r:
        return 0
    if (n, r) in nCr:
        return nCr[(n, r)]
    nCr[(n, r)] = cmb(n-1, r) + cmb(n-1, r-1)
    return nCr[(n, r)]


def main():
    n = int(input())
    s_list = []
    for i in range(n):
        temp_s = sorted(list(input()))
        s_list.append(''.join(temp_s))

    counter = collections.Counter(s_list)
    ans = 0
    for key, value in counter.items():
        temp = cmb(value, 2)
        ans += temp


    print(ans)


if __name__ == '__main__':
    main()
Problem p02995 (python)

Fixed submission:
import math
import fractions

def main():
    a, b, c, d = map(int, input().split())

    quotient = []
    temp_lcm = c * d // fractions.gcd(c, d)
    for i, x in enumerate([c, d, temp_lcm]):
        temp = (b // x) - ((a-1) // x)
        quotient.append(temp)
    temp1 = b - a + 1
    ans = temp1 - (quotient[0] + quotient[1]) + quotient[2]
    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math
import fractions

def main():
    a, b, c, d = map(int, input().split())

    quotient = []
    temp_lcm = fractions.gcd(c, d) // c * d
    for i, x in enumerate([c, d, temp_lcm]):
        temp = (b // x) - ((a-1) // x)
        quotient.append(temp)
    temp1 = b - a + 1
    ans = temp1 - (quotient[0] + quotient[1]) + quotient[2]
    print(ans)


if __name__ == '__main__':
    main()
Problem p02760 (python)

Fixed submission:
A = []
index = {}
for i in range(3):
    lst = list(map(int,input().split()))
    for idx,l in enumerate(lst):
        index[l] = (i,idx)
    A.append(lst)
N = int(input())

for _ in range(N):
    s = int(input())
    if s in index:
        i,j = index[s]
        A[i][j] = 0

for i in range(3):
    if sum(A[i]) == 0:
        print("Yes")
        exit()
for i in range(3):
    su = 0
    for j in range(3):
        su+=A[j][i]
    if su == 0:
        print("Yes")
        exit()
if A[0][0] + A[1][1] + A[2][2] == 0 or A[0][2] + A[1][1] + A[2][0] == 0:
    print("Yes")
    exit()
print("No")

Buggy submission (verdict: Runtime Error):
A = []
index = {}
for i in range(3):
    lst = list(map(int,input().split()))
    for idx,l in enumerate(lst):
        index[l] = (i,idx)
    A.append(lst)
#print(index)
N = int(input())

for _ in range(N):
    s = int(input())
    if s in index:
        i,j = index[s]
        A[i][j] = 0

for i in range(3):
    if sum(A[i]) == 0:
        print("Yes")
        exit()
for i in range(3):
    su = 0
    for j in range(3):
        su+=A[j][i]
    if su == 0:
        print("Yes")
        eixt()
if A[0][0] + A[1][1] + A[2][2] == 0 or A[0][2] + A[1][1] + A[2][0] == 0:
    print("Yes")
    exit()
print("No")
Problem p03161 (python)

Fixed submission:
N,K = map(int,input().split())
A = list(map(int, input().split()))
dp = [0 for _ in range(len(A))]
dp[0] = 0 
for i in range(1,N):
    tmp = [float("inf")]
    for j in range(1,K+1):
        if i - j>=0:
            tmp.append(dp[i-j] + abs(A[i] - A[i-j]))
    dp[i] = min(tmp)

print(dp[len(A)-1])

Buggy submission (verdict: Runtime Error):
from functools import lru_cache
import sys
sys.setrecursionlimit(2147483647)

N = int(input())
A = []
for i in range(0,N):
    A.append(list(map(int,input().split())))

@lru_cache(None)
def dfs(d,pre):
    if d>=N-1: return 0
    tmp = [0] 
    for idx,a in enumerate(A[d]):
        if idx != pre:
            res = dfs(d + 1,idx) + a 
            tmp.append(res)
    return max(tmp)

print(dfs(-1,-1))

Buggy submission (verdict: Runtime Error):
from functools import lru_cache
import sys
sys.setrecursionlimit(2147483647)

N = int(input())
A = []
for i in range(0,N):
    A.append(list(map(int,input().split())))



@lru_cache(None)
def dfs(d,pre):
    if d>=N-1: return 0
    tmp = [0] 
    for idx,a in enumerate(A[d]):
        if idx != pre:
            res = dfs(d + 1,idx) + a 
            tmp.append(res)
    return max(tmp)

print(dfs(-1,-1))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
for i in range(0,N):
    A.append(list(map(int,input().split())))

def dfs(d,pre):
    if d>=N-1: return 0
    tmp = [0] 
    for idx,a in enumerate(A[d]):
        if idx != pre:
            res = dfs(d + 1,idx) + a 
            tmp.append(res)
    return max(tmp)

print(dfs(-1,-1))
Problem p03163 (python)

Fixed submission:
import sys 
sys.setrecursionlimit(2147483647)

N,W = map(int,input().split())
A = [list(map(int, input().split())) for i in range(N)]
dp = [[0 for _ in range(W+1) ] for _ in range(N + 1)] 

for i in range(1,N + 1): 
    for j in range(W + 1): 
        if j - A[i-1][0] >= 0:
            res1 = dp[i - 1][j - A[i-1][0]] + A[i - 1][1]
            res2 = dp[i - 1][j]
            dp[i][j] = max(res1,res2)
        else:
            dp[i][j] = dp[i-1][j]
#print(dp)
print(max(dp[N]))

Buggy submission (verdict: Runtime Error):
import sys 
sys.setrecursionlimit(2147483647)

N,W = map(int,input().split())
A = [list(map(int, input().split())) for i in range(N)]
dp = [[0 for _ in range(W+1) ] for _ in range(N + 1)] 

for i in range(1,N + 1): 
    for j in range(W + 1): 
        if j - A[i-1][0] >= 0:
            res1 = dp[i - 1][j - A[i-1][0]] + A[i - 1][1]
            res2 = dp[i - 1][j]
            dp[i][j] = max(res1,res2)
        else:
            dp[i][j] = dp[i-1][j]
#print(dp)
print(max(dp[N]))
~
Problem p03165 (python)

Fixed submission:
S = input()
T = input()
dp = [[ 0] * (len(S) + 1 ) for _ in range(len(T) + 1)]
ma = 0
for i in range(len(dp)-1):
    for j in range(len(dp[0])-1):
        if T[i ] == S[j]:
            dp[i + 1][j + 1] = dp[i][j] + 1
        else:
             dp[i + 1][j + 1]  = max(dp[i][j + 1],dp[i +1][j])
i = len(T) - 1
j = len(S) - 1 
ans = ""
while i >=0 and j >= 0:
    if dp[i][j+1] == dp[i + 1][j + 1]:
        i-=1
    elif dp[i + 1][j] == dp[i + 1][j + 1]:
        j-=1
    else:
        #print(j,i)
        ans = S[j] + ans
        i-=1
        j-=1
print(ans)

Buggy submission (verdict: Runtime Error):
from numba import njit
S = input()
T = input()
dp = [[ "" for _ in range(len(S) + 1 )] for _ in range(len(T) + 1)]


@njit
def solv()
for i in range(1,len(dp)):
    for j in range(1,len(dp[0])):
        if T[i - 1] == S[j-1]:
            dp[i ][j ] = dp[i-1][j-1] + S[j-1]
        else:
            res1 = dp[i - 1][j]
            res2 = dp[i][j - 1]
            l1 = len(res1)
            l2 = len(res2)
            if l1 > l2:
                dp[i ][j] = res1
            else:
                dp[i ][j] = res2
solv()
print(dp[-1][-1])

Buggy submission (verdict: Runtime Error):
S = input()
T = input()

import sys
sys.setrecursionlimit(2147483647)

def dfs(i,j):
    if (i,j) in dic: return dic[(i,j)]
    if i > len(S) - 1 or j > len(T) - 1:
        return ""
    ans  = ""
    if S[i] == T[j]:
        ans = S[i] + dfs(i + 1,j + 1)
    else:
        res1 = dfs(i + 1,j)
        res2 = dfs(i, j + 1)
        if max([len(res1),len(res2)]) == len(res1):
            ans = res1
        else:
            ans = res
    dic[(i,j)] = ans
    return ans
dic = {}
print(dfs(0,0))
Problem p03166 (python)

Fixed submission:
import collections
import sys
sys.setrecursionlimit(10000000)

N,M = map(int,input().split())
A = [list(map(int, input().split())) for i in range(M)]
visit = set()
G = collections.defaultdict(set)
for idx,(f,to) in enumerate(A):
    G[f].add(to)

cache = {}
    
def dfs(start):
    if start in cache:
        return cache[start]
    ma = 0
    for i in G[start]:
        if i not in visit:
            visit.add(i)
            ma = max(ma,dfs(i))
            visit.remove(i)
    cache[start] = ma + 1 
    return ma + 1

ma = 0 
for f,to in A:
    visit.add(f)
    ma = max(ma,dfs(f))
    visit.remove(f)
print(ma - 1)

Buggy submission (verdict: Runtime Error):
import collections
N,M = map(int,input().split())
A = [list(map(int, input().split())) for i in range(M)]
visit = set()
G = collections.defaultdict(set)
for idx,(f,to) in enumerate(A):
    G[f].add(to)

cache = {}
    
def dfs(start):
    if start in cache:
        return cache[start]
    ma = 0
    for i in G[start]:
        if i not in visit:
            visit.add(i)
            ma = max(ma,dfs(i))
            visit.remove(i)
    cache[start] = ma + 1 
    return ma + 1

ma = 0 
for f,to in A:
    visit.add(f)
    ma = max(ma,dfs(f))
    visit.remove(f)
print(ma - 1)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = [list(map(int, input().split())) for i in range(M)]
visit = set()
G = collections.defaultdict(set)
for idx,(f,to) in enumerate(A):
    G[f].add(to)

cache = {}
    
def dfs(start):
    if start in cache:
        return cache[start]
    ma = 0
    for i in G[start]:
        if i not in visit:
            visit.add(i)
            ma = max(ma,dfs(i))
            visit.remove(i)
    cache[start] = ma + 1 
    return ma + 1

ma = 0 
for f,to in A:
    visit.add(f)
    ma = max(ma,dfs(f))
    visit.remove(f)
print(ma - 1)
Problem p03168 (python)

Fixed submission:
import collections
N = int(input())
A = list(map(float,input().split()))
K = N//2  + 1
dp = [[0 for _ in range(N + 1) ] for _ in range(N + 1)]
if N == 0: 
    print(0)
    exit
dp[0][0] = 1
ans = 0
for i in range(1,N+1):
    for j in range(i+1):
        if j - 1 < 0:
            dp[i][j] = dp[i-1][j]*(1-A[i-1])
        else:
            dp[i][j] = dp[i-1][j-1]*A[i-1] + dp[i-1][j]*(1-A[i-1])
for i in range(K,len(dp[N])):
        ans+=dp[N][i]
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(float,input().split()))
K = N//2 + 1


def dfs(i,K):
    if (i,K) in cache: return cache[(i,K)]
    if K < 0: 
        cache[(i,K)] = 1
        return 1
    if i>=N: 
        cache[(i,K)] = 1
        return 1
    if len(A[i:]) < K: 
        res = (1-A[i])*dfs(i+1,K)
    elif len(A[i:]) == K: 
        res = A[i]*dfs(i + 1,K-1)
    else:
        res = A[i]*dfs(i+1,K-1) + (1-A[i])*dfs(i+1,K)
    cache[(i,K)] = res
    return res
cache={}
print(dfs(0,K))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(float,input().split()))
K = N//2 + 1


def dfs(i,K):
    if (i,K) in cache: return cache[(i,K)]
    if i>=N: 
        cache[(i,K)] = 1
        return 1
    if len(A[i:]) < K: 
        res = (1-A[i])*dfs(i+1,K)
    elif len(A[i:]) == K: 
        res = A[i]*dfs(i + 1,K-1)
    else:
        res = A[i]*dfs(i+1,K-1) + (1-A[i])*dfs(i+1,K)
    cache[(i,K)] = res
    return res
cache={}
print(dfs(0,K))