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

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

for i in range(N-1,-1,-1) :
    num = i+1
    cnt = 0
    for j in range(i+num,N,num) :
        cnt += B[j]
    
    if A[i] != cnt % 2 :
        ans.append(i+1)
        B[i] = 1
    
print(len(ans))
print(*ans, sep="\n")

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

ball = [0] * N
ans = []

for i in range(1, N+1) :
    ballCount = sum(ball[N-i::N-i+1])
    if ballCount % 2 == A[N-i] :
        pass
    else :
        ball[N - i] = 1
        ans.append(N - i + 1)
print(len(ans))
print(*ans)

Solution (Python):

n = int(input())
a = list(map(int, input().split()))
b = [0]*n
cnt = 0
ans = 0
seq = []
for i in reversed(range(1,n+1)):
    sumi = sum(b[i-1:n:i])
    if sumi % 2 == a[i-1]:
        continue
    else:
        b[i-1] = 1
        seq.append(i)
        cnt += 1
    
if ans == -1:
    print(-1)
else:
    print(cnt)
    print(' '.join(list(map(str, seq))))

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


for i in range((n//2+1),n+1):
  b[i]=a[i]
for i in range(n//2,0,-1):
  j=2
  b[i]=a[i]
  while(j*i<=n):
    b[i]^=b[j*i]
    j+=1

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

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

b=[0]*n

for i in range(1,n+1):
    now=n-i+1
    tmp=0
    j=now+now
    while(j<=n):
        if b[j-1]==1:
            tmp+=1
        j+=now
    tmp=tmp%2
    if tmp==a[now-1]:
        pass
    else:
        b[now-1]=1

anscount=0
ans=[]
for i in range(n):
    if b[i]==1:
        anscount+=1
        ans.append(i+1)
print(anscount)
print(" ".join(map(str,ans)))

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

st = int(n/2)
ans =  [i+st+1 for i, n in enumerate(a[st:]) if n ==1] 
for ind in range(st, 0, -1):
    tmp = [ls[i] for i in range(2*ind-1, n, ind)]
    s = sum(tmp)%2
    if a[ind-1] == s:
        ls[ind-1] = 0
    else:
        ls[ind-1] = 1
        ans.append(ind)
        
print(sum(ls))
print(' '.join(map(str, ans)))

Solution (Python):
l = []
counter = 0
ans_list = []

n = int(input())
b_list = [0 for _ in range(n)]
l = list(map(int, input().split()))

for i in range(n,0,-1):
    index = n // i
    if index == 1: 
        b_list[i-1] = l[i-1]
    else:
        sum = 0
        for j in range(2, index+1):
            sum = sum + b_list[(i * j)-1]
        
        if l[i-1] != sum % 2:
            b_list[i-1] = 1

    if b_list[i-1] == 1:
        counter += 1
        ans_list.append(str(i))


print(counter)
if ans_list != []:
    print(' '.join(sorted(ans_list)))

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

for n in range(N):
  i = N-n
  BB = B[::i]
  if (sum(BB))%2 == A[i-1]:
    B[i] = 0
  else:
    B[i] = 1
    x.append(str(i))
  
if len(x) == 0:
  print(0)
else:
  print(len(x))
  print(' '.join(x))

Solution (Python):
import math
def func1(lst, value):
    return [i+1 for i, x in enumerate(lst) if x == value]
N = int(input())
a = list(map(int,input().split()))

b = [0] * N

summ = 0
for i in reversed(range(N)):

    x = N//(i+1)

    if x == 1:
        b[i] = a[i]
    else:
        for j in range(x):
            
            summ += b[(i+1)*(j+1)-1]
        
        
        judge=summ%2
        
        if (judge==0 and a[i]==0) or (judge==1 and a[i]==1):
            b[i] = 0
        else:
            b[i] = 1
        summ = 0
        judge = 0

print(sum(b))
if sum(b) != 0:
    ans = func1(b,1)
    
    if len(ans)>1:
        ans = map(str,ans)
        print(" ".join(ans))
    else:
        print(str(ans.pop()))

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

for i in range(1,n+1):

    j = 1
    while (n-i+1)*j <= n:
        B_sum[n-i+1] += B[(n-i+1)*j]
        j += 1
    if B_sum[n-i+1] % 2 != A[n-i]:
        B[n-i+1] = 1
        count += 1
print(count)
for i in range(1,n+1):
    
    if B[i]==1:
        print(str(i) + " ", end = "")

Solution (Python):
import math

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


mid = math.floor(N / 2)


M = 0
b = [0 for i in range(N)]
b.insert(0, -1)
for i in reversed(range(1, N + 1)):
    num = 0
    for j in range(1, N // i + 1):
        num += b[j * i]
    if num % 2 == 0:
        if a[i] == 0:
            b[i] = 0
        else:
            M += 1
            b[i] = 1
    else:
        if a[i] == 0:
            M += 1
            b[i] = 1
        else:
            b[i] = 0

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

Solution (Python):
m = int(input())
b = list(map(int, input().split()))
a = [-1 for i in range(m)]

for i in range(m//2+1,m+1):
        a[i-1] = b[i-1]

for i in range(m//2,m//3,-1):
    if b[i-1] == b[i*2-1]:
        a[i-1] = 0
    else:
        a[i-1] = 1



for i in range(m//3,0,-1):

    suma = b[i*2-1]
    for ii in range(i*3-1,m,i*2):
        suma += a[ii]

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

print(a.count(1))
c= []
for i in range(m):
    if a[i] == 1:
        c.append(str(i+1))

print(' '.join(c))

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

Solution (Python):
import sys
import math

def add_ball(idx):
    add_list = []
    for j in range(1, int(math.sqrt(idx))+1):
        if idx%j == 0:
            add_list.append(j)
            if j != idx//j:
                add_list.append(idx//j)
    for k in add_list:
        b_list[k] += 1

if __name__ == "__main__":
    input = sys.stdin.readline

    n = int(input())
    a_list = list(map(int, input().split()))
    b_list = [0] * (n+1)
    cnt = 0
    ans_list = []
    for a, i in zip(reversed(a_list), range(n, 0, -1)):
        if a != b_list[i]%2:
            cnt += 1
            ans_list.append(i)
            add_ball(i)
    ans_list.sort()
    print(cnt)
    if cnt > 0:
        print(' '.join(map(str, ans_list)))

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

b = [0] * n

for i in range(0, n)[::-1]:
  if (i+1)*2 > n:
    if a[i] == 1:
      b[i] = 1
  else:
    tmp = 0
    for j in range(i,n)[::i+1]:
     
      tmp = tmp ^ b[j]
    b[i] = tmp ^ a[i]

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

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

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

res = [-1 for i in range(N//2)] + [ai for ai in a[N//2 : N]]

for i in range(N//2, 0, -1):
    res[i-1] = (sum(res[2*i-1:N:i]) % 2) ^ a[i-1]

ans = [i+1 for i in range(N) if res[i] == 1]
print(len(ans))

if len(ans) != 0:
    print(' '.join(list(map(str,ans))))

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

Solution (Python):

import sys
sys.setrecursionlimit(4100000)
n = int(input())
a = [int(i) for i in input().split()]
balls = [0] * (n+1)

for i in reversed(range(1,n+1)):
    temp = i*2
    current = 0
    while temp <= n:
        current += balls[temp]
        temp += i
    if current%2 == 0:
        if a[i-1] == 0:
            balls[i] = 0
        else:
            balls[i] = 1
    else:
        if a[i-1] == 1:
            balls[i] = 0
        else:
            balls[i] = 1
counter = 0

for i in range(n):
    if balls[i+1] == 1:
        counter += 1
print(counter)
for i in range(n):
    if balls[i+1] == 1:
        print(i+1)

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

b=[0]*N

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

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
B = [0]*N
for i in range(N, 0, -1):
  t = B[(i-1)::i]
  s = sum(t)%2
  B[i-1] = 0 if s == A[i-1] else 1

ans = sum(B)
print(ans)
ans_b = []
if ans > 0:
  for i in range(N):
    if B[i] > 0:
      ans_b.append(str(i+1))
  print(' '.join(ans_b))

Solution (Python):


def solve(A, N):
    B = [0] * len(A)
    for i in range(1, N+1)[::-1]:
        A2 = A[i*2] if i*2 <= N else 0
        x = A[i]
        for j in range(i*2, N+1, i):
            x ^= B[j]
        B[i] = x
    return B



def main():
    N = int(input())
    A = [0] + [int(x) for x in input().split()]
    B = solve(A, N)
    print(sum(B))
    for i in range(1, N+1):
        if B[i]:
            print(i)

main()

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

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
B = [0 for _ in range(N)]
for n, a in enumerate(reversed(A)):
    l = N - 1 - n
    if sum(B[l:: l + 1]) % 2 != a:
        B[l] = 1
M = sum(B)
print(M)
ans = [str(n + 1) for n in range(N) if B[n] == 1]
print(' '.join(ans))

Solution (Python):
import sys

N = int(input())
Atmp = [0] + list(map(int, input().split()))
A = {}

for i,a in enumerate(Atmp):
    A[i] = a



X = {}

for i in reversed(list(range(1,N+1))):
    Xsum = 0
    j = 2
    while(i*j <= N):
        Xsum += X[i*j]
        j += 1
        continue
    odd = Xsum % 2
    if odd == A[i]:
        X[i] = 0
    else:
        X[i] = 1
    
M = 0
for i in range(1, N+1):
    if X[i] == 1:
        M += 1

print(M)
if M == 0:
    sys.exit()

xxx = []
for i in range(1, N+1):
    if X[i] == 1:
        xxx.append(str(i))

print(' '.join(xxx))

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

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

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

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

for i in range(0,n):
    j = n - 1 - i
    c = 0
    for k in range(2, n+1):
        idx = k * (j + 1) - 1
        if  idx > n-1:
            break
        c += bn[idx]
    
    bn[j] = (c + ai[j]) % 2


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

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

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

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

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

b=[0]*n
m=[]
for i in range(n,0,-1):
    v=0
    for j in range(i,n+1,i):
        v+=b[j-1]
    
    if v%2!=a[i-1]:
        b[i-1]=1
        m.append(i)

print len(m)
print " ".join(map(str, m))

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

Solution (Python):
n=int(input())
al=list(map(int,input().split()))
ans=[]
tl=[0]*n
for i in range(n,0,-1):
    if tl[i-1]%2^al[i-1]:
        ans.append(i)
        for j in range(1,int(i**0.5)+1):
            if i%j==0:
                tl[j-1]^=1
                if j**2==i:
                    continue
                tl[i//j-1]^=1
print(len(ans))
print(*ans)

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

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

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

Solution (Python):

N = int(input())

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

bn = [0] * N

for i in range(N, 0, -1):
    s = sum(bn[(i - 1)::i]) % 2
    bn[i - 1] = 0 if s == an[i - 1] else 1

ans = sum(bn)
print(ans)
ans_b = []
if ans != 0:
    for i in range(N):
        if bn[i] == 1:
            ans_b.append(str(i + 1))
    print(' '.join(ans_b))

Solution (Python):
N = int(input())
ans = 0
lst = list(map(int, input().split()))
slice_lst = lst[:int(N / 2)]
for i,k in enumerate(reversed(slice_lst)):
  sub_lst = lst[len(slice_lst)-i-1:len(lst):len(slice_lst)-i]
  if (k != sum(sub_lst) % 2):
    if (k == 0):
      lst[len(slice_lst)-i-1] = 1
    else:
      lst[len(slice_lst)-i-1] = 0

if (ans == -1):
  print(ans)
else:
  ans_lst = []
  for i,k in enumerate(lst):
    if (k == 1):
      ans_lst.append(str(i+1))
  print(len(ans_lst))
  result = ' '.join(ans_lst)
  print(result)

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

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

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

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
M = N//2
ans = -1

def fun(x):
    u = 0
    n = N//x-1
    for i in range(n):
        u+=a[x*(i+2)-1]
    return u%2

for i in range(M):
    y = fun(M-i)
    if a[M-i-1] == 1 and y == 1:
        a[M-i-1] = 0
    elif a[M-i-1] == 0 and y == 1:
        a[M-i-1] = 1

print(sum(a))
for j in range(N):
    if a[j] == 1:
        print(str(j+1)+" ", end="")

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

Solution (Python):
def yakusuu(n):
    yakusuu_list = list()
    for i in range(n):
        if n % i == 0:
            yakusuu_list.append(i)
    return yakusuu_list


def baisuu(n, max_N):
    baisuu_list = list()
    for i in range(n, max_N + 1, n):
        baisuu_list.append(i)
    return baisuu_list


N = int(input())
A = [-1] + list(map(int, input().split()))
box = [0 for _ in range(N + 1)]
ans = list()

for i in range(N, N // 2, -1):
    box[i] = A[i]

for i in range(N // 2, 0, -1):
    baisuu_list = baisuu(i, N)
    baisuu_xor = 0
    for b in baisuu_list:
        baisuu_xor ^= box[b]
    box[i] = baisuu_xor ^ A[i]

print(sum(box))
for i in range(1, N + 1):
    if box[i] == 1:
        ans.append(i)
print(" ".join(map(str, ans)))

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

Solution (Python):

N = int(input())

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

bn = [0] * N

for i in range(N, 0, -1):
    s = sum(bn[(i - 1)::i]) % 2
    bn[i - 1] = 0 if s == an[i - 1] else 1

ans = sum(bn)
print(ans)
ans_b = []
if ans != 0:
    for i in range(N):
        if bn[i] == 1:
            ans_b.append(str(i + 1))
    print(' '.join(ans_b))

Solution (Python):
"""
1 2 3 4 5 6 ... N
任意のiについて
iの倍数が書かれた箱に入っているボールの個数の和を2で割ったあまりがai
"""

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

"""
1 2 3 4 5 6
0 1 0 1 0 1

i = 1  sum(As)%2 
i = 2  sum(As[::2]%2)

1    1 1 1 1 1 1 1 1 1 1
2    0 1 0 1 0 1 0 1 0 1
3    0 0 1 0 0 1 0 0 1 0
4    0 0 0 1 0 0 0 1 0 0
5    0 0 0 0 1 0 0 0 0 1
6    0 0 0 0 0 1 0 0 0 0
7    0 0 0 0 0 0 1 0 0 0
8    0 0 0 0 0 0 0 1 0 0 
9    0 0 0 0 0 0 0 0 1 0
10   0 0 0 0 0 0 0 0 0 1

後ろから決めていく？
"""
Bs = [0] * N
inball = []
for i in [N-i for i in range(N)]:
    n = N//i
    cnt = 0
    for j in [n-i for i in range(n)]:
        cnt += Bs[i*j-1]
    Bs[i-1] = (cnt+As[i-1]) % 2

ans = [i+1 for i,b in enumerate(Bs) if b==1]
M = len(ans)
print(M)
if M > 0:
    print(*ans)

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

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

ans=[]
li2=[0 for _ in range(n)]
for i in range(n,0,-1):
  count=0
  for j in range(i*2,n+1,i):
    if li2[j-1]==1:
      count+=1
  if count%2!=li[i-1]:
    li2[i-1]=1
    ans.append(i)

ans.reverse()
print(len(ans))
L=[str(a) for a in ans]
L=" ".join(L)
if len(L)!=0:
  print(L)

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

for k in range(N,0,-1):
    t = 0
    l = 1
    while l*k-1 < N:
        t += B[l*k-1]
        l += 1
    if t%2 != A[k-1]%2:
        B[k-1] = 1

print(sum(B))
C = []
for k in range(N):
    if B[k] == 1:
        C.append(k+1)
print(*C)

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

h = N // 2 + N % 2
ans = [-1] * N

for i in range(h, N):
    ans[i] = a[i]
for i in range(h - 1, -1, -1):
    ans[i] = ((sum(ans[i::i + 1]) + 1) % 2) ^ a[i]

print(sum(ans))
for i, x in enumerate(ans):
    if x == 1:
        print(i+1)

Solution (Python):
n = int(input())
a = input().split(' ')

b = [int(x) for x in a]

c = []
for i in range(n):
    c.append(0)

d=[]

for i in range(n):
    i = n - i
    s = 0
    for j in range(i*2,n+1,i):
     
        s = s + c[j-1]
    
    if s%2 != b[i-1]:
        c[i-1] = 1
        d.append(i)

d=sorted(d)
print(len(d))
for i in range(len(d)):
    print(d[i],end=' ')

Solution (Python):
import heapq as hq
def main():
    n = int(input())
    a = list(map(int,input().split(' ')))
    ans = [0]*(n+1)
    ans_cnt = 0
    for num,i in enumerate(a[::-1]):
        cnt = 0
        for j in range(n-num,n+1,n-num):
            if ans[j] ==1:
                cnt += 1
        if cnt%2 != i:
            ans[n-num] = 1
            ans_cnt += 1
    print(ans_cnt)
    for num,i in enumerate(ans):
        if i:
            print(num,'',end='')

if __name__ == '__main__':
    main()

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

boxin = []
bx = [0 for _ in range(N+1)]
for cnt in range(N, 0, -1):
    a = ax[cnt-1]
    i = 2
    memo_cnt = 0
    while 1:
        test_val = i * cnt
        if test_val > N:
            break
        if bx[test_val]:
            memo_cnt += 1
        i += 1
    if a != memo_cnt % 2:
        boxin.append(cnt)
        bx[cnt] = 1

 
box = len(boxin)
print(box)
if box != 0:
    boxin.reverse()
    print(' '.join(map(str, boxin)))

Solution (Python):
N = int(input())
l = list(map(int,input().split(' ')))
mid = N // 2
MAP = [0]*N
ans_l = []
for i in range(N-1,mid-1,-1):
    k = l[i]
    MAP[i] = k
    if k==1:
        ans_l.append(str(i+1))
flag = False
for i in range(mid,0,-1):
    s = N // i + 1
    t = 0
    for j in range(2,s):
        t += MAP[i*j-1]
    if t%2==0:
        if l[i-1]%2==1:
            ans_l.append(str(i))
            MAP[i-1] += 1
    else:
        if l[i-1]%2==0:
            ans_l.append(str(i))
            MAP[i-1] += 1
 
leng = len(ans_l)
print(leng)
print(" ".join(ans_l))

Solution (Python):
N = int(input())
l = list(map(int,input().split(' ')))
mid = N // 2
MAP = [0]*N
ans_l = []

for i in range(N,0,-1):
    s = N // i + 1
    t = 0
    for j in range(1,s):
        t += MAP[i*j-1]
    if t%2 != l[i-1]:
        ans_l.append(str(i))
        MAP[i-1] = 1
leng = len(ans_l)
print(leng)
print(" ".join(ans_l))

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

a.insert(0, 0)
b.insert(0, 0)

n = int(N/2)

for i in range(N, 0, -1):
    nums = 0
    for ii in range(2, int(N/i)+1):
        nums += b[i*ii]

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

sum_b = sum(b)
print(sum_b)

flag = False
for i, bb in enumerate(b):
    if i == 0:
        continue

    if bb != 0:
        flag = True
        print(i, end=' ')

if flag:
    print()

Solution (Python):


import sys

sys.setrecursionlimit(10**7)


input = sys.stdin.readline


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h(typ) if m > 1 else typ(input()) for _ in range(n)]


def main():
    n, = read_h()
    mod = [None] + read_h()

    i = n
    box = [None] * (n + 1)
    while i >= 1:
        s = sum(box[j] for j in range(i * 2, n + 1, i))
        box[i] = abs(mod[i] - (s % 2))
        i -= 1

    
    

    print(sum(box[1:]))
    t = [str(i) for i, b in enumerate(box) if b is not None and b > 0]
    if t:
        print(' '.join(t))


if __name__ == '__main__':
    main()

Solution (Python):
import sys

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

if __name__ == "__main__":
    n = int(input())
    al = list(map(int, input().split()))

    nums = [0] * n
    for i in range(n, 0, -1):
        if sum(nums[i-1::i]) % 2 != al[i-1]:
            nums[i-1] = 1

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

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

def dq(N, Alist):
    Blist = [0]*(N//2+1)+Alist[N//2:]
    Alist = [0]+Alist
    for ind in range(N//2, 0, -1):
        total = 0
        for i in range(ind, N+1, ind):
            total += Blist[i]
        if total%2 != Alist[ind]:
                Blist[ind] = 1
    retnum = 0
    retind = []
    for ind, bi in enumerate(Blist):
        if bi == 1:
            retnum +=1
            retind.append(str(ind))
    print(retnum)
    if retnum > 0:
        print(" ".join(retind))
dq(N,Alist)

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

def index(n):
    return [i for i in range(2 * n, N + 1, n)]


F = set()
for n in range(N, 0, -1):
    a = sum([1 if i in F else 0 for i in index(n)])
    if a % 2 != A[n]:
        F.add(n)

print(len(F))
L = list(map(str, F))
print(" ".join(L))

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
b = [0] * n
f = 0
for i in sorted(list(range(n)),reverse=True):
	k = n//(i+1)
	if a[i] == 1:
		if k == 1:
			b[i] = 1
		else:
			c = 0
			for j in range(0,k):
				c+=b[i+(j*(i+1))]
			if c % 2 == 0:
				b[i] = 1
	else:
		if k != 1:
			c = 0
			for j in range(0,k):
				c+=b[i+(j*(i+1))]
			if c % 2 == 1:
				b[i] = 1
print(sum(b))
result=[]
for i in range(len(b)):
	if b[i] == 1:
		result.append(i+1)
if len(result) > 0:
	print(*result)

Solution (Python):
def findcount(arr, x, n):
	ans = 0
	for i in range(x, n+1, x):
		ans += arr[i-1]
	
	return ans


n = int(input())
arr = [int(j) for j in input().split()]

ans = [False]*n
for i in range(n, 0, -1):
	x = findcount(ans, i, n)
	if x%2 == arr[i-1]:
		continue
	else:
		ans[i-1] = True

count = 0
temp = []
for x in range(1, n+1):
	if ans[x-1] == True:
		temp += [x]
		count += 1

print(count)
print(*temp)

Solution (Python):
N = int(input())
l = list(map(int,input().split(' ')))
mid = N // 2
MAP = [0]*N
ans_l = []

for i in range(N,0,-1):
    s = N // i + 1
    t = 0
    for j in range(1,s):
        t += MAP[i*j-1]
    if t%2 != l[i-1]:
        ans_l.append(str(i))
        MAP[i-1] = 1
leng = len(ans_l)
print(leng)
print(" ".join(ans_l))

Solution (Python):
import math
N = int(input())
ax = list(map(int,input().split()))

M = 0
boxin = []
bx = [0 for _ in range(N+1)]
for cnt in range(N, 0, -1):
    a = ax[cnt-1]
    tmp = 0
    for tmp_cnt in range(cnt*2, N+1, cnt):
        if bx[tmp_cnt] != 0:
            tmp += 1
    
    if tmp % 2 != a:
        bx[cnt] = 1
        boxin.append(cnt)

box = len(boxin)
print(box)
if box != 0:
    boxin.reverse()
    print(' '.join(map(str, boxin)))

Solution (Python):
n = int(input())
A = [int(i) for i in input().split()]
A.insert(0, 0)

boxes = dict()
have_balls = list()
for bn in range(n, 0, -1):
    a = A[bn]
    s = 0
    for t in range(2, n+1):
        if bn * t > n:
            break
        s += boxes[bn*t]

    if s % 2 == a:
        boxes[bn] = 0
    else:
        boxes[bn] = 1
        have_balls.append(str(bn))

print(len(have_balls))
print(' '.join(have_balls))

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

for n in range(N):
    i = N - n
    BB = B[::i]
    if (sum(BB)) % 2 == A[i - 1]:
        B[i] = 0
    else:
        B[i] = 1
    if B[i] == 1:
        x.append(str(i))

if len(x) == 0:
    print(0)
else:
    print(len(x))
    print(' '.join(x))

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

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

Solution (Python):
N=int(input())
listA=list(map(int,input().split()))
listB=[0 for i in range(N)]
listANS=[]
for i in range(N-1,-1,-1):
  listN=listA[i:N:i+1]
  if len(listN)==1 and listA[i]==1:
    listB[i]=1
  elif len(listN)>1 and listA[i]!=sum(listB[i:N:i+1])%2:
    listB[i]=1
for i in range(N):
  if listB[i]==1:
    listANS+=[i+1]
ANS=len(listANS)
print(ANS)
if ANS!=0:
  print(*listANS)

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

for n in range(N):
  i = N-n
  
  BB = B[::i]
  if (sum(BB))%2 == A[i-1]:
    B[i] = 0
  else:
    B[i] = 1
    
  if B[i] == 1:
    x.append(str(i))
  
if len(x) == 0:
  print(0)
else:
  print(len(x))
  print(' '.join(x))

Solution (Python):

"""
Created on Sat Jul 20 20:54:28 2019

@author: sp8783
"""
import copy

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

tmp = copy.deepcopy(lst)

f_lst = list(range(n//2))[::-1]

for i in f_lst:
    a = (sum(tmp[i::i+1])-tmp[i]) % 2
    b = tmp[i]
    if a == b:
        tmp[i] = 0
    else:
        tmp[i] = 1
    
print(sum(tmp))
x = [i+1 for i, x in enumerate(tmp) if x == 1]
print(*x)

Solution (Python):

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

for i in range(n, 0, -1):
    if i > n // 2:
        b[i] = a[i]
    else:
        s = 0
        for j in range(2, n // i + 1):
            if i * j > n:
                break
            s += b[i * j]
        mod = s % 2
        if mod == 0:
            b[i] = a[i]
        else:
            b[i] = 1 - a[i]

ans = sum(b)
print(ans)
if ans > 0:
    print(" ".join([str(i) for i, x in enumerate(b) if x == 1]))

Solution (Python):
def inpl():
    return list(map(int, input().split()))


def func(n):
    
    tmp = n + n
    a = 0
    while tmp <= N:
        a += ans[tmp - 1]
        tmp += n
    return a % 2


N = int(input())
A = inpl()
ans = [0 for i in range(N)]

for i in reversed(range(N)):
    if func(i + 1) != A[i]:
        ans[i] = 1


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

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

Solution (Python):
import math

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

use=[-1 for _ in range(N)]
for i in reversed(range(N)):
    use[i]=a[i]
    
    if i+1==N//2+1:
        break

for i in reversed(range(N//2)):
    x=i+1
    tmp=0
    cnt=2
    while cnt*x<=N:
        tmp+=use[cnt*x-1]
        
        cnt+=1
    use[i]=(tmp+a[i])%2
    

print(sum(use))
ans=""
for i in range(N):
    if use[i]==1:
        ans+=str(i+1)+" "
ans.split()
print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
 
ans=[]
cnt=0
B = [0 for i in range(N)]
import math
for i in range(math.floor(N/2),N):
    B[i]=A[i]
    if(A[i]==1):
        cnt+=1
        ans.append(i+1)
        
from functools import reduce
for i in range(math.floor(N/2)-1,-1,-1):
    R=[B[(i+1)*j-1] for j in range(2,(N//(i+1))+1)]
    r=sum(R)%2
    l = int(not (r)) if A[i]==1 else int(r)
    B[i]=l
    if l==1:
        cnt+=1
        ans.append(i+1)
print(cnt)
if cnt>0:
    print(" ".join(map(str, ans)))

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

ball_list = [0] * (N + 1)
for n in reversed(range(1, N + 1)):
    mod = 0
    for i in range(n, N + 1, n):
        mod ^= ball_list[i]
    if mod != a_list[n - 1]:
        ball_list[n] = 1

num = sum(ball_list)
print(num)

if num > 0:
    for i, b in enumerate(ball_list):
        if b == 1:
            print(i)