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









INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    n=INT()
    A=LIST()
    flg=True
    la=len(A)
    bool=[False]*(n+1)
    B=[]
    for i in range(la-1,-1,-1):
        a=A[i]
        s=i+1
        temp=0
        for j in range(n//s+1):
            if j==0:
                continue
            if bool[j*s]:
                temp+=1
        
        if temp%2!=a:
            B.append(s)
            bool[s]=True
    
    B=sorted(B)
    print(len(B))
    if len(B)!=0:
        print(*B)

            

if __name__=='__main__':
    do()

Solution (Python):
import sys


def IN_I(): return int(sys.stdin.readline().rstrip())
def IN_LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def IN_S(): return sys.stdin.readline().rstrip()
def IN_LS(): return list(sys.stdin.readline().rstrip().split())


N = IN_I()
a = [0] + IN_LI()
b = [0] * (N + 1)
ans = []

for i in range(N, 0, -1):
    tmp = 0
    for j in range(2 * i, N + 1, i):
        tmp += b[j]
    if tmp % 2 != a[i]:
        b[i] = 1
        ans.append(i)
if len(ans) == 0:
    print(0)
else:
    print(len(ans))
    print(' '.join(map(str, ans)))

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

for i in reversed(range(1, N + 1)):
    p = (N // i) * i
    s = 0
    while res[p - 1] != -1:
        s += res[p - 1]
        s %= 2
        p -= i
    res[p - 1] = (A[p - 1] - s) % 2

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

Solution (Python):

import sys
input = lambda: sys.stdin.readline().strip()
n = int(input())
a = [0, *(int(x) for x in input().split())]
divisors = [[] for i in range(n + 1)]
for i in range(1, n + 1):
    for j in range(i, n + 1, i):
        divisors[j].append(i)
ans = []
for i in reversed(range(1, n + 1)):
    if a[i]:
        for j in divisors[i]:
            a[j] ^= 1
        ans.append(i)
print(len(ans))
print(*ans)

Solution (Python):
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    
    n = I()
    a = [0] + LI()
    ans = [0 for _ in range(n+1)]

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

    print(len(ans_lst))
    print(*ans_lst)

    
main()

Solution (Python):
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    
    n = I()
    a = [0] + LI()
    ans = [0 for _ in range(n+1)]

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

    print(len(ans_lst))
    print(*ans_lst)

    
main()

Solution (Python):
N = int(input())
a = list(map(int,input().split()))
b = [0] * N
ans = 0 
from collections import deque        
ansL = deque()
for i in range(N):
    m = N - i 
    count = 0
    for k in range(1,N//m+1):
        count += b[m*k-1]
    if count % 2 != a[m-1]:
        b[m-1] = 1
        ans += 1
        ansL.appendleft(m)    
print(ans)
print(*ansL)

Solution (Python):
def divisors(n):
   d=[]
   for i in range(1,int(n**0.5)+1):
       if n%i==0:
           d.append(i)
           if i!=n//i:
               d.append(n//i)
   d.sort()
   return d
n=int(input())
table=[0]*(n+1)
ball=[]
a=list(map(int,input().split()))[::-1]
for i in range(n):
    if table[n-i]!=a[i]:
        ball.append(n-i)
        for j in divisors(n-i):
            table[j]=1-table[j]
print(len(ball))
if len(ball)!=0:
    print(*ball)

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

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


ans = []
for i, j in enumerate(b):
    if(j == 1):
        ans.append(i)
print(len(ans))
if(len(ans)):
    print(*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)):
    ans=0
    for j in range(i,n+1,i):
        ans+=b[j]
    if ans%2==a[i]:
        b[i]=0
    else:
        b[i]=1
c_=[]
for c,d in enumerate(b):
    if d==1:
        c_.append(str(c))
print(len(c_))
print(' '.join(c_))

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

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]:
    b[i]+=1
    ans.append(i+1)
        
print(sum(b))
print(*sorted(ans))

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

m=0
ans=[]
c=[0]*(n+1)
for i in reversed(range(1,n+1)):
  if a[i]%2!=c[i]%2:
    m+=1
    ans.append(i)
    j=1
    r=set()
    while j*j<=i:
      if i%j==0:
        r.add(j)
        r.add(i//j)
      j+=1
    for j in r:
      c[j]+=1
      c[j]%=2
        
print(m)
print(*sorted(ans))

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






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

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

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

def fast_factorization_init(N):
    res=list(range(N))
    for i in range(2,N):
        if i*i>N:
            break
        for j in range(i*i,N,i):
            if res[j]==j:
                res[j]=i
        if res[i]<i:
            continue
    return res            
    
min_factors=fast_factorization_init(2*10**5+10)
def fast_factorization(n):
    res=[]
    while n>1:
        res.append(min_factors[n])
        n//=min_factors[n]
    return res

def factors(n):
    res=[1]
    for i,j in Counter(fast_factorization(n)).items():
        res+=[r*i**(b+1) for r in res for b in range(j)]
    return res

res=[0]*(N+1)
num=0
for n in reversed(range(N)):
    res[n+1]=A[n+1]
    if A[n+1]:
        num+=1
        for m in factors(n+1):
            A[m]=(A[m]+1)%2
print(num)
print(*[i+1 for i in range(N) if res[i+1]>0],sep='\n')

Solution (Python):

url = "https://atcoder.jp//contests/abc134/tasks/abc134_d"

def main():
    n = int(input())
    a = [0]
    a.extend(list(map(int, input().split())))
    balls = [0]*(n+1)
    b = {}
    for i in range(n, 0, -1):
        ball = 0
        for j in range(i, n+1, i):
            ball += balls[j]
        if ball % 2 != a[i]:
            b[i] = 1
            balls[i] = 1
    if len(b) == 0:
        print(0)
        exit()
    else:
        print(len(b))
    ks = sorted(b.items(), key=lambda x:x[0])
    for k in ks:
        print(k[0], end=" ")


if __name__ == '__main__':
    main()

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

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

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

for i, a in list(enumerate(A))[::-1]:
    i += 1
    d = sum(B[i - 1::i])
    if a != (d % 2):
        B[i - 1] = 1
print(sum(B))
for i, b in enumerate(B):
    if b != 0:
        print(i+1)

Solution (Python):
import sys









MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

def Main():
    n = read_int()
    a = read_int_list()
    b = [0] * n
    ans = []
    for i in range(n - 1, -1, -1):
        if sum(b[i::i + 1]) % 2 != a[i]:
            b[i] = 1
            ans.append(i + 1)
    print(len(ans))
    if len(ans): print(*ans)    
    
if __name__ == '__main__':
    Main()

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

    divisors.sort()
    return divisors


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

cnt=[0]*n
lst=[]

for i in range(n,0,-1):
    if cnt[i-1]%2==a[i-1]:
        continue
    
    else:
        lst.append(str(i))
        xxx=make_divisors(i)

        for j in xxx:
            cnt[j-1]+=1


print(len(lst))

if len(lst)>0:
    print(' '.join(lst))

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

ans = [0 for i in range(N)]
for i in range(N-1,-1,-1):
    val = i+1
    if val*2>N:
        if A[i]==0:
            ans[i] = 0
        else:
            ans[i] = 1
    else:
        tmp = 0
        res = val
        while(1):
            if val>N:
                break
            tmp += ans[val-1]
            val += res

        if A[i]==0:
            if tmp%2==0:
                ans[i]=0
            else:
                ans[i]=1
        else:
            if tmp%2==0:
                ans[i]=1
            else:
                ans[i]=0

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

print(cnt)
print(*b)

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

Solution (Python):









N = int(input())



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





































A.insert(0, 0)
B = [0] * (N + 1)

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


print(sum(B))
for i, b in enumerate(B):
    if b == 1:
        print(i)

Solution (Python):
import sys


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    ans = [0] * n
    for i in range(n, 0, -1):
        s = 0
        for j in range(i, n + 1, i):
            s += ans[j - 1]
        if s % 2 == a[i - 1]:
            ans[i - 1] = 0
        else:
            ans[i - 1] = 1
    m = sum(ans)
    print(m)
    for i in range(1, n + 1):
        if ans[i - 1]:
            print(i)


if __name__ == "__main__":
    main()

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

for i in range(N, 0, -1):
	tmpBalls = 0
	x = 1
	while i * x <= N:
		tmpBalls += balls[i*x]
		x += 1
	
	if A[i] == 1 and tmpBalls % 2 == 1:
		pass
		
	elif A[i] == 1 and tmpBalls % 2 == 0:
		balls[i] += 1
	
	elif A[i] == 0 and tmpBalls % 2 == 1:
		balls[i] += 1
	
	elif A[i] == 0 and tmpBalls % 2 == 0:
		pass
		

isOkay = True
for i in range(1, N+1):
	if balls[i] > 1:
		print(-1)
		exit()
	
print(balls.count(1))	
for i in range(1, N+1):
	if balls[i]:
		print(i)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
b = [0] * n
ans = 0
for i in range(n)[::-1]:
    t = 0
    j = (i+1)*2
    while j <= n:
        t += b[j-1]
        j += (i+1)
    if a[i] == 0:
        if t % 2 == 0:
            b[i] = 0
        else:
            b[i] = 1
            ans += 1
    else:
        if t % 2 == 0:
            b[i] = 1
            ans += 1
        else:
            b[i] = 0
print(ans)
l = []
for i in range(n):
    if b[i] == 1:
        l.append(str(i+1))
print(' '.join(l))

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
ans=[0]*N
for i in range(N):
  n=N-i
  add=A[n-1]
  n_tmp=n
  while True:
    n_tmp+=n
    if n_tmp>N:break
    if ans[n_tmp-1]:
      add=0 if add else 1
  if add:
    ans[n-1]=1
print(ans.count(1))
ans2=[]
for i,v in enumerate(ans):
  if v:
    ans2.append(i+1)
print(*ans2)

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

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

print(B.count(1))
for n in range(N+1):
  if B[n]:
    print(n,end=" ")

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

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

for i in range(N - 1, -1, -1):
    tmp_sum = 0
    for j in range((i + 1) * 2 - 1, N, i + 1):
        tmp_sum += B[j]
        tmp_sum %= 2
    B[i] = tmp_sum ^ A[i]

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

Solution (Python):
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C



N,A=ilint()
a=[0]+A[:]
x=[0]*(N+1)
ans=[]
for k in range(N,0,-1):
    tmp=0
    l=2*k
    while l<=N:
        tmp+=x[l]
        l+=k
    if tmp%2!=a[k]:
        x[k]=1
        ans.append(k)
print(len(ans))
if len(ans)>0:
    lprint(ans,' ')

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

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

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

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

b = [0] * n
c = []
for i in range(n-1, -1, -1):
    v = i + 1
    s = 0
    for j in range(1, 10**6):
        if v*j > n:
            break    
        s += b[v*j-1]
    if s % 2 != a[i]:
        b[i] = 1
        c.append(v)
print(len(c))
for i in reversed(c):
    print(i)

Solution (Python):
from collections import deque
N=int(input())
A=list(map(int,input().split()))
reverse_A=list(reversed(A))
numbers=[]
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
boxes=[0 for _ in range(N)]
for n in range(N):
    yakusuu=make_divisors(n+1)
    numbers+=[yakusuu]
reverse_numbers=list(reversed(numbers))
answers=[0 for _ in range(N)]
balls=[0 for _ in range(N)]
for n in range(N-1):
    number=reverse_numbers[n]
    if balls[n]%2==0 and reverse_A[n]==1:
        answers[n]+=1
        for num in number:
            balls[-num]+=1
    elif balls[n]%2==1 and reverse_A[n]==0:
        answers[n] += 1
        for num in number:
            balls[-num] += 1
if sum(answers)%2==0 and reverse_A[-1]==1:
    answers[-1]+=1
elif sum(answers)%2==1 and reverse_A[-1]==0:
    answers[-1]+=1
print(sum(answers))
reverse_answers = list(reversed(answers))
kotae = []
for n in range(N):
    if reverse_answers[n] != 0:
        kotae.append(n + 1)
print(*kotae)

Solution (Python):
import math

def main():
	N = int(input())
	A = [int(a) for a in input().split(" ")]
	B = [0] * N
	if N == 1:
		if A[0] == 1:
			print(1)
			print(1)
		else:
			print(0)
		return 0
	for i in range(1, N):
		for j in range(math.ceil(N / (i + 1)), math.floor(N / i) + 1):
			ball = 0
			for k in range(2 * j, N + 1, j):
				ball += B[k - 1]
			B[j - 1] = (ball % 2 + A[j - 1]) % 2
	ans = [str(x + 1) for x, v in enumerate(B) if v == 1]
	print(len(ans))
	if len(ans) > 0:
		print(" ".join(ans))

main()

Solution (Python):

import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil, atan, pi
def input(): return sys.stdin.readline()[:-1] 


import string

from bisect import bisect_left, bisect_right
from functools import lru_cache
MOD = int(1e9)+7
INF = float('inf')


def solve():
    n = int(input())
    a = [int(x) for x in input().split()]
    xd = [0] * n
    ans = []
    for i in range(n-1,-1,-1):
        cnt = 0
        for j in range(i, n, i + 1):
            cnt += xd[j]
        cnt %= 2
        if cnt != a[i]:
            ans.append(i + 1)
            xd[i] = 1
    ans.reverse()
    print(len(ans))
    if ans:
        print(*ans)
        

    
t = 1

for case in range(1,t+1):
    ans = solve()


"""


"""

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

b = [0] * (N + 1)

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

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

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

input_num = [0 for _ in range(n)]

for i in range(n-1, -1, -1):
    tmp = 0
    j = i+i+1
    while j < n:
        tmp += input_num[j]
        j += i+1

    if tmp % 2 != a[i]:
        input_num[i] = 1

print(sum((input_num)))
for i, j in enumerate(input_num):
    if j:
        print(i+1, end=' ')

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

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

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
d=[0 for i in range(n+1)]
ans=[0 for i in range(n+1)]
for i in range(n,0,-1):
  c=0
  for j in range(i*2,n+1,i):
    c+=ans[j]
  if (c%2)^a[i-1]:
    ans[i]=1

r=""
c=0
for i in range(1,n+1):
  if ans[i]:
    c+=1
    r+=str(i)+" "
print(c)
print(r[:-1])

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

for i in range(N,0,-1):
    res = 0
    for j in range(1,N+1):
        if i*j>N:
            break
        else:
            res += ans[i*j]
      
    if res%2 != a[i-1]:
        ans[i] += 1
        
print(sum(ans))
A = []
for i,v in enumerate(ans):
    if v>0:
        A.append(i)
        
        
print(*A)

Solution (Python):
n = int(input())
A = [0] + list(map(int,input().split()))
B = [0]*(n+1)
m = 0
for i in range(n,0,-1):
    cnt = 0
    for j in range(i,n+1,i):
        cnt += B[j]
    if cnt%2==A[i]:
        continue
    else:
        B[i] =1
        m += 1
print(m)
for i in range(len(B)):
    if B[i]==1:
        print(i)

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

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

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

hako = [0]*n

for i in range(n,0,-1):
    tmp = i
    su = 0
    while tmp<=n:
        su += hako[tmp-1]
        tmp += i
    if su % 2 == a[i-1]:
        continue
    else:
        hako[i-1] = 1

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

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

ans = [False] * n

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

for i in range(n//2-1, -1, -1):
    mod = False
    for j in range(i, n, i+1):
        if ans[j] == 1:
            mod = not mod

    mod = 1 if mod else 0

    ans[i] = True if mod != a[i] else False

cnt = 0
ind = []
for i in range(n):
    if ans[i] == True:
        cnt += 1
        ind.append(i+1)

print(cnt)
if cnt > 0:
    print(" ".join(map(str, ind)))

Solution (Python):
N = int(input())
Alist = list(map(int,input().split()))
Answer = [0]*(N+1)
M = 0
for i in range(1,len(Alist)+1):
    A = Alist[-i]
    n = (N+1)-i
    if sum(Answer[n::n])%2 != A:
        Answer[-i] = 1
        M += 1
print(M)
Ans = []
for k in range(len(Answer)):
    if Answer[k] == 1:
        Ans.append(k)
print(*Ans[0:],end="\t")

Solution (Python):
import sys
import numpy as np
input = sys.stdin.buffer.readline
N = int(input())
A = np.array(list(map(int, input().split())))

B = np.array([0] * N)
for i in range(len(A), 0, -1):
    v = B[2 * i - 1::i].sum() % 2
    if A[i - 1] != v:
        B[i - 1] = 1


M = B.sum()
print(M)
idx = np.where(B == 1)[0] + 1
print(*idx, sep=' ')

Solution (Python):





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

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

ans_num = 0
ans_list = ""
for i in range(N):
    tmp = N - i
    s = 0
    for j in range(tmp, N+1, tmp):
        s += ans[j-1]

    if s % 2 != A[tmp - 1]:
        ans[tmp - 1] = 1
        ans_num += 1
        ans_list += str(tmp)
        ans_list += " "


print(ans_num)
print(ans_list[:-1])

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

    ans = set()
    
    for i in range(n, 0, -1):
        now = 0
        for j in range(2*i, n+1, i):
            if j in ans:
                now += 1
        if now % 2 != a[i-1]:
            ans.add(i)
    
    return ans

if __name__ == '__main__':
    x = solve()
    print(len(x))
    print(*x, sep=' ')

Solution (Python):
def resolve():
    '''
    code here
    '''
    N = int(input())
    As = [int(item) for item in input().split()]

    box = set()

    for i in range(N):
        num = N -i
        sum_num  = 0
        for j in range(1, N//num +1):
            if j*num in box:
                sum_num += 1

        if As[num-1] != sum_num % 2:
            box.add(num)

    print(len(box))

    for item in box:
        print(item)

if __name__ == "__main__":
    resolve()

Solution (Python):
n = int(input())
lis =[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 != lis[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()))
box = set([])
for i in range(n,0,-1):
  cnt = 0
  for j in range(1,n//i+1):
    if i*j in box:
      cnt += 1
  if cnt%2 != a[i-1]:
    box.add(i)
print(len(box))
print(*box)

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

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

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

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

ans=[0 for _ in range(n+1)]
t=[]
S=0

for i in range(n):
  b=n-i
  c=(n-i)*2
  ch=0
  while c<=n:
    ch+=ans[c]
    c+=b
    
  if ch%2==0:
    if a[b-1]==1:
      ans[b]+=1
      S+=1
      t.append(str(b))
  else:
    if a[b-1]==0:
      ans[b]+=1
      S+=1
      t.append(str(b))
      

print(S)
if S>0:
  
  print(' '.join(t))

Solution (Python):
n = int(input())
alst = list(map(int, input().split()))
divisor_lst = [[0] for _ in range(n)]
ans = []
for i in range(2, n + 1):
    for k in range(i * 2, n + 1, i):
        divisor_lst[k - 1].append(i - 1)
for i in range(n - 1, -1, -1):
    if alst[i] == 1:
        for j in divisor_lst[i]:
            alst[j] += 1
            alst[j] %= 2
        ans.append(i + 1)
print(len(ans))
print(*ans)

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

for i in range(N,0,-1):
  if sum(res[j] for j in range(i,N+1,i)) % 2 != A[i]:
    res[i] = 1
    M += 1
    
print(M)
print(*[k for k, r in enumerate(res) if r])

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

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

print(len(ans))
for i in ans:
    print(i)

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

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

print(l.count(1))

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

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    a=LI()
    b=[0]*N
    
    
    for i in range(N-1,-1,-1):
        temp=0
        for j in range(i+1,N+1,i+1):
            jj=j-1
            if b[jj]:
                temp+=1
        temp=temp%2
        if temp!=a[i]:
            b[i]=1
            
    M=sum(b)
    ans=[]
    for i in range(N):
        if b[i]:
            ans.append(i+1)
            
    print(M)
    print(' '.join(map(str, ans)))
        

main()

Solution (Python):
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy


import heapq
sys.setrecursionlimit(10**6)

INF = 10**18
import bisect
import statistics
mod = 10**9+7


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

b = [0 for i in range(N+1)]
c = []
for i in range(N,0,-1):
    ii = 2*i
    s = 0
    while ii <= N:
        s += b[ii]
        ii += i
    s = s % 2
    if s == a[i]:
        b[i] = 0
    else:
        b[i] = 1
        c.append(i)

print(len(c))
if len(c) > 0:
    c = map(str, c)
    print(" ".join(c))