Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(4100000)
def input():
    return sys.stdin.readline().rstrip()

N = int(input())
a = list(map(int, input().split()))
b = []
for i in range(N, 0, -1):
  s = a[i - 1]
  if i * 2 <= N:
    s += sum([1 for k in range(2, N // i + 1) if i * k in b])
  if s % 2 == 1:
  	b.append(i)
print(len(b))
print(*b)


Fixed submission:
N = int(input())
a = list(map(int, input().split()))
b = []
arr = [-1] * N
for i in range(N, 0, -1):
  s = 0
  j = i * 2
  while j <= N:
    s += arr[j - 1]
    j += i
  if s % 2 != a[i - 1]:
    arr[i - 1] = 1
    b.append(i)
  else:
    arr[i - 1] = 0
print(len(b))
print(*b)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(4100000)

N = int(input())
a = list(map(int, input().split()))
b = []
for i in range(N, 0, -1):
  s = a[i - 1]
  if i * 2 <= N:
    s += sum([1 for k in range(2, N // i + 1) if i * k in b])
  if s % 2 == 1:
  	b.append(i)
print(len(b))
print(*b)


Fixed submission:
N = int(input())
a = list(map(int, input().split()))
b = []
arr = [-1] * N
for i in range(N, 0, -1):
  s = 0
  j = i * 2
  while j <= N:
    s += arr[j - 1]
    j += i
  if s % 2 != a[i - 1]:
    arr[i - 1] = 1
    b.append(i)
  else:
    arr[i - 1] = 0
print(len(b))
print(*b)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(4100000)

N = int(input())
a = list(map(int, input().split()))
b = []
if N > 10 ** 5:
  for i in range(N, 10 ** 5, -1):
    if a[i - 1] == 1:
      b.append(i)
for i in range(min(10 ** 5, N), 0, -1):
  j = i * 2
  s = a[i - 1]
  while j <= N:
    if j in b:
      s += 1
    j += i
  if s % 2 == 1:
  	b.append(i)
print(len(b))
print(*b)


Fixed submission:
N = int(input())
a = list(map(int, input().split()))
b = []
arr = [-1] * N
for i in range(N, 0, -1):
  s = 0
  j = i * 2
  while j <= N:
    s += arr[j - 1]
    j += i
  if s % 2 != a[i - 1]:
    arr[i - 1] = 1
    b.append(i)
  else:
    arr[i - 1] = 0
print(len(b))
print(*b)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(4100000)

N = int(input())
a = list(map(int, input().split()))
b = []
if N > 10 ** 5:
  for i in range(N, 10 ** 5, -1):
    if a[i - 1] == 1:
      b.append(i)
for i in range(min(10 ** 5, N), 0, -1):
  j = i * 2
  s = a[i - 1]
  while j <= N:
    if j in b:
      s += 1
    j += i
  if s % 2 == 1:
  	b.append(i)
print(len(b))
print(*b)


Fixed submission:
N = int(input())
a = list(map(int, input().split()))
b = []
arr = [-1] * N
for i in range(N, 0, -1):
  s = 0
  j = i * 2
  while j <= N:
    s += arr[j - 1]
    j += i
  if s % 2 != a[i - 1]:
    arr[i - 1] = 1
    b.append(i)
  else:
    arr[i - 1] = 0
print(len(b))
print(*b)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
b = []
if N > 10 ** 5:
  for i in range(N, 10 ** 5, -1):
    if a[i - 1] == 1:
      b.append(i)
for i in range(min(10 ** 5, N), 0, -1):
  j = i * 2
  s = a[i - 1]
  while j <= N:
    if j in b:
      s += 1
    j += i
  if s % 2 == 1:
  	b.append(i)
print(len(b))
b = list(map(str, b))
print(" ".join(b))


Fixed submission:
N = int(input())
a = list(map(int, input().split()))
b = []
arr = [-1] * N
for i in range(N, 0, -1):
  s = 0
  j = i * 2
  while j <= N:
    s += arr[j - 1]
    j += i
  if s % 2 != a[i - 1]:
    arr[i - 1] = 1
    b.append(i)
  else:
    arr[i - 1] = 0
print(len(b))
print(*b)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
b = []
for i in range(N, 0, -1):
  j = i * 2
  s = a[i - 1]
  while j <= N:
    if j in b:
      s += 1
    j += i
  if s % 2 == 1:
  	b.append(i)
print(len(b))
b = list(map(str, b))
print(" ".join(b))


Fixed submission:
N = int(input())
a = list(map(int, input().split()))
b = []
arr = [-1] * N
for i in range(N, 0, -1):
  s = 0
  j = i * 2
  while j <= N:
    s += arr[j - 1]
    j += i
  if s % 2 != a[i - 1]:
    arr[i - 1] = 1
    b.append(i)
  else:
    arr[i - 1] = 0
print(len(b))
print(*b)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
b = []
for i in range(N, 0, -1):
  j = i * 2
  s = a[i - 1]
  while j <= N:
    if j in b:
      s += 1
    j += i
  if s % 2 == 1:
  	b.append(i)
print(len(b))
b = list(map(str, b))
print(" ".join(b))


Fixed submission:
N = int(input())
a = list(map(int, input().split()))
b = []
arr = [-1] * N
for i in range(N, 0, -1):
  s = 0
  j = i * 2
  while j <= N:
    s += arr[j - 1]
    j += i
  if s % 2 != a[i - 1]:
    arr[i - 1] = 1
    b.append(i)
  else:
    arr[i - 1] = 0
print(len(b))
print(*b)