Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
H,N=map(int,input().split())

A=[]
B=[]

for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

DP=[[1000000000]*(H+max(A)+1) for i in range(N+1)]


for i in range(N):
    DP[i+1][A[i]]=B[i]


for i in range(N):
    for h in range(H+max(A)+1):
        DP[i+1][h]=min(DP[i+1][h],DP[i][h])
        if h-A[i]>=0:
            DP[i+1][h]=min(DP[i+1][h-A[i]]+B[i],DP[i+1][h])

print(min(DP[N][H:]))

Fixed submission:
H,N=map(int,input().split())

A=[]
B=[]

for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

DP=[[1000000000]*(H+max(A)+1) for i in range(N+1)]


for i in range(N):
    DP[i+1][A[i]]=B[i]


for i in range(N):
    for h in range(H+max(A)+1):
        DP[i+1][h]=min(DP[i+1][h],DP[i][h])
        if h-A[i]>=0:
            DP[i+1][h]=min(DP[i+1][h-A[i]]+B[i],DP[i+1][h])

print(min(DP[N][H:]))

Buggy python submission (verdict: Runtime Error):
H,N=map(int,input().split())

A=[]
B=[]
DP=[10000000000]*(H+1)
DP[0]=0
for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
    DP[a]=b



minA=A[A.index(min(A))]
minB=B[B.index(min(B))]

for i in range(1,A.index(min(A))):
    DP[i]=minB

for i in range(A.index(min(A)),H+1):
    temp=[]
    for j in range(i+1):
        temp.append(DP[j]+DP[i-j])
    DP[i]=min(temp)

print(DP[H])


Fixed submission:
H,N=map(int,input().split())

A=[]
B=[]

for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

DP=[[1000000000]*(H+max(A)+1) for i in range(N+1)]


for i in range(N):
    DP[i+1][A[i]]=B[i]


for i in range(N):
    for h in range(H+max(A)+1):
        DP[i+1][h]=min(DP[i+1][h],DP[i][h])
        if h-A[i]>=0:
            DP[i+1][h]=min(DP[i+1][h-A[i]]+B[i],DP[i+1][h])

print(min(DP[N][H:]))

Buggy python submission (verdict: Runtime Error):
H,N=map(int,input().split())

A=[]
B=[]
DP=[10000000000]*(H+1)
DP[0]=0
for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
    DP[a]=b



minA=A[A.index(min(A))]
minB=B[B.index(min(B))]

for i in range(1,A.index(min(A))):
    DP[i]=minB

for i in range(A.index(min(A)),H+1):
    temp=[]
    for j in range(i//2+1):
        temp.append(DP[j]+DP[i-j])
    DP[i]=min(temp)

print(DP[H])


Fixed submission:
H,N=map(int,input().split())

A=[]
B=[]

for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

DP=[[1000000000]*(H+max(A)+1) for i in range(N+1)]


for i in range(N):
    DP[i+1][A[i]]=B[i]


for i in range(N):
    for h in range(H+max(A)+1):
        DP[i+1][h]=min(DP[i+1][h],DP[i][h])
        if h-A[i]>=0:
            DP[i+1][h]=min(DP[i+1][h-A[i]]+B[i],DP[i+1][h])

print(min(DP[N][H:]))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
P=list(map(int,input().split()))

cnt=0
for i in range(N):
    if min(P[:i+1])==P[i]:
        cnt+=1

print(cnt)

Fixed submission:
N=int(input())
P=list(map(int,input().split()))

cnt=0
mi=P[0]

for i in range(N):
    if mi>=P[i]:
        cnt+=1
        mi=P[i]
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())

ansAC=0
ansP=0

n=[0]*N
AC=[]

for i in range(M):
    p,s =map(str,input().split())
    p=int(p)-1
    if p in AC:continue

    if s=="AC":
        ansP+=n[p]
        ansAC+=1
        AC.append(p)
    else:
        n[p]+=1

print(ansAC,ansP)


Fixed submission:
N,M=map(int,input().split())

ansAC=0
ansP=0

n=[0]*N
AC=[0]*N

for i in range(M):
    p,s =map(str,input().split())
    p=int(p)-1
    if AC[p]==1:continue
    if s=="AC":
        ansP+=n[p]
        ansAC+=1
        AC[p]=1
    else:
        n[p]+=1

print(ansAC,ansP)
Buggy python submission (verdict: Runtime Error):
S=input()
T=input()
print(T+S)

Fixed submission:
S,T=map(str,input().split())
print(T+S)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())

if N%2==1:
    print(0)
    exit()

cnt=0

for i in range(1,19):
    cnt+=N//(10**i)

cnt+=N//100

for i in range(250,N+1,500):
    temp=i//10
    while temp:
        if temp%5==0:
            cnt+=1
        else:
            break
        temp=temp//5

print(cnt)

Fixed submission:
N=int(input())

if N%2==1:
    print(0)
    exit()

k=5
ans=0
while k*2<=N:
    ans+=N//(k*2)
    k=k*5

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())

if N%2==1:
    print(0)
    exit()

cnt=0

for i in range(1,19):
    cnt+=N//(10**i)

cnt+=N//100

for i in range(250,N+1,500):
    temp=i//10
    while temp:
        if temp%5==0:
            cnt+=1
        else:
            break
        temp=temp//5

print(cnt)

Fixed submission:
N=int(input())

if N%2==1:
    print(0)
    exit()

k=5
ans=0
while k*2<=N:
    ans+=N//(k*2)
    k=k*5

print(ans)
Buggy python submission (verdict: Runtime Error):
X=int(input())

DP=[False]*(X+1)

for i in range(100,106):
    DP[i]=True

for i in range(106,X+1):
    if DP[i-100] or DP[i-101] or DP[i-102] or DP[i-103] or DP[i-104] or DP[i-105]:
        DP[i]=True

if DP[X]==True:
    print(1)
elif DP[X]==False:
    print(0)


Fixed submission:
X=int(input())

t=X//100

if 100*t<=X<=105*t:
    print(1)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
L=len(S)

ans=[]
for i in range(1000):
    key=str(i).zfill(3)
    if key[0] in S:
        idx1=S.index(key[0])
    else:
        continue
    for j in range(idx1+1,L-1):
        if S[j]==key[1]:
            idx2=j
            for k in range(idx2+1,L):
                if S[k]==key[2]:
                    ans.append(key)
                    break
               

print(len(set(ans)))


Fixed submission:
N=int(input())
S=input()

L0=[]
L1=[]
ans=[]

for i in range(N-2):
    if S[i] in L0:
        continue
    else:
        L0.append(S[i])
    for j in range(i+1,N-1):
        temp=S[i]+S[j]
        if temp in L1:
            continue
        else:
            L1.append(temp)
        for k in range(j+1,N):
            ans.append(temp+S[k])


print(len(set(ans)))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()

L1=[]
ans=[]

for i in range(N-2):
    for j in range(i+1,N-1):
        temp=S[i]+S[j]
        if temp in L1:
            continue
        else:
            L1.append(temp)
        for k in range(j+1,N):
            ans.append(temp+S[k])


print(len(set(ans)))

Fixed submission:
N=int(input())
S=input()

L0=[]
L1=[]
ans=[]

for i in range(N-2):
    if S[i] in L0:
        continue
    else:
        L0.append(S[i])
    for j in range(i+1,N-1):
        temp=S[i]+S[j]
        if temp in L1:
            continue
        else:
            L1.append(temp)
        for k in range(j+1,N):
            ans.append(temp+S[k])


print(len(set(ans)))
Buggy python submission (verdict: Time Limit Exceeded):
a,b,x=map(int,input().split())

div=a/b

from math import tan
from math import degrees
from math import pi

l=0
r=pi/2
for i in range(100000):
    mid=(l+r)/2
    t=tan(mid)
    if t<=div:
        f=a*b*b*t/2
    else:
        f=a*a/2*(2*b-a/t)
    if f<=x:
        l=mid
    else:
        r=mid

print(90-degrees(r))

Fixed submission:
import math

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

if x>=(a*a*b)/2:
    y=(2*b-2*x/(a*a))/a
    d=math.degrees(math.atan(y))
else:
    y=(a*b*b)/(2*x)
    d=math.degrees(math.atan(y))
print(d)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

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

L.sort()

ans=0
for i in range(N-1):
    for j in range(i+1,N):
        temp=L[i]+L[j]
        idx=bisect.bisect_left(L,temp)
        for k in range(idx-1,-1,-1):
            if k!=i and k!=j:
                if min(L[i],L[j])+L[k]<=max(L[i],L[j]):
                    continue
                ans+=1


print(ans//3)



Fixed submission:
import bisect

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

L.sort()

ans=0
for i in range(N-1,-1,-1):
    for j in range(i-1,-1,-1):
        temp=L[i]-L[j]
        idx=bisect.bisect_right(L,temp)
        ans+=max(0,j-idx)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
L=list(map(int,input().split()))

L.sort()

ans=0
for i in range(N-1):
    for j in range(i+1,N):
        temp=L[i]+L[j]
        for k in range(N):
            f=True
            if k!=i and k!=j:
                if temp<=L[k]:
                    break
                elif L[j]+L[k]<=L[i]:
                    f=False
                elif L[k]+L[i]<=L[j]:
                    f=False
                if f:
                    ans+=1


print(ans//3)



Fixed submission:
import bisect

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

L.sort()

ans=0
for i in range(N-1,-1,-1):
    for j in range(i-1,-1,-1):
        temp=L[i]-L[j]
        idx=bisect.bisect_right(L,temp)
        ans+=max(0,j-idx)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
L=list(map(int,input().split()))

L.sort()

ans=0
for i in range(N-1):
    for j in range(i+1,N):
        temp=L[i]+L[j]
        for k in range(N):
            f=True
            if k!=i and k!=j:
                if temp<=L[k]:
                    f=False
                elif L[j]+L[k]<=L[i]:
                    f=False
                elif L[k]+L[i]<=L[j]:
                    f=False
                if f:
                    ans+=1


print(ans//3)



Fixed submission:
import bisect

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

L.sort()

ans=0
for i in range(N-1,-1,-1):
    for j in range(i-1,-1,-1):
        temp=L[i]-L[j]
        idx=bisect.bisect_right(L,temp)
        ans+=max(0,j-idx)
print(ans)
Buggy python submission (verdict: Runtime Error):
S=input()
K=int(input())
LS=len(S)

cnt=1
ans1=0
for i in range(1,LS-1):
    if S[i-1]==S[i]:
        cnt+=1
    elif cnt!=1:
        ans1+=cnt//2
        cnt=1

if K==1:
    if S[-2]==S[-1]:
        cnt+=1
        ans1+=cnt//2
else:
    if S[-2]==S[-1]:
        cnt+=1
        if cnt%2==0:
            ans1+=cnt//2
            ans1=ans1*K
        elif cnt%2==1 and S[0]==S[-1]:
            ans1+=cnt//2+1
            ans1=ans1*K-1
        elif cnt%2==1 and S[0]!=S[-1]:
            ans1+=cnt//2
            ans1=ans1*K
    else:
        if S[0]==S[-1]:
            ans1=ans1*K-1
        else:
            ans1=ans1*K
print(ans1)







Fixed submission:
S=input()
K=int(input())
LS=len(S)

if LS==1:
    if K==1:
        print(0)
        exit()
    else:
        print(K//2)
        exit()

cnt=1
ans1=0
c=[]
for i in range(1,LS-1):
    if S[i-1]==S[i]:
        cnt+=1
    elif cnt!=1:
        ans1+=cnt//2
        c.append(cnt)
        cnt=1

if K==1:
    if S[-2]==S[-1]:
        cnt+=1
        ans1+=cnt//2
        print(ans1)
        exit()

if S[-2] == S[-1]:
    cnt += 1
    c.append(cnt)
    if cnt % 2 == 0:
        if ans1 != 0:
            ans1 += cnt // 2
            ans1 = ans1 * K
        else:
            ans1 = (cnt // 2) * K
    elif cnt % 2 == 1 and S[0] == S[-1]:
        if ans1 != 0:
            if c[0] % 2 == 0:
                ans1 += cnt // 2
                ans1 = ans1 * K
            else:
                ans1 += cnt // 2 + 1
                ans1 = ans1 * K - 1
        else:
            if ans1!=0:
                ans1 = (cnt // 2) * K + K - 1
            else:
                ans1=(cnt*K)//2
    elif cnt % 2 == 1 and S[0] != S[-1]:
        ans1 += cnt // 2
        ans1 = ans1 * K
else:
    ans1 += cnt // 2

    if S[0] == S[-1]:
        if ans1!=0 and c[0]%2==0:
            ans1=ans1*K
        else:
            ans1 = ans1*K+K - 1
    else:
        ans1 = ans1 * K


print(ans1)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
Alist=[]
for i in range(N):
    Alist.append(A.index(i+1)+1)

print(" ".join(map(str,Alist)))


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
Alist=[]
for i in range(N):
    Alist.append([A[i],i+1])

Alist.sort()

for i in range(N):
    print(Alist[i][1],end=" ")
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
A=list(map(int,input().split()))

if N==1:
    print(A[0]//(2**M))
    exit()

A.sort(reverse=True)

for i in range(M):
    A[0]=A[0]//2
    A.sort(reverse=True)


print(sum(A))


Fixed submission:
import heapq

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

for i in range(N):
    A[i]=-1*A[i]

heapq.heapify(A)

for i in range(M):
    temp=heapq.heappop(A)
    heapq.heappush(A,(temp+1)//2)

print(-1*sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
A=list(map(int,input().split()))

c=0
i=0

for i in range(M):
    idx=A.index(max(A))
    A[idx]=A[idx]//2
    c+=1


print(sum(A))

Fixed submission:
import heapq

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

for i in range(N):
    A[i]=-1*A[i]

heapq.heapify(A)

for i in range(M):
    temp=heapq.heappop(A)
    heapq.heappush(A,(temp+1)//2)

print(-1*sum(A))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
ans=0
for i in range(N):
    ans+=i
print(ans)



Fixed submission:
N=int(input())
ans=((N-1)*N)//2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

sys.setrecursionlimit(10**6)


N,Q=map(int,input().split())

A=[[] for i in range(N)]
c=[0]*N

for i in range(N-1):
    a,b=map(int,input().split())
    A[a-1].append(b-1)
    A[b-1].append(a-1)

for i in range(Q):
    p,x=map(int,input().split())
    c[p-1]+=x

def dfs(now,prev=-1):
    for next in A[now]:
        if next==prev:continue
        else:
            c[next]+=c[now]
            dfs(next,now)
dfs(0)
print(*c)


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

sys.setrecursionlimit(10**6)


N,Q=map(int,input().split())

A=[[] for i in range(N)]
c=[0]*N

for i in range(N-1):
    a,b=map(int,input().split())
    A[a-1].append(b-1)
    A[b-1].append(a-1)

for i in range(Q):
    p,x=map(int,input().split())
    c[p-1]+=x

def dfs(now,prev=-1):
    for next in A[now]:
        if next==prev:continue
        else:
            c[next]+=c[now]
            dfs(next,now)
dfs(0)
print(*c)

Buggy python submission (verdict: Runtime Error):
N,Q=map(int,input().split())

R=[[] for i in range(N)]
ans=[0]*N

for i in range(N-1):
    a,b=map(lambda x:int(x)-1,input().split())
    R[b].append(a)


c=[0]*N
for i in range(Q):
    p,x=map(int,input().split())
    c[p-1]+=x

ans=[0]*N

for i in range(N-1,-1,-1):
    tem=i
    while True:
        if tem==0:
            ans[tem]=c[0]
            break
        ans[i]+=c[R[tem][0]]
        tem=R[tem][0]


print(*ans)

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

sys.setrecursionlimit(10**6)


N,Q=map(int,input().split())

A=[[] for i in range(N)]
c=[0]*N

for i in range(N-1):
    a,b=map(int,input().split())
    A[a-1].append(b-1)
    A[b-1].append(a-1)

for i in range(Q):
    p,x=map(int,input().split())
    c[p-1]+=x

def dfs(now,prev=-1):
    for next in A[now]:
        if next==prev:continue
        else:
            c[next]+=c[now]
            dfs(next,now)
dfs(0)
print(*c)
Buggy python submission (verdict: Time Limit Exceeded):
import math

N = int(input())
s = [""]*N
a =[[0]*26 for i in range(N)]
b =[""]*N

cn =ord("a")

for i in range(N):
    s[i] = list(input())
    for j in range(26):
        a[i][j] = s[i].count(chr(cn+j))
    b[i] ="".join(str(a[i]))

b.sort()
c = 0
ans =0

for i in range(N-1):
    if b[i]==b[i+1]:
        c +=1
    else:
        if c !=0:
            ans=ans + math.factorial(c+1)/(math.factorial(2)*math.factorial(c+1-2))
            c = 0


if c !=0:
    ans = ans + math.factorial(c+1)/(math.factorial(2)*math.factorial(c+1-2))
    

print(int(ans))


Fixed submission:
import math

N = int(input())
s = [[""]*10 for i in range(N)]
a =[[0]*26 for i in range(N)]
b =[""]*N

cn =ord("a")

for i in range(N):
    s[i] = list(input())
    s[i].sort()
    b[i] ="".join(s[i])

b.sort()
c = 0
ans =0

for i in range(N-1):
    if b[i]==b[i+1]:
        c +=1
    else:
        if c !=0:
            ans=ans + math.factorial(c+1)/(math.factorial(2)*math.factorial(c+1-2))
            c = 0


if c !=0:
    ans = ans + math.factorial(c+1)/(math.factorial(2)*math.factorial(c+1-2))
    

print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):

N = int(input())
s = [""]*N
a =[[0]*26 for i in range(N)]
b =[""]*N

cn =ord("a")

for i in range(N):
    s[i] = list(input())
    for j in range(26):
        a[i][j] = s[i].count(chr(cn+j))
    b[i] ="".join(str(a[i]))

c = 0
for i in range(N-1):
    for j in range(i+1,N):
        if b[i]==b[j]:
            c = c+1

print(c)


Fixed submission:
import math

N = int(input())
s = [[""]*10 for i in range(N)]
a =[[0]*26 for i in range(N)]
b =[""]*N

cn =ord("a")

for i in range(N):
    s[i] = list(input())
    s[i].sort()
    b[i] ="".join(s[i])

b.sort()
c = 0
ans =0

for i in range(N-1):
    if b[i]==b[i+1]:
        c +=1
    else:
        if c !=0:
            ans=ans + math.factorial(c+1)/(math.factorial(2)*math.factorial(c+1-2))
            c = 0


if c !=0:
    ans = ans + math.factorial(c+1)/(math.factorial(2)*math.factorial(c+1-2))
    

print(int(ans))
Buggy python submission (verdict: Runtime Error):
 = int(input())
A = [0]*N

for i in range(N):
    A[i] = int(input())

mx = max(A)
mxi = A.index(max(A))

for i in range(N):
    
    if i != mxi:
        print(mx)
    elif i == 0:
        print(max(A[1:N]))
    elif i == N-1:
        print(max(A[mxi+1:N]))
    else:
        print(max(max(A[0:i]),max(A[i+1:N])))


Fixed submission:
N = int(input())
A = [0]*N

for i in range(N):
    A[i] = int(input())

mx = max(A)
mxi = A.index(max(A))

for i in range(N):
    if i != mxi:
        print(mx)
    elif i == 0:
        print(max(A[1:N]))
    elif i == N-1:
        print(max(A[0:N-1]))
    else:
        print(max(max(A[0:i]),max(A[i+1:N])))

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [0]*N

for i in range(N):
    A[i] = int(input())

mx = max(A)
mxi = A.index(max(A))

for i in range(N):
    if i == 0:
        print(max(A[1:N]))
    elif i != mxi:
        print(mx)
    elif i == N-1:
        print(max(A[mxi+1:N]))
    else:
        print(max(max(A[0:i]),max(A[i+1:N])))


Fixed submission:
N = int(input())
A = [0]*N

for i in range(N):
    A[i] = int(input())

mx = max(A)
mxi = A.index(max(A))

for i in range(N):
    if i != mxi:
        print(mx)
    elif i == 0:
        print(max(A[1:N]))
    elif i == N-1:
        print(max(A[0:N-1]))
    else:
        print(max(max(A[0:i]),max(A[i+1:N])))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [0]*N

for i in range(N):
    A[i] = int(input())


for i in range(N):
    if i == 0:
        print(max(A[1:N]))
    elif i == N-1:
        print(max(A[0:N-1]))
    else:
        print(max(max(A[0:i]),max(A[i+1:N])))


Fixed submission:
N = int(input())
A = [0]*N

for i in range(N):
    A[i] = int(input())

mx = max(A)
mxi = A.index(max(A))

for i in range(N):
    if i != mxi:
        print(mx)
    elif i == 0:
        print(max(A[1:N]))
    elif i == N-1:
        print(max(A[0:N-1]))
    else:
        print(max(max(A[0:i]),max(A[i+1:N])))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [0]*N
B = [0]*N

for i in range(N):
    A[i] = int(input())


for i in range(N):
    for j in range(N):
        if j != i:
            B[j] = A[j]
        else:
            B[j] = 0
    print(max(B))

Fixed submission:
N = int(input())
A = [0]*N

for i in range(N):
    A[i] = int(input())

mx = max(A)
mxi = A.index(max(A))

for i in range(N):
    if i != mxi:
        print(mx)
    elif i == 0:
        print(max(A[1:N]))
    elif i == N-1:
        print(max(A[0:N-1]))
    else:
        print(max(max(A[0:i]),max(A[i+1:N])))
Buggy python submission (verdict: Runtime Error):
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=" ")


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

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

for i in range(N,0,-1):
    cnt = 0

    for j in range(i+i,N+1,i):
        if b[j] == 1:
            cnt += 1

    if a[i-1]==1 and cnt%2==0:
        b[i]=1
        M+=1
    elif a[i-1]==0 and cnt%2==1:
        b[i]=1
        M+=1
        

print(M)
for i in range(1,N+1):
    if b[i]==1:
        print(i,end=" ")
Buggy python submission (verdict: Runtime Error):
import math

A, B, C, D = map(int, input().split())

x = math.gcd(C, D)
CD = x * (C // x) * (D // x)

Cm = B // C - (A - 1) // C
Dm = B // D - (A - 1) // D
CDm = B // CD - (A - 1) // CD

print(B + 1 - A - (Cm + Dm - CDm))

Fixed submission:
import fractions

A, B, C, D = map(int, input().split())

x = fractions.gcd(C, D)
CD = x * (C // x) * (D // x)

Cm = B // C - (A - 1) // C
Dm = B // D - (A - 1) // D
CDm = B // CD - (A - 1) // CD

print(B + 1 - A - (Cm + Dm - CDm))
Buggy python submission (verdict: Runtime Error):
N=int(input())

P=[]
for i in range(N):
    P.append(list(map(int,input().split())))

c={}
for i in range(N):
    for j in range(N):
        if i!=j:
            p=P[j][0]-P[i][0]
            q=P[j][1]-P[i][1]
            temp=str(p)+"_"+str(q)
            if temp in c:
                c[temp]+=1
            else:
                c[temp]=1
c_num=[]
for j in c:
    c_num.append(c[j])

print(N-max(c_num))



Fixed submission:
N=int(input())

if N==1:
    print(1)
    exit()

P=[]
for i in range(N):
    P.append(list(map(int,input().split())))

c={}
for i in range(N):
    for j in range(N):
        if i!=j:
            p=P[j][0]-P[i][0]
            q=P[j][1]-P[i][1]
            temp=str(p)+"_"+str(q)
            if temp in c:
                c[temp]+=1
            else:
                c[temp]=1
c_num=[]
for j in c:
    c_num.append(c[j])

print(N-max(c_num))
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))

A.sort(reverse=True)
P=[]
M=[]

for i in A:
    if i<0:
        M.append(i)
    else:
        P.append(i)
ans=[]
if len(M)==0:
    x=P.pop()
    y=P.pop()
    ans.append([x,y])
    M.append(x-y)
if len(P)==0:
    x=M.pop()
    y=M.pop()
    ans.append([x,y])
    P.append(x-y)


for i in range(len(P)-1):
    y=P.pop()
    x=M.pop()
    ans.append([x,y])
    M.append(x-y)

for i in range(len(M)):
    y=M.pop()
    x=P.pop()
    ans.append([x,y])
    P.append(x-y)

print(P[0])

for x,y in ans:
    print(x,y)







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

A.sort(reverse=True)
P=[]
M=[]

for i in A:
    if i<0:
        M.append(i)
    else:
        P.append(i)

ans=[]
if len(M)==0:
    if P[0]==0:
        print(0)
        for i in range(N-1):
            print(0,0)
        exit()
    else:
        x=P.pop()
        y=P.pop(0)
        ans.append([x,y])
        M.append(x-y)
if len(P)==0:
    x=M.pop(0)
    y=M.pop()
    ans.append([x,y])
    P.append(x-y)


for i in range(len(P)-1):
    y=P.pop()
    x=M.pop()
    ans.append([x,y])
    M.append(x-y)

for i in range(len(M)):
    y=M.pop()
    x=P.pop()
    ans.append([x,y])
    P.append(x-y)

print(P[0])

for x,y in ans:
    print(x,y)