Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
N = int(input())
arr = list(map(int, input().split()))
puts = []
dd = defaultdict(int)
 
def make_divisors(n):
    divisors = []
    # Nの最大の約数は√N
    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)
    # divisors.sort()
    return divisors
 
for i in range(1,N+1)[::-1]:
    if N//2 < i and arr[i-1] == 1:
        puts.append(i)
        ds = make_divisors(i)
        for j in ds:
            dd[j] += 1
    else:
        # c = len([p for p in puts if p % i == 0])
        c = dd[i]
        if (c % 2 == 0 and arr[i-1] == 1) or (c % 2 == 1 and arr[i-1] == 0):
            puts.append(i)
            ds = make_divisors(i)
            for j in ds:
                dd[j] += 1
 
print(len(puts))
if len(puts):
    print(" ".join(map(str, sorted(puts, reverse=True))))

Fixed submission:
from collections import defaultdict
N = int(input())
arr = list(map(int, input().split()))
puts = []
dd = defaultdict(int)

def make_divisors(n):
    divisors = []
    # Nの最大の約数は√N
    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)
    # divisors.sort()
    return divisors

for i in range(1,N+1)[::-1]:
    if N//2 < i and arr[i-1] == 1:
        puts.append(i)
        ds = make_divisors(i)
        for j in ds:
            dd[j] += 1
    else:
        # c = len([p for p in puts if p % i == 0])
        c = dd[i]
        if (c % 2 == 0 and arr[i-1] == 1) or (c % 2 == 1 and arr[i-1] == 0):
            puts.append(i)
            ds = make_divisors(i)
            for j in ds:
                dd[j] += 1

print(len(puts))
if len(puts):
    print(" ".join(map(str, sorted(puts, reverse=True))))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
arr = list(map(int, input().split()))
puts = []

for i in range(1,N+1)[::-1]:
    if N//2 < i and arr[i-1] == 1:
        puts.append(i)
    else:
        c = len([p for p in puts if p % i == 0])
        if (c % 2 == 0 and arr[i-1] == 1) or (c % 2 == 1 and arr[i-1] == 0):
            puts.append(i)

print(len(puts))
if len(puts):
    print(" ".join(map(str, sorted(puts, reverse=True))))


Fixed submission:
from collections import defaultdict
N = int(input())
arr = list(map(int, input().split()))
puts = []
dd = defaultdict(int)

def make_divisors(n):
    divisors = []
    # Nの最大の約数は√N
    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)
    # divisors.sort()
    return divisors

for i in range(1,N+1)[::-1]:
    if N//2 < i and arr[i-1] == 1:
        puts.append(i)
        ds = make_divisors(i)
        for j in ds:
            dd[j] += 1
    else:
        # c = len([p for p in puts if p % i == 0])
        c = dd[i]
        if (c % 2 == 0 and arr[i-1] == 1) or (c % 2 == 1 and arr[i-1] == 0):
            puts.append(i)
            ds = make_divisors(i)
            for j in ds:
                dd[j] += 1

print(len(puts))
if len(puts):
    print(" ".join(map(str, sorted(puts, reverse=True))))