Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
array = list(map(int,input().split()))

su = sum(array)

def func(c,ar):
    num = max(ar[0:c])
    idx = ar.index(num)
    for i in range(idx+1,c):
        ar[i] = num 
    if idx == 0:
        print(sum(ar)-su)
        return
    func(idx,ar)
    
res = func(N,array)

Fixed submission:
N = int(input())
array = list(map(int,input().split()))
new_array = array
t = sum(array)

for i in range(N-1):
    if array[i] > array[i+1]:
        array[i+1] = array[i]
print(sum(array) - t)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
array = list(map(int,input().split()))

def func(c,result):
    num = max(array[0:c])
    idx = array.index(num)
    result += (-sum(array[idx+1:c]) + (num*(c-idx-1)))
    if idx == 0:
        print(result)
        return
    func(idx,result)
    
res = func(N,0)

Fixed submission:
N = int(input())
array = list(map(int,input().split()))
new_array = array
t = sum(array)

for i in range(N-1):
    if array[i] > array[i+1]:
        array[i+1] = array[i]
print(sum(array) - t)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
array = list(map(int,input().split()))

def func(c,result):
    num = max(array[0:c])
    idx = array.index(num)
    result += (-sum(array[idx:c]) + (num*(c-idx)))
    if idx == 0:
        print(result)
        return
    func(idx,result)
    
res = func(N,0)

Fixed submission:
N = int(input())
array = list(map(int,input().split()))
new_array = array
t = sum(array)

for i in range(N-1):
    if array[i] > array[i+1]:
        array[i+1] = array[i]
print(sum(array) - t)
Buggy python submission (verdict: Runtime Error):
from math import pi
radius = int(input())
circumfernece = 2*pi*radius
print(circumference)

Fixed submission:
from math import pi

r = int(input())
print(pi*2*r)
Buggy python submission (verdict: Runtime Error):
S=int(input())
T = input().split()
U = [int(T(i)) for i in S]
U.sort
r = 0

for i in S-1:
  if(T[i] == T[i+1]):
    r++
    
if(r==0):
  print("YES")
else:
  print("NO")

Fixed submission:
S=int(input())
T = input().split()
U = [int(i) for i in T]
U.sort()
r = 0

for i in range(S-1):
  if(U[i] == U[i+1]):
    r+=1
    
if(r==0):
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
  
N,K = map(int,imput().split())
A = Base_10_to_n(N, K)
print(len(A))


Fixed submission:
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
  
N,K = map(int,input().split())
A = Base_10_to_n(N, K)
print(len(A))

Buggy python submission (verdict: Runtime Error):
import math
N,K = map(int,imput().split())

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

A = Base_10_to_n(N, K)
print(len(A))


Fixed submission:
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
  
N,K = map(int,input().split())
A = Base_10_to_n(N, K)
print(len(A))
Buggy python submission (verdict: Runtime Error):
import collections
import sys
input = lambda: sys.stdin.readline().strip()

def main():
    N,M = map(int,input().split())
    H_list = list(map(int,input().split()))
    ab_list = [map(int,input().split()) for _ in range(M)]

    ab_dict = dict()
    for a,b in ab_list:
        minab = min(a,b)
        if str(minab) not in ab_dict.keys():
            ab_dict.update({min(a,b):[max(a,b)]})
        else:
            ab_dict[str(minab)] += max(a,b)
    c = collections.Counter(H_list)

    ans = 0
    for i in range(1,len(ab_dict)+1):
        if i < min(ab_dict.get(i)):
            ans += c[i]
    print(ans)

main()


Fixed submission:
import collections
import sys
input = lambda: sys.stdin.readline().strip()

def main():
    N,M = map(int,input().split())
    H_list = list(map(int,input().split()))
    ab_list = [list(map(int,input().split())) for _ in range(M)]

    ab_dict = {i: [] for i in range(N)}
    for a,b in ab_list:
        a,b = a-1,b-1
        ab_dict[a].append(b)
        ab_dict[b].append(a)

    c = collections.Counter(H_list)

    # print(H_list)
    # print(ab_dict)
    ans = 0
    for k,v_list in ab_dict.items():
        for v in v_list:
            if H_list[v] >= H_list[k]:
                break
        else:ans += 1
    print(ans)

main()
Buggy python submission (verdict: Runtime Error):
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def is_kaibun(_S):
    if _S[:int((len(_S)-1)/2)]==_S[int((len(_S)+1)/2):][::-1]:
        return True
    else:
        return False

def main():
    _S = S()
    is_tsuyoi1 = is_kaibun(_S)
    is_tsuyoi2 = is_kaibun(_S[:int((len(_S)-1)/2)])
    is_tsuyoi3 = is_kaibun(_S[int((len(_S)+3)/2)])
    print("Yes" if is_tsuyoi1 and is_tsuyoi2 and is_tsuyoi3 else "No")


main()


Fixed submission:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def is_kaibun(_S):
    if len(_S)==1 or _S[:int((len(_S))/2)]==_S[int((len(_S)+1)/2):][::-1]:
        return True
    else:
        return False

def main():
    _S = S()
    is_tsuyoi1 = is_kaibun(_S)
    is_tsuyoi2 = is_kaibun(_S[:int((len(_S)-1)/2)])
    is_tsuyoi3 = is_kaibun(_S[int((len(_S)+1)/2):])
    print("Yes" if is_tsuyoi1 and is_tsuyoi2 and is_tsuyoi3 else "No")


main()
Buggy python submission (verdict: Runtime Error):
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    N,M = LI()
    SC = [LI() for _ in range(M)]
    a = [0 for _ in range(N)]
    pre = [None for _ in range(N)]
    for s,c in SC:
        s = s-1
        if (a[s]==c) or (pre[s] is None):
            pre[s] = a[s]
            a[s] = c
        else:
            print(-1)
            exit(0)
    ans = int("".join(map(str,a)))
    if len(str(ans))==N:
        for i in range(N,3):
            if pre[i] is not None:
                print(-1)
                exit(0)
            else:
                pass
        print("{}".format(int(ans)))
    else:
        print(-1)
main()



Fixed submission:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    N,M = LI()
    SC = [LI() for _ in range(M)]
    a = [0 for _ in range(N)]
    pre = [None for _ in range(N)]
    # for s,c in SC:
    #     s = s-1
    #     if (a[s]==c) or (pre[s] is None):
    #         pre[s] = a[s]
    #         a[s] = c
    #     else:
    #         print(-1)
    #         exit(0)
    # ans = int("".join(map(str,a)))
    # if len(str(ans))==N:
    #     print("{}".format(int(ans)))
    # else:
    #     print(-1)

    for i in range(1000):
        i = str(i)
        if len(i)==N:
            for s,c in SC:
                if i[s-1] == str(c):
                    # print(i[s-1], c)
                    continue
                else:
                    break
            else:
                print(i)
                exit(0)
        else:
            continue
    else:
        print(-1)

main()
Buggy python submission (verdict: Time Limit Exceeded):
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    N = I()
    P = LI()
    ans = 0
    for i in range(N):
        if min(P[:i+1])>=P[i]:
            ans += 1
    print(ans)

main()



Fixed submission:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    N = I()
    P = LI()
    ans = 0
    min_num = P[0]
    for i in range(N):
        if min_num>=P[i]:
            ans += 1
            min_num = P[i]

    print(ans)

main()

Buggy python submission (verdict: Time Limit Exceeded):
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    N = I()
    P = LI()
    bar_ans = 0
    for i in range(N):
        for j in range(0,i+1):
            if P[j]<P[i]:
                bar_ans += 1
                break
            else:
                pass
    print(N - bar_ans)

main()



Fixed submission:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    N = I()
    P = LI()
    ans = 0
    min_num = P[0]
    for i in range(N):
        if min_num>=P[i]:
            ans += 1
            min_num = P[i]

    print(ans)

main()
Buggy python submission (verdict: Runtime Error):
# a,b,c=map(int,input().split());print("Yes" if a<=c<=b else "No")

# a,b,c=map(int,input().split());print('NYoe s'[a<=c<=b::2])
# a,b,c=map(int,input().split())
# print(a,b,c)
# import numpy as np
# arr = np.fromstring(input(), sep=" ")
# print(arr)


*s,c=input().split();print(["No","Yes"][int(s[0])<=c<=s[1]])
# print(*s[2::]<=c)
# print(exec("$0=substr(\"YesNo\",$3<$1||$3>$2?4:1,3))")

Fixed submission:
a,b,c=map(int,input().split());print("Yes" if a<=c<=b else "No")
Buggy python submission (verdict: Runtime Error):
a = input()
s = 0
for i in a:
    s += int(i)
if s % 9 == 0 :
    print("Yes")
else:
    print("No")

Fixed submission:
a = input().split(" ")
g = int(a[0])
c = int(a[1])
b = int(a[2])
l = c
m = b
while c < g :
    c = c + l
    b = b + m
print(b)
Buggy python submission (verdict: Time Limit Exceeded):
a = int(input())
def getSum(n):
    s = 0
    while (n != 0):
        s = s + (n % 10)
        n = n // 10
    return s
c = getSum(a)
if c % 9 == 0 :
    print("Yes")
else:
    print("No")

Fixed submission:
a = input()
s = 0
for i in a:
    s += int(i)
if s % 9 == 0 :
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
a = input().split(" ")
m = len(a)
b = 0
while b < m :
    if a[b]=="0"
    print(b)
    b = b + 1

Fixed submission:
a = input().split(" ")
m = len(a)
b = 0
while b < m :
    if a[b] == "0":
        print(b + 1)
    b = b + 1
Buggy python submission (verdict: Runtime Error):
a = input().split(" ")
print(a[0]*a[1])

Fixed submission:
a = input().split(" ")
print(int(a[0])*int(a[1]))
Buggy python submission (verdict: Time Limit Exceeded):
a = int(input())
b = input().split(" ")
i = 0
s = 1
while i < a :
    s = s * int(b[i])
    i = i + 1
if s > (10 ** 18) :
    print("-1")
else:
    print(s)

Fixed submission:
a = int(input())
b = input().split(" ")
i = 0
s = 1
f = 0
while i < a :
    if b[i] == "0" :
        print(0)
        f = f + 1
    i = i + 1
i = 0
while (i < a) and f == 0 :
    s = s * int(b[i])
    i = i + 1
    if s > (10 ** 18):
        print("-1")
        break
    if (s <= 10 ** 18) and (i == a):
        print(s)

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = input().split(" ")
i = 0
s = 1
while i < a :
    s = s * int(b[i])
    i = i + 1
if s > (10 ** 18) :
    print("-1")
else:
    print(s)


Fixed submission:
a = int(input())
b = input().split(" ")
i = 0
s = 1
f = 0
while i < a :
    if b[i] == "0" :
        print(0)
        f = f + 1
    i = i + 1
i = 0
while (i < a) and f == 0 :
    s = s * int(b[i])
    i = i + 1
    if s > (10 ** 18):
        print("-1")
        break
    if (s <= 10 ** 18) and (i == a):
        print(s)

Buggy python submission (verdict: Time Limit Exceeded):
a = int(input())
b = input().split(" ")
i = 0
s = 1
while i < a :
    s = s * int(b[i])
    i = i + 1
if s > (10 ** 18) :
    print("-1")
else:
    print(s)

Fixed submission:
a = int(input())
b = input().split(" ")
i = 0
s = 1
f = 0
while i < a :
    if b[i] == "0" :
        print(0)
        f = f + 1
    i = i + 1
i = 0
while (i < a) and f == 0 :
    s = s * int(b[i])
    i = i + 1
    if s > (10 ** 18):
        print("-1")
        break
    if (s <= 10 ** 18) and (i == a):
        print(s)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = input()
i = 0
while i < a :
    print(end = b[i])
    i = i + 1
if a < len(b) :
    print(end = "...")

Fixed submission:
a = int(input())
b = input()
i = 0
while i < a and i < len(b):
    print(end = b[i])
    i = i + 1
if a < len(b) :
    print(end = "...")
Buggy python submission (verdict: Runtime Error):
a = input()
b = 0
c = 0
i = 0
while i < a :
    if a[i] == "A" :
        b = b + 1
    if a[i] == "B" :
        c = c + 1
    i = i + 1
if (b > 0) and (c > 0) :
    print("Yes")
else:
    print("No")

Fixed submission:
a = input()
b = 0
c = 0
i = 0
while i < len(a) :
    if a[i] == "A" :
        b = b + 1
    if a[i] == "B" :
        c = c + 1
    i = i + 1
if (b > 0) and (c > 0) :
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())

svn = 7
cnt = 1
for i in range(10**7):
    svn %= k
    if svn == 0:
        print(cnt)
        exit()
    svn *= 10
    svn += 7
    cnt += 1
print(-1)

Fixed submission:
k = int(input())

svn = 7
cnt = 1
for i in range(10**7):
    svn %= k
    if svn == 0:
        print(cnt)
        exit()
    svn *= 10
    svn += 7
    cnt += 1
print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int,input().split()))
ans = 1
for i in range(n):
    ans *= A[i]

if ans <= pow(10,18):
    print(ans)
else:
    print(-1)

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
ans = 1
if 0 in A:
    print(0)
    exit()
for i in range(n):
    ans *= A[i]
    if ans > pow(10,18):
        print(-1)
        exit()
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = list(input())
cnt = 0
Num = []
for i in range(10):
    for j in range(10):
        for k in range(10):
            s = [str(i),str(j),str(k)]
            Num.append(s)

for num in Num:
    flag1 = False
    flag2 = False
    memo1 = 0
    memo2 = 0
    for x in range(n-2):
        if num[0] == lst[x]:
            flag1 = True
            memo1 = x
            break
    if flag1:
        for y in range(memo1+1,n-1):
            if num[1] == lst[y]:
                flag2 = True
                memo2 = y
                break
        if flag2:
            for z in range(memo2+1,n):
                if num[2] == lst[z]:
                    cnt += 1
                    break
print(cnt)

Fixed submission:
n = int(input())
lst = list(input())
cnt = 0
Num = []
for i in range(10):
    for j in range(10):
        for k in range(10):
            s = [str(i),str(j),str(k)]
            Num.append(s)

for num in Num:
    flag1 = False
    flag2 = False
    memo1 = 0
    memo2 = 0
    for x in range(n-2):
        if num[0] == lst[x]:
            flag1 = True
            memo1 = x
            break
    if flag1:
        for y in range(memo1+1,n-1):
            if num[1] == lst[y]:
                flag2 = True
                memo2 = y
                break
        if flag2:
            for z in range(memo2+1,n):
                if num[2] == lst[z]:
                    cnt += 1
                    break
print(cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())
m = int(input())
a = list(map(int,input().split()))
M = 10000

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

for i in range(n+1):
    dp[i][0] = 1
    
for i in range(n):
    for j  in range(1,m+1):
        if j - 1 - a[i] >= 0:
            dp[i + 1][j] = (dp[i + 1][j - 1] + dp[i][j] - dp[i][j - 1 - a[i]] ) % M
        else:
            dp[i + 1][j] = (dp[i + 1][j - 1] + dp[i][j]) % M
            
print(dp)

Fixed submission:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

from scipy.special import comb
n, m = map(int, input().split())
a = factorization(m)
M = 10**9 + 7

ans = 1
if m == 1:
    print(1)
    exit()
for i in a:
    ans *= comb(n, i[1], exact=True, repetition=True)
    ans = ans%M
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import Counter

n = int(input())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

cnt = Counter(prime_factorize(n))
two_five = min(cnt[2],cnt[5])
x = 0
for key in cnt:
    if x < key:
        x = key
keta = len(str(key))

print(max(keta,-(-two_five//2)+1))

Fixed submission:
n = int(input())
a = []
for i in range(1,int(n**(0.5))+1):
    if n%i == 0:
        a.append(i)
m = max(a)
c = int(n/m)
keta = len(str(c))
print(keta)

Buggy python submission (verdict: Runtime Error):
from collections import Counter

n = int(input())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

cnt = Counter(prime_factorize(n))
two_five = min(cnt[2],cnt[5])
x = 0
for key in cnt:
    if x < key:
        x = key
keta = len(str(key))

print(max(keta,-(-two_five//2)+1))

Fixed submission:
n = int(input())
a = []
for i in range(1,int(n**(0.5))+1):
    if n%i == 0:
        a.append(i)
m = max(a)
c = int(n/m)
keta = len(str(c))
print(keta)
Buggy python submission (verdict: Runtime Error):
import math

L, R, d = map(int, input().parse())

num = 0
start_d = int(math.ceil(L / d))
end_d = int(math.floor(R / d))

print(end_d - start_d +1)

Fixed submission:
# -*- coding: utf-8 -*-
import math

#L, R, d = map(int, input().parse())
L, R, d = map(int, input().split())
start_d = int(math.ceil(L / d))
end_d = int(math.floor(R / d))
print(end_d - start_d +1)

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

L, R, d = map(int, input().parse())

num = 0
start_d = int(math.ceil(L / d))
end_d = int(math.floor(R / d))

return end_d - start_d +1

Fixed submission:
# -*- coding: utf-8 -*-
import math

#L, R, d = map(int, input().parse())
L, R, d = map(int, input().split())
start_d = int(math.ceil(L / d))
end_d = int(math.floor(R / d))
print(end_d - start_d +1)
Buggy python submission (verdict: Time Limit Exceeded):
x, y = map(int, input().split())

count = [2]*x
ans = []

for i in range(2**x):
    for j in range(x):
        if ((i>>j)&1):
            count[j]=4
    if sum(count) == y:
        ans = 'Yes'
        break
    else:
        ans = 'No'

print(ans)

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

for i in range(x+1):
    foot = 2*i + 4* (x-i)
    if foot == y:
        print('Yes')
        exit()
print('No')

Buggy python submission (verdict: Time Limit Exceeded):
x, y = map(int, input().split())

count = [2]*x
ans = []

for i in range(2**x):
    for j in range(x):
        if ((i>>j)&1):
            count[j]=4
    ans.append(sum(count))

if ans.count(y):
    print('Yes')
else:
    print('No')

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

for i in range(x+1):
    foot = 2*i + 4* (x-i)
    if foot == y:
        print('Yes')
        exit()
print('No')

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

c = [4,2]
count = []

for i in range(x-1):
    for j in range(x-1):
        for k in range(x-1):
            sum = c[i]+c[j]+c[k]
            count.append(sum)

if count.count(y) or (x == 1 and y == 2) or (x == 1 and y == 4):
    print('Yes')
else:
    print('No')

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

for i in range(x+1):
    foot = 2*i + 4* (x-i)
    if foot == y:
        print('Yes')
        exit()
print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
nums = list(map(int, input().split()))
ans = 1

if nums.count(0) > 0:
  ans = 0
else:
  for i in range(n):
    ans *= nums[i]
    if ans >= 10**18:
      ans = -1
      break
  else:
    break
 
print(ans)

Fixed submission:
n = int(input())
nums = list(map(int, input().split()))
ans = 1

if nums.count(0) > 0:
  ans = 0
else:
  for i in range(n):
    ans *= nums[i]
    if ans > 10**18:
      ans = -1
      break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
nums = list(map(int, input().split()))
ans = 1
 
for i in range(n):
  ans *= nums[i]
  
if ans > 10**18:
  ans = -1
 
print(ans)

Fixed submission:
n = int(input())
nums = list(map(int, input().split()))
ans = 1

if nums.count(0) > 0:
  ans = 0
else:
  for i in range(n):
    ans *= nums[i]
    if ans > 10**18:
      ans = -1
      break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
t = list(input())
count = 0
nums = []
num = []
ans = []
 
for i in range(len(t)):
  if t[i] == '?':
    count += 1
    num.append(i)
 
for j in range(2**count):
  tmp = ['D'] * count
  for k in range(count):
    if j >> k & 1:
      tmp[k] = 'P'
    a = num[k]
    t[a] = tmp[k]
  b = ''.join(t)
  nums.append(b)
  c = int(b.count('PD')) + int(b.count('D'))
  ans.append(c)
  
d = ans.index(max(ans))
print(nums[d])

Fixed submission:
t = list(input())
t = ''.join(t)
t = t.replace('?',  'D')

print(t)

Buggy python submission (verdict: Time Limit Exceeded):
t = list(input())
count = 0
nums = []
num = []
ans = []

for i in range(len(t)):
  if t[i] == '?':
    count += 1
    num.append(i)

for i in range(2**count):
  tmp = ['D'] * count
  for j in range(count):
    if i >> j & 1:
      tmp[j] = 'P'
    a = num[j]
    t[a] = tmp[j]
  b = ''.join(t)
  nums.append(b)
  c = int(b.count('PD')) + int(b.count('D'))
  ans.append(c)
  
d = ans.index(max(ans))
print(nums[d])

Fixed submission:
t = list(input())
t = ''.join(t)
t = t.replace('?',  'D')

print(t)