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())
b = list(map(int, input().split()))
bb = [0 for _ in range(N+1)]
ans = []

for num, val in list(enumerate(b))[::-1]:
    if not sum(bb[::num+1]) % 2 == val:
        bb[num+1] = 1
        ans.append(str(num+1))
print(len(ans))
if len(ans):
    print(' '.join(ans))

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

for num, val in list(enumerate(b))[::-1]:
    if not sum(bb[::num+1]) % 2 == val:
        bb[num+1] = 1
        ans.append(str(num+1))
print(len(ans))
if len(ans):
    print(' '.join(ans))

Solution (Python):
N = int(input())
num_line = [0] + list(map(int, input().split()))
for i in range(N//2, 0, -1):
    num_line[i] = sum(num_line[i::i]) % 2
    
        
print(num_line.count(1))
print(" ".join(map(str, list(i for i in range(1, N+1) if num_line[i] == 1))))

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

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

print(ans.count(1))
result = ''
for i in range(N):
    if ans[i] == 1:
        result += str(i+1) + ' '
print(result)

Solution (Python):
n,a,d,l=int(input()),list(map(int,input().split())),set(),0;b=[0]*n
for i in range(n-1,-1,-1):
  c=0
  for j in range(2*i+1,n,i+1):c=(c+b[j])%2
  if a[i]!=c:b[i]+=1;d.add(i+1);l+=1
print(l)
print(*[d.pop()for _ in range(l)])

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
b=[0 for i in range(n)]
c=0
d=[]
for i in range(n-1,-1,-1):
  j=2
  c=b[i]
  while((i+1)*j<=n):
    c=c^b[(i+1)*j-1]
    j+=1
  if (c!=a[i]):
    b[i]=1
  c=0
  j=2
print('{0}'.format(sum(b)))
for i in range(n):
  if(b[i]==1):
    d.append(i+1)
e=list(map(str,d))
f=' '.join(e)
print('{0}'.format(f))

Solution (Python):
import sys,math
n = int(input())
a = list(map(int,input().split()))
select = [0 for _ in range(n+1)]
mark = [0 for _ in range(n+1)]
c = 0
for i in range(n-1,0,-1):
    if a[i] ==0 and mark[i+1]%2==1:
        c += 1
        select[i + 1] = 1
        l = 1
        r = (i + 1)
        m = math.sqrt(i+1)
        m = int(m)
        while (l <=m):
            if (i + 1) % l == 0:
                mark[l] += 1
                r = (i + 1) // l
                if l != r:
                    mark[r] += 1
            l += 1
    if a[i] and mark[i+1]%2==0:
        c+=1
        select[i + 1] = 1
        l = 1
        r = (i + 1)
        m = math.sqrt(i + 1)
        m = int(m)
        while (l <= m):
            if (i + 1) % l == 0:
                mark[l] += 1
                r = (i + 1) // l
                if l!=r:
                    mark[r] += 1
            l += 1
if a[0]==0 and mark[1]%2==1:
    c+=1
    select[1]=1
    mark[1]+=1
elif a[0]==1 and mark[1]%2==0:
    c += 1
    select[1] = 1
    mark[1] += 1
print(c)
for i in range(1,n+1):
    if select[i]:
        sys.stdout.write('{} '.format(i))

Solution (Python):
from collections import defaultdict

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

d = defaultdict(int)


def makeDivisor(n):
    for i in range(1, int(n ** 0.5)+1):
        if n % i == 0:
            d[i] += 1
            if i != n // i:
                d[n//i] += 1
    return

b = [0] * N
cnt = 0
for i in range(N, 0, -1):
    if d[i] % 2 == 1 and a[i-1] == 0:
        b[i-1] = 1
        cnt += 1
        makeDivisor(i)
    elif d[i] % 2 == 0 and a[i-1] == 1:
        b[i-1] = 1
        cnt += 1
        makeDivisor(i)

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

Solution (Python):

import sys
n = int(input())
a=list(map(int,input().split()))
b=[0 for i in range(n)] 
for i in range(n-1,-1,-1): 
    limit=n//(i+1) 
    if limit==1: 
        b[i]=a[i] 
    else:
        modcontainer=0 
        for j in range(limit,0,-1): 
            modcontainer+=b[(i+1)*j-1] 
            modcontainer%=2
        if modcontainer!=a[i]:
            b[i]=1
print(b.count(1))
if b.count(1)==0:
    sys.exit()
else:
    c=list(enumerate(b))
    d=[str(i+1) for i in range(len(b)) if c[i][1]==1]
    print(" ".join(d))

Solution (Python):
import sys
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
a = IL()
cnt = [0]*(N+1)
ans = []
M = 0
for i in range(N-1,-1,-1):
  tmp = sum(cnt[i::i+1])
  if tmp%2 != a[i]:
    ans.append(str(i+1))
    cnt[i] = 1
    M += 1

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

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

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

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

for i in range(N, 0, -1):
    tmp = 0
    j = i
    while j < N+1:
        tmp += A[j]
        j += i
    A[i] = tmp % 2
ans = []
for i, j in enumerate(A):
    if j == 1:
        ans.append(i)

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

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

for _ in range(N):
    i = N - _
    a = A[i-1]
    if sum(R[i::i]) % 2 != a:
        R[i] = 1
        ans.append(i)

ans.sort()
print(len(ans))
if ans:
    print(' '.join(map(str, ans)))

Solution (Python):


def main():
    N = int( input())
    A = [0] + list( map( int, input().split()))
    ANS = [0]*(N+1)
    for i in range(N,0,-1):
        t = sum([ANS[i*(j+1)] for j in range(N//i)] )%2
        if t == A[i]:
            continue
        ANS[i] = 1
    print( sum(ANS))
    print( " ".join( map( str, [ i for i in range(N+1) if ANS[i] == 1])))
if __name__ == '__main__':
    main()

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

for i in range(N//2, 0, -1):
    tmp = 0
    j = i
    while j < N+1:
        tmp += A[j]
        j += i
    A[i] = tmp % 2

ans = []
for i, j in enumerate(A):
    if j == 1:
        ans.append(i)


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

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

for i in range(N//2, 0, -1):
    tmp = 0
    j = i
    while j < N+1:
        tmp += A[j]
        j += i
    A[i] = tmp % 2
    
ans = [i for i, j in enumerate(A) if j == 1]

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

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

for i in range(N//2, 0, -1):
    
    
    
    
    
    
    A[i] = sum(A[i::i]) % 2
ans = [i for i, j in enumerate(A) if j == 1]

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

Solution (Python):

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

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

def check(i):
    cnt = 0
    n = i
    while n <= N:
        cnt += b[n-1]
        n += i
    return cnt

for i in range(N-1, -1, -1):
    if (a[i] + check(i+1)) % 2 == 1:
        b[i] = 1

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

print(cnt)
L = [str(int(i)) for i in ans]
print(' '.join(L))

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

Solution (Python):
import sys
sys.setrecursionlimit(4100000)

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)



def resolve():
    N = [int(x) for x in sys.stdin.readline().split()][0]
    a_list = [int(x) for x in sys.stdin.readline().split()]

    logger.debug('{} {}'.format(N, a_list))

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

    for i in reversed(range(N)):
        suma = sum(box_list[i:N:i+1])

        r = suma % 2
        if r != a_list[i]:
            box_list[i] = 1

    s = sum(box_list)
    print(s)

    if s > 0:
        print(' '.join(
            [str(i + 1) for i in range(len(box_list)) if box_list[i]]))


if __name__ == "__main__":
    resolve()





import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3
1 0 0"""
        output = """1
1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """5
0 0 0 0 0"""
        output = """0"""
        self.assertIO(input, output)

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

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

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

Solution (Python):
N = int(input())
arr = [0] + list(map(int, input().split(' '))) 
for i in range(N//2, 0, -1):
  arr[i] = sum(arr[i::i]) % 2
ans = [i for i, j in enumerate(arr) if j == 1]
print(len(ans))
print(*ans)

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

def check(i):

    n = i
    cnt = 0
    
    while n <= N:
        cnt += b[n-1]
        n += i
        
    return cnt

for i in range(N-1, -1, -1):
    if (a[i]+check(i+1))%2 == 1:
        b[i] = 1
    
ans = sum(b)
ll = []
for i in range(N):
    if b[i] == 1:
        ll.append(i+1)

lll = [str(i) for i in ll]
if ans == 0:
    print(ans)
else:
    print(ans)
    print(" ".join(lll))

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

C = [0]*(N+1)
ans = []
for i in range(N, 0, -1):
    c = 0
    for j in range(2*i-1, N, i):
        if C[j]:
            c += 1
    if c % 2 != A[i-1]:
        ans.append(i)
        C[i-1] = 1
ans.reverse()
print(len(ans))
if ans:
    print(*ans)

Solution (Python):
def main():
    n = int(input())
    A = [0] + list(map(int, input().rstrip().split()))
    for i in range(n // 2, 0, -1):  
        A[i] = sum(A[i::i]) % 2
    ans = [i for i, j in enumerate(A) if j]
    print(len(ans))  
    print(*ans)


if __name__ == "__main__":
    main()

Solution (Python):

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



NumValid = [True] * (N+1)
ans = []
NumAns = [0] * (N+1)


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

Solution (Python):
import math
N = int(input())
a_array = list(map(int,input().split()))
ans_array = [] 
now_ball_array = [0] * N

for i in range(N-1,-1,-1):
    if a_array[i] != now_ball_array[i]:
        ans_array.append(str(i+1))
        box_root = math.ceil(math.sqrt(i+1))
        if box_root * box_root == (i+1):
            now_ball_array[box_root-1] = (now_ball_array[box_root-1] + 1) % 2  
        for j in range(1,box_root):
            if (i+1) % j == 0:
                now_ball_array[j-1] = (now_ball_array[j-1] + 1) % 2 
                now_ball_array[(i+1)//j-1] = (now_ball_array[(i+1)//j-1] + 1) % 2  
    
print(len(ans_array))
if len(ans_array):
    print(" ".join(ans_array))

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

d = c + a

for i in range(N, 0, -1):
    s = 0
    for j in range(2 * i, N + 1, i):
        s ^= b[j]

    b[i] = (s ^ d[i])


print(b.count(1) if b.count(1) else 0)
for i in range(1, len(b)):
    if b[i] != 0:
        print(i, end=' ')

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

d = c + a

for i in range(N, 0, -1):
    s = 0
    for j in range(2 * i, N + 1, i):
        s ^= b[j]

    b[i] = (s ^ d[i])


print(b.count(1) if b.count(1) else 0)
if len(b):
    for i in range(1, len(b)):
        if b[i] != 0:
            print(i, end=' ')
else:
    print(0)

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

for i in range(1,n+1)[::-1]:
    ball_sum = sum(balls[i::i]) % 2
    if ball_sum ^ a[i]:
        balls[i] = 1

print(sum(balls))
ball_list = [str(k) for k, v in enumerate(balls) if v == 1 ]
print(" ".join(ball_list))

Solution (Python):
n = int(input())
A = list(map(int, input().split()))
cnt = 0
res = []
for i in range(n - 1, -1, -1):
    c = i + 1
    if (A[i] % 2 == 1):
        cnt += 1
        res.append(c)
        for k in range(1, int(c ** 0.5) + 1):
            if (c % k == 0):
                if (k != c // k):
                    A[k - 1] -= 1
                    A[c // k - 1] -= 1
                else:
                    A[k - 1] -= 1
print(cnt)
print(*res)

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

for i in range(N, 0, -1):
    x = 0
    for j in range(i, N+1, i):
        x ^= a[j]

    a[i] = x

ans = []
for i, ai in enumerate(a):
    if ai == 1:
        ans.append(i)

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

Solution (Python):
a = int(input())
b = list(map(int, input().split()))
c = [0] * a
d = 0
e = []
for i in range(a, 0, -1):
    d = 0
    for j in range(i, a+1, i):
        d += c[j-1]
    if d % 2 != b[i-1]:
        c[i-1] = 1
        d += 1
        e.append(i)
print(d)
if d == 1:
    print(e[0])
elif d > 1:
    print(" ".join(map(str, e)))

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

A = [None] + A
B = [None] + [0] * N

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

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

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


for i in range(N-1, -1, -1):
    for j in [0, 1]:
        b[i] = j
        if sum(b[i::i+1]) % 2 == a[i]:
            break
    else:
        print("-1")
        exit()

M = sum(b)
print(M)

for index, value in enumerate(b):
    if value == 1:
        c.append(index + 1)

ans = ' '.join(map(str, c))
print(ans)

Solution (Python):






N = int(input())
a = [int(_) for _ in input().split()]
b = set()
out = []
n = 0
for i in range(N-1, -1, -1):
    if a[i] == 1:
        out.append(i + 1)
        n += 1
        
        for f in range(1, int((i+1)**0.5)+1):
            if (i+1)%f == 0:
                a[f-1] = 0 if a[f-1] == 1 else 1
                if f != (i+1)//f and f != 1:
                    a[(i+1)//f-1] = 0 if a[(i+1)//f-1] == 1 else 1
    
print(n)

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

Solution (Python):





def solve():
  
  N = int(input())
  An = [0] + list(map(int, input().split()))

  
  Retn = [0 for _ in range(N+1)]
  for i in range(N,0,-1):
    mul = 2
    while i*mul <= N:
      An[i] = An[i]+An[i*mul]
      mul += 1
    An[i] = An[i]%2
  
  M = An.count(1)
  print(M)
  for i,a in enumerate(An):
    if a==1:
      print(i)

solve()

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




As = [-1] + As
Bs = [0 for _ in range(N+1)]


for i in reversed(range(1,N+1)):
	tmpS = 0
	
	for j in range(2*i,N+1,i):
		tmpS += Bs[j]
		
	
	
	if tmpS % 2 != As[i]:
		Bs[i] = 1

anss = []

for i in range(N+1):
	if Bs[i] == 1:
		anss.append(str(i))
		
print(len(anss))
print(" ".join(anss))

Solution (Python):

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

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

temp = [0]*N
for i in range(N-1,-1,-1):
  for j in [0,1]:
    temp[i] = j
    if sum(temp[i::i+1])%2 == A[i]:
      break
  else:
    print(-1)
    exit()
print(sum(temp)) 
anslist = []
for i in range(N):
  if temp[i] == 1:
    anslist.append(i+1)
if anslist == []:
  exit()
else:
  print(*anslist)
  exit()

Solution (Python):
import sys

N = int(input())

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

b = [0] * (N+1)

num = 0

for i in range(N, 0, -1):
    sum = 0
    for j in range(i+i, N+1, i):
        if j < len(a):
            sum ^= b[j]
        else:
            break

    b[i] = sum ^ a[i]
    if b[i] == 1:
        num += 1

print(num)

if num == 0 or num == -1:
    sys.exit(0)

flag = False

for i in range(1, N+1):
    if b[i] == 1:
        if flag == True:
            print(" ", end="")
        print(i, end="")
        flag = True

print("")

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

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

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

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

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

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

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

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

Solution (Python):
import sys, math, itertools, bisect, copy, re
from collections import Counter, deque, defaultdict






INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)









def divisor_list(n):
    ret = set()
    i = 1
    while i * i <= n:
        if n % i == 0:
            ret.add(i)
            ret.add(n // i)
        i += 1
    return ret


N = int(input())
tmp = [int(x) for x in input().split()]
A = [-999]
for a in tmp:
    A.append(a)

B = []

for i in range(N, 0, -1):
    
    if A[i] == 1:
        B.append(str(i))
        DL = divisor_list(i)
        for j in DL:
            A[j] = (A[j] + 1) % 2

print(len(B))
print(" ".join(B))

pass

Solution (Python):
N=int(input())
a=list(map(int, input().split()))
n=N//2
b=[None]*N
for i in range(n,N):
        b[i]=a[i]
for i in range(n-1,-1,-1):
        c=0
        t=2*i+1
        while t<N:
                if b[t]==1:
                        c+=1
                t+=(i+1)
        b[i]=(c+a[i])%2
print(b.count(1))
for i in range(N):
        if b[i]==1:
                print(i+1,end=" ")

Solution (Python):

n = int(input())

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





ans = [0]*(n+1)

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

    ta = sum(ans[i::i])
    ans[i] = 0 if ta%2 == an[i-1] else 1




m = sum(ans)
print(m)

if m > 0:
    print(*[i for i, x in enumerate(ans) if x >0])

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

nums = []
memo = [0] * N
for i in range(N - 1, -1, -1):
    if A[i] != sum(memo[i :: i + 1]) % 2:
        memo[i] = 1
        nums.append(i + 1)
        
print(sum(memo))
print(' '.join(map(str, nums)))

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

Solution (Python):


def main():
    n = int(input())
    A = [0] + list(map(int, input().rstrip().split()))
    ans = []  
    ans_append = ans.append
    for i in range(n, 0, -1):
        A[i] = sum(A[i::i]) % 2
        if A[i]:
            ans_append(i)
    print(len(ans))
    print(*ans)


if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
a=[int(x) for x in input().split()]
for i in range(n,0,-1):
    a[i-1] = sum(a[i-1::i])%2
print(sum(a))
print(' '.join([str(i+1) for i,j in enumerate(a) if j == 1]))

Solution (Python):


def main():
    n = int(input())
    A = [0] + list(map(int, input().rstrip().split()))
    for i in range(n // 2, 0, -1):  
        A[i] = sum(A[i::i]) % 2
    ans = [i for i, j in enumerate(A) if j]
    print(len(ans))  
    print(*ans)


if __name__ == "__main__":
    main()

Solution (Python):

def main():
    n = int(input())
    A = [0] + list(map(int, input().rstrip().split()))
    B = [0] * (n + 1)
    for i in range(n, 0, -1):
        cnt, p = 0, 2
        while i * p <= n:
            cnt += B[i * p]
            p += 1
        if cnt % 2 != A[i]:
            B[i] += 1
    total = sum(B)
    if total == 0:
        print(0)
    else:
        print(total)
        print(*(i for i, j in enumerate(B[1:], start=1) if j == 1))


if __name__ == "__main__":
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
n=int(input())
aa=list(map(int,input().split()))
bb=[0]*len(aa)
for i in range(n):
    j = n-i-1
    s = sum(bb[j::j+1])
    if s % 2 != aa[j]:
       bb[j] = 1
print(sum(bb))
print(' '.join(str(i+1) for i in range(len(bb)) if bb[i]))

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

ret = [0] * N

for i in range(N-1, -1, -1) :
    s = a[i]
    for j in range(i, N, i + 1) :
        s ^= ret[j]
    ret[i] = s
    
b = []
for i in range(N) :
    if ret[i] :
        b.append(i+1)

print(len(b))
print(' '.join([str(i) for i in b]))

Solution (Python):
import sys
input = sys.stdin.readline
 
n = int(input())
num_list = [ int(v) for v in input().split() ]
ans_list = [ 0 ] * n
for i in range(n-1,-1,-1):
 
    if sum(ans_list[i::i+1]) % 2 == num_list[i]:
        ans_list[i] = 0
    else:
        ans_list[i] = 1
 
print(sum(ans_list))
for i in range(n):
 
    if ans_list[i] == 1:
        print(i+1)

Solution (Python):
N = int(input())

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

B = [0] * (N+1)

for i in range(N, 0, -1):
    
    x = 2
    _sum = 0
    for j in range(i+i, N+1, i):    
        _sum ^= B[j]

    B[i] = _sum ^ A[i-1]

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

if ans:
    print(len(ans))
    print(' '.join(map(str, ans)))
else:
    print(0)

Solution (Python):
N = int(input())
arr = list(map(int, input().split()))
ans_list = [0] * (N)
ans = []
for i in range(N):
    summ = 0
    j = N - i
    while j < N:
        j = j + N - i
        if j - 1 < N:
            summ += ans_list[j-1]
    if (summ % 2) != arr[N - i - 1]:
        ans_list[N - i - 1] = 1
        ans.append(N - i)

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

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

Solution (Python):
def d_preparing_boxes(N, A):
    boxes = [0] * (N + 1)
    result = []

    for i in range(N, 0, -1):
        
        total = 0
        for j in range(1, N // i):
            total += boxes[(j + 1) * i]
        
        if total % 2 != A[i - 1]:
            boxes[i] = 1
            result.append(i)
    return '\n'.join(map(str, [len(result)] + result)) if len(result) != 0 else 0

N = int(input())
A = [int(i) for i in input().split()]
print(d_preparing_boxes(N, A))

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

M = [0 for _ in range(N)]
for i in range(N-1, -1, -1):
    total = 0
    n = 2
    while (i+1) * n <= N:
        total += M[(i+1)*n-1]
        n += 1

    if total % 2 == A[i]:
        M[i] = 0
    else:
        M[i] = 1


print(sum(M))

kugiri = False
for i in range(len(M)):
    if M[i] == 1:
        if kugiri:
            print(" ", end="")
        print(i+1, end="")
        kugiri = True
print()

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

for i in range(n//2, 0, -1):
  if(a[i-1] != sum(b[i-1::i])%2):
    b[i-1] = 1 - a[i-1]
print(sum(b))
print(*(i+1 for i, x in enumerate(b) if x))

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

idxs = [i for i in range(N,0,-1)]
box=[0 for _ in range(N)]

for idx in idxs:
    div = [(i+1)*idx for i in range(N//idx)]
    sum_=sum([box[c-1] for c in div])
    if sum_ % 2 != l[idx-1]:
        box[idx-1] = 1
    
print(sum(box))
for i, v in enumerate(box):
    if v==1:
        print(i+1, end=' ')

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

if set(a) <= {0,1}:
    for i in range(N//2, -1, -1):
        ball_sum = sum(b[i::i+1])
        if ball_sum % 2 == a[i]:
            continue
        else:
            b[i] = int(not(b[i]))
        
    print(sum(b))
    for j in range(N-1, -1, -1):
        if b[j]: print(j+1)

else: print(-1)

Solution (Python):
N,*A=map(int,open(0).read().split())
for n in range(N):A[N-n-1]=sum(A[N-n-1::N-n])%2
print(sum(A),'\n',*(i+1 for i,x in enumerate(A) if x))

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

    for i in range(N):
        A[N - i] = sum(A[N - i :: N - i]) % 2

    print(sum(A))
    print(*(i for i, v in enumerate(A) if v))

    return


if __name__ == "__main__":
    main()

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

lst = [0]*N
for i in range(N, 0, -1):
    tmp = 0
    for j in range(i-1, N, i):
        tmp += lst[j]
    if A[i-1]!=tmp%2:
        lst[i-1]=1
print(sum(lst))
for idx, e in enumerate(lst):
    if e==1:
        print(idx+1, end= ' ')

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

for i in range(N//2, -1, -1):
    ball_sum = sum(b[i::i+1])
    if ball_sum % 2 == a[i]:
        continue
    else:
        b[i] = int(not(b[i]))

print(sum(b))
for j in range(N-1, -1, -1):
    if b[j]: print(j+1)

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

j = 0
while i>0:
    sum1=0
    j = i + i
    while j<=N:
        sum1 += B[j-1]
        sum1=(sum1+2)%2
        j=j+i
    B[i-1]+=(A[i-1]+sum1)
    B[i-1]=(B[i-1]+2)%2
    i=i-1
count=0
for s in B:
  if s == 1 :
    count+=1
print(count)
for i in range(N):
  if B[i]==1:
    print(i+1,end=" ")

Solution (Python):

import sys
input = sys.stdin.readline

n = int(input())
num_list = [ int(v) for v in input().split() ]
ans_list = [ 0 ] * n

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

    if sum(ans_list[i::i+1]) % 2 == num_list[i]:
        ans_list[i] = 0
    else:
        ans_list[i] = 1

print(sum(ans_list))
for i in range(n):

    if ans_list[i] == 1:
        print(i+1)

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

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

for i in range(N):
    base = N - 1 - i
    for j in range(base, N, base+1):
        if j == base:
            ans[i] += A[j]
        else:
            ans[i] -= ans[N - 1 - j]
        ans[i] = ans[i] % 2
        if ans[i] < 0:
            print('-1')
            break

else:
    ans_ids = [str(i+1) for i, a in enumerate(reversed(ans)) if a % 2 == 1]
    print(len(ans_ids))
    print(' '.join(ans_ids))

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

Solution (Python):
N=int(input())
A=[Ai for Ai in map(int,input().split())]
B=[]
for i in range (N//2+1,N+1):
    if A[i-1]==1:
        B.append(i)

for i in range (1, N//2+1)[::-1]:
    A[i-1]=sum(A[i-1::i])%2
    if A[i-1]==1:
        B.append(i)

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

Solution (Python):
import math

N=int(input())
a=list(map(int, input().split()))
H=math.floor(N / 2)
B=a[:]

for i in range(H-1,-1,-1):
    s = 0
    j = i
    j+=(i+1)
    while j < N:
        s+=B[j]
        j+=(i+1)
    m = s % 2
    B[i] = a[i] ^ m

ans = [i + 1 for i, x in enumerate(B) if x == 1]
l = len(ans)
print(l)
if (l > 0):
    print(*ans)

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

hako = [0] * (N+1)

for i in range(1,N+1)[::-1]:
    count = 0
    for j in range(i,N+1,i):
        if j%i == 0:
            count += hako[j]

    if count % 2 == a[i-1]:
        hako[i] = 0
    else:
        hako[i] = 1

print(sum(hako))

if sum(hako):
    ans = []
    for i, bin in enumerate(hako):
        if bin:
            ans.append(i)
    print(*ans)

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

hako = [0] * (N+1)

for i in range(1,N+1)[::-1]:
    if i > N / 2:
        if a[i-1] == 1:
            hako[i] = a[i-1]
    else:
        count = 0
        for j in range(i,N+1,i):
            if j%i == 0:
                count += hako[j]

        if count % 2 == a[i-1]:
            hako[i] = 0
        else:
            hako[i] = 1

print(sum(hako))

if sum(hako):
    ans = []
    for i, bin in enumerate(hako):
        if bin:
            ans.append(i)
    print(*ans)

Solution (Python):
import math

N=int(input())
a=list(map(int, input().split()))
B=a[:]

for i in range(N-1,-1,-1):
    s = 0
    j = i
    j+=(i+1)
    while j < N:
        s+=B[j]
        j+=(i+1)
    m = s % 2
    B[i] = a[i] ^ m

ans = [i + 1 for i, x in enumerate(B) if x == 1]
l = len(ans)
print(l)
if (l > 0):
    print(*ans)