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 = [0] + list(map(int, input().split()))



def make_divisors(n):
    import math
    divisors = []
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0: 
            divisors.append(i)
            if i != n//i:
                divisors.append(n//i)
    
    return divisors

B = [0] * (N + 1)
ans = [0] * (N + 1)
for i in range(N, 0, -1):
    if B[i] == A[i]:
        continue
    ans[i] = 1
    lst = make_divisors(i)
    for tmp in lst:
        B[tmp] += 1
        B[tmp] %= 2

M = sum(ans)
print (M)
for index, b in enumerate(ans):
    if b == 1:
        print (index, end = ' ')

Solution (Python):
n = int(input())
a = [0]+list(map(int,input().split()))
ans = [-1]*(n+1)
for i in range(n,0,-1):
    res = 0
    for j in range(i+i,n+1,i):
        res += ans[j]
    ans[i] = (res - a[i])%2
p = []
for ind,v in enumerate(ans):
    if v== -1:continue
    if v == 1:p.append(ind)

print(len(p))
print(*p)

Solution (Python):
def main():
    n = int(input())
    a = [0] + [int(x) for x in input().split()]
    balls = [0 for _ in range(n + 1)]
    answer = []
    for i in range(n, 0, -1):
        if sum(balls[i::i]) % 2 != a[i]:
            balls[i] += 1
            answer.append(i)
    print(sum(balls))
    print(" ".join(map(str, answer)))


if __name__ == '__main__':
    main()

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

box = [0] * N
for i in range(N - 1, -1, -1):
    cnt = 0
    num = i + 1
    while num <= N:
        cnt += box[num - 1]
        num += i + 1
    
    if cnt % 2 != A[i]:
        box[i] = 1
    
ans = [idx + 1 for idx in range(N) if box[idx]]

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

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

for i in range(N, 0, -1):
  cnt = 0
  for j in range(2, (N//i) + 1):
    cnt += afterA[j*i-1] 
  if(cnt % 2 != A[i-1]):
    afterA[i-1] = 1 
    ans.append(i)
  
print(sum(afterA))
print(*ans)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
M = 0
b = [0]*N
B = []
for i in range(N, 0, -1):
    wa = sum(b[i-1::i])
    if wa%2 != a[i-1]:
        M+=1
        b[i-1] = 1
        B.append(i)
print(M)
if M!=0:
    print(*B)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
M = 0
b = [0]*N
B = []
for i in range(N, 0, -1):
    wa = 0
    cnt = 1
    while i*cnt <= N:
        wa += b[i*cnt-1]
        cnt+=1
    if wa%2 != a[i-1]:
        M+=1
        b[i-1] = 1
        B.append(i)
print(M)
if M!=0:
    print(*B)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque

from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [LI()for i in range(n)]
inf = 10**17
mod = 10**9 + 7

n=I()
As=list(map(int,input().rstrip().split(" ")))


ans=[0 for i in range(n)]
for i in range(n//2,n):
    ans[i]=As[i]

for j in range(n//2):
    k=n//2-j-1
    ball=0
    for l in range(2,n//(k+1)+1):
        ball+=ans[(k+1)*l-1]
        if ball%2==As[k]:
            ans[k]=0
        else:
            ans[k]=1
print(sum(ans))
for i in range(n):
    if ans[i]==1:
        print(i+1,end=" ")

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque

from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [LI()for i in range(n)]
inf = 10**17
mod = 10**9 + 7

n=I()
As=list(map(int,input().rstrip().split(" ")))


ans=[0 for i in range(n)]
for i in range(n//2,n):
    ans[i]=As[i]

for j in range(n//2):
    k=n//2-j-1
    ball=0
    for l in range(2,n//(k+1)+1):
        ball+=ans[(k+1)*l-1]
        if ball%2==As[k]:
            ans[k]=0
        else:
            ans[k]=1
print(sum(ans))
for i in range(n):
    if ans[i]==1:
        print(i+1,end=" ")

Solution (Python):
import sys
import math  
import bisect  
import queue  


def input():
    return sys.stdin.readline().rstrip()


if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))

    B = [0 for _ in range(N)]
    for i in range(N - 1, N // 2 - 1, -1):
        B[i] = A[i]
    for i in range(N // 2 - 1, -1, -1):
        res = 0
        for j in range(i, N, i + 1):
            res += B[j]
        if res % 2 == 0 and A[i] == 1:
            B[i] = 1
        elif res % 2 != 0 and A[i] == 0:
            B[i] = 1

    cnt = 0
    for b in B:
        if b == 1:
            cnt += 1
    print(cnt)
    if cnt > 0:
        res = [i + 1 for i, b in enumerate(B) if b != 0]
        print(*res)

Solution (Python):
def solve(k):
    
    num = int(k**0.5)
    l = []
    for i in range(1, num + 1):
        if k % i == 0:
            l.append(i)
            l.append(k//i)
    return set(l)

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

box = [0] * n
ans = [0] * n
cnt = 0
for i in range(n):
    if box[-(i + 1)] != a[-(i + 1)]:
        cnt += 1
        ans[-(i + 1)] = 1
        num = solve(n - i)
        for j in num:
            box[j - 1] = (box[j - 1] + 1) % 2
print(cnt)
for i in range(n):
    if ans[i]:
        print(i + 1)

Solution (Python):
n = int(input())
ns = list(map(int, input().split()))
rslt = [0] * n
r = n - 1 
while r >= 0:
    if sum(rslt[r:n:r+1]) % 2 != ns[r]:
        rslt[r] += 1
    r -= 1
print(sum(rslt))
if sum(rslt):
    print(*[i+1 for i, num in enumerate(rslt) if num == 1])

Solution (Python):


data=int(input())
array=list(map(int,input().split()))

result=[]
box=[0]*data

for i in reversed(range(1,data+1)):
  asum=sum(box[i-1::i])
  if asum%2+array[i-1]==1:
    box[i-1]=1
    result.append(i)

print(len(result))
print(*result)

Solution (Python):
import math
import collections
from operator import mul
from functools import reduce
import bisect
import string
import copy

def search(b,ind,n):
    sum=0
    while(ind*n<len(b)):
        sum+=b[ind*n]
        n+=1
    return sum%2

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

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

Solution (Python):


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

check=[0 for i in range(N)]
M=0
b=[]
for j in reversed(range(1,N+1)):
    total=0
    for k in range(1,int(N/j)+1):
        total+=check[int(j*k)-1]
    if a[j-1]!=total%2:
        M+=1
        check[j-1]=1
        b.append(j)

print(M)
for l in range(len(b)):
    print(b[l],end=' ')
else:
    print()

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

for k in range(400):
    if m % 2 == 0:
        m //= 2
        for i in range(m+1,2*m+1):
            al = 0
            for j in range(i,2*n+1,i):
                al += ans[j]
            ans[i] = (a[i] + al) % 2
            
    else:
        m //= 2
        for i in range(m+1,2*m+2):
            al = 0
            for j in range(i,2*n+1,i):
                al += ans[j]
            ans[i] = (a[i] + al) % 2
            
    if m <= 0:
        break
        
ans2 = ans[1:n+1]
q = []
aa = 0
for i in range(n):
    if ans2[i] == 1:
        q.append(i+1)
        aa += 1
        
print(aa)
print(*q)

Solution (Python):
from collections import deque

n = int(input())
l = list(map(int, input().split()))
ans = deque()
ans2 = 0
now = [0]*n

for i in range(n):
  i = n-i
  zoom = 2
  cnt = 0
  while i*zoom <= n:
    cnt += now[i*zoom-1]
    zoom += 1
  if (l[i-1] + cnt) % 2 == 1:
    now[i-1] = 1
    ans.appendleft(i)
    ans2 += 1
    
print(ans2)
print(*ans)

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

N = int(input())
A = [None] + list(map(int, input().split()))
answer = []
B = [0] * (N + 1)

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

N = int(input())
A = [None] + list(map(int, input().split()))
answer = []
B = [0] * (N + 1)

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

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

Solution (Python):
import math
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
b = [0]*(N+1)
a = [0] + a
for i in range(N, 0, -1):
  tmp = 0
  for j in range(1, N//i+1):
    tmp += b[i*j]
  tmp %= 2
  if a[i] == tmp:
    continue
  elif a[i] == 1 and tmp == 0:
    b[i] += 1
  elif a[i] == 0 and tmp == 1:
    b[i] += 1
  
M = 0
for i in range(1, N+1):
  if b[i] == 1:
    M += 1
print(M)
for i in range(1, N+1):
  if b[i] == 1:
    print(i, end=" ")

Solution (Python):
N = int(input())
boxes = [0] * (N + 1)
ans = tuple(n for n, digit in reversed(tuple(enumerate(map(int, input().split()), 1))) if (sum(d for d in boxes[n::n]) & 1 != digit and (boxes.__setitem__(n, 1) or 1)))
print("%d\n" % len(ans), *ans)

Solution (Python):
N = int(input())
boxes = [0] * (N + 1)
ans = tuple(n for n, digit in reversed(tuple(enumerate(map(int, input().split()), 1))) if (sum(d for d in boxes[n::n]) & 1 != digit and (boxes.__setitem__(n, 1) or 1)))
print(len(ans))
print(*ans)

Solution (Python):
N = int(input())
boxes = [0] * (N + 1)
ans = tuple(n for n, digit in reversed(tuple(enumerate(map(int, input().split()), 1))) if (sum(d for d in boxes[n::n]) & 1 != digit and (boxes.__setitem__(n, 1) or 1)))

print(len(ans))
if ans:
    print(*ans)

Solution (Python):
N = int(input())
A = reversed(tuple(enumerate(map(int, input().split()), 1)))

boxes = [0] * (N + 1)
ans = []

for n, digit in A:
    put = sum(d for d in boxes[n::n]) & 1 != digit
    if put:
        boxes[n] = 1
        ans.append(n)

print(len(ans))
if ans:
    print(*ans)

Solution (Python):
def main():
    n = int(input())
    a = list(map(int,input().split()))
    ans = [0 for i in range(n+1)]
    for i in range(n):
        s = 0
        k = n-i
        for j in range(1,n//k+1):
            s += ans[k*j]
        if s%2!=a[k-1]:
            ans[k] = 1
    print(sum(ans))
    if sum(ans)!=0:
        print(' '.join([str(i) for i , x in enumerate(ans) if x==1]))



if __name__ == "__main__":
    main()

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7


def main():
  N = int(readline())
  A = [None] + list(map(int, readline().split()))
  ans = []
  choosen = [0] * (N+1)
  
  for n in range(N,0,-1):
    x = sum(choosen[n::n])
    if x %2 == A[n]:
      continue
    choosen[n] += 1
    ans.append(str(n))
  print(len(ans))
  print(' '.join(ans))
  
  
if __name__ == '__main__':
  main()

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

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

    sum_b = sum(A)
    print(sum_b)
    if sum_b:
        ans = [i for i, v in enumerate(A) if v == 1]
        print(*ans, sep='\n')


if __name__ == "__main__":
    main()

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

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

    sum_b = sum(A)
    print(sum_b)
    if sum_b:
        ans = [i for i, v in enumerate(A) if v == 1]
        print(*ans, sep='\n')


if __name__ == "__main__":
    main()

Solution (Python):
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()
a = na()

d = [0] * n
for i in range(n // 2, n):
    d[i] = a[i]

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

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

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

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

    sum_b = sum(A)
    print(sum_b)
    if sum_b:
        ans = [str(i) for i, v in enumerate(A) if v == 1]
        print('\n'.join(ans))


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
nums = [int(i) for i in input().split()]
box = [0] * n
for i in range(1, n + 1)[::-1]:
    c = i * 2
    ball = nums[i - 1]
    while c <= n:
        ball = ball ^ box[c - 1]
        c += i
    box[i - 1] = ball

ans = box.count(1)
print(ans)
ball = []
for i in range(n):
    if box[i] == 1:
        ball.append(i + 1)
print(*ball)

Solution (Python):
n = int(input())
nums = [int(i) for i in input().split()]
box = [0] * n
for i in range(1, n + 1)[::-1]:
    c = i * 2
    ball = nums[i - 1]
    while c <= n:
        ball = ball ^ box[c - 1]
        c += i
    box[i - 1] = ball

ans = box.count(1)
print(ans)
ball = []
for i in range(n):
    if box[i] == 1:
        ball.append(i + 1)
print(*ball)

Solution (Python):
import sys

N = int(input())
a = list(map(int, sys.stdin.readline().split()))
box = [0] * N
if N % 2 == 0:
    half = N // 2 - 1
else:
    half = N // 2
    
ball_count = 0
ball_box = []

for i in range(N - 1, -1, -1):
    m = N // (i + 1)
    count = 0
    for j in range(1, m + 1):
        count += box[(i + 1) * j - 1]
        count %= 2
    if a[i] != count:
        box[i] = 1
        ball_count += 1
        ball_box.append(i + 1)
            
print(ball_count)
if ball_box != 0:
    ball_box = [str(ball_box[i]) for i in range(ball_count - 1, -1, -1)]
    box_ans = " ".join(ball_box)
    print(box_ans)

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

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

Solution (Python):

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

box = [0 for _ in range(n)]
result = []
def baisu(n,max_n):
    ans = []
    cnt = 1
    while n*cnt <= max_n:
        ans.append(n*cnt)
        cnt += 1  
    return ans

for i in range(n-1,-1,-1):
    if i+1 > n//2:
        box[i] = a[i]
        
    else:
        num = baisu(i+1,n)
        tmp = 0
        for j in num:
            tmp += box[j-1]
        if tmp % 2 == a[i]:
            box[i] = 0
            
        else:
            box[i] = 1
            
for i,j in enumerate(box):
    if j == 1:
        result.append(i+1)
        
if result == []:
    print(0)
else:
    print(len(result))
    print(*result)

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

b = [False] * n
b_index = []
b_count = 0
for i in range(n-1, -1, -1):
  flag = bool(a[i])
  for j in range(2*i+1, n, i+1):
    flag ^= b[j]
  b[i] = flag
  if flag:
    b_index.append(str(i+1))
    b_count += 1
print(b_count)
print(' '.join(b_index))

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

def check():
    balls = [None] * N  
    for i in range(N-1,-1,-1):
        k = i+1
        if 2*k > N:
            balls[i] = A[i]
            continue
        r = 0
        for j in range(2*k-1,N,k):
            r = (r + balls[j]) & 1
        balls[i] = r ^ A[i]
    return [i+1 for i, b in enumerate(balls) if b]

c = check()
if c is None:
    print(-1)
else:
    print(len(c))
    if c:
        print(*c)

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

res = [0] * N
for idx, ai in zip(range(N-1, -1, -1), As[::-1]):
    oe = sum([res[i] for i in range(idx, N, idx+1)]) % 2
    res[idx] = ai ^ oe

print(sum(res))
idxs = []
for i, val in enumerate(res):
    if val:
        idxs += [i + 1]
print(*idxs)

Solution (Python):
n = int(input())
nums = [int(i) for i in input().split()]
box = [-1] * n
for i in range(1, n + 1)[::-1]:
    c = i * 2
    ball = nums[i - 1]
    while c <= n:
        ball = ball ^ box[c - 1]
        c += i
    box[i - 1] = ball

ans = box.count(1)
print(ans)
ball = []
for i in range(n):
    if box[i] == 1:
        ball.append(i + 1)
print(*ball)

Solution (Python):
n = int(input())
nums = [int(i) for i in input().split()]
box = [-1] * n
for i in range(1, n + 1)[::-1]:
  C = i * 2
  BALL = nums[i-1]
  while C <= n:
    BALL = BALL ^ box[C-1]
    C += i
  box[i-1] = BALL 

print(box.count(1))
ball = []
for i in range(n):
  if box[i] == 1:
    ball.append(i + 1)
print(*ball)

Solution (Python):
n = int(input())
nums = list(map(int, input().split()))
ans = [-1] * n
for i in range(1, n + 1)[::-1]:
  C = i * 2
  BALL = nums[i-1]
  while C <= n:
    BALL = BALL ^ ans[C-1]
    C += i
  ans[i-1] = BALL 

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

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

for _ in range(n):
  ans.append(-1)

for i in range(1, n + 1)[::-1]:
  C = i * 2
  BALL = nums[i-1]
  while C <= n:
    BALL = BALL ^ ans[C-1]
    C += i
  ans[i-1] = BALL 

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

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

for _ in range(n):
  ans.append(-1)

for i in range(1, n + 1)[::-1]:
  C = i*2
  BALL = nums[i-1]
  while C <= n:
    BALL = BALL ^ ans[C-1]
    C += i
  ans[i-1] = BALL 

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

L=[str(a) for a in ans2]
L=" ".join(L)
print(L)

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

for _ in range(N):
  ans.append(-1)

for i in range(1, N + 1)[::-1]:
  C = i*2
  BALL = A[i-1]
  while C <= N:
    BALL = BALL ^ ans[C-1]
    C += i
  ans[i-1] = BALL 

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

L=[str(a) for a in ans2]
L=" ".join(L)
print(L)

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

for _ in range(N):
  ans.append(-1)

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

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

L=[str(a) for a in ans2]
L=" ".join(L)
print(L)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
B=[0]*N
for n in range(N,0,-1):
    if A[n-1]==1:
        B[n-1]=1
        for x in range(1,int(n**0.5)+1):
            if n%x==0:
                if x**2==n:
                    A[x-1]=(A[x-1]+1)%2
                else:
                    y=n//x
                    A[x-1]=(A[x-1]+1)%2
                    A[y-1]=(A[y-1]+1)%2
print(sum(B))
for i in range(N):
    if B[i]==1:
        print(i+1,end=" ")

Solution (Python):
def main():
    n = int(input())
    b = [0] * n
    for i, ai in enumerate([int(i) for i in input().split()][::-1]):
        m = n - i
        c = 0
        for j in range(m * 2, n + 1, m):
            c += b[j - 1]
        b[m - 1] += ai ^ (c % 2)
    c = [i + 1 for i, bi in enumerate(b) if bi]
    print(len(c))
    print(*c)

if __name__ == '__main__':
    main()

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

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

M=0
s=''

for i in range(1,N+1):
    if b[i]==1:
        s+=str(i)+' '
        M+=1

print(M)
if M>0:
    print(s[:-1])

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

for _ in range(N):
  ans.append(-1)

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

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

L=[str(a) for a in ans2]
L=" ".join(L)
print(L)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


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(readline())
a = list(map(int, readline().split()))
a = a[::-1]
cnt = [0] * n
ans = []
for i in range(n):
    if cnt[n - i - 1] % 2 != a[i]:
        ans.append(n - i)
        memo = make_divisors(n - i)
        for j in range(len(memo)):
            cnt[memo[j] - 1] += 1
print(len(ans))
print(*ans[::-1])

Solution (Python):

import sys

MOD = 2  


def solve(N: int, a: "List[int]"):

    box = [0]*N

    for x in range(N, 0, -1):
        ca = N // x
        t = 0
        for i in range(1,ca+1):
            t += box[i*x-1]
        
        if t%2 != a[x-1]:
            box[x-1] = 1

    print(sum(box))
    if sum(box) !=0:
        ans = [x for x in range(1, N+1) if box[x-1]==1]
        print(*ans)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    a = [int(next(tokens)) for _ in range(N)]  
    solve(N, a)

if __name__ == '__main__':
    main()

Solution (Python):


N = int(input())
a = list(map(int,input().split()))
b = [0]*N
for i in reversed(range(1,N+1)):
    c = 0
    for d in reversed(range(N//i)):
        c += b[i*(d+1)-1]
    
    if c%2==a[i-1]:
        b[i-1] = 0
    else:
        b[i-1] = 1
print(sum(b))
if sum(b)>0:
    print(*[i+1 for i in range(N) if b[i]==1])

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]


 
N = ii()
A = li()
 
for i in reversed(range(N)):

    ind = 2*(i+1)
    while(ind-1 < N):
        A[i] ^= A[ind-1]
        ind += i+1
 
print(sum(A))

ans = ''
for i in range(N):
    if A[i] == 1:
        ans += str(i+1) + ' '
if ans != '':
    print(ans[:-1])

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]


 
N = ii()
A = li()
 
A_f = A[:N//2]
A_l = A[N//2:]
 
table = [0] * (N//2)
 
for i in reversed(range(N//2)):
    ind = i+1
    while(ind-1 < N):
        if ind-1 < N//2 and ind!=i+1:
            table[i] += table[ind-1]
        else:
            table[i] += A[ind-1]
        ind += i+1
    table[i] %= 2
 
table += A_l
 
ans = ''
print(sum(table))

for i in range(N):
    if table[i]%2 == 1:
        ans += str(i+1) + ' '
 
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]



N = ii()
A = li()
'''
for i in reversed(range(N//2)):
    ind = i+1
    ind += i+1
    while(ind-1 < N):
        A[i] += A[ind-1]
        ind += i+1
    A[i] %= 2
'''

for i in reversed(range(N)):
    ind = 2*(i+1)
    while(ind-1 < N):
        A[i] += A[ind-1]
        ind += i+1
    if i < N//2:
        A[i] %= 2

ans = ''
print(sum(A))
for i in range(N):
    if A[i]%2 == 1:
        ans += str(i+1) + ' '

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

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]



N = ii()
A = li()

for i in reversed(range(N//2)):
    ind = i+1
    ind += i+1
    while(ind-1 < N):
        A[i] += A[ind-1]
        ind += i+1
    A[i] %= 2

'''
for i in range(N):
    ind = 2*(i+1)
    while(ind-1 < N):
        A[i] += A[ind-1]
        ind += i+1
    A[i] %= 2
'''

ans = ''
print(sum(A))
for i in range(N):
    if A[i]%2 == 1:
        ans += str(i+1) + ' '

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

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]



N = ii()
A = li()

A_f = A[:N//2]
A_l = A[N//2:]

for i in reversed(range(N//2)):
    ind = i+1
    ind += i+1
    while(ind-1 < N):
        A[i] += A[ind-1]
        ind += i+1
    A[i] %= 2



ans = ''
print(sum(A))
for i in range(N):
    if A[i]%2 == 1:
        ans += str(i+1) + ' '

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

Solution (Python):
def check(n):
    num=int(n**0.5)
    l=[]
    for i in range(1,num+1):
        if n%i==0:
            l.append(i)
            l.append(n//i)
    return set(l)

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

box=[0]*n
cnt=0
ans=[0]*n
for i in range(n):
    if a[-(i+1)]==box[-(i+1)]:continue
    cnt+=1
    ans[-(i+1)]=1
    l=check(n-i)
    for j in l:
        box[j-1]=(box[j-1]+1)%2

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

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
b=(N//2)+1

ans=[]
for _ in range(N):
    ans.append(0)
for i in range(b-1,N):
    ans[i]=A[i]


for j in range(0,b-1)[::-1]:
    n=2
    sum=0
    while True:
        if n*(j+1)-1<=N-1:
            sum+=ans[n*(j+1)-1]
            n+=1
        else:
            break
    if sum%2!=A[j]:
        ans[j]=1

M=0
Ans=[]
for k in range(N):
    if ans[k]==1:
        M+=1
        Ans.append(k+1)
print(M)
if len(Ans)>0:
    print(*Ans)

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

box = [0] * n
ans = []
for i in range(n, 0, -1):
    if sum(box[i - 1:n:i]) % 2 != a[i - 1]:
        box[i - 1] = 1
        ans.append(i)

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