Problem:
 Score : 400 points    Problem Statement There are N empty boxes arranged in a row from left to right.
The integer i is written on the i -th box from the left (1 \leq i \leq N) .  For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.  We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied:   For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2 .   Does there exist a good set of choices? If the answer is yes, find one good set of choices.      Constraints  All values in input are integers.  1 \leq N \leq 2 \times 10^5  a_i is 0 or 1 .         Input Input is given from Standard Input in the following format:  N  a_1  a_2  ...  a_N       Output If a good set of choices does not exist, print -1 .  If a good set of choices exists, print one such set of choices in the following format:  M  b_1  b_2  ...  b_M   where M denotes the number of boxes that will contain a ball, and b_1,\ b_2,\ ...,\ b_M are the integers written on these boxes, in any order.        Sample Input 1 3
1 0 0      Sample Output 1 1
1  Consider putting a ball only in the box with 1 written on it.   There are three boxes with multiples of 1 written on them: the boxes with 1 , 2 , and 3 . The total number of balls contained in these boxes is 1 .  There is only one box with a multiple of 2 written on it: the box with 2 . The total number of balls contained in these boxes is 0 .  There is only one box with a multiple of 3 written on it: the box with 3 . The total number of balls contained in these boxes is 0 .   Thus, the condition is satisfied, so this set of choices is good.       Sample Input 2 5
0 0 0 0 0      Sample Output 2 0  Putting nothing in the boxes can be a good set of choices.

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

b = [0]*n
for i in range(n)[::-1]:
    tmp = 0
    for j in range(n//(i+1)):
        tmp += b[(i+1)*(j+1)-1]
    if tmp%2 != a[i]:
        b[i] += 1

print(sum(b))
ans = [i+1 for i in range(n) if b[i]]
print(*ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

ans = [0] * n
for i in range(n-1, -1, -1):
    cnt = 0
    for j in range(i, n, i+1):
        cnt += ans[j]
    if cnt % 2 != a[i]:
        ans[i] = 1

print(sum(ans))
print(' '.join(str(i+1) for i in range(n) if ans[i]))

Solution (Python):
def main():
    N=int(input())
    a=list(map(int,input().split()))
    table=[0]*N
    result=0
    result_li=[]
    for i in range(N):
        i=N-i
        count=0
        for j in range(i,N+1,i):
            count+=table[j-1]
        if count%2==a[i-1]:
            pass
        else:
            table[i-1]=1
            result+=1
    for i in range(N):
        if table[i]==1:
            result_li.append(i+1)
    print(result)
    if len(result_li)>=1:
        print(" ".join(map(str,result_li)))

if __name__=="__main__":
    main()

Solution (Python):
n=int(input())
A=list(map(int,input().split()))

B=[0]*(n+1)
C,cnt=[],0
for i in range(1,n+1)[::-1]:
    sum_list=sum([B[j] for j in range(i,n+1,i)])
    if sum_list%2!=A[i-1]:
        B[i]=1
        cnt +=1
        C.append(i)

print(cnt)
print(*C[::-1])

Solution (Python):
from sys import stdin

N = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
A = [0] + a
B = [0]*(N+1)
putBall = []

for i in range(N, 0, -1):
    if sum(B[i::i])%2 != A[i]:
        B[i] = 1
        putBall.append("%d" % i)

print(sum(B))
print(*putBall)

Solution (Python):
from sys import stdin

N = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
A = [0] + a
B = [0]*(N+1)
putBall = []

for i in range(N, 0, -1):
    cnt = 1
    multiple = i
    tmp = 0
    if sum(B[i::i])%2 != A[i]:
        B[i] = 1
        putBall.append("%d" % i)

print(sum(B))
print(*putBall)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ans = [0] * n

i = n-1
while i >= 0:
    cnt = 0
    for j in range(1, n+1):
        if (i+1) * j - 1  >= n:
            break
        cnt += ans[(i+1)*j-1]
    if cnt % 2 != a[i]:
        ans[i] = 1
    i -= 1
    
print(ans.count(1))
for i in range(n):
    if ans[i] == 1:
        print(i+1)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ans = [0] * (n+1)

i = n
while i > 0:
    cnt = 0
    for j in range(1, n+1):
        if i * j  > n:
            break
        cnt += ans[i*j]
    if cnt % 2 != a[i-1]:
        ans[i] = 1
    i -= 1
    
print(ans.count(1))
for i in range(1,n+1):
    if ans[i] == 1:
        print(i)

Solution (Python):
N = int(input())
Bn =  list(map(int,input().split(' ')))

output_list = []

for i in reversed(range(N)):
    current_sum = 0
    target_num = i+1
    target_num_idx = 0
    for j in range((N)//(target_num)):
        target_num_idx = target_num_idx + target_num
        current_sum += Bn[target_num_idx -1]
    if current_sum % 2 != Bn[i]:
        if Bn[i] == 1:
            Bn[i] = 0
        else:
            Bn[i] = 1
    if Bn[i] == 1:
        output_list.append(target_num)
print(len(output_list))
output_list.reverse()
print(' '.join(map(str,output_list)))

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(n-1,-1,-1):
  b[i]=(a[i]+sum(b[i::i+1]))%2
l=[x+1 for x,y in enumerate(b) if y==1]
print(len(l))
print(*l)

Solution (Python):






import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


N = read_a_int()
A = [0] + read_ints()

B = [0] * (N + 1)
B[(N // 2) + 1:] = A[(N // 2) + 1:]


for i in range(N // 2, 0, -1):
    a = A[i]
    j = i + i
    while j < N + 1:
        a -= B[j]
        j += i
    B[i] = a % 2



print(sum(B))
for i, b in enumerate(B):
    if b:
        print(i, end=' ')

Solution (Python):






n=int(input())
a=list(map(int,input().split()))
h=n//2

b=[-1]*h+a[h:]
for i in range(h,-1,-1):
  
  jsum=0
  for j in range((i+1)*2-1,len(b),i+1):
    jsum^=b[j]
  b[i]=a[i]^jsum

print(sum(b))
for i in range(n):
  if b[i]:
    print(i+1)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

balls = [0] * n

def get_b(num):
    cnt=0
    now=num
    while True:
        cnt+=balls[now-1]
        now+=num
        if now > n:
            break
    return cnt

for i in range(n,0,-1):
    now_cnt=get_b(i)
    if now_cnt%2 != a[i-1]:
        balls[i-1]=1

print(sum(balls))

for i in range(n):
    if balls[i] != 0:
        print(i+1,end=" ")

Solution (Python):

import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True

    @staticmethod
    def divisor(n):
        i = 1
        table = []
        while i * i <= n:
            if n % i == 0:
                table.append(i)
                table.append(n // i)
            i += 1
        table = list(set(table))
        return table


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)

    def list(self):
        return self.__q

    def length(self):
        return len(self.__q)


sys.setrecursionlimit(1000000)
MOD = int(1e09) + 7
INF = int(1e30)


def main():
    
    N = Scanner.int()
    A = Scanner.map_int()
    B = [0] * N
    for i in reversed(range(1, N+1)):
        now = 0
        j = i
        while j <= N:
            if B[j - 1] == 1:
                now += 1
            j += i
        if now % 2 != A[i - 1]:
            B[i - 1] = 1
    print(B.count(1))
    for i in range(N):
        if B[i] == 1:
            print(i + 1)

    return


if __name__ == "__main__":
    main()

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
ans=[0 for i in range(0,N)]
for i in range(0,N):
    ans[N-1-i]=(A[N-1-i]-sum(ans[k*(N-i)-1] for k in range(1,N//(N-i)+1)))%2
print(sum(ans))
data=[i+1 for i in range(0,N) if ans[i]==1]
print(*data)

Solution (Python):
N = int(input())
a = [0] + list(map(int, input().split()))
b = set([i for i in range(N//2 + 1, N + 1) if a[i] == 1])

for i in range(N//2, 0, -1):
    if sum([1 for k in range(2, N//i + 1) if k*i in b]) % 2 != a[i]:
        b.add(i)

if len(b) > 0:
    print(len(b))
    print(' '.join(list(map(str, sorted(list(b))))))
else:
    print(0)

Solution (Python):
N = int(input())
a = [0] + list(map(int, input().split()))
b = set([i for i in range(N//2 + 1, N + 1) if a[i] == 1])

for i in range(N//2, 0, -1):
    k, temp = 2, 0
    while k * i < N + 1:
        if k * i in b:
            temp += 1
        k += 1
    if temp % 2 != a[i]:
        b.add(i)

if len(b) > 0:
    print(len(b))
    print(' '.join(list(map(str, sorted(list(b))))))
else:
    print(0)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
d=[0]*n
for i in range(n):
  c=n-i
  t=0
  sum_d=sum(d[x] for x in range(c-1,n,c))
  if sum_d%2 != a[c-1]:
    d[c-1]=1

print(sum(d))
b=[]
if sum(d):
  for i in range(n):
    if d[i]>0:
      b.append(i+1)
  print(*b)

Solution (Python):
N = int(input())
A = tuple(map(int, input().split()))
lst = [0] * (N + 1)
ans = set()
for i in range(N, 0, -1):
    tmp = (sum(lst[i::i]) % 2 + A[i - 1]) % 2
    if tmp:
        ans.add(i)
    lst[i] = tmp
print(len(ans))
print(*ans)

Solution (Python):
n = int(input())
arr = list(map(int, input().split()))
flag = [-1] * n
ans = []

for i in range(n-1, -1, -1):
    cnt = 0
    for j in range(i, n, i + 1):
        if j == i:
            continue
        else:
            if flag[j] == 1:
                cnt += 1
    if (arr[i]+cnt) % 2 == 0:
        flag[i] = 0
    else:
        flag[i] = 1
        ans.append(i + 1)
num = len(ans)
if num == 0:
    print(0)
else:
    print(num)
    print(*ans)

Solution (Python):
N=int(input())
a=list(map(int,input().split()))

res=[0]*(N+1)
for i in range(1,N+1)[::-1]:
    sum_res=sum(res[x] for x in range(i,N+1,i))
    if sum_res % 2!=a[i-1]:
        res[i] = 1

print(sum(res))

if sum(res):
    ans=[]
    for i,ele in enumerate(res):
        if ele:
            ans.append(i)
    print(*ans)

Solution (Python):
import sys

n, *a = map(int, sys.stdin.read().split())
a = [None] + a

def main():
    res = [0] * (n + 1)
    chosen = []
    for i in range(n, 0, -1):
        tmp = sum(res[i*2:n+1:i]) & 1
        if tmp ^ a[i]:
            res[i] = 1
            chosen.append(i)

    if chosen:
        m = len(chosen)
        return [m], chosen[::-1]
    else:
        return [[0]]

if __name__ == '__main__':
    ans = main()
    for a in ans:
        print(*a, sep=' ')

Solution (Python):
n=int(input())
a=[-1]+list(map(int,input().split()))

t=((n+1)+2-1)//2

ans=[-1]+[0 for i in range(n)]
ans[t:]=a[t:]

for i in range(t-1,0,-1):
 t_sum=sum(ans[i+i::i])
 if a[i]%2==t_sum%2:
  ans[i]=0
 else:
  ans[i]=1

m=ans.count(1)
ans_l=[]
for i in range(n+1):
 if ans[i]==1:
  ans_l.append(i)
print(m)
if ans_l:
 print(*ans_l)

Solution (Python):
n=int(input())
a=[-1]+list(map(int,input().split()))

t=((n+1)+2-1)//2

ans=[-1]+[0 for i in range(n)]
ans[t:]=a[t:]




for i in range(t-1,0,-1):
 t_sum=sum(ans[i+i::i])

 if a[i]%2==t_sum%2:
  ans[i]=0
 else:
  ans[i]=1



m=ans.count(1)
ans_l=[]
for i in range(n+1):
 if ans[i]==1:
  ans_l.append(i)
print(m)
if ans_l:
 print(*ans_l)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

d = [0]*(int(n/2)) + a[int(n/2):]

for i in range(int(n/2), 0, -1):
    i_sum = sum(d[i-1::i])
    if a[i-1] == 1 and i_sum%2 == 0:
        d[i-1] = 1
    elif a[i-1] == 0 and i_sum%2 == 1:
        d[i-1] = 1

m = d.count(1)
print(m)
if m != 0:
    print(*[i+1 for i in range(n) if d[i] == 1])

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
B=[0]*N
ret = []
for i in range(N, 0, -1):
  if (sum(B[i-1::i])%2) != A[i-1]:
    B[i-1]= 1
    ret.append(i)
print(sum(B))
print(*ret)

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 6)


def input():
    return sys.stdin.readline()[:-1]


def main():
    N = int(input())
    a = [-1]+list(map(int, input().split()))
    b = [0] * (N+1)
    for i in reversed(range(1,N+1)):
        total = 0
        for j in range(i,N+1,i):
            total += b[j]
        if a[i] != (total%2):
            b[i] = 1
    ans = []
    cnt = 0
    for i, n in enumerate(b):
        if n!=0:
            ans.append(i)
            cnt += 1
    print(cnt)
    print(*ans)

if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
num=[0]+[int(i)  for i in input().split()]

ans=[]
for i in range(n,0,-1):
  cnt,j=0,2
  while i*j<=n:
    cnt+=num[i*j]
    j+=1
  if cnt%2==num[i]:
    num[i]=0
  else:
    num[i]=1
    ans.append(i)
print(len(ans))
print(*ans)

Solution (Python):
import sys
n = int(input())
a = list(map(int, input().split()))
ans = [0] * (n+1)
ans_index = set([])
for i in reversed(range(1, n + 1)):
    sum_i = sum(ans[i * 2:n + 1:i])
    if a[i-1] == (sum_i + 1) % 2:
        ans[i] = 1
        ans_index.add(i)
    elif a[i-1] == sum_i % 2:
        ans[i] = 0
    else:
        print(-1)
        sys.exit()
print(sum(ans))
if ans_index:
    print(*ans_index)

Solution (Python):
import sys
input = sys.stdin.readline

def sumN(n,N,f):
	total = 0
	i = n
	while i < N:
		total += f[i]
		i += n+1

	if total % 2:
		return 1
	else:
		return 0

def main():
	N = int(input())
	a = list(map(int,input().split()))
	ball = []
	ballNum = 0
	f = [0]*N

	for i in reversed(range(0,N)):
		if (sum(f[i::i+1])%2) != (a[i] % 2):
			f[i] = 1
			ball.append(i+1)
			ballNum +=1

	if (sum(f) % 2) != (a[0] % 2):
		f[0] = 1
		ball.append(1)
		ballNum +=1

	print(ballNum)
	print(*ball)

if __name__ == "__main__":
	main()

Solution (Python):
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = list(map(int,input().split()))
    A.insert(0,0)

    B = [[] for i in range(N+1)]
    B[0] = 0

    for i in range(N, 0, -1):
        if 2*i > N:
            B[i] = A[i]
        else:
            B[i] = (A[i]+sum(B[i*2::(i-1)+1]))%2

    print(sum(B))
    for i in range(1, N+1,1):
        if B[i] == 1:
            print(i, end =" ")


if __name__ == "__main__":
    main()

Solution (Python):
import sys
input = sys.stdin.readline

def sumN(n,N,f):
	total = 0
	i = n
	while i < N:
		total += f[i]
		i += n+1

	if total % 2:
		return 1
	else:
		return 0

def main():
	N = int(input())
	a = list(map(int,input().split()))
	ball = []
	ballNum = 0
	f = [0]*N

	for i in reversed(range(1,N)):
		if sumN(i,N,f) != (a[i] % 2):
			f[i] = 1
			ball.append(i+1)
			ballNum +=1

	if (sum(f) % 2) != (a[0] % 2):
		f[0] = 1
		ball.append(1)
		ballNum +=1

	print(ballNum)
	print(*ball)

if __name__ == "__main__":
	main()

Solution (Python):
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = list(map(int,input().split()))
    A.insert(0,0)

    B = [[] for i in range(N+1)]
    B[0] = 0

    for i in range(N, 0, -1):
        if 2*i > N:
            B[i] = A[i]
        else:
            B[i] = (A[i]+sum(B[i*2::i]))%2

    print(sum(B))
    for i in range(1, N+1,1):
        if B[i] == 1:
            print(i, end =" ")


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
*b, = map(int, input().split())
ans = []

for i in range(N)[::-1]:
    n = i+1
    if b[i]:
        ans.append(n)
        for j in range(1, int(n**0.5)+1):
            if n%j==0:
                b[j-1] ^= 1
                if j!=n//j:
                    b[n//j-1] ^= 1

M = len(ans)
print(M)
if ans:
    print(*ans)

Solution (Python):
N = int(input())
*b, = map(int, input().split())
ans = []

for i in range(N)[::-1]:
    n = i+1
    if b[i]:
        ans.append(n)
        
        tmp = 1
        while tmp*tmp <= n:
            if n % tmp == 0:
                b[tmp-1] ^= 1
                if tmp != n//tmp:
                    b[n//tmp-1] ^= 1
            tmp += 1

M = len(ans)
print(M)
if ans:
    print(*ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
b = [None]*n
for i in range(n, 0, -1):
    s = 0
    for j in range(2*i, n+1, i):
        s += b[j-1]
    b[i-1] = a[i-1]^(s%2)
print(sum(b))
print(*[ind+1 for ind, i in enumerate(b) if i])

Solution (Python):

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()))

cnt_list = [0] * N
M = 0
ans_list = []
for i in range(N-1, -1, -1):
    if A[i] == 1 and cnt_list[i] % 2 == 0:
        M += 1
        ans_list.append(i+1)
        tmp_list = make_divisors(i+1)
        for t in tmp_list:
            cnt_list[t-1] += 1
    elif A[i] == 1 and cnt_list[i] % 2 == 1:
        pass
    elif A[i] == 0 and cnt_list[i] % 2 == 0:
        pass
    else:
        M += 1
        ans_list.append(i+1)
        tmp_list = make_divisors(i+1)
        for t in tmp_list:
            cnt_list[t-1] += 1
print(M)
if M == 0:
    exit()
print(" ".join(map(str, ans_list)))

Solution (Python):
import math,itertools,fractions,heapq,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  ans=[0]*n

  ind=n
  for i in range(n):
    sm=0
    for j in range(2,n+1):
      if ind*j>n:
        break
      else:
        sm+=ans[ind*j-1]
    ans[ind-1]=(l[ind-1]+sm)%2
    ind-=1
    

  

  _ans=[]
  for i,x in enumerate(ans):
    if x==1:
      _ans.append(i+1)

  ln=len(_ans)
  print(ln)
  if ln!=0:
    print(' '.join([str(x) for x in _ans]))

main()

Solution (Python):
import unittest
from io import StringIO
import sys


def resolve():
    input = sys.stdin.readline
    N = int(input())
    
    
    A = list(map(int, input().split()))

    
    
    
    
    
    

    isBalls = [0] * (N + 1)
    for k in reversed(range(1, N + 1)):
        num = sum([isBalls[k * i] for i in range(1, N // k + 1)])
        if num % 2 != A[k - 1]:
            isBalls[k] = 1

    M = sum(isBalls)
    ans = [i for i in range(1, N + 1) if isBalls[i] > 0]

    print(M)
    if ans:
        print(' '.join(map(str, ans)))

resolve()

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
box = [0]*(n+1)
def c(lst,x):
  ans = 0
  now = x
  while now <= n:
    ans += lst[now]
    now += x
  return ans

for i in range(n,0,-1):
  if c(box,i)%2 != a[i-1]:
    box[i] = 1
print(sum(box))
for i in range(1,n+1):
  if box[i] == 1:
    print(i,end=" ")

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
b = [0]*n
bon = []
for i in range(n):
  ri = n - i - 1
  if sum(b[ri::ri+1]) % 2 != a[ri]:
    b[ri] = 1
    bon.append(ri+1)
print(len(bon))
print(*bon)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a.insert(0, 0)
b = [0] * N
M = 0
for i in range(N, 0, -1):
    ball = 0
    for j in range(i + i, N + 1, i):
        ball ^= b[j - 1]
    b[i - 1] = ball ^ a[i]
M = sum(b)
print(M)
for i in range(N):
    if b[i]:
        print(i + 1, end = ' ')

Solution (Python):
def main():
    N = int(input())
    A = [0] + list(map(int, input().split()))
    B = [0] * (N + 1)
    for i in range(N,0,-1):
        B[i] = A[i]
        j = 2
        while i * j < (N + 1):
            B[i] ^= B[i * j]
            j += 1

    ans = []
    for i in range(1,N+1):
        if B[i] == 1:
            ans.append(i)
    print(len(ans))
    print(*ans)


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
 
b = [0] * n
 
for i in range(n, 0, -1):
    if sum(b[i-1::i]) % 2 == a[i-1]:
        continue
    else:
        b[i-1] = 1
 
c = []
for i in range(n):
    if b[i] == 1:
        c.append(i+1)
print(sum(b))
if len(c) > 0:
    print(*c)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

b = [0] * n

for i in range(n, 0, -1):
    if sum(b[i-1::i]) % 2 == a[i-1]:
        continue
    else:
        b[i-1] = 1

c = []
for i in range(n):
    if b[i] == 1:
        c.append(i+1)
print(sum(b))
if len(c) > 0:
    print(*c)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

B = [0]*N

for i in range(N-1, -1, -1):
  count = 0
  for j in range(i, N, i+1):
    count += B[j]
  if count%2 == A[i]:
    B[i] = 0
  else:
    B[i] = 1

sum = sum(B)
if sum == 0:
  print(0)
else:
  print(sum)
  ans = []
  for i in range(N):
    if B[i] == 1:
      ans.append(i+1)
  print(*ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

B = [0]*N

for i in range(N-1, -1, -1):
  count = 0
  for j in range(i, N, i+1):
    count += B[j]
    if count%2 == A[i]:
      B[i] = 0
    else:
      B[i] = 1

sum = sum(B)
if sum == 0:
  print(0)
else:
  print(sum)
  ans = []
  for i in range(N):
    if B[i] == 1:
      ans.append(i+1)
  print(*ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

B = [0 for i in range(N)]

for i in range(N-1, -1, -1):
  count = 0
  for j in range(i, N, i+1):
    count += B[j]
    if count%2 == A[i]:
      B[i] = 0
    else:
      B[i] = 1

sum = sum(B)
if sum == 0:
  print(0)
else:
  print(sum)
  ans = []
  for i in range(N):
    if B[i] == 1:
      ans.append(i+1)
  print(*ans)

Solution (Python):
N=int(input())
a=list(map(int, input().split()))
a.insert(0, 0)
b=[0 for _ in range(N+1)]
for i in range(N, 0, -1):
    s=0
    for j in range(i, N+1, i):
        s=s^b[j]
    b[i]=s^a[i]
ans=[]
for i in range(1, N+1):
    if b[i]==1:
        ans.append(i)
print(len(ans))
if len(ans):
    print(" ".join(map(str, ans)))

Solution (Python):
n = int(input())
A = [0] + list(map(int, input().split()))
B = [0]*(n+1)
for i in range(n, 0, -1):
    B[i] =(A[i] + sum(B[::i])) % 2
print(sum(B))
print(*(i for i, b in enumerate(B) if b))

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(n)]

ans_m = 0
ans_b = []
for i in range(n-1,n//2-1,-1):
    
    if a[i] == 1:
        b[i] = 1
        ans_m += 1
        ans_b.append(i+1)
        
        


for i in range(n//2-1,-1,-1):
    
    s = 0
    for j in range((i+1)*2,n+1,i+1):
        
        s += b[j-1]
        
    
    if s % 2 != a[i]:
        b[i] = 1
        ans_m += 1
        ans_b.append(i+1)
        



print(ans_m)
print(*ans_b)

Solution (Python):

import sys
sys.setrecursionlimit(10000000)
INF = 1<<32

MOD = 2  

def solve(N: int, a: "List[int]"):
    a = [0] + a
    b = [0] * (N+1)
    for i in range(N,0,-1):
        j = i*2
        n = 0
        while j <= N:
            n += b[j]
            j += i
        
        if a[i] == n%MOD:
            b[i] = 0
        else:
            b[i] = 1

    x = [i for i in range(1, N+1) if b[i] == 1]
    print(len(x))
    for i in x:
        print(i)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    a = [int(next(tokens)) for _ in range(N)]  
    solve(N, a)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline

N = int(input())
a_list = list(map(int, input().split()))

ans_list = [0] * N
ans_text = ''
for i in range(N):
  
  j = N - i
  sum_j = sum(ans_list[j-1::j])
  if sum_j%2 != a_list[j-1]:
    ans_list[j-1] = 1
    ans_text += str(j) + ' '
    
    
print(sum(ans_list))
print(ans_text)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

box = [0] * (N+1)
ans = []
for i in range(N,0,-1):
  work = 0
  for j in range(0,N+1,i):
    work += box[j]
    
  if work % 2 != A[i-1]:
    box[i] = 1
    ans.append(i)

print(len(ans))
if len(ans) > 0:
  print(" ".join(list(map(str, ans))))

Solution (Python):
n =int(input())

num = list(map(int, input().split()))

box =[0]*n
sum=0
for i in reversed(range (n)):
  sum=0
  for j in (range(int(n/(i+1))-1)):
    sum +=box[i+(i+1)*(j+1)]
  box[i]=(sum+num[i])%2


ans = []
for i in range(n):
  if box[i]==1:
    ans.append(i+1)
print(len(ans))
ans=[str(a) for a in ans]
ans=" ".join(ans)
print(ans)

Solution (Python):
n =int(input())

num = list(map(int, input().split()))

box =[0]*n
sum=0
for i in reversed(range (n)):
  sum=0
  for j in (range(int(n/(i+1))-1)):
    sum +=box[i+(i+1)*(j+1)]
  box[i]=(sum+num[i])%2


ans = []
for i in range(n):
  if box[i]==1:
    ans.append(i+1)
print(len(ans))
ans=[str(a) for a in ans]
ans=" ".join(ans)
print(ans)

Solution (Python):
N = int(input())
a = [0] + list(map(int, input().split()))

b = [0] * (N + 1)
ans = []
for i in range(1,N+1)[::-1]:
    s = sum(b[i+i::i]) % 2
    if a[i] != s:
        b[i] = 1
        ans.append(i)

if ans == []:
    print(0)
else:
    print(len(ans))
    print(" ".join(map(str, ans)))

Solution (Python):
n=int(input())
a=list(map(int,input().split()))

ball = [0]*n
for i in range(n)[::-1]:
    _sum=0
    for g in range(1,n+1):
        if (i+1)*g-1<n:
            _sum+=ball[(i+1)*g-1]
        else:
            break
    if _sum%2!=a[i]:
        ball[i]=1

print(sum(ball))
if sum(ball)!=0:
    print(*[g+1 for g in range(len(ball)) if ball[g]!=0])

Solution (Python):

N = int(input())
A = list(map(int, input().split()))
B = set()

for i in list(range(1, N+1))[::-1]:
  tmp = i
  cnt = 0
  while tmp <= N:
    if tmp in B:
      cnt += 1    
    tmp += i

  if cnt % 2 != A[i-1]:
    B.add(i)

len_b = len(B)
if len_b == 0:
  print(0)
else:
  print(len_b)
  print(*sorted(list(B)))

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
b = set()
c = [0]*n

for i in range(n, 0, -1):
  x = 0
  for j in range(2*i, n+1, i):
    x+=c[j-1]
  if a[i-1] != x%2:
    c[i-1] += 1
    b.add(i)
print(len(b))
print(*b)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
b = set()

for i in range(n-1):
  if a[n-1-i]&1:
    b.add(n-i)
    for j in range(2, int((n-i)**0.5)+1):
      if (n-i)%j == 0:
        a[j-1] += 1
        if (n-i)//j != j:
          a[(n-i)//j -1] += 1
if a[0] != len(b)%2:
  b.add(1)
          
print(len(b))
if len(b)>0:
  print(*b)

Solution (Python):
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


def main():
    N = I()
    a = LI()
    b = [0] * N

    for i in range(N-1, -1, -1):
        total = 0

        for cur in range(i, N, i+1):
            
            total += b[cur]

        if a[i] != total % 2:
            b[i] = 1
            
        

    ans = []
    for i in range(N):
        if b[i] == 1:
            ans.append(i+1)

    print(len(ans))
    if len(ans) > 0:
        print(*ans)


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
ball=[False]*n
for i in range(n-1,-1,-1):
    cnt=0
    for j in range(i,n,i+1):
        if ball[j]:
            cnt+=1
    if cnt%2!=a[i]:
        ball[i]=True
ans=[i+1 for i in range(n) if ball[i]]
print(len(ans))
print(*ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ans_l = [0]*n
for i in reversed(range(1,n)):
    if sum(ans_l[(i)::(i+1)])%2 != a[i]:
        ans_l[i] += 1
if sum(ans_l)%2 != a[0]:
    ans_l[0] += 1
ans = []
for i in range(n):
    if ans_l[i]==1:
        ans.append(i+1)
print(len(ans))
if len(ans)>0:
    print(" ".join(map(str, ans)))

Solution (Python):
n=int(input())
A=list(map(int,input().split()))
choice=[0]*n
ans=[]
cnt=0
for i in reversed(range(n)):
    a=i+1
    c=0
    a+=i+1
    while a<=n:
        c+=choice[a-1]
        a+=i+1
    if c%2!=A[i]:
        choice[i]+=1
        ans.append(i+1)
        cnt+=1
if cnt==0:
    print(0)
else:
    print(cnt)
    ans.sort()
    print(*ans, sep=' ')

Solution (Python):
n=int(input())
A=list(map(int,input().split()))
choice=[0]*n
ans=[]
cnt=0
for i in reversed(range(n)):
    a=i+1
    c=0
    a+=i+1
    while a<=n:
        c+=choice[a-1]
        a+=i+1
    if c%2!=A[i]:
        choice[i]+=1
        ans.append(i+1)
        cnt+=1
if cnt==0:
    print(0)
else:
    print(cnt)
    ans.sort()
    print(*ans, sep=' ')

Solution (Python):
n=int(input())
A=list(map(int,input().split()))
choice=[0]*n
ans=[]
cnt=0
for i in range(n-1,-1,-1):
    a=i+1
    c=0
    a+=i+1
    while a<=n:
        c+=choice[a-1]
        a+=i+1
    if c%2!=A[i]:
        choice[i]+=1
        ans.append(i+1)
        cnt+=1
if cnt==0:
    print(0)
else:
    print(cnt)
    ans.sort()
    print(*ans, sep=' ')

Solution (Python):
N = int(input())
a = [0] + [int(x) for x in input().split()]

nball = [0] * (N + 1)  

nball[N] = a[N]

for i in range(N - 1, 0, -1):
    if 2 * i <= N:
        nball[i] = ( a[i] + sum(nball[2 * i : N + 1 : i]) ) % 2  
    else:
        nball[i] = a[i]

M = 0
b = []
for i in range(N + 1):
    M += nball[i]
    if nball[i] > 0:
        b.append(i)

print(M)
if len(b) > 0:
    print(' '.join(map(str, b)))