Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    A = list(map(int, input().split()))
    B = [0] * n
    ans = []
    for i, a in enumerate(A[::-1]):
        i = n - i
        b = sum(B[i - 1::i])
        if b % 2 != a:
            ans.append(str(i))
            B[i] = 1
    print(len(ans))
    print(' '.join(ans))

if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    A = list(map(int, input().split()))
    B = [0] * n
    ans = []
    for i, a in enumerate(A[::-1]):
        i = n - i
        b = sum(B[i - 1::i])
        if b % 2 != a:
            ans.append(str(i))
            B[i - 1] = 1
    print(len(ans))
    print(' '.join(ans))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    A = list(map(int, input().split()))
    B = [0] * n
    ans = []
    for i, a in enumerate(A[::-1]):
        i = n - i
        b = sum(B[i::i])
        if b % 2 != a:
            ans.append(str(i))
            B[i] = 1
    print(len(ans))
    print(' '.join(ans))

if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    A = list(map(int, input().split()))
    B = [0] * n
    ans = []
    for i, a in enumerate(A[::-1]):
        i = n - i
        b = sum(B[i - 1::i])
        if b % 2 != a:
            ans.append(str(i))
            B[i - 1] = 1
    print(len(ans))
    print(' '.join(ans))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
def main():
    def add_divisors(n, d):
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                d[i] += 1
                if i != n // i:
                    d[n // i] += 1
    n = int(input())
    A = list(map(int, input().split()))
    d = defaultdict(int)
    ans = []
    for i, a in enumerate(A[::-1]):
        i = n - i
        if d[i] % 2 != a:
            ans.append(str(i))
            add_divisors(i, d)
    print(len(ans))
    print(' '.join(ans))

if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    A = list(map(int, input().split()))
    B = [0] * n
    ans = []
    for i, a in enumerate(A[::-1]):
        i = n - i
        b = sum(B[i - 1::i])
        if b % 2 != a:
            ans.append(str(i))
            B[i - 1] = 1
    print(len(ans))
    print(' '.join(ans))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    def add_divisors(n, d):
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                d[i] += 1
                if i != n // i:
                    d[n // i] += 1
    n = int(input())
    A = list(map(int, input().split()))
    d = {}
    ans = []
    for i in range(1, n + 1):
        d[i] = 0
    for i, a in enumerate(A[::-1]):
        i = n - i
        if d[i] % 2 != a:
            ans.append(str(i))
            add_divisors(i, d)
    print(len(ans))
    print(' '.join(ans))

if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    A = list(map(int, input().split()))
    B = [0] * n
    ans = []
    for i, a in enumerate(A[::-1]):
        i = n - i
        b = sum(B[i - 1::i])
        if b % 2 != a:
            ans.append(str(i))
            B[i - 1] = 1
    print(len(ans))
    print(' '.join(ans))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    def make_divisors(n):
        divisors = []
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n//i)
        return divisors
    n = int(input())
    A = list(map(int, input().split()))
    d = {}
    ans = []
    for i in range(1, n + 1):
        d[i] = 0
    for i, a in enumerate(A[::-1]):
        i = n - i
        if d[i] % 2 != a:
            ans.append(str(i))
            for divisor in make_divisors(i):
                d[divisor] += 1
    print(len(ans))
    print(' '.join(ans))

if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    A = list(map(int, input().split()))
    B = [0] * n
    ans = []
    for i, a in enumerate(A[::-1]):
        i = n - i
        b = sum(B[i - 1::i])
        if b % 2 != a:
            ans.append(str(i))
            B[i - 1] = 1
    print(len(ans))
    print(' '.join(ans))

if __name__ == '__main__':
    main()