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()))
from collections import defaultdict

balls = defaultdict(int)
for i in range(n-1,-1,-1):
    count=A[i]
    for j in range(n//(i+1)):
        count+=balls[(j*(i+1))-1]
    if count%2:
        balls[i]=1

ans=[i+1 for i in range(n) if balls[i]==1]
print(len(ans))
print(*ans)
n=int(input())
A=list(map(int,input().split()))
from collections import defaultdict

balls = defaultdict(int)
for i in range(n-1,-1,-1):
    count=A[i]
    for j in range(n//(i+1)):
        count+=balls[(j*(i+1))-1]
    if count%2:
        balls[i]=1

ans=[i+1 for i in range(n) if balls[i]==1]
print(len(ans))
print(*ans)

Submission status: Runtime Error

Solution code:
#43 ABC134D
n=int(input())
a=list(map(int,input().split()))
x=[0 for _ in range(n)]
for i in range(n,0,-1):
	x[i-1]=sum([a[j] for j in range(i-1,n,i)])%2
j=True
for i in range(a):
	if a[i]!=sum([a[j] for j in range(i,n,i+1)])%2:
		j=False
if j:
	print(sum(x))
	if sum(x)!=0:
		res=[]
		for i,t in enumerate(x):
			if t==1:
				res.append(str(i+1))
		print(" ".join(res))
else:
	print(-1)

Submission status: Runtime Error

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

N = int(input())
A = [0] + list(map(int, input().split()))
B = [0] * (N+1)aimport sys
input = sys.stdin.readline

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

ans = []
for i in list(range(N, 0, -1)):
    sum = 0
    for j in list(range(2 * i, N, i)):
        sum ^= B[j]
    B[i] = sum ^ A[i]
    if B[i]:
        ans.append(str(i))

print(len(ans))
if ans:
    print(' '.join(ans))


ans = []
for i in range(N, 0, -1):
    sum = 0
    for j in range(2 * i, N, i):
        sum ^= B[j]
    B[i] = sum ^ A[i]
    if B[i]:
        ans.append(str(i))
        
print(len(ans))
if ans:
    print(' '.join(ans))

Submission status: Runtime Error

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

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

for i in range(N, 0, -1):aimport sys
input = sys.stdin.readline

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(2 * i, N, i):
        sum ^= B[j]
    B[i] = sum ^ A[i]
ans = []
for i in range(1, N+1):
    if B[i]:
        ans.append(str(i))
print(len(ans))
if ans:
    print(' '.join(ans))

    sum = 0
    for j in range(2 * i, N, i):
        sum ^= B[j]
    B[i] = sum ^ A[i]
ans = []
for i in range(1, N+1):
    if B[i]:
        ans.append(str(i))
print(len(ans))
if ans:
    print(' '.join(ans))

Submission status: Runtime Error

Solution code:
def main(A,N):
    A = [0] + A
    for a in range(N//2,0,-1):
        #print(inds[ind::ind+1])
        if sum(A[a::a]) %2== 0:
            A[a] = 0
        else:
            A[a] = 1
        
        res = [x for x in range(0,N+1) if A[x]]
    print(len(res))
    print(*res)

N = int(input())
A = [int(x) for x in input().split()]
    
main(A,N)

Submission status: Runtime Error

Solution code:
def main(a):
    for ind,_ in enumerate(a):
        #print(inds[ind::ind+1])
        buf = a[ind::ind+1]
        if (buf[0]==0 and sum(buf)%2==0) or (buf[0]==1 and sum(buf)%2==1):
            pass
        else:
            print(-1)
            return 0

    print(sum(a))
    if sum(a)>0:print(' '.join([str(ind+1) for ind,x in enumerate(a) if x == 1]))

N = int(input())
a = [int(input()) for _ in range(N)]
    
main(a)

Submission status: Runtime Error

Solution code:
def main(a):
    for ind,_ in enumerate(a):
        #print(inds[ind::ind+1])
        buf = a[ind::ind+1]
        if (buf[0]==0 and sum(buf)%2==0) or (buf[0]==1 and sum(buf)%2==1):
            pass
        else:
            print(-1)
            return 0

    print(sum(a))
    print(' '.join([str(ind+1) for ind,x in enumerate(a) if x == 1]))

N = int(input())
a = [int(input()) for _ in range(N)]
    
main(a)

Submission status: Runtime Error

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

def get_divisors(n, reverse=False):
    from math import sqrt
    divisors = []
    for num in range(1, int(sqrt(n))+1):
        if n % num == 0:
            divisors.append(num)
            if n//num != num:
                divisors.append(n//num)
    return sorted(divisors, reverse=reverse)

total = sum(A)
divisors = get_divisors(total, reverse=True)
ans = -1
for d in divisors:
    R = [a%d for a in A]
    R.sort(reverse=True)
    pr = 0
    nr = -sum(R)
    for i, r in enumerate(R):
        pr += d-r
        nr += r
        if nr+pr >= 0:
            if pr <= K and nr+pr == 0:
                ans = d
            break
    if ans != -1:
        print(ans)
        break
else:
    print(1)

Submission status: Runtime Error

Solution code:
def multiple_factors(i, N):
  factors = []
  factors.append(int(1*i))
  for index in range(1, N//i):
    factors.append(int(index*i))
  return factors
  
def assign_ball(factors, blist, ai, b_add_index):
  sum_b = 0
  for index in range(len(factors)-1, 0, -1):
    sum_b += blist[factors[index]-1]
  
  if ai != sum_b%2:
    blist[factors[0]-1] =1
    b_add_index.append(str(factors[index]))
  return blist, b_add_index

      
N = int(input())
alist = list(map(int, input().split()))
blist = [0 for i in range(N)]
M = 0
b_add_index = []
for i in range(N-1,-1, -1):
  factors = multiple_factors(i+1, N)
  blist, b_add_index = assign_ball(factors, blist, alist[i], b_add_index)

if sum(blist)%2 != alist[0]:
  print(-1)
else:
  print(len(b_add_index))
  print(" ".join(b_add_index))

Submission status: Runtime Error

Solution code:
def multiple_factors(i, N):
  factors = []
  factors.append(int(1*i))
  for index in range(1, N//i):
    factors.append(int(index*i))
  return factors
  
def assign_ball(factors, blist, ai, b_add_index):
  sum_b = 0
  for index in range(len(factors)-1, 0, -1):
    sum_b += blist[factors[index]-1]
  
  if ai != sum_b%2:
    blist[factors[-1]-1] =1
    b_add_index.append(str(factors[index]))
  return blist, b_add_index

      
N = int(input())
alist = list(map(int, input().split()))
blist = [0 for i in range(N)]
M = 0
b_add_index = []
for i in range(N-1,-1, -1):
  factors = multiple_factors(i+1, N)
  blist, b_add_index = assign_ball(factors, blist, alist[i], b_add_index)

if sum(blist)%2 != alist[0]:
  print(-1)
else:
  print(len(b_add_index))
  print(" ".join(b_add_index))

Submission status: Runtime Error

Solution code:
def multiple_factors(i, N):
  factors = []
  factors.append(int(1*i))
  for index in range(1, N//i):
    factors.append(int(index*i))
  return factors
  
def assign_ball(factors, blist, ai, b_add_index):
  sum_b = 0
  for index in range(len(factors)-1, 0, -1):
    sum_b += blist[factors[index]-1]
  
  if ai != sum_b%2:
    blist[factors[index]-1] =1
    b_add_index.append(str(factors[index]))
  return blist, b_add_index

      
N = int(input())
alist = list(map(int, input().split()))
blist = [0 for i in range(N)]
M = 0
b_add_index = []
for i in range(N-1,-1, -1):
  factors = multiple_factors(i+1, N)
  blist, b_add_index = assign_ball(factors, blist, alist[i], b_add_index)

if sum(blist)%2 != alist[0]:
  print(-1)
else:
  print(len(b_add_index))
  print(" ".join(b_add_index))

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
ls = []
for i in reversed(range(n)):
    count = 0
    for lsi in ls:
        if lsi >= i and not lsi % i:
            count += 1
    if count % 2 != a[i]:
        ls.append(i+1)
print(len(ls))
print(' '.join(map(str, ls)))

Submission status: Runtime Error

Solution code:
# -*- coding:utf-8 -*-
# /usr/bin/python3

def main():
  N = int(input())
  liA = list(map(int, input().strip().split(' ')))
  liB = []
  for i, a in enumerate(liA[::-1]):
    i = len(liA) - i
    sumA = sum([liA[j] for j in range(i, len(liA), i+1)])
    if sumA % 2 != a:
      liA[i] += 1
      liB += [i]
  print(len(liB))
  print(' '.join(map(str,liB)))
  pass

if __name__=='__main__':
  main()

Submission status: Runtime Error

Solution code:
# -*- coding:utf-8 -*-
# /usr/bin/python3

def main():
  N = int(input())
  liA = list(map(int, input().strip().split(' ')))
  liB = []
  for i, a in enumerate(liA[::-1]):
    i = len(liA) - i
    sumA = sum([liA[i] for j in range(i, len(liA), i+1)])
    if sumA % 2 != a:
      liA[i] += 1
      liB += [i]
  print(len(liB))
  print(' '.join(map(str,liB)))
  pass

if __name__=='__main__':
  main()

Submission status: Runtime Error

Solution code:
n = int(input())
alist = list(map(int,input().split()))
anslist =[]
def act(i,nowlist):
    now = i+1
    ai =alist[i]
    s = 1
    multisum =0
    while now * s <= n:
        multisum += nowlist[now*s-1]
        s +=1
    if multisum%2 ==ai:
        anslist.append(0)
    if multisum%2 !=ai:
        anslist.append(1)
    if i == n-1:
        return 
    act(i+1,nowlist)
    
numlist = [0 for i in range(n)]
act(0,numlist)
print(anslist.count(1))
if anslist.count(1)>0:
    indexes = [i+1 for i, x in enumerate(anslist) if x == 1]
    [print(i,end=" ") for i in indexes]

Submission status: Runtime Error

Solution code:
import math as math

N = int(input())
A = list(map(int, input().split()))
ANS = [0]*len(A)
for i in range(math.ceil(N/2)+1,N):
    ANS[i] = A[i]

fnum=math.ceil(N/2)
for i in range(fnum,-1,-1):
    j = i + 1
    tsum=A[i]
    for k in range(j,N+1,j):
        tsum+=ANS[k-1]
    ANS[i]=tsum%2

#print(ANS)
anslist=[]
for i in range(N):
    if ANS[i]==1:
        anslist.append(i+1)
 
print(len(anslist))
for s in anslist:
    print(s, end =" ")

Submission status: Runtime Error

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

ans = [1 for i in range(n+1)]; ans[0] = 0
for i in range(n+1):
    s = 0
    for j in range(i,n+1,i): s += ans[j]
    if (s - a[i-1])%2 == 0: pass
    else: ans[i] = 0

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

Submission status: Runtime Error

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

ans = [0 for i in range(n+1)]
for i in range(n+1):
    s = 0
    for j in range(i*2,n+1,i): s += ans[j]
    if (s - a[i-1])%2 == 0: pass
    else: ans[i] = 1

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

Submission status: Runtime Error

Solution code:

n = int(input())
a = [0] + [i for i in input().split()]
retval = [0] * (n+1)

for i in range(n,0,-1):
    p = sum([retval[x] for x in range(i+i,n+1,i)])
    retval[i] = (p%2) ^ a[i]

print(sum(retval))
print(i for i in range(1,n+1) if retval[i])

Submission status: Runtime Error

Solution code:
N = int(input())
A = [0]+[int(x) for x in input().split()]
dp = [0]*(N+1)
res = 0
for i in range(N):
    k = N-i
    if k < N//2:
        l = N//k
        dp[k] = A[k]-sum([dp[k*j] for j in range(2,l+1)])%2
    else:
        dp[k] = A[k]
    res += dp[k]
     
print(res)
print(' '.join([i for i,x in enumerate(dp) if x==1]))

Submission status: Runtime Error

Solution code:
N = int(input())
A = [0]+[int(x) for x in input().split()]
dp = [0]*(N+1)
res = 0
for i in range(N):
    # 今見てるところ
    k = N-i
    if k < N//2:
        dp[k] = A[k]-sum([x for i,x in enumerate(dp[k+1:]) if i%k==0])%2
    else:
        dp[k] = A[k]
    res += dp[k]

print(res)
print(' '.join([i for i,x in enumerate(dp) if x==1]))

Submission status: Runtime Error

Solution code:
# 明らかにTLEする
N = int(input())
A = [0]+[int(x) for x in input().split()]
dp = [0]*(N+1)
res = 0
for i in range(N):
    k = N-i
    if k < N//2:
        dp[k] = A[k]-sum([x for i,x in enumerate(dp[k+1:]) if i%k==0])%2
    else:
        dp[k] = A[k]
    res += dp[k]

print(res)
print('0'.join([i for i,x in enumerate(dp) if x==1]))

Submission status: Runtime Error

Solution code:
n=int(input())
balls=list(map(int,input().split()))
ans=[0]*n;m=0
for i in range(n)[::-1]:
  d=i+1
  c=n//d
  check=0
  while d*(c+1)<=n:
    check+=ans[d*(c+1)-1]
    c+=1
  if check!=balls[i]:
    ans[i]=1
    m+=1
print(m)
print(" ".join(ans))

Submission status: Runtime Error

Solution code:
n = int(input())
li = list(map(int, input().split()))
make_li = [0 for _ in range(n)]
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

for i in reversed(range(n)):
    if li[i] == 1:
        make_li[i] = 1
        for j in make_divisors(i):
            li[i] = abs(li[i]-1)

if 1 in li:
    print(-1)
else:
    li = [i+1 for i in range(n) if li[i] == 1]
    print(len(li))
    print(" ".join(map(str, li)) if len(li) > 1 else li[i] if len(li) == 0)

Submission status: Runtime Error

Solution code:
n = int(input())
li = list(map(int, input().split()))
make_li = [0 for _ in range(n)]
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

for i in reversed(range(n)):
    if li[i] == 1:
        make_li[i] = 1
        for j in make_divisors(i):
            li[i] = abs(li[i]-1)

if 1 in li:
    print(-1)
else
    li = [i+1 for i in range(n) if li[i] == 1]
    print(len(li))
    print(" ".join(map(str, li)) if len(li) > 1 else li[i] if len(li) == 0)

Submission status: Runtime Error

Solution code:
n = int(input())
li = list(map(int, input().split()))
make_li = [0 for _ in range(n)]
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

for i in reversed(range(n)):
    if li[i] == 1:
        make_li[i] = 1
        for j in make_divisors(i):
            li[i] = abs(li[i]-1)


li = [i+1 for i in range(n) if li[i] == 1]
print(len(li))
print(" ".join(map(str, li) )if len(li) > 1 else li[i])

Submission status: Runtime Error

Solution code:
n = int(input())
li = list(map(int, input().split()))
make_li = [0 for _ in range(n)]
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

for i in reversed(range(n)):
    if li[i] == 1:
        make_li[i] = 1
        for j in make_divisors(i):
            li[i] = abs(li[i]-1)


li = [i+1 for i in range(n) if li[i] == 1]
print(len(li))
print(" ".join(map(str, li) if len(li) > 1 else li[i])

Submission status: Runtime Error

Solution code:
n = int(input())
li = list(map(int, input().split()))
make_li = [0 for _ in range(n)]
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

for i in reversed(range(n)):
    if li[i] == 1:
        make_li[i] = 1
        for j in make_divisors(i):
            li[i] = abs(li[i]-1)


li = [i+1 for i in range(n) if li[i] == 1]
print(len(li))
print(" ".join(map(str), li) if len(li) > 1 else li[i])

Submission status: Runtime Error

Solution code:
n = int(input())
li = list(map(int, input().split()))
make_li = [0 for _ in range(n)]
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

for i in reversed(range(n)):
    if li[i] == 1:
        make_li[i] = 1
        for j in make_divisors(i):
            li[i] = abs(li[i]-1)


li = [i+1 for i in range(n) if li[i] == 1]
print(" ".join(map(str), li) if len(li) > 1 else li[i] if len(li) == 1 else 0)

Submission status: Runtime Error

Solution code:
from functools import lru_cache
import sys

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

sys.setrecursionlimit(2 ** N)

def check(s):
    for i in range(len(s)):
        if sum(s[i::i+1]) % 2 != A[i]:
            return False
    return True

def dfs(s=[]):
    if not check(s):
        return None
    if len(s) == N:
        return s

    ret0 = dfs(s + [0])
    if ret0 is not None:
        return ret0

    ret1 = dfs(s + [1])
    if ret1 is not None:
        return ret1
    return None

ret = dfs()

if ret is None:
    print(-1)
else:
    ans = []
    for i in range(len(ret)):
        if ret[i] == 1:
            ans.append(i+1)
    print(len(ans))
    if len(ans):
        print(*ans)

Submission status: Runtime Error

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

def check(s):
    for i in range(len(s)):
        if sum(s[i::i+1]) != A[i]:
            return False
    return True

def dfs(s):
    if not check(s):
        return None
    if len(s) == N:
        return s

    ret0 = dfs(s + [0])
    if ret0 is not None:
        return ret0

    ret1 = dfs(s + [1])
    if ret1 is not None:
        return ret1
    return None

ret = dfs([])

if ret is None:
    print(-1)
else:
    c = 0
    ans = []
    for i in range(len(ret)):
        if ret[i] == 1:
            ans.append(i+1)
    print(len(ans))
    print(*ans)

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split()))
b = []
flag = False
if max(a) == 0:
  j = 0
  flag = True
for i in range(1,N+1):
  if flag:
    break
  n = int(N/i)
  b = []
  for j in range(1,n+1):
    b.extend([i*j])
    if j % 2 == a[i-1]:
      flag = True
      break
if not flag:
  print (-1)
else:
  print (j)
if len(b) != 0:
  print (b[0])
  for i in range(len(b)-1):
    print (" " + b[i+1])

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split()))
b = []
flag = False
if max(a) == 0:
  j = 0
  flag = True
for i in range(1,N+1):
  if flag:
    break
  n = int(N/i)
  b = []
  for j in range(1,n+1):
    b.extend([i*j])
    if j % 2 == a[i-1]:
      flag = True
      break

print (j)
if len(b) != 0:
  print (b[0])
  for i in range(len(b)-1):
    print (" " + b[i+1])

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split()))
b = []
flag = False
if max(a) == 0:
  j = 0
  flag = True
for i in range(1,N+1):
  if flag:
    break
  n = int(N/i)
  b = []
  for j in range(1,n+1):
    b.extend([i*j])
    print (b)
    if j % 2 == a[i-1]:
      flag = True
      break

print (j)
print (' '.join(b))

Submission status: Runtime Error

Solution code:
N = int(input())
inf = input().split()
if inf[0]==1:
  print(-1)
else:
  A = {i+1:int(inf[i]) for i in range(N)}
  ans = [0 for i in range(N+1)]
  keys = list(A.keys())
  keys.sort(reverse=True)
  for k in keys[::-1]:
    count = 0
    for j in range(2*k, N, k)[::-1]:
      count += ans[j]
      ans[k] = (A[k]-(count%2))%2
      value = sum(ans)
  print(value)
  tag = []
  for i in range(N+1):
    if ans[i]:
      tag += [str(i)]
      print(' '.join(tag))

Submission status: Runtime Error

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


answer = []
B = 0

for i in range(N):
    L = N // (N-i)
    if L == 1:
        answer.append(a[N-i-1])
    else:
        for j in range(L-1):
            t = (N-i) * j
            B += answer[t]
        B = B % 2
        if B == a[N-i-1]:
            answer.append(0)
        else:
            answer.append(1)
    B = 0


k = 0
P = len(answer)
while (answer[0] == 0) and (k < P-1):
    answer.remove(0)
    k += 1

if answer == [0]:
    print(0)
else:
    answer.reverse()
    print(answer.count(1))
    for i in range(J):
        if answer[i] == 1:
            print(i+1, end=' ')

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(1, n, -1):
    if sum(b[i::i])%2 == a[i]:
        b[i] = 0
    else:
        b[i] = 1
if sum(b)%2 == a[0]:
    b[0] = 0
else:
    b[0] = 1

if sum(b) != 0:
    print(sum(b))
    ans = []
    for i in range(n):
        if b[i] == 1:
            ans.append(i)
    print(ans.join(" "))
else:
    print("0")

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(input()) for _ in range(n)]
b = [0 for _ in range(n)]
for i in range(1, n, -1):
    if sum(b[i::i])%2 == a[i]:
        b[i] = 0
    else:
        b[i] = 1
if sum(b)%2 == a[0]:
    b[0] = 0
else:
    b[0] = 1

if sum(b) != 0:
    print(sum(b))
    ans = []
    for i in range(n):
        if b[i] == 1:
            ans.append(i)
    print(ans.join(" "))
else:
    print("0")

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(input()) for _ in range(n)]
b = [0 for _ in range(n)]
for i in range(0, n, -1):
    if sum(b[i::i])%2 == a[i]:
        b[i] = 0
    else:
        b[i] = 1
if sum(b) != 0:
    print(sum(b))
    ans = []
    for i in range(n):
        if b[i] == 1:
            ans.append(i)
    print(ans.join(" "))
else:
    print("0")

Submission status: Runtime Error

Solution code:
n=int(input())
l=list(map(int,input().split()))
b=[]
ans=0
for i in range(n)[::-1]:
  c=n//(i+1)
  s=0
  while (c+1)*(i+1)<=n:
    s+=l[(c+1)*(i+1)]
    c+=1
    s%=2
  if l[i]!=s:
    b.append(i+1)
    ans+=1
print(ans)
print(" ".join(b))

Submission status: Runtime Error

Solution code:
import sys

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

answer = [0] * N
count = [0] * N

divisor = 1
for i in range(len(A), -1, -1):
  answer[i-1] = 0 if count[i-1] == A[i-1] else 1
  if answer[i-1] == 1:
    for j in range(1, i//2):
      if i % j == 0:
        count[i] += 1

appearance = [str(i+1) for i in range(len(answer)) if answer[i] == 1]
print(len(appearance))
if len(appearance) > 0:
    print(" ".join(appearance))

Submission status: Runtime Error

Solution code:
from sys import stdin

def main():
    n = int(stdin.readline().rstrip())
    xs = [int(stdin.readline().rstrip()) for _ in range(n)]

    for i range(n):
        l_max = max(xs[0:i])
        r_max = max(xs[i+1:])
        print(max(l_max,r_max))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n=int(input())
a=[0]+[int(x) for x in input().split()]
b=[0]*(n+1)
 
for s in range(n,0,-1):
    i=s
    t=0
    while i<=n:
        t += b[i]
        i += s
    if a[s]!=t%2:
        b[s]=1
print(b.count(1))
for i in range(n+1):
    if b[i+1]==1:
        print(i+1)

Submission status: Runtime Error

Solution code:
import numpy as np
import sys
N = int(input())
A = list(map(int, input().split()))
result = np.zeros(N)
for i in range(N-1, -1, -1):
  if A[i] != np.sum(result[i::(i+1)]):
    result[i] = 1

if A[0] != np.sum(result) or A[1] != np.sum(result[1::2]):
  print(-1)
  sys.exit(0)

print(int(np.sum(result)))
for i in result:
  if i == 1:
    print(1)

Submission status: Runtime Error

Solution code:
N = int(input("N = "))
a = []
ball = []
while N != len(a):
    a.append(int(input("a_i = ")))
    ball.append(0)
i = N
ballcount = 0
check = 2
out = 0
while i != 0 and out != N + 1:
    while check * i <= N: 
        ballcount += ball[check * i - 1]
        check += 1
    if ballcount % 2 != a[i - 1]:
        ball[i - 1] = 1
    check = 2
    i -= 1
    ballcount = 0
    out += 1
if out == N + 1:
    i = out
    print(-1)
M = 0
while i < N:
    if ball[i] == 1:
        M += 1
    i += 1
print(M)
i = 0
while i < N:
    if ball[i] == 1:
        print(i + 1)
    i += 1

Submission status: Runtime Error

Solution code:
N = int(input("N = "))
a = []
ball = []
while N != len(a):
    a.append(int(input("a_i = ")))
    ball.append(0)
i = N
ballcount = 0
check = 2
out = 0
while i != 0 and out != N + 1:
    while check * i <= N: 
        ballcount += ball[check * i - 1]
        check += 1
    if ballcount % 2 != a[i - 1]:
        ball[i - 1] = 1
    check = 2
    i -= 1
    ballcount = 0
    out += 1
if out == N + 1:
    i = out
    print(-1)
M = 0
while i < N:
    if ball[i] == 1:
        M += 1
    i += 1
print(M)
i = 0
while i < N:
    if ball[i] == 1:
        print(i + 1,end=" ")
    i += 1

Submission status: Runtime Error

Solution code:
N = int(input())
a = []
ball = []
while N != len(a):
    a.append(int(input()))
    ball.append(0)
i = N
ballcount = 0
check = 2
out = 0
while i != 0 and out != N + 1:
    while check * i <= N: 
        ballcount += ball[check * i - 1]
        check += 1
    if ballcount % 2 != a[i - 1]:
        ball[i - 1] = 1
    check = 2
    i -= 1
    ballcount = 0
    out += 1
if out == N + 1:
    i = out
    print(-1)
M = 0
while i < N:
    if ball[i] == 1:
        M += 1
    i += 1
print(M)
i = 0
while i < N:
    if ball[i] == 1:
        print(i + 1)
    i += 1

Submission status: Runtime Error

Solution code:
def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    b = [0]*n
    for i in reversed(range(n)):
        x = n//(i+1)
        now = 0
        for j in range(1,x+1):
            now += b[k*(i+1)-1]
        if a[i] != now%2:
            b[i]=1
    print(b.count(1))
    if not m==0:
        for i in range(n):
            if b[i]==1:
                print(str(i+1),end=" ")
    
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math
m = list(map(int, input().split()))[0]
a = list(map(int, input().split()))


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
  
b = [False for i in range(m)]
c = [False for i in range(m)]

for i in range(m):
    ii = m - i
    if(a[ii-1] != b[ii-1]):
        k = make_divisors(ii)
        for j in k:
            b[j-1] = not b[j-1]
        c[ii-1] = True
    print("b",b)
    print("c",c)
    print()

ans = ""
count = 0
for i in range(m):
    if(c[i] == True):
        ans+= str(i+1) + " "
        count +=1
        
print(count)
print(ans)

Submission status: Runtime Error

Solution code:
#coding : utf-8

import os
import sys

N = int(input())

a = list(map(lambda x: int(x), input().split(" ")))

#print(N)
#print(a)

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

#print(box)

for i in range(N, 0, -1):
	#print(f"i={i}, a{i}={a[i-1]}")

	idx = []
	for k in range(1, N+1):
		v = i * k
		if v > N:
			break
		idx.append(v)

	idx.reverse()

	#print(idx)

	balls = 0
	for k in idx:
		balls += box[k-1]
	
	#print(balls)

	if a[i-1] == 0:
		if balls == 0:
			box[i-1] = 0
		else:
			box[i-1] = 1
	else:
		if balls == 0:
			box[i-1] = 1
		else:
			box[i-1] = 0

#print(box)

print(box.count(1))

first = True

for i, b in enumerate(box):
	if b == 1:
		if first:
			first = False
		else:
			print(" ", end="")
		print(f"{i+1}", end="")

Submission status: Runtime Error

Solution code:
#coding : utf-8

import os
import sys

N = int(input())

a = list(map(lambda x: int(x), input().split(" ")))

#print(N)
#print(a)

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

#print(box)

for i in range(N, 0, -1):
	#print(f"i={i}, a{i}={a[i-1]}")

	idx = []
	for k in range(1, N+1):
		v = i * k
		if v > N:
			break
		idx.append(v)

	idx.reverse()

	#print(idx)




	balls = 0
	for k in idx:
		balls += box[k-1]
	
	#print(balls)

	if a[i-1] == 0:
		if balls == 0:
			box[i-1] = 0
		else:
			box[i-1] = 1
	else:
		if balls == 0:
			box[i-1] = 1
		else:
			box[i-1] = 0

#print(box)

print(box.count(1))

first = True

for i, b in enumerate(box):
	if b == 1:
		if first:
			first = False
		else:
			print(" ", end="")
		print(f"{i+1}", end="")

Submission status: Runtime Error

Solution code:
#coding : utf-8

import os
import sys

N = int(input())

a = list(map(lambda x: int(x), input().split(" ")))

#print(N)
#print(a)

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

#print(box)

for i in range(N, 0, -1):
	#print(f"i={i}, a{i}={a[i-1]}")

	idx = []
	for k in range(1, N+1):
		v = i * k
		if v > N:
			break
		idx.append(v)

	idx.reverse()

	#print(idx)




	balls = 0
	for k in idx:
		balls += box[k-1]
	
	#print(balls)

	if a[i-1] == 0:
		if balls == 0:
			box[i-1] = 0
		else:
			box[i-1] = 1
	else:
		if balls == 0:
			box[i-1] = 1
		else:
			box[i-1] = 0

#print(box)

print(box.count(1))

for i, b in enumerate(box):
	if b == 1:
		print(f"{i+1} ", end="")

Submission status: Runtime Error

Solution code:
N = int(input())
A = [int(input()) for _ in range(N)]

sum_index = [0]*(N+1)

for i in range(N)[::-1]:
    sum_ = 0    
    for j in sum_index[i+1::i+1]:
        sum_ ^= j
    sum_index[i+1] = sum_ ^ A[i] 
print(sum(sum_index))
print(sum_index[1:])

Submission status: Runtime Error

Solution code:
N = int(input())
A = [0] + inpl()
D = [0]*(N+1)

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

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

Submission status: Runtime Error

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

box_num = int(input())
ball_in_box_num_list = ([int(i), []] for i in input().split(" "))
for i in range(1, box_num + 1):
    k = 2
    while i * k <= box_num:
        ball_in_box_num_list[i * k - 1][1].append(i - 1)
        k += 1
ans_num = 0
ans_list = []
for i in range(box_num):
    a = box_num - 1 - i
    b = ball_in_box_num_list[a]
    if b[0] == 1:
        ans_num += 1
        ans_list.append(a + 1)
        for j in b[1]:
            ball_in_box_num_list[j][0] = 1 - ball_in_box_num_list[j][0]
print(ans_num)
if ans_list != 0:
    ans_list = [str(i) for i in ans_list]
    ans_list = ans_list[::-1]
    print(" ".join(ans_list))