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.



Sample input:
3
1 0 0


Sample output:
1
1

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 5 + 10)

import math



def main():
    num = int(input())
    data = list(map(int, input().split()))

    ans_data = [-1 for i in range(num + 1)]
    # count = 0
    for i in range(1, num + 1)[::-1]:
        count = 0
        ind = i * 2
        while ind <= num:
            if ans_data[ind]:
                count ^= 1
            ind += i
        # print('ind', i, data[i - 1], count)
        ans_data[i] = data[i - 1] ^ count

    count = 0
    for i in range(1, num + 1):
        if ans_data[i]:
            count += 1

    print(count)

    for i in range(1, num + 1):
        if ans_data[i]:
            print(i)




if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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

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

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().strip().split(' ')))
A=[0]+A
dp=[0]*len(A)
dp[N]=A[N]
for i in range(N-1,0,-1):
    temp=0
    for j in range(2,len(A)):
        if i*j>=len(A):
            break
        temp+=dp[j*i]
    #temp+dp[i] = A[i] mod 2
    dp[i]=(A[i]-temp)%2
ans=sum(dp[1:])
want=[]
for i in range(len(dp)):
    if dp[i]>0:
        want+=[i]

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

#print(dp[1:])

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N = inp()
aa = inpl()


n = N
ans = [0]*(N+1)
cnts = [0]*(N+1)

for a in reversed(aa):
    #print(a,n,cnts,ans)
    if cnts[n]%2 == a:
        ans[n] = 0
    else:
        ans[n] = 1
        r = 1
        while r <= math.sqrt(n):
            if n%r == 0:
                cnts[r] += 1
                if r != n//r:
                    cnts[n//r] += 1
            r += 1
    n -= 1


tmp = sum(ans)
if tmp == 0:
    print(0)
else:
    print(tmp)
    fans = []
    for i,x in enumerate(ans):
        if x == 1:
            fans.append(str(i))
    print(' '.join(fans))

Submission status: Accepted

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

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

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

print(ans)
print(*box)

Submission status: Accepted

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

isBalls = [0] * (N+1)
for k in reversed(range(1, N+1)):
    num = sum([isBalls[k*i] for i in range(1, N//k+1)])
    if num % 2 != As[k-1]:
        isBalls[k] = 1

M = sum(isBalls)
anss = [i for i in range(1, N+1) if isBalls[i] > 0]

print(M)
print(' '.join(map(str, anss)))

Submission status: Accepted

Solution code:
n = int(input())
alist = list(map(int, input().split()))
boxList = [0] * (n + 1)

m = 0
resultList = []

for i in range(1, n+1)[::-1]:
    sums = 0
    for j in range(1, n // i):
        sums += boxList[(j+1) * i]
    if sums % 2 != alist[i - 1]:
        boxList[i] = 1
        m+= 1
        resultList.append(i)

print(m)
if m != 0:
    print(' '.join(map(str, resultList)))

Submission status: Accepted

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

ANS=[0]*(N+1)

for i in range(N,0,-1):
    SUM=0
    for j in range(i*2,N+1,i):
        SUM=(SUM+ANS[j])%2

    ANS[i]=(A[i]-SUM)%2

if min(ANS)<0 or max(ANS)>1:
    print(-1)
else:
    ANS2=[i for i in range(N+1) if ANS[i]==1]
    print(len(ANS2))
    print(*ANS2)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n = int(input())
a = [int(i) for i in readline().split()]

ans = [0]*n

for i in range(n-1,-1,-1):
    ai = a[i]
    j = i+1
    while i < n:
        if ans[i]: ai ^= 1
        i += j
    ans[j-1] = ai

#print(ans)

res = [i+1 for i,c in enumerate(ans) if c]

print(len(res))
print(*res)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    print(3*n**2)
    return

#B
def B():
    n,d = LI()
    f = [1]*(n+2*d+2)
    ans = 0
    for i in range(n):
        if f[i]:
            for j in range(i,i+2*d+1):
                f[j] = 0
            ans += 1
    print(ans)
    return

#C
def C():
    n = I()
    a = IR(n)
    mi = max(a)
    if a.count(mi) > 1:
        for i in range(n):
            print(mi)
    else:
        b = [a[i] for i in range(n)]
        b.sort()
        b = b[::-1]
        for i in range(n):
            if mi != a[i]:
                print(mi)
            else:
                print(b[1])

    return

#D
def D():
    n = I()
    a = LI()
    b = [0]*(n+1)
    for i in range(1,n+1)[::-1]:
        j = 2*i
        k = 0
        while j <= n:
            k ^= b[j]
            j += i
        if a[i-1]^k:
            b[i] = 1
    ans = []
    for i in range(n+1):
        if b[i]:
            ans.append(i)
    print(len(ans))
    if ans:
        print(*ans)
    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    D()

Submission status: Accepted

Solution code:
def div(val):
  ret=[]
  for i in range(1,int(val**0.5)+1):
    if val%i==0:
      ret.append(i)
      if val//i!=i:
        ret.append(val//i)
  return ret

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

Submission status: Accepted

Solution code:
n = int(input())
arr = list(map(int, input().split()))

res = [0] * (n + 1)

for i in range(1, n + 1)[::-1]:
    sum_res = sum(res[x] for x in range(i, n + 1, i))
    if sum_res % 2 != arr[i - 1]:
        res[i] = 1

print(sum(res))

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

Submission status: Accepted

Solution code:
def main():
    n = input()
    aa = map(int, raw_input().split())
    ans = [0] * n
    m = 0
    for i in xrange((n + 1) // 2, n):
        if aa[i] == 1:
            ans[i] = 1
            m += 1
    for i in xrange((n + 1) // 2 - 1, -1, -1):
        s = sum(ans[i::i + 1]) % 2
        if aa[i] != s:
            ans[i] = 1
            m += 1
    print m
    for i, a in enumerate(ans, 1):
        if a:
            print i


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
A=tuple(map(int,input().split()))
B=[0]*n
for i in reversed(range(n//2,n)):
    B[i]=A[i]
for i in reversed(range(n//2)):
    k=i+1
    l=n//k
    tmp=0
    for j in range(2,l+1):
        idx=k*j-1
        tmp+=B[idx]
    B[i]=(tmp%2-A[i])%2
s=0
Ans=[]
for i,b in enumerate(B):
    if b:
        s+=1
        Ans.append(i+1)
print(s)
print(*Ans)

Submission status: Accepted

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

b = [0 for _ in range(N + 1)]
M = 0
for i in range(N, 0, -1):
    x = a[i - 1]
    for j in range(i, N + 1, i):
        x += b[j]
    x = x % 2
    b[i] = x
    M += x
print(M)
for i in range(1, N + 1):
    if b[i] == 1:
        print(i)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(a) for a in input().split()]

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

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

Submission status: Accepted

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

ans = [0] * N

for i in range(N, 0, -1):
  t = 0
  for j in range(i + i, N + 1, i):
    t += ans[j - 1]
  k = t % 2
  if a[i - 1] != k:
    ans[i - 1] = 1

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

print(su)
if len(L) != 0:
  print(" ".join(map(str, L)))

Submission status: Accepted

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

dp = [None]*(N+1)
for i in range(N, 0, -1):
    a = A[i]
    for j in range(2*i, N+1, i):
        a -= dp[j]
    dp[i] = (a % 2)
dp = dp[1:]
print(sum(dp))
for i in range(N):
    if dp[i]:
        print(i+1)

Submission status: Accepted

Solution code:
N = int(input())
a_list = list(map(int, input().split()))
res_list = [0] * N

for i in range(N - 1, -1, -1):
    r = sum(res_list[i::(i + 1)])
    if (r - a_list[i]) % 2 != 0:
        res_list[i] = 1

S = sum(res_list)
print(S)

if S != 0:
    print(" ".join([str(i+1) for i in range(N) if res_list[i] == 1]))

Submission status: Accepted

Solution code:
import sys


fin = sys.stdin.readline
N = int(fin())
a_list = [int(elem) for elem in fin().split()]
is_ball_in = [False] * N
for i in reversed(range(1, N + 1)):
    num_balls = 0
    for j in range(i, N + 1, i):
        num_balls += is_ball_in[j - 1]
    num_balls %= 2
    a = a_list[i - 1]
    if num_balls != a:
        is_ball_in[i - 1] = True
    else:
        is_ball_in[i - 1] = False

num_boxes_with_a_ball = sum(is_ball_in)
print(num_boxes_with_a_ball)
indices = [i for i, b in enumerate(is_ball_in, start=1) if b]
print(*indices)

Submission status: Accepted

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

ans = [0]*N
for i in reversed(range(1,N+1)):
    v = A[i-1]
    for j in range(i,N+1,i):
        v += ans[j-1]
    ans[i-1] = v % 2

M = sum(ans)
print(M)
if M:
    print(*(i+1 for i,b in enumerate(ans) if b == 1))

Submission status: Accepted

Solution code:
from collections import *
import sys
inp = raw_input

def err(s):
    sys.stderr.write('{}\n'.format(s))

def ni():
    return int(inp())

def nl():
    return [int(_) for _ in inp().split()]

N = ni()
A = nl()

out = [0]*N
fail = False
B = []
for i in range(N-1, -1, -1):
    j = i + 1
    S = 0
    for k in range(i, N, j):
        S += out[k]
    if S%2 != A[i]:
        out[i] = 1
        B.append(j)
print(len(B))
if len(B):
    print(' '.join(map(str, B)))

Submission status: Accepted

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N=int(input())
a=list(map(int,input().split()))
box=[0]*N
for i in range(N, 0,-1):
    sm = 0
    for j in range(i, N+1, i):
        sm += box[j-1]
    print(i, sm)
    box[i-1] = (sm % 2) ^ a[i-1]
print(sum(box))
print(*sum)

Submission status: Runtime Error

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

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

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

print(S)
if S>0:
  
  print(t)

Submission status: Runtime Error

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

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

for j in range(N//2,-1,-1):
  cnt = 0
  for k in res:
    if k%j == 0:
      cnt += 1
  if A[j] == 1 and cnt%2 == 0:
    res.append(j)
  elif A[j] == 0 and cnt%2 == 1:
    res.append(j)
  
res.sort()
print(*res)

Submission status: Runtime Error

Solution code:
import sys
import math

n = int(input())
a = list(map(int, input().split()))
sosu = a[:]

for i in range(2, n//2):
  for j in range(2,n):
    if i*j > n:
      break
    else:
      sosu.remove(i*j) 

m = 0

for i in sosu:
  if i > n/2:
    m = sosu.index(i)
    break

del sosu[:(m-1)]

newa = [i for i in a if i not in sosu]

for i in newa:
  if i != newa[0]:
    print('-1')
    sys.exit()

num = [str(i+1) for i, x in enumerate(a) if x == 1]

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

Submission status: Runtime Error

Solution code:
n = int(input())
al = list(map(int, input().split()))
boxs = []
cnts = [0]*(n+1)
for i in range(n,0,-1):
    if cnts[i]%2 != al[i-1]:
        boxs.append(i)
        for j in range(1, int(i**0.5)+1):
            if i%j == 0:
                cnts[j] += 1
                if j*j != i: cnts[i//j] += 1
    print(i, boxs, cnts)


print(len(boxs))
for b in boxs: print(b)

Submission status: Runtime Error

Solution code:
import sympy

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

ans = []
for i in range(N)[::-1]:
    if A[i] % 2 == 1:
        ans.append(i+1)
        for j in sympy.divisors(i+1)[:-1]:
            A[j-1] += 1

print(len(ans))
if ans:
    print(" ".join([str(_) for _ in ans]))

Submission status: Runtime Error

Solution code:
import sys

N = int(sys.stdin.readline())
D = list(map(int, sys.stdin.readline().split()))

times = [0] * 24
for d in D:
    times[d] += 1

if max(times) > 2 or times[0] == 2 or times[12] == 2:
    print(0)
else:
    ans = 0
    # 1 - 11時間の時差の場合、Diと24 - Diの両方を試す
    for i in range(2**11):
        positions = []
        if times[0] == 1:
            positions.append(0)
        for j in range(11):
            if times[j+1] == 2:
                positions.append(j+1)
                positions.append(24 - j-1)
            elif times[j+1] == 1:
                if (i >> j) & 1:
                    positions.append(24 - j-1)
                else:
                    positions.append(j+1)
        if times[12] == 1:
            positions.append(12)
        positions.sort()
        # print(positions)
        lp = len(positions)
        d = float("inf")
        for p in range(lp):
            # 0をまたぐ場合がある
            if p == lp -1:
                diff = 24 - positions[p] + positions[0]
            else:
                diff = positions[p+1] - positions[p]
            d = min(d, diff if diff != 24 else 0)
        ans = max(ans, d)

print(ans)

Submission status: Runtime Error

Solution code:
import sympy
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

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

res = [0]*n
cnts = [0]*n
for i in reversed(range(n)):
    if aas[i] == 0:
        if cnts[i]%2 != 0:
            res[i] = 1
            #for j in make_divisors(i+1):
            for j in list(sympy.divisors(i+1)):
                cnts[j-1] += 1
    else:
        if cnts[i]%2 == 0:
            res[i] = 1
            #for j in make_divisors(i+1):
            for j in list(sympy.divisors(i+1)):
                cnts[j-1] += 1

res_tmp = sum(res)
print(res_tmp)
if res_tmp:
    res_tmp = ""
    for i in range(n):
        if res[i] == 1:
            res_tmp += str(i+1) + " "
    print(res_tmp[:-1])

Submission status: Runtime Error

Solution code:
import sympy
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

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

res = [0]*n
cnts = [0]*n
for i in reversed(range(n)):
    if aas[i] == 0:
        if cnts[i]%2 != 0:
            res[i] = 1
            #for j in make_divisors(i+1):
            for j in sympy.divisors(i+1):
                cnts[j-1] += 1
    else:
        if cnts[i]%2 == 0:
            res[i] = 1
            #for j in make_divisors(i+1):
            for j in sympy.divisors(i+1):
                cnts[j-1] += 1

res_tmp = sum(res)
print(res_tmp)
if res_tmp:
    res_tmp = ""
    for i in range(n):
        if res[i] == 1:
            res_tmp += str(i+1) + " "
    print(res_tmp[:-1])

Submission status: Runtime Error

Solution code:
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

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

res = [0]*n
cnts = [0]*n
for i in reversed(range(n)):
    if aas[i] == 0:
        if cnts[i]%2 != 0:
            res[i] = 1
    else:
        if cnts[i]%2 == 0:
            res[i] = 1
            for j in make_divisors(i+1):
                cnts[j] += 1

res_tmp = sum(res)
print(res_tmp)
if res_tmp:
    res_tmp = ""
    for i in range(n):
        if res[i] == 1:
            res_tmp += str(i+1) + " "
    print(res_tmp[:-1])

Submission status: Runtime Error

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

with open('testcase_12.in') as f:
    n = int(f.readline())
    a = list(map(int, f.readline().split()))

b = [-1] * n
for i in range(n, 0, -1):
    cnt = sum(b[j - 1] for j in range(i + i, n + 1, i))
    b[i - 1] = int(a[i - 1] != cnt % 2)

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

Submission status: Runtime Error

Solution code:

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

ans = [-1 for _ in range(N)]

count = 0
for i in range(N, 0, -1):
    tmp_sum = 0
    if N % i == 0 and N // i > 1:
        multi_max = N // i
        c = 1
        while multi_max > c:
            c += 1
            tmp_sum += ans[c * i - 1]

    # print(i, tmp_sum)
    if A[i-1] == 1:
        if tmp_sum % 2 == 0:
            count += 1
            ans[i-1] = 1
        else:
            ans[i-1] = 0
    else:
        if tmp_sum % 2 == 0:
            ans[i-1] = 0
        else:
            count += 1
            ans[i-1] = 1

print(count)
if count:
    print(" ".join(["1"] * count))

Submission status: Runtime Error

Solution code:
import sympy

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

cnt = [0]*200010

b = []

for i in reversed(range(n)):

	num = i + 1
	if cnt[num]%2 != a[num-1]:
		b.append(num)
		divs = sympy.divisors(num)

		for div in divs:
			cnt[div] += 1

print(len(b))
b.sort()

for i in b:
	print(str(i)+' ',end='')

print()

Submission status: Runtime Error

Solution code:
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    M = 0
    ret_M = []
    memo_N = [-1]*N # memo: 倍数を足したときに2で割った余り
    for i in range(N)[::-1]:
        i_ = i+1
        q = N//i_
        
        if q == 1:
            memo_N[i] = A[i]
            if A[i] == 1:
                M += 1
                ret_M.append(i_)
        else:
            memo_N[i] = memo_N[i_*2]^A[i]
            if memo_N[i]:
                M += 1
                ret_M.append(i_)
                
    print(M)
    if M: print(' '.join(map(str, ret_M[::-1])))
      
solve()

Submission status: Runtime Error

Solution code:
x = int(input())
l = set([])
i = 1
while i < x:
    j = 2
    while j < 10:
        if i**j <= x:
            l.add(i**j)
        j += 1
    i += 1

print(max(l))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    N,=pin()
    A=lispin()
    cnt=[0]*N
    ans=set()#1個入れるものを書く
    hurui=list(range(2,450))
    for i in range(2,25):
        temp=[]
        t=hurui[0]
        for j in hurui:
            if j==t or j%t!=0:
                temp.append(j)
        hurui=temp
    #print(hurui)
    for i in range(N-1,-1,-1):
        
        if A[i]!=cnt[i]:
            ans.add(i+1)
            temp=i+1
            ok=0
            cond=0
            for j in range(N):
                if temp==1 or cond==1:
                    break
                cond=1
                for x in range(ok,int(temp**0.5)+2):
                    k=hurui[x]
                    if temp%k==0:                        
                        temp//=k
                        cond=0
                        cnt[temp-1]+=1
                        cnt[temp-1]%=2
                        ok=x
                        break
        #print(cnt,i+1)
    print(len(ans))
        
    if len(ans)>0:print(*sorted(ans))
#%%submit!
resolve()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    N,=pin()
    A=lispin()
    cnt=[0]*N
    ans=set()#1個入れるものを書く
    hurui=list(range(2,450))
    for i in range(2,25):
        temp=[]
        t=hurui[0]
        for j in hurui:
            if j==t or j%t!=0:
                temp.append(j)
        hurui=temp
    #print(hurui)
    for i in range(N-1,-1,-1):
        
        if A[i]!=cnt[i]:
            ans.add(i+1)
            temp=i+1
            ok=0
            cond=0
            for j in range(N):
                if temp==1 or cond==1:
                    break
                cond=1
                for x in range(ok,int(temp**0.5)+2):
                    k=hurui[x]
                    if temp%k==0:                        
                        temp//=k
                        cond=0
                        cnt[temp-1]+=1
                        cnt[temp-1]%=2
                        ok=x
                        break
        #print(cnt,i+1)
    print(len(ans))
        
    if len(ans)>0:print(*sorted(ans))
#%%submit!
resolve()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def main():
    n = int(input())
    A = list(map(int, input().split()))
    B = [0] * n
    ans = []
    for i, a in enumerate(A[::-1]):
        i = n - i
        b = sum(B[i - 1::i])
        if b % 2 != a:
            ans.append(str(i))
            B[i] = 1
    print(len(ans))
    print(' '.join(ans))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
    n = int(input())
    A = list(map(int, input().split()))
    B = [0] * n
    ans = []
    for i, a in enumerate(A[::-1]):
        i = n - i
        b = sum(B[i::i])
        if b % 2 != a:
            ans.append(str(i))
            B[i] = 1
    print(len(ans))
    print(' '.join(ans))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))
div_list = [] * N
ans_list = np.zeros(N).astype(int)
N_2 = N // 2
for i in range(N):
    tmp = N - i - 1
    # print(tmp)
    if i < N_2:
        ans_list[tmp] = A[tmp]
    else:
        ans_list[tmp] = (np.sum(ans_list[tmp::i]) + A[tmp]) % 2

print(np.sum(ans_list))
for i in range(N):
    if ans_list[i] == 1:
        print(ans_list[i], end="")

Submission status: Runtime Error

Solution code:
3
1 0 0

Submission status: Runtime Error

Solution code:
n = int(input())
A = list(map(int, input().split()))
b = []
for i in reversed(range(n)):
    if A[i]:
        num = i + 1
        b.append(num)
        tmp = 1
        while tmp * tmp <= num:
            if num % tmp == 0:
                A[num] ^= 1
                if tmp != num // tmp:
                    A[num//tmp]
            tmp += 1
print(len(b))
print(*b)

Submission status: Runtime Error

Solution code:
ef main():
    N = int(input())
    A = list(map(int, input().split()))
    A.insert(0, 1e10)
    ans = []
    B = [0] * len(A)
    for i in range(len(A)-1, 0, -1):
        idx = i
        s = 0
        while idx <= len(A) - 1:
            s += B[idx]
            idx += i

        if s % 2 != A[i]:
            ans.append(i)
            B[i] = 1

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


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
zn = int(input())
a = list(map(int, input().split()))
ans = [0] * n
m = 0
res = []
# 1 idx
for i in range(n, 0, -1):
    # i の倍数でbit立っているものの個数を数える
    cnt = 0
    idx = 2
    while i * idx <= n:
        if ans[i * idx - 1]:
            cnt += 1
        idx += 1
    debug = cnt
    if cnt % 2 != a[i - 1]:
        ans[i - 1] = 1
        m += 1
        res.append(i)
print(m)
if m:
    print(*res)

Submission status: Runtime Error

Solution code:
def main():
    n, *a = map(int, open(0).read().split())
    m = [0] * (n + 1)
    res = []
    for i in range(n, 0, -1):
        x = a[i - 1] % 2
        y = m[i] % 2
        if x != y:
            res.append(i)
            c = i // 2
            j = 1
            while j < c:
                if i % j == 0:
                    res[j] += 1
                j += 1

    m = len(res)
    print(m)
    if m == 1:
        print(res[0])
    elif m > 1:
        l = ' '.join(map(str, res))
        print(l[::-1])


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n, a = input(), input()
print(" ".join(["0"]*n))

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline

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

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

print(m)
for an in ans:
    if an > 0:
        print(an, end=' ')
print()