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):
from collections import defaultdict, deque
import sys

sys.setrecursionlimit(100000)

MIN = -10 ** 9
MAX = 10 ** 9 + 7


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

    return divisors


def main():
    N = int(input())
    
    
    
    
    A = [int(a) for a in input().split()]

    res1 = []
    bucket = [0] * (N + 1)

    i = N
    for Ai in reversed(A):
        i -= 1
        k = i + 1
        if k * 2 > N:
            if Ai == 1:
                res1.append(k)
                bucket[k] = 1

            continue
        if k == 1:
            if len(res1) % 2 != Ai:
                res1.append(k)
            break

        s = 0
        j = 0
        while True:
            j+=1
            if j * k > N:
                break
            s += bucket[j * k]

        if s % 2 != Ai:
            res1.append(k)
            bucket[k] = 1
    print(len(res1))
    print(*res1)


if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np

def main():
    n = int(input())
    a = np.zeros([n], dtype=int)
    
    a = list(map(int, input().split(" ")))
    b = np.zeros_like(a)

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

    for i in range(1,n//2+1)[::-1]:
        if np.sum(b[i-1::i])%2 != a[i-1]:
            b[i-1] = 1

    ball = np.where(b==1)[0]
    print(len(ball))
    for i in ball:
        print(i+1, end=" ")
        
if __name__ == "__main__":
    main()

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

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

for i in range(1,N+1)[::-1]:
    tmp = 0
    for j in range(1,N//i+1):
        tmp = (tmp + X[i*j]) % 2
    X[i] = tmp ^ A[i]
print(sum(X))
[print(i) for i, a in enumerate(X) if a]

Solution (Python):
def main():
    n = int(input())
    a_s = list(map(int, input().split(' ')))
    results = [0]*n
    for i, a in enumerate(reversed(a_s)):
        idx = (n-1) - i
        if sum(results[idx::(idx+1)]) % 2 != a:
            results[idx] = 1
    print(sum(results))
    idxs = [str(i+1) for i, r in enumerate(results) if r == 1]
    if results:
        print(' '.join(idxs))


if __name__ == '__main__':
    main()

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


def main():
    _ = int(input())
    A = list(map(int,input().split()))

    M = set()
    lenA = len(A)
    for i in range(len(A))[::-1]:
        if i > lenA/2:
            if A[i] == 1:
                M.add(i+1)
        else:
            bai = set([x*(i+1) for x in range(1, int(lenA/(i+1))+1)])
            num = len(M&bai) % 2
            if A[i] != num:
                M.add(i+1)
    
    print(len(M))
    if len(M) > 0:
        print(*M)

if __name__=='__main__':
    main()

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

Solution (Python):
N=int(input())
a=[-1]+[int(i) for i in input().split()]
b=[0 for i in range(N+1)]
for i in range(1,N+1)[::-1]:
    tmp=0
    for j in range(2*i,N+1,i):
        tmp+=b[j]
    if tmp%2!=a[i]:
        b[i]=1
ans=[]
for i in range(N+1):
    if b[i]==1:
        ans.append(str(i))
print(len(ans))
print(" ".join(ans))

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
r = [None] * (n + 1)
for i in range(n, 0, -1):
    r[i] = a[i - 1] ^ 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 = [int(s) for s in input().split()]
cen = n //2
ANS = [0]*(cen)
A_p = A[cen:n]
ANS = ANS + A_p

for i in range(cen):
    part_sum = sum(ANS[cen-i-1::cen-i])
    dot = part_sum % 2
    if dot == A[cen-i-1]:
        pass
    else:
        ANS[cen-i-1] = 1

sum_ans = sum(ANS)
print(sum_ans)
if sum_ans == 0:
    pass
else:
    B = []
    for i in range(n):
        if ANS[i] != 0:
            B.append(i+1)
        else:
            pass
    BB = [str(a) for a in B]
    BB =" ".join(BB)
    print(BB)

Solution (Python):
import io
import sys


def IN_S():
  return input()


def IN_I():
  return int(input())


def IN_L_I():
  return list(map(int, input().split()))


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


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


test_str = '''
4
1 0 1 0
'''



def MAIN():
  
  A()


def A():
  n = IN_I()
  li = IN_L_I()

  tmp = [False] * n
  tmp2 = [False] * n
  for i, b in enumerate(reversed(li)):
    ci = n - i - 1
    
    if b == 1 and not tmp[ci]:
      tmp[ci] = True
      tmp2[ci] = True

    if b == 0 and tmp[ci]:
      tmp[ci] = False
      tmp2[ci] = True

    if tmp2[ci]:
      
      for j in make_divisors(ci + 1):
        if j != ci + 1:
          tmp[j - 1] = not tmp[j - 1]

    
    

  puts = [i for i, x in enumerate(tmp2) if x]
  print(len(puts))
  if len(puts) > 0:
    print(" ".join([str(i + 1) for i in puts]))
  return None


def B():
  return None


def C():
  return None


MAIN()

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
c = 0
d = [0] * n
ans = []
for i in range(n):
    m = n-i
    p = 1
    b = 0
    while m * p <= n:
        tmp = m * p
        if d[tmp-1] == 1:
            b += 1
        p += 1
    if b % 2 != a[m-1]:
        d[m-1] = 1
        ans.append(m)
        c += 1

if c%2 != a[0]:
    print('-1')
else:
    print(c)
    print(" ".join(repr(e) for e in ans))

Solution (Python):
N = int(input())
A = map(int, raw_input().split())
ANS = set()

for j in range(N, 0, -1):
    s = 0
    for k in range(j+j, N+1, j):
        if k in ANS:
            s += 1

    am = s % 2
    if A[j-1] != am:
        ANS.add(j)

print(len(ANS))
str_ANS = [str(j) for j in ANS]
print(" ".join(str_ANS))

Solution (Python):
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
import copy
def divisor(n): 
    f=[]
    d=[1]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            f.append([i,c])
            c=0
    if n!=1:
        f.append([n,1])
    for i in range(len(f)):
        t=[]
        for j in range(1,f[i][1]+1):
            t.append(f[i][0]**j)
        for j in range(len(d)):
            for k in range(len(t)):
                d.append(d[j]*t[k])
    return sorted(d)
n=I()
A=IL()
Ans=copy.deepcopy(A)
AA=[0]*n
AAA=[0]*n
last=-1
first=n
ans=0
c=True
while first>0:
    last=first
    first=first//2
    for i in range(first,last):
        if A[i]==1:
            if AA[i]==1:
                c=False
                break
            AA[i]=1
            L=divisor(i+1)
            for l in L:
                if A[l-1]==0:
                    A[l-1]=1
                else:
                    A[l-1]=0
                    
                if AAA[l-1]==0:
                    AAA[l-1]=1
                else:
                    AAA[l-1]=0   
                

if AAA!=Ans or not c:
    print(-1)
    print(A)
else:
    print(sum(AA))
    for i in range(n):
        if AA[i]==1:
            print(i+1,end=" ")
    print()

Solution (Python):


import sys

sys.setrecursionlimit(10**7)


input = sys.stdin.readline


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h(typ) if m > 1 else typ(input()) for _ in range(n)]


def main():
    n, = read_h()
    mod = [None] + read_h()

    i = n
    box = [None] * (n + 1)
    while i >= 1:
        if n // i <= 1:
            box[i] = mod[i]
            i -= 1
            continue

        s = sum(box[j] for j in range(i * 2, n + 1, i))
        box[i] = abs(mod[i] - (s % 2))

        i -= 1

    
    
    print(sum(box[1:]))
    t = [str(i) for i, b in enumerate(box) if b is not None and b > 0]
    if len(t) > 0:
        print(' '.join(t))


if __name__ == '__main__':
    main()

Solution (Python):

N = int(input())

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

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






    
print(sum(X))
for i, j in enumerate(X):
    if j == 1:
        print(str(i+1) + " ", 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)

    divisors.sort()
    return divisors


n = int(input())
a = list(map(int, input().split()))
box = [0 for _ in range(n)]
sum_box = [0 for _ in range(n)]
for i in range(n)[::-1]:
    if a[i] == 1 and sum_box[i] % 2 == 0:
        for k in make_divisors(i+1):
            sum_box[k-1] += 1
        box[i] = 1
    elif a[i] == 1 and sum_box[i] % 2 != 0:
        box[i] = 0
    elif a[i] != 1 and sum_box[i] % 2 != 0:
        for k in make_divisors(i+1):
            sum_box[k-1] += 1
        box[i] = 1
    elif a[i] != 1 and sum_box[i] % 2 == 0:
        box[i] = 0
ans = []
for i, b in enumerate(box):
    if b == 1:
        ans.append(str(i+1))
if not ans:
    print(0)
else:
    s = ' '.join(ans)
    print(len(ans))
    print(s)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
for i in range(1,n // 2 + 1):
    an = a[n //2 - i]
    if (sum(a[n // 2 - i::n // 2 + 1 - i]) - an) % 2 == an:
        a[n // 2 - i] = 0
    else:
        a[n // 2 - i] = 1
b = []
cnt = 0
for i in range(len(a)):
    if a[i] == 1:
        b.append(str(i + 1))
        cnt += 1
if cnt != 0:
    print(cnt)
    print(' '.join(b))
else:
    print(0)

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

balls = [0] * n
nrev = reversed(range(n))
ballcount = 0

for i in nrev:
    if i > n // 2:
        balls[i] = a[i]
        if balls[i] == 1:
            ballcount = ballcount + 1
    else:
        kosuu = n // (i + 1)
        ball = 0
        now = i + 1
        for j in range(kosuu):
            if balls[now - 1] == 1:
                ball = ball + 1
            now = now + i + 1
        if ball % 2 == a[i]:
            balls[i] = 0
        else:
            balls[i] = 1
            ballcount = ballcount + 1

print(ballcount)

for i in range(n):
    if balls[i] == 1:
        print(i + 1)

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

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

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

cx=0
for i in range(1,n+1):
    if b[i]==1:
        cx=cx+1

if any(b)==False:
    print(0)
else:
    def func1(lst, value):
        return [i for i, x in enumerate(lst) if x == value]
    idx=func1(b,1)
    print(cx)
    print(' '.join(map(str, idx)))

Solution (Python):
n = int(input())
a = [int(_) for _ in input().split()]
b = [0] * n
res = []
m = 0
for i in range(n//2,n):
    if a[i] == 1:
        res.append(i+1)
        b[i] = 1
        m += 1
for i in range(n//2):
    k = n//2-i
    cnt = 0
    for j in range(2*k-1,n,k):
        if b[j] == 1:
            cnt = (cnt+1)%2
    if cnt != a[k-1]:
        res.append(k)
        b[k-1] = 1
        m += 1 
if m == 0:
    print(0)
else:
    print(m)
    for i in range(m):
        if i != 0:
            print(' ',end='')
        print(res[i],end='',)
    print()

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

    count = 0
    printlist = []
    for i in range(N//2,N):
        boxes[i] = A[i]
        if A[i] == 1:
            count += 1
            printlist.append(i)
            
    for i in range(N//2-1,-1,-1):
        s = A[i]
        
        for j in range(2,N//(i+1)+1):
            
            s ^= boxes[(i+1)*j - 1]
        boxes[i] = s
        if s == 1:
            count += 1
            printlist.append(i)
            

    import sys
    print(count)
    for i in printlist:
        sys.stdout.write(str(i+1))
        sys.stdout.write(' ')
    print()

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
a = list(map(int,input().split()))
b = [-1] * N
nfi = N // 2
for i in range(nfi,N):
    b[i] = a[i]
for j in range(nfi-1,-1,-1):
    bn = b[j::j+1][1:]
    bnsum = sum(bn)
    if a[j] == 1:
        if bnsum%2==1:b[j] = 0
        else:b[j] = 1
    else:
        if bnsum%2==0:b[j] = 0
        else:b[j] = 1        
dl = []
for k in range(N):
    if b[k] == 1:
        dl.append(k+1)
if sum(b) == 0:
    print(0)
else:
    print(sum(b))
    print(*dl)

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

b=[-1]*N
b[N-1]=a[N-1]
for i in range(N-1)[::-1]: 
    sum_count = N // (i+1)
    if sum_count==1:
        b[i]=a[i]
    else:
        sum1=0
        for j in range(sum_count-1):
            sum1 = sum1 + b[(i+1)*(j+2)-1]
        sum1 = sum1 % 2
        b[i]=(a[i]+ sum1)%2

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

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

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

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

answer = []
choose = [0] * (N+1)

for n in range(N,0,-1):
    x = sum(choose[2*n::n])
    if x % 2 == A[n]:
        continue
    choose[n] += 1
    answer.append(str(n))

print(len(answer))
print(' '.join(answer))

Solution (Python):
n = int(input())
l = list(map(int,input().split()))
u = []
m = n
c = [0]*n
b = 0
count = 0
for i in range(2,n+1):
    while(m>n//i):
        b=0
        for j in range(1,i):
            b = b^l[m*j-1]
            
        l[m-1] = b
        if(b):
            u.append(m)
            count += 1
        m -= 1
b = 0
for i in range(0,n):
    b = b^l[i]
if(b):
    u.append(m)
    count += 1
print(count)
if(u):
    print(*list(reversed(u)))

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

for i in range(n):
	
		cnt=0
		for k in range(n//(n-i)):
			if b[(n-i)*(k+1)-1]==1:
				cnt+=1
		if cnt%2==a[n-i-1]:
			b[n-i-1]=0
		else:
			b[n-i-1]=1
	
	
ans_1=0
ans_2=[]
for i in range(n):
	if b[i]==1:
		ans_1+=1
		ans_2.append(i+1)
print(ans_1)
print(*ans_2)

Solution (Python):
import os, sys, re, math

N = int(input())

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

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

for i in range(N,0,-1):
    temp_s = 0
    m = 2
    while m * i <= N:
        temp_s += memo[m*i]
        m += 1

    memo[i] = (temp_s % 2) ^ a[i-1]

ret = [i for i in range(1,N+1) if memo[i] == 1]
if len(ret) == 0:
    print(0)
else:
    print(len(ret))
    ret = list(map(str,ret))
    print(' '.join(ret))

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

for i in range(n, n//2, -1):
  if a[i-1]:
    c[i-1] = 1
for i in range(n//2, 1, -1):
  t = i
  tt = 0
  cnt = 1
  while t<=n:
    tt += c[t-1]
    cnt += 1
    t = i*cnt
  if (a[i-1]==1 and tt%2==0) or (a[i-1]==0 and tt%2==1):
    c[i-1] = 1

ttt = sum(c)
if (ttt%2==0 and a[0]==1) or (ttt%2==1 and a[0]==0):
  c[0] = 1
  ttt += 1

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

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

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

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
            divisors = make_divisors(i)
            for d in divisors:
                X[d-1] += t
    B = []
    for i, y in enumerate(Y):
        if y > 0:
            B.append(i+1)
    M = len(B)
    print(M)
    if M > 0:
        print(' '.join([str(b) for b in B]))

main()

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

shoki = N // 2
A.insert(0, -1)
N += 1
boxes = [0 for i in range(N)]
result = []

N -= 1
for i in range(N, shoki, -1):
    boxes[i] = A[i]
    if A[i] == 1:
        result.append(i)

for i in range(shoki, 0, -1):
    mul = 2
    val = i
    cnt = 0
    while val*mul <= N:
        if boxes[val*mul] == 1:
            cnt += 1
        mul += 1
    if A[i] == 0 and (cnt % 2) == 0:
        boxes[i] = 0
    elif A[i] == 0:
        boxes[i] = 1
        result.append(i)
    elif A[i] == 1 and (cnt % 2) == 0:
        boxes[i] = 1
        result.append(i)
    else:
        boxes[i] = 0
if result:
    print(str(len(result)))
    print(*result)
else:
    print("0")

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


def divisor(n):  
    ans = [1, n]
    i = 2
    while i ** 2 <= n:
        if n % i == 0:
            ans.append(i)
            if i ** 2 < n:
                ans.append(n // i)
        i += 1
    ans.sort()
    return ans
a = list(map(int,input().split()))
ans = []
for num in range(n-1,-1,-1):
    if a[num] %2== 1:
        ans.append(num+1)
        q = divisor(num+1)
        for j in q:
            a[j-1] += 1

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

print()

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

ball = [False for _ in range(n)]

ans = []
for i, a in enumerate(reversed(box)):
    
    idx = n - 1 - i
    count_right = 0
    p = 2
    j = (idx + 1) * p
    
    while j <= n:
        
        if ball[j-1]:
            count_right += 1
        p+=1
        j = (idx + 1)  * p
    if a != 0:
        if (count_right % 2) != 0:
            ball[idx] = False
        else:
            ball[idx] = True
            ans.append(idx+1)
    else:
        if (count_right % 2) != 0:
            ball[idx] = True
            ans.append(idx+1)
        else:
            ball[idx] = False

ans_len = len(ans)
print(ans_len)
if (int(ans_len) == 0):
    pass 
else:
    ans_s = ""
    for i, b in enumerate(ball):
        if b:
            if ans_s == "":
                ans_s = str(i+1)
            else:
                ans_s += " "
                ans_s += str(i+1)
    print(ans_s)

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

A=[int(i) for i in input().split()]
Ans=[]
C=[False]*n
for i in reversed(range(n)):
  if A[i]==1:    
    if 2*(i+1)>n:
      Ans.append(i+1)
      C[i]=True
    else:
      c=0
      j=2
      while j*(i+1)<=n:
        if C[j*(i+1)-1]==True:
          c^=1
        j+=1
      if c==0:
        Ans.append(i+1)
        C[i]=True
        
  elif A[i]==0:    
    c=0
    j=2
    while j*(i+1)<=n:
      if C[j*(i+1)-1]==True:
        c^=1
      j+=1
    if c==1:
      Ans.append(i+1)
      C[i]=True
      
if len(Ans)==0:
  print(0)
else:
  print(len(Ans))
  Ans.sort()
  print(*Ans)

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

b = [0] * N
i = N-1
while i >= 0:
    for j in range(1, N//(i+1)):
        c[i] = c[i] - b[(j+1)*(i+1)-1]
    b[i] = c[i]%2
    i -= 1


count = 0
for i in range(N):
    e = sum(b[i::i+1])
    if e%2 != a[i] :
        print(-1)
        count =1
        break


if count == 0 :
    d = []

    print(b.count(1))

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

    if len(d) != 0:
        print(' '.join(d))

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

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

print(b.count(1))

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

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

Solution (Python):


import math

if __name__ == '__main__':
    N = int(input())
    A = [int(c) for c in input().split()]
    R = [0 for i in range(N)]
    M = 0

    for i in range(N-1, -1, -1):
        
        start = i
        sum = 0
        for j in range(start, N, i + 1):
            
            sum += R[j]
        
        
        if sum % 2 != A[i]:
            R[i] = 1
            M += 1

    

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

Solution (Python):

import copy

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

for i in range(int(N/2), 0, -1):
    s = 0
    for j in range(2*i, N+1, i):
        s += ball[j-1]
    if A[i-1] == s%2:
        ball[i-1] = 0
    else: ball[i-1] = 1

s = sum(ball)
print(s)
if s != 0:
    out = str(ball.index(1) + 1)
    for i in range(int(out), N):
        if ball[i] == 1: out += ' ' + str(i+1)
    print(out)

Solution (Python):
n=int(input())
lst=list(map(int,input().split()))
ball=[0 for x in range(n)]
for i in range(n):
  idx=n-1-i
  if idx==n-1:
    ball[idx]=lst[idx]
  else:
    num=int(n/(idx+1)-1)
    sum_ball=0
    for j in range(2,num+2):
      sum_ball+=ball[(idx+1)*j-1]
    if sum_ball%2==lst[idx]:
      continue
    else:
      ball[idx]=1
      
indexes=[i+1 for i,x in enumerate(ball) if x==1]
if len(indexes):
  print(len(indexes))
  for i,x in enumerate(indexes):
    if i!=0:
      print(" ",end="")
      print(x,end="")
    else:
      print(x,end='')
  print()
else:
  print(0)

Solution (Python):
import sys
N=input()
A=map(int, sys.stdin.readline().split())


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

for i in range(N/2, N):
	ans[i]=A[i]
	V[i]=1

for i in range(N/2-1,-1,-1):
	t=A[i]
	k=i+1
	for j in range(i+k,N,k):
		t^=ans[j]
	ans[i]=t


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

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

if N % 2 == 0:
    k = N // 2
    x = [0] * k + a[k:]
    start = k
else:
    k = (N + 1) // 2
    x = [0] * (k - 1) + a[k - 1:]
    start = k - 1

for i in range(start, 0, -1):
    x[i - 1] = (sum(x[2 * i - 1::i]) + a[i - 1]) % 2

M = 0
b = []
for i in range(N):
    if x[i] == 1:
        M += 1
        b.append(str(i + 1))
print(M)
print(' '.join(b))

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

res = [0 for i in range(N)]
for i in range(N, 0, -1):
    othors_idxs = [(j+1)*i-1 for j in range(int(N/i)) if j != 0]
    othors = [res[idx] for idx in othors_idxs]
    if sum(othors + [1]) % 2 == A[i-1]:
        res[i-1] = 1

ans = [str(i+1) for i in range(N) if res[i] == 1]
l = len(ans)
if l > 0:
    print(l)
    print(' '.join(ans))
else:
    print(0)

Solution (Python):
import numpy as np
import copy

N = int(input())  
a = np.array(input().split(), dtype=np.int32)
M = np.arange(N) + 1
    
for i in np.arange(N // 2)[::-1]:
    A = a[i::i+1]
    if np.sum(A) % 2  == 0:
        a[i] = 0
    else:
        a[i] = 1
        
ans = np.where(a == 1)[0] + 1

print(np.size(ans))

if np.size(ans) > 0:
    print(*ans.astype(np.int32))

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

B = [0] * (N)
BB = []
cnt_b = 0
for i in range(N)[::-1]:
    sum_b = 0
    idx = 1
    while True:
        if (i+1) * idx > N:
            B[i] = (A[i] + sum_b)%2
            if B[i] == 1:
                cnt_b += 1
                BB.append(i+1)
            break
        else:
            sum_b += B[(i+1)*idx-1]
        idx += 1
print(cnt_b)
str_b = ' '.join(map(str, BB))
if str_b != '0':
    print(str_b)

Solution (Python):

import numpy as np

def main():
    
    
    
    
    
    
    
    
    N = int(input())
    a_list = [int(i) for i in input().split()]
    b_list = [0] * N
    ret_b = []

    
    
    for i, a in enumerate(a_list[::-1]):
        index = N - 1 - i 
        ball_sum = get_sum(index, b_list)
        
        if ball_sum % 2 != a:
            b_list[index] = 1
            ret_b.append(index + 1)
        
        
    print(len(ret_b))
    if len(ret_b)>0:
        print(' '.join(map(str, ret_b)))




def get_sum(index, b_list): 
    index_ = index + 1
    cur = index_
    ret_sum = 0
    while (cur<len(b_list)+1):
        ret_sum += b_list[cur-1]
        cur += index_
    return ret_sum


if __name__=='__main__':
    main()

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    A = [-1] + A
    ans = 0
    B = [0] * (N+1)
    ans = []
    for i in range(N, 0, -1):
        s = 0
        for j in range(i, N+1, i):
            s += B[j]
        if s % 2 != A[i]:
            B[i] = 1
            ans.append(i)
    
    print(len(ans))
    if ans:
        print(' '.join(map(str, ans)))


def main():
    N = read_int()
    A = read_int_n()
    slv(N, A)


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
l = [0 for i in range(N)]
ans = []
cnt = 0
for i in reversed(range(N)):
    j = 2
    memo = 0
    while (i+1)*j <= N:
        memo += l[(i+1)*j-1]
        j += 1
    memo = memo%2
    
    if memo != a[i]:
        l[i] = 1
        cnt += 1
        ans.append(str(i+1))
ans.sort()
print(cnt)
print(" ".join(ans))

Solution (Python):
n=int(input())
al=list(map(int,input().split()))
ac=0
ans=set()
tl=[0]*n
for i in range(n,0,-1):
    if tl[i-1]%2!=al[i-1]:
        ac+=1
        ans.add(i)
        for j in range(1,int(i**0.5)+1):
            if i%j==0:
                tl[j-1]+=1
                if j**2==i:
                    continue
                tl[i//j-1]+=1
print(ac)
if ac>0:
    print(' '.join(map(str,ans)))