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):
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)

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


def makeDivisors(n):
	divisors = []
	
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			
			if n // i != i:
				divisors.append(n // i)
			
	return divisors

counter = [0] * N
ballNum = 0
boxWithBall = []

for i in range(N - 1, -1, -1):
	if counter[i] != A[i]:
		ballNum += 1
		boxWithBall.append(i + 1)
		
		for j in makeDivisors(i + 1):
			counter[j - 1] ^= 1
			
print(ballNum)

for i in boxWithBall:
	print(i, end=' ')

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

ans = [0]*(N+1)

for i in range(1, N + 1)[::-1]:
    sum_ans = sum(ans[x] for x in range(i, N + 1, i))
    if sum_ans % 2 != A[i - 1]:
        ans[i] = 1
        
print(sum(ans))


prt = []
if sum(ans) > 0:
  for i, v in enumerate(ans):
    if v != 0:
      prt.append(i)
  print(*prt)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
for i in range(N//2+1, 0, -1):
  sum = 0
  for o in range(1, (N//i)+1):
    sum += A[i*o-1]
  A[i-1] = sum%2
  
print(A.count(1))
ans = [str(q) for q,w in zip(range(1, N+1), A) if w == 1]
print(" ".join(ans))

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)

    divisors.sort()
    return divisors[:-1]

def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    
    
    B = [-1]*N
    dic = {}
    rest = N
    for i in reversed(range(1,N+1)):
        B[i-1] = A[i-1]
        rest -= 1
        div = make_divisors(i)
        for d in div:
            A[d-1] += B[i-1]
            rest -= 1
    B = [b % 2 for b in B]
    res = []
    for i, b in enumerate(B):
        if b == 1:
            res.append(str(i+1))
    print(len(res))
    print(" ".join(res))
main()

Solution (Python):
import numpy as np
n = int(input())
a = np.array(list(map(int, input().strip().split())))
b = [0] * (n+1)
for i in range(n):
    b[i+1] = a[i]




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



s = sum(b)

print(s)
if s > 0:
    sl = ''
    for i in range(len(b)):
        if b[i] == 1:
            sl += str(i) + ' '

    print(sl[:-1])

Solution (Python):



import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

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

b = [0]*(n+1)

for i in range(n//2,n):
    if a[i] == 1:
        b[i+1] = 1

for i in range(1,n//2+1)[::-1]:
    s = 0
    if i == 1:
        if sum(b) == 0 and a[0]:
            b[1] = 1
        elif sum(b) % 2 != a[0]:
            b[1] = 1
        break
    for j in range(2,n):
        if i*j > n:
            break
        if b[i*j] == 1:
            s += 1
    if s % 2:
        if a[i-1] == 1:
            continue
        b[i] = 1
    elif s % 2 == 0 and a[i-1] == 1:
        b[i] = 1

m = sum(b)
if m == 0:
    print(0)
    quit()
else:
    print(m)
    ans = [i for i,v in enumerate(b) if v]
    print(*ans)

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

b = [0]*n

for i in range(n):
    c = []
    j=2
    while (n-i)*j<=n:
        c.append((n-i)*j)
        j+=1
    if len(c)==0:
        b[n-i-1]=a[n-i-1]
    else:
        d = a[n-i-1]
        for x in c:
            d+=b[x-1]
        if d%2==1:
            b[n-i-1]=1
        else:
            b[n-i-1]=0

ans = []


for i in range(n):
    if b[i]%2==1:
        ans.append(i+1)
print(len(ans))
for i in range(len(ans)):
    print(ans[i],end=' ')

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

result = [0] * N
for i in range(N):
    if A_list[N - i - 1] == 1 and (N - i) * 2 > N:
        result[N - i - 1] = 1
    if A_list[N - i - 1] == 0 and (N - i) * 2 > N:
        result[N - i - 1] = 0
    if A_list[N - i - 1] == 1 and (N - i) * 2 <= N:
        tmp_sum = 0
        for r in range(N - i - 1, N, N - i):
            tmp_sum += result[r]
        if tmp_sum % 2 == 0:
            result[N - i - 1] = 1
        if tmp_sum % 2 == 1:
            result[N - i - 1] = 0
    if A_list[N - i - 1] == 0 and (N - i) * 2 <= N:
        tmp_sum = 0
        for r in range(N - i - 1, N, N - i):
            tmp_sum += result[r]
        if tmp_sum % 2 == 0:
            result[N - i - 1] = 0
        if tmp_sum % 2 == 1:
            result[N - i - 1] = 1

print(sum(result))
for i, r in enumerate(result):
    if r == 1:
        print(i + 1)

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

Solution (Python):
n,*a=map(int,open(0).read().split())
r=range(n)
for i in r:a[~i]=sum(a[~i::n-i])%2
print(sum(a),*[i+1for i in r if a[i]])

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

ans = [0 for x in range(N+1)]
ans_m = 0
ans_a = []
for i in range(N,0,-1):
    s = 0
    for j in range(2*i,N+1,i):
        if ans[j] == 1:
            s += 1
    if s & 1 != A[i-1]:
        ans[i] = 1
        ans_m += 1
        ans_a.append(i)

print(ans_m)
if ans_m > 0:
    print(" ".join(map(str,ans_a)))

Solution (Python):
n,*a=map(int,open(0).read().split())
r=range(n)
for i in r:a[~i]=sum(a[~i::n-i])%2
print(sum(a),*[i+1for i in r if a[i]])

Solution (Python):
"""
from collections import defaultdict
from collections import deque

def prime(N):
    se = [0,0,1]+[1]*(N-2)
    n = 2
    while n ** 2 <= N:
        if se[n]:
            nn = 2*n
            while nn <= N:
                se[nn] = 0
                nn += n
        n += 1

    return [x for x in range(0,N+1) if se[x]]
"""
N = int(input())
A = list(map(int,input().split()))



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



"""
pr = prime(N)

deq = deque(pr)
deq.appendleft(1)

cnt = len(deq)

d = [0]*(N+1)
d[1] = -1
for p in pr:
    d[p] = -1

B = pr
while cnt < N:
    C = []
    for num in B:
        if num * 2 > N:
            break
        for p in pr:
            if num * p > N:
                break
            aaa = num * p
            if d[aaa] <= 0:
                d[aaa] = p
                deq.append(aaa)
                C.append(aaa)
                cnt += 1
    B = sorted(C)
"""
B = [0]*N

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

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

Solution (Python):
n,*a=map(int,open(0).read().split())
r=range(n)
for i in r[::-1]:a[i]=sum(a[i::i+1])%2
print(sum(a),*[i+1for i in r if a[i]])

Solution (Python):
n,*a=map(int,open(0).read().split())
for i in range(n,0,-1):a[i-1]=sum(a[i-1::i])%2
print(sum(a),*[i+1for i in range(n)if a[i]])

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




def sol(i,want):
    num=N//(i+1)
    wa=B[i]

    for j in range(num):
        k=i+j*(i+1)
        wa+=B[k]



    wa=wa%2

    
    if wa==want:
        x=0
    else:
        x=1

    return x 

B=A[:]
half=N//2
for i in range(half):
    j=half-1-i

    B[j]=sol(j,A[j])
    
C=[i+1 for i, x in enumerate(B) if x ==1]

m=sum(B)
print(m)
print(*C)

Solution (Python):
import sys
line = sys.stdin.readline
M = int(line())
b = list(map(int, line().split()))
c = [0] * M
for i in range(M, 0, -1):
    ball = 0
    for j in range(2, M+1):
        if i * j > M:
            break
        ball += c[i * j - 1]
    c[i - 1] = (b[i - 1] + ball) % 2
ans = []
for i, v in enumerate(c):
    if v == 1:
        ans.append(i + 1)
print(len(ans))
print(*ans)

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

ans = [0 for x in range(N+1)]
for i in range(N,0,-1):
    s = 0
    for j in range(2*i,N+1,i):
        if ans[j] == 1:
            s += 1
    ans[i] = s & 1 != A[i-1]

ans_m = 0
ans_a = []
for i in range(len(ans)):
    if ans[i]:
        ans_m += 1
        ans_a.append(i)

print(ans_m)
if ans_m > 0:
    print(" ".join(map(str,ans_a)))

Solution (Python):
n,*a=map(int,open(0).read().split())
b=[0]*-~n
for i in range(n,0,-1):b[i]=(sum(b[j]for j in range(i,n+1,i))+a[i-1])%2
c=[i for i in range(n+1)if b[i]]
print(len(c),*c)

Solution (Python):
n,*a=map(int,open(0).read().split())
b=[0]*-~n
for i in range(n,0,-1):b[i]=(sum(b[j]for j in range(i,n+1,i))+a[i-1])%2
c=[i for i in range(n+1)if b[i]]
print(len(c),*c)

Solution (Python):
import math

N = int(input())

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

bb = aa[:]

i = N

while i > 0:

    total = 0
    j = i * 2

    while j <= N:
        total ^= bb[j - 1]
        j += i

    bb[i - 1] = total ^ aa[i - 1]
    i -= 1

bbKisu = list(filter(lambda n: n % 2 == 1, bb))
count = len(bbKisu)

print(count)
for i in range(N):
    if bb[i] == 1:
        print(i + 1)

Solution (Python):
n,*a=map(int,open(0).read().split())
b=[0]*-~n
for i in range(n,0,-1):
    t=0
    for j in range(i,n+1,i):
        t+=b[j]
    b[i]=(t+a[i-1])%2
c=[i for i,b in enumerate(b)if b]
print(len(c),*c)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(n)]
for i in range(n-1, -1, -1):
	tmp = 0
	for j in range(2*(i+1)-1, n, i+1):
		tmp ^= b[j]
	b[i] = a[i]^tmp
ans = [i+1 for i in range(n) if b[i]]
print(len(ans))
print(*ans)

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

from math import ceil

n = int(input())
a = list(map(int,input().split()))
b = ['0'] * (n+1)
    
for i in reversed(range(0, n)):
    d = n // (i+1)
    cn = 0
    for j in range(2, d+1):
        if b[j*(i+1)] == '1':
            cn += 1
    if cn % 2 == a[i]:
        b[i+1] = '0'
    else:
        b[i+1] = '1'
print(b.count('1'))
ee = []
for i,v in enumerate(b):
    if i == 0:
        continue
    if v == '1':
        ee.append(str(i))
print(' '.join(ee))

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a.insert(0,0)
b = [0] * (N + 1)
ans = []
count = 0
for i in reversed(range(1,N + 1)):
  if a[i] == 1:
    sumi = 0
    j = 2
    while True:
      if (i * j) > N:
        break
      sumi += b[i * j]
      j += 1
    if sumi % 2 == 0:
      b[i] = 1
      count += 1
      ans.append(int(i))
  else:
    sumi = 0
    j = 2
    while True:
      if (i * j) > N:
        break
      sumi += b[i * j]
      j += 1
    if sumi % 2 == 1:
      b[i] = 1
      count += 1
      ans.append(int(i))

print(count)
print(' '.join(map(str, ans)))

Solution (Python):
import math

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

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

ans = [index for index, v in enumerate(a) if v == 1]
print(len(ans))
print(*ans)

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

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a.insert(0,0)
b = [0] * (N + 1)
ans = []
count = 0
for i in reversed(range(1,N + 1)):
  if a[i] == 1:
    sumi = 0
    j = 2
    while True:
      if (i * j) > N:
        break
      sumi += b[i * j]
      j += 1
    if sumi % 2 == 0:
      b[i] = 1
      count += 1
      ans.append(int(i))
  else:
    sumi = 0
    j = 2
    while True:
      if (i * j) > N:
        break
      sumi += b[i * j]
      j += 1
    if sumi % 2 == 1:
      b[i] = 1
      count += 1
      ans.append(int(i))
ans.sort()
print(count)
print(' '.join(map(str, 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(2*i+1,n,i+1):
    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=tuple(map(int,input().split()))
B=[0]*n
for i in reversed(range(n)):
    k=i+1
    l=n//k
    tmp=0
    for j in range(2,l+1):
        idx=k*j-1
        tmp^=B[idx]
    B[i]=tmp^A[i]
Ans=[]
for i,b in enumerate(B):
    if b:
        Ans.append(i+1)
print(len(Ans))
print(*Ans)

Solution (Python):
n = int(input())
a = input()
r = [None] * (n + 1)
for i in range(n, 0, -1):
    r[i] = (ord(a[2 * i - 2]) + sum(r[i * 2::i])) % 2
print(r.count(1))
print(*(i for i, x in enumerate(r) if x))

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

Solution (Python):
n = int(input())
a = input()
r = [None] * (n + 1)
for i in range(n, 0, -1):
    r[i] = (ord(a[2 * i - 2]) ^ sum(r[i * 2::i])) % 2
print(r.count(1))
print(*(i for i, x in enumerate(r) if x))

Solution (Python):
n = int(input())
a = input()
r = [None] * (n + 1)
for i in range(n, 0, -1):
    r[i] = (ord(a[2 * i - 2]) + sum(r[i * 2::i])) % 2
print(r.count(1))
print(*(i for i, x in enumerate(r) if x))

Solution (Python):
n = int(input())
a = input()
r = [None] * (n + 1)
for i in range(n, 0, -1):
    r[i] = (ord(a[2 * i - 2]) ^ sum(r[i * 2::i])) % 2
print(r.count(1))
print(*(i for i, x in enumerate(r) if x))

Solution (Python):
def resolve():
    n = int(input())
    a = [0]
    a.extend( list(map(int,input().split())) )
    tmp = [0]*(n+1)
    ans = []
    for i in range(n,0,-1):
        sum = 0
        for j in range(i+i,n+1,i):
            sum = sum^tmp[j]
        tmp[i] = sum^a[i]
    for i in range(1,n+1):
        if(tmp[i]>0):
            ans.append(i)
    
    print(len(ans))
    s = ' '.join([str(n) for n in ans])
    print(s)

if __name__ == "__main__":
    resolve()

Solution (Python):
n = int(input())
a = input()
b = [None] * (n + 1)
r = []
for i in range(n, 0, -1):
    b[i] = (ord(a[2 * i - 2]) + sum(b[i * 2::i])) % 2
    if b[i]:
        r.append(i)
print(len(r))
print(*r)

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

Solution (Python):
import sys

def solve(N, a):
    balls = [0] * (N+1)
    for i in range(N, 0, -1):
        s = sum([ balls[j] for j in range(i, N+1, i) ])
        if s % 2 != a[i]:
            balls[i] = 1

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

    print(len(ans))
    for x in ans:
        print(x, end=' ')


def main():
    N = int(input())
    a = list(map(int, input().split()))
    a.insert(0, [])
    solve(N, a)


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
a = [0] + list(map(int, input().split()))
for i in range(n // 2, 0, -1):
    a[i] = sum(a[i::i]) % 2

s = [i for i, b in enumerate(a) if b]
print(len(s))
print(*s)

Solution (Python):
import sys

def count(c,num,N):
        x = 0
        for i in range(num*2,N+1,num):
                x += c[i]
        return x%2


N = int(input())
b = input()
a = list(b.split())
a = [int(s) for s in a]
a = [-1] + a

c = [0 for i in range(N+1)]
if max(a) == 0:
        print("0")
        sys.exit()
for i in range(N,0,-1):
        if i > N//2:
                c[i] = a[i]
        else:
                x = count(c,i,N)
                if a[i] != x: c[i] = 1


print(sum(c))
f = 1
for i in range(1,N+1):
        if c[i]:
                if f:
                        print("{}".format(i),end="")
                        f = 0
                else: print(" {}".format(i),end="")
print()

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

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

for i in reversed(range(n//2)):
    sum_ball = 0
    for j in range(1, n//(i+1)):
        sum_ball += ball[(i+1)*(j+1)-1]
    if sum_ball % 2 != a[i]:
        ball[i] = 1

index = [i+1 for i, x in enumerate(ball) if x == 1]
l = len(index)
print(l)
if l > 0:
    print(" ".join(map(str, index)))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
B = [0]*(N+1)
x = []
for n in range(N):
  if (sum(B[::N-n]))%2!=A[N-n-1]:
    B[N-n]=1
    x.append(str(N-n))
print(len(x),'\n',' '.join(x))

Solution (Python):


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

boxes = [0] * n

for i in range(n):
    x = n - i - 1
    if A[x]:
        if sum(boxes[k] for k in range(x, n, x+1)) % 2 == 0:
            boxes[x] = 1
    else:
        if sum(boxes[k] for k in range(x, n, x+1)) % 2 == 1:
            boxes[x] = 1
print(boxes.count(1))
if sum(boxes):
    print(' '.join(map(str, (i+1 for i, b in enumerate(boxes) if b == 1))))

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


M = 0
b = [0 for i in range(N)]
b.insert(0, -1)
for i in reversed(range(1, N + 1)):
    num = 0
    for j in range(1, N // i + 1):
        num ^= b[j * i]
    b[i] = a[i] ^ num

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

Solution (Python):
N = int(input())
As = [int(i) for i in input().split(" ")]
Bs = [0 for _ in range(N)]
for i in reversed(range(N)):
  s = 0
  for j in range(i, N, i+1):
    s += Bs[j] 
  Bs[i] = (s % 2) ^ As[i] 
print(len([b for b in Bs if b == 1]))
for i, b in enumerate(Bs):
    if b == 1:
       print(i + 1, end=" ")

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]
N = int(input())
A = list(map(int, input().split()))

chk = [0]*N

A.reverse()
for i, a in enumerate(A):
    if i+1 <= N//2:
        if a:
            chk[N-i-1] = 1
    else:
        sum_chk = sum(chk[N-i-1::N-i])
        s2 = sum_chk%2
        if a:
            if s2 == 0:
                chk[N-i-1] = 1
        else:
            if s2 == 1:
                chk[N-i-1] = 1

M = sum(chk)
b = [i+1 for i, v in enumerate(chk) if v==1]
print(M)
if M != 0: print(*b)

Solution (Python):
N=int(input())
box=[0]*N
ans=[]
a_list=list(map(int,input().split(' ')))
for i in range(N,0,-1):
    sum=0
    for j in range(1,N+1):
        
        if j*i<= N:
            sum+=box[j*i-1]
        else:
            break
    if sum%2 != a_list[i-1]:
        box[i-1]=1
        ans.append(str(i))
sum=0
print(len(ans))
print(" ".join(ans))

Solution (Python):
N = int(input())
l = list(map(int,input().split(' ')))
mid = N // 2
MAP = [0]*N
ans_l = []

for i in range(N,0,-1):
    s = N // i + 1
    t = 0
    for j in range(1,N+1):
      if i*j<=N:
        t += MAP[i*j-1]
      else:
        break
    if t%2 != l[i-1]:
        ans_l.append(str(i))
        MAP[i-1] = 1
leng = len(ans_l)
print(leng)
print(" ".join(ans_l))

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

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]
N = int(input())
A = list(map(int, input().split()))

chk = [0]*N

A.reverse()
for i, a in enumerate(A):
    if i+1 <= N//2:
        if a == 0:
            continue
        else:
            chk[N-i-1] = 1
            continue
    else:
        sum_chk = sum(chk[N-i-1::N-i])
        s2 = sum_chk%2
        if a == 0:
            if s2 == 0:
                continue
            else:
                chk[N-i-1] = 1
                continue
        else:
            if s2 == 0:
                chk[N-i-1] = 1
                continue
            else:
                continue

M = sum(chk)
b = [i+1 for i, v in enumerate(chk) if v==1]
print(M)
if M != 0: print(*b)

Solution (Python):
import sys

input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
a = [None] + a
a = tuple(a)

ans = set()
cnt = [0] * (n + 1)

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

        st = set()
        j = 1
        while j * j <= i:
            if i % j == 0:
                st.add(j)
                st.add(i // j)
            j += 1
        for d in st:
            cnt[d] += 1

print(len(ans))
print(*ans)

Solution (Python):
def get_divisor(n):
    a,b = [],[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            a.append(i)
            b.append(n//i)
    if a[-1]==b[-1]:b.pop()
    a.extend(b[::-1])
    return a

N = int(input())
*A, = map(int,input().split())
D = [0]*(N+1)
ans = []
for i in range(N,0,-1):
    if D[i]%2 != A[i-1]:
        ans.append(i)
        for j in get_divisor(i):
            D[j]+=1
print(len(ans))
print(*ans)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
 
ball = [0] * N
 
 
if a[-1] == 1:
        ball[-1] = 1
 
for i in reversed(range(N-1)):
        tmp = 0
        if i != 0:
                for j in range(i + (i + 1), N, i + 1):
                        
                        if (j + 1) % (i + 1) == 0:
                                tmp += ball[j]
        else:
                tmp = sum(ball[1:])
        
        if tmp % 2 != a[i]:
                ball[i] = 1
 

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

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

Solution (Python):
import math
import copy
import numpy as np

n = int(input())
a = [int(i) for i in input().split()] 
x = a
num_list = []

i = n
while i > math.ceil(n/2):
  if a[i-1] == 1:
    num_list.append(i)
  i -= 1

i = math.ceil(n/2)
while i > 0:
  count = 0
  tmp = [x[i] for i in range(2*i-1, n, i)]
  s = sum(tmp)%2
  if a[i-1] == s:
    x[i-1] = 0
  else:
    x[i-1] = 1
    num_list.append(i)
  i -= 1

l = (len(num_list))

if l == 0:
  print(0)
else:
  print(l)
  print(' '.join([str(n) for n in num_list]))

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

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

print(len(res))
print(*res)

Solution (Python):
def get_divisor(n):
    if n==1:return [1]
    a = [1]
    b = [n]
    for i in range(2,int(n**0.5)+1):
        if n%i==0:
            a.append(i)
            b.append(n//i)
    if a[-1]==b[-1]:b.pop()
    a.extend(b[::-1])
    return a

N = int(input())
*A, = map(int,input().split())
D = [0]*(N+1)
ans = []
for i in range(N,0,-1):
    if D[i]%2 != A[i-1]:
        ans.append(i)
        for j in get_divisor(i):
            D[j]+=1
print(len(ans))
print(*ans)

Solution (Python):

import sys
INF = float("inf")

MOD = 2  


import math
import collections


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

    c = [i+1 for i, val in enumerate(b) if val % 2 > 0]
    print(len(c))
    if len(c) != 0:
        print(*c, sep=" ")
    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):
def add(n):
    return n + 1

if __name__ == "__main__":
    n = int(input())
    buf = input().split()
    a = [int(s) for s in buf]
    
    boxes = [0] * n

    for i in reversed(range(n)):
        pick_boxes = boxes[i::i+1]
        pick_boxes.pop(0)
        if pick_boxes:
            if (sum(pick_boxes) % 2) == a[i]:
                boxes[i] = 0
            else:
                boxes[i] = 1
        else:
            boxes[i] = a[i]

    box_name = [i for i, x in enumerate(boxes) if x == 1]
    box_name = list(map(add, box_name))
    print(len(box_name))
    if len(box_name) != 0:
        box_name = ' '.join(map(str,box_name))
        print(box_name)

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
b=[0 for i in range(N)]
c=[]
A=0
B=0
for i in range(N):
    s=N//(N-i)
    p=1
    while p<=s:
      if b[(N-i)*p-1]==1:
        A+=1
      p+=1
    p=1
    if (A-a[N-1-i])%2==0:
      b[N-1-i]=0
    elif (A-a[N-1-i])%2==1:
      b[N-1-i]=1
    A=0
for i in range(N):
  if b[i]==1:
    B+=1
    c+=[i+1]
c=[c]
print(B)
print(*c[0])

Solution (Python):
import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))


def divisors(n):
    d = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            d.append(i)
            if i != n // i:
                d.append(n//i)
    
    return d

def main():
    N = i2n()
    A = i2nn()
    X = [0] * N
    Y = [0] * N
    for i in range(N, 0, -1):
        t = (A[i-1] + X[i-1]) % 2
        if t > 0:
            Y[i-1] = 1
            dd = divisors(i)
            for d in dd:
                X[d-1] += t
    B = []
    for i, y in enumerate(Y):
        if y > 0:
            B.append(i+1)
    M = len(B)
    print(M)
    for i, b in enumerate(B):
        print(b, end=' ')
    print()

main()

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

if len(set(A)) == 1 and A[0] == 0:
  print(0)
else:
  ans = [0]*N
  ans[N//2:] = A[N//2:]
  for i in range(N//2):
    j = N//2 - i
    check = 0
    for n in range(N//j):
      check += ans[j*(n+1)-1]
    ans[j-1] = 1 if (check%2 != A[j-1]) else 0
  ans = [i for i,x in enumerate(ans) if x==1]
  print(len(ans))
  print(' '.join([str(n+1) for n in ans]))

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
half=int(N/2)
ans=[-1]*N

for i in range(half, N):
    ans[i]=a[i]
for i in range(half-1, -1, -1):
    s=0
    j=i+(i+1)
    while j<N:
        s^=ans[j]
        j+=(i+1)
    ans[i]=s^a[i]

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

Solution (Python):
N = int(input())
a_list = [int(x) for x in input().split()]
cnt = 0
b_list = set()
for i in range(len(a_list), 0, -1):
    tmp = 0
    for j in range(i*2, N+1, i):
        tmp ^= (j in b_list)
    if (tmp != a_list[i-1]):
        b_list.add(i)
M = len(b_list)
print(M)
if (M>0):
    print(" ".join([str(b) for b in b_list]))

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

for i in range(n):
    k = int(n-i-1)
    if a_list[k] != sum(b_list[k::k+1])%2:
        b_list[k] = 1

b_list = [i+1 for i,x in enumerate(b_list) if x ==1]
x = len(b_list)
print(x)
if x != 0:
    print(*b_list)

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
    ans[-1] = al[-1]

    for i in range(n-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 = [i + 1 for i in range(len(ans)) if ans[i] == 1]
        print(' '.join(map(str, boxes)))


if __name__ == '__main__':
    main()

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

b=[0]*n

for i in range(1,n+1):
    now=n-i+1
    tmp=0
    j=now+now
    while(j<=n):
        if b[j-1]==1:
            tmp+=1
        j+=now
    tmp=tmp%2
    if tmp==a[now-1]:
        pass
    else:
        b[now-1]=1

anscount=0
ans=[]
for i in range(n):
    if b[i]==1:
        anscount+=1
        ans.append(i+1)
print(anscount)
print(" ".join(map(str,ans)))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
B = [0]*(N+1)
x = []
 
for n in range(N):
  i = N-n
  BB = B[::i]
  if (sum(BB))%2 == A[i-1]:
    B[i] = 0
  else:
    B[i] = 1
    x.append(str(i))
  
print(len(x))
print(' '.join(x))

Solution (Python):
N = int(input())
aN = [ int(i) for i in input().split() ]
bN = [0] * N

for i in range(N, 0, -1):
    if sum(bN[i-1: :i]) % 2 != aN[i - 1]:
        bN[i-1] = 1

print(sum(bN))
if sum(bN) != 0:
    print(*[i+1 for i, b in enumerate(bN) if b == 1])

Solution (Python):
n = int(input())
aa = list(map(int, input().split()))
balls = {}
ai = {}
for i in range(len(aa)):
    if aa[i] == 1:
        ai[i + 1] = 1
    else:
        ai[i + 1] = 0


for i in range(n, 0, -1):
    parity = 0
    k = 1
    while k * i <= n:
        if k * i in balls:
            parity ^= 1
        k += 1
    if parity != ai[i]:
        balls[i] = True

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

Solution (Python):
import math

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

def box_sum(a):
    s = 0
    for i in range(1,a):
        s = s + b[(i+1)*(N-k)-1]
    return s

for k in range(N):
    c = N//(N-k)
    if c==1:
        b[N-1-k] = a[N-1-k]
    else:
        s = box_sum(c)
        if s%2==a[N-1-k]%2:
            b[N-1-k] = 0
        else:
            b[N-1-k] = 1
print(b.count(1))
box_num = [i for i,x in enumerate(b) if x == 1]
for d in range(b.count(1)):
    print(box_num[d]+1)