Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
b == input()
print('A' if b == 'T')

Fixed submission:
b = input()
if b == 'A':
  print('T')
elif b == 'T':
  print('A')
elif b == 'C':
  print('G')
else:
  print('C')

Buggy python submission (verdict: Runtime Error):
b = input()
print('T' if b == 'A')
print('A' if b == 'T')
print('C' if b == 'G')
print('G' if b == 'C')

Fixed submission:
b = input()
if b == 'A':
  print('T')
elif b == 'T':
  print('A')
elif b == 'C':
  print('G')
else:
  print('C')
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()

for _ in range(q):
    l,r = map(int, input().split())
    print(s[l-1:r].count('AC'))

Fixed submission:
n, q = map(int, input().split())
s = input()
t = [0]*(n+1)
for i in range(n):
    if s[i:i+2] == 'AC':
        t[i+1] = t[i]+1
    else:
        t[i+1] = t[i]

for _ in range(q):
    l,r = map(int, input().split())
    print(t[r-1]-t[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
s = input()

tmp = s
while '01' in tmp or '10' in tmp :
    tmp = tmp.replace('01','').replace('10','')

print(len(s)-len(tmp))

Fixed submission:
s = input()
print(min(s.count('1'), s.count('0'))*2)
Buggy python submission (verdict: Time Limit Exceeded):
n, W = map(int, input().split())
dp = [0]*(W+1)
for _ in range(n):
    w, v = map(int, input().split())
    tmp_dp = [max(dp[sum_w], dp[sum_w - w] + v) for sum_w in range(w, W+1)]
    dp[w:] = tmp_dp
print(max(dp))

Fixed submission:
n, W = map(int, input().split())
dp = [0]*(W+1)
for _ in range(n):
    w, v = map(int, input().split())
    tmp_dp = [max(dp[sum_w], dp[sum_w - w] + v) for sum_w in range(w, W+1)]
    dp[w:] = tmp_dp
print(max(dp))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
cnt = 0

while s.count('BW'):
    cnt += s.count('BW')
    s = s.replace('BW', 'WB')
print(cnt)

Fixed submission:
s = input()
cnt = 0
b_cnt = 0
for c in s:
    if c == 'B':
        b_cnt += 1
    else:
        cnt += b_cnt
print(cnt)
Buggy python submission (verdict: Runtime Error):
from collections import Counter

n, *v = map(int, open(0).read().split())
vo = Counter(v[::2])
ve = Counter(v[1::2])
vo_mc = vo.most_common()[0]
ve_mc = ve.most_common()[0]
if vo_mc[0] == ve_mc[0]: 
    if vo_mc[1] > ve_mc[1]:
        ans = n//2 - vo_mc[1]
        if ve_mc[1] != n//2:
            ans += n//2 - ve.most_common()[1][1]
        else:
            ans += n//2
    elif vo_mc[1] < ve_mc[1]:
        ans =  n//2 - ve_mc[1]
        if vo_mc[1] != n//2:
            ans += n//2 - vo.most_common()[1][1]
        else:
            ans += n//2
else:
    ans = n//2 - vo_mc[1] + n//2 - ve_mc[1]
print(ans)

Fixed submission:
from collections import Counter

n, *v = map(int, open(0).read().split())
vo = Counter(v[::2])
ve = Counter(v[1::2])
vo_mc = vo.most_common()[0]
ve_mc = ve.most_common()[0]
if vo_mc[0] == ve_mc[0]:
    if vo_mc[1] > ve_mc[1]:
        ans = n//2 - vo_mc[1]
        if ve_mc[1] != n//2:
            ans += n//2 - ve.most_common()[1][1]
        else:
            ans += n//2
    elif vo_mc[1] < ve_mc[1]:
        ans =  n//2 - ve_mc[1]
        if vo_mc[1] != n//2:
            ans += n//2 - vo.most_common()[1][1]
        else:
            ans += n//2
    else:
        ans = n
        if ve_mc[1] != n//2:
            ans = min(n//2 - vo_mc[1] + n//2 - ve.most_common()[1][1], ans)
        if vo_mc[1] != n//2:
            ans = min(n//2 - vo.most_common()[1][1] + n//2 - ve_mc[1], ans)
        ans = min(n//2 - vo_mc[1] + n//2, ans)
else:
    ans = n//2 - vo_mc[1] + n//2 - ve_mc[1]
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

n, *spot = map(int, open(0).read().split())
spot.sort()
dist = set([spot[i+1]-spot[i] for i in range(n)])
print(gcd_list(dist))

Fixed submission:
import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

n, *spot = map(int, open(0).read().split())
spot.sort()
dist = set([spot[i+1]-spot[i] for i in range(n)])
print(gcd_list(dist))
Buggy python submission (verdict: Runtime Error):
s=str(input())
n = int(input())
for i in range(n):
    if s[i] != "1":
        print(int(s[i]))
        break
	else:
    	print("1")

Fixed submission:
s = input()
k = int(input())
for i in range(k):
    if s[i] != "1":
        break
print(s[i])
Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().split())
ans=′Yay!′
if a>=9 or b>=9:
  ans=′:(′
print(ans)

Fixed submission:
a,b = map(int, input().split())
ans=':('
if a<=8 and b<=8:
  ans = 'Yay!'
print(ans)

Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().split())
ans=′Yay!′
if a>9 or b>9:
  ans=′:(′
print(ans)

Fixed submission:
a,b = map(int, input().split())
ans=':('
if a<=8 and b<=8:
  ans = 'Yay!'
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = n
for i in range(n):
    ans = min(ans, s[:i].count('W')+s[i+1:].count('E'))
print(ans)

Fixed submission:
n = int(input())
s = input()
all_w = s.count('W')
all_e = s.count('E')
left_w = 0
right_e = all_e
ans = left_w + right_e
for i in range(n):
    if s[i] == 'E':
        right_e -= 1
    ans = min(ans, left_w + right_e)
    if s[i] == 'W':
        left_w += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
masu = ['.'*(w+2)]
masu += ['.' + input() + '.' for _ in range(w)]
masu.append('.'*(w+2))
ans = 'Yes'
for i in range(1,h+1):
    for j in range(1,w+1):
        if masu[i][j] == '#':
            if masu[i+1][j] == '#' or masu[i-1][j] == '#' or masu[i][j+1] == '#' or masu[i][j-1] == '#':
                continue
            else:
                ans = 'No'
                break
print(ans)

Fixed submission:
h, w = map(int, input().split())
masu = ['.'*(w+2)]
masu += ['.' + input() + '.' for _ in range(h)]
masu.append('.'*(w+2))
ans = 'Yes'
for i in range(1,h+1):
    for j in range(1,w+1):
        if masu[i][j] == '#':
            if masu[i+1][j] == '#' or masu[i-1][j] == '#' or masu[i][j+1] == '#' or masu[i][j-1] == '#':
                continue
            else:
                ans = 'No'
                break
print(ans)

Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
masu = ['.'*(w+2)]
masu += ['.' + input() + '.' for _ in range(w)]
masu.append('.'*(w+2))
ans = 'Yes'
for i in range(1,h):
    for j in range(1,w):
        if masu[i][j] == '#':
            if masu[i+1][j] == '#' or masu[i-1][j] == '#' or masu[i][j+1] == '#' or masu[i][j-1] == '#':
                continue
            else:
                ans = 'No'
                break
print(ans)

Fixed submission:
h, w = map(int, input().split())
masu = ['.'*(w+2)]
masu += ['.' + input() + '.' for _ in range(h)]
masu.append('.'*(w+2))
ans = 'Yes'
for i in range(1,h+1):
    for j in range(1,w+1):
        if masu[i][j] == '#':
            if masu[i+1][j] == '#' or masu[i-1][j] == '#' or masu[i][j+1] == '#' or masu[i][j-1] == '#':
                continue
            else:
                ans = 'No'
                break
print(ans)

Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
masu = ['.'*(w+2)]
masu += ['.' + input() + '.' for _ in range(w)]
masu.append('.'*(w+2))
ans = 'Yes'
for i in range(1,h-1):
    for j in range(1,w-1):
        if masu[i][j] == '#':
            if masu[i+1][j] == '#' or masu[i-1][j] == '#' or masu[i][j+1] == '#' or masu[i][j-1] == '#':
                continue
            else:
                ans = 'No'
                break
print(ans)

Fixed submission:
h, w = map(int, input().split())
masu = ['.'*(w+2)]
masu += ['.' + input() + '.' for _ in range(h)]
masu.append('.'*(w+2))
ans = 'Yes'
for i in range(1,h+1):
    for j in range(1,w+1):
        if masu[i][j] == '#':
            if masu[i+1][j] == '#' or masu[i-1][j] == '#' or masu[i][j+1] == '#' or masu[i][j-1] == '#':
                continue
            else:
                ans = 'No'
                break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,k = map(int, input().split())
temp = [ i for i in range(a,b+1)]
for i in sorted(set(temp[:k]+temp[-k:])):
  print(i)

Fixed submission:
a,b,k = map(int, input().split())
small = [i for i in range(a,min(a+k,b+1))]
large = [i for i in range(max(a,b-k+1),b+1)]
for i in sorted(set(small+large)):
  print(i)
Buggy python submission (verdict: Runtime Error):
n = int(input())
march_l = [0]*5
for _ in range(n):
    s = input()
    s0 = s[0]
    if s0 == 'M':
        march_l[0] += 1
    elif s0 == 'A':
        march_l[1] += 1
    elif s0 == 'R':
        march_l[2] += 1
    elif s0 == 'C':
        march_l[3] += 1
    elif s0 == 'H':
        march_l[4] += 1

cnt =  [i for i in march_l if i != 0]
len_cnt = len(cnt)

if len_cnt > 3:
    for i in range(2**len_cnt):
        tmp = 1
        if str(bin(i)).count('1') == 3:
            for j in range(len_cnt):
                if ((i>>j) & 1):
                    tmp *= cnt[j]
            ans += tmp
elif len_cnt == 3:
    ans = 1
    for i in cnt:
        ans *= i
else:
    ans = 0

print(ans)

Fixed submission:
n = int(input())
march_l = [0]*5
for _ in range(n):
    s = input()
    s0 = s[0]
    if s0 == 'M':
        march_l[0] += 1
    elif s0 == 'A':
        march_l[1] += 1
    elif s0 == 'R':
        march_l[2] += 1
    elif s0 == 'C':
        march_l[3] += 1
    elif s0 == 'H':
        march_l[4] += 1

cnt =  [i for i in march_l if i != 0]
len_cnt = len(cnt)
ans = 0

if len_cnt > 3:
    for i in range(2**len_cnt):
        tmp = 1
        if str(bin(i)).count('1') == 3:
            for j in range(len_cnt):
                if ((i>>j) & 1):
                    tmp *= cnt[j]
            ans += tmp
elif len_cnt == 3:
    ans = 1
    for i in cnt:
        ans *= i
        
print(ans)
Buggy python submission (verdict: Runtime Error):
n = input()
int_n = int(n)
len_n = len(n)
ans = 0

if n[0] == '1' and n[1:] == '0'*(len_n-1):
    print(9 * (len_n - 1))
    exit()

for i in range(len_n):
    target = int(n[:i+1][-1]) -1
    tmp_n = n[:i] + str(target) + '9'* (len_n - i - 1)
    tmp_n_ans = sum([int(i) for i in tmp_n])
    ans = max(tmp_n_ans, ans)
print(ans)

Fixed submission:
n = input()
int_n = int(n)
len_n = len(n)
ans = sum([int(i) for i in n])

for i in range(len_n):
    target = int(n[:i+1][-1]) -1
    if target < 0:
        continue
    tmp_n = n[:i] + str(target) + '9'* (len_n - i - 1)
    tmp_n_ans = sum([int(i) for i in tmp_n])
    ans = max(tmp_n_ans, ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
l_2 = 2
l_1 = 1

for _ in range(1,n):
  l_now = l_1 + l_2
  l_2 = l_1
  l_1 = l_now
print(l_now)

Fixed submission:
n = int(input())
l_2 = 2
l_1 = 1
l_now = 1

for _ in range(1,n):
  l_now = l_1 + l_2
  l_2 = l_1
  l_1 = l_now
print(l_now)
Buggy python submission (verdict: Runtime Error):
n=input()
if ′9′ in n:
  print(′Yes′)
else:
  print(′No′)

Fixed submission:
n=input()
if '9' in n:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

n = int(input())

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

t = set()
for _ in range(n):
    t.add(int(input()))

print(lcm_list(t))

Fixed submission:
from fractions import gcd
from functools import reduce

n = int(input())

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

t = set()
for _ in range(n):
    t.add(int(input()))

print(lcm_list(t))
Buggy python submission (verdict: Time Limit Exceeded):
n, *a = map(int, open(0).read().split())
b = []
for i in range(n):
    if i % 2 == 0:
        b.append(a[i])
    else:
        b = [a[i]] + b

if n % 2 == 0:       
    print(' '.join(map(str, b)))
else:
    print(' '.join(map(str, b[::-1])))

Fixed submission:
n, *a_l = map(int, open(0).read().split())
b = []

for a in a_l[::-2]:
        b.append(a)
for a in a_l[n%2::2]:
        b.append(a)

print(' '.join(map(str, b)))

Buggy python submission (verdict: Time Limit Exceeded):
n, *a = map(int, open(0).read().split())
b = []
for i in range(n):
    if i % 2 == 0:
        b.append(a[i])
    else:
        b.insert(0, a[i])

if n % 2 == 0:       
    print(' '.join(map(str, b)))
else:
    print(' '.join(map(str, b[::-1])))

Fixed submission:
n, *a_l = map(int, open(0).read().split())
b = []

for a in a_l[::-2]:
        b.append(a)
for a in a_l[n%2::2]:
        b.append(a)

print(' '.join(map(str, b)))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = [int(input()) -1 for _ in range(N)]

done = []
i = 0
cnt = 0

while True:
    if i not in done:
        done.append(i)
        cnt += 1
        if a[i] == 1:
            break
        i = a[i]
    else:
        cnt = -1
        break

print(cnt)

Fixed submission:
N = int(input())
a = [int(input()) -1 for _ in range(N)]

done = [False]*N
i = 0
cnt = 0

while True:
    if done[i] == False:
        done[i] = True
        cnt += 1
        if a[i] == 1:
            break
        i = a[i]
    else:
        cnt = -1
        break

print(cnt)
Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().split())
if a == 'H':
  print(b)
else:
  print('HD'.replace(b,''))

Fixed submission:
a,b = input().split()
if a == 'H':
  print(b)
else:
  print('HD'.replace(b,''))
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input.split())
if a == b:
  ans = 'Draw'
elif a == 1:
  ans = 'Alice'
elif b == 1:
  ans = 'Bob'
elif a > b:
  ans = 'Alice'
else:
  ans = 'Bob'
print(ans)

Fixed submission:
a,b = map(int,input().split())
if a == b:
  ans = 'Draw'
elif a == 1:
  ans = 'Alice'
elif b == 1:
  ans = 'Bob'
elif a > b:
  ans = 'Alice'
else:
  ans = 'Bob'
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
cnt = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x+y+z == s:
                cnt += 1
print(cnt)

Fixed submission:
k, s = map(int, input().split())
cnt = 0
for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if 0<=z<=k:
            cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N, A, *x = map(int, open(0).read().split())
dp = [[[0]*(3000) for _ in range(55)] for _ in range(55)]
dp[0][0][0] = 1

for j in range(N+1):
    for k in range(N+1):
        for s in range(N*A+1):
            if j >= 1:
                dp[j][k][s] += dp[j-1][k][s]  # 選ばない場合
                if k >= 1 and s >= x[j-1]:
                    dp[j][k][s] += dp[j-1][k-1][s-x[j-1]]  # 選ぶ場合
ans = 0
for k in range(1, N+1):
    ans += dp[N][k][k*A]
print(ans)

Fixed submission:
N, A, *x = map(int, open(0).read().split())
dp = [[[0]*(3000) for _ in range(55)] for _ in range(55)]
dp[0][0][0] = 1

for j in range(N+1):
    for k in range(N+1):
        for s in range(N*A+1):
            if j >= 1:
                dp[j][k][s] += dp[j-1][k][s]  # 選ばない場合
                if k >= 1 and s >= x[j-1]:
                    dp[j][k][s] += dp[j-1][k-1][s-x[j-1]]  # 選ぶ場合
ans = 0
for k in range(1, N+1):
    ans += dp[N][k][k*A]
print(ans)
Buggy python submission (verdict: Runtime Error):
import math,sys,bisect,heapq
from collections import defaultdict,Counter,deque
from itertools import groupby,accumulate
#sys.setrecursionlimit(200000000)
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda: map(int,input().split())
alele = lambda: list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
#def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
MOD = 1000000000 + 7
def Y(c):  print(["NO","YES"][c])
def y(c):  print(["no","yes"][c])
def Yy(c):  print(["No","Yes"][c])

def fun(A,N,dp,pos= 0):
    if pos == N-1:
        return 0
    elif pos == N-2:
        return abs(A[N-1] - A[N-2])
    if dp.get(pos,-1) != -1:
        return dp[pos]
    else:
        dp[pos]= min(abs(A[pos] - A[pos+1]) + fun(A,N,dp,pos+1), abs(A[pos] - A[pos+2]) + fun(A,N,dp,pos+2))
        return dp[pos]
    
dp = {}
N = int(input())
A = alele()
print(fun(A,N,dp))

Fixed submission:
import math,sys,bisect,heapq
from collections import defaultdict,Counter,deque
from itertools import groupby,accumulate
#sys.setrecursionlimit(200000000)
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda: map(int,input().split())
alele = lambda: list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
#def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
MOD = 1000000000 + 7
def Y(c):  print(["NO","YES"][c])
def y(c):  print(["no","yes"][c])
def Yy(c):  print(["No","Yes"][c])

def fun(A,N):
    dp = [0]*N
    for pos in range(N):
        if pos == 0:
            dp[pos] = 0
        elif pos == 1:
            dp[pos]  = abs(A[pos-1] - A[pos])
        else:
            dp[pos]= min(abs(A[pos] - A[pos-1]) + dp[pos-1], abs(A[pos] - A[pos-2]) + dp[pos-2])
    return dp[-1]

N = int(input())
A = alele()
print(fun(A,N))
Buggy python submission (verdict: Time Limit Exceeded):
import math,sys,bisect,heapq
from collections import defaultdict,Counter,deque
from itertools import groupby,accumulate
#sys.setrecursionlimit(200000000)
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda: map(int,input().split())
alele = lambda: list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
#def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
MOD = 1000000000 + 7
def Y(c):  print(["NO","YES"][c])
def y(c):  print(["no","yes"][c])
def Yy(c):  print(["No","Yes"][c])
    
def fun(A,P,W,N,dp):
    if N == 0 or W == 0:
        return 0
    if dp.get((W,N),-1) != -1:
        return dp[(W,N)]
    else:
        if A[N-1] <= W:
            dp[(W,N)]  = max(P[N-1] + fun(A,P,W-A[N-1],N-1,dp) , fun(A,P,W,N-1,dp))
        else:
            dp[(W,N)] =  fun(A,P,W,N-1,dp)
        return dp[(W,N)]
    
    
N,W = ilele()
P = []
A = []
for i in range(N):
    a,b =ilele()
    A.append(a)
    P.append(b)
dp = {}
print(fun(A,P,W,N,dp))
    

Fixed submission:
import math,sys,bisect,heapq
from collections import defaultdict,Counter,deque
from itertools import groupby,accumulate
#sys.setrecursionlimit(200000000)
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda: map(int,input().split())
alele = lambda: list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
#def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
MOD = 1000000000 + 7
def Y(c):  print(["NO","YES"][c])
def y(c):  print(["no","yes"][c])
def Yy(c):  print(["No","Yes"][c])
    
def knapsack(wts,P,N,W):
    if N==0 or W == 0:
        return 0
    dp = list2d(100,100001,1e10) #dp[item][val] = weight
    dp[0][0] = 0
    dp[0][P[0]] = wts[0]
    ##we have to minimize the weight
    for i in range(1,N):
        dp[i][0] = 0
        for j in range(1,100000+1):
            dp[i][j] = dp[i-1][j] # discarding current
            if P[i] <= j:
                dp[i][j] = min(wts[i] + dp[i-1][j - P[i]] , dp[i][j])
            
    #minimum weight
    for val in range(100000,-1,-1):
        if dp[N-1][val] <= W:
            return val #returning the val at maximum weight
    

N,W = ilele()
P = []
A = []
for i in range(N):
    a,b =ilele()
    A.append(a)
    P.append(b)
print(knapsack(A,P,N,W))
Buggy python submission (verdict: Time Limit Exceeded):
import math,sys,bisect,heapq
from collections import defaultdict,Counter,deque
from itertools import groupby,accumulate
sys.setrecursionlimit(200000000)
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda: map(int,input().split())
alele = lambda: list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
#def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
MOD = 1000000000 + 7
def Y(c):  print(["NO","YES"][c])
def y(c):  print(["no","yes"][c])
def Yy(c):  print(["No","Yes"][c])

    
def fun(A,N,h,t,dp):
    if N < 0:
        return 0
    if N==0:
        if h > t:
            return 1
        return 0
    x = dp.get((N,h,t),-1)
    if x!= -1:
        return x
    else:
        dp[(N,h,t)] = A[N-1]*fun(A,N-1,h+1,t,dp) + (1 - A[N-1])*fun(A,N-1,h,t+1,dp)
        return dp[(N,h,t)]
        
N = int(input())
A = list(map(float, input().split()))
dp = {}
print(fun(A,N,0,0,dp))

Fixed submission:
import math,sys,bisect,heapq
from collections import defaultdict,Counter,deque
from itertools import groupby,accumulate
#sys.setrecursionlimit(200000000)
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda: map(int,input().split())
alele = lambda: list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
#def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
MOD = 1000000000 + 7
def Y(c):  print(["NO","YES"][c])
def y(c):  print(["no","yes"][c])
def Yy(c):  print(["No","Yes"][c])

    
def fun(A,N):
    dp = list2d(3000,3000,0)
    dp[0][0] = 1 - A[0]
    dp[0][1] = A[0]
    for i in range(1,N):
        for j in range(3000):
            #tails
            dp[i][j] += (1-A[i])*dp[i-1][j]
            #heads
            if j > 0:
                dp[i][j] += A[i]*(dp[i-1][j-1])
    ans = 0
    for i in range(N//2 + 1,3000):
        ans += dp[N-1][i]
    return ans
        
N = int(input())
A = list(map(float, input().split()))
print(fun(A,N))
Buggy python submission (verdict: Runtime Error):
l, r, d = map(int, input().split(' '))
count = 0
for i range(l, r + 1):
  if i % d == 0:
    count += 1
print(count)

Fixed submission:
def main():
    l, r, d = map(int, input().split(' '))
    count = 0
    for i in range(l, r + 1):
        if i % d == 0:
            count += 1
    print(count)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
def main():
    n = int(input())
    ans = []
    for x in range(1, n):
        for y in range(1, n):
            for z in range(1, n):
                ans.append(x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x)
    counter = Counter(ans)
    for i in range(1, n+1):
        print(counter[i])
 
 
if __name__ == '__main__':
    main()

Fixed submission:
from collections import Counter
import math
def main():
    n = int(input())
    ans = []
    for x in range(1, int(math.sqrt(n+1))+1):
        for y in range(1, int((math.sqrt(n+1)))+1):
            for z in range(1, int((math.sqrt(n+1)))+1):
                ans.append(x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x)
    counter = Counter(ans)
    for i in range(1, n+1):
        print(counter[i])
 
 
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    for i in range(n):
        calc(i)
 
def calc(n):
    count = 0
    for x in range(1, n + 1):
        for y in range(1, n + 1):
            for z in range(1, n + 1):
                if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x == n+1:
                     count += 1
    print(count)
    return
 
if __name__ == '__main__':
    main()

Fixed submission:
from collections import Counter
import math
def main():
    n = int(input())
    ans = []
    for x in range(1, int(math.sqrt(n+1))+1):
        for y in range(1, int((math.sqrt(n+1)))+1):
            for z in range(1, int((math.sqrt(n+1)))+1):
                ans.append(x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x)
    counter = Counter(ans)
    for i in range(1, n+1):
        print(counter[i])
 
 
if __name__ == '__main__':
    main()