Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
li=list(map(int,input().split()))

ans=[]
for i in range(n-1,n//2-1,-1):
  if li[i]==1:
    ans.append(i+1)

for i in range(n//2,0,-1):
  count=0
  for j in ans:
    if j%i==0:
      count+=1
  if count%2!=li[i-1]:
    ans.append(i)
ans.reverse()
print(len(ans))
L=[str(a) for a in ans]
L=" ".join(L)
if len(L)!=0:
  print(L)

Fixed submission:
n=int(input())
li=list(map(int,input().split()))

ans=[]
li2=[0 for _ in range(n)]
for i in range(n,0,-1):
  count=0
  for j in range(i*2,n+1,i):
    if li2[j-1]==1:
      count+=1
  if count%2!=li[i-1]:
    li2[i-1]=1
    ans.append(i)

ans.reverse()
print(len(ans))
L=[str(a) for a in ans]
L=" ".join(L)
if len(L)!=0:
  print(L)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
li=list(map(int,input().split()))

ans=[]
for i in range(n-1,n//2-1,-1):
  if li[i]==1:
    ans.append(i+1)

for i in range(n//2,0,-1):
  count=0
  for j in ans:
    if j%i==0:
      count+=1
  count+=li[i-1]
  if count%2==1:
    ans.append(i)
ans.reverse()
print(len(ans))
L=[str(a) for a in ans]
L=" ".join(L)
if len(L)!=0:
  print(L)

Fixed submission:
n=int(input())
li=list(map(int,input().split()))

ans=[]
li2=[0 for _ in range(n)]
for i in range(n,0,-1):
  count=0
  for j in range(i*2,n+1,i):
    if li2[j-1]==1:
      count+=1
  if count%2!=li[i-1]:
    li2[i-1]=1
    ans.append(i)

ans.reverse()
print(len(ans))
L=[str(a) for a in ans]
L=" ".join(L)
if len(L)!=0:
  print(L)

Buggy python submission (verdict: Runtime Error):
n=int(input())
li=list(map(int,input().split()))

ans=[]
for i in range(n,n//2,-1):
  if li[i]==1:
    ans.append(i+1)

for i in range(n//2,0,-1):
  count=0
  for j in ans:
    if j%i==0:
      count+=1
  count+=li[i-1]
  if count%2==1:
    ans.append(i)
ans.reverse()
print(len(ans))
L=[str(a) for a in ans]
L=" ".join(L)
if len(L)!=0:
  print(L)

Fixed submission:
n=int(input())
li=list(map(int,input().split()))

ans=[]
li2=[0 for _ in range(n)]
for i in range(n,0,-1):
  count=0
  for j in range(i*2,n+1,i):
    if li2[j-1]==1:
      count+=1
  if count%2!=li[i-1]:
    li2[i-1]=1
    ans.append(i)

ans.reverse()
print(len(ans))
L=[str(a) for a in ans]
L=" ".join(L)
if len(L)!=0:
  print(L)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
li=list(map(int,input().split()))

ans=[]
for i in range(n//2,n):
  if li[i]==1:
    ans.append(i+1)
ans.reverse()
for i in range(n//2,0,-1):
  count=0
  for j in ans:
    if j%i==0:
      count+=1
  count+=li[i-1]
  if count%2==1:
    ans.append(i)
ans.reverse()
print(len(ans))
L=[str(a) for a in ans]
L=" ".join(L)
if len(L)!=0:
  print(L)

Fixed submission:
n=int(input())
li=list(map(int,input().split()))

ans=[]
li2=[0 for _ in range(n)]
for i in range(n,0,-1):
  count=0
  for j in range(i*2,n+1,i):
    if li2[j-1]==1:
      count+=1
  if count%2!=li[i-1]:
    li2[i-1]=1
    ans.append(i)

ans.reverse()
print(len(ans))
L=[str(a) for a in ans]
L=" ".join(L)
if len(L)!=0:
  print(L)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
li=list(map(int,input().split()))

ans=[]
for i in range(n//2,n):
  if li[i]==1:
    ans.append(i+1)
ans.reverse()
for i in range(n//2,0,-1):
  count=0
  for j in ans:
    if j%i==0:
      count+=1
  count+=li[i-1]
  if count%2==1:
    ans.append(i)
ans.reverse()
print(len(ans))
L=[str(a) for a in ans]
L=" ".join(L)
if len(L)!=0:
  print(L)

Fixed submission:
n=int(input())
li=list(map(int,input().split()))

ans=[]
li2=[0 for _ in range(n)]
for i in range(n,0,-1):
  count=0
  for j in range(i*2,n+1,i):
    if li2[j-1]==1:
      count+=1
  if count%2!=li[i-1]:
    li2[i-1]=1
    ans.append(i)

ans.reverse()
print(len(ans))
L=[str(a) for a in ans]
L=" ".join(L)
if len(L)!=0:
  print(L)