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


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


num = int(N // 2 + 1)
cnt = {}
for i in range(1, N + 1):
    cnt[i] = 0
A.reverse()
B = []

for i, a in enumerate(A):
    i = N - i
    if i >= num:
        if a == 1:
            for p in make_divisors(i):
                cnt[p] = (cnt[p] + 1) % 2
            B.append(i)
    else:
        if cnt[i] != a:
            for p in make_divisors(i):
                cnt[p] = (cnt[p] + 1) % 2
            B.append(i)

print(len(B))
B = list(map(str, B))
print(' '.join(B))

Solution (Python):
import math

n = int(input())
line = list(map(int,input().split( )))

bline = line[:]
sep = math.ceil(n/2)
bline[:sep] = [0]*sep



for i in reversed(range(sep)):
    bline[i]=(sum(bline[i::i+1])+line[i])%2

blist=[]

for i in range(len(bline)):
    if bline[i]==1:
        blist.append(i+1)




print(len(blist))
print(' '.join(map(str,blist)))

Solution (Python):
N=int(input())
lst = [int(s) for s in input().split()]
ans=[0]*N
result=[]
def now(num):
  res=0
  k=1
  while(k*num<=N):
    res=res+ans[k*num-1]
    k=k+1
  return res%2
for i in range(N):
  n=N-i
  x=lst[n-1]
  y=now(n)
  if(x!=y):
    ans[n-1]=1
    result.append(n)
result.sort()
print(len(result))
if (len(result)!=0):
  print(' '.join(map(str, result)))

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

for i in reversed(range(n)):
    t = i+1
    if t*2 > n:
        b[i] = a[i]
    else:
        
        b[i] = a[i*2+1]
        j = i + (t*2)
        
        
        while j < n:
            b[i] += b[j]
            
            j += t*2
        b[i] = b[i] % 2
        
        if b[i] == a[i]:
            b[i] = 0
        else:
            b[i] = 1


ans = []
for i in range(len(b)):
    if b[i] == 1:
        ans.append(str(i+1))
print(len(ans))
if len(ans) > 0:
    print(" ".join(ans))

Solution (Python):
N = int(input())
a = [0]
for x in input().split():
    a.append(int(x))
b = [0]*(N+1)
for i in range(1, N+1)[::-1]:
    if i > N//2:
        b[i] = a[i]
    else:
        b[i] = (a[i] + sum([b[j] for j in range(i, N+1, i)])) % 2

print(sum(b))
print(" ".join(map(str, [i for i in range(1, N+1) if b[i] == 1])))

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

N=int(input().strip())
An=[int(x) for x in input().strip().split()]
Bn=[-1 for _ in range(N)]
Sum=0
for i in range(N-1,-1,-1):
    temp=0
    index=(i+1)*2
    while index <= N:
        temp=temp^Bn[index-1]
        index+=(i+1)

    ball= An[i] ^ temp
    Sum+=ball
    Bn[i]= ball

print(Sum)
if Sum!=0:
    ans=[str(x+1) for x in range(N) if Bn[x]==1]
    print(' '.join(ans))

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

baisuu = [[] for _ in range(N + 1)]

for i in range(1, N + 1):
    for j in range(i, N + 1, i):
        baisuu[j].append(i)


ans = []
lst = [0 for _ in range(N + 1)]
for i in reversed(range(1, N + 1)):

    lst[i] = (lst[i] + A[i]) % 2
    if lst[i] == 1:
        ans.append(i)

    for j in baisuu[i]:
        lst[j] = (lst[j] + lst[i]) % 2

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

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

for i in range(mid, n):
    b[i] = a[i]

for i in range(mid-1, -1, -1):
    s = 0
    for j in range(i,n,i+1):
        s += b[j]
    if s%2 != a[i]:
        b[i] += 1


print(b.count(1))
for i in range(n):
    if b[i] == 1:
        print(i+1, end = ' ')

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
b=[0]*N
n=0
ans=[]
for i in reversed(range(N)):
    t=0
    for j in range(2*(i+1)-1,N,i+1):
        if b[j]==1:
            t^=1
    b[i]=a[i]^t
    if b[i]==1:
        n+=1
        ans.append(str(i+1))
print(n)
print(' '.join(ans))

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

a = []
aa = input().split() 

for i in range(n):
    a.append(int(aa[i]))

ans = [0 for i in range(n)]

memo = int(n/2)+2
for i in range(n-1,-1,-1):
    if i >= memo:
        ans[i] = a[i]
    else:
        memo2 = 0
        s = i+1
        t = 2
        while (s*t-1)<=(n-1):
            if ans[s*t-1] == 1:
                memo2 += 1
            t += 1
        if a[i] != memo2%2:
                ans[i] = 1

v = 0
for i in range(n):
    if ans[i] == 1:
        v += 1

print(v)

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

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]:
        b[i-1]=1

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

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

Solution (Python):
a=int(input())
b=list(map(int,input().split()))
c=[0 for i in range(a)]
e=[]
i=a-1
while i>=0:
  d=(b[i]+sum(c[i::i+1]))%2
  if d==1:
    c[i]=1
    e.append(i+1)
  i-=1
print(len(e))
for i in range(len(e)):
  print(str(e[i]),end="")
  if i!=len(e)-1:
    print(" ",end="")

Solution (Python):

import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))
a = np.insert(a,0,0)

box = np.zeros(n+1,dtype="int32")


for i in range((n//2)+1,n+1):
    if a[i] == 1:
        box[i] = 1
        
for i in reversed(range(1,(n//2)+1)):
    
    if a[i]==1:
        if np.sum(box[i::i])%2==0:
            box[i] = 1
        else:
            box[i] = 0
    
    else:
        if np.sum(box[i::i])%2==1:
            box[i] = 1
        else:
            box[i] = 0
m = np.sum(box)
ans_index = np.where(box==1)[0]

ans_index = map(str, ans_index)
print(m)
if m!=0:
    ans = " ".join(ans_index)
    print(ans)

Solution (Python):
import sys
import numpy as np
from scipy.misc import comb
sys.setrecursionlimit(1000000)
 
n = int(input())

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

a.insert(0,0)

list_n = n + 1

box = [0] * (n+1)

one = []

for i in range(list_n-1):
    cnt = n - i
    tmp = 0
    for j in range(list_n):
        
        if cnt * (j+1) <= n:
            tmp = ( tmp + box[cnt*(j+1)] ) % 2
        elif tmp == a[cnt]:
            box[cnt] = 0
            break
        else:
            box[cnt] = 1
            one.append(cnt)
            break
        
if len(one) == 0:
    print(0)
else:
    print(len(one))
    print(*one)

Solution (Python):
import math

N = int(input())
a = list(map(int, input().split(' ')))
a.insert(0, -1)


mid = math.floor(N / 2)


M = 0
b = [0 for i in range(N)]
b.insert(0, -1)
for i in reversed(range(1, N + 1)):
    if i > mid:
        if a[i] == 0:
            b[i] = 0
        else:
            M += 1
            b[i] = 1
    else:
        num = 0
        for j in range(1, N // i + 1):
            num += b[j * i]
        if num % 2 == 0:
            if a[i] == 0:
                b[i] = 0
            else:
                M += 1
                b[i] = 1
        else:
            if a[i] == 0:
                M += 1
                b[i] = 1
            else:
                b[i] = 0

print(M)
for i in range(1, N + 1):
    if b[i] == 1:
        print(i, end=' ')

Solution (Python):
n = int(input())
l = list(map(int,input().split()))
half = n//2

ans = [0]*n
for i in range(half,n):
    if l[i] == 1:
        ans[i] = 1
for i in range(0,half):
    p = half-1-i
    s = 0
    qmax = n //(p+1)
    for j in range(1,qmax+1):
        s += ans[j*(p+1)-1]
    if s%2 != l[p]:
        ans[p] = 1
print(sum(ans))
for i in range(n):
    if ans[i] == 1:
        print(i+1,end=" ")

Solution (Python):
N = int(input())
a = [int(_) for _ in input().split()] 
b = [-1] * N

for i in reversed(range(N)):

    b[i] = (sum(b[i::(i+1)]) -b[i] + a[i]) % 2

print(sum(b))


res = []
for i in range(N):
    if b[i] == 1:
        res.append(str(i+1))
print(" ".join(res))

Solution (Python):



import numpy as np


def solv(m, a):
    boxs = np.zeros(m, dtype=np.int)

    for i in range(m, 0, -1):
        
        s = np.count_nonzero(boxs[i+i-1:m:i])
        boxs[i-1] = (s + a[i-1]) % 2

    return boxs


if __name__ == '__main__':

    m = int(input())
    a = np.array(list(map(int, input().split())), dtype=np.int)

    ans = solv(m, a)

    print(sum(ans))
    for i in range(m):
        if ans[i]:
            print(i+1)

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

if N == 1:
    if A[0] == 1:
        print(1)
        print(1)
        exit()

ans = [0 for _ in range(N // 2 + 1)] + A[N // 2:]

for i in range(N // 2, 1, -1):
    count = 0
    n = i
    j = 2
    while n * j <= N:
        count += ans[n * j]
        j += 1
    ans[i] = (count + A[i - 1]) % 2

sans = sum(ans)

ans[1] = (sans + A[0]) % 2

sans += ans[1]

print(sans)
p = ''
for i in range(1, N + 1):
    if ans[i] == 1:
        p += str(i) + ' '

print(p)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
ans = [1 for i in range(N)]
for i,a in enumerate(A):
    i = N-i-1
    if i != 0:
        partsum = 0
        if i <= N//2-1:
            for j in range(N//(i+1)):
                k = j+1
                k *= (i+1)

                partsum += ans[k-1]

            if partsum % 2 != A[i]:
                ans[i] = 0
            
        else:
            if A[i] == 0:
                ans[i] = 0
    else:
        if sum(ans)%2 == A[i]:
            bans = []
            for bi, b in enumerate(ans):
                if b == 1:
                    bans.append(bi+1)
            print(len(bans))
            if len(bans) != 0:
                print(*bans)
        else:
            ans[i] = 0
            bans = []
            for bi, b in enumerate(ans):
                if b == 1:
                    bans.append(bi+1)
            print(len(bans))
            if len(bans) != 0:
                print(*bans)

Solution (Python):
import numpy as np


def main():
	
	N = int(input()) + 1
	a = [0]
	a += [int(x) for x in input().split()]
	b = [0] * (len(a))

	counter = 0
	for i in range(N-1, 0, -1):
		num = 0
		for j in range(i, N, i):
			num += b[j]
		if not num % 2 == a[i]:
			b[i] += 1
			counter += 1
	if max(b) > 1:
		print(-1)
		return
	print(counter)
	l = [i for i, x in enumerate(b) if x == 1]
	for row in l:
		print(row, end=" ")
	print("")

if __name__ == "__main__":
	main()

Solution (Python):
def make_divisors(n):
    
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            B[i]+=1
            if i != n // i:
                B[n//i]+=1

    
    

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

B=[0]*300000
C=[]
count=0
for i in reversed(range(N)):
    if B[i+1]%2!=A[i]:
        make_divisors(i+1)
        count +=1
        C.append(i+1)
print(count)

if count!=0:
    for i in reversed(range(1,count)):
        print(str(C[i])+" ",end="")
    print(C[0], end="")

Solution (Python):

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

M = 0
box_dict = {}
for i in reversed(range(N)):
    idx = i + 1
    multi_sum = 0
    if N // idx < 2:
        if a_list[i] == 0:
            box_dict[idx] = 0
        else:
            box_dict[idx] = 1
            M += 1
    else:
        for j in range(2, (N // idx) + 1):
            multi_sum += box_dict[idx * j]
        if a_list[i] - (multi_sum % 2) == 0:
            box_dict[idx] = 0
        else:
            box_dict[idx] = 1
            M += 1

print(M)
if M > 0:
    b_list = [key for key, value in box_dict.items() if value == 1]
    print(" ".join(map(str, b_list)))

Solution (Python):
import math

def myinput_int():
    return list(map(int, input().split()))
def myinput_int_special():
    text = '99 '+input() 
    return list(map(int, text.split()))

N, = myinput_int()
a = myinput_int_special()
answer=[-99]*(N+1)

for i in range(N,0,-1):
    goukei=0
    for j in range(2,math.floor(N/i)+1):
        goukei += answer[i*j]
    answer[i] = (goukei+a[i])%2

output=""
count=0
for i in range(1,N+1):
    if answer[i]==1:
        output+=' '+str(i)
        count+=1

output=output[1:] 
print(count)
if output!="":
    print(output)

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

ls = [0]*n
for i in range(n-1,-1,-1):
    count = 0
    for j in range(i,n,i+1):
        count += ls[j]
    if (count + 1) % 2 == a[i]:
        ls[i] = 1
check = 0
for i in range(n):
    if ls[i] == 1:
        check += 1
    
print(check)
for i in range(n):
    if ls[i] == 1:
        print(i+1)

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

A = [None] + A
B = [0] * (N + 1)

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

B = [i for i, b in enumerate(B) if b == 1]
print(len(B))
for i in B:
    print(i)

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

b = [0] * N

for i in range(N//2, N) :
    b[i] = a[i]

for i in range(0, N//2)[::-1] :
    buf = 0
    for j in range(1, N//(i+1)) :
        buf += b[(i+1)*(j+1) - 1]
    buf += a[i]


    if buf % 2 == a[i] :
        b[i] = a[i]
    else :
        if a[i] == 1 :
            b[i] = 0
        if a[i] == 0 :
            b[i] = 1



ans = []
cnt = 0

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

print(cnt)
for i in range(len(ans)) :
    print(ans[i], end=" ")
if len(ans) > 0 :
    print()

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
B = [0] * N
list_B = [0] * N

for i in range(N)[::-1]:
  if A[i] != (sum(B[i::i+1]) % 2):
    B[i] = 1
    list_B[i] = i + 1

print(int(sum(B)))
list_B = ' '.join([str(a) for a in [i for i in list_B if i != 0]])
print(list_B)

Solution (Python):
N = int(input())
A=[-1]
A.extend([int(a) for a in input().split()])

ans = {}
ret = []

def get_xor(frm):
    global ans
    i = frm *2
    re = 0
    while i < len(A):
        re = re ^ ans[i]
        i += frm
    return re

for i in range(1,len(A)):
    ri = len(A) - i
    if 2 * ri < len(A):
        
        ans[ri] = A[ri] ^ get_xor(ri)
        if ans[ri]==1:
            ret.append(str(ri))
        pass
    else:  
        ans[ri] = A[ri]
        if ans[ri]==1:
            ret.append(str(ri))
print(len(ret))
s = " ".join(ret)
if s:
    print(s)

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

ans=[0]*n

i=n-1
j=1
f=0
while i!=-1:
    while True:
        try:
            b=i+(i+1)*j
            f+=ans[b]
            j+=1
        except:
            break
    f=f%2
    if (f-s[i])==0:
        ans[i]=0
    else:
        ans[i]=1
    j=1
    f=0
    i-=1
sad=[]
print(ans.count(1))
i=0
while i!=len(s):
    if ans[i]==1:
        sad.append(i+1)
    i+=1


print(' '.join(map(str, sad)))

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

for i in reversed(range(n)):
  if n/2 > i :
    tmp = 2
    sum_num = 0
    while (tmp*(i+1) - 1) < n:
      sum_num += 1 if b[tmp*(i+1)-1] == 1 else 0
      tmp += 1
      
    b[i] = 0 if sum_num %2 == a[i] else 1
  else:
    b[i] = a[i]
  
  if b[i] == 1:
    count += 1
    ans.append(str(i+1))
    
list.sort(ans)
print(count)
print(' '.join(ans))

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
boxes = ["mada"] * n

for i in range(n, 0, -1):
    if boxes[i-1] == "mada":
        kokomade = sum((boxes[i-1::i])[1:]) % 2
        if kokomade == a[i-1]:
            boxes[i-1] = 0
        else:
            boxes[i-1] = 1

ans = []
for i in range(n):
    if boxes[i] == 1:
        ans.append(str(i+1))

print(len(ans))
print(" ".join(ans))

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

ans = [0 for i in range(n)]

for i in range(n, 0, -1):
    k = n // i

    an = a[i-1]

    for j in range(2,k+1):
        an = an ^ ans[j*i-1]

    ans[i-1] = an

print(sum(ans))
ans_l = [i+1 for i,x in enumerate(ans) if x == 1]
print(" ".join(map(str,ans_l)))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
ans = [0 for _ in range(N)]

for i, a in enumerate(A[::-1]):
    ind = N - i
    if ind > N//2:
        ans[ind-1] = a
    else:
        cnt = 0
        for j in range(2, (N // ind) + 1):
            cnt += ans[j * ind - 1]
        if cnt % 2 == A[ind-1]:
            ans[ind-1] = 0
        else:
            ans[ind-1] = 1

print(sum(ans))
for i, a in enumerate(ans):
    if a == 1:
        print(i+1, end="")
        print(' ', end="")

Solution (Python):
from collections import deque

def main():
    n = int(input())
    A = list(map(int, input().split()))
    ans = 0
    B = [0] * n
    
    ansList = deque()

    def makeList(num):
        start = num + 1
        mul = n // start
        return [start * j - 1 for j in range(1, mul+1)]


    def makeRes(indices):
        flag = 0
        for elm in indices:
            if B[elm] == 1:
                flag = (flag + 1) % 2
        return flag


    for i in range(n-1, -1, -1):
        if i + 1 >  n / 2:
            if A[i] == 1:
                B[i] = 1
                ans += 1
                ansList.appendleft(i+1)
        else:
            indices = makeList(i)
            
            res = makeRes(indices)
            
            if A[i] != res:
                B[i] = 1
                ans += 1
                ansList.appendleft(i+1)

    print(ans)

    if ans != 0:
        print(*(list(ansList)))


if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
for j in range(n):
    i=n-j-1
    
    
    sum=a[i]
    for k in range(2,n+1):
        if((i+1)*k>n):
            break
        
        sum=sum^ans[i*k+k-1]
    ans[i]=sum



kazu=0
for i in range(n):
    if(ans[i]==1):
        kazu+=1
print(kazu)
for i in range(n):
    if(ans[i]==1):
        print(i+1)

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

Solution (Python):
n=int(input())
a=[0]+[int(i) for i in input().split()]
b=[0]*(n+1)
only=int(n/2)
for i in range(only+1,n+1):
    b[i]=a[i]
if n%2==1:
    only+=1
for i in range(n-(only),0,-1):
    sum1=0
    for j in range(i,n+1,i):
        sum1+=b[j]
    if sum1%2==a[i]:
        b[i]=0
    else:
        b[i]=1
m=b.count(1)
print(m)
for i in range(1,n+1):
    if b[i]==1:
        print(i,end=" ")

Solution (Python):
n = int(input())
a_list=[9]
a_list += list(map(int, input().split()))

ans_list=[0]*(n+1)
output=[]
for i in range(n,0,-1):
  
  siji=a_list[i]
  num=n//i
  
  tmp=0
  for j in range(1,num+1):
    
    tmp+=ans_list[i*j]
  
  
  
  if tmp%2==siji:
    ans_list[i]=0
  else:
    ans_list[i]=1
    output.append(i)
    
print(sum(ans_list[1:]))
for i in range(len(output)):
    if i == len(output)-1:
      print(output[i])
    else:
      print(output[i],end=" ")

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

import collections

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

    y_dict = collections.defaultdict(list)

    
    for i in range(1, N//2+2):
        cnt = 2
        while True:
            baisu = i * cnt
            y_dict[baisu].append(i)
            cnt += 1
            if baisu > N:
                break

    dprint(y_dict)
    bits = collections.defaultdict(int)
    ans = []
    
    for i in range(N, 0, -1):

        a = a_list[i-1]
        dprint(a, bits[i])
        if a == bits[i]:
            continue
        for y in y_dict[i]:
            bits[y] = (bits[y] + 1) % 2
        ans.append(i)


    print(len(ans))
    print(' '.join([str(num) for num in reversed(ans)]))

solve()

Solution (Python):

n = int(input()) 

a=[0]*n    
ama=list(map(int,input().split()))

for i in reversed(ama):
    if sum(a[n-1::n])%2==i:
        next
    else:
        a[n-1]=(a[n-1]+1)%2
    n=n-1


print(sum(a))
print(" ".join(list(map(str,list(map(lambda x: x+1, [i for i, x in enumerate(a) if x == 1]))))))

Solution (Python):
import sys
from collections import deque
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

B=[0]*N
kazu = 0
for i in range(N, 0, -1):
	num = N//i
	total = 0
	for n in range(1, num + 1):
		total += B[i*n - 1]
	total = total % 2
	if total != a[i - 1]:
		B[i - 1] = 1
		kazu += 1

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

print("\n")

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

def main():
  n = int(input())
  alist = list(map(int, input().split()))
  ans = [0 for _ in range(n+1)]
  anss = 0
  res = []
  for i in range(n, 1, -1):
    if ans[i]%2 != alist[i-1]:
      anss += 1
      res.append(i)
      j = 1
      while j*j <= i:
        if i % j == 0:
          if j*j == i:
            ans[j] += 1
          else:
            ans[j] += 1
            ans[i//j] += 1
        j += 1
    
  if ans[1] %2 != alist[0]:
    print(anss+1)
    res.append(1)
    res.reverse()
    print(*res)
  else:
    print(anss)
    if res:
      res.reverse()
      print(*res)


if __name__ == '__main__':
  main()

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
b=[0]*(n+1)
for i in reversed(range(1,n+1)):
    tmp_num=i
    tmp=0
    while tmp_num<=n:
        tmp+=b[tmp_num]
        tmp_num+=i
    b[i]=(a[i-1]+tmp)%2
cnt=0
c=[]
for i in range(len(b)):
    if b[i]==1:
        cnt+=1
        c.append(str(i))
print(cnt)
if cnt!=0:
    print(" ".join(c))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
C = [0 for i in range(N)]

for i in range(N, 0, -1):
    if i > N // 2:
        C[i-1] = A[i-1]
    else:
        sum_b = 0
        for k in range(1, 10**6):
            if i * k > N:
                break
            else:
                sum_b += C[i * k - 1]
        if sum_b % 2 == A[i-1]:
            C[i-1] = 0
        else:
            C[i-1] = 1

print(sum(C))
B = []
for i in range(N):
    if C[i] == 1:
       B.append(i+1)
for i in range(len(B)):
    if i == len(B) - 1:
        print(B[i], end=" ")
    else:
        print(B[i], end=" ")

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

Solution (Python):




import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop
import math

def main():
    n = int(input())
    al = list(map(int, input().split()))

    ans = [0] * n

    half = math.ceil(n/2)
    for i in range(half, n):
        ans[i] = al[i]

    for i in range(half-1, -1, -1):
        num = i + 1
        val = 0
        for j in range(num * 2 - 1, n, num):
            
            val += ans[j]

        val %= 2
        ans[i] = 0 if val == al[i] else 1

    c = ans.count(1)
    print(c)
    if c > 0:
        boxes = []
        for i in range(len(ans)):
            if ans[i] == 1:
                boxes.append(i + 1)
        print(' '.join(map(str, boxes)))


if __name__ == '__main__':
    main()

Solution (Python):
from heapq import *
from math import log
from itertools import accumulate
from collections import deque

import sys
sys.setrecursionlimit(100100)

import math
from math import ceil
from bisect import bisect_left


from copy import deepcopy
from itertools import permutations

from math import sqrt
from heapq import *
from math import factorial
from collections import defaultdict



from bisect import bisect_left as bl
from bisect import bisect_right as br
from math import log

from fractions import gcd
import math
from collections import deque

import sys
input=sys.stdin.readline


N=int(input())
A=list(map(int,input().split()))
A=[0]+A
B=[0 for i in A]
def prime_factor(n):
    i = 2
    table = defaultdict(int)
    while i * i <= n:
        while n % i == 0:
            n //= i
            table[i]+=1
        i += 1
    if n > 1:
        table[n]+=1
    return table
K=[]
for n in range(N,0,-1):
    if A[n]-B[n]==0:
        continue
    K.append(n)
    table=prime_factor(n)
    
    l=[1]
    if n==1:
        continue
    for i,j in table.items():
        l_=[]
        for k in l:
            l_.extend([k*i**m for m in range(1,j+1)])
        l.extend(l_)
    
    for i in l:
        B[i]=1-B[i]
    


if len(K):
    print(len(K))
    print(*K,sep=" ")
else:
    print(len(K))

Solution (Python):
def resolve():

    n = int(input())
    ai = list(map(int, input().split()))

    ans = [0] * n

    for i in range(n)[::-1]:

        bit = sum(ans[i:n:i+1]) % 2
        if bit != ai[i]:
            ans[i] = 1

    print(sum(ans))

    if sum(ans) != 0:
        ans_index = [i+1 for i, x in enumerate(ans) if x == 1]
        print(' '.join(map(str, ans_index)))
        
resolve()

Solution (Python):
def main():
    n = int(input())
    s = list(map(int,input().split()))
    r = [0] * n
    for i in range(n,n//2,-1):
        if s[i-1] == 1:
            r[i-1] = 1
    for i in range(n//2,0,-1):
        p = n // i
        c = 0
        for j in range(1,p+1):
            if r[(j * i) - 1] == 1:
                c += 1
        if c % 2 != s[i-1]:
            r[i-1] = 1

    o = sum(r)
    print(o)
    if o > 0:
        u = []
        for i in range(len(r)):
            if r[i] == 1:
                u.append(str(i+1))
        print(" ".join(u))
    
if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
B = [0] * (N+1)

for i in range(N)[::-1]:
  if(not sum(B[::i+1])%2 == A[i]):
    B[i+1] = 1
  if(not sum(B[::i+1])%2 == A[i]):
    print(-1)
    quit()
  
print(sum(B))
for i, b in enumerate(B):
  if b == 1:
    print(i, end=" ")

Solution (Python):

def sum_remainder_before_i(i, a):
    ans = 0
    j = 1
    while True:
        if (j+1)*(i+1)-1 > len(a)-1:
            return ans
        else:
            ans = ans + a[(j+1)*(i+1)-1]
            j = j + 1

N = int(input())
a = tuple(map(int, input().split()))

i = N - 1
ans = [-1]*N
result = False

while True:
    sum = sum_remainder_before_i(i, ans)
    if sum % 2 == a[i]:
        ans[i] = 0
    else:
        ans[i] = 1
    if i == 0:
        break
    i = i - 1

m = 0
answers = []
for i, a in enumerate(ans):
    if a == 1:
        answers.append(i+1)
        m = m + 1

print(m)
if m > 0:
    print(" ".join(map(str,answers)))

Solution (Python):
import math

n = int(input())

ans = [0] * n

def baisuu(num, max):
    ret = []
    i = num
    while i <= max:
        ret.append(i)
        i = i + num
    return ret
    



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

for i in range(n):
    sum = 0
    for mltp in baisuu(n-i, n):
        sum = sum+ans[mltp-1]
    if not sum % 2 == an[n-i-1]:
        ans[n-i-1] = 1
                     

ans = list(map(lambda x: x%2,ans))
print("{}".format(ans.count(1)))

for i in range(n):
    if ans[i] == 1:
        print("{}".format(i+1))

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

h = N // 2 + N % 2
ans = [-1] * N

for i in range(h, N):
    ans[i] = a[i]
for i in range(h - 1, -1, -1):
    ans[i] = ((sum(ans[i::i + 1]) + 1) % 2) ^ a[i]

print(sum(ans))
for i, x in enumerate(ans):
    if x == 1:
        print(i+1)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
x = [-1]*N
b = []
for i in range(N,0,-1):
    m = N//i
    x[i-1] = int(sum(x[j] for j in range(i*2-1,i*m,i)) % 2 != a[i-1])
    if x[i-1] == 1:
        b.append(i)
print(len(b))
if len(b) > 0:
    print(" ".join(map(str, b)))

Solution (Python):
N = int(input())
List = list(map(int,input().split()))
found = True
A = []
B =[]
for i in range(N):
    a = N - i
    k = N // a
    c = 0
    for j in range(1,k):
        c += A[N - (j+1)*a]
    b = (List[a-1]-c)%2
    A.append(b)
    if b == 1:
       B.append(a) 
print(sum(A))
print(*B)

Solution (Python):
import sys
N=int(input())
A=list(map(int,input().split()))
c=1+N//2
ans=[-1 for _ in range(N+1)]
c_box=[]
total=0
b=[]
for i in range(c,N+1):
    ans[i]=A[i-1]
    if A[i-1]==1:
        c_box.append(i)
        total+=1
    
for i in range(c-1,0,-1):
    tmp=0
    for j in range(i*2,N+1,i):
        tmp+=ans[j]
    if tmp%2==0 and A[i-1]==0 or tmp%2==1 and A[i-1]==1:
        ans[i]=0
    elif tmp%2==1 and A[i-1]==0 or tmp%2==0 and A[i-1]==1:
        ans[i]=1
        c_box.append(i)
        total+=1
    else:
        print(-1)
        exit()
    
print(total)   
if total>0:
    print(" ".join(map(str,sorted(c_box))))