Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def bin_search(list,value,low,high):
    middle = int((low + high) / 2)
    if low > high :
        return 'nothing'
    else:
        if list[middle] == value:
            return middle
        elif list[middle] > value:
            return bin_search(list,value,low,middle - 1)
        elif list[middle] < value:
            return bin_search(list,value,middle + 1,high)


n = int(input())
list = [int(x) for x in input().split()]
list.sort()
count = 0
for i in range(n - 1):
    for j in range(i,n-1):
        a = list[n - i - 1]
        b = list[n - j - 2]
        c = a - b + 1
        while b > c :
         if bin_search(list,c,0,len(list)-1) != 'nothing':
             count += 1
         c += 1
print(count)


Fixed submission:
from bisect import bisect_left

count = 0
n = int(input())
list = sorted([int(x) for x in input().split()])

for i in range(n):
    for j in range(i + 1, n) :
        sum = list[i] + list[j]
        a = bisect_left(list,sum)
        count += a - j - 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list = [int(x) for x in input().split()]
ans = []
count = 0
for  i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if (list[i] >= list[j] + list[k]) or (list[j] >= list[i] + list[k]) or (list[k] >= list[i] + list[j]):
                continue
            else:
                count+= 1
print(count)


Fixed submission:
from bisect import bisect_left

count = 0
n = int(input())
list = sorted([int(x) for x in input().split()])

for i in range(n):
    for j in range(i + 1, n) :
        sum = list[i] + list[j]
        a = bisect_left(list,sum)
        count += a - j - 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list = [int(x) for x in input().split()]
count = 0
for  i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if not((list[i] >= list[j] + list[k]) or (list[j] >= list[i] + list[k]) or (list[k] >= list[i] + list[j])):
                count+= 1
print(count)



Fixed submission:
from bisect import bisect_left

count = 0
n = int(input())
list = sorted([int(x) for x in input().split()])

for i in range(n):
    for j in range(i + 1, n) :
        sum = list[i] + list[j]
        a = bisect_left(list,sum)
        count += a - j - 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list = [int(x) for x in input().split()]
ans = []
count = 0
for  i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if (list[i] < list[j] + list[k]) and (list[j] < list[i] + list[k]) and (list[k] < list[i] + list[j]):
                count+= 1
print(count)


Fixed submission:
from bisect import bisect_left

count = 0
n = int(input())
list = sorted([int(x) for x in input().split()])

for i in range(n):
    for j in range(i + 1, n) :
        sum = list[i] + list[j]
        a = bisect_left(list,sum)
        count += a - j - 1
print(count)
Buggy python submission (verdict: Runtime Error):
from math import gcd
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

a,b = map(lambda x : int(x),input().split())
ko = gcd(a,b)
if ko == 1 :
    print(1)
else :
    list = factorize(ko)

    print(len(set(list)) + 1)


Fixed submission:
from fractions import gcd
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

a,b = map(lambda x : int(x),input().split())
ko = gcd(a,b)
if ko == 1 :
    print(1)
else :
    list = factorize(ko)
    print(len(set(list)) + 1)
Buggy python submission (verdict: Time Limit Exceeded):
n,k,q = map(lambda x: int(x), input().split())
a = []
score = [k]*n
for i in range(q):
    a.append(int(input()))

for i in a:
    score[i-1] += 1
    score = list(map(lambda y: y-1,score))

for i in score :
    if i > 0:
        print('Yes')
    else:
        print('No')


Fixed submission:
n,k,q = map(lambda x: int(x), input().split())
a = []
score = [k-q]*n
for i in range(q):
    a.append(int(input()))

for i in a:
    score[i-1] += 1

for i in score :
    if i > 0:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left

n,m = map(lambda x: int(x), input().split())
a = sorted(map(lambda x: int(x),input().split()))

for i in range(m):
    a.insert(bisect_left(a,a[n-1] // 2),a[n-1] // 2)
    a.pop(n)
print(sum(a))


Fixed submission:
import heapq
n,m = map(lambda x: int(x), input().split())
a = list(map(lambda x: int(x)*(-1),input().split()))
heapq.heapify(a)

for _ in range(m):
    max = heapq.heappop(a)
    heapq.heappush(a,(-1)*(-max//2))
print(-sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left

n,m = map(lambda x: int(x), input().split())
a = sorted(list(map(lambda x: int(x),input().split())))

for i in range(m):
    x = bisect_left(a,a[n-1] // 2)
    a.insert(x,a[n-1] // 2)
    a.pop(n)
print(sum(a))


Fixed submission:
import heapq
n,m = map(lambda x: int(x), input().split())
a = list(map(lambda x: int(x)*(-1),input().split()))
heapq.heapify(a)

for _ in range(m):
    max = heapq.heappop(a)
    heapq.heappush(a,(-1)*(-max//2))
print(-sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list = [int(x+1) for x in range(1,n)]
list.append(1)
mod = 0

for i in range(n) :
    mod += (i + 1) % list[i]
print(mod)


Fixed submission:
n = int(input())
print((n*(n-1))//2)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list = [int(x+1) for x in range(n)]
list.pop(0)
list.append(1)
mod = 0

for i in range(n) :
    mod += (i + 1) % list[i]
print(mod)

Fixed submission:
n = int(input())
print((n*(n-1))//2)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
n,y = map(lambda x:int(x),input().split())

for i in range(n+1) :
    for j in range(n+1) :
        nokori = y - i*10000 - j*5000
        if nokori < 0 :
            continue
        if nokori % 1000 == 0:
            k = int(nokori / 1000)
            if n == i + j + k :
                print(i,j,k)
                sys.exit()
print(-1,-1,-1)


Fixed submission:
import sys
n,y = map(lambda x:int(x),input().split())

for i in range(n+1) :
    for j in range(n+1) :
        if n - (i + j) < 0 :
            continue
        nokori = y - i*10000 - j*5000
        if nokori % 1000 == 0:
            k = int(nokori / 1000)
            if n == i + j + k :
                print(i,j,k)
                sys.exit()
print(-1,-1,-1)

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

for i in range(n+1) :
    for j in range(n+1) :
        nokori = y - i*10000 - j*5000
        if nokori >= 0 and nokori % 1000 == 0:
            k = int(nokori / 1000)
            if n == i + j + k :
                print(i,j,k)
                sys.exit()
print(-1,-1,-1)


Fixed submission:
import sys
n,y = map(lambda x:int(x),input().split())

for i in range(n+1) :
    for j in range(n+1) :
        if n - (i + j) < 0 :
            continue
        nokori = y - i*10000 - j*5000
        if nokori % 1000 == 0:
            k = int(nokori / 1000)
            if n == i + j + k :
                print(i,j,k)
                sys.exit()
print(-1,-1,-1)
Buggy python submission (verdict: Time Limit Exceeded):
k,s = map(lambda x:int(x),input().split())
count = 0
for i in range(k+1) :
    for j in range(k+1):
        for l in range(k+1) :
            if i + j + l == s :
                count += 1
print(count)


Fixed submission:
k,s = map(lambda x:int(x),input().split())
count = 0
for x in range(k+1) :
    for y in range(k+1):
        z = s - x - y
        if z >= 0 and z <= k :
            count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
s = input()
if(s[0] == s[1] or s[1] == s[2] || s[2] == s[3]):print("Bad")
else: print("Good")

Fixed submission:
s = input()
if(s[0] == s[1] or s[1] == s[2] or s[2] == s[3]):print("Bad")
else: print("Good")
Buggy python submission (verdict: Time Limit Exceeded):
N, C = map(int, input().split())
x = []
v = []
for i in range(N):
    x_i, v_i = map(int, input().split())
    x.append(x_i)
    v.append(v_i)

v_1 = [sum(v[:i]) for i in range(1, N+1)]
v_n = [sum(v[i:]) for i in range(N-1, -1, -1)]

c = 0
for i in range(N):
    c_t = v_1[i] - x[i]
    if c_t > c:
        c = c_t
    for j in range(i+1, N):
        c_t = v_1[i] + v_n[N-j-1] - (2 * x[i] + (C - x[j]))
        if c_t > c:
            c = c_t
for i in range(N-1, -1, -1):
    c_t = v_n[N-i-1] - (C - x[i])
    if c_t > c:
        c = c_t
    for j in range(i-1, -1, -1):
        c_t = v_1[j] + v_n[N-i-1] - (x[j] + 2*(C - x[i]))
        if c_t > c:
            c = c_t

print(c)

Fixed submission:
N, C = map(int, input().split())
x = [0]
v = [0]
for i in range(N):
    x_i, v_i = map(int, input().split())
    x.append(x_i)
    v.append(v_i)
fw = [0] * (N+1)
bw = [0] * (N+1)
for i in range(N):
    fw[i+1] = fw[i] + v[i+1]
    bw[i+1] = bw[i] + v[N-i]

for i in range(N):
    fw[i+1] -= x[i+1]
    bw[i+1] -= C - x[N-i]
m_fw = [0] * (N+1)
m_bw = [0] * (N+1)
for i in range(N):
    m_fw[i+1] = max(m_fw[i], fw[i+1])
    m_bw[i+1] = max(m_bw[i], bw[i+1])
c = 0
for i in range(N+1):
    if i == 0:
        l = 0
    else:
        l = C - x[-i]
    c = max(c, bw[i]+m_fw[N-i]-l, fw[i]+m_bw[N-i]-x[i])
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
X = [int(x) for x in input().split(' ')]

for i in range(N):
    tmp = X[:i]
    tmp.extend(X[i+1:])
    print(int(np.median(tmp)))

Fixed submission:
N = int(input())
x = [int(x) for x in input().split()]
y = sorted(x)
l = y[len(x)//2-1]
r = y[len(x)//2]

for xi in x:
    if xi < r: print(r)
    else: print(l)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
X = [int(x) for x in input().split(' ')]

for i in range(N):
    tmp = X[:i]
    tmp.extend(X[i+1:])
    tmp.sort()
    print(tmp[int((N-1) / 2)])

Fixed submission:
N = int(input())
x = [int(x) for x in input().split()]
y = sorted(x)
l = y[len(x)//2-1]
r = y[len(x)//2]

for xi in x:
    if xi < r: print(r)
    else: print(l)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
X = [int(x) for x in input().split(' ')]

for i in range(N):
    tmp = X[:i]
    tmp.extend(X[i+1:])
    for j in range(int((N - 1) / 2)):
        tmp.remove(min(tmp))
    print(min(tmp))

Fixed submission:
N = int(input())
x = [int(x) for x in input().split()]
y = sorted(x)
l = y[len(x)//2-1]
r = y[len(x)//2]

for xi in x:
    if xi < r: print(r)
    else: print(l)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
X = [int(x) for x in input().split(' ')]

for i in range(N):
    tmp = X.copy()
    tmp.pop(i)
    tmp.sort()
    print(tmp[int((N-1)/2)])

Fixed submission:
N = int(input())
x = [int(x) for x in input().split()]
y = sorted(x)
l = y[len(x)//2-1]
r = y[len(x)//2]

for xi in x:
    if xi < r: print(r)
    else: print(l)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, K = map(int, input().split())

items = [i for i in range(A, B + 1) if i - A + 1 <= K or B - i + 1 <= K]
for item in items:
    print(item)

Fixed submission:
A, B, K = map(int, input().split())

if A + K - 1 >=  B - K + 1:
    for item in range(A, B + 1):
        print(item)
else:
    for item in range(A, A + K):
        print(item)
    for item in range(B - K + 1, B + 1):
        print(item)

Buggy python submission (verdict: Time Limit Exceeded):
A, B, K = map(int, input().split())

result = sorted(i for i in range(A, B + 1) if i - A + 1 <= K or B - i + 1 <= K)
for item in result:
    print(item)

Fixed submission:
A, B, K = map(int, input().split())

if A + K - 1 >=  B - K + 1:
    for item in range(A, B + 1):
        print(item)
else:
    for item in range(A, A + K):
        print(item)
    for item in range(B - K + 1, B + 1):
        print(item)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
    if i in a:dp[i]=0
print(dp[n])

Fixed submission:
n,m=map(int,input().split())
a=set([int(input()) for i in range(m)])#setにしないとTLEになる
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
    if i in a:
        dp[i]=0
print(dp[n])
# 入力
# 6 1
# 3
Buggy python submission (verdict: Runtime Error):
s = input()
q = int(input())
qs = [input().split() for i in range(q)]
n = False
left= right = ""
for operation in qs:
    if operation[0] == '1':
        n = not n
    if operation[0] == '2':
        t , f, c = operation
        f = int(f)
        if n:
            f = 1 if f != 1 else 2
        if f == 1:
            left=c+left
        elif f == 2:
            right+=c
s = left+s+right
print(s[::-1] if n else s

Fixed submission:




s = input()
q = int(input())
qs = [input().split() for i in range(q)]
n = False
left= right = ""
for operation in qs:
    if operation[0] == '1':
        n = not n
    if operation[0] == '2':
        t , f, c = operation
        f = int(f)
        if n:
            f = 1 if f != 1 else 2
        if f == 1:
            left=c+left
        elif f == 2:
            right+=c
s = left+s+right
print(s[::-1] if n else s)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = int(input())
for i in range(n):
    a = input().split()
    if len(a) == 1:
        s = s[::-1]
    else:
        if int(a[1]) == 1:
            s  = a[2]+s
        else:
            s = s + a[2]
print(s)

Fixed submission:




s = input()
q = int(input())
qs = [input().split() for i in range(q)]
n = False
left= right = ""
for operation in qs:
    if operation[0] == '1':
        n = not n
    if operation[0] == '2':
        t , f, c = operation
        f = int(f)
        if n:
            f = 1 if f != 1 else 2
        if f == 1:
            left=c+left
        elif f == 2:
            right+=c
s = left+s+right
print(s[::-1] if n else s)
Buggy python submission (verdict: Runtime Error):

n,m = map(int,input().split())
d = dict()
for i in range(m):
    k,v = map(int,input().split())
    if k in d:
        if d[k] !=v:
            print(-1)
            exit()
    else:
        d[k] = v
if 2 not in d:
    d[2] = 0
if 3 not in d:
    d[3] = 0
res = str(d[1])+str(d[2])+str(d[3])
if res == "000":
    print(-1)
    exit()
print(res)

Fixed submission:
n, m = map(int, input().split())
lst = [x for x in range(n)]
dic = {}
not_found = False
special_case = False
for i in range(m):
    a, b = map(int, input().split())
    if str(a) not in list(dic.keys()):
        dic[str(a)] = b
    else:
        if dic[str(a)] != b:
            not_found = True
    lst[a - 1] = b
if m == 0:
    special_case = True
if not_found:
    print(-1)
elif special_case:
    if n == 1:
        print(0)
    elif n == 2:
        print(10)
    else:
        print(100)
else:
    for i in range(n):
        if str(i + 1) not in list(dic.keys()):
            if i + 1 == 1:
                lst[i] = 1
            else:
                lst[i] = 0
    lst = list(map(str, lst))
    res = ''.join(lst)
    if res[0] == '0' and len(res) > 1:
        print(-1)
    else:
        print(int(res))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
arr = list()
for i in range(n):
    arr.append(input())

maxi = 0
res = list()
flag = True
while True:
    if arr:
        x = max(set(arr), key = arr.count)
        if flag:
            maxi = arr.count(x)
            flag = False
            res.append(x)
            while x in arr:
                arr.remove(x)
        else:
            if arr.count(x) == maxi:
                res.append(x)
                while x in arr:
                    arr.remove(x)
            else:
                break
    else:
        break
for i in sorted(res):
    print(i)

Fixed submission:
from collections import defaultdict
N = int(input())
ans = dict()
for _ in range(N):
    k = str(input())
    if k in ans:
        ans[k]+=1
    else:
        ans.update({k:1})
groupedByValue = defaultdict(list)
for key, value in sorted(ans.items()):
    groupedByValue[value].append(key)
l = groupedByValue[max(groupedByValue)]
for i in l:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
arr = list()
for i in range(n):
    arr.append(input())

maxi = 0
s = set(arr)
res = list()
while True:
    flag = True
    x = ""
    if s:
        for i in s:
            if arr.count(i) >= maxi:
                x = i
                maxi = arr.count(i)
                flag = False
        if flag:
            break
        res.append(x)
        while x in arr:
            arr.remove(x)
    else:
        break
for i in sorted(res):
    print(i)



Fixed submission:
from collections import defaultdict
N = int(input())
ans = dict()
for _ in range(N):
    k = str(input())
    if k in ans:
        ans[k]+=1
    else:
        ans.update({k:1})
groupedByValue = defaultdict(list)
for key, value in sorted(ans.items()):
    groupedByValue[value].append(key)
l = groupedByValue[max(groupedByValue)]
for i in l:
    print(i)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
N = list(map(int,input().split()))
N.sort()
for i in range(b):
    N.pop()
print(sum(N))

Fixed submission:
a,b = map(int,input().split())
N = list(map(int,input().split()))
N.sort()
for i in range(b):
    if N:
        N.pop()
print(sum(N))
Buggy python submission (verdict: Time Limit Exceeded):
a = int(input())
num = 2
def is_prime(num):
    if num > 1:
        for i in range(2,num):
            if (num % i) == 0:
                return False
                break
        else:
            return True
    else:
        return False
while True:
    if is_prime(num):
        if num >= a:
            print(num)
            break
    num +=1


Fixed submission:
def checkPrime(num):
    isPrime = True
    for i in range(2,(num//2)+1):
        if(num%i == 0):
            isPrime = False
            break
    return isPrime
def nextPrime(num):
    if(checkPrime(num)):
        return num
    n = num-1 if(num%2==0) else num
    while(True):
        n +=2
        if(checkPrime(n)):
            result = n
            break
    return result

num = int(input())
print(nextPrime(num))
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
arr = [1,2,3]
for i in arr:
  if i != a or i !=b:
	print(i)
    

Fixed submission:
a = int(input())
b = int(input())
arr = [1,2,3]
arr.remove(a)
arr.remove(b)
print(arr[0])
Buggy python submission (verdict: Runtime Error):
n = int(input())
a,b = input().split()
for i in range(n):
    str += a[i]+b[i]
print(str)

Fixed submission:
n = int(input())
a,b = input().split()
print(''.join([a[i]+b[i] for i in range(n)]))
Buggy python submission (verdict: Runtime Error):
import math
a,b = input().split()
print(int((int(a)*int(b))/math.gcd(a,b)))

Fixed submission:
def gcd(a,b):
    return a if (b==0) else gcd(b,a%b)
a,b = map(int,input().split())
print(int((a*b)/gcd(a,b)))

Buggy python submission (verdict: Runtime Error):
import math
a,b = map(int,input().split())
print(int((a*b)/math.gcd(a,b)))


Fixed submission:
def gcd(a,b):
    return a if (b==0) else gcd(b,a%b)
a,b = map(int,input().split())
print(int((a*b)/gcd(a,b)))

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

Fixed submission:
def gcd(a,b):
    return a if (b==0) else gcd(b,a%b)
a,b = map(int,input().split())
print(int((a*b)/gcd(a,b)))
Buggy python submission (verdict: Runtime Error):
cumsum_b = [0] * (N+1)
cumsum_w = [0] * (N+1)

for i in range(N):#累積和
  if S[i] == "#":
    cumsum_b[i+1] += cumsum_b[i] + 1
  else:
    cumsum_w[i+1] += cumsum_w[i] + 1

ans = N
for left in range(1,N+1):#白の範囲を全探索
  tmp = 0
  tmp += cumsum_b[left] - cumsum_b[1]
  tmp += cumsum_w[-1] - cumsum_w[left]
  ans = min(ans,tmp)
else:
  print(ans)

Fixed submission:
N = int(input())
S = input()
 
cumsum_b = [0] * (N+1)
 
for i in range(N):#累積和
  if S[i] == "#":
    cumsum_b[i+1] = cumsum_b[i] + 1
  else:
    cumsum_b[i+1] = cumsum_b[i]

ans = N
tmp = 0
for i in range(N+1):#境界を全探索
  tmp = cumsum_b[i] + ((N-i) - (cumsum_b[-1] - cumsum_b[i]))
  ans = min(ans,tmp)
else:
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

length = []
cnt = 0
now = "#"

for i in S:
  if now == i:
    cnt += 1
  else:
    if now == "#":
      now = "."
    else:
      now = "#"
    length.append(cnt)
    cnt = 1
else:
  length.append(cnt)
  
if len(length) % 2 == 0:
    pass
else:
    length.append(0)
  
ans = 0
for i,v in enumerate(length[0::2]):
    ans += min(v,length[1::2][i])

print(ans)  

Fixed submission:
N = int(input())
S = input()
 
cumsum_b = [0] * (N+1)
 
for i in range(N):#累積和
  if S[i] == "#":
    cumsum_b[i+1] = cumsum_b[i] + 1
  else:
    cumsum_b[i+1] = cumsum_b[i]

ans = N
tmp = 0
for i in range(N+1):#境界を全探索
  tmp = cumsum_b[i] + ((N-i) - (cumsum_b[-1] - cumsum_b[i]))
  ans = min(ans,tmp)
else:
  print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
b = list(map(int,input().split()))

if 1 not in b:
    print(-1)
else:
    lst = []
    index = -1
    for i in range(N):
        if b[i] == 1:
            lst.append([])
            index += 1
        lst[index].append(b[i])
            
    flag = False
    ans = []
    if N < max(b):
        print(-1)
    else:
        if len(lst) == 0:
            print(-1)
        else:
            lst.reverse()
            for i in range(len(lst)):
                for j in range(len(lst[i])):
                    if lst[i][j] > j+1:
                        flag = True
                        print(-1)
                        break
                if flag:
                    break
            
            for i in range(len(lst)):
                lst[i].reverse()
                cnt = 1
                while(len(lst[i]) > 0 ):
                    
                    if lst[i][0] <= cnt:
                        ans.append(lst[i].pop(0))
                    else:
                        ans.append(cnt)
        
                        lst[i].reverse()
                        lst[i].pop(lst[i].index(cnt))
                        lst[i].reverse()             
                        
                    cnt += 1
            else:
                print(*ans,sep="\n")

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

ans = []
while(True):
    if len(b) == 0:
        ans.reverse()
        print(*ans,sep="\n")
        break
    for i in range(len(b)-1,-1,-1):
        if b[i] == i+1:
            ans.append(b.pop(i))
            break
    else:
        print(-1)
        break
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

S = input()
S = list(S)
S = np.array(S)

index_black = np.where(S=="B")[0]

count = 0
for i in index_black:
    count += np.sum(S[i+1:]=="W")

print(count)    

Fixed submission:
import numpy as np

S = input()
S = list(S)
S = np.array(S)

index_black = np.where(S=="B")[0]
diff = np.array([i for i in range(len(S)-len(index_black),len(S))])
count = int(np.sum(np.abs(diff-index_black)))
print(count)