Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
for i in range(n):
    if i == 0:
        s = input()
        S = {s: 1}
    else:
        s = input()
        if s in S:
            S[s] += 1
        else:
            S[s] = 1
max_k_list = [kv[0] for kv in S.items() if kv[1] == max(S.values())]
ans = sorted(max_k_list)
for a in ans:
    print(a, sep="\n")

Fixed submission:
n = int(input())
ans = []
for i in range(n):
    if i == 0:
        s = input()
        S = {s: 1}
        ans.append(s)
        mx = 1
    else:
        s = input()
        if s in S:
            S[s] += 1
            if S[s] > mx:
                ans = [s]
                mx = S[s]
            elif S[s] == mx:
                ans.append(s)
        else:
            S[s] = 1
            if S[s] == mx:
                ans.append(s)
ans = sorted(ans)
for a in ans:
    print(a, sep="\n")
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ac = []
sb = []
for i in range(m):
    p, s = input().split()
    p = int(p)
    sb.append([p, s])
    if s == "AC" and p not in ac:
        ac.append(p)
a = 0
w = 0
for q, st in sb:
    if q in ac:
        if st == "AC":
            a += 1
            ac.remove(q)
        else:
            w += 1
print(str(a) + " " + str(w))

Fixed submission:
n, m = map(int, input().split())
ac = [False] * n
wa = [0] * n
for _ in range(m):
    p, s = input().split()
    p = int(p)
    if s == "AC" and ac[p-1] == False:
        ac[p-1] = True
    elif s == "WA" and ac[p-1] == False:
        wa[p-1] += 1
a = 0
w = 0
for i in range(n):
    if ac[i]:
        a += 1
        w += wa[i]
print(a, w)
Buggy python submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
a, b = map(int, input().split())
print(lcm(a, b))

Fixed submission:
def gcd(a, b):
    while b!=0:
        a,b = b, a%b
    return a

def lcm(a, b):
    return a*b//gcd(a,b)

a, b = map(int, input().split())
print(lcm(a, b))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
S = list(input())
sl = itertools.combinations(S, 3)
sl_s = set(sl)
print(len(sl_s))

Fixed submission:
n = int(input())
s = input()
ans = 0
for i in range(1000):
    tg = str(i + 1000)[1:]
    if tg[0] not in s:
        continue
    else:
        x2 = s[s.index(tg[0]) + 1:]
        if tg[1] not in x2:
            continue
        else:
            x3 = x2[x2.index(tg[1]) + 1:]
            if tg[2] not in x3:
                continue
            else:
                ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
S = list(input())
sl = itertools.combinations(S, 3)
sl_s = set(sl)
print(len(sl_s))

Fixed submission:
n = int(input())
s = input()
ans = 0
for i in range(1000):
    tg = str(i + 1000)[1:]
    if tg[0] not in s:
        continue
    else:
        x2 = s[s.index(tg[0]) + 1:]
        if tg[1] not in x2:
            continue
        else:
            x3 = x2[x2.index(tg[1]) + 1:]
            if tg[2] not in x3:
                continue
            else:
                ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n = int(input())
s = input()
nm = [i for i in range(n)]
sl = itertools.combinations(nm, 3)
ans = []

for v in sl:
    a, b, c = v[0], v[1], v[2]
    p = str(s[a]) + str(s[b]) + str(s[c])
    ans.append(p)
    ans_s = set(ans)
    
print(len(ans_s))

Fixed submission:
n = int(input())
s = input()
ans = 0
for i in range(1000):
    tg = str(i + 1000)[1:]
    if tg[0] not in s:
        continue
    else:
        x2 = s[s.index(tg[0]) + 1:]
        if tg[1] not in x2:
            continue
        else:
            x3 = x2[x2.index(tg[1]) + 1:]
            if tg[2] not in x3:
                continue
            else:
                ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort(reverse=True)

right = 0
left = a[-1]*f[0]

while right!=left:
    mid = (right+left)//2
    syu = 0
    
    for i in range(n):
        if a[i]*f[i]>mid:
            syu += a[i] - mid//f[i]
    
    if syu <= k:
        left = mid
    else:
        right = mid + 1
        
print(right)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort(reverse=True)

right = 0
left = a[-1]*f[0]

while right!=left:
    mid = (right+left)//2
    syu = 0
    
    for i in range(n):
        if a[i]*f[i]>mid:
            syu += a[i] - mid//f[i]
    
    if syu <= k:
        left = mid
    else:
        right = mid + 1
        
print(right)
Buggy python submission (verdict: Runtime Error):
import heapq
def _heappush_max(heap, item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappop_max(heap):
    lastelt = heap.pop()    
    if heap:
        returnitem = heap[0]
        heap[0] = lastelt
        heapq._siftup_max(heap, 0)
        return returnitem
    return lastelt

N, M = map(int, input().split())
price = list(map(int, input().split()))

heapq._heapify_max(price)

for i in range(M):
    a = heapq._heappop_max(price)
    a //= 2
    _heappush_max(price, a)

print(sum(price))

Fixed submission:
import heapq

def _heappush_max(heap, item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
    
def _heappop_max(heap):
    lastelt = heap.pop()    
    if heap:
        returnitem = heap[0]
        heap[0] = lastelt
        heapq._siftup_max(heap, 0)
        return returnitem
    return lastelt

N, M = map(int, input().split())
p = list(map(int, input().split()))

heapq._heapify_max(p)

for i in range(M):
    a = _heappop_max(p)
    a //= 2
    _heappush_max(p, a)

print(sum(p))

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

for i in range(M):
    price[-1] //= 2
    price.sort()
    
print(sum(price))

Fixed submission:
import heapq

def _heappush_max(heap, item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
    
def _heappop_max(heap):
    lastelt = heap.pop()    
    if heap:
        returnitem = heap[0]
        heap[0] = lastelt
        heapq._siftup_max(heap, 0)
        return returnitem
    return lastelt

N, M = map(int, input().split())
p = list(map(int, input().split()))

heapq._heapify_max(p)

for i in range(M):
    a = _heappop_max(p)
    a //= 2
    _heappush_max(p, a)

print(sum(p))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [list(input()) for _ in range(N)]
l = []
cnt = 0
for st in s:
    st.sort()
    l.append("".join(st))
l.sort()
a = list(set(l))
for uni in a:
    c = l.count(uni)
    if c>1:
        cnt += (1+(c-1))*(c-1)//2
print(cnt)

Fixed submission:
N = int(input())
s = [list(input()) for _ in range(N)]
l = []
for st in s:
    st.sort()
    l.append("".join(st))
l.sort()
cnt = 0
c = 1
for i in range(N-1):
    if l[i]==l[i+1]:
        c += 1
    else:
        if c>1:
            cnt += (1+(c-1))*(c-1)//2
        c = 1
print(cnt+(1+(c-1))*(c-1)//2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [list(input()) for _ in range(N)]
l = []
cnt = 0
for st in s:
    st.sort()
    l.append("".join(st))
l.sort()
a = list(set(l))
for uni in a:
    c = l.count(uni)
    if c>1:
        while c>1:
            cnt += c-1
            c -=1
print(cnt)

Fixed submission:
N = int(input())
s = [list(input()) for _ in range(N)]
l = []
for st in s:
    st.sort()
    l.append("".join(st))
l.sort()
cnt = 0
c = 1
for i in range(N-1):
    if l[i]==l[i+1]:
        c += 1
    else:
        if c>1:
            cnt += (1+(c-1))*(c-1)//2
        c = 1
print(cnt+(1+(c-1))*(c-1)//2)
Buggy python submission (verdict: Runtime Error):
import math
a, b, c ,d = map(int, input().split())
e = int((c * d) / math.gcd(c, d))
wareru = (int(b/c) + int(b/d) - int(b/e) - (int((a-1)/c) + int((a-1)/d) - int((a-1)/e)))
print(b-a+1-wareru)

Fixed submission:
a, b, c ,d = map(int, input().split())
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
def lcm(a,b):
      return a*b//gcd(a,b)
e = lcm(c, d)
wareru = b//c + b//d - b//e - ((a-1)//c + (a-1)//d - (a-1)//e)
print(b-a+1-wareru)

Buggy python submission (verdict: Runtime Error):
import math
a, b, c ,d = map(int, input().split())
e = (c * d) // math.gcd(c, d)
wareru = (int(b/c) + int(b/d) - int(b/e) - (int((a-1)/c) + int((a-1)/d) - int((a-1)/e)))
print(b-a+1-wareru)

Fixed submission:
a, b, c ,d = map(int, input().split())
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
def lcm(a,b):
      return a*b//gcd(a,b)
e = lcm(c, d)
wareru = b//c + b//d - b//e - ((a-1)//c + (a-1)//d - (a-1)//e)
print(b-a+1-wareru)

Buggy python submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

a, b, c ,d = map(int, input().split())
e = lcm(c, d)
wareru = (int(b/c) + int(b/d) - int(b/e) - (int((a-1)/c) + int((a-1)/d) - int((a-1)/e)))
print(b-a+1-wareru)

Fixed submission:
a, b, c ,d = map(int, input().split())
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
def lcm(a,b):
      return a*b//gcd(a,b)
e = lcm(c, d)
wareru = b//c + b//d - b//e - ((a-1)//c + (a-1)//d - (a-1)//e)
print(b-a+1-wareru)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
print(a*b - a - b + 1)

Fixed submission:
a, b = map(int,input().split())
print(a*b - a - b + 1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = []
cnt = 1
for num in a:
    num -= cnt
    b.append(num)
    cnt += 1
test = [int(mean(b))-1,int(mean(b)),int(mean(b))+1]
ans = []
s = 9999999999999
for i in test:
    cnt = 1
    c = []
    for num in a:
        st = 0
        st = abs(num - (i+cnt))
        c.append(st)
        cnt += 1
    ans.append(sum(c))
print(min(ans))

Fixed submission:
import numpy as np

n = int(input())
a = list(map(int,input().split()))
b = []
cnt = 1
for num in a:
    num -= cnt
    b.append(num)
    cnt += 1
test = [int(np.mean(b))-1,int(np.mean(b)),int(np.mean(b))+1,int(np.median(b))]
test = list(set(test))
ans = []
s = 9999999999999
for i in test:
    cnt = 1
    c = []
    for num in a:
        st = 0
        st = abs(num - (i+cnt))
        c.append(st)
        cnt += 1
    ans.append(np.sum(c))
print(np.min(ans))

Buggy python submission (verdict: Runtime Error):
from statistics import mode
n = int(input())
a = list(map(int,input().split()))
b = []
c = []
cnt = 1
for num in a:
    num -= cnt
    b.append(num)
    cnt += 1
if sum(b) != 0:
    cnt = 1
    for num in a:
        st = 0
        st = abs(num - (mode(b) + cnt))
        c.append(st)
        cnt += 1
    print(sum(c))
else:
    print(sum(b))

Fixed submission:
import numpy as np

n = int(input())
a = list(map(int,input().split()))
b = []
cnt = 1
for num in a:
    num -= cnt
    b.append(num)
    cnt += 1
test = [int(np.mean(b))-1,int(np.mean(b)),int(np.mean(b))+1,int(np.median(b))]
test = list(set(test))
ans = []
s = 9999999999999
for i in test:
    cnt = 1
    c = []
    for num in a:
        st = 0
        st = abs(num - (i+cnt))
        c.append(st)
        cnt += 1
    ans.append(np.sum(c))
print(np.min(ans))
Buggy python submission (verdict: Runtime Error):
import numpy as np
n, k = map(int,input().split())
a = list(map(int,input().split()))
start = [i for i,x in enumerate(a) if x == min(a)]
m = 10000000
for i in start:
    if np.ceil(i/(k-1))+np.ceil(((n-1)-i)/(k-1)) < m:
        m = np.ceil(i/(k-1))+np.ceil(((n-1)-i)/(k-1))
print(m)

Fixed submission:
s = input()
print(s.count("+")-s.count("-"))

Buggy python submission (verdict: Runtime Error):
import numpy as np
import math
n, k = map(int,input().split())
a = list(map(int,input().split()))
start = [i for i,x in enumerate(a) if x == min(a)]
m = 10000000
for i in start:
    if math.ceil(i/(k-1))+math.ceil(((n-1)-i)/(k-1)) < m:
        m = math.ceil(i/(k-1))+math.ceil(((n-1)-i)/(k-1))
print(m)

Fixed submission:
s = input()
print(s.count("+")-s.count("-"))
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if a<=8 and b <= 8:
    print("Yay!")
else:
    print(":(")

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

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if a<=8 and b <= 8:
    print("Yay!")
else:
    print(":(")

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

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if a<=8 and b <= 8:
    print("Yay!")
else:
    print(":(")

Fixed submission:
a, b = map(int,input().split())
if a<=8 and b <= 8:
    print("Yay!")
else:
    print(":(")
Buggy python submission (verdict: Runtime Error):
n = int(input())
pp = list(map(int, input().split()))
cnt = 0
for idx, p in enumerate(pp):
    if p == idx + 1:
        pp[idx], pp[idx+1] = pp[idx+1], pp[idx]
        cnt += 1
print(cnt)

Fixed submission:
n = int(input())
pp = list(map(int, input().split()))
cnt = 0
for i in range(n-1):
    if pp[i] == i + 1:
        pp[i], pp[i+1] = pp[i+1], pp[i]
        cnt += 1
if pp[n-1] == n:
    cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
lcmn = 1
def lcm(a, b):
    return a*b//math.gcd(a, b)
for _ in range(n):
    t = int(input())
    lcmn = lcm(lcmn, t)
print(lcmn)

Fixed submission:
n = int(input())
lcmn = 1
def gcd(a, b):
    while b!=0:
        a, b = b, a%b
    return a
def lcm(a, b):
    return a*b//gcd(a, b)
for _ in range(n):
    t = int(input())
    lcmn = lcm(lcmn, t)
print(lcmn)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
mod = 10**9+7
ans = 1
i = 1
while i <= n:
    ans *= i
    i += 1
print(ans%mod)

Fixed submission:
n = int(input())
mod = 10**9+7
ans = 1
for i in range(1, n+1):
    ans = (ans*i)%mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

A = list(map(int, input().split()))

A_sum = 0

for i in range(N):
    A_sum += A[i]

min = A_sum

for i in range(N):
    AA_sum = 0
    for j in range(i):
        AA_sum += A[j]
    AA_sa = 2*AA_sum - A_sum
    if AA_sa < 0:
        AA_sa = -1 * AA_sa
    if AA_sa < min:
        min = AA_sa
print(min)

Fixed submission:
N = int(input())

A = list(map(int, input().split()))

Asum = 0
A_sum = []

for i in range(N):
    Asum += A[i]
    A_sum.append(Asum)

for i in range(N):
    A_sum[i] = 2*A_sum[i] - Asum
    if A_sum[i] < 0:
        A_sum[i] = -1 * A_sum[i]

print(min(A_sum))
Buggy python submission (verdict: Runtime Error):
import math
from operator import mul
from functools import reduce

def cmb(n,r):
    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

xy = list(map(int, input().split()))

if (2*xy[1]-xy[0]) % 3 == 0 and (2*xy[0]-xy[1]) % 3 == 0:
    a = (2*xy[1]-xy[0]) // 3
    b = (2*xy[0]-xy[1]) // 3
    print(cmb(a+b, a))
else:
    print(0)

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

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
xy = list(map(int, input().split()))

if (2*xy[1]-xy[0]) % 3 == 0 and (2*xy[0]-xy[1]) % 3 == 0 and 2*xy[1]-xy[0] > -1 and 2*xy[0]-xy[1] > -1:
    a = (2*xy[1]-xy[0]) // 3
    b = (2*xy[0]-xy[1]) // 3
    print(cmb(a+b, a)%(10**9 + 7))
else:
    print(0)

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

xy = list(map(int, input().split()))

if (2*xy[1]-xy[0]) % 3 == 0 and (2*xy[0]-xy[1]) % 3 == 0:
    a = (2*xy[1]-xy[0]) // 3
    b = (2*xy[0]-xy[1]) // 3
    ans = int(math.factorial(a+b)/(math.factorial(a)*math.factorial(b)))
    print(int(ans/(10**9 + 7)))
else:
    print(0)

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

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
xy = list(map(int, input().split()))

if (2*xy[1]-xy[0]) % 3 == 0 and (2*xy[0]-xy[1]) % 3 == 0 and 2*xy[1]-xy[0] > -1 and 2*xy[0]-xy[1] > -1:
    a = (2*xy[1]-xy[0]) // 3
    b = (2*xy[0]-xy[1]) // 3
    print(cmb(a+b, a)%(10**9 + 7))
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [input() for i in range(N)]
for i in range(N):
    s[i] = list(s[i])
    s[i].sort()
count = 0
for i in range(N):
    for j in range(i + 1, N):
        if s[i] == s[j]:
            count += 1
print(count)

Fixed submission:
N = int(input())

s = []
ans = 0
count = 1

for i in range(N):
    tmp = input()
    s.append("".join(sorted(tmp)))

s.sort()

for i in range(N - 1):
    if s[i] == s[i + 1]:
        count += 1
    else:
        ans += count*(count - 1) / 2
        count = 1
ans += count*(count - 1) / 2

print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [input() for i in range(N)]
for i in range(N):
    s[i] = list(s[i])
    s[i].sort()
count = 0
for i in range(N):
    for j in range(i + 1, N):
        if s[i] == s[j]:
            count += 1
print(count)


Fixed submission:
N = int(input())

s = []
ans = 0
count = 1

for i in range(N):
    tmp = input()
    s.append("".join(sorted(tmp)))

s.sort()

for i in range(N - 1):
    if s[i] == s[i + 1]:
        count += 1
    else:
        ans += count*(count - 1) / 2
        count = 1
ans += count*(count - 1) / 2

print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [input() for i in range(N)]
for i in range(N):
    s[i] = list(s[i])
    s[i].sort()
count = 0
for i in range(N):
    for j in range(i + 1, N):
        if s[i] == s[j]:
            count += 1
print(count)

Fixed submission:
N = int(input())

s = []
ans = 0
count = 1

for i in range(N):
    tmp = input()
    s.append("".join(sorted(tmp)))

s.sort()

for i in range(N - 1):
    if s[i] == s[i + 1]:
        count += 1
    else:
        ans += count*(count - 1) / 2
        count = 1
ans += count*(count - 1) / 2

print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    A = Counter(A)
    Q = int(input())
    for _ in range(Q):
        b,c = map(int, input().split())
        A[c] += A[b]
        A[b] = 0
        ans = 0
        for k,v in A.items():
            ans += k*v
        print(ans)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    suma = sum(A)
    A = Counter(A)
    Q = int(input())
    for _ in range(Q):
        b,c = map(int, input().split())
        suma -= A[b]*b
        suma += A[b]*c
        A[c] += A[b]
        A[b] = 0
        print(suma)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
  for i,n in enumerate(list(map(int,input().split()))):
  	if n == 0:
    	return i + 1

if __name__ == '__main__':
  main()

Fixed submission:
def main():
  nums = list(map(int,input().split()))
  for i,n in enumerate(nums):
    if n == 0:
      return i + 1

if __name__ == '__main__':
  print(main())

Buggy python submission (verdict: Runtime Error):
def main():
  for i,n in enumerate(map(int,input().split())):
  	if n == 0:
    	return i

if __name__ == '__main__':
  main()

Fixed submission:
def main():
  nums = list(map(int,input().split()))
  for i,n in enumerate(nums):
    if n == 0:
      return i + 1

if __name__ == '__main__':
  print(main())
Buggy python submission (verdict: Runtime Error):
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    T = input()
    result = []
    for i in range(len(T)-1):
        if T[i] == "?":
            if result[i-1] == "P":
                result.append("D")
            elif T[i+1] == "?" or T[i+1] == "D":
                result.append("P")
            else:
                result.append("D")
        else:
            result.append(T[i])
    if T[-1] == "?":
        result.append("D")
    else:
        result.append(T[-1])
    print("".join(result))

if __name__ == '__main__':
    main()


Fixed submission:
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    T = input()
    result = []
    bef = ""
    for i in range(len(T)-1):
        if T[i] == "?":
            if bef == "P":
                result.append("D")
            elif T[i+1] == "?" or T[i+1] == "D":
                result.append("P")
            else:
                result.append("D")
        else:
            result.append(T[i])
        bef = result[-1]
    if T[-1] == "?":
        result.append("D")
    else:
        result.append(T[-1])
    print("".join(result))

if __name__ == '__main__':
    main()