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 for i in range(N)]
for n in range(N):
    step = N - n
    sm = A[step-1]
    for i in range(step-1, N ,step)[::-1]:
        sm += B[i]
    B[step-1] = (sm%2)
    
print (sum(B))
C = " ".join([str(i+1) for i in range(len(B)) if B[i]])
print (C)

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

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

r=[0]*n

for i in range(n)[::-1]:
    if sum(r[i::i+1])%2 != a[i]:
        r[i]=1

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

Solution (Python):

N=int(input())
a=list(map(int,input().split())) 
a=[0]+a
b=[0 for i in range(N+1)]
for i in range(N,0,-1):
  y=2
  tmp=0
  x=i*y
  while x<N+1:
    tmp+=b[x]
    y +=1
    x=i*y
  if tmp%2!=a[i]:
    b[i]=1
    
print(b.count(1))
indexes = [i for i,x in enumerate(b) if x==1]
indexes = map(str,indexes)
if b.count(1)!=0:
  print(' '.join(indexes))

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

Solution (Python):

import numpy as np

n = int(input())
a = list(map(int, input().split()))
ret = np.zeros(n+1, dtype="int")
ret2 = []

for i in reversed(list(range(n))): 
  if sum(ret[::i+1][1:])%2 != a[i]:
    ret[i+1] = 1
    ret2.append(i+1)

print(sum(ret[1:]))
print(" ".join(list(map(str, ret2[::-1]))))

Solution (Python):

import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))
ret = [0]*(n+1)
ret2 = []

for i in reversed(list(range(n))): 
  if sum(ret[::i+1][1:])%2 != a[i]:
    ret[i+1] = 1
    ret2.append(i+1)

print(sum(ret[1:]))
print(" ".join(list(map(str, ret2[::-1]))))

Solution (Python):
import numpy as np

n = int(input())
a = list(map(int, input().split()))
ret = [0]*(n+1)
ret2 = []

for i in reversed(list(range(n))): 
  if sum(ret[::i+1][1:])%2 != a[i]:
    ret[i+1] = 1
    ret2.append(i+1)

print(sum(ret[1:]))
print(" ".join(list(map(str, ret2[::-1]))))

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

for i in reversed(list(range(n))): 
  if sum(ret[::i+1][1:])%2 != a[i]:
    ret[i+1] = 1
    ret2.append(i+1)

print(sum(ret[1:]))
print(" ".join(list(map(str, ret2[::-1]))))

Solution (Python):

import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))
ret = np.zeros(n+1, dtype="int")
tmp = list(range(n+1))
ret2 = []

for i in reversed(list(range(n))): 
  if sum(ret[::i+1][1:])%2 != a[i]:
    ret[i+1] = 1
    ret2.append(i+1)

print(sum(ret[1:]))
print(" ".join(list(map(str, ret2[::-1]))))

Solution (Python):

import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))
ret = np.zeros(n+1, dtype="int")
tmp = list(range(n+1))
ret2 = []

for i in reversed(list(range(n))): 
  if sum(ret[::i+1][1:])%2 != a[i]:
    ret[i+1] = 1
    ret2.append(i+1)

print(sum(ret[1:]))
ret2 = sorted(ret2)
print(" ".join(list(map(str, ret2))))

Solution (Python):

import numpy as np

def cout(*args):
  arglist = []
  for arg in args:
    if hasattr(arg, "__iter__"):
      arglist.extend(arg)
    else:
      arglist.append(arg)
      
  arglist = list(map(str, arglist))
  print(" ".join(arglist))

n = int(input())
a = np.array(list(map(int, input().split())))
ret = np.zeros(n+1, dtype="int")
tmp = list(range(n+1))
ret2 = []

for i in reversed(list(range(n))): 
  if sum(ret[::i+1][1:])%2 != a[i]:
    ret[i+1] = 1
    ret2.append(i+1)

print(sum(ret[1:]))
ret2 = sorted(ret2)
cout(ret2)

Solution (Python):
from collections import OrderedDict
N = int(input())
a = list(map(int, str(input()).split()))

box = OrderedDict(zip(range(N, 0, -1), [0] * N))
output = list()
count = 0
for i in box:
    mul = N // i
    total_ball = 0
    for m in range(1,mul+1):
        total_ball += box[m * i]
    if (a[i-1] == 1 and total_ball % 2 == 0) or (a[i-1] == 0 and total_ball % 2 == 1) :
        box[i] = 1
        count += 1
        output.append(str(i))
    else:
        pass

if len(output) != 0:
    print(count)
    print(' '.join(output))
else:
    print(0)

Solution (Python):
def main(n, a):
    box = [0] * n
    for i in range(n, 0, -1):
        if a[i - 1] != sum(box[i - 1 :: i]) % 2:
            box[i - 1] = 1

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


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

Solution (Python):
n = int(input())
moto = [int(i) for i in input().split()]
 
array=[0]*n
 
for i in reversed(range(1,n+1)):
  if sum(array[i-1::i])%2 != moto[i-1]:
    array[i-1] = 1
    
m = array.count(1)
print(m)
ans = ""
for i in range(n):
  if array[i] == 1:
    print(i+1, end=" ")

Solution (Python):
n = int(input())
moto = [int(i) for i in input().split()]
 
array=[0]*n
 
for i in reversed(range(1,n+1)):
  if sum(array[i-1::i])%2 != moto[i-1]:
    array[i-1] = 1
    
m = sum(array)
print(m)
ans = ""
for i in range(n):
  if array[i] == 1:
    print(i+1, end=" ")

Solution (Python):
import sys
import copy
def input():
    return sys.stdin.readline()
n = int(input())
a = [int(i) for i in 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

ans = []
tmp = []
for i,x in enumerate(reversed(a)):
  y = n-i
  if x:
    ans.append(y)
    tmp = make_divisors(y)
    for j in tmp:
      a[j-1] ^= 1
      
print(len(ans))
for i in reversed(ans):
  print(i,end=' ')

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

def zero_or_one(i):
	count = 0
	num = i+1
	while num <= N:
		count += box[num-1]
		num += i+1
	if count%2 == a[i]:
		box[i] = 0
	else:
		box[i] = 1

for i in reversed(range(N)):
	zero_or_one(i)

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

if ball == 0:
	print(0)
else:
	print(ball)
	ans = " ".join(map(str,ans))
	print(ans)

Solution (Python):
def D_PreparingBoxes():
    N = int(input())
    a = list(map(int, input().split()))
    b = [0] * N
    for x in reversed(range(N)):
        if sum(b[x::x+1]) % 2 != a[x]:
            b[x] = 1
    print(sum(b))
    for x in range(N):
        if b[x]:
            print(x+1, end=" ")

if __name__ == "__main__":
    D_PreparingBoxes()

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

Solution (Python):
N = int(input())
A = [0] + [int(s) for s in input().split()]
ball = [0] * (N + 1)
for i in range(N, 0, -1):
    ball[i] = (sum(ball[i::i]) - A[i]) % 2
ans = [i for i, v in enumerate(ball) if v == 1]
print(len(ans))
print(*ans)

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

    for i in reversed(range(1, N + 1)):
        target = N // i
        v = sum([B[i * j - 1] for j in range(1, target + 1)])
        if v % 2 != A[i - 1]:
            B[i - 1] = 1
            ans.append(i)

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


if __name__ == '__main__':
    p_d()

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

    for i in reversed(range(1, N + 1)):
        target = N // i
        v = sum([B[i * j - 1] for j in range(1, target + 1)])
        if v % 2 != A[i - 1]:
            B[i - 1] = 1
            ans.append(i)

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


if __name__ == '__main__':
    p_d()

Solution (Python):
def multiple_factors(i, N):
  factors = []
  for index in range(0, N//i):
    factors.append(int((index+1)*i))
  return factors
  
def assign_ball(factors, blist, ai, b_add_index):
  sum_b = 0
  for index in range(len(factors)-1, 0, -1):
    sum_b += blist[factors[index]-1]
  
  if ai != sum_b%2:
    blist[factors[0]-1] = 1
    b_add_index.append(str(factors[0]))
  return blist, b_add_index

      
N = int(input())
alist = list(map(int, input().split()))
blist = [0 for i in range(N)]
b_add_index = []
for i in range(N-1,-1, -1):
  factors = multiple_factors(i+1, N)
  blist, b_add_index = assign_ball(factors, blist, alist[i], b_add_index)

if sum(blist)%2 != alist[0]:
  print(-1)
else:
  print(len(b_add_index))
  print(" ".join(b_add_index))

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

    filled = [0]*(n+1)
    ans = []
    for i in range(n-1, -1, -1):
        if sum(filled[::i+1][1:]) % 2 != A[i]:
            filled[i+1] = 1
            ans.append(i+1)
    print(len(ans))
    print(' '.join(map(str, ans)))


if __name__ == '__main__':
    main()

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

filled = [0]*(n+1)
ans = []
for i in range(n-1, -1, -1):
  if sum(filled[::i+1][1:]) % 2 != A[i]:
    filled[i+1] = 1
    ans.append(i+1)
print(len(ans))
print(' '.join(map(str, ans)))

Solution (Python):

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

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

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

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

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

for i in range(N, 0, -1):
    mod = sum(b[i::i]) % 2
    if mod == a[i]:
        pass
    else:
        b[i] = 1
    
print(b.count(1))
for idx, n in enumerate(b):
    if n:
        print(idx, '', end='')

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

l = list(map(int, input().split()))
box = [0]*n
num_box = list(range(1,n+1))
x = list(reversed(range(n)))
for i in x:
    if l[i] == 1 and sum(box[i::num_box[i]])%2==0:
        box[i] += 1
    elif l[i] == 1 and sum(box[i::num_box[i]])%2==1:
        continue
    elif l[i] == 0 and sum(box[i::num_box[i]])%2==0:
        continue
    elif l[i] == 0 and sum(box[i::num_box[i]])%2==1:
        box[i] += 1

num_lis = [str(i) for i in num_box if box[i-1] == 1]
print(len(num_lis))
print(' '.join(num_lis))

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
boxes = [0 for _ in range(N)]
ans = []
for i in range(N):
    j = N-i
    count = sum([boxes[k] for k in range(j-1,N,j)])





    if count%2 != a[j-1]:
        ans.append(j)
        boxes[j-1] = 1
print(len(ans))
ans = [str(x) for x in ans]
ans = ' '.join(ans)
print(ans)

Solution (Python):



def main():
  N = int(input())
  liA = list(map(int, input().strip().split(' ')))
  boxes = [0 for _ in range(len(liA))]
  index = []
  for i in range(len(liA))[::-1]:
    sumBoxes = sum([boxes[j] for j in range(i, len(boxes), i+1)])
    if sumBoxes % 2 != liA[i]:
      boxes[i] += 1
      index += [i+1]
  print(len(index))
  print(' '.join(map(str, index)))
  pass

if __name__=='__main__':
  main()

Solution (Python):
N = int(input())
a = [int(i) for i in input().split()]
b = [0]*N
c = []
m = 0

for i in range(N-1,N//2,-1):
  if a[i] == 1:
    b[i] = 1
    c.append(i+1)
    m += 1
for i in range(N//2,-1,-1):
  sum_b = 0
  j = (i+1)*2
  while j <= N:
    sum_b += b[j-1]
    j += i+1
  if sum_b%2 != a[i]:
    c.append(i+1)
    b[i] = 1
    m += 1

print(m)
print(" ".join(map(str,c)))

Solution (Python):
def abc_134d(N, A):
	index = N
	result = [0 for _ in range(N)]

	while index > 0:
		index -= 1
		j = 2
		sumval = 0

		if (index + 1) <= N // 2:
			while (index + 1) * j <= N:
				sumval += result[(index + 1) * j - 1]
				j += 1
			result[index] = (sumval % 2 + A[index]) % 2
		else:
			result[index] = A[index]

	if 1 not in result:
		print(0)
	else:
		buf = [i + 1 for i in range(N) if result[i] == 1]
		print(len(buf))
		[print(str(val), end=" ") if i < len(buf) - 1 else print(str(val)) for i, val in enumerate(buf)]


if __name__ == "__main__":
	N = int(input())
	A = [int(val) for val in input().split()]
	abc_134d(N, A)

Solution (Python):
M = int(input())
a = list(map(int,input().split()))
a = [None]+a
b = [M-k for k in range(M)]
c = [0 for k in range(M+1)]
h = 0
for s in b:
	w = M // s
	wa = 0
	for k in range(w-1):
		wa += c[s*(k+2)]
	if wa % 2 == a[s]:
		c[s] = 0
	else:
		c[s] = 1
		h += 1
print(h)
for k in range(1,len(c)):
	if c[k] == 1:
		print(k, end=" ")

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

    for j in range(n):
        i = n - j -1
        if sum(x[i::i+1])%2 != a[i]:
            x[i] = 1
            b.add(i+1)
    cnt = len(b)

    if cnt == 0:
        print(0)
    else:
        print(cnt)
        print(*b)


resolve()

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

dp = [0 for i in range(N+1)]
ball = [0 for b in range(N+1)]

if N % 2 == 0:
    for i in range(N//2):
        ball[-i-1] = A[-i-1]
    num = N//2
else:
    for i in range(N//2+1):
        ball[-i-1] = A[-i-1]
    num = N//2


while num >= 1:
    c = num
    mod = 0
    k = 1
    while c*k <= N:
        mod += ball[c*k]
        k += 1
    if mod % 2 == 0:
        if A[num-1] == 1:
            ball[num] += 1
    else:
        if A[num-1] == 0:
            ball[num] += 1
    num -= 1

M = sum(ball)
print(M)
for i in range(N+1):
    if ball[i] != 0:
        print(i)

Solution (Python):
N = int(input())
a_ls = list(map(int,input().split(" ")))
N = [0]*N
l = len(a_ls)


for i in range(l):
    a = a_ls[-(i+1)]
    s = sum(N[(l-i)-1::(l-i)])%2
    
    
    if a != s:
        N[-(i+1)]=1
        
sen = ""
for i,n in enumerate(N):
    if n == 1:
        sen += "{} ".format(i+1)

if len(sen) == 0:
    print(0)
else:
    print(sum(N))
    print(sen[:-1])

Solution (Python):
N = int(input())
a_ls = list(map(int,input().split(" ")))
N = [0]*N
l = len(a_ls)


for i in range(l):
    a = a_ls[-(i+1)]
    s = sum(N[(l-i)-1::(l-i)])%2
    
    
    if a != s:
        N[-(i+1)]=1
        
sen = ""
for i,n in enumerate(N):
    if n == 1:
        sen += "{} ".format(i+1)

if len(sen) == 0:
    print(0)
else:
    print(sum(N))
    print(sen[:-1])

Solution (Python):

n = int(input())

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


for i in range(n-1, -1, -1):
    tmp = sum(ans[i::i+1])
    if tmp % 2 == a[i]:
        continue
    else:
        b.add(i+1)
        ans[i] = 1

cnt = len(b)


if cnt == 0:
    print(0)
else:
    print(cnt)
    print(*b)

Solution (Python):
import math as math

N = int(input())
A = list(map(int, input().split()))
ANS = [0]*len(A)
for i in range(math.floor(N/2)+1,N):
    ANS[i] = A[i]

fnum=math.floor(N/2)
for i in range(fnum,-1,-1):
    j = i + 1
    tsum=A[i]
    for k in range(j,N+1,j):
        tsum+=ANS[k-1]
    ANS[i]=tsum%2


anslist=[]
for i in range(N):
    if ANS[i]==1:
        anslist.append(i+1)
 
print(len(anslist))
for s in anslist:
    print(s, end =" ")

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

a=[0 for i in range(n)]
b=[0 for j in range(n)]
a=input().split()

bsum=0
c=[]
for i in range(n):
    index=n-i-1
    m=math.floor(n/(index+1))
    sum=0
    for j in range(m-1):
        sum+=b[(index+1)*(j+2)-1]
    b[index]=abs(sum%2-int(a[index]))
    if b[index]==1:
        c.append(index+1)
    bsum+=b[index]

print(bsum)
print(' '.join(map(str, c)))

Solution (Python):

N = int(input()) 
a = list(map(int,input().split()))
box = [0] * N 
result = []
for i in range(N-1, -1, -1):
    aisum = 0 
    for j in range(i, N, i+1):
        aisum += box[j] 
    if aisum%2  != a[i]%2: 
        box[i] = 1 
        result.append(i+1)
    else: 
        box[i] = 0 
print(len(result))
if len(result) != 0:
    print(' '.join(map(str, result)))

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

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

for i in reversed(range(1, N+1)):
    tmp = 0
    for j in range(i, N+1, i):
        tmp += ans[j-1]
    if tmp % 2 != a[i-1]:
        ans[i-1] = 1

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

print(len(anslist))
print(*anslist)

Solution (Python):

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

r = l[::-1]
ans = [0] * n
for i in range(n):
    s = 0
    for j in range(n//(n-i)):
        s += ans[n-i + j*(n-i)-1]

        
    else:
        if s%2 != l[n-i-1]:
            ans[n-i-1]+=1
            ans[n-i-1]%=2
ansL = []
R = 0
for i , a in enumerate(ans):
    if a == 1:
        R+=1
        ansL.append(i+1)
print(R)
if R >0:
    print(*ansL)

Solution (Python):

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

r = l[::-1]
ans = [0] * n
for i in range(n):
    s = 0
    for j in range(n//(n-i)):
        s += ans[n-i + j*(n-i)-1]

        
    else:
        if s%2 != l[n-i-1]:
            ans[n-i-1]+=1
            ans[n-i-1]%=2
ansL = []
R = 0
for i , a in enumerate(ans):
    if a == 1:
        R+=1
        ansL.append(i+1)
print(R)
if R >0:
    print(*ansL)

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

ans = [0 for i in range(n+1)]
for i in range(n,0,-1):
    s = 0
    for j in range(i,n+1,i): s += ans[j]
    if (s - a[i-1])%2 == 0: pass
    else: ans[i] = 1

print(sum(ans))
anss = []
for i in range(n+1):
    if ans[i] == 1: anss.append(i)
print(*anss)

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

ans = [1 for i in range(n+1)]; ans[0] = 0
for i in range(n,0,-1):
    s = 0
    for j in range(i,n+1,i): s += ans[j]
    if (s - a[i-1])%2 == 0: pass
    else: ans[i] = 0

print(sum(ans))
anss = []
for i in range(n+1):
    if ans[i] == 1: anss.append(i)
print(*anss)

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

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

print(sum(ans))
anss = []
for i in range(n+1):
    if ans[i] == 1: anss.append(i)
print(*anss)

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

ans = [0] * n

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

for i in reversed(range(n)):
    if li[i] == 1:
        ans[i] = 1
        for j in make_divisors(i+1):
            li[j-1] = (li[j-1] + 1) % 2

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

Solution (Python):

n = int(input())
a = [0] + [int(i) for i in input().split()]
retval = [0] * (n+1)

for i in range(n,0,-1):
    p = sum([retval[x] for x in range(i+i,n+1,i)])
    retval[i] = (p%2) ^ a[i]

print(sum(retval))
print(" ".join(str(i) for i in range(1,n+1) if retval[i]))

Solution (Python):

n = int(input())
a = [0] + [int(i) for i in input().split()]
b = [0] * (n+1)

for i in range(1,n+1)[::-1]:
    mul_sum = sum((b[x] for x in range(i+i,n+1,i)))
    b[i] = (mul_sum%2) ^ a[i]

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

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

for i in reversed(range(1,N+1)):
    count = 0
    total = 0
    
    for j in range(i, N+1, i):
        count += 1
        total += ans[j-1]
    
    if count == 1:
        if nums[i-1] == 0:
            ans[i-1] = 0
        else:
            ans[i-1] = 1
    
    else:
        
        if nums[i-1] == 0:
            if total % 2 != 0:
                ans[i-1] = 1
        else:
            if total % 2 == 0:
                ans[i-1] = 1



result = [i+1 for i in range(len(ans)) if ans[i] == 1]
result = [str(i) for i in result]
print(len(result))
print(" ".join(result))

Solution (Python):
N = int(input())
A = [0]+[int(x) for x in input().split()]
res = [0]*(N+1)
sum_res = 0
for i in range(N):
    
    k = N-i
    tmp = 0
    for j in range(k,N+1,k):
       	tmp += res[j]
    res[k] = A[k] ^ tmp%2
    sum_res += res[k]
 
print(sum_res)
print(' '.join([str(i) for i,x in enumerate(res) if x==1]))

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

ans = []
for i in range(n):
    if i < n//2:
        ans.append(0)
    else:
        ans.append(a[i])

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

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

Solution (Python):
n=int(input())
balls=list(map(int,input().split()))
ans=[0]*n;m=0;al=[]
for i in range(n)[::-1]:
  d=i+1
  c=n//d
  mal=2
  check=0
  while d*mal<=n:
    check+=ans[d*mal-1]
    mal+=1
  check%=2
  if check!=balls[i]:
    ans[i]=1
    al.append(str(d))
    m+=1
print(m)
print(" ".join(al))

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

B = [0] * N

out = []
for idx in range(N, 0, -1):
    a = A[idx - 1]

    q = N // idx

    cnt = 0
    for j in range(2, q + 1):
        if B[idx * j - 1] == 1:
            cnt += 1

    r = cnt % 2

    if a == 0:
        if r == 1:
            B[idx - 1] = 1
            out.append(idx)
        else:
            B[idx - 1] = 0
    else:
        if r == 1:
            B[idx - 1] = 0
        else:
            B[idx - 1] = 1
            out.append(idx)

g = sum(B)
print(g)

if g != 0:
    print(*out)

Solution (Python):
n=int(input())
A=list(map(int, input().split()))
box=[0]*n
for i in range(n-1,-1,-1):
    if n//(i+1)<=1 and A[i]==1:
        box[i]=1
    elif n//(i+1)<=1 and A[i]==0:
        pass
    elif n//(i+1)>1:
        if A[i]==sum(box[2*(i+1)-1::(i+1)])%2:
            pass
        elif A[i]!=sum(box[2*(i+1)-1::(i+1)])%2:
            box[i]=1
ans=""
cnt=0
for i in range(n):
    if box[i]==1:
        ans+=str(i+1)+" "
        cnt+=1
if cnt==sum(box):
    print(sum(box))
    print(ans)
else:print("-1")

Solution (Python):

N=int(input())
a=list(map(int,input().split()))
b_l=[1]*N
b_ll=[]
for i in range(N,0,-1):
    b_i=0
    j=i
    while j<=N:
        b_i+=b_l[j-1]
        j+=i     
    if b_i%2 != a[i-1]:
        b_l[i-1]-=1
    else:
        b_ll.append(i)
print(sum(b_l))
print(*b_ll)

Solution (Python):
N = int(input())
inf = input().split()
A = {i+1:int(inf[i]) for i in range(N)}
ans = [0 for i in range(N+1)]
keys = list(A.keys())
keys.sort(reverse=True)
for k in keys:
  count = 0
  for j in range(2*k, N+1, k)[::-1]:
    count += ans[j]
  ans[k] = (A[k]-(count%2))%2
value = sum(ans)
print(value)
if value>0:
  tag = []
  for i in range(N+1):
    if ans[i]:
      tag += [str(i)]
  print(' '.join(tag))

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

b_list = [0 for _ in range(N)]
c_list = []
for i in range(N,0,-1):
  
  tmp = sum(b_list[i-1::i]) 
  
  if tmp %2 != a_list[i-1]: 
    b_list[i-1] = 1
    c_list.append(str(i))
if len(c_list)!=0:
  print(len(c_list))
  print(" ".join(c_list))
elif all(elem == 0 for elem in a_list):
  print("0")
else:
  print("-1")

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

patternlist=[None for i in range(n)]



for i in range(n//2,n):
    if a[i]==0:
        patternlist[i]=0
    else:
        patternlist[i]=1



for i in range(0,n//2):
    i=n//2-1-i
    sumnum=0
    num=i+1
    multiply=1
    while True:
        multiply+=1
        if num*multiply>n:
            break
        sumnum+=patternlist[num*multiply-1]
        sumnum=sumnum%2
        
    if sumnum==a[i]:
        patternlist[i]=0
    else:
        patternlist[i]=1
    
        
    
print(patternlist.count(1))
for i in range(n):
    if patternlist[i]==1:
        print(i+1)

Solution (Python):
N = int(input())
A = [int(x) for x in input().split()]
B = [0 for _ in range(N)]
C = []
for i in range(N,0,-1):
    tmp = sum(B[i-1::i])
    if tmp%2!=A[i-1]:
        B[i-1] = 1
        C.append(str(i))
print(len(C))
if len(C)!=0:
    print(" ".join(C))

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

Solution (Python):



def main():
    n = int(input())
    
    a = [0] + list(map(int, input().split()))
    c = [0 for _ in range(n + 1)]

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

        
        
        for j in range(2 * i, n + 1, i):
            
            
            ball_count ^= c[j]

        
        c[i] = a[i] ^ ball_count

    
    
    ans = [index for index, ci in enumerate(c) if ci == 1]
    print(len(ans))
    print(' '.join(map(str, ans)))


if __name__ == '__main__':
    main()

Solution (Python):



def main():
    n = int(input())
    
    a = [0] + list(map(int, input().split()))
    c = [0 for _ in range(n + 1)]

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

        
        
        for j in range(2 * i, n + 1, i):
            
            
            ball_count ^= c[j]

        
        c[i] = a[i] ^ ball_count

    
    
    ans = [index for index, ci in enumerate(c) if ci == 1]
    print(len(ans))
    print(' '.join(map(str, ans)))


if __name__ == '__main__':
    main()

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


answer = []
B = 0

for i in range(N):
    U = N - i
    L = N // (U)
    if L == 1:
        answer.append(a[U-1])
    else:
        for j in range(L-1):
            t = U * (j+1)
            B += answer[-t]
        B = B % 2
        if B == a[U-1]:
            answer.append(0)
        else:
            answer.append(1)
    B = 0


k = 0



answer.reverse()
print(answer.count(1))
J = len(answer)
for i in range(J):
    if answer[i] == 1:
        print(i+1, end=' ')

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

for i in range(n,0,-1):
    tmp = sum(b[i-1::i])
    if tmp%2!=a[i-1]:
        b[i-1] = 1
        c.append(str(i))
        
print(len(c))
if len(c)!=0:
    print(" ".join(c))

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

    b[i] = tmp ^ a[i]

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

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

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

c = [i+1 for i in range(n) if b[i] == 1]
if len(c) != 0:
    print(len(c))
    print(*c)
else:
    print("0")

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

Solution (Python):
import sys

sys.setrecursionlimit(10**9)

input = sys.stdin.readline

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

for i in reversed(range(N)):
    if A[i]:
        put.append(i + 1)

        tmp = 1
        n = i + 1
        while tmp * tmp <= n:
            if n % tmp == 0:
                A[tmp - 1] ^= 1
                if tmp != n // tmp:
                    A[n // tmp - 1] ^= 1
            tmp += 1

if len(put) > 0:
    print(len(put))
    print(*put)
else:
    print(0)

Solution (Python):
a = int(input())
b = list(map(int,input().split()))
c = 0
x = []
k = [0]*a
for i in range(a-1,-1,-1):
    souwa = 0
    for j in range(i,a,i+1):
        souwa += k[j]
    if not souwa%2 == b[i]:
        k[i] = 1
        c += 1
        x.append(i+1)
print(c)
if len(x) > 0:
    for o in range(len(x)):
        print(x[o],' ',end="")

Solution (Python):
import sys, math, itertools, bisect, copy, re
from collections import Counter, deque, defaultdict






INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)









def divisor_list(n):
    ret = set()
    i = 1
    while i * i <= n:
        if n % i == 0:
            ret.add(i)
            ret.add(n // i)
        i += 1
    return ret


N = int(input())
A = [int(x) for x in input().split()]
A = [0] + A

R = []

for i in range(N, 0, -1):
    if A[i] == 1:
        R.append(i)
        dl = divisor_list(i)
        for j in dl:
            A[j] = (A[j] + 1) % 2

print(len(R))
print(" ".join([str(i) for i in R]))