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

Solution (Python):
import sys
input = sys.stdin.readline
LOCAL = len(sys.argv) > 1 and sys.argv[1] == 'LOCAL'


def dprint(*args):
  if LOCAL:
    print(*args)


n = int(input())
a = [None] + list(map(int, input().split()))

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

dprint(b)

print(b.count(1))
for i, x in enumerate(b):
  if x == 1:
    print(i, end=' ')

Solution (Python):
n=int(input())
A=list(map(int,input().split()))
choice=[0]*n
ans=[]
cnt=0
for i in range(n-1,-1,-1):
    a=i+1
    c=0
    a+=i+1
    while a<=n:
        c+=choice[a-1]
        a+=i+1
    if c%2!=A[i]:
        choice[i]+=1
        ans.append(i+1)
        cnt+=1
if cnt==0:
    print(0)
else:
    print(cnt)
    ans.sort()
    print(*ans, sep=' ')

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
aN = 0
al = [0] * (N + 1)
ans = []
for i in reversed(range(1, N + 1)):
    total = 0
    for j in range(2 * i, N + 1, i):
        total += al[j]
    if total % 2 != a[i - 1]:
        al[i] = 1
        ans.append(i)
ans.reverse()
print(len(ans))
for i in ans:
    print(i, end=' ')

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

ans = [0 for _ 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 % 2 == a[i]:
        ans[i] = 0
    else:
        ans[i] = 1
print(sum(ans))
print(*[i + 1 for i, j in enumerate(ans) if j == 1])

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
B = [0 for _ in range(N)]
for i in range(N, 0, -1):
  S = sum(B[(m+1)*i-1] for m in range(1, N//i))
  B[i-1] = (A[i-1] + S) % 2
C = []
for i in range(N):
  if B[i] == 1:
    C.append(i+1)
print(len(C))
for i in range(len(C)):
  if i != len(C) - 1:
    print(C[i], end = ' ')
  else:
    print(C[i])

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

ans = []

i = 0
while i < n:
    j = k = n - i
    add = j
    times = n - i
    cnt = 0

    if j == 1:
        cnt = sum(b)
    else:
        while j <= n:
            cnt += b[j-1]
            j += add

    
    if cnt % 2 != a[k-1]:
        b[k-1] = 1
        ans.append(k)
    else:
        b[k-1] = 0

    i += 1

print(len(ans))
if len(ans) > 0: print(*ans[::-1])

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

N = int(input())
a = list(map(int,input().split()))
a.insert(0,-1)

for i in range(N,0,-1):
    k=2
    temp=a[i]
    while i*k<=N:
        if a[i*k]==1:
            temp = (temp+1)%2
        k+=1
    a[i] = temp

M=0
b=[]
for i in range(1,N+1):
    if a[i]==1:
        M+=1
        b.append(i)

print(M)
[print(x) for x in b]

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

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



for i in range(N,0,-1):
    k=2
    temp=a[i-1]
    
    while i*k<=N:
        if a[i*k-1]==1:
            temp = (temp+1)%2
        k+=1
    a[i-1] = temp

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

print(M)
[print(x) for x in b]

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

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
b = []
arr = [-1] * N
for i in range(N, 0, -1):
  s = 0
  j = i * 2
  while j <= N:
    s += arr[j - 1]
    j += i
  if s % 2 != a[i - 1]:
    arr[i - 1] = 1
    b.append(i)
  else:
    arr[i - 1] = 0
print(len(b))
print(*b)

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

r = [0] * N


def f(n):
    """
    nの倍数のボールの数
    """
    cnt = 0
    t = n + n
    while t <= N:
        cnt += r[t-1]
        t += n
    return cnt


for i in range(N):
    n = N - i
    x = f(n)
    if x % 2 == A[n-1]:
        pass
    else:
        r[n-1] += 1



ans = []
for i, ri in enumerate(r):
    if ri == 1:
        ans.append(str(i+1))

if len(ans) == 0:
    print(0)
else:
    print(len(ans))
    print(" ".join(ans))

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

r = [0] * N


def f(n):
    """
    nの倍数のボールの数
    """
    cnt = 0
    i = 2
    while n * i <= N:
        cnt += r[n*i-1]
        i += 1
    return cnt


for i in range(N):
    n = N - i
    x = f(n)
    if x % 2 == A[n-1]:
        pass
    else:
        r[n-1] += 1



ans = []
for i, ri in enumerate(r):
    if ri == 1:
        ans.append(str(i+1))

if len(ans) == 0:
    print(0)
else:
    print(len(ans))
    print(" ".join(ans))

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

for n in range(N):
    m = N - n
    q = N // m
    r = 0
    for q0 in range(2, q + 1):
        r += b[m * q0] % 2
    b[m] = (a[m] - r) % 2
print(sum(b))
ans = []
for n in range(N):
    m = N - n
    if b[m] == 1:
        ans.append(m)
print(*ans)

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

r = [None] * N




def f(n):
    i = 2
    cnt = 0
    while n * i <= N:
        
        cnt += r[(n * i)-1]
        i += 1
    
    return cnt

n = N
while n > 0:
    c = f(n)
    
    if c % 2 == A[n-1]:
        r[n-1] = 0
    else:
        r[n-1] = 1
    n -= 1



r_a = []
r_cnt = r.count(1)
print(r_cnt)
for i, ri in enumerate(r):
    if ri == 1:
        r_a.append(str(i+1))

if r_cnt != 0:
    print(" ".join(r_a))

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    b = [0]*(n+1)
    for i in range(1,n+1)[::-1]:
        x = i
        s = 0
        while x <= n:
            s ^= b[x]
            x += i
        b[i] = s^a[i-1]
    ans = [i for i in range(1,n+1) if b[i]]
    print(len(ans))
    print(*ans)
    return


if __name__ == "__main__":
    solve()

Solution (Python):
import sys
input = sys.stdin.readline
N=int(input())
a=list(map(int,input().split()))
a0 = a[0]
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    
    return divisors
ma = N
mi = N//2
for i in range(len(bin(N))-2):
    for j in range(ma,mi,-1):
        if a[j-1]%2==1:
            tg_list = make_divisors(j)
            for k in tg_list:
                if k!=j:
                    a[k-1] += 1
    
    
    ma = mi
    mi = mi//2
if sum(a)%2 == a0:
    
    res = [str(i+1) for i in range(N) if a[i]%2==1]
    M = len(res)
    print(M)
    if M!=0:
        print(' '.join(res))
else:
    print(-1)

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

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

Bo = [0 for _ in range(n)]
Ans = []

for i in range(n-1, -1, -1):
    tot = sum(Bo[i::i+1])

    if (tot % 2 == A[i]):
        pass
    elif (tot % 2 != A[i]):
        Ans.append(str(i+1))
        Bo[i] += 1
    else:
        pass
if len(Ans) ==0:
    print(0)
else:
    print(len(Ans))
    print(' '.join(Ans))

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

a = [0]+a
ball = [0]+ball

for i in range(N,0,-1):
  num = 0
  for j in range(i,N+1,i):
    num += ball[j]
  if num%2 != a[i]:
    ball[i] += 1
    
print(sum([1 for i in range(len(ball)) if ball[i]]))
num_list = []
for i in range(1,len(ball)):
  if ball[i]:
    num_list.append(i)
    
print(*num_list)

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
x = [0]*(n+1)
m = 0
ans = []
for i in reversed(range(1,n+1)):
  tmp = 0
  for j in range(2*i,n+1,i):
    if x[j] == 1:
      tmp += 1
  if tmp % 2 != a[i-1]:
    x[i] = 1
    m += 1
    ans.append(i)
print(m)
for i in ans:
  print(i,end=" ")

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
x = [0]*(n+1)
m = 0
ans = []
for i in reversed(range(1,n+1)):
  tmp = 0
  for j in range(2*i,n+1,i):
    if x[j] == 1:
      tmp += 1
  if tmp % 2 != a[i-1]:
    x[i] = 1
    m += 1
    ans.append(i)
print(m)
for i in ans:
  print(i,end=" ") 
"""

if all(i == 0 for i in x):
  print(0)
  exit()

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

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

B = [0] * (M + 1)

for i in range(M, 0, -1):
  j = 2
  tmp = 0
  while i * j <= M:
    B[i] += B[i * j]
    j += 1
  B[i] += A[i]
  B[i] %= 2
  
answer = []
for i in range(M + 1):
  if B[i]:
    answer.append(i)

if len(answer):
  print(len(answer))
  print(*answer)
else:
  print(0)

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

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

print(sum(b))
print(' '.join(map(str, ans)))

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

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

print(len(ans))
print(' '.join(list(map(str,ans))))

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

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

print(len(ans))
print(' '.join(list(map(str,ans))))

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

B = [0] * (N + 1)
for i in reversed(range(1, N + 1)):
    ball = 0
    base = i + 1

    for j in range(i, N + 1, i):
        ball += B[j]

    if ball % 2 != A[i]:
        B[i] = 1

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

Solution (Python):
N = int(input())
a = list(map(int, 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 == 0:
    b[i] = a[i]
  else:
    b[i] = 1-a[i]

ans = []
for i in range(N):
  if b[i] == 1:
    ans.append(i+1)
    
print(len(ans))
print(' '.join(map(str, ans)))

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

ans=[0]*(N+1)

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

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

Solution (Python):
N = int(input())
B = [int(i) for i in input().split()]
S = [0]*N
cnt = 0
for i in range(N-1, -1, -1):
  A = S[i::i+1]
  if sum(A)%2 == B[i]:
    continue
  elif sum(A)%2 == 0 and B[i] == 1:
    S[i] += 1
    cnt += 1
  elif sum(A)%2 == 1 and B[i] == 0:
    S[i] += 1
    cnt += 1
print(cnt)
l = []
for i in range(N):
  if S[i] == 1:
    l.append(i+1)
print(" ".join(map(str,l)))

Solution (Python):
N = int(input())
a = list(map(int,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 == 0:
        b[i] = a[i]
    else:
        b[i] = 1-a[i]

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

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

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

for i in reversed(range(1, N+1)):
    total = 0
    for j in range(i+i, N+1, i):
        total ^= b[j]
    b[i] = total ^ a[i]

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

print(ans_n)
print(' '.join(ans_l))

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

for i in reversed(range(1, N+1)):
    total = 0
    for j in range(i+i, N+1, i):
        total ^= b[j]
    b[i] = total ^ a[i]

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

print(ans_n)
print(' '.join(ans_l))

Solution (Python):
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    a=list(map(int,input().split()))
    l=[0]*N
    l2=[]
    ans=0
    for i,x in enumerate(reversed(a)):
        z=N-i
        c=0
        for j in range(2,N//z+1):
            c+=l[z*j-1]
        if c%2!=x:
            l[N-1-i]+=1
            ans+=1
            l2.append(N-i)
    print(ans)
    print(*l2)

if __name__ == '__main__':
    main()

Solution (Python):
from _collections import deque


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
import scipy
from collections import deque


"""
need to consider the case that ticket is not enough to lower everything
"""
N = gi()
A = [0] * (N + 5)
bs = [0] * (N + 5)
for i in range(1, N + 1):
    A[i] = gi()

ans = []
for i in range(N, 0, -1):
    tc = 0
    mul = 1
    while mul * i <= N:
        tc += bs[mul * i]
        mul += 1
    if (tc % 2 != A[i]):
        bs[i] = 1
        ans.append(i)

print(len(ans))
for v in ans:
    print("%d " % (v), end="")

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
BOX = [None for i in range(N)]
ANS_LIST = []
for i in range(N-1,-1,-1):
    loop = N//(i+1)
    cnt = 0
    for j in range(loop):
        if BOX[(i+1)*(j+1)-1]!=None:
            cnt+=BOX[(i+1)*(j+1)-1]
    BOX[i]=(cnt-A[i])%2

for i in range(N):
    if BOX[i]==1:
        ANS_LIST.append(i+1)

print(sum(BOX))
print(*ANS_LIST)

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

i = n // 2
BOXES[i:] = A[i:]

j = i
for _ in range(i):
    k = j - 1
    count = 0
    while True:
        count += BOXES[k]
        k += j
        if k >= n:
            break
    if count % 2 != A[j - 1]:
        BOXES[j - 1] = 1
    j -= 1

m = sum(BOXES)
print(m)
for i in range(n):
    if BOXES[i] == 1:
        b = i + 1
        print(b)

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

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


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

Solution (Python):
N, = map(int, input().split())
As = [0] + list(map(int, input().split()))
Bs = [0] * (N+1)
for i in range(N):
    i = N - i
    tmp = 0
    for j in range(N//i-1):
        tmp += Bs[i * (j+2)]
    tmp %= 2
    if As[i]:
        Bs[i] = 1 - tmp
    else:
        Bs[i] = tmp
print(sum(Bs))
rs = []
for i, v in enumerate(Bs):
    if v:
        rs.append(i)
print(*rs)

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

for i in range(N - 1, -1, -1):
    p = A[i]
    j = i + 1
    while i < N:
        if B[i]:
            p ^= 1
        i += j
    B[j - 1] = p

S = [i + 1 for i, c in enumerate(B) if c]

print(len(S))
print(*S)

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

boxes=[0]*n 
'''
b=[]

i=n 
while i>=1:
	count=a[i-1]
	for j in range(i+1,n+1):
		if j%i==0:
			count+=boxes[j-1]
	boxes[i-1]=count%2
	if boxes[i-1]:
		b.append(i)
	i-=1


print(len(b))
print(*b) 
'''
for i in reversed(range(n)):
	boxes[i]=(a[i]+sum(boxes[i::i+1]))%2

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

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

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

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

ans_count = 0
ans_numbers = []
for i, count in enumerate(box):
    if count == 1:
        ans_count += 1
        ans_numbers.append(i + 1)

print(ans_count)
if ans_count != 0:
    print(*ans_numbers)

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

for i in range(n,0,-1):
    cnt = 0
    x = i
    while x <= n:
        if ball[x-1] == 1:
            cnt += 1
        x += i
    if cnt%2 != a[i-1]:
        ball[i-1] = 1
        ans.append(i)

m = len(ans)
print(m)
for i in range(m):
    if i<m-1: print(ans[i],end=" ")
    else: print(ans[i])

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

for i in range(n,0,-1):
    cnt = 0
    x = i
    while x <= n:
        if ball[x-1] == 1:
            cnt += 1
        x += i
    if cnt%2 != a[i-1]:
        ball[i-1] = 1
        ans.append(i)

m = len(ans)
print(m)
if m != 0:
    for b in ans:
        print(b,end=" ")
    else:
        print("")

Solution (Python):

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

bl = [0]*n
for i in range(n,0,-1):
    if i*2>n:
        if al[i-1]>0:
            bl[i-1] = 1
        continue

    c = 2
    s = 0
    while i*c<=n:
        s += bl[i*c-1]
        c += 1
    if al[i-1]==1:
        bl[i-1] = 1 if s%2==0 else 0
    else:
        bl[i-1] = 0 if s%2==0 else 1

res = []
for i in range(1,n+1):
    if bl[i-1]>0:
        res.append(i)

print(len(res))
if len(res)>0:
    print(*res)

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a = tuple(map(int, input().split()))
    ls = [0] * n
    ans = []

    for i in range(n)[::-1]:
        if (sum(ls[i::i+1]) % 2) != a[i]:
            ls[i] = 1
            ans.append(i+1)
    print(sum(ls))
    if ans:
        print(*ans[::-1])


if __name__ == '__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a = tuple(map(int, input().split()))
    ls = [0] * n
    ans = []

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


if __name__ == '__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a = tuple(map(int, input().split()))
    ls = [0] * n

    for i in range(n-1, -1, -1):
        if (sum(ls[i::i+1]) % 2) != a[i]:
            ls[i] = 1
    sum_ls = sum(ls)
    print(sum_ls)
    if sum_ls:
        print(*[i+1 for i, v in enumerate(ls) if v == 1])

if __name__ == '__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    n_half = n // 2
    a = list(map(int, input().split()))
    ls = [0] * n
    ans = []

    for i in range(n-1, -1, -1):
        ai = a[i]
        if ai > n_half:
            ls[i] = ai
            ans.append(i+1)
        elif (sum(ls[i::i+1]) % 2) != ai:
            ls[i] = 1
            ans.append(i+1)
    print(sum(ls))
    if ans:
        print(*ans[::-1])


if __name__ == '__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    n_half = n // 2
    a = list(map(int, input().split()))
    ls = [0] * n
    ans = []

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


if __name__ == '__main__':
    main()

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

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

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


box=[0]*n


for i in range(n):
  num=n-i

  
  baisu=n//num

  if baisu==1:
    box[num-1]=a[num-1]

  
  temp=0
  for j in range(2,baisu+1):
    temp+=box[num*j-1]
  box[num-1]=abs(temp%2-a[num-1])

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

if sum(ans)!=0:
  print(len(ans))
  print(*ans)
else:
  print("0")

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

    r = []
    for i in reversed(range(N)):
        t = sum(B[i::i + 1]) & 1
        B[i] = abs(A[i] - t)
        if B[i]:
            r.append(i)
    print(len(r))
    if r:
        print(' '.join(str(i + 1) for i in r))

main()

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

    ans = []
    for i in range(N+1):
        if B[i] != 0:
            ans.append(i)

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



if __name__ == "__main__":
    main()

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

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
ans = [0]*N
for i in range(N):
    n = N - i 
    coun = sum(ans[n-1::n])%2
    if A[n-1] != coun:
        ans[n-1] = 1
n = sum(ans)
st = " ".join(["" if n==0 else str(i+1) for i,n in enumerate(ans)])
print(n)
print(st)

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


box=[0]*n


for i in range(n):
  num=n-i

  
  baisu=n//num

  if baisu==1:
    box[num-1]=a[num-1]

  
  temp=0
  for j in range(2,baisu+1):
    temp+=box[num*j-1]
  box[num-1]=abs(temp%2-a[num-1])

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

if sum(ans)!=0:
  print(len(ans))
  print(*ans)
else:
  print("0")

Solution (Python):
def main():

    N = int(input())
    a = {i: inp for i, inp in enumerate(map(int, input().split()), 1)}
        
    b = {i : 0 for i in range(1, N+1)}
    ret = []

    for i in range(N, 0, -1):
        sum_multiple = 0
        cursor = 2
        while i * cursor <= N:
            sum_multiple += b[i * cursor]
            cursor += 1

        if a[i] == 1:
            if sum_multiple % 2 == 0:
                b[i] = 1
                ret.append(i)
        else:
            if sum_multiple % 2:
                b[i] = 1
                ret.append(i)

    M = len(ret)
    print(M)
    if M:
        ret = ' '.join([str(i) for i in ret])
        print(ret)

if __name__=="__main__":
    main()

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

i=n-1
while i>=0:
    if A[i]==1:
        s=i
        break
    i-=1

if i==-1:
    print(0)
elif s==0:
    print(1)
    print(1)
else:
    i=(s+1)//2-1
    while i>=0:
        B=[A[j] for j in range(i,n,i+1)]
        r=sum(B[1:])
        if r%2==0 and A[i]==0:
            A[i]=0
        elif r%2==0 and A[i]==1:
            A[i]=1
        elif r%2==1 and A[i]==0:
            A[i]=1
        else:
            A[i]=0
        i-=1
    C=[m for m,k in enumerate(A,1) if k!=0]
    print(len(C))
    print(*C)

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

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

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

Solution (Python):

import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int,input().split()))
ret = [0 for _ in range(n+1)]

for i,a_i in enumerate(a[-1::-1]):
    cur_ret_sum = sum(ret[n-i::n-i])%2
    if a_i!=cur_ret_sum:
        ret[n-i]=1
m = sum(ret[1::])
print(m)
if m > 0:
    print(" ".join([str(i) for i,v in enumerate(ret) if v==1]))

Solution (Python):
N = int(input())
Data = list(map(int,input().split()))
Ans  = [0]*N
Ans2 = [0]*N

for n in range(N,0,-1):
    Ans[n-1] = Data[n-1]
    k = 2
    while k*n <= N:
        Ans[n-1] -= Ans[k*n-1]
        if Ans[n-1] < 0:
            Ans[n-1] = 1
        k+=1

cnt = 0
for i in range(N):
    if Ans[i] == 1:
        Ans2[cnt] = i+1 
        cnt += 1

print(cnt)
if cnt > 0:
    for i in range(cnt):
        print( Ans2[i], end = ' ')
    print()

Solution (Python):
def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    l = [0] * N
    for i in range(N, 0, -1):
        t = 0
        for j in range(i, N+1, i):
            t += l[j-1]
        l[i-1] = abs(A[i-1] - (t % 2))
    print(sum(l))
    l2 = [i + 1 for i, j in enumerate(l) if j == 1]
    print(' '.join([str(i) for i in l2]))
main()

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

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

ans = []

for i in range(N-1, -1, -1):
  A[i] = sum(A[i::i+1]) & 1

ans = [i + 1 for i in range(N) if A[i]]

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

Solution (Python):
def calculate(arr):
    N = len(arr)
    index = N - 1

    result = [0]*N
    result2 = []

    while index >= 0:

        if N // (index+1) > 1:
            v1 = calculate2(N // (index+1),index,result)

            if arr[index] % 2 == 0:
                if v1 % 2 == 0:
                    pass
                else:
                    result[index] = 1
                    result2.append(index + 1)
            else:
                if v1 % 2 == 0:
                    result[index] = 1
                    result2.append(index + 1)
                else:
                    pass

        else:
            if arr[index] == 0:
                result[index] = 0
            else:
                result[index] = 1
                result2.append(index + 1)

        index = index - 1

    return result,result2


def calculate2(len, base, arr):
    result = 0
    for i in range(2, len+1):
        result += arr[(base + 1) * i - 1]
    return result


N = int(input())
S = input().split(" ")
arr = [int(s) for s in S]

result, result2 = calculate(arr)

print(sum(result))
if len(result2) > 0:
    print(" ".join([str(s) for s in result2]))

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
ans = [0]*n
an=[]
for i in range(n-1,-1,-1):
	now = i
	cnt=0
	while(now<n):
		cnt+=ans[now]
		now+=i+1
	ans[i] = a[i]^(cnt%2)
	if ans[i]:
		an.append(i+1)
an.reverse()
print(sum(ans))
print(" ".join([str(x)for x in an]))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
B = [False] * N
for i in range(N, 0, -1):
    B[i-1] = (A[i-1] + sum(B[j-1] for j in range(i * 2, N+1, i))) & 1
C = [i for i, a in enumerate(B, 1) if a]
print(len(C))
print(*C)

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

for i in reversed(range(1, n + 1)):
    k = i
    cnt = 0
    while k <= n:
        cnt += b[k]
        k += i

    if cnt % 2 != a[i]:
        b[i] = 1

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

Solution (Python):
import sys

import numpy as np

readline = sys.stdin.buffer.readline


def main():
    N = int(readline())
    A = [0] + list(map(int, readline().split()))
    A = np.array(A)
    C = np.zeros(N + 1, dtype=np.int32)

    if A[-1] == 1:
        C[-1] == 1

    for j in range(N, 0, -1):
        cnt = np.count_nonzero(C[j::j])
        C[j] = (cnt % 2) ^ A[j]

    ans = np.sum(C)
    print(ans)
    if ans != 0:
        B = np.arange(N + 1)
        li = B[C == 1]
        print(*li, sep='\n')


main()