Problem:
 Score : 400 points    Problem Statement There are N empty boxes arranged in a row from left to right.
The integer i is written on the i -th box from the left (1 \leq i \leq N) .  For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.  We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied:   For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2 .   Does there exist a good set of choices? If the answer is yes, find one good set of choices.      Constraints  All values in input are integers.  1 \leq N \leq 2 \times 10^5  a_i is 0 or 1 .         Input Input is given from Standard Input in the following format:  N  a_1  a_2  ...  a_N       Output If a good set of choices does not exist, print -1 .  If a good set of choices exists, print one such set of choices in the following format:  M  b_1  b_2  ...  b_M   where M denotes the number of boxes that will contain a ball, and b_1,\ b_2,\ ...,\ b_M are the integers written on these boxes, in any order.        Sample Input 1 3
1 0 0      Sample Output 1 1
1  Consider putting a ball only in the box with 1 written on it.   There are three boxes with multiples of 1 written on them: the boxes with 1 , 2 , and 3 . The total number of balls contained in these boxes is 1 .  There is only one box with a multiple of 2 written on it: the box with 2 . The total number of balls contained in these boxes is 0 .  There is only one box with a multiple of 3 written on it: the box with 3 . The total number of balls contained in these boxes is 0 .   Thus, the condition is satisfied, so this set of choices is good.       Sample Input 2 5
0 0 0 0 0      Sample Output 2 0  Putting nothing in the boxes can be a good set of choices.

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

out = []
for i in range(N, 0, -1):
    a = A[i - 1]
    q = N // i
    count = 0
    
    for j in range(2, q+1):
        if B[i * j - 1] == 1:
            count += 1
    
    r = count % 2
    
    if a == 0:
        if r == 1:
            B[i - 1] = 1
            out.append(i)
        else:
            B[i - 1] = 0
    else:
        if r == 1:
            B[i - 1] = 0
        else:
            B[i - 1] = 1
            out.append(i)
g = sum(B)
print(g)
    
if g != 0:
    print(*out)

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

b = [0]*N

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

M=sum(b)

ans = []
for i,v in enumerate(b):
    if v==1:
        ans.append(i+1)

print(M)
print(*ans)

Solution (Python):
n=int(input())
lists=list(map(int,input().split()))
lists.insert(0,0)
anslists=[0]*(n+1)
for j in range(n,0,-1):

    numbers=n//j
    if numbers==1:
        anslists[j]=lists[j]
    else:
        check=0
        for i in range(2,numbers+1):
            check+=anslists[i*j]
            
        if check%2==0:
            anslists[j]=lists[j]
            
        else:
            
            if lists[j]==1:
                anslists[j]=0
                
            if lists[j]==0:
                anslists[j]=1
                

printA=0

del anslists[0]


Anslist=[]
for k in range(n):
    if anslists[k]==1:
        printA+=1
        Anslist.append(k+1)
print(printA)
print(*Anslist)

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

Solution (Python):
n = int(input())
A = list(map(int,input().split()))
B = [0]*n
ans = []
cur = 0
for i in range(n,0,-1):
	
	j = i
	cur = 0
	k = 1
	while j*k <= n:
		
		cur += B[j*k-1]
		k += 1
	if cur % 2 != A[i-1]:
		ans.append(i)
		B[i-1] = 1
	
print(len(ans))
if ans:
	print(*ans[::-1])

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

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

a.insert(0,0)

ans = [0]*(n+1)

for i in range(n,0,-1):
    value = 0
    for j in range(2*i,n+1,i):
        value = value ^ ans[j]
    ans[i] = value ^ a[i]
print(sum(ans))
for i in range(1,n+1):
    if ans[i] == 1:
        print(i,end = " ")

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

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

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

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

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

Solution (Python):
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import bisect
import sys
import logging
import heapq
logging.basicConfig(level=logging.DEBUG)

input = sys.stdin.readline

setrecursionlimit(1000000)

MOD = 10**9+7

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

    ans=[]
    check=[None]+[0]*N

    for i in reversed(range(1,N+1)):
        
        
        if not sum(check[i::i])%2 == A[i]:
            check[i]=1
            ans.append(i)

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

main()

Solution (Python):
N =int(input())
a_list = list(map(int, ("0 " + input()).split()))
put_list = [0] * (N+1)
count = 0
in_list = []
for index in reversed(range(len(a_list))):
    if index == 0:
        break
    upper_index_keisuu = 2
    upper_sum = 0
    while True:
        if index * upper_index_keisuu > (len(a_list)-1):
            break
        upper_sum += put_list[index * upper_index_keisuu]
        upper_sum %= 2
        upper_index_keisuu += 1

    if upper_sum != a_list[index]:
        count += 1
        put_list[index] = 1
        in_list.append(index)


print(count)

if count > 0:
    ret_str = ""
    for add in in_list:
        ret_str += str(add) + " "
    print(ret_str)

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

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    ls = [0] * n
    cnt = 0
    ans = []
    for i in range(n-1, -1, -1):
        t = 0
        for j in range(i, n, (i + 1)):
            t += ls[j]
        if t % 2 != a[i]:
            ls[i] += 1
            cnt += 1
            ans.append(i + 1)
    print(cnt)
    if cnt != 0:
        print(*ans)


if __name__ == '__main__':
    slove()

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

check=[0]*(n+1)
ans=[]

for i in range(n,0,-1):
    if sum(check[2*i::i])%2==a[i]:
        continue
    else:
        check[i]=1
        ans.append(i)
print(len(ans))
print(*ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
Ans = [0 for i in range(n)]
for i in range(1,n + 1)[::-1]:
    count = 0
    mul = 1
    k = i
    while k * mul <= n:
        count += Ans[k * mul - 1]
        mul += 1
    if count % 2 != a[i - 1]:
        Ans[i - 1] = 1
print(sum(Ans))
for i in range(1, n + 1):
    if Ans[i - 1] == 1:
        print("{} ".format(i), end = " ")

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


for i in range(n, 0, - 1):
    k=0
    for j in range(2*i-1, n, i):
        k ^= b[j] & 1
    b[i - 1] = k ^ a[i - 1]
print(sum(b))
for i, j in enumerate(b):
    if j == 1:
        print(i+1)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)
B = [0] * (N + 1)
for i in reversed(range(1, N + 1)):
    sum_val = 0
    for j in range(i*2, N + 1, i):
        sum_val ^= B[j]
    B[i] = sum_val ^ A[i]

ans = [str(idx) for idx, val in enumerate(B) if val == 1]
print(len(ans))
print(" ".join(ans))

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

a.insert(0, 0) 
ans = [0 for _ in range(N+1)]

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

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

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

for i in range(n, 0, -1):
    if i > n//2:
        if a[i-1] == 1:
            box[i-1] += 1
    elif i == 1:
        if a[0] != (sum(box) % 2):
            box[0] += 1
    elif a[i-1] != (sum(box[i-1:: i]) % 2):
        box[i-1] += 1

for i in range(n):
    if box[i] == 1:
        m += 1
        b.append(i+1)

print(m)
for x in b:
    print(x, end=' ')

Solution (Python):

from collections import deque
n=int(input())
a=deque(list(map(int,input().split())))
a.appendleft(0)
b=[0 for i in range(n+1)]
c=[]
m=0
for i in range(n):
    k=2
    sum=0
    while (n-i)*k<=n:
        sum+=b[(n-i)*k]
        k+=1
    if sum%2!=a[n-i]:
        b[n-i]=1
        c.append(n-i)
        m+=1
print(m)
c.sort()
c=list(map(str,c))
print(" ".join(c))

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

memo = [0] * N
for i in range(1, N+1)[::-1]:
    sm = sum([memo[j-1] for j in range(i, N+1, i)])
    memo[i-1] = (sm + a[i-1]) % 2

M = sum(memo)
print(M)

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

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

res = [0] * (n + 1)

for i in range(1, n + 1)[::-1]:
    sum_res = sum(res[x] for x in range(i, n + 1, i))
    if sum_res % 2 != arr[i - 1]:
        res[i] = 1

print(sum(res))

if sum(res):
    ans = []
    for i, elm in enumerate(res):
        if elm:
            ans.append(i)
    print(*ans)

Solution (Python):

import sys

MOD = 2  


def solve(N: int, a: "List[int]"):
    
    tf = [0] * N
    
    m = 0
    x = []
    for i in range(N-1, -1, -1):
        
        b = sum([tf[j] for j in range(i+(i+1), N, i+1)])
        if(b%2 != a[i]):
            m += 1
            x.append(i+1)
            tf[i] = (tf[i]+1)%2
        
    print(m)
    if(x):
        print(' '.join(map(str, x)))

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

if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))

    ans = [False for i in range(n)]

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

    out = list()
    for i in range(n):
        if ans[i]:
            out.append(i + 1)
    print(len(out))
    print(*out)

Solution (Python):
import sys

if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))

    ans = [False for i in range(n)]

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

    out = list()
    for i in range(n):
        if ans[i]:
            out.append(i + 1)
    print(len(out))
    print(*out)

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

for i in range(n-1, -1, -1):
    prev = 0
    index = i+1
    for j in range(2, n+1):
        if (index * j)-1 >= n: break
        prev += ans_list[(index * j)-1]
    if prev % 2 != a[i]:
        ans_list[i] = 1

print(sum(ans_list))
if sum(ans_list) != 0:
    print(' '.join([str(i+1) for i, x in enumerate(ans_list) if x == 1]))

Solution (Python):
import sys
from collections import Counter, deque, defaultdict
from math import factorial
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

n = INT()
A = LIST()
ans = [0]*n
for i in range(n-1,-1,-1):
    res = 0
    j = 0
    while (j+1) *(i+1) <= n:
        res += ans[(j+1)*(i+1)-1]
        j += 1
    if res%2 != A[i]:
        ans[i] = 1
print(ans.count(1))
for i in range(n):
    if ans[i] == 1:
        print(str(i+1)+' ', end = '')

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

for _i in range(N):
    i = N-_i
    cur = i * 2
    sum_b = 0
    

    if i == 0:
        break

    while cur <= N:
        
        sum_b += B[cur-1]
        cur += i

    b = (sum_b + A[i-1]) % 2

    
    if b == 1:
        B[i-1] = b
        bc += 1


print(bc)
if bc > 0:
    print(' '.join([str(i+1) for i in range(N) if B[i] > 0]))

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


for i in range(1,N+1)[::-1]:
    count = 0
    if i > N//2:
        pattern[i-1] = As[i-1]

    else:
        for j in range(2,N//i+1):
            count += pattern[i*j-1]
        if count % 2 == As[i-1]:
            pattern[i-1] = 0
        else:
            pattern[i-1] = 1
s = sum(pattern)
print(s)
if s:
    s = ""
    for i,e in enumerate(pattern):
        if e == 1:
            s += str(i+1)
            s += ' '

    print(s[:-1])

Solution (Python):
import sys

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

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

for i in range(n):
	if b[i] == 1:
		m += 1
		ans.append(i+1)

if not ans:
	print("0")
else:
	print(m)
	for i,x in enumerate(ans):
		if i == 0:
			sys.stdout.write(str(x))
		else:
			sys.stdout.write(" ")
			sys.stdout.write(str(x))

Solution (Python):
import sys
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
ball_ls = [0 for i in range(n)]
for i in range(n-1,-1,-1):
    if i > n / 2 - 1:
        ball_ls[i] = a_ls[i]
    else:
        ball_ls[i] = (sum(ball_ls[i::(i + 1)]) + a_ls[i]) % 2
cnt = sum(ball_ls)
ball_ls = [str(i+1) for i, ball in enumerate(ball_ls) if ball > 0]
print(cnt)
if cnt > 0:
    print(" ".join(ball_ls))

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

cs = [0] * N

for i in range(N):
    j = N - i
    cs[j - 1] = (A[j-1] + sum(cs[j - 1::j])) % 2

rs = []
for i, v in enumerate(cs):
    if v:
        rs.append(i + 1)

print(len(rs))
print(*rs)

Solution (Python):


import math
N = int(input())
a = list(map(int,input().split()))
ball = [0]*N
for i in range(N,0,-1):
    
    stock = 0
    for j in range(i,N+1,i):
        stock += ball[j-1]
        
    if stock %2 == 1:
        if a[i-1] ==1:
            ball[i-1] += 0
        elif a[i-1] == 0:
            ball[i-1] += 1
    elif stock %2 == 0:
        if a[i-1] ==1:
            ball[i-1] += 1
        elif a[i-1] == 0:
            ball[i-1] += 0



ans1 = []
count = 0
for k in range(N):
    if ball[k] == 1:
        ans1.append(k+1)
        count += 1
ans2 = [str(l) for l in ans1]
print(count)
print(' '.join(ans2))

Solution (Python):
n = int(input())
A = list(map(int,input().split()))
M = [0 for i in range(n)]
for i in reversed(range(1,n+1)):
    k = 0
    j = 2*i
    while j<=n:
        if M[j-1] == 1:
            k += 1
        j += i
    if (k+1)%2 == A[i-1]:
        M[i-1] = 1
B = []
for i in range(n):
    if M[i] == 1:
        B += [i+1]
print(len(B))
if len(B) > 0:
    print(*B)

Solution (Python):
def solve(n, a):
    b = [-1] * n
    for i in range(n, 0, -1):
        cnt = 0
        for j in range(2*i, n+1, i):
            cnt += b[j-1]
        p = cnt % 2
        b[i-1] = p ^ a[i-1]
    res = []
    for i, v in enumerate(b):
        if v > 0:
            res.append(i+1)
    m = len(res)
    print(m)
    if m > 0:
        print(" ".join(map(str, res)))

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

Solution (Python):
def solve(string):
    n, *a = map(int, string.split())
    for i in range(n // 2, 0, -1):
        a[i - 1] = sum(a[i - 1::i]) % 2
    ans = [str(i + 1) for i, _a in enumerate(a) if _a == 1]
    return "0" if len(ans) == 0 else "{}\n{}".format(len(ans), " ".join(ans))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Solution (Python):
import numpy as np


def solve(string):
    n, *a = map(int, string.split())
    a = np.asarray([0] + a)
    for i in range(n // 2, 0, -1):
        a[i] = a[i::i].sum() % 2
    ans = np.where(a == 1)[0]
    return "0" if len(ans) == 0 else "{}\n{}".format(len(ans), " ".join(map(str, ans)))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Solution (Python):
from math import ceil


def solve(string):
    n, *a = map(int, string.split())
    t = [0] * n
    ans = []
    for i, _a in zip(range(n, 0, -1), a[::-1]):
        if t[i - 1] % 2 == _a:
            continue
        ans.append(str(i))
        for j in range(1, ceil((i + 1)**0.5)):
            if i % j == 0:
                t[j - 1] += 1
                if j != i // j:
                    t[i // j - 1] += 1
    return "0" if len(ans) == 0 else "{}\n{}".format(len(ans), " ".join(ans[::-1]))

  
if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
B = [0] * N
ans = []
for i in range(N, 0, -1):
    y = 1
    x = i * y
    s = 0
    while x <= N:
        s += B[x-1]
        y += 1
        x = i * y
    if s % 2 != A[i-1]:
        B[i-1] = 1
        ans.append(i)

M = sum(B)
ans = map(str, ans)
ans = " ".join(ans)

print(M)
print(ans)

Solution (Python):

def main():
    N, *A = map(int, open(0).read().split())
    A = [0] + A
    for i in range(N // 2, 0, -1):  
        A[i] = sum(A[i::i]) % 2
    ans = [i for i, j in enumerate(A) if j]
    print(len(ans))
    print(*ans)


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
a_list = list(map(int, input().split()))
b_list = [0 for _ in range(N)]
ans_list = []
ballN = 0
for i in range(N, 0, -1):
    y = 2
    x = i * y
    while x <= N:
        ballN += b_list[x-1]
        y += 1
        x = i * y
    if ballN % 2 == a_list[i - 1]:
        ballN = 0
        continue
    else:
        b_list[i-1] = 1
        ans_list.append(i)
        ballN = 0



ans = map(str, ans_list)
ans = " ".join(ans)

M = sum(b_list)
print(M)
print(ans)

Solution (Python):

import sys
sys.setrecursionlimit(10 ** 7)

MOD = 2  


def solve(N: int, a: "List[int]"):
    ans = [0 for x in range(N)]
    for i in range(N - 1, -1, -1):
        s = 0
        for j in range(i, N, i + 1):
            s += ans[j]
        
        if (s + a[i]) & 1:
            ans[i] = 1
    
    b = int(sum(ans))
    print(b)
    l = []
    if b:
        for i, x in enumerate(ans):
            if x == 1:
                l.append(i + 1)
        print(*l)
    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):
import sys
input = sys.stdin.readline

n = int(input())
a_list = [-1]
a_tmp = list(map(int, input().split()))
a_list.extend(a_tmp)

ball_list = [0]*(n+1)


for i in reversed(range(1, n+1)):
    div = n // i

    sum_ball = 0
    for j in range(2, div+1):
        sum_ball += ball_list[i*j]

    if a_list[i] == 1:
        if sum_ball % 2 == 0:
            ball_list[i] = 1
    else:
        if sum_ball % 2 == 1:
            ball_list[i] = 1

sb = sum(ball_list)
print(sb)
if sb != 0:
    p_a = [str(i) for i in range(1, n+1) if ball_list[i] == 1]
    print(' '.join(p_a))

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

A = [0] + [int(_) for _ in input().split()]
ans = [0] * (N + 1)

for i in range(N, 0, -1):
    ans[i] = A[i]
    j = i * 2
    while j <= N:
        ans[i] += ans[j]
        j += i
    ans[i] = ans[i] % 2


spam = [i for i in range(1, N + 1) if ans[i]]
print(len(spam))
if spam:
    print(*spam)

Solution (Python):
n = int(input())
A = [int(x) for x in input().split()]
B = [0] * n

for i in reversed(range(n)):
    if i + 1 > n // 2:
        B[i] = A[i]
        
    else:
        
        c = n // (i+1)
        s = 0
        for j in range(c):
            s += B[(i+1)*(j+1)-1]
        if s % 2 == A[i]:
            continue
        else:
            B[i] = 1

ans = sum(B)
print(ans)
count = 0
for i in range(len(B)):
    if B[i] == 1:
        count += 1
        if count == ans:
            print(i + 1)
        else:
            print(i + 1, end=' ')

Solution (Python):
n = int(input())
A = [int(x) for x in input().split()]
B = [0] * n

for i in reversed(range(n)):
    if i + 1 > n // 2:
        B[i] = A[i]
        
    else:
        
        c = n // (i+1)
        s = 0
        for j in range(c):
            s += B[(i+1)*(j+1)-1]
        if s % 2 == A[i]:
            continue
        else:
            B[i] = 1

ans = sum(B)
print(ans)
count = 0
for i in range(len(B)):
    if B[i] == 1:
        count += 1
        if count == sum:
            print(i + 1)
        else:
            print(i + 1, end=' ')

Solution (Python):
n = int(input())
AL = [0] + list(map(int, input().split()))
ball_plus_list = [0]*(n+1)
for i in range(n, 0, -1):
    sum_ball = 0
    for j in range(2, n//i + 1):
        sum_ball += ball_plus_list[i*j]
    if sum_ball%2 != AL[i]:
        ball_plus_list[i] = 1

ans = []
for i, ball_exist in enumerate(ball_plus_list):
    if ball_exist == 1:
        ans.append(str(i))
print(len(ans))
print(" ".join(ans))

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

for i in reversed(range(n)):
  if i>=n//2:
    b.append(a[i])
  else:
    
    temp = [b[n-k*(i+1)] for k in range(2,n//(i+1)+1)]
    b.append((sum(temp)-a[i])%2)

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

Solution (Python):
N = int(input())
a_list = list(map(int, input().split()))
n_dict = {i:0 for i in range(1, N+1)}

for i in range(N, 0, -1):
    j = i
    a = a_list[j-1]
    temp_a = 0
    while j <= N:
        temp_a += n_dict[j]
        j += i
    if temp_a % 2 == a:
        pass
    else:
        n_dict[i] = 1

ans_num = list(n_dict.values())
ans_num = ans_num.count(1)
print(ans_num)

ans_str = ""
for i in range(1, N+1):
    if n_dict[i] == 1:
        if ans_str == "":
            ans_str = str(i)
        else:
            ans_str += " "+str(i)
if ans_str == "":
    pass
else:
    print(ans_str)

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

ans=[n for n,x in enumerate(b) if x==1]
print(len(ans))
print(*ans)

Solution (Python):
N = int(input())
a_list = list(map(int, input().split()))
n_dict = {i:0 for i in range(1, N+1)}

for i in range(N, 0, -1):
    j = i
    a = a_list[j-1]
    temp_a = 0
    while j <= N:
        temp_a += n_dict[j]
        j += i
    if temp_a % 2 == a:
        pass
    else:
        n_dict[i] = 1

ans_num = list(n_dict.values())
ans_num = ans_num.count(1)
print(ans_num)

ans_str = ""
for i in range(1, N+1):
    if n_dict[i] == 1:
        if ans_str == "":
            ans_str = str(i)
        else:
            ans_str += " "+str(i)
if ans_str == "":
    pass
else:
    print(ans_str)

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

for i in range(N - 1, -1, -1):
    if score[i] % 2 != A[i]:
        ans.append(i + 1)
        divisors = make_divisors(i + 1)
        for v in divisors:
            score[v - 1] += 1



print(len(ans))
if len(ans) != 0:
    for v in ans:
        print(v, end=" ")

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

ansCount = 0
ansIndices = []
for idx, content in enumerate(boxes):
    if content:
        ansCount += 1
        ansIndices.append(idx + 1)

print(ansCount)
if ansCount > 0:
    print(" ".join(map(str, ansIndices)))

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

for i in range(N, 0, -1):
  x=sum(b[2*i::i])
  
  if x%2!=a[i]:
    b[i]=1
    
print(sum(b))
for i in range(1, N+1):
  if b[i]==1:
    print(str(int(i)), end=' ')

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

Solution (Python):

N = int(input())
a = [0]+list(map(int,input().split()))
ans = [0]*(N+1)
an = []
for i in range(N,0,-1):
  c =0
  c = sum(ans[2*i::i])
  if c%2!=a[i]:
    ans[i]=1
    an.append(i)
print(len(an))
for i in range(len(an)):
  print(an[i],end=" ")

Solution (Python):

N = int(input())
a = [0]+list(map(int,input().split()))
ans = [0]*(N+1)
an = []
for i in range(N,0,-1):
  c =0
  b = [i*j for j in range(2,N//i+1)]
  for j in b:
    c +=ans[j]
  c = c%2
  if c!=a[i]:
    ans[i]=1
    an.append(i)
print(len(an))
for i in range(len(an)):
  print(an[i],end=" ")

Solution (Python):

N = int(input())
a = [0]+list(map(int,input().split()))
ans = [0]*(N+1)
an = []
for i in range(N,0,-1):
  c =0
  b = [i*j for j in range(2,N//i+1)]
  for j in b:
    c +=ans[j]
  c = c%2
  if c!=a[i]:
    ans[i]=1
    an.append(i)
print(len(an))
for i in range(len(an)):
  print(an[i],end=" ")

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

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

    count = 0
    ball = [0] * (N+1)

    for i in range(N, 0, -1):
        tmp = 0
        for j in range(i*2, N+1, i):
            tmp += ball[j]
        if tmp%2 != a[i-1]:
            ball[i] = 1
            count += 1
    
    print(count)
    if count > 0:
        for i in range(1, N+1):
            if ball[i] == 1:
                print(i, end=" ")
        print()


if __name__ == "__main__":
    main()

Solution (Python):

n = int(input())
a = list(map(int,input().split()))
b = [0 for _ in range(n)]
for i in range(n,0,-1):
  tmp = 0
  here = i
  while True:
    try:
      tmp ^= b[here-1]
      here += i
    except:
      tmp ^= a[i-1]
      break
  if tmp == 1:
    b[i-1] = 1
print(sum(b))
c = []
for i in range(n):
  if b[i] == 1:
    c.append(i+1)
print(' '.join(list(map(str,c))))

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

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

print(sum(a))

for j in range(1, n+1):
  if a[j] == 1:
    print(j)

Solution (Python):
n,a=open(0);n=int(n);b=[0]*-~n
for x in range(n,0,-1):b[x]=(sum(b[x::x])+int(a[x*2-2]))%2
print(sum(b));print(*[i+1for i in range(n)if b[i+1]])

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

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

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

Solution (Python):
import numpy as np
N = int(input())
A = [int(x) for x in input().split()]
solls = np.zeros(N+1)
A.insert(0,0)
solls[N//2+1:] = A[N//2+1:]

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

s = 0
ls = []
for i in range(N+1):
    if solls[i] == 1:
        ls.append(i)
        s = s+1

print(s)
print(*ls)

Solution (Python):
import numpy as np
n = int(input())
a = [int(i) for i in input().split(" ")]
b = [0 for i in range(n//2)] + a[n//2:]
for i in range(n//2-1, -1, -1):
    if sum(b[i::i+1])%2 != a[i]:
        b[i] = 1
te = sum(b)
if te == 0:
    print(0)
else:
    print(te)
    print(" ".join(map(str, np.where(np.array(b)==1)[0]+1)))

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

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
b = [0 for i in range(n)]
	
for i in range(n)[::-1]:
	sm = 0
	for j in range(n):
		if (j + 1) * (i + 1) <= n:
			sm += b[(j + 1) * (i + 1) - 1]
		else:
			break
	if sm % 2 != a[i]:
		b[i] += 1

ans = [str(i + 1) for i, bb in enumerate(b) if bb == 1]
nans = len(ans)
print(nans)
if nans != 0:
	print(' '.join(ans))

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

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

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

Solution (Python):
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
import numpy as np

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N = int(input())
    AS = [0] + list(map(int, input().split()))

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

    print(res.count(1))
    if res.count(1) != 0:
        print(*[i for i,r in enumerate(res) if r == 1])

if __name__ == '__main__':
    main()