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: Runtime Error

Solution code:
N=int(input())
a=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!=a[i-1]:
        res[i] = 1

print(sum(res))

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

Submission status: Runtime Error

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

def main():
	N = int(input())
	a = list(map(int,input().split()))
	ball = []
	ballNum = 0
	f = [0]*N

	for i in reversed(range(1,N)):
		if (sum(f[0::i+1]) % 2) != (a[i] % 2):
			f[i] = 1
			ball.append(i+1)
			ballNum +=1

	if (sum(f) % 2) != (a[0] % 2):
		f[i] = 1
		ball.append(1)
		ballNum +=1

	print(ballNum)
	print(*ball)

if __name__ == "__main__":
	main()

Submission status: Runtime Error

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

def main():
	N = int(input())
	a = list(map(int,input().split()))
	ball = []
	ballNum = 0
	f = [0]*N

	for i in reversed(range(1,N)):
		if (sum(f[0::i]) % 2) != (a[i] % 2):
			f[i] = 1
			ball.append(i+1)
			ballNum +=1

	if (sum(f) % 2) != (a[0] % 2):
		f[i] = 1
		ball.append(1)
		ballNum +=1

	print(ballNum)
	print(*ball)

if __name__ == "__main__":
	main()

Submission status: Runtime Error

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

def main():
	N = int(input())
	a = list(map(int,input().split()))
	ball = []
	ballNum = 0
	f = [0]*N

	for i in reversed(range(1,N)):
		if (sum(f[0::i]) % 2) != (a[i] % 2):
			f[i] = 1
			ball.append(i+1)
			ballNum +=1

	if (sum(f) % 2) != (a[i] % 2):
		f[i] = 1
		ball.append(i+1)
		ballNum +=1

	print(ballNum)
	print(*ball)

if __name__ == "__main__":
	main()

Submission status: Runtime Error

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

def main():
	N = int(input())
	a = list(map(int,input().split()))
	ball = []
	ballNum = 0
	f = [0]*N

	for i in reversed(range(N)):
		if (sum(f[0::i]) % 2) != (a[i] % 2):
			f[i] = 1
			ball.append(i+1)
			ballNum +=1

	print(ballNum)
	print(*ball)

if __name__ == "__main__":
	main()

Submission status: Runtime Error

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

def main():
	N = int(input())
	a = list(map(int,input().split()))
	ball = []
	ballNum = 0
	f = [0*N]

	for i in reversed(range(N)):

		if (sum(filter(lambda x: x % (i+1) == 0, f)) % 2) != (a[i] % 2):
			f[i] = 1
			ball.append(i+1)
			ballNum +=1

	print(ballNum)
	print(*ball)

if __name__ == "__main__":
	main()

Submission status: Runtime Error

Solution code:
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())




N = int(input())
alist = list(map(int, input().split()))
ans_list = []

for i in range(N, 0, -1):
    if i > N//2:
        if alist[i-1]:
            ans_list.append(i)
    else:
        if sum(alist[i-1::i])%2 != alist[i-1]:
            ans_list.append(i)
print(len(ans_list))
if len(ans_list >0):
    print(*ans_list)

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!
import fractions
from functools import reduce



def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
    
def pin(type=int):
    return map(type,input().split())


N, =pin()
A = list(pin())#a1=A[0]
"""
#考察
i の倍数が書かれた箱に入っているボールの個数の和を 2 で割った「余り」が ai である。
ここで、Aの中身が全部0ならあまりが偶数なのだが実際の数も0を含む
そのため、”よい入れ方”を作るときには0のみとなるのが容易な答えとなる

逆に、Aの中身に1が混じっていることでその入れ方（何も入れない）ができなくなる
"""
"""
考察2
i=1 すべての箱に入っている個数の和を2で割ったあまり<=>int(M) % 2
I={A[I]=1|Iは自然数}と集合をていぎしたら…
a1=0なら2個、a1=1なら1個の玉をIの部分集合とその補集合についてのLCM（ただし。うまく互いに素になるように）を求めれば済ませられるのでは。
-1をつけなくて良い
"""
odd=[]
for i in range(1,N):
    if A[i]==1:
        odd.append(i+1)


#print(odd)
if (A[0] == 1):
    #A[1]=1とどうち LCM出力
    print(1)
    print(gcd_list(odd))
else:
    print(2)
    print(gcd_list(odd),200002)

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!
import math
from functools import reduce



def gcd_list(numbers):
    return reduce(math.gcd, numbers)
    
def pin(type=int):
    return map(type,input().split())


N, =pin()
A = list(pin())#a1=A[0]
"""
#考察
i の倍数が書かれた箱に入っているボールの個数の和を 2 で割った「余り」が ai である。
ここで、Aの中身が全部0ならあまりが偶数なのだが実際の数も0を含む
そのため、”よい入れ方”を作るときには0のみとなるのが容易な答えとなる

逆に、Aの中身に1が混じっていることでその入れ方（何も入れない）ができなくなる
"""
"""
考察2
i=1 すべての箱に入っている個数の和を2で割ったあまり<=>int(M) % 2
I={A[I]=1|Iは自然数}と集合をていぎしたら…
a1=0なら2個、a1=1なら1個の玉をIの部分集合とその補集合についてのLCM（ただし。うまく互いに素になるように）を求めれば済ませられるのでは。
-1をつけなくて良い
"""
odd=[]
for i in range(1,N):
    if A[i]==1:
        odd.append(i+1)


#print(odd)
if (A[0] == 1):
    #A[1]=1とどうち LCM出力
    print(1)
    print(gcd_list(odd))
else:
    print(2)
    print(gcd_list(odd),200002)

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!
import fractions
from functools import reduce



def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
    
def pin(type=int):
    return map(type,input().split())


N, =pin()
A = list(pin())#a1=A[0]
"""
#考察
i の倍数が書かれた箱に入っているボールの個数の和を 2 で割った「余り」が ai である。
ここで、Aの中身が全部0ならあまりが偶数なのだが実際の数も0を含む
そのため、”よい入れ方”を作るときには0のみとなるのが容易な答えとなる

逆に、Aの中身に1が混じっていることでその入れ方（何も入れない）ができなくなる
"""
"""
考察2
i=1 すべての箱に入っている個数の和を2で割ったあまり<=>int(M) % 2
I={A[I]=1|Iは自然数}と集合をていぎしたら…
a1=0なら2個、a1=1なら1個の玉をIの部分集合とその補集合についてのLCM（ただし。うまく互いに素になるように）を求めれば済ませられるのでは。
-1をつけなくて良い
"""
odd=[]
for i in range(1,N):
    if A[i]==1:
        odd.append(i+1)


#print(odd)
if (A[0] == 1):
    #A[1]=1とどうち LCM出力
    print(1)
    print(gcd_list(I))
else:
    print(2)
    print(gcd_list(I),200002)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = [0 for _ in range(N)]
for i in range(N, 0, -1):
  S = sum(B[m*(i+1)-1] for m in range(1, N//i))
  B[i-1] = (A[i-1] + S) % 2
C = []
for i in range(N):
  if B[i] == 1:
    C.append(i+1)
print(len(C))
for i in range(len(C)):
  if i != len(C) - 1:
    print(C[i], end = ' ')
  else:
    print(C[i])

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):
  x=(sum(ans[i-1::i]))%2
  if x!=a[i]:
    ans[i]=1
print(sum(ans))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input().split())
a = list(map(int,input().split()))
ans = []
for i in range(n,0,-1):
  if sum(a[::i]) % 2 == 1:
    ans.append(i)
ans.reverse()
print(len(ans))
print(" ".join(ans))

Submission status: Runtime Error

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

#箱の状態を記録しておく配列
box=[0]*n


for i in range(1,n+1):
  num=n-i

  #まず割って、その数より大きい倍数がいくつあるか探る
  baisu=n//num

  if baisu==1:
    box[num-1]=a[num-1]

  #1～baisu倍の箱の状態を調べる。
  temp=0
  for j in range(2,baisu+1):
    temp+=box[num*j-1]
  box[num-1]=abs(temp%2-a[num-1])

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

if sum(ans)!=0:
  print(len(ans))
  print(*ans)
else:
  print("0")

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int,input().split()))
ret = [0 for _ in range(n+1)]
#後ろから求める
for i,a_i in enumerate(a[-1::-1]):
    cur_ret_sum = sum(ret[n-i::n-i])%2
    if a_i!=cur_ret_sum:
        ret[n-i]=1

print(sum(ret[1::]))
print(" ".join(ret[1::]))

Submission status: Runtime Error

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

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import numpy as np

N = int(input())
# 1-indexed
a = [int(i) for i in input().split()]

now = [0] * N
for i in range(N-1,-1,-1):
    if now[i] != a[i]:
        div = make_divisors(i+1)
        for j in div:
            now[j] += 1
            now[j] %= 2

print(M)

answer = [i+1 for i,x in enumerate(now) if x == 1]
if answer:
    print(" ".join(list(map(str,answer))))

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = []
a.insert(0, 0)
for i in range(n, 0, -1):
    t_sum = 0
    j = 2 * i
    while j <= n:
        t_sum ^= b[j]
        j += i
    b.append(t_sum ^ a[i])
print(sum(b))
for i in range(n):
    if b[i] != 0:
        print(1)

Submission status: Runtime Error

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

ans=[]
balls=[0]*n
for i in range(n-1,-1,-1):
  if A[i]!=0:
    total=0
    for j in range(n-1,i,A[i]):
      total+=A[j]
    if total%2!=A[i]:
      if totaL+1!=A[i]:
        print(-1)
        exit()
      balls[i]+=1
      ans.append(i+1)
print(sum(balls))
print(*ans,sep=' ')

Submission status: Runtime Error

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

def search(x):
    n = 1
    res = 0
    while True:
        nx = n*x
        if nx > N:
            break
        res += boxes[nx-1]
        n += 1
    return res%2


boxes = [0]*N
for i, ai in enumerate(a):
    i = N-i
    eo = search(i)
    if ai!=eo:
        boxes[i]=1

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

if ans==[]:
    print(0)
else:
    print(*ans)

Submission status: Runtime Error

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

def search(x):
    n = 1
    res = 0
    while True:
        nx = n*x
        if nx >= N:
            break
        res += boxes[nx]
        n += 1
    return res%2


boxes = [0]*N
for i, ai in enumerate(a):
    i = N-i
    eo = search(i)
    if ai!=eo:
        boxes[i]=1

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

if ans==[]:
    print(0)
else:
    print(*ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
c = [0]
d = c + a
s = [0 for _ in range(n + 1)]
 
for i in range(n, 0, -1):
    w = 0
    for j in range(2 * i, n + 1, i):
        w ^= s[j]
    s[i] = w ^ d[i]
    
print(b.count(1) if b.count(1) else 0)
for i in range(1, n + 1):
    if s[i] != 0:
        print(s[i], end=' ')

Submission status: Runtime Error

Solution code:
n=int(input())
A=list(map(int,input().split()))
B=[0 for i in range(n)]
flag=0
for i in range(1,int(n**0.5)+1):
    for j in range(0,n,i):
        B[i-1] +=A[j]
C=[]
for i in range(int(n**0.5)+1):
    if B[i]%2==A[i] and B[i]%2==0:
        flag=1
    if B[i]%2==A[i] and B[i]%2!=0:
        C.append(i+1)
        flag=1

if flag:
    if len(C)==0:print(0);exit()
    print(1)
    print(*C)
else:print(-1)

Submission status: Runtime Error

Solution code:
n=int(input())
A=list(map(int,input().split()))
B=[0 for i in range(n)]
for i in range(1,int(n**0.5)+1):
    for j in range(0,n,i):
        B[i] +=A[j]

C=[]
for i in range(int(n**0.5)+1):
    if B[i]%2==A[i]:
        C.append(i+1)

if len(C)==0:print(0);exit()
print(1)
print(*C)

Submission status: Runtime Error

Solution code:
import os

input = sys.stdin.readline

N = int(input())

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

ans = False
b = [0]*N

for i in range(N, 0 ,-1):
    b_sum = 0
    for j in range(i, N+1, i):
        b_sum += b[j-1]
    if b_sum % 2 != a[i-1]: b[i-1] = 1
if b==[0]*N:print(0)      
else:
    print(sum(b))
    print(*[k+1 for k, l in enumerate(b) if l==1])

Submission status: Runtime Error

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

c = []
for i in range(1,n):
    if ((i+1)==2 or (i+1)//2==1):
        if a[i] == 1:
            c.append((i+1))
if len(c)//2!==a[0]:
    c.append(1)

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

Submission status: Runtime Error

Solution code:
from math import sqrt

N = int(input())
arr = input().split()

good = True
for i in range(int(sqrt(N))+1):
  
  total = 0
  for j in range(i, N, i+1):
    total += int(arr[j])
  
  if total % 2 != int(arr[i]):
    good = False
    print('-1')
    break

if good:
  print(arr.count('1'))
  for i in range(N):
    if arr[i] == '1':
      print(i+1, end = ' ')

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3

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

# 最初が0から始まる場合
b_list = [0] * N
b_list[-1] = a_list[-1]

for i in range(N):
    # 大きい方から決めていく
    idx = N - (i + 1)
    total = 0
    for j in b_list[:: idx + 1]:
        # idx + 1の倍数のボールの個数を数える
        total += b_list[j]

    if total % (idx + 1) != a_list[idx]:
        b_list[idx] = 1

idx_list = [str(i + 1) for i, b in enumerate(b_list) if b == 1]
ans = sum(b_list)
print(ans)
print(" ".join(idx_list))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3

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

# 最初が0から始まる場合
b_list = [0] * N
b_list[-1] = a_list[-1]

for i in range(1, N + 1):
    # 大きい方から決めていく
    idx = N - i
    total = 0
    for j in b_list[:: idx + 1]:
        # idx + 1の倍数のボールの個数を数える
        total += b_list[j]

    if total % (idx + 1) != a_list[idx]:
        b_list[idx] = 1

idx_list = [str(i + 1) for i, b in enumerate(b_list) if b == 1]
ans = sum(b_list)
print(ans)
print(" ".join(idx_list))

Submission status: Runtime Error

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

for i in range(n):
  ptr = n - 1 - i
  if a[ptr] % 2 == 1:
    for j in range(1, int(math.sqrt(ptr+1))+1):
      if (ptr + 1) % (j + 1) == 0:
        a[j] += 1
      
cnt = 0
que = []
for  i in range(n):
  if a[i]:
    cnt += 1
    que.append(a[i])

print(cnt)
if cnt > 0:
  print(' '.join(map(str, que)))

Submission status: Runtime Error

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

for i in range(n):
  ptr = n - 1 - i
  if a[ptr] % 2 == 1:
    for j in range(1, int(math.sqrt(ptr+1))+1):
      if (ptr + 1) % (j + 1) == 0:
        a[j] += 1
      
cnt = 0
que = []
for  i in range(n):
  if a[i]:
    cnt += 1
    que.append(a[i])

print(cnt)
print(' '.join(map(str, que)))

Submission status: Runtime Error

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

b=[0]*(N+1)
PN=[2]
M=0

if a[0]==1:
    b[1]=1
    M+=1
if a[1]==1:
    b[2]=1
    M+=1
    b[4]=1
    M+=1

for i in range(3,N+1):
    if a[i-1]==1 and b[i]==0:
        b[i]=1
        M+=1
        for j in PN:
            if i%j==0:
                if i+j>N:
                    print(-1)
                    exit()
                else:
                    b[i+j]=1
                    M+=1
    if a[i-1]==0 and b[i]==1:
        if i+i>N:
            print(-1)
            exit()
        else:
            b[i+i]=1
        for j in PN:
            if i%j==0:
                if i+j>N:
                    print(-1)
                    exit()
                else:
                    b[i+j]=1
                    M+=1
    f=True
    for j in PN:
        if i%j==0:
            f=False
    if f==True:
        PN.append(i)

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

Submission status: Runtime Error

Solution code:
s=input()
D= [c  for c in s]
n=int(input())
d=D*n
l=len(d)
count=0
for i in range(l-2):
  if d[i]==d[i+1]:
    if d[i]!=d[i+2]:
       d[i]="1"
       count+=1
    elif d[i]==d[i+2]:
      d[i+1]="1"
      count+=1
if d[l-2]==d[l-1]:
  count+=1
  
print(count)

Submission status: Runtime Error

Solution code:
#import numpy as np

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

n = 3
a_s =[1,0,0]

m = 0
ans = [0]*(n+1)
#ans = np.zeros(n+1).astype(int)


i=1
for i in range(n,0,-1):
    sum_num = 0
    for j in range(i,n+1,i):
        sum_num += ans[j]

    if((sum_num & 1) != a_s[i-1]):
        m += 1
        ans[i] = 1

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

print(m)
print(' '.join(map(str,ans2[])))

Submission status: Runtime Error

Solution code:
N=int(input())
b=list(map(int,input().split()))
a=[0]*N
for i in range(N):
    z = N-i-1
    while z <= N-1:
        a[N-1-i] += b[z]
        z=(z+1)*2-1
print(sum(a))
if sum(a) != 0:
    s = ''
    for i in a:
        s += str(i) + ' ' if i != 0 else ''
print(s.rstrip())

Submission status: Runtime Error

Solution code:
n = input()
a = map(int, raw_input().split())
b = [0 for _ in range(n)]
used = []

for i in xrange(n, 0, -1):
  sum = 0
  for j in xrange(2 * i, n + 1, i):
    sum += b[j]
  if sum % 2 != a[i]:
    used.append(i)
    b[i] = 1
print len(used)
for x in used: print x,
print

Submission status: Runtime Error

Solution code:
n=int(input())
a= list(map(int, input().split()))
li=[]
for i in range(n-1,n//2+1,-1):
    if 0!=a[i]:
        li.append(i+1)
for i in range(n//2+1,-1,-1):
    check=0
    for j in range(n//(i+1)):
        check+=(i+1)*(j+1) in li
    if check%2!=a[i]:
        li.append(i+1)
print(len(li))
print(" ".join(map(str,li)))

Submission status: Runtime Error

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

for i in range(n-1,-1,-1):
 # i= n-1, n-2......1,0
 #左からi+1番目に着いて調べる
    number=n//(i+1)
    if number==1:
          anslists[i]=lists[i]
    else:
　　    
        for some in range(number):
               check+=anslists[(i+1)*(some+1)]
        nums=check-lists[i]
        if nums%2==0:
           anslists[i]=lists[i]
        elif nums%2!=0:
           if lists[i]==0:
               anslists[i]=1
           if lists[i]==1:
               anslists[i]=0
Anscnt=0
Anslist=[]
for j in range(n):
    if anslists[j]==1:
        Anslist.append(j+1)
        Anscnt+=1
print(Anscnt)
print(*Anslist)

Submission status: Runtime Error

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

for i in range(n-1,-1,-1):
 # i= n-1, n-2......1,0
 #左からi+1番目に着いて調べる
    number=n//(i+1)
    if number==1:
          anslists[i]=lists[i]
    else:
        cnt=0
        check=0
        while cnt<=number-1:
           check+=anslists[i+cnt*(i+1)]
           cnt+=1
        nums=check-lists[i]
        if nums%2==0:
           anslists[i]=lists[i]
        elif nums%2!=0:
           if lists[i]==0:
               anslists[i]=1
           if lists[i]==1:
               anslists[i]=0
           
           
print(*anslists)

Submission status: Runtime Error

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

for i in range(n-1,-1,-1):
    cnt=0
    check=0
 # i= n-1, n-2......1,0
 #左からi+1番目に着いて調べる
    number=n//(i+1)
    if number==1:
          anslists[i]=lists[i]
    else:
        while cnt<=number-1:
           check+=anslists[i+cnt*(i+1)]
        nums=check-lists[i]
        if nums%2==0:
           anslists[i]=lists[i]
        elif nums%2!=0:
           if lists[i]==0:
               anslists[i]=1
           if lists[i]==1:
               anslists[i]=0
           
           
print(*anslists)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
m = 0
ans= []
for i in reversed(range(n)):
  z = 0
  for a in ans:
    if a%(i+1)==0:
      z += 1
  if (z+a[i])%2==1:
    ans.append(i+1)
    m+= 1
  else:
    pass
print(m)
print(*ans)

Submission status: Runtime Error

Solution code:
import sys
import numpy as np
import time

if __name__ == '__main__':
    n, q = map(int, input().split())

    board = np.zeros(n+1, dtype=np.int64)

    for i in range(q):
        l, r = map(int, input().split())
        l -= 1
        r -= 1
        board[l] += 1
        board[r+1] -= 1

    cumsum = np.cumsum(board)

    for i in range(n):
        print(int(cumsum[i])%2, end="")
    print()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
import numpy as np
sys.setrecursionlimit(10 ** 7)

MOD = 2  # type: int


def solve(N: int, a: "List[int]"):
    a = np.array(a)
    ans = np.zeros(N)
    # print(ans)
    ans_idx = []
    for i in range(N - 1, -1, -1):
        # print(i)
        # print(list(range(i * 2 + 1, N, i + 1)))
        # print(ans[range(i * 2 + 1, N, i + 1)])
        # print()
        if (a[i] + ans[range(i * 2 + 1, N, i + 1)].sum()) % 2 == 0:
            ans[i] = 0
        else:
            ans[i] = 1
            ans_idx.append(i + 1)
    # print(ans)
    b = int(sum(ans))
    print(b)
    if b:
        print(*ans_idx)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools
# (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#import numpy as np
N = int(input())
a = [0]+list(map(int,input().split()))
ans = [0]*(N+1)
an = []
for i in range(N,0,-1):
  c =0
  c = sum(ans[s*i::i])
  if c%2!=a[i]:
    ans[i]=1
    an.append(i)
print(len(an))
for i in range(len(an)):
  print(an[i],end=" ")

Submission status: Runtime Error

Solution code:
#Coding:Utf-8
N=int(input())
A=list(map(int,input().split()))
Box=[0 for i in range(N)]
BoxNum=[]

for l in reversed(range(N)):
    Incount=0
    for m in range(1,int(N/(l+1))):
        Incount+=Box[A[l]*m]
    if Incount%2!=A[l]:
        Box[A[l]]+=1
        BoxNum.append(l+1)

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

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
a = [0] + list(map(int, input().split()))
b = [0] * (N + 1)
for i in range(N, N//2, -1):
    b[i] = a[i]
for i in range(N//2, 0, -1):
    sum = 0
    for j in range(i+i, N, i):
        sum += b[j]
    b[i] = (a[i] + sum)%2
b = np.array(b)
if len(np.where(b==1)) != 0:
    print(len(np.where(b==1)[0]))
    ans = ' '.join(map(str, np.where(b == 1)[0]))
    print(ans)
else:
    print(0)

Submission status: Runtime Error

Solution code:
n=int(input())
A=list(map(int, input().split())).insert(0, 0)
B=[0]*(n+1)
for i in range(n, 0, -1):
  if sum([B[j] for j in range(i, n+1, i)])&1!=A[i]:
    B[i]+=1
res=[]
for i in range(n):
  if B[i]==1:
    res.append(i)
print(len(res))
if res:
  print(" ".join([str(e) for e in res]))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-                                                                              

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: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
# n = 5

arr = [0]*n
suffix_arr = [0]*(n+1)
# arr = [0, 2, 0, 4, 2]
for i in range(n):
	arr[i] = int(input())

conditional_flag = True

for i in range(1, n+1):
	for j in range(i, n+1, i):
		suffix_arr[i] += arr[j-1]
	if suffix_arr[i]%2 != arr[i-1]%2:
		conditional_flag = False
		break

if conditional_flag:
	b = [i+1 for i in range(i) if arr[i]]
	length = len(b)
	print(length)
	if length: print(*b)
else:
	print(-1)

Submission status: Runtime Error

Solution code:
import heapq

n = int(input())
# n = 3

arr = [0]*n

pq = []
for i in range(n):
	arr[i] = int(input())
	heapq.heappush(pq, (-arr[i], i))
heapq.heapify(pq)
lg = heapq.heappop(pq)
slg = heapq.heappop(pq)
print(lg, slg)
lg, slg = lg[1], slg[1]

for i in range(n):
	if i==lg:
		print(arr[slg])
	else:
		print(arr[lg])

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

b = []

for i in range(N):
    ind = N-i
    val = 0
    j=2
    while ind*j<=N:
        val += b[ind*j-1]
        j+=1
    if val%2 != a[ind-1]:
        b.append(ind)
print(len(b))
if len(b)!=0:
    print(' '.join([str(b[len(b)-i-1]) for i in range(len(b))]))

Submission status: Runtime Error

Solution code:
#include <iostream>

using namespace std;

int main(){
    int i,j,N;
    int a[N+1],b[N+1];
    cin >> N;

    for(i=1;i<=N;i++){
        cin >> a[i];
        b[i]=0;
    }

    int M = 0;
    int k = 0;
    for(i=N;i>0;i--){
        int val = 0;
        for(j=2;i*j<=N;j++){
            val+=b[i*j];
        }
        if(val%2!=a[i]){
            b[i]=1;
            M++;
            k=max(k,i);
        }            
    }
    cout << M << endl;
    for(i=1;i<=N;i++){
        if(b[i]==1){
            cout<<i<<" ";
        }
    }
    if(M!=0)
        cout<<endl;
}

Submission status: Runtime Error

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

ans = []


def ball_ok(balls):
    global ans
    for i in range(1, n + 1):
        sum_ = 0
        for j in range(i, n + 1, i):

            sum_ += balls[j]

        if sum_ % 2 != a[i-1]:
            return 0

    ans = balls
    return 1


def ball(balls, k):
    if k == n+1:
        return ball_ok(balls)
    b0 = ball(balls + [0], k + 1)
    b1 = ball(balls + [1], k + 1)
    return b0 or b1


res = ball(balls=[1], k=1)

cnt = 0

ansi = []

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

if cnt == 0:
    print(0)
else:
    print(len(ansi))
    for _ in ansi:
        print(_)

Submission status: Runtime Error

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

res = nums.copy()

for i in range(n // 2, 0, -1):
    res[i] = 0
    for j in range(1, n // i + 1):
        res[i] += res[i * j]
    res[i] %= 2
for elem in res:
    print(elem)

Submission status: Runtime Error

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

info = [0] * (n+1)

for i in range(0,n):
    count = 0
    for j in range(n-i,n+1):
        count += info[j]
    if count != a[n-i]:
        info[n-i] = 1

ans = []

for k in range(1,n+1):
    if info[k] == 1:
        ans.append(k)

print(len(ans))
print(ans)

Submission status: Runtime Error

Solution code:
import sys
n = int(input())
A = list(map(int, input().split()))
if sum(A) == 0:
  print(0)
  sys.exit()
for i in range(1,n+1):
  s = sum(A[i-1::i])
  if s%2 == A[i]:
    print(len(A[i-1::i]))
    print(*list(map(lambda n: n+1, A[i-1::i])))
    sys.exit()
print(-1)

Submission status: Runtime Error

Solution code:
# Nの倍数の数を格納する辞書
baisuu = {i:0 for i in range(1,N+1)}
M=0
out_list=[]

a=listA

half=N//2

for i,ai in enumerate(a):
    now_index=N-i
    if now_index > half:
        if ai==1:
            soinsuu = factorization(now_index)
            out_list.append(now_index)
            M+=1
            for so in soinsuu:
                baisuu[so]+=1
    else:
        if baisuu[now_index]%2!=int(ai):
            out_list.append(now_index)
            M+=1
            soinsuu = factorization(now_index)
            for so in soinsuu:
                baisuu[so]+=1

print(M)
if M>0:
    out_list=sorted(out_list)
    print(" ".join(list(map(str, out_list))))

Submission status: Runtime Error

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

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

b=[]
M = 0
count = [0 for _ in range(N)]
for i in reversed(range(1,N+1)):
    if count[i-1]%2 == a[i-1]: continue
    else:
        for j in range(1,int(i**0.5)+1):
            if i%j==0:
                count[j]+=1
                if j!=i//j:
                    count[i//j]+=1
        M+=1
        b.append(i)
print(M)
if M!=0:
    print(*b)