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):
def pbox(n,a):
    count = 0
    result = []
    x=[0]*n
    for i in xrange(n,0,-1):
        total = 0
        for j in xrange(i,n+1,i):
            total += x[j-1]
        if  total % 2 != a[i-1]:
            x[i-1]=1
            result.append(i)
        else:
            pass
 
    print len(result)
    print ' '.join(map(str,result))
 
if __name__ == '__main__':
    n = int(raw_input())
    a = map(int,raw_input().split())
 
    pbox(n,a)

Solution (Python):


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

    ans_num = 0
    ans = ""
    box = [0] * (N)
    for i in range(N-1, -1, -1):
        total = 0
        for j in range(i, N, i+1):
            
            total += box[j]
        if total%2 == A[i]:
            continue
        else:
            ans_num += 1
            ans += str(i+1) + " "
            box[i] = 1
    
    
    for i in range(N-1, -1, -1):
        total = 0
        for j in range(i, N, i+1):
            total += box[j]
        if total%2 == A[i]:
            continue
        else:
            print(-1)
            return

    print(ans_num)
    if ans_num != 0:
        print(ans[0:-1])

if __name__ == "__main__":
    solve()

Solution (Python):
a = int(input())
b = list(map(int, input().split()))
c = [0] * a
e = 0
f = []
for i in range(a - 1, -1, -1):
    d = 0
    for j in range(i, a, i + 1):
        d += c[j]
    if d % 2 != b[i]:
        c[i] = 1
        e += 1
        f.append(str(i + 1))
print(e)
if e > 0:
    f.sort()
    print(" ".join(f) if e > 1 else f[0])

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
b = [False] * n
for i in range(n - 1, -1, -1):
    if sum(b[i::i+1]) % 2 != a[i]:
        b[i] = True
res = [str(x + 1) for x, v in enumerate(b) if v]
print(len(res))
if len(res) > 0:
    print(' '.join(res))

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

def main():
	n = int(input().strip())
	a = []
	a.append(0)
	a.extend(list(map(int, input().strip().split())))
	s = [0] * (n+1)
	for i in reversed(range(1, n+1)):
		j = 1
		d = 0
		while i * j <= n:
			d += s[i*j]
			j += 1
		s[i] = (d+a[i]) % 2
	M = sum(s)
	print(M)
	for i in range(n+1):
		if s[i] == 1:
			print("{} ".format(i), end="")
	print("")

if __name__ == '__main__':
	main()

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

b = set()
d = dict()
for i in range(n, 0, -1):
    x = i * 2
    count = 0
    while x <= n:
        count += d[x]
        x += i
    if a[i] == 0:
        if count % 2 == 1:
            b.add(i)
            d[i] = 1
        else:
            d[i] = 0
    else:
        if count % 2 == 0:
            b.add(i)
            d[i] = 1
        else:
            d[i] = 0

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
import numpy as np







h = int(np.floor(n/2))

boxes = np.zeros(n)
boxes[h:] = a[h:]
if n%2==0:       
    for i in range(h):
        d = n-h-i-1
        s = sum(boxes[2*(d+1)-1::d+1])%2
        if s==a[d]:
            boxes[d] = 0
        else:
            boxes[d] = 1
    
    ans = list(map(int, boxes))
    print(sum(ans))
    for i in range(len(ans)):
        if ans[i]==1:
            print("{} ".format(i+1), end="")
else:
    for i in range(h):
        d = n-h-i-2
        s = sum(boxes[2*(d+1)-1::d+1])%2
        if s==a[d]:
            boxes[d] = 0
        else:
            boxes[d] = 1
    
    ans = list(map(int, boxes))
    print(sum(ans))
    for i in range(len(ans)):
        if ans[i]==1:
            print("{} ".format(i+1), end="")

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

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

print(sum(b))
if len(ans) > 0:
    print(*ans)

Solution (Python):

N = int(input())
A = list(map(int,input().split()))
C = [0 for i in range(N)]
for i in range(N):
    I = N-1-i
    n = N//(I+1)
    check = 0
    for j in range(n):
        check+=C[(I+1)*(j+1)-1]
    
    
    if A[I] == check%2:
        C[I] = 0
    else:
        C[I] = 1

b = 0
B = []
for i in range(N):
    if C[i] == 1:
        b+=1
        B.append(i+1)
print(b)
for i in range(b):
    print(B[i],end=" ")

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

A = [0] + A
for i in range(N//2, 0, -1):
    A[i] = sum(A[i::i])%2
ans = [i for i in range(N+1) if A[i]]
print(len(ans))
print(*ans)

Solution (Python):
N = int(input())
a_list = list(map(int,input().split()))
I = N//2
import copy
b_list = copy.deepcopy(a_list)
for i in range(I-1,-1,-1):

    split = N//(i+1)
    wa = 0
    for s in range(split):
        wa += b_list[i+s*(i+1)]
    if wa % 2 != a_list[i]:
        b_list[i] = 1- a_list[i]

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

Solution (Python):
import sys

M = int(input())

b_list = list(map(int, input().split()))
b_list.insert(0,0)
result_list = [0] * (M+1)

def getCount(index):
    multi = 2
    count = 0
    while True:
        next_index = index * multi
        if next_index > M:
            break
        count += result_list[next_index]
        multi += 1
    
    return count
        

for i in range(M, 0, -1):
    num = b_list[i]
    count = getCount(i)
    if count % 2 == num:
        result_list[i] = 0
    else:
        result_list[i] = 1

result_list.pop(0)
ans = ""
for i in range(len(result_list)):
    if result_list[i] == 1:
        ans += str(i+1) + " "

print(result_list.count(1))
if ans != "":
    print(ans)

Solution (Python):
def main():
    n = int(input())
    a_s = list(map(int, input().split()))
    results = [0]*n
    a_r = reversed(a_s)
    for i, a in enumerate(a_r):
        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):
a = int(input())
b = list(map(int, input().split()))
c = [0] * (a + 1)
e = []
for i in range(len(b), 0, -1):
    d = 0
    for j in range(i, a + 1, i):
        d += c[j]
    if d % 2 != b[i-1]:
        c[i] += 1
        e.append(str(i))
f = sum(c)
print(f)
if len(e) > 1:
    print(" ".join(e))
elif len(e) == 1:
    print(e[0])

Solution (Python):


n=int(raw_input())
a=map(int,raw_input().split())
s=[]
x=[0]*n
for i in xrange(n,0,-1):
 y=0
 for j in xrange(i,n+1,i):
  y+=x[j-1]
 if y%2!=a[i-1]:
  x[i-1]=1
  s.append(i)
print len(s)
print ' '.join(map(str,s))

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

Solution (Python):
n=int(input())
a=[0]+[int(x) for x in input().split()]
b=[0]*(n+1)
 
for s in range(n,0,-1):
    i=s
    t=0
    while i<=n:
        t += b[i]
        i += s
    if a[s]!=t%2:
        b[s]=1
print(b.count(1))
for i in range(1,n+1):
    if b[i]==1:
        print(i)

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

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


def returnResMod2(i):
    
    res = sum([ansList[(i+1)*(k+1)-1] for k in range(N//(i+1))]) % 2
    return res


ansList = [0 for i in range(N)]
for i in range(N-1, -1, -1):
    tmp = (returnResMod2(i)+A[i]) % 2
    ansList[i] = tmp
    

M = sum(ansList)
print(M)
if M == 0:
    quit()
print(' '.join([str(i+1) for i, a in enumerate(ansList) if a == 1]))

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
ball = [0 for c in range(N)]
i = N
ballcount = 0
check = 2
out = 0
while i != 0 and out != N + 1:
    while check * i <= N: 
        ballcount += ball[check * i - 1]
        check += 1
    if ballcount % 2 != a[i - 1]:
        ball[i - 1] = 1
    check = 2
    i -= 1
    ballcount = 0
    out += 1
if out == N + 1:
    i = out
    print(-1)
M = 0
while i < N:
    if ball[i] == 1:
        M += 1
    i += 1
print(M)
i = 0
while i < N:
    if ball[i] == 1:
        print(i + 1)
    i += 1

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

bList=[0] * N

for i in reversed(range(N)):
    x = N // (i + 1)
    tmp = 0
    for j in range(1, x+1):
        tmp += bList[j * (i + 1) - 1]
    if aList[i] != tmp%2:
        bList[i] = 1
M = bList.count(1)

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

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

a_count = len(a_list)

boll_list = [0] * n

for rev_index, a in enumerate(reversed(a_list)):
    
    index = a_count - rev_index - 1
    divide_max = a_count // (index + 1)
    total = 0
    for divide in range(divide_max):
        total += boll_list[(index + 1) * (divide + 1) - 1]
    if a_list[index] != total % 2:
        boll_list[index] = 1

if 1 in boll_list:
    output_list = []
    for index, i in enumerate(boll_list):
        if i == 1:
            output_list.append(str(index + 1))
    print(len(output_list))
    print(' '.join(output_list))
else:
    print('0')

Solution (Python):
def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    b = [0]*n
    for i in reversed(range(n)):
        x = n//(i+1)
        now = 0
        for j in range(1,x+1):
            now += b[j*(i+1)-1]
        if a[i] != now%2:
            b[i]=1
    m = b.count(1)
    print(m)
    if not m==0:
        for i in range(n):
            if b[i]==1:
                print(str(i+1),end=" ")
    
if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
a_s = list(map(int,input().split()))
b_s = [0] * N
answers = []
for i,a in enumerate(list(reversed(a_s))):
    k = len(a_s)-i-1
    if sum(b_s[k::(k+1)])%2 != a_s[k]:
        b_s[k] = 1
        answers.append(str(k+1))
print(len(answers))
print(" ".join(list(reversed(answers))))

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

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

print(sum(res))
ans = []
for i, ele in enumerate(res):
    if ele == 1:
        ans.append(i)
print(' '.join(map(str, ans)))

Solution (Python):
import math

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

for i in reversed(range(N)):
    x = math.floor(N/(i+1))
    temp = 0
    for k in range(1,x+1):
        temp += b[k*(i+1) - 1]
    if a[i] != (temp%2):
        b[i] = 1
M = b.count(1)
print(M)
if M != 0:
    for i in range(N):
        if b[i] ==1:
            print(str(i+1), end = " ")

Solution (Python):


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

b = [0] * N

for i, aa in enumerate(a):
    box_number = N-i
    sum_item_num = N//box_number
    item_sum = 0
    for sum_count in range(sum_item_num, 0, -1):
        if sum_count != 1:
            item_sum += b[(box_number * sum_count) - 1]
        else:
            
            b[box_number - 1] = aa ^ (item_sum % 2)

b = [str(i+1) for i, x in enumerate(b) if x == 1]
print(len(b))
if len(b) > 0:
    print(' '.join(b))

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
ans = [0]*N
ct = 0
for i in reversed(range(N)):
    balls = sum(ans[2*i+1::i+1])
    if a[i] % 2:
        if balls % 2:
            pass
        else:
            ans[i] = 1
            ct += 1
    else:
        if balls % 2:
            ans[i] = 1
            ct += 1
        else:
            pass
print(ct)
for i in range(N):
    if ans[i]:
        print(i+1)

Solution (Python):
n=int(input())
a=[0]+[int(x) for x in input().split()]
b=[0]*(n+1)

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

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

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

B = [0 for _ in range(N)]

for i, a in enumerate(A[::-1]):
    i = N - i
    v = B[i-1]
    for j in range(i*2, N+1, i):
        v ^= B[j-1]
    if v != a:
        B[i-1] ^= 1

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

Solution (Python):
from functools import reduce
from operator import xor


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



dp = [0 for _ in range(N + 1)]
for i in range(N, 0, -1):
    dp[i] = reduce(
        xor,
        (dp[j] for j in range(2 * i, N + 1, i)),
        a[i - 1]
    )
b = [i for i in range(1, N + 1) if dp[i]]
ans = (
    '0' if len(b) == 0 else
    '{}\n{}'.format(
        len(b),
        ' '.join(map(str, b))
    )
)

print(ans)

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

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
b = [0]*N
d = 1
r = []
for i in range(N, 0, -1):
  m = 0
  c = 2*i
  while c <= N:
    m += b[c-1]
    c += i
  if m % 2 != a[i-1]:
    b[i-1] = 1
    r.append(i)
print(sum(b))
print(" ".join([str(s) for s in r]))

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
b = [0 for i in range(N)]
m = N // 2 + 1
for i in range(N,0,-1):
    if i >= m:
        b[i-1] = a[i-1]
    else:
        kaisu = N // i
        count = 0
        for j in range(2, kaisu+1):
            count += b[j*i-1]
        amari = count % 2
        if amari == 0 and a[i-1] == 1:
            b[i-1] = 1
        elif amari == 1 and a[i-1] == 0:
            b[i-1] = 1
print(sum(b))
for i in range(N):
    if b[i] == 1:
        print(i+1)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
num_l = [0]*N
bn = 0
for i in range(N, 0, -1):
    nn = 0
    for j in range(2*i, N+1, i):
        nn += num_l[j-1]

    if nn % 2 != A[i-1]:
        num_l[i-1] = 1

M = sum(num_l)
print(M)
if M != 0:
    ans = []
    flg = False
    for i, n in enumerate(num_l):
        if flg:
            print(' ', end='')
        if n == 1:
            print(i+1, end='')
        flg = True

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

for i in reversed(range(1, N+1)):
    summ = 0
    for j in range(i, N+1, i):
        summ += b[j-1]
    if summ % 2 != a[i-1]:
    	b[i-1] = 1
    
 
cnt = sum(b)
print(cnt)
not_first = False
if cnt > 0:
 
    for j in range(N):
        if b[j] == 1:
            if not_first:
                print(" ", end="")
            print(j+1, end="")
            not_first = True
    print()

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
b = [0 for i in range(n+1)]
a.reverse()
a.insert(0,0)
counter = 0
for i in range(1,n+1): 
    temp = 0
    t = 1
    while (n+1-i)*t <= n:
        temp += b[(n+1-i)*t]
        t += 1
    if temp%2 != a[i]:
        b[n+1-i] = 1
        counter += 1
print(counter)
for i in range(1,n+1):
    if b[i] == 1:
        if counter != 1:
            print(i,end= " ")
        else:
            print(i)
        counter -= 1

Solution (Python):
def solve(n, a):
    box = [0] * (n + 1)
    for i in reversed(range(1, n + 1)):
        j = 2
        count = 0
        while i * j < n + 1:
            if box[i * j] == 1:
                count += 1
            j += 1
        if a[i - 1] != count % 2:
            box[i] = 1
    ans = [str(i) for i, it in enumerate(box) if it == 1]
    return len(ans), ans


if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    m, b = solve(N, A)
    print(m)
    if m > 0:
        print(' '.join(b))

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

    res = [0] * (N + 1)

    for i in range(N, 0, -1):
        res[i] = (sum(res[2 * i::i]) % 2) ^ an[i]

    print(sum(res))
    print(*[i for i in range(N + 1) if res[i]])


if __name__ == '__main__':
    main()

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
M=0
b=[]
M=0
for i in range(N):
    b.append(0)
for j in range(N,0,-1):
    cnt=0
    for k in range(j,N+1,j):
        cnt+=b[k-1]
    if cnt%2!=a[j-1]:
        b[j-1]=1
        M+=1
c=[l+1 for l, x in enumerate(b) if x==1]
c=list(map(str,c))
print(M)
print(' '.join(c))

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

sum_index = [0]*(N+1)
index = []
for i in range(N)[::-1]:
    sum_ = 0
    for j in sum_index[i+1::i+1]:
        sum_ ^= j
    sum_index[i+1] = sum_ ^ A[i]
    if sum_index[i+1] == 1:
        index.append(str(i+1))

print(sum(sum_index))
if index:
    print(" ".join(index))

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

for i in range(N, 0, -1):
    
    wa = 0
    for j in range(i, N+1, i):
        
        wa += boxes[j]
    if wa % 2 != A[i]:
        boxes[i] = 1
    
ans = []
for i in range(len(boxes)):
    if boxes[i] == 1:
        ans.append(i)

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

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

for i, ai in enumerate(reversed(A)):
  count = 0

  for j in range(N-i, N+1, N-i):
    count += B[j-1]
  if ai != count%2:
    B[N-1-i] = 0

M = sum(B)
l = [i+1 for i, bi in enumerate(B) if bi == 1]
print(M)
print(*l)

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


M = sum(B)
l = [i+1 for i, bi in enumerate(B) if bi == 1]
print(M)
print(*l)

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

B = [0 for _ in range(N)]
for i in range(N-1,-1,-1):
  isum = 0
  itr = 2
  while (i+1)*itr -1 < N:
    isum += B[(i+1)*itr - 1]
    itr += 1
  isum %= 2
  if isum != A[i]:
    B[i] = 1

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

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
b = [0]*n
tmp=[]
ans=""
for i in range(n-1,-1,-1):
  num = i+1
  total=0
  j=1
  while (i+1)*j <= n:
    total+=b[((i+1)*j)-1]
    j+=1  
  if total%2==a[i]:
    b[i]=0
  else:
    b[i]=1
    tmp.append(i+1)

print(sum(b))
print(str(sorted(tmp)).replace(',','').replace('[','').replace(']',''))

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

boxes = [0 for i in range(N+1)]  

for i in range(N, 0, -1):
    
    wa = 0
    for j in range(i, N+1, i):
        
        wa += boxes[j]
    if wa % 2 != A[i]:
        boxes[i] = 1

ans_n = sum(boxes)
ans_list = []

for i in range(len(A)):
    if boxes[i] == 1:
        ans_list.append(i)
print(ans_n)
if ans_n != 0:
    print(" ".join(map(str, ans_list)))

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

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

ans = a[:]

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

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

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
ans=[]
anscnt=0
for i in range(n-1,-1,-1):
    ai=a[i]
    j=2*(i+1)-1
    while n>j:
        ai^=b[j]
        j+=i+1
    if ai==1:
        b[i]=1
        ans.append(i+1)
        anscnt+=1
print(anscnt)
if anscnt>0:
    ans.reverse()
    print(*ans)

Solution (Python):
n=int(input())
a=[0]+[int(i) for i in input().split()]
m=0
ans=[]
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
for i in range(n,0,-1):
    if a[i]%2==1:
        m+=1
        ans.append(i)
        l=make_divisors(i)
        for j in l:
            a[j]+=1
print(m)
if ans!=[]:
    for i in range(m):
        if i!=m-1:
            print(ans[i],end=" ")
        else:
            print(ans[i])

Solution (Python):
def inpl(): return list(map(int, input().split()))

N = int(input())
A = [0] + inpl()
D = [0]*(N+1)

for i in range(N, 0, -1):
    D[i] = (sum(D[2*i::i])%2)^A[i]
print(sum(D))
print(*[i for i in range(N+1) if D[i]])

Solution (Python):
def inpl(): return list(map(int, input().split()))

N = int(input())
A = [0] + inpl()
D = [0]*(N+1)

for i in range(N, 0, -1):
    D[i] = (sum(D[2*i::i])%2)^A[i]
print(sum(D))
print(*[i for i in range(N+1) if D[i]])

Solution (Python):
n = int(input())
data = [int(_) for _ in input().split(" ")]

for i in range(len(data),0,-1):
    count = n//i
    total = 0
    for k in range(count,1,-1):
        total += data[i*k-1]
    if data[i-1]%2 == 0 and total%2 == 0:
        data[i-1] = 0
    elif data[i-1]%2 == 1 and total%2 == 1:
        data[i-1] = 0
    else:
        data[i-1] = 1

m = 0
for ele in data:
    if ele != 0:
        m += 1

print(m)
if m != 0:
    ans = []
    for i in range(len(data)):
        if data[i] != 0:
            ans.append(i+1)
    print(" ".join(map(str,ans)))

Solution (Python):
import sys




def oaa(a_ll, val, oe):
	
	if val == 1:
		s=sum(a_ll)
	else:
		c=1
		s=0
		lll=len(a_ll)
		s=sum(a_ll[val-1::val])
		
		
		
		
	return 1 if oe != s%2 else 0
		
def main():
	n = int(input())
	ll= list(map(int, input().split()))
	
	ret = [0 for _ in range(n)]
	for i in range(n):
		val=n-i
		rr=oaa(ret, val, ll[-i-1])
		ret[-i-1]=rr
	
	
	print(sum(ret))
	print(' '.join([str(i+1) for i,v in  enumerate(ret) if v == 1]))
		
		
	


if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Solution (Python):



box_num = int(input())
ball_in_box_num_list = tuple([int(i), []] for i in input().split(" "))
for i in range(1, box_num + 1):
    k = 2
    while i * k <= box_num:
        ball_in_box_num_list[i * k - 1][1].append(i - 1)
        k += 1
ans_num = 0
ans_list = []
for i in range(box_num):
    a = box_num - 1 - i
    b = ball_in_box_num_list[a]
    if b[0] == 1:
        ans_num += 1
        ans_list.append(a + 1)
        for j in b[1]:
            ball_in_box_num_list[j][0] = 1 - ball_in_box_num_list[j][0]
print(ans_num)
if ans_list != 0:
    ans_list = [str(i) for i in ans_list]
    ans_list = ans_list[::-1]
    print(" ".join(ans_list))

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

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

for i in range(n-1, -1, -1):
    j = i + 1
    ball = B[i::j]
    if sum(ball) % 2 != A[i]:
        B[i] = 1

print(sum(B))

B_ball = [str(i+1) for i in range(n) if B[i] == 1]
print(" ".join(B_ball))

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


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

b = b[1:]
b_index = []
for i, n in enumerate(b):
    if n == 1:
        b_index.append(str(i+1))

print(len([n for n in b if n == 1]))
if len(b_index) > 0:
    print(' '.join(b_index))

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

b = [0] * n
for i in range(n)[::-1]:
    multiple = b[i::i + 1]
    if sum(multiple) % 2 != a[i]:  
        b[i] = 1  
    
print(sum(b))
true_b = []  
for i in range(n):
    if b[i] == 0: continue
    true_b.append(str(i + 1))

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

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

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

b = [0]*N
for i in reversed(range(N)):
    j = i + 1
    buf = b[i::j]
    if (sum(buf) % 2) != a[i]:
        b[i] = 1
print(sum(b))
bb = [i+1 for i in range(N) if b[i] == 1]
if sum(b) != 0:
    print(' '.join(map(str, bb)))

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

for i in range(n,0,-1):
    s=0
    c=n//i
    if c == 1:
        b[i-1]=a[i-1]
    else:
        for j in range(1,c+1):
            s += b[i*j-1]
        if (s+a[i-1]) % 2 == 1:
            b[i-1]=1
for k in range(0,n):
    if b[k]==1:
        l.append(k+1)

print(len(l))
for m in l:
    print(m)

Solution (Python):
def get_divisor(i, n):
    out = [0] * (n // i)
    for j in range(len(out)):
        out[j] = i * (j+1)
    return out

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

B = [False] * n

for i in range(n, 0, -1):
    divisors = get_divisor(i, n)
    B[i-1] = bool(A[i-1]) ^ bool(sum(B[divisor-1] for divisor in divisors) % 2)

out = [str(i+1) for i in range(n) if B[i]]

print(sum(B))
print(" ".join(out))

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

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

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

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

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

b = [0] * (N + 1)
half = N // 2
b[half + 1:] = A[half:]
for i in range(half, 1, -1):
    s = sum([b[j] for j in range(i * 2, N + 1, i)]) % 2
    if s != A[i - 1]:
        b[i] = 1
s = sum(b)
if s % 2 != A[0]:
    b[1] = 1
    s += 1
print(s)
for i, b_ in enumerate(b[:]):
    if b_ == 1:
        print(i, end=" ")

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

box = [0] * N
v = N // 2  

for i in range(v, N):
    if ai[i] == 0:
        box[i] = 0
    else:
        box[i] = 1

for i in range(v - 1, -1, -1):
    value = i + 1
    sum = 0
    for j in range(value * 2 - 1, N, value):
        sum += box[j]
    if sum & 1 == 1:
        box[i] = 0 if ai[i] & 1 == 1 else 1
    else:
        box[i] = 0 if ai[i] & 1 == 0 else 1
print(box.count(1))
for i in range(N):
    if box[i] == 1:
        print(i + 1)

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

for i in range(N,0,-1):
  kari=a[i]
  for j in range(2,N+1):
    if i*j <= N:
      kari=kari+c[i*j]
    else:
      break
  c[i]=kari%2
M=sum(c)
b = [i for i in range(1,N+1) if c[i] ==1]
b2 = ' '.join(map(str,b))
print(M)
if M>0:
  print(b2)

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
x = [0]*n
for i in range(n,0,-1):
    m,c = 2,0
    while i*m<=n:
        c+=x[i*m-1]
        m+=1
    x[i-1] = (a[i-1]+c%2)%2
print(sum(x))
for i in range(n):
    if x[i]: print(i+1)

Solution (Python):
import math
n = int(input())
a = list(map(int,input().split()))
length = n
ans=0
for i in range(n):
    x = length-i-1
    tmp1 = length-i
    tmp2 = tmp1*2
    while tmp2 <= n:
        if a[tmp2-1]%2==1:
            a[x]+=1
        tmp2 += tmp1
    if a[x]%2==1:
        ans+=1
print(ans)
for i in range(n):
    if a[i]%2 == 1:
        print(i+1,end=" ")

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
a.insert(0,0)
b = [0]*(n+1)
cnt = 0
for i in range(n,0,-1):
    
    for j in range(1,n+1):
        
        if(i*j>n):
            break
        else:
            cnt += b[i*j]
    if((cnt%2==0 and a[i]==0) or (cnt%2==1 and a[i]==1)):
        b[i] = 0
    elif((cnt%2==0 and a[i]==1) or (cnt%2==1 and a[i]==0)):
        b[i] = 1
    else:
        b[i]=a[i]
    cnt = 0

m = sum(b)
print(m)
for k in range(1,n+1):
    if(b[k]==1):
        print(k,end=' ')

Solution (Python):



import itertools as ite
import math
import random
import sys
import codecs
from collections import defaultdict

INF = 10 ** 18
MOD = 10 ** 9 + 7

sys.setrecursionlimit(1000000)

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

ans = [0] * (N + 1)

for i in range(1, N + 1)[::-1]:
    cnt = 0
    for j in range(i * 2, N + 1, i):
        cnt += ans[j]
    cnt %= 2
    if a[i - 1] != cnt:
        ans[i] = 1
ls = []
for i in range(1, N + 1):
    if ans[i]:
        ls += [i]
print len(ls)
if len(ls) == 0:
    exit()
print " ".join(map(str, ls))