Problem p02972 (python)

Fixed submission:
import sys

# import re
import math
import collections
# import decimal
# import bisect
# import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    a = na()

    b = [0 for i in range(n)]
    ans = []

    for i in range(n // 2, n):
        if a[i] == 1:
            b[i] = a[i]
            ans.append(i + 1)

    for i in range(n // 2 - 1, -1, -1):
        cnt = 0
        for j in range(i * 2 + 1, n, i + 1):
            cnt ^= b[j]
        if cnt != a[i]:
            b[i] = 1
            ans.append(i + 1)

    tmp = len(ans)
    print(tmp)
    if tmp > 0:
        print(*ans, sep=" ")


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math
import copy
from copy import deepcopy
import sys
import fractions
from functools import reduce
import statistics
import heapq
 
# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)
 
# ===FUNCTION===
 
def getInputInt():
    inputNum = int(input())
    return inputNum
 
 
def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]
 
    return outputData
 
 
def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)
 
    return outputDataList
 
 
def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)
 
    return outputDataList
 
 
# ===CODE===
 
n = getInputInt()
data = getInputListInt()
l = len(data)
 
ans = []
 
for i in range(l-1, -1, -1):
    cnt = 0
    for j in ans:
        if j % (i+1) == 0:
            cnt += 1
    if data[i] != cnt % 2:
        ans.append(i+1)
 
if len(ans) == 0:
    print(0)
else:
    print(len(ans))
    print(*ans, sep=" ")

Buggy submission (verdict: Runtime Error):
import math
import copy
from copy import deepcopy
import sys
import fractions
import numpy as np
from functools import reduce
import statistics
import heapq

input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = getInputInt()
data = getInputListInt()
l = len(data)

ans = []

for i in range(l-2, -1, -1):
    cnt = 0
    for j in ans:
        if j % (i+1) == 0:
            cnt += 1
    if data[i] != cnt % 2:
        ans.append(i+1)

if len(ans) == 0:
    print(0)
else:
    print(len(ans))
    print(*ans, sep=" ")

Buggy submission (verdict: Runtime Error):
import math
import copy
from copy import deepcopy
import sys
import fractions
import numpy as np
from functools import reduce
import statistics
import heapq

input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = getInputInt()
data = getInputListInt()
l = len(data)

ans = []

for i in range(l-1, -1, -1):
    cnt = 0
    for j in ans:
        if j % (i+1) == 0:
            cnt += 1
    if data[i] != cnt % 2:
        ans.append(i+1)

if len(ans) == 0:
    print(0)
else:
    print(len(ans))
    print(*ans, sep=" ")

Buggy submission (verdict: Runtime Error):
import math
import copy
from copy import deepcopy
import sys
import fractions
import numpy as np
from functools import reduce
import statistics
import heapq

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input()).rstrip("\n")
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split().rstrip("\n")
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = getInputInt()
data = getInputListInt()
l = len(data)

ans = []

for i in range(l-1, -1, -1):
    cnt = 0
    for j in ans:
        if j % (i+1) == 0:
            cnt += 1
    if data[i] != cnt % 2:
        ans.append(i+1)

if len(ans) == 0:
    print(0)
else:
    print(len(ans))
    print(*ans, sep=" ")

Buggy submission (verdict: Runtime Error):
import math
import copy
from copy import deepcopy
import sys
import fractions
import numpy as np
from functools import reduce
import statistics
import heapq

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = getInputInt()
data = getInputListInt()
l = len(data)

ans = []

for i in range(l-1, -1, -1):
    cnt = 0
    for j in ans:
        if j % (i+1) == 0:
            cnt += 1
    if data[i] != cnt % 2:
        ans.append(i+1)

if len(ans) == 0:
    print(0)
else:
    print(len(ans))
    print(*ans, sep=" ")