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

import sys

MOD = 2  

def solve(N: int, a: "List[int]"):
    def isodd(ai: int):
        flag = False
        hoge = N // ai

        while True:
            if hoge == 1:
                break
            if ans[ai * hoge -1]:
                flag = not flag
            hoge = hoge - 1
        return flag

    sum = 0
    num = []
    ans = [0] * N

    for i in reversed(range(1, N+1)):
        odd = isodd(i)
        write = not (odd == a[i-1])

        if write:
            sum = sum + 1
            num.append(i)
            ans[i-1] = 1

    print(sum)
    if sum != 0:
        print(' '.join(map(str, num)))
    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):
N = int(input())
a = [int(x) for x in input().split()]
b = [0]*N
for i in range(N-1,-1,-1):
    if a[i] != sum([b[x] for x in range(i,N,i+1)]) % 2:
        b[i] = 1
print(b.count(1))
if b.count(1) != 0:
    print(" ".join([str(x+1) for x in range(N) if b[x]==1]))

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

a.reverse()
check = [0 for _ in range(N + 1)]
ball = []
for i in range(N):
  if check[N - i] % 2 != a[i]:
    ball.append(N - i)
    div = make_divisors(N - i)
    for d in div:
      check[d] += 1

print(len(ball))
for i in range(len(ball)):
  print(ball[i], end = "")
  if i != len(ball) - 1:
    print(" ", end = "")
  else:
    print()

Solution (Python):
N = int(input())
As = list(map(bool, map(int, input().split())))
As.insert(0, False)
Ans = [False for _ in range(N + 1)]
Ans[N] = As[N]
for i in range(N - 1, 0, -1):
    p = i * 2
    s = False
    while p <= N:
        s ^= Ans[p]
        p += i
    Ans[i] = s ^ As[i]
M = sum(Ans)
print(M)
if M > 0:
    c = True
    for i in range(1, N + 1):
        if Ans[i]:
            if c:
                c = False
            else:
                print(" ", end="")
            print(i, end="")
    print("")

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(n // 2, 0, -1):
    s = sum(b[(i*2)-1:n:i])
    b[i - 1] = (s % 2) ^ a[i - 1]
    
print(sum(b))
ans = ""
for i in range(n):
    if b[i] == 1:
        ans = ans + "{} ".format(i + 1)
print(ans.strip())

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
B = [0]*N
for i, a in enumerate(A[::-1]):
    if N - i > N // 2:
        B[-(i+1)] = 1 if a == 1 else 0
    else:
        x = N-i
        n = 2
        c = 0
        while N >= x*n:
            if B[x*n-1] == 1:
                c += 1
            n += 1
        if c % 2 == 1:
            B[-(i + 1)] = 0 if a == 1 else 1
        else:
            B[-(i + 1)] = 1 if a == 1 else 0

M = B.count(1)
if M:
    ans = []
    print(M)
    for i, v in enumerate(B):
        if v == 1:
            ans.append(i+1)
    print(*ans)
else:
    print(0)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
AS=[0]*N
ans=[]
div=N//2
div
j=1
for i in reversed(range(N)):
    if i+1 <= div:
        j=N//div
        div=N//(j+1)
    at=0
    for jt in range(j):
        at+=AS[(i+1)*(jt+1)-1]
    if at%2!=A[i]:
        ans.append(i+1)
        AS[i]=1

ans.reverse()
print(len(ans))
for i in ans:print(str(i)+' ',end="")

Solution (Python):
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque

from itertools import product

from itertools import permutations

from itertools import combinations

from itertools import accumulate
from bisect import bisect_left, bisect_right

import re




def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 



N = i_inpl()
A = l_inpl()

ans = [0] * N
flag = True
for i in range(N)[::-1]:
    num = i+1
    cnt = N//num
    if cnt == 1:
        ans[i] = A[i]
    else:
        tmp = 0
        for j in range(1, cnt+1):
            tmp += ans[j*num-1]
        tmp %= 2
        if tmp == A[i]:
            ans[i] = 0
        elif tmp != A[i]:
            ans[i] = 1
        else:
            flag = False
            break
if flag:
    print(sum(ans))
    l = []
    for ind, i in enumerate(ans):
        if i != 0:
            l.append(str(ind+1))
    if sum(ans) != 0:
        print(" ".join(l))
else:
    print("-1")

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

b_s = [0 for _ in range(n)]
for i in range(n - 1, -1, -1):
  name = i + 1
  m_sum = a_s[i]
  for m_name in range(2 * name, n + 1, name):
    m = m_name - 1
    m_sum += b_s[m]
  b_s[i] = m_sum % 2

b_s_in = [str(i + 1) for i in range(n) if b_s[i] > 0]
print(len(b_s_in))
print(" ".join(b_s_in))

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

dp = [-1] * (n+1)
cnt = n
tmp = 0
s = -1


for i in range(1,n+1):
    for j in range(0,n+1,cnt):
        if j == 0:
            continue
        if s == -1:
            s = j
        if dp[-i] == -1:
            dp[-i] = li[j]
        tmp += dp[j]
        
    
    if tmp%2 != li[s]:
        tmp -= dp[s]
        dp[s] = (li[s]+1)%2
        tmp += dp[s]
        if tmp%2 != li[s]:
            print(-1)
            exit()
    cnt -= 1
    tmp = 0
    s = -1


print(dp.count(1))
ans = list([i for i,x in enumerate(dp) if x == 1])
print(*ans)

Solution (Python):
import math

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

flag = 0
s = sum(a)
if s == 0:
    print("0")
    exit()

for i in range(N, 0, -1):
    i_max = math.floor(N / i)

    if i_max == 1:
        l[i] = a[i]
    else:
        tmp = 0
        for j in range(i_max, 1, -1):
            tmp += l[i * j]


        if tmp % 2 == a[i]:
            l[i] = 0
        else:
            l[i] = 1

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

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

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

ans = sum(A)
print(ans)
if ans > 0:
    print(*[i+1 for i, a in enumerate(A) if a == 1], sep=" ")

Solution (Python):
from copy import deepcopy
n = int(input())
A = list(map(int,input().split()))
AA = deepcopy(A)
f = [0]*n
m = 0
b = []
for i in range(n-1,0,-1):
    if A[i]%2==0:
        continue
    b.append(i+1)
    m += 1
    for k in range(1,int((i+1)**0.5)+1):
        if (i+1)%k == 0:
            if(k-1!=(i+1)//k-1):
                A[k-1] -= 1
                A[(i+1)//k-1] -= 1
                f[k-1] += 1
                f[(i+1)//k-1] += 1
            else:
                A[k-1] -= 1
                f[k-1] += 1

if f[0]%2 !=AA[0]%2:
    b.append(1)
    m += 1
for i in range(1,n):
    if f[i]%2 != AA[i]:
        print(-1)
        exit()
print(m)
if m==0:
    exit()
print(*b)

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


blist = []
for j in range(n-1,-1,-1):
    k=j+1
    count= 0
    while k<=n:
        count = count + b[k-1]
        k = k+j+1
    if a[j] == 1:
        if (count)%2 == 0:
            b[j] = 1
            blist.append(j+1)
    else:
        if (count)%2 == 1:
            b[j] = 1
            blist.append(j+1)

sb = sum(b)
print(sb)
strb = " ".join(map(str,blist))
print(strb)

Solution (Python):
n = int(input())
a = tuple(map(int, input().split()))
b = [0] * n
ret = 0
ret2 = []
append = ret2.append
for i in range(n, 0, -1):
  count = 0
  for j in range(i+i, n+1, i):
    count += b[j-1]
  
  if not (count % 2) == a[i-1]:
    b[i-1] = 1
    ret += 1
    append(i)


print(ret)
if ret == 0:
  exit()



for i in range(n):
  if b[i] == 1:
    print('%d ' % (i+1), end="")

Solution (Python):
n = int(input())
lis = [0]
lis2 = list(map(int,input().split()))
lis_a = lis+lis2
if n %2 ==0:
    flag_a = [0] * (int(n/2)+1)
    for i in range(int(n/2),n):
        flag_a.append(lis_a[i+1])
else:
    flag_a = [0] * (int(n//2)+1)
    for i in range((n//2),n):
        flag_a.append(lis_a[i+1])
for i in range((n//2),0,-1):
    temp_sum = 0
    j = 2
    while (i*j <=n):
        temp_sum += flag_a[i*j]
        j += 1
    if temp_sum % 2 == 0:
        if lis_a[i] == 1:
            flag_a[i] = 1
        else:
            flag_a[i] = 0
    else:
        if lis_a[i] == 1:
            flag_a[i] = 0
        else:
            flag_a[i] = 1

print(flag_a.count(1))
anslis = []
for i in range(n+1):
    if flag_a[i] == 1:
        anslis.append(i)
strin = ""
for item in anslis:
    strin += str(item) + " "
if len(anslis):
    print(strin)

Solution (Python):
import copy

N = int(input())

a = [int(x) for x in input().split()]
b = copy.copy(a)

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



ret = []
for i in range(N):
    if b[i] == 1:
        ret.append("{}".format(i+1))
print(len(ret))
print(" ".join(ret))

Solution (Python):
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    As = [int(x) for x in stdin.readline().rstrip().split()]
    result = [0 for _ in range(N)]
    for i, a in enumerate(As[::-1]):
        num = N - i
        idx = num - 1
        if N // num < 2:
            result[idx] = a
        else:
            sum_ = 0
            cnt = 2
            while True:
                if N < (num * cnt):
                    break
                sum_ += result[(num * cnt) - 1]
                cnt += 1
            if sum_ % 2 == 1:
                result[idx] = 1 if a == 0 else 0
            else:
                result[idx] = 0 if a == 0 else 1
    print(len([x for x in result if x == 1]))
    for i, x in enumerate(result):
        if x == 1:
            print(i + 1, end=' ')


if __name__ == "__main__":
    main()

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

for i in reversed(range(1,N+1)):
  c = N//i
  if c==1:
    if a[i-1]==1:
      ans[i-1]=1
  else:
    d = 0
    for j in range(2,c+1):
      d += ans[i*j-1]
    ans[i-1]=(d+a[i-1])%2

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

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

for i in range(n, 0, -1):
    
    
    t = 0
    for j in range(0, n // i):
        
        t += res[ ((j+1) * i) -1]

    

    if t % 2 == 1:
        if dat[i-1] == 1:
            res[i-1] = 0
        else:
            res[i-1] = 1
    else:
        if dat[i-1] == 1:
            res[i-1] = 1
        else:
            res[i-1] = 0

    
    



c = 0
for i in range(n):
    if res[i] == 1:
        c += 1

resl = []
resc = c
for i in range(n):
    if c == 0:
        break
    if res[i] == 1:
        c -= 1
        resl.append(str(i + 1))
    else:
        pass
        

print( resc )
if resc !=0:
    print(" ".join(resl))

Solution (Python):
import sys

import math

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

ball_arr = [0] * N

for i in range(math.floor(N/2), N):
    ball_arr[i] = a[i]
    


for i in reversed(range(math.floor(N/2))):
    
    
    
    
    mul_arr = ball_arr[i::i+1]
    
    if sum(mul_arr) % 2 != a[i]:
        
        if 0 in mul_arr: 
            ball_arr[(mul_arr.index(0)+1)*i] = 1
        else:
            print(-1)
            sys.exit()
    
    


M = sum(ball_arr)
print(M)
for i, v in enumerate(ball_arr):
    if v == 1:
        print(i+1, end=' ')

Solution (Python):
import sys
input = sys.stdin.readline
import collections
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
N = int(input())
a = list(int(i) for i in input().split())
ans_list = []
ans = 0
for i in range(N):
	if a[N-1-i] == 1:
		ans += 1
		ans_list.append(N-i)
		chk = make_divisors(N-i)
		for j in range(len(chk)):
			a[chk[j]-1] = (1+a[chk[j]-1])%2
print(ans)
if len(ans_list) != 0:
	print(*ans_list)

Solution (Python):
n=int(input())
ls=list(map(int,input().split()))
count_ls=[0]*n
answers=[]
m=0

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.remove(n)
    return divisors

for i in range(n,0,-1):
    plus_flag=False
    idx=i-1
    if count_ls[idx]%2!=ls[idx]:
        plus_flag=True
        m+=1
        answers.append(i)
    if plus_flag:
        divisors=set(make_divisors(i))
        for j in divisors:
            j_idx=j-1
            count_ls[j_idx]+=1

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

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

n = int(input())
a = list(map(int, input().split()))
b = [0]*n
for i in range(n, 0, -1):
    temp = 0
    if n//i == 1:
        b[i-1] = a[i-1]
    else:
        for j in range(2, n+1):


            if i*j > n:
                break
            temp += b[i*j-1]
        if a[i-1] == 1:
            b[i-1] = 1 - temp%2
        else:
            b[i-1] = temp%2
print(sum(b))
for i in range(n):
    if b[i] == 1:
        print(i+1, "", end="")
print()

Solution (Python):
from sys import stderr
N = int(input())
A = [int(i) for i in input().split()]

B = [0] * N

for i in range(N // 2, N):
    B[i] = A[i]

for i in reversed(range(N // 2)):
    s = sum(B[i::i + 1])
    B[i] = (A[i] - s) % 2

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

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
B = [0]*N
n = N
for a in (reversed(A)):
    if n*2 > N:
        B[n-1] = a
        n -= 1
        continue
    total = 0
    for i in range(2,N+2):
        if n*i <= N:
            total += B[n*i-1]
        else:
            if a == total % 2:
                B[n-1] = 0
            else:
                B[n-1] = 1
            break
    n -= 1

M = sum(B)
print(M)
C = [str(n+1) for n, v in enumerate(B) if v == 1]
print(' '.join(C))

Solution (Python):

import math
import sys

def solve(N: int, a: "List[int]"):
    dp = [0] * N
    for i in range(N, 0, -1):
        if i > N // 2:
            dp[i-1] = a[i-1]
        else:
            for j in range(2, N // i+1):
                dp[i-1] += dp[j * i - 1]
            dp[i-1] += a[i-1]
            dp[i-1] %= 2
    print(sum(dp))
    s = []
    for i in range(N):
        if dp[i] == 1:
            s.append('%d' % (i + 1))
    if len(s) > 0:
        print(' '.join(s))
    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):
N = int(input())
a_list = [int(i) for i in input().split()]
ans = ""
ans_list = [0]*N
for i in range(N, 0, -1):
  sum_ = 0
  for j in range(1, N//i+1):
    if j == 1:
      sum_ += ans_list[i*j-1]
    sum_ += ans_list[i*j-1]
    sum_ %= 2
  if sum_ != a_list[i-1]:
    ans_list[i-1] = 1

for i in range(N, 0, -1):
  sum_ = 0
  for j in range(1, N//i+1):
    sum_ += ans_list[i*j-1]
    sum_ %= 2
  if sum_ != a_list[i-1]:
    print(-1)
    exit()

for i, a in enumerate(ans_list):
  if a == 1:
    ans += str(i+1) + " "
print(sum(ans_list))
if ans:
  print(ans[:-1])

Solution (Python):
N = int(input())
a = list(map(int,input().split()))
b = [None for _ in range(N)]
for i in range(N):
    j = N-i
    if j > N//2:
        b[j-1] = a[j-1]
    else:
        s = 0
        for k in range(2*j-1, N, j):
            s = (s+b[k])%2
        b[j-1] = (a[j-1]-s) % 2
ans = []
for i in range(N):
    if b[i] == 1:
        ans.append(i+1)
if ans == []:
    print(0)
else:
    print(len(ans))
    print(" ".join(map(str, ans)))

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

b = []
start = n // 2 + 1
end = n
num = [0] * n
while True:
    if start > end:
        break
    else:
        for i in range(end, start - 1, -1):
            if a[i - 1] != num[i - 1]:
                b.append(i)
                divisors = make_divisors(i)
                for j in divisors:
                    a[j - 1] += 1
                    a[j - 1] %= 2
        end = start - 1
        start = end // 2 + 1
b.sort()
print(len(b))
if len(b) >= 2:
    print(" ".join(map(str, b)))
elif len(b) == 1:
    print(b[0])
else:
    pass

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

ans = {}

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

    if len(b) > 1:
        for n in b[1:]:
            cnt += ans[n-1]
        tmp = cnt % 2
        if tmp == 0:
            ans[i] = li[i]
        else:
            ans[i] = (li[i] + 1)%2 
    else:
        ans[i] = li[i]
        
print(sum(ans.values()))
answer = [ str(i+1) for i in ans.keys()  if ans[i] == 1]
print(" ".join(answer))

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
    su = 0
    
    
    for j in range(i,i*k+i,i):
        su += ANS[j-1]
    if (su%2)!=A[i-1]:
        ANS[i-1] += 1



print(sum(ANS))
for i in range(len(ANS)):
    if ANS[i]==1:
        print(i+1)

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

a = list(map(int, input().split()))
b = [0] * N
flag = True

for k in range(N):
    i = N - k
    count = 0
    for m in range(i, N + 1, i):
        count += b[m - 1]

    if count % 2 == a[i - 1]:
        pass
    elif (count + 1) % 2 == a[i - 1]:
        b[i - 1] = 1
    else:
        print(-1)
        flag = False
        break

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

Solution (Python):
if __name__ == '__main__':
    n = int(input())
    a = [int(s) for s in input().split()]
    b = [0] * n
    for i in range(n, 0, -1):
        b[i - 1] = a[i - 1]
        j = i + i
        while j <= n:
            b[i - 1] ^= b[j - 1]
            j += i
    m = b.count(1)
    print(m)
    if m:
        print(*(i + 1 for i, x in enumerate(b) if x))

Solution (Python):
from sys import stdin
N = int(stdin.readline().rstrip())
data = [int(x) for x in stdin.readline().rstrip().split()]
data = [0] + data
ans = [0] * (N+1)
for i in range(N,0,-1):
    if data[i] == 1 and sum(ans[::i]) % 2 == 0: 
        ans[i] = 1
    elif data[i] == 0 and sum(ans[::i]) % 2 != 0:
        ans[i] = 1
print(sum(ans))
for ind,k in enumerate(ans):
  if k != 0:
    print(ind,end=" ")

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

    
    return divisors

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

a.insert(0, -1)

env = [0] * (n+1)
hako = [0] * (n+1)
ind = []

for _ in range(n):
    i = n - _
    if a[i] != env[i]:
        hako[i] = 1
        ind.append(str(i))
        yakusuu = make_divisors(i)
        for j in yakusuu:
            if env[j] == 0:
                env[j] = 1
            else:
                env[j] = 0

goukei = sum(hako)
print(goukei)
if ind != []:
    mojiretu = ' '.join(ind)
    print(mojiretu)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
ans = []
temp = [0]*n
for i in range(n):
    x = n-i
    y = 0
    for j in range(n):
        if x*(j+2) <= n:
            if temp[x*(j+2)-1] == 1:
                y += 1
        else:
            break
    if not y%2 == a[x-1]:
        ans.append(x)
        temp[x-1] += 1
s = len(ans)
print(s)
if s > 0:
    print(" ".join([str(i) for i in ans]))

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

for i in range(n, 0, -1):
  f = 0
  for j in range(i, n + 1, i):
    f = f ^ b[j-1]
  b[i-1] = a[i-1] ^ f

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 = [int(x) for x in input().split()]

ans_flag = False
B =[0]*N
B[N//2:] = A[N//2:]
for idx in list(reversed(range(N//2))):
  sum_bai = sum(B[idx::idx+1]) % 2
  
  if A[idx] == 0:
    if sum_bai == 0:
      B[idx] = 0
    else:
      B[idx] = 1
  else:
    if sum_bai == 0:
      B[idx] = 1
    else:
      B[idx] = 0
      
M = sum(B)
B_ans = [idx+1 for idx in range(N) if B[idx] == 1]
print(M)
print(' '.join(list(map(str, B_ans))))

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

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

Solution (Python):
N=int(input())
A=[0]+[int(_) for _ in input().split()]
ans=[0]*(N+1)
result=[]
for i in range(N,0,-1):
    bai=N//i
    if A[i]!=sum(ans[i*b] for b in range(2,bai+1))%2:
        ans[i]=1
        result+=[i]
print(len(result))
print(*result)

Solution (Python):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())
a = [-1]
a.extend(list(map(int, input().split())))
ans = [0]*(n+1)


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



s = ""
c = 0
for i in range(n+1):
    if (ans[i] == 1):
        c += 1
        s += str(i)+" "
print(c)
if(c != 0):
    print(s)

Solution (Python):
import sys
n=int(input())
L=[0 for i in range(n+1)]
a=list(map(int,input().split()))
if n==1 and a[0]==1:
  print(1)
  print(1)
  sys.exit()
for i in range((n//2)+1,n+1):
  L[i]=a[i-1]
  if L[i]==1:
    for j in range(1,int(i**0.5)+1):
      if i%j==0:
        L[j]+=1
        if j*j!=i and j!=1:
          L[i//j]+=1
for i in range(n//2,0,-1):
  L[i]=(a[i-1]+L[i])%2
  if i!=1 and L[i]==1:
    for j in range(1,int(i**0.5)+1):
      if i%j==0:
        L[j]+=1
        if j*j!=i and j!=1:
          L[i//j]+=1
ct=0
for i in range(1,len(L)):
  if L[i]==1:ct+=1
print(ct)
ans=[]
for i in range(1,len(L)):
  if L[i]==1:ans.append(str(i))
print(' '.join(ans))

Solution (Python):
def solve():
    n = int(input())
    A = [0] + list(map(int, input().split()))
    for i in range(n // 2, 0, -1):
        t = len([1 for k in range(i, n + 1, i) if A[k] == 1]) & 1
        if A[i] != t:
            A[i] = 1 - A[i]
    print(sum(A))
    print(*list(i for i in range(1, n + 1) if A[i]))
solve()

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
M=0
b=[]
c=[]
for i in range(N):
    b.append(0)

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

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

print(M)
print(' '.join(c))

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

ball = [0]*(n+1)
for j in range(n//2+1, n+1):
    ball[j] = a[j-1]
for i in range(n//2, 0, -1):
    summ = 0
    for k in range(2, n+1):
        if i*k > n:
            break
        else:
            summ += ball[i*k]
    if a[i-1] == (summ%2):
        ball[i] = 0
    else:
        ball[i] = 1

print(sum(ball))
if sum(ball) > 0:
    ans = []
    for l in range(1, n+1):
        if ball[l] == 1:
            ans.append(l)
    print(' '.join(map(str, ans)))

Solution (Python):

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

b = [0 for _ in range(n)]

for i, e in enumerate(a[::-1]):
    _sum = sum(b[n-1 - i: n: n-i])
    if _sum % 2 == e:
        pass
    else:
        b[n-1 - i] = 1

ball_cnt = sum(b)
print(ball_cnt)
if ball_cnt > 0:
    boxes = [i + 1 for i, e in enumerate(b) if e == 1]
    print(" ".join(map(str, boxes)))

Solution (Python):
import sys
from math import floor

n= int(sys.stdin.readline())
a= [ int(x) for x in sys.stdin.readline().split() ]
ans= [-1]*n
c = floor(n/2) + 1
for i in range(c,n+1):
    j= i-1
    ans[j]= a[j]

for i in range(c-2,-1,-1):
    j= i+1
    s= a[i]
    for k in range(2*j,n+1,j): s+= ans[k-1]
    ans[i]= s%2

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

Solution (Python):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = [0] * N
    for i in range(N - 1, -1, -1):
        for j in range(i, N, i + 1):
            B[i] += B[j]
        if B[i] % 2 == 1:
            if A[i] == 1:
                B[i] = 0
            else:
                B[i] = 1
        else:
            if A[i] == 1:
                B[i] = 1
            else:
                B[i] = 0
    print(B.count(1))
    for i, c in enumerate(B):
        if c == 1:
            print(i + 1)


main()

Solution (Python):
N, *a = map(int, open(0).read().split())

dp = [0] * N
for i in reversed(range(N)):
    cnt = sum(dp[i::i + 1])
    if cnt % 2 == a[i]:
        dp[i] = 0
    else:
        dp[i] = 1
            
if True:
    b_bin = [i + 1 for i in range(N) if dp[i] > 0]
    print(len(b_bin))
    print(*b_bin)
else:
    print(-1)

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

cnt = 0
for i in range(1, n + 1)[::-1]:
    s = sum([l[(j + 2) * i - 1] for j in range(n // i - 1)])
    l[i - 1] = (s + a[i - 1]) % 2
    cnt += l[i - 1]

print(cnt)
ju = 0
for i, k in enumerate(l):
    if k != 0:
        if (ju == 1):
            print(" ", end="")
        if (ju == 0):
            ju = 1
        print(i + 1, end="")
if ju == 1:
    print()

Solution (Python):
import math
import sys


def nontrivial_divisors(x):
	for i in range(1, math.floor(math.sqrt(x)) + 1):
		d, m = divmod(x, i)
		if m == 0:
			if i != x:
				yield i
			if d != x:
				yield d


def solve(n, qs):
	ps = [0] 
	ps.extend(qs)
	balls = [0] * (n + 1)
	vals = [0] * (n + 1)
	divs = [set() for _ in range(n + 1)]
	for i in range(1, n // 2 + 1):
		for j in range(2, n // i + 1):
			divs[i * j].add(i)
	
	first = n // 2 + 1
	last = n
	while True:
		for i in range(first, last + 1):
			if vals[i] % 2 != ps[i]:
				balls[i] += 1
				vals[i] += 1
				for j in divs[i]:
					vals[j] += 1
		if first == 1:
			break
		last = first - 1
		first = last // 2 + 1
	for i in range(1, n + 1):
		if vals[i] % 2 != ps[i]:
			return None
	else:
		bs = [b for b in range(1, n + 1) if balls[b]]
		m = len(bs)
		return m, bs
	

def main():
	n = int(input())
	qs = [int(q) for q in input().split()]
	res = solve(n, qs)
	if res is None:
		print(-1)
	else:
		m, bs = res
		print(m)
		print(*bs)


if __name__ == "__main__":
	main()

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

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

  mod = tmp % 2
  if A[i - 1] == 0:
    if mod == 0:
      pass
    else:
      B[i - 1] = 1
      M.append(str(i))
  else:
    if mod == 0:
      B[i - 1] = 1
      M.append(str(i))
    else:
      pass

print(len(M))
if len(M) > 0:
  print(' '.join(M))

Solution (Python):
N = int(input())
a = list(map(int,input().split()))
ans = [0]*N
num_list = [list(map(lambda x: x-1,list(range(i+1,N+1,i+1)))) for i in range(N)]
for i in range(N)[::-1]:
  
  before_num = sum([ans[i] for i in num_list[i]])
  
  
  ans[i] = (before_num%2 + a[i])%2
  

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

Solution (Python):
import numpy

N = int(input())

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

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

ans = []



l = N//2

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

ind = l
for _ in range(l):
    
    
    
    ai = a[ind - 1]
    iter = N // ind - 1
    s = 0
    for j in range(1, iter+1):
        s += b[ind + j * ind - 1]
    
    if (s % 2) == ai:
        b[ind - 1] = 0
    else:
        b[ind - 1] = 1
        ans.append(ind)

    if ind == 1:
        break
    else:
        ind -= 1


m = sum(b)

print(m)

if m != 0:
    for c in ans:
        print(c, end =" ")