Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
def inbox(i, n):
    i = max(0, i)
    i = min(i, n)
    return(i)

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    a_new = [0 for _ in range(n)]
    for _ in range(k):
        b = [0 for p in range(n)]
        for i in range(n):
            l = inbox(i - a[i], n)
            r = inbox(i + a[i] + 1, n)
            b[l] += 1
            if r != n:
                b[r] -= 1

        a_new[0] = b[0]
        for i in range(1, n):
            a_new[i] = a_new[i-1] + b[i]
        if a_new == a:
            break
        a = a_new[:]

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


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python
from collections import deque

def main():
    n, m = map(int, input().split())
    rw_lst = [[] for _ in range(n+1)]
    for _ in range(m):
        a, b = map(int, input().split())
        rw_lst[a].append(b)
        rw_lst[b].append(a)

    sign_lst = [-1 for _ in range(n+1)]
    sign_lst[1] = 0
    check_lst = [False for _ in range(n+1)]
    check_lst[1] = True

    queue = deque([1])
    while queue:
        room = queue.popleft()
        for way in rw_lst[room]:
            if not check_lst[way]:
                check_lst[way] = True
                sign_lst[way] = room
                queue.append(way)

    check = True
    for i in range(1, n+1):
        check = check and check_lst[i]

    if check:
        print("Yes")
        for i in range(2, n+1):
            print(sign_lst[i])
    else:
        print("No")


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python

def makesign(room, rw_lst, sign_lst, check_lst):
    check_lst[room] = True
    newways = []
    for way in rw_lst[room]:
        if sign_lst[way] == -1:
            newways.append(way)
            sign_lst[way] = room
    rw_lst[room] = newways

    for way in rw_lst[room]:
        makesign(way, rw_lst, sign_lst, check_lst)

def main():
    n, m = map(int, input().split())
    rw_lst = [[] for _ in range(n+1)]
    for _ in range(m):
        a, b = map(int, input().split())
        rw_lst[a].append(b)
        rw_lst[b].append(a)

    sign_lst = [-1] * (n+1)
    sign_lst[1] = 0
    check_lst = [False for _ in range(n+1)]
    check_lst[0] = True

    makesign(1, rw_lst, sign_lst, check_lst)

    check = True
    for i in range(1, n+1):
        check = check and check_lst[i]

    if check:
        print("Yes")
        for i in range(2, n+1):
            print(sign_lst[i])
    else:
        print("No")


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python
from collections import deque

def main():
    n, m = map(int, input().split())
    rw_lst = [[] for _ in range(n+1)]
    for _ in range(m):
        a, b = map(int, input().split())
        rw_lst[a].append(b)
        rw_lst[b].append(a)

    sign_lst = [-1 for _ in range(n+1)]
    sign_lst[1] = 0
    check_lst = [False for _ in range(n+1)]
    check_lst[1] = True

    queue = deque([1])
    while queue:
        room = queue.popleft()
        for way in rw_lst[room]:
            if not check_lst[way]:
                check_lst[way] = True
                sign_lst[way] = room
                queue.append(way)

    check = True
    for i in range(1, n+1):
        check = check and check_lst[i]

    if check:
        print("Yes")
        for i in range(2, n+1):
            print(sign_lst[i])
    else:
        print("No")


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python

def makesign(room, rw_lst, sign_lst, check_lst):
    check_lst[room] = True
    newways = []
    for way in rw_lst[room]:
        if sign_lst[way] == -1:
            newways.append(way)
            sign_lst[way] = room
    rw_lst[room] = newways

    for way in rw_lst[room]:
        makesign(way, rw_lst, sign_lst, check_lst)

def main():
    n, m = map(int, input().split())
    rw_lst = [[] for _ in range(n+1)]
    for _ in range(m):
        a, b = map(int, input().split())
        rw_lst[a].append(b)
        rw_lst[b].append(a)

    print(rw_lst)

    sign_lst = [-1] * (n+1)
    sign_lst[1] = 0
    check_lst = [False for _ in range(n+1)]
    check_lst[0] = True

    makesign(1, rw_lst, sign_lst, check_lst)

    check = True
    for i in range(1, n+1):
        check = check and check_lst[i]

    if check:
        print("Yes")
        for i in range(2, n+1):
    else:
        print("No")


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python
from collections import deque

def main():
    n, m = map(int, input().split())
    rw_lst = [[] for _ in range(n+1)]
    for _ in range(m):
        a, b = map(int, input().split())
        rw_lst[a].append(b)
        rw_lst[b].append(a)

    sign_lst = [-1 for _ in range(n+1)]
    sign_lst[1] = 0
    check_lst = [False for _ in range(n+1)]
    check_lst[1] = True

    queue = deque([1])
    while queue:
        room = queue.popleft()
        for way in rw_lst[room]:
            if not check_lst[way]:
                check_lst[way] = True
                sign_lst[way] = room
                queue.append(way)

    check = True
    for i in range(1, n+1):
        check = check and check_lst[i]

    if check:
        print("Yes")
        for i in range(2, n+1):
            print(sign_lst[i])
    else:
        print("No")


if __name__ == '__main__':
    main()