Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 998244353


n = INT()
d = MAP()

if d[0]!=0:
    print(0)
    exit(0)

l = [d.count(i) for i in range(max(d)+1)]
ans=1
for i in range(1,max(d)+1):
    ans*=pow(l[i-1],l[i],MOD)
    ans %= MOD
print(ans)

Fixed submission:
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 998244353


n = INT()
d = MAP()

if d[0]!=0 or not all(d[1:]):
    print(0)
    exit(0)

l = [0]*(max(d)+1)
for i in d:
    l[i]+=1

ans=1
for i in range(1,max(d)+1):
    ans*=pow(l[i-1],l[i],MOD)
    ans %= MOD
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 998244353


n = INT()
d = MAP()

if d[0]!=0:
    print(0)
    exit(0)

ans=1
for i in range(1,max(d)+1):
    ans*=pow(d.count(i-1),d.count(i),MOD)
    ans %= MOD
print(ans)

Fixed submission:
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 998244353


n = INT()
d = MAP()

if d[0]!=0 or not all(d[1:]):
    print(0)
    exit(0)

l = [0]*(max(d)+1)
for i in d:
    l[i]+=1

ans=1
for i in range(1,max(d)+1):
    ans*=pow(l[i-1],l[i],MOD)
    ans %= MOD
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 998244353


n = INT()
d = MAP()

if d[0]!=0:
    print(0)
    exit(0)

ans=1
for i in range(1,max(d)+1):
    ans*=pow(d.count(i-1),d.count(i),MOD)
    ans %= MOD
print(ans)

Fixed submission:
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 998244353


n = INT()
d = MAP()

if d[0]!=0 or not all(d[1:]):
    print(0)
    exit(0)

l = [0]*(max(d)+1)
for i in d:
    l[i]+=1

ans=1
for i in range(1,max(d)+1):
    ans*=pow(l[i-1],l[i],MOD)
    ans %= MOD
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7
from math import factorial
def comb(n,r):
    return factorial(n) // (factorial(r) * factorial(n - r))

n = INT()
l = MAP()

l.sort()
res=0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if l[i]+l[j]<=l[k]:
                res+=n-k
                break
        else:
            break


print(comb(n,3)-res)

Fixed submission:
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7


n = INT()
l = MAP()

l.sort()
ans=0
for i in range(n):
    for j in range(i+1,n):
        idx = bisect.bisect_left(l,l[i]+l[j])
        ans+=idx-j-1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7
from math import factorial
def comb(n,r):
    return factorial(n) // (factorial(r) * factorial(n - r))

n = INT()
l = MAP()

l.sort()
res=0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if l[i]+l[j]<=l[k]:
                res+=n-k
                break
        else:
            break


print(comb(n,3)-res)

Fixed submission:
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7


n = INT()
l = MAP()

l.sort()
ans=0
for i in range(n):
    for j in range(i+1,n):
        idx = bisect.bisect_left(l,l[i]+l[j])
        ans+=idx-j-1

print(ans)
Buggy python submission (verdict: Runtime Error):
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n = INT()
if n%2==0:
    print(n/2)
else:
    print(math.ceil(n/2)/n)

Fixed submission:
import math
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n = INT()
if n%2==0:
    print(0.5)
else:
    print(math.ceil(n/2)/n)
Buggy python submission (verdict: Time Limit Exceeded):
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n = INT()
a = MAP()
res=[]

for i in range(1,n+1):
    print(a.index(i)+1,end=" ")
print()


Fixed submission:
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n = INT()
a = MAP()
res=[0]*n

for i in range(n):
    res[a[i]-1]=i+1
print(*res)

Buggy python submission (verdict: Time Limit Exceeded):
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n = INT()
a = MAP()
res=[]

for i in range(1,n+1):
    res.append(a.index(i)+1)
print(*res)

Fixed submission:
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n = INT()
a = MAP()
res=[0]*n

for i in range(n):
    res[a[i]-1]=i+1
print(*res)
Buggy python submission (verdict: Time Limit Exceeded):
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

def prime(num):
    for i in range(2,int(math.sqrt(num))+1):
        if num%i==0:
            return False
    return True

a,b = MAP()
ans = 0
for i in range(1,min(a,b)+1):
    if (a%i==0) and (b%i==0):
        if prime(i):
            ans+=1

print(ans)

Fixed submission:
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

a,b = MAP()
print(len(set(prime_factorize(a)) & set(prime_factorize(b)))+1)
Buggy python submission (verdict: Time Limit Exceeded):
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n,m = MAP()
a = MAP()

for i in range(m):
    idx = a.index(max(a))
    a[idx] = a[idx]//2

print(sum(a))

Fixed submission:
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n,m = MAP()
a = MAP()
a = [-i for i in a]
heapify(a)
for i in range(m):
    tmp = -heappop(a)
    heappush(a,-(tmp//2))
print(-sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n,m = MAP()
a = MAP()

for i in range(m):
    idx = a.index(max(a))
    a[idx] = a[idx]//2

print(sum(a))

Fixed submission:
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n,m = MAP()
a = MAP()
a = [-i for i in a]
heapify(a)
for i in range(m):
    tmp = -heappop(a)
    heappush(a,-(tmp//2))
print(-sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n,m = MAP()
a = MAP()
a.sort()

for i in range(m):
    a[len(a)-1] = a[len(a)-1]//2
    a.sort()

print(sum(a))

Fixed submission:
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n,m = MAP()
a = MAP()
a = [-i for i in a]
heapify(a)
for i in range(m):
    tmp = -heappop(a)
    heappush(a,-(tmp//2))
print(-sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

def get_keys_from_value(d, val):
    return [k for k, v in d.items() if v == val]

n = INT()
s = input()

di = {}
ans=0

for start in range(n):
    for end in range(start,n):
        di[(start,end)] = s[start:end+1]

for k,v in di.items():
    tmp = di[k]
    di[k]=0
    if tmp in di.values():
        keys = get_keys_from_value(di,tmp)
        for i in keys:
            if k[1]<i[0]:
                ans = max(ans,len(tmp))

print(ans)


Fixed submission:
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n = INT()
s = input()

a=0
i=0
j=1

while j<n:
    if s[i:j] in s[j:]:
        a = max(a,len(s[i:j]))
        j+=1
    else:
        i+=1
    if i==j:
        i+=1
        j+=2

print(a)

Buggy python submission (verdict: Time Limit Exceeded):
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

def get_keys_from_value(d, val):
    return [k for k, v in d.items() if v == val]

n = INT()
s = input()

di = {}
ans=0

for start in range(n):
    for end in range(start,n):
        di[(start,end)] = s[start:end+1]

for k,v in di.items():
    tmp = di[k]
    di[k]=0
    if tmp in di.values():
        keys = get_keys_from_value(di,tmp)
        for i in keys:
            if k[1]<i[0]:
                ans = max(ans,len(tmp))

print(ans)


Fixed submission:
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n = INT()
s = input()

a=0
i=0
j=1

while j<n:
    if s[i:j] in s[j:]:
        a = max(a,len(s[i:j]))
        j+=1
    else:
        i+=1
    if i==j:
        i+=1
        j+=2

print(a)
Buggy python submission (verdict: Runtime Error):
a,b = MAP()
ans=1
while a<b:
    a += a-1
    ans += 1
print(ans)

Fixed submission:
def MAP(): return map(int,input().split())
import math

a,b = MAP()
print(math.ceil((b-a)/(a-1))+1)
Buggy python submission (verdict: Runtime Error):
def dfs(v,p):
    for i in tree[v]:
        if i==p:
            continue
        res[i]+=res[v]
        dfs(i,v)

n,q = map(int, input().split())
tree = [[] for _ in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

res = [0]*n
for i in range(q):
    p,x = map(int,input().split())
    res[p-1] += x

dfs(0,-1)
print(*res)

Fixed submission:
a = int(input())
s=input()

if a>=3200:
    print(s)
else:
    print("red")
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)
t = input()

s = list(s+s)
ans=0
start = 0
for ch in t:
    if ch in s:
        tmp = s[start:start+n]
        ans += tmp.index(ch)+1
        start = (start+tmp.index(ch)+1)%n
    else:
        print(-1)
        exit(0)

print(ans)

Fixed submission:
import collections
import bisect

d = collections.defaultdict(list)
s = input()
t = input()
for i,S in enumerate(s,1):
    d[S].append(i)
k=0
ans=0
for ch in t:
    l = d[ch]
    if len(l)==0:
        print(-1)
        exit(0)
    if l[-1]<=ans:
        ans=l[0]
        k+=1
    else:
        ans=l[bisect.bisect_right(l,ans)]

print(len(s)*k+ans)

Buggy python submission (verdict: Time Limit Exceeded):

s = list(input())
t = input()
tmp=0
ans=0
flag=True
for ch in t:
    if ch in s:
        while ch != s[tmp]:
            ans += 1
            tmp = (tmp+1)%len(s)
        ans += 1
        tmp = (tmp+1)%len(s)
    else:
        flag = False
        break

if flag:
    print(ans)
else:
    print(-1)

Fixed submission:
import collections
import bisect

d = collections.defaultdict(list)
s = input()
t = input()
for i,S in enumerate(s,1):
    d[S].append(i)
k=0
ans=0
for ch in t:
    l = d[ch]
    if len(l)==0:
        print(-1)
        exit(0)
    if l[-1]<=ans:
        ans=l[0]
        k+=1
    else:
        ans=l[bisect.bisect_right(l,ans)]

print(len(s)*k+ans)
Buggy python submission (verdict: Time Limit Exceeded):

import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def change_dict(string):
	dic = {}
	for ch in set(string):
		dic[ch] = string.count(ch)
	return dic

n = int(input())
st = []
for i in range(n):
	st.append(change_dict(input()))
ans = 0

lst = []
for i in st:
	if (st.count(i)>=2) and (not(i in lst)):
		ans += combinations_count(st.count(i),2)
		lst.append(i)

print(ans)





Fixed submission:
n = int(input())
dic = {}
ans = 0
for i in range(n):
	tmp = list(input())
	sorted_str = "".join(sorted(tmp))
	if not(sorted_str in dic):
		dic[sorted_str] = 0
	else:
		dic[sorted_str] += 1
		ans += dic[sorted_str]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def change_dict(string):
	dic = {}
	for ch in set(string):
		dic[ch] = string.count(ch)
	return dic

n = int(input())
st = []
for i in range(n):
	st.append(change_dict(input()))
cnt = 0

for i in range(n-1):
	for j in range(i+1,n):
		if st[i]==st[j]:
			cnt+=1

print(cnt)

Fixed submission:
n = int(input())
dic = {}
ans = 0
for i in range(n):
	tmp = list(input())
	sorted_str = "".join(sorted(tmp))
	if not(sorted_str in dic):
		dic[sorted_str] = 0
	else:
		dic[sorted_str] += 1
		ans += dic[sorted_str]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#標準入力受け取り
N, M = list(map(int, input().split()))
jobs = [[] for _ in range(M)]

for i in range(N):
    d, r = list(map(int, input().split()))
    if d-1 < M:
        jobs[d-1].append(r)

#解法
rewards = 0
li = []
for i in range(M):
    #候補をリストに追加(給料が間に合うもの仕事が一日ごとに増える)
    li.extend(jobs[i])
    if len(li) >0:
        #最大値を求める(給料が高いバイトをしたい)
        reward = max(li)
        rewards += reward
        #使った値は取り除く(同じバイトはNGのため)
        li.remove(reward)

print(rewards)

Fixed submission:
import heapq
#標準入力受け取り
N, M = list(map(int, input().split()))
jobs = [[] for _ in range(M)]

for i in range(N):
    d, r = list(map(int, input().split()))
    if d-1 < M:
        jobs[d-1].append(-r)

#解法
rewards = 0
heap = []
for i in range(M):
	for reward in jobs[i]:
		heapq.heappush(heap,reward)

	if len(heap)>0:
		reward = heapq.heappop(heap)
		rewards += -reward

print(rewards)

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
a = []
b = []
for i in range(n):
	k,l = map(int,input().split())
	a.append(k)
	b.append(l)

ans = 0
for v in range(1,m+1):
	tmp = [i for i,x in enumerate(a) if x <= v]
	if len(tmp)!=0:
		b_list = [b[i] for i in tmp]
		max_index = tmp[b_list.index(max(b_list))]
		ans += b[max_index]
		del(a[max_index])
		del(b[max_index])
print(ans)

Fixed submission:
import heapq
#標準入力受け取り
N, M = list(map(int, input().split()))
jobs = [[] for _ in range(M)]

for i in range(N):
    d, r = list(map(int, input().split()))
    if d-1 < M:
        jobs[d-1].append(-r)

#解法
rewards = 0
heap = []
for i in range(M):
	for reward in jobs[i]:
		heapq.heappush(heap,reward)

	if len(heap)>0:
		reward = heapq.heappop(heap)
		rewards += -reward

print(rewards)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
S = list(S)
import math
lst = []
switch = "R"
tmp = ""
for i in range(len(S)):
	if S[i]==switch:
		tmp += S[i]
		if i==len(S)-1:
			lst.append(tmp)
	else:
		lst.append(tmp)
		tmp = S[i]
		if i==len(S)-1:
			lst.append(tmp)
		if switch is "R":
			switch = "L"
		else:
			switch = "R"
ls = []
for i in range(0,len(lst),2):
	ls.append(list(lst[i]+lst[i+1]))

for l in ls:
	for i in range(len(l)):
		if l[i] == "L":
			l_num = i
			break
	r_count = math.ceil(((i+1)/2)) + (len(l)-(i+1))//2
	l_count = len(l) - r_count
	l[l_num-1] = l_count
	l[l_num] = r_count

ls = sum(ls,[])
for i in ls:
	if (i=="R") or (i=="L"):
		print("0 ",end="")
	else:
		print(i,end=" ")
print()


Fixed submission:
s = input()
n = len(s)

ret = [0]*n

for i in range(n-1):
	if s[i:i+2] == "RL":
		for j in range(i,-1,-1):
			if s[j] == "R":
				ret[i + (i+j)%2] += 1
			else:
				break
		for j in range(i+1,n):
			if s[j] == "L":
				ret[i + (i+j)%2] += 1
			else:
				break

print(" ".join(map(str,ret)))
Buggy python submission (verdict: Time Limit Exceeded):

s=list(input())
l=len(s)
mod=10**9+7
dp=[0]*13
dp[0] = 1
mul=1
for i in s[::-1]:
    nextDp=[0]*13
    if i=="?":
        for k in range(10):
            for j in range(13):
                nextDp[(k*mul+j)%13] += dp[j]
                #nextDp[(k*mul+j)%13]%=mod
    else:
        for j in range(13):
            nextDp[(int(i)*mul+j)%13] += dp[j]
            #nextDp[(int(i)*mul+j)%13]%=mod
    mul *= 10
    dp = nextDp

print(dp[5]%mod)

Fixed submission:
MOD = 10**9 + 7
S = input()
 
cur = [0] * 13
cur[0] = 1
r = 1
base = 0
for i in range(len(S)):
    s = S[-(i+1)]
    if s == '?':
        prev = cur
        cur = [sum(prev)] * 13
        for m in range(13):
            for d in range(10,13):
                cur[(m + r*d) % 13] -= prev[m]
        for m in range(13):
            cur[m] %= MOD
    else:
        base = (base + r*int(s)) % 13
 
    r = (10 * r) % 13
 
print(cur[(5-base) % 13])

Buggy python submission (verdict: Time Limit Exceeded):

s=list(input())
l=len(s)
mod=10**9+7
dp=[0]*13
dp[0] = 1
mul=1
for i in s[::-1]:
    nextDp=[0]*13
    if i=="?":
        for k in range(10):
            for j in range(13):
                nextDp[(k*mul+j)%13] += dp[j]
                nextDp[(k*mul+j)%13]%=mod
    else:
        for j in range(13):
            nextDp[(int(i)*mul+j)%13] += dp[j]
            nextDp[(int(i)*mul+j)%13]%=mod
    mul *= 10
    dp = nextDp

print(dp[5])

Fixed submission:
MOD = 10**9 + 7
S = input()
 
cur = [0] * 13
cur[0] = 1
r = 1
base = 0
for i in range(len(S)):
    s = S[-(i+1)]
    if s == '?':
        prev = cur
        cur = [sum(prev)] * 13
        for m in range(13):
            for d in range(10,13):
                cur[(m + r*d) % 13] -= prev[m]
        for m in range(13):
            cur[m] %= MOD
    else:
        base = (base + r*int(s)) % 13
 
    r = (10 * r) % 13
 
print(cur[(5-base) % 13])

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
l=len(s)
mod=10**9+7
dp=[[0 for j in range(13)] for i in range(l+1)]
dp[0][0]=1
for i in range(l):
    if s[i]=='?':
        for j in range(10):
            for k in range(13):
                dp[i+1][(k*10+j)%13]+=dp[i][k]%mod
    else:
        for k in range(13):
            dp[i+1][(k*10+int(s[i]))%13]+=dp[i][k]%mod
print(dp[-1][5]%mod)


Fixed submission:
MOD = 10**9 + 7
S = input()
 
cur = [0] * 13
cur[0] = 1
r = 1
base = 0
for i in range(len(S)):
    s = S[-(i+1)]
    if s == '?':
        prev = cur
        cur = [sum(prev)] * 13
        for m in range(13):
            for d in range(10,13):
                cur[(m + r*d) % 13] -= prev[m]
        for m in range(13):
            cur[m] %= MOD
    else:
        base = (base + r*int(s)) % 13
 
    r = (10 * r) % 13
 
print(cur[(5-base) % 13])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = []
for i in range(N):
    a.append(int(input()))

for i in range(N):
    tmp,a[i] = a[i],0
    print(max(a))
    a[i] = tmp

Fixed submission:
N = int(input())
a = []
for i in range(N):
    a.append(int(input()))

sorted_list = sorted(a,reverse=True)
first = sorted_list[0]
secend = sorted_list[1]

for num in a:
    if num != first:
        print(first)
    else:
        print(secend)
Buggy python submission (verdict: Runtime Error):
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)

Fixed submission:
n = int(input())
*a, = map(int,input().split())
box = [0]*n
for i in range(n,0,-1):
    sum_box = 0
    for j in range(i,n+1,i):
        sum_box+=box[j-1]
    if sum_box%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+1)
    print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
*a, = map(int,input().split())
box = [0]*n
cnt=0
ans=[]
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]:
        ans.insert(0,i)
        cnt+=1
        box[i-1]+=1

if cnt!=0:
    print(cnt)
    print(*ans)
else:
    print(0)

Fixed submission:
n = int(input())
*a, = map(int,input().split())
box = [0]*n
for i in range(n,0,-1):
    sum_box = 0
    for j in range(i,n+1,i):
        sum_box+=box[j-1]
    if sum_box%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+1)
    print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
*a, = map(int,input().split())
box = [0]*n
cnt=0
ans=[]
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]:
        ans.insert(0,i)
        cnt+=1
        box[i-1]+=1

if cnt!=0:
    print(cnt)
    print(*ans)
else:
    print(0)

Fixed submission:
n = int(input())
*a, = map(int,input().split())
box = [0]*n
for i in range(n,0,-1):
    sum_box = 0
    for j in range(i,n+1,i):
        sum_box+=box[j-1]
    if sum_box%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+1)
    print(*ans)