Buggy python submission (verdict: Runtime Error):
import sys
readline = sys.stdin.readline
N, M = map(int, readline().split())

def check(Edge, Dim):
    N = len(Edge)
    if any(d&1 for d in Dim):
        return 'No'
    if max(Dim) > 4:
        return 'Yes'
    dc4 = Dim.count(4)
    if dc4 <= 1:
        return 'No'
    if dc4 >= 3:
        return 'Yes'
    a = Dim.index(4)
    st = (a+1)%N
    used = set([a, st])
    stack = [st]
    while stack:
        vn = stack.pop()
        for vf in Edge[vn]:
            if vf not in used:
                stack.append(vf)
                used.add(vf)
    if len(used) == N:
        return 'No'
    return 'Yes'
Edge = [[] for _ in range(N)]
Dim = [0]*N

for _ in range(M):
    a, b = map(int, readline().split())
    a -= 1
    b -= 1
    Edge[a].append(b)
    Edge[b].append(a)
    Dim[a] += 1
    Dim[b] += 1

print(check(Edge, Dim))

Fixed submission:
from sys import exit
N = int(input())
B = list(map(int, input().split()))
ctr = 0
ans = []
for _ in range(N):
    ctr = 0
    for i, b in enumerate(B, 1):
        if i == b:
            ctr = i
    ans.append(ctr)
    if ctr == 0:
        print(-1)
        exit()
    B = B[:ctr-1] + B[ctr:]
print('\n'.join([str(s) for s in ans][::-1]))

Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
P = list(map(int, input().split()))
Pmin = [None]*N
Pmax = [None]*N
for i, p in enumerate(P):
    k = 20000
    for pj in P[:i]:
        if pj > p:
            k = min(k, pj)
    Pmin[p-1] = k

for i, p in enumerate(P):
    k = -1
    for pj in P[:i:-1]:
        if pj < p:
            k = max(k, pj)
    Pmax[p-1] = k
dp = [[10**15]*(N+2) for _ in range(N+2)]
dp[1][N] = 0
for k in range(N-1, -1, -1):
    for i in range(1, N - k + 1):
        x = dp[i][i+k]
        if Pmax[i+k-1] + 1 <= i:
            dp[i][i+k-1] = min(dp[i][i+k-1], x)
        else:
            dp[i][i+k-1] = min(dp[i][i+k-1], x+A)
        if Pmin[i-1] - 1 >= i+k:
            dp[i+1][i+k] = min(dp[i+1][i+k], x)
        else:
            dp[i+1][i+k] = min(dp[i+1][i+k], x+B)
print(min([dp[i][i] for i in range(1, N+1)]))

Fixed submission:
from sys import exit
N = int(input())
B = list(map(int, input().split()))
ctr = 0
ans = []
for _ in range(N):
    ctr = 0
    for i, b in enumerate(B, 1):
        if i == b:
            ctr = i
    ans.append(ctr)
    if ctr == 0:
        print(-1)
        exit()
    B = B[:ctr-1] + B[ctr:]
print('\n'.join([str(s) for s in ans][::-1]))

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
Edge = [0] * N
for _ in range(M):
    a, b = map(int, input().split())
    Edge[a - 1] += 1
    Edge[b - 1] += 1
if any([i%2 == 1 for i in Edge]):
    print('No')
elif len([i for i in Edge if i > 4]) > 0:
    print('Yes')
elif len([i for i in Edge if i > 2]) > 1:
    print('Yes')
else:
    print('No')

Fixed submission:
from sys import exit
N = int(input())
B = list(map(int, input().split()))
ctr = 0
ans = []
for _ in range(N):
    ctr = 0
    for i, b in enumerate(B, 1):
        if i == b:
            ctr = i
    ans.append(ctr)
    if ctr == 0:
        print(-1)
        exit()
    B = B[:ctr-1] + B[ctr:]
print('\n'.join([str(s) for s in ans][::-1]))