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

Solution (Python):
def main():

    """ convenient functions
    
    
    
    
    
    """

    """convenient decorator
    
    
        
        
        
        
        
        
        
        
        
        
    """
    
    
    import sys
    sys.setrecursionlimit(10**7)
    from itertools import accumulate, combinations, permutations, product 
    
    from math import factorial, ceil, floor, sqrt
    def factorize(n):
        """return the factors of the Arg and count of each factor
        
        Args:
            n (long): number to be resolved into factors
        
        Returns:
            list of tuples: factorize(220) returns [(2, 2), (5, 1), (11, 1)]
        """
        fct = []  
        b, e = 2, 0  
        while b * b <= n:
            while n % b == 0:
                n = n // b
                e = e + 1
            if e > 0:
                fct.append((b, e))
            b, e = b + 1, 0
        if n > 1:
            fct.append((n, 1))
        return fct
    def combinations_count(n, r):
        """Return the number of selecting r pieces of items from n kinds of items.
        
        Args:
            n (long): number
            r (long): number
        
        Raises:
            Exception: not defined when n or r is negative
        
        Returns:
            long: number
        """
        
        if n < 0 or r < 0:
            raise Exception('combinations_count(n, r) not defined when n or r is negative')
        if n - r < r: r = n - r
        if r < 0: return 0
        if r == 0: return 1
        if r == 1: return n
        numerator = [n - r + k + 1 for k in range(r)]
        denominator = [k + 1 for k in range(r)]
        for p in range(2,r+1):
            pivot = denominator[p - 1]
            if pivot > 1:
                offset = (n - r) % p
                for k in range(p-1,r,p):
                    numerator[k - offset] /= pivot
                    denominator[k] /= pivot
        result = 1
        for k in range(r):
            if numerator[k] > 1:
                result *= int(numerator[k])
        return result
    def combinations_with_replacement_count(n, r):
        """Return the number of selecting r pieces of items from n kinds of items allowing individual elements to be repeated more than once.
        
        Args:
            n (long): number
            r (long): number
        
        Raises:
            Exception: not defined when n or r is negative
        
        Returns:
            long: number
        """
        if n < 0 or r < 0:
            raise Exception('combinations_with_replacement_count(n, r) not defined when n or r is negative')
        elif n == 0:
            return 1
        else:
            return combinations_count(n + r - 1, r)
    from bisect import bisect_left, bisect_right
    from collections import deque, Counter, defaultdict 
    from heapq import heapify, heappop, heappush, heappushpop, heapreplace,nlargest,nsmallest 
    from copy import deepcopy, copy 
    import operator
    from operator import itemgetter
    
    
    from functools import reduce, lru_cache
    def chmin(x, y):
        """change minimum
        if x > y, x = y and return (x, True).
        convenient when solving problems of dp[i]
        
        Args:
            x (long): current minimum value
            y (long): potential minimum value
        
        Returns:
            (x, bool): (x, True) when updated, else (x, False)
        """
        if x > y:
            x = y
            return (x, True)
        else:
            return (x, False)
    def chmax(x, y):
        """change maximum
        if x < y, x = y and return (x, True).
        convenient when solving problems of dp[i]
        
        Args:
            x (long): current maximum value
            y (long): potential maximum value
        
        Returns:
            (x, bool): (x, True) when updated, else (x, False)
        """
        if x < y:
            x = y
            return (x, True)
        else:
            return (x, False)

    from fractions import gcd 
    def gcds(numbers):
        return reduce(gcd, numbers)
    def lcm(x, y):
        return (x * y) // gcd(x, y)
    def lcms(numbers):
        return reduce(lcm, numbers, 1)

    
    
    INF = 10 ** 18
    MOD = 10 ** 9 + 7
    modpow = lambda a, n, p = MOD: pow(a, n, p) 
    def modinv(a, p = MOD):
        
        
        return modpow(a, p-2, p)
    def modinv_list(n, p = MOD):
        if n <= 1:
            return [0,1][:n+1]
        else:
            inv_t = [0,1]
            for i in range(2, n+1):
                inv_t += [inv_t[p % i] * (p - int(p / i)) % p]
            return inv_t
    def modfactorial_list(n, p = MOD):
        if n == 0:
            return [1]
        else:
            l = [0] * (n+1)
            tmp = 1
            for i in range(1, n+1):
                tmp = tmp * i % p
                l[i] = tmp
            return l
    def modcomb(n, k, fac_list = [], p = MOD):
        
        
        from math import factorial
        if n < 0 or k < 0 or n < k: return 0
        if n == 0 or k == 0: return 1
        if len(fac_list) <= n:
            a = factorial(n) % p
            b = factorial(k) % p
            c = factorial(n-k) % p
        else:
            a = fac_list[n]
            b = fac_list[k]
            c = fac_list[n-k]
        return (a * modpow(b, p-2, p) * modpow(c, p-2, p)) % p
    def modadd(a, b, p = MOD):
        return (a + b) % MOD
    def modsub(a, b, p = MOD):
        return (a - b) % p
    def modmul(a, b, p = MOD):
        return ((a % p) * (b % p)) % p
    def moddiv(a, b, p = MOD):
        return modmul(a, modpow(b, p-2, p))

    """ initialize variables and set inputs
    
        
        
    
        
        
        
        
        
    
        
        
        
        
    
        
        
    """

    
    r = lambda: sys.stdin.readline().strip()
    r_int = lambda: int(r())
    R = lambda: list(map(int, r().split()))
    Rmap = lambda: map(int, r().split())
    Rfloat = lambda: list(map(float, r().split()))
    Rtuple = lambda: tuple(map(int, r().split()))

    """ how to treat input
    
    
    
    
    
    
    
    """

    if __name__ != '__main__':
        
        sys.stdin = open('sample.txt')

    
    

    N = int(r())
    A = R()
    B = [0] * N
    for i in range(N-1, -1, -1):
        j = i + 1
        B[i] = (sum(B[i::j])%2 + A[i]) % 2
    print(sum(B))
    if sum(B) != 0:
        C = []
        for i, b in enumerate(B):
            if b == 1:
                C.append(i+1)
        print(*C)
    
    
    

    """memo: how to use defaultdict of list
    
    Dic = defaultdict(list)
    
    Dic[x].append(y)
    
    for k, v in Dic.items():
    """

if __name__ == '__main__':
    main()

Solution (Python):
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

N = _I()
A = LI()

'''
全箱にボールを入れてしまうと、2**N時間かかってしまうので無理
後ろから見たほうが絶対良い
最後の箱には、1であればボールが入るし、、0であればいれない
その次に、その数の約数を大きい方から確認していく
例えば、800が最後だとするとその次は400になる

'''


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

ans = [None for _ in range(N)]
divisor_data = [None for _ in range(N)]
for n in reversed(range(0, N)):
    
    if divisor_data[n] == None:
        
        
        if A[n] == 0:
            
            ans[n] = 0
        else:
            
            ans[n] = 1
            divisors = sorted(make_divisors(n+1))
            
            for d in divisors[:-1]:
                if divisor_data[d-1] == None:
                    divisor_data[d-1] = 1
                else:
                    divisor_data[d-1] ^= 1
    else:
        
        
        if divisor_data[n] == A[n]:
            
            ans[n] = 0
        else:
            
            ans[n] = 1
            divisors = sorted(make_divisors(n+1))
            
            for d in divisors[:-1]:
                if divisor_data[d-1] == None:
                    divisor_data[d-1] = 1
                else:
                    divisor_data[d-1] ^= 1
    



if all(a == 0 for a in ans):
    print(0)
else:
    print(ans.count(1))
    for aidx, a in enumerate(ans):
        if a == 1:
            print(aidx+1, end=' ')

Solution (Python):
import sys
N = int(input())
a = [int(x) for x in input().split()]
b = []
for i in reversed(range(int(N/2))):
    b = i
    stack = 0
    while b < N:
        stack += a[b]
        stack %= 2
        b += i+1
    a[i] = stack
c = sum(a)
if c == 0:
    print(c)
    sys.exit()
print(c)
for j in range(N):
    if a[j] == 1:
        print(j+1, end=" ")
print()

Solution (Python):
import sys
 
def main():
    input = sys.stdin.readline
    N = int(input())
    A = [0] + list(map(int, input().split()))
 
    M = 0
    ans = []
    B = [0] * (N+1)
    for i in range(N, 0, -1):
        cnt = 0
        for j in range(2*i, N+1, i):
            cnt += B[j]
 
        if A[i] != cnt % 2:
            B[i] += 1
            M += 1
            ans.append(i)
 
    if M == 0:
        print(0)
    else:
        ans = ans[::-1]
        print(M)
        print(' '.join(map(str, ans)))
 
 
if __name__ == '__main__':
    main()

Solution (Python):
import sys
sys.setrecursionlimit(10**6)

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

B = [-1]*N
for j in range(N//2 + 1,N+1):
    B[j-1] = A[j-1]

def rec(i):
    if B[i-1] != -1:
        return B[i-1]
    res = A[i-1]
    for j in range(2*i,N+1,i):
        res -= rec(j)
        res %= 2
    B[i-1] = res
    return res

rec(1)
b = [i for i in range(1,N+1) if B[i-1] == 1]
M = len(b)

print(M)
if b != []:
    print(*b)

Solution (Python):

N = int(input())
a = [int(i) for i in input().split()]
b = [0 for i in range(N)]

a = [0] + a
b = [0] + b

m = N // 2

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

if len(ans) == 0:
    print(0)
else:
    print(len(ans))
    for i in range(len(ans)):
        if i == 0:
            print(ans[i], end="")
        else:
            print(" ", end="")
            print(ans[i], end="")

Solution (Python):
n = int(input())
a = [int(a) for a in input().split()]
flag = [0] * (n + 1)
ret = []
for i in range(n, 0, -1):
    if flag[i] ^ a[i - 1] == 1:
        ret.append(i)
        j = 1
        while j * j <= i:
            if i % j == 0:
                flag[j] ^= 1
                if j * j != i:
                    flag[i // j] ^= 1
            j += 1
print(len(ret))
if len(ret) > 0:
    print(" ".join(map(str, ret)))

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 = i * 2
  s = 0
  while (j <= N):
    s += B[j]
    j += i
  B[i] = (s + A[i]) % 2
print(sum(B))
if sum(B) > 0:
  ans = ''
  for i in range(1, N + 1):
    if B[i] == 1:
      ans += str(i) + ' '
  print(ans.strip())

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

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

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


balls = [0]*N
for i in range(N-1, -1, -1):
    
    ball_sum = 0
    box_i = i + 1
    while box_i <= N:
        
        ball_sum += balls[box_i - 1]
        box_i += i +1 
        
    
    rest = ball_sum % 2
    
    if checks[i] == 0:
        
        if rest == 1:
            balls[i] = 1
    
    if checks[i] == 1:
        
        if rest == 0:
            balls[i] = 1

print(sum(balls))
print(" ".join([str(i + 1) for i in range(0, N) if balls[i] == 1]))

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

ans = a[:]

for i in reversed(range(n)):
    ans[i] = sum(ans[i :: i + 1]) % 2

print(sum(ans))
print(*[i + 1 for i in range(n) if ans[i]])

Solution (Python):
import sys
p = [[int(t) for t in r.split()] for r in sys.stdin.read().split('\n') if r != '']
N = p[0][0]
a = p[1]
b = [0]*N
c = 0
for i in range(N, 0, -1):
    f = a[i-1] ^ (sum(b[i-1:N:i]) % 2)
    b[i-1] = f
    c += f
print(c)
print(' '.join([str(i + 1) for i, n in enumerate(b) if n]))

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

def find_baisu(a, N):
    j = 2
    ret = []
    while(a*j <= N):
        ret.append(a*j)
        j += 1
    return ret
    
for i in range(N):
    num = N-i
    baisu = find_baisu(num, N)
    baisu_box_sum = 0
    for j in range(len(baisu)):
        baisu_box_sum += box[baisu[j]]
    if(baisu_box_sum % 2 == a[num]):
        box[num] = 0
    else:
        box[num] = 1

M = 0
ans = ''
for i in range(N+1):
    if(box[i] == 1):
        M += 1
        ans += str(i) + ' '

print(M)
print(ans)

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

hako = [0]*(N+1)

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


print(hako.count(1))
s = ""
for i, x in enumerate(hako):
    if x == 1:
        s += str(i) + " "

print(s)

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, d=DVSR): return pow(x, d - 2, d)
def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N=II()
INL=LI()
RES=[0]*(N+1)
cnt = 0
for i in range(N, 0, -1):
    pt = 2*i
    sm = 0
    while pt <= N:
        sm += RES[pt]
        pt += i
    if (not sm & 1 and INL[i-1]) or (sm & 1 and not INL[i-1]):
        cnt += 1
        RES[i] = 1

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
a = LIST()

ball = [0] * (N+1)

for i in range(len(a), 0, -1):
	if i > N // 2:
		ball[i] = a[i-1]
	else:
		tmp = a[i-1]
		for x in range(i, N+1, i):
			
			if x == i:
				continue
			tmp = tmp ^ ball[x]
			
		ball[i] = tmp
		
		

print(sum(ball))
for i, j in enumerate(ball):
	if j == 1:
		print(i, end=" ")
print()

Solution (Python):

"""
Created on Sat Jul 20 20:53:47 2019

@author: ctiuser
"""


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

counta = 0
Ans = [0 for i in range(N)]
ans = []
for i in range(N,0,-1):
    tmp = N // i
    res = A[i-1]
    for j in range(tmp):
        res ^= Ans[(j+1)*i-1]
    if res == 1:
        Ans[i-1] = 1
        ans.append(i)
        counta += 1

ans.reverse()

print(counta)
if counta > 0:
    print(' '.join(map(str,ans)))

Solution (Python):


from collections import defaultdict
N = int(input())
a = [int(i) for i in input().split()]

d = defaultdict(int)


ans = 0
for n in range(N, 0, -1):
    a_i = a[n-1]
    cnt = 0
    n2 = n*2
    while n2 <= N:
        cnt += d[n2]
        n2 += n
    if cnt % 2 != a_i:
        d[n] = 1
        ans += 1

print(ans)
if ans >= 1:
    for k, v in d.items():
        if v == 1:
            print(k)

Solution (Python):

import sys

MOD = 2  

def solve(N: int, a: "List[int]"):
    a = [0] + a
    result = [0 for i in range(N+1)]
    for i in range(N, 0, -1):
        bai = 1

        summation = 0
        while bai * i <= N:
            summation += result[bai * i]
            bai += 1

        if a[i] == 0:
            if summation % 2 == 0:
                result[i] = 0
            else:
                result[i] = 1
        else:
            if summation % 2 == 0:
                result[i] = 1
            else:
                result[i] = 0
                
    print(sum(result))

    if sum(result) > 0:
        output = ''
        for i in range(1, N+1):
            if result[i] == 1:
                output += ' %d' % (i)
        print(output[1:])
    
    return



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

if __name__ == '__main__':
    main()

Solution (Python):

import sys

MOD = 2  

def solve(N: int, a: "List[int]"):
    a = [0] + a
    result = [0 for i in range(N+1)]
    for i in range(N, 0, -1):
        count_baisu = 1

        sum_ = 0
        while count_baisu * i <= N:
            sum_ += result[count_baisu * i]
            count_baisu += 1

        if a[i] == 0:
            if sum_ % 2 == 0:
                result[i] = 0
            else:
                result[i] = 1
        else:
            if sum_ % 2 == 0:
                result[i] = 1
            else:
                result[i] = 0
                
    print(sum(result))

    if sum(result) > 0:
        output = ''
        for i in range(1, N+1):
            if result[i] == 1:
                output += ' %d' % (i)
        print(output[1:])
    
    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):

"""
Created on Sat Jul 20 21:10:32 2019

@author: yama
"""

n = int(input())
l = [-1] + list(map(int, input().split()))

ll = [0 for i in range(n+1)]

for i in range(n, 0, -1):
    c = n//i
    s = 0
    for j in range(1, c+1):
        s += ll[i*j]
    if l[i] == 0:
        if s % 2 == 0:
            ll[i] = 0
        else:
            ll[i] = 1
    else:
        if s % 2 == 0:
            ll[i] = 1
        else:
            ll[i] = 0
              
m = ll.count(1)
print(m)
lll = []
for i in range(1, len(ll)):
    if ll[i] == 1:
        lll.append(i)
        
print(' '.join(map(str, lll)))

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
import math
mod = 10**9 + 7
def I(): return int(input())
def II(): return map(int, input().split())
def L(): return list(map(int, input().split()))
def TWO(M):
  L=[0]*M
  R=[0]*M
  for i in range(M):
    L[i],R[i] = II()
  return L, R
N = I()
a = L()
ans = [-1]*(N)
for i in range(N)[::-1]:
  temp = N//(i+1)
  x = []
  for j in range(2,temp+1):
    x.append(ans[(i+1)*j-1])
  ans[i] = abs(a[i]-sum(x)%2)
  

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

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

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

m = sum(ans)
s = ""
for i in range(n):
    if ans[i] == 1 and s == "":
        s += str(i+1)
    elif ans[i] == 1:
        s += " "+str(i+1)

if m == 0:
    print(m)
else:
    print(m)
    print(s)

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

for i in range(n,0,-1):
    m=n//i
    total=0
    for j in range(1,m+1):
        if j==1:
            total+=a[i-1]
        else:
            total+=b[i*j-1]
    b[i-1]=total%2
ans=sum(b)
print(ans)
if ans != 0:
    l=[]
    for i in range(n):
        if b[i]==1:
            l.append(i+1)
    print(*l)

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
b=[0]*N
ans=[]
for i in range(N):
    n=N-i
    syou=N//n
    c=0
    for l in range(1,syou):
        aa=n*(l+1)-1
        c=(c+b[aa])%2
    if a[n-1]==0:
        if c==0:
            b[n-1]=0
        else:
            b[n-1]=1
            ans.append(str(n))
    if a[n-1]==1:
        if c==0:
            b[n-1]=1
            ans.append(str(n))
        else:
            b[n-1]=0
print(len(ans))
if len(ans)>1:
    print(' '.join(ans))
if len(ans)==1:
    print(1)

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

m = 0

b_list = [0 for _ in range(N+1)]

result_list = []

for i in range(N,0,-1):
    tmp = 0
    for j in range(i+i, N+1, i):

        tmp += b_list[j]

    
    
    if not tmp%2 == a_list[i]:
        b_list[i] = 1
        result_list.append(i)
        m += 1

print(m)
if m > 0:
    print(" ".join(map(str,result_list)))

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

for i in range(N, 0, -1):

    j = i
    sum_num = 0
    while j <= N:
        a = a_list[j-1]
        if j != i:
            sum_num += a
        if i == 1:
            j += 1
        else:
            j += i
    if sum_num % 2 == 0:
        if a_list[i-1] == 0:
            continue
        else:
            a_list[i-1] = 1
    else:
        if a_list[i-1] == 1:
            a_list[i-1] = 0
        else:
            a_list[i-1] = 1

ans = sum(a_list)
print(ans)

for i in range(1, N+1):
    if a_list[i-1] != 0:
        print(i)

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

ans = [-1] * (N+1)
count = 0
for i in range(N, 0, -1):
    tmp = 0
    p = i
    p += p
    
    while p <= N: 
        tmp += ans[p]
        p += i
    ans[i] = abs(a[i] - (tmp%2))
    if ans[i] == 1:
        count += 1
    
    

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

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

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

    if s % 2 == a[i]:
        b[i] = 0
    else:
        b[i] = 1

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

Solution (Python):

from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n = int(input())
    a = [int(i) for i in input().split()]

    c = [0] * n
    b = []

    for i in range(n - 1, -1, -1):
        if i < n // 2:
            if (sum(c[j] for j in range(i, n, i + 1)) % 2) != a[i]:
                c[i] = 1
                b.append(i + 1)
        elif a[i]:
            c[i] = 1
            b.append(i + 1)

    print(len(b))
    print(*b)




BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")



if __name__ == "__main__":
    main()

Solution (Python):
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    N = INT()
    A = LIST()
    M = 0
    b = []
    yaku = [0] * N;
    for i in range(N):
        n = N - i
        if (yaku[n-1] + A[n-1]) % 2:
            b.append(n)
            M += 1
            for i in range(1, int(n**0.5)+1):
                if n % i == 0:
                    yaku[i - 1] += 1
                    if i != n // i:
                        yaku[n//i - 1] += 1
    b.reverse()
    print(M)
    if M != 0:
        print(*b)

if __name__ == '__main__':
    main()

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

def prim(n):
    result = []
    for x in range(1, int(n ** 0.5) + 1):
        if n % x == 0:
            result.append(x)
            pair = n // x
            if pair != x:
                result.append(n // x)
    return result

ans = [0] * (n + 1)
ball = [0] * (n + 1)
for i in reversed(range(1, n + 1)):
    value = ans[i] ^ a[i]
    ball[i] = value
    for x in prim(i):
        ans[x] ^= value
print(sum(ball))
for i, v in enumerate(ball[1:], 1):
    if v:
        print(i, end=" ")
print()

Solution (Python):
n = int(input())
aa = list(map(int, input().split()))
aa = [-1] + aa[:]
ans = []
for i in range(n // 2 + 1, n + 1):
    if aa[i]:
        ans.append(i)
for i in range(n // 2, 0, -1):
    s = 0
    for ii in range(i * 2, n + 1, i):
        s += aa[ii]
    if aa[i] == s % 2:
        aa[i] = 0
    else:
        aa[i] = 1
        ans.append(i)
print(len(ans))
if ans:
    print(*ans, sep="\n")

Solution (Python):
n = int(input())
div = [None] + [int(v) for v in input().split()]
result = [None for _ in range(n+1)]

for d in range(1, n+1):
    for i in range(n//d, n//(d+1), -1):
        part = sum([result[i*j] for j in range(2, d+1)], 0)
        result[i] = (part + div[i]) % 2

print(sum(result[1:]))
for i, r in enumerate(result[1:]):
    if r > 0:
        print(i+1)

Solution (Python):
n = int(input())
aaa = list(map(int, input().split()))
aaa = [0] + aaa
for i in range(n // 2, 0, -1):
    b = 0
    j = i * 2
    while n >= j:
        b ^= aaa[j]
        j += i
    aaa[i] ^= b

ans = [i for i, b in enumerate(aaa) if b]
print(len(ans))
print(*ans)

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

b = [0]
b.extend(a)
array = [0 for _ in range(n+1)]
result = []

for i in range(n, 0, -1):
    num = 1
    counter = 0
    while i*num <= n:
        if array[i*num] == 1:
            counter += 1

        num += 1

    if counter % 2 != b[i]:
        array[i] = 1
        result.append(i)

print(len(result))
for i in result:
    print(i, end=' ')

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


B = []
checked = [0 for _ in range(N)]
for i in range(N, 0, -1):
    num = N // i
    a = A[i-1]
    for j in range(1, num+1):
        a += checked[j*i-1]
    if a % 2 == 1:
        B.append(i)
        checked[i-1] = 1
print(len(B))
print(' '.join([str(b) for b in B]))

Solution (Python):
import math

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

B = [str(N - i) for i in range(math.ceil(N / 2)) if A[N - i - 1] == 1]
C = [0] * math.floor(N / 2) + A[math.floor(N / 2):]

for i in range(math.floor(N / 2), 0, -1):
    count = 0
    for j in range(i, N + 1, i):
        count += C[j - 1]
    if not count % 2 == A[i - 1]:
        B.append(str(i))
        C[i - 1] = 1

print(len(B))
if not len(B) == 0:
    print(" ".join(B))