Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
211 5
31 41 59 26 53


Fixed submission:
h,n = map(int,input().split())
a = [int(i) for i in input().split()]
b = sum(a)
ans = 'Yes'
if b < h:
    ans = 'No'
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
h,n = map(int,input().split())


ab = []
for i in range(n):
    ab.append([int(i) for i in input().split()])
ab.sort()

dp = []
for i in range(h + ab[n-1][0]):
    dp.append(pow(2, 31) - 1)
dp[0] = 0

for i in range(1, len(dp)):
    tmp = dp[i]
    for j in range(n):
        #print(j-ab[j][0])
        tmp = min(tmp, dp[max(0, i-ab[j][0])]+ab[j][1])
    dp[i] = tmp

#print(dp)
print(min(dp[h:]))

Fixed submission:
import math
h,n = map(int,input().split())


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

dp = []
for i in range(h + max(a)):
    dp.append(pow(2, 31) - 1)
dp[0] = 0

for i in range(1, len(dp)):
    '''
    tmp = dp[i]
    for j in range(n):
        tmp = min(tmp, dp[max(0, i-a[j])] + b[j])
    dp[i] = tmp
    '''
    dp[i] = min(dp[i - A] + B for A, B in zip(a, b))

print(min(dp[h:]))

Buggy python submission (verdict: Runtime Error):
import math
h,n = map(int,input().split())

dp = []
for i in range(n):
    a, b = map(int,input().split())
    if i == 0:
        for j in range(h):
            dp.append(math.ceil((j + 1) / a) * b)
    for j in range(h):
        if dp[j] > dp[j - a] + b:
            dp[j] = dp[j - a] + b
print(dp[h - 1])

Fixed submission:
import math
h,n = map(int,input().split())


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

dp = []
for i in range(h + max(a)):
    dp.append(pow(2, 31) - 1)
dp[0] = 0

for i in range(1, len(dp)):
    '''
    tmp = dp[i]
    for j in range(n):
        tmp = min(tmp, dp[max(0, i-a[j])] + b[j])
    dp[i] = tmp
    '''
    dp[i] = min(dp[i - A] + B for A, B in zip(a, b))

print(min(dp[h:]))
Buggy python submission (verdict: Time Limit Exceeded):
import copy
n = int(input())
xl = []
for i in range(n):
    xl.append([int(i) for i in input().split()])
    xl[i].append(xl[i][0] - xl[i][1])
    xl[i].append(xl[i][0] + xl[i][1])
xl.sort(key=lambda x: x[3])
ng = []
ans = 0
for i in range(n):
    tmp = list(range(xl[i][2] + 1, xl[i][3]))
    a = copy.deepcopy(tmp) #動く範囲
    a.extend(ng)
    if len(set(a)) == len(a):
        ng.extend(tmp)
        ans += 1
print(ans)


Fixed submission:
n = int(input())
robot = []
for i in range(n):
    x, l = map(int,input().split())
    robot.append([x + l, x - l]) #left, right
robot.sort()
preright = robot[0][1]
ans = 0
for i in range(n):
    left = robot[i][1]
    #print(preright, left)
    if preright <= left:
        ans += 1
        preright = robot[i][0]
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

s, t = STR()
print(s + t)

Fixed submission:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

s, t = S_MAP()
print(t + s)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split()]

i = 0
ans = 0
while i < len(a):
    if not a[i] == i + 1:
        del a[i]
        ans += 1
        i -= 1
    i += 1
if len(a) == 0:
    print(-1)
else:
    print(ans)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]

i = 0
ans = 0
tmp = 1
for i in range(n):
    if a[i] == tmp:
        tmp += 1
    else:
        ans += 1

if ans == n:
    print(-1)
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
if n % 2 != 0:
    print(0)
    exit()
l = math.ceil(math.log(n, 5))
#print(l)
ans = 0
for i in range(1, l + 1):
    #print(pow(5, i), n // pow(5, i))
    ans += n // pow(5, i) // 2
print(ans)

Fixed submission:
n = int(input())
if n % 2 == 1:
    print(0)
else:
    ans = 0
    for i in range(1, 26):
        if 5 ** i < n:
            ans += n // 2 // (5 ** i)
    print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
if n % 2 == 1:
    print(0)
else:
    ans = 1
    import math
    for i in range(1, int(math.log(n, 5))):
        ans += n // 2 // (5 ** i)
    print(ans)




Fixed submission:
n = int(input())
if n % 2 == 1:
    print(0)
else:
    ans = 0
    for i in range(1, 26):
        if 5 ** i < n:
            ans += n // 2 // (5 ** i)
    print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = list(str(input()))

for i in range(len(s)):
    tmp = ord(s[i]) + n
    if tmp > ord('Z')
        s[i] = chr(tmp - ord('Z'))
    else:
        s[i] = chr(tmp)

ans = ''
for i in range(len(s)):
    ans += s[i]

print(ans)

Fixed submission:
n = int(input())
s = list(str(input()))

for i in range(len(s)):
    tmp = ord(s[i]) + n
    if tmp > ord('Z'):
        tmp -= ord('Z') - ord('A') + 1
    s[i] = chr(tmp)

ans = ''
for i in range(len(s)):
    ans += s[i]

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10000)

def cmb(n, r, prime):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n % prime

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] = numerator[k - offset] // pivot
                denominator[k] = denominator[k] // pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result = (result % prime) * (numerator[k] % prime)
    result = result % prime
    return result




def mod_combination(n, k, mod):
    # nCk (mod m)
    def mod_permutation(n, k, mod):
        if n<=k:
            return 1
        else:
            return (n * mod_permutation(n-1,k,mod))%mod

    def mod_inv_permutation(k, mod):
        k, mod = int(k), int(mod)
        if k<=1:
            return 1
        else:
            return (pow(k,mod-2,mod) * mod_inv_permutation(k-1, mod))%mod

    return (mod_permutation(n,n-k,mod) * mod_inv_permutation(k, mod))%mod


def comb(n,k,p):
    """power_funcを用いて(nCk) mod p を求める"""
    from math import factorial
    if n<0 or k<0 or n<k: return 0
    if n==0 or k==0: return 1
    a=factorial(n) %p
    b=factorial(k) %p
    c=factorial(n-k) %p
    return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p

def power_func(a,b,p):
    """a^b mod p を求める"""
    if b==0: return 1
    if b%2==0:
        d=power_func(a,b//2,p)
        return d*d %p
    if b%2==1:
        return (a*power_func(a,b-1,p ))%p

x,y = map(int, input().split())

ans = 0
if (x + y) % 3 != 0:
    ans = 0
else:
    a = (x + y) // 3
    b = (2*x - y) // 3
    #ans = cmb(a,b, pow(10,9) + 7)
    ans = mod_combination(a,b,pow(10,9) + 7)

print(ans)


Fixed submission:
def cmb(n, r, prime):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n % prime

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] = numerator[k - offset] // pivot
                denominator[k] = denominator[k] // pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= numerator[k]
    
    result = result % prime
    return result


x,y = map(int, input().split())

ans = 0

if (x + y) % 3 == 0 and 2*x - y >= 0 and 2*y - x >= 0:
    a = (x + y) // 3
    b = (2*x - y) // 3
    ans = cmb(a,b, pow(10,9) + 7)
    #ans = mod_combination(a,b,pow(10,9) + 7)

print(ans)
Buggy python submission (verdict: Runtime Error):
def calcsum(n):
    return n * (n + 1) // 2

s = str(input())
n = len(s) + 1
arrk = []
arrg = []
tmp = s[0]
cnt = 1
for i in range(1, n-1):
    if s[i] == tmp:
        cnt += 1
    elif s[i] != tmp:
        if tmp == '<':
            arrk.append(cnt)
        else:
            arrg.append(cnt)
        cnt = 1
        tmp = s[i]
if tmp == '<':
    arrk.append(cnt)
else:
    arrg.append(cnt)
#print(arrk, arrg)
ans = 0
for i in range(len(arrk)):
    #print(calcsum(arrk[i]-1))
    ans += calcsum(arrk[i]-1)
for i in range(len(arrg)):
    #print(calcsum(arrg[i]-1))
    ans += calcsum(arrg[i]-1)
#print('ans',ans)
if s[0] == '<':
    for i in range(len(arrg)):
        #print('a', max(arrg[i], arrk[i]))
        ans += max(arrg[i], arrk[i])
    if len(arrg) > len(arrk):
        ans += arrg[len(arrg)-1]
    elif len(arrk) > len(arrg):
        ans += arrk[len(arrk)-1]
elif s[0] == '>':
    ans += arrg[0]
    for i in range(len(arrk)-1):
        #print('a', max(arrg[i+1], arrk[i]))
        ans += max(arrg[i+1], arrk[i])
    if len(arrg) > len(arrk):
        ans += arrg[len(arrg)-1]
    elif len(arrk) > len(arrg):
        ans += arrk[len(arrk)-1]
    else:
        if s[n-2] == '<':
        ans += arrk[len(arrk)-1]
print(ans)


Fixed submission:
def calcsum(n):
    return n * (n + 1) // 2

s = str(input())
n = len(s) + 1
arrk = []
arrg = []
tmp = s[0]
cnt = 1
for i in range(1, n-1):
    if s[i] == tmp:
        cnt += 1
    elif s[i] != tmp:
        if tmp == '<':
            arrk.append(cnt)
        else:
            arrg.append(cnt)
        cnt = 1
        tmp = s[i]
if tmp == '<':
    arrk.append(cnt)
else:
    arrg.append(cnt)
#print(arrk, arrg)
ans = 0
for i in range(len(arrk)):
    #print(calcsum(arrk[i]-1))
    ans += calcsum(arrk[i]-1)
for i in range(len(arrg)):
    #print(calcsum(arrg[i]-1))
    ans += calcsum(arrg[i]-1)
#print('ans',ans)
l = min(len(arrg), len(arrk))
m = max(len(arrg), len(arrk))
#print(l, len(arrg), len(arrk))
if s[0] == '<':
    for i in range(l):
        ans += max(arrg[i], arrk[i])
    if l < len(arrk):
        ans += arrk[len(arrk) - 1]
elif s[0] == '>':
    ans += arrg[0]
    #print(arrg[0])
    if l != m:
        for i in range(l):
            #print('a', arrg[i+1], arrk[i], max(arrg[i+1], arrk[i]))
            ans += max(arrg[i+1], arrk[i])
    else:
        for i in range(l-1):
            #print('a', arrg[i+1], arrk[i], max(arrg[i+1], arrk[i]))
            ans += max(arrg[i+1], arrk[i])
    if s[n-2] == '<':
        ans += arrk[len(arrk) - 1]
    if l < len(arrk):
        ans += arrk[len(arrk) - 1]
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

s = STR()
k = INT()
ans = 0
i = 0
while i < len(s):
    tmp = 1
    for j in range(i + 1, len(s)):
        if s[i] == s[j]:
            tmp += 1
        else:
            i = j - 1
            break
    tmp //= 2
    ans += tmp
    i += 1
ans *= k
if s[0] == s[-1] and s[-1] != s[-2]:
    ans += k - 1
print(ans)

Fixed submission:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

s = STR()
k = INT()
ans = 0
a = 0
b = 0
if s[0] == s[-1]:
    if len(set(s)) == 1:
        ans = len(s) * k // 2
        print(ans)
        exit()
    for j in range(len(s)):
        if s[0] == s[j]:
            a += 1
        else:
            break
    for j in reversed(range(len(s))):
        if s[-1] == s[j]:
            b += 1
        else:
            break
    ans = a // 2 + b // 2 + (a + b) // 2 * (k - 1)
i = a
ans2 = 0
while i < len(s) - b:
    tmp = 1
    for j in range(i + 1, len(s)):
        if s[i] == s[j]:
            tmp += 1
        else:
            break
    i += tmp
    tmp //= 2
    ans2 += tmp
print(ans + ans2 * k)
Buggy python submission (verdict: Time Limit Exceeded):
#https://atcoder.jp/contests/abc139/tasks/abc139_b

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

x = 0
i = 0
while True:
    x = a + (a-1)*i
    if x<b:
        i+=1

print(i)

Fixed submission:
#https://atcoder.jp/contests/abc139/tasks/abc139_b

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

c = a-1
cnt=0
'''
cnt = b // c
if b%c>1:
    cnt+=1
print(cnt)
'''
'''
b-=a
cnt = 1
if b>0:
    while True:
        if b>0:
            b-=c
            cnt+=1
        else:
            break
'''
while True:
    if b>1:
        b-=c
        cnt+=1
    else:
        break
print(cnt)
Buggy python submission (verdict: Runtime Error):
#https://atcoder.jp/contests/abc139/tasks/abc139_c

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

a = []

for i in range(n-1):
    a.append(h[i+1]-h[i])

cnt = []
tmp=0
for i in range(len(a)):
    if a[i] <= 0:
        tmp+=1
        if i == len(a)-1:
            cnt.append(tmp)
    else:
        cnt.append(tmp)
        tmp=0
    
cnt.sort(reverse=True)

#print(a,cnt)
print(cnt[0])

Fixed submission:
#https://atcoder.jp/contests/abc139/tasks/abc139_c

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

cnt = []
if n!=1:
    a = []
    for i in range(n-1):
        a.append(h[i+1]-h[i])

    tmp=0
    for i in range(len(a)):
        if a[i] <= 0:
            tmp+=1
            if i == len(a)-1:
                cnt.append(tmp)
        else:
            cnt.append(tmp)
            tmp=0
else:
    cnt.append(0)

cnt.sort(reverse=True)

#print(a,cnt)
print(cnt[0])
Buggy python submission (verdict: Time Limit Exceeded):
#https://atcoder.jp/contests/abc139/tasks/abc139_d

n = int(input())

a = 0
for i in range(1,n):
    a+=i

print(a)

Fixed submission:
#https://atcoder.jp/contests/abc139/tasks/abc139_d

n = int(input())

a = (n-1)*n // 2

print(a)
Buggy python submission (verdict: Runtime Error):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n = INT()
v = LIST()
v.sort()
v = deque(v)
for i in range(n - 1):
    v1 = v.popleft()
    v2 = v.popleft()
    v.insert(0, (v1 + v2) / 2)
print(v[0])

Fixed submission:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n = INT()
v = LIST()
v.sort()
v = deque(v)
for i in range(n - 1):
    v1 = v.popleft()
    v2 = v.popleft()
    v.appendleft((v1 + v2) / 2)
print(v[0])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

for i in range(n):
    c = sorted(a,reverse = True)
    if c[0] == a[i]:
        b = c[1]
    else:
        b = c[0]
    print(b)

Fixed submission:
import sys
input = sys.stdin.readline

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

c = sorted(a,reverse = True)

for i in range(n):
    if c[0] == a[i]:
        b = c[1]
    else:
        b = c[0]
    print(b)

Buggy python submission (verdict: Time Limit Exceeded):
#https://atcoder.jp/contests/abc134/tasks/abc134_c

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

for i in range(n):
    b = max(a)
    if b == a[i]:
        c = sorted(a,reverse = True)
        b = c[1]
    print(b)

Fixed submission:
import sys
input = sys.stdin.readline

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

c = sorted(a,reverse = True)

for i in range(n):
    if c[0] == a[i]:
        b = c[1]
    else:
        b = c[0]
    print(b)
Buggy python submission (verdict: Time Limit Exceeded):
#https://atcoder.jp/contests/abc134/tasks/abc134_d
import sys
input = sys.stdin.readline

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

b = [0] * n
for i in reversed(range(1, n + 1)):
    s = 0
    for j in range(1, n + 1):
        if j % i == 0 and j != i:
            s += a[j - 1]
    
    if s % 2 == a[i - 1]:
        b[i - 1] = 0
    else:
        b[i - 1] = 1
#print(b)
e = sum(b)
print(e)

if e != 0:
    d = []
    for i in range(n):
        if b[i] == 1:
            d.append(i + 1)
    print(' '.join(map(str, d)))

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]
arr = [0 for _ in range(n)]
for i in reversed(range(n)):
    s = 0
    for j in range(i, n, i+1):
        s += arr[j]
    s %= 2
    if a[i] != s:
        arr[i] = 1
print(sum(arr))
for i in range(n):
    if arr[i] == 1:
        print(i+1, end=' ')
print('')

Buggy python submission (verdict: Time Limit Exceeded):
#https://atcoder.jp/contests/abc134/tasks/abc134_d
n = int(int(input()))
a = [int(i) for i in input().split()]

b = [0] * n
for i in reversed(range(1, n + 1)):
    cnt = 0
    c = []
    for j in range(1, n + 1):
        if j % i == 0 and j != i:
            cnt += 1
            c.append(j)
    s = 0
    for j in c:
        s += a[j - 1]
    #print(i, cnt, c, s)
    if s % 2 == a[i - 1]:
        b[i - 1] = 0
    else:
        b[i - 1] = 1
#print(b)
e = sum(b)
print(e)

if e != 0:
    d = []
    for i in range(n):
        if b[i] == 1:
            d.append(i + 1)
    print(' '.join(map(str, d)))

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]
arr = [0 for _ in range(n)]
for i in reversed(range(n)):
    s = 0
    for j in range(i, n, i+1):
        s += arr[j]
    s %= 2
    if a[i] != s:
        arr[i] = 1
print(sum(arr))
for i in range(n):
    if arr[i] == 1:
        print(i+1, end=' ')
print('')
Buggy python submission (verdict: Time Limit Exceeded):
import sys

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

l,r = map(int,input().split())
mod = 2019
a = range(l, r + 1)
for i in range(mod):
    m = l * (l + 1)
    M = (r - 1) * r
    for j in range(m // mod, M // mod + 1):
        b = j * mod + i
        c = make_divisors(b)
        #print(b, c)
        for k in c:
            d = b // k
            #print(k, d)
            if k != d and l <= k and k <= r and l <= d and d <= r:
                #print('i: ',end='')
                print(i)
                sys.exit()


Fixed submission:
l,r = map(int,input().split())
ans = 2018
for i in range(l, min(r, l + 2019)):
    for j in range(i + 1, min(r + 1, i + 2020)):
        ans = min(ans, (i * j) % 2019)
print(ans)