Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
k=int(input())
def gcd(*numbers):
    return reduce(math.gcd, numbers)
ans=0
for i in range(1,k+1):
  for j in range(j,k+1):
    for l in range(l,k+1):
      if l==i:
        ans+=gcd(i,j,l)
      elif i==j or j==l:
        ans+=2*gcd(i,j,l)
      else:
        ans+=gcd(i,j,l)
print(ans)


Fixed submission:
import math
from functools import reduce
k=int(input())
def gcd(*numbers):
    return reduce(math.gcd, numbers)
ans=0
for i in range(1,k+1):
  for j in range(i,k+1):
    for l in range(j,k+1):
      if l==i:
        ans+=gcd(i,j,l)
      elif i==j or j==l:
        ans+=3*gcd(i,j,l)
      else:
        ans+=6*gcd(i,j,l)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
k=int(input())
def gcd(*numbers):
    return reduce(math.gcd, numbers)
ans=0
for i in range(1,k+1):
  for j in range(1,k+1):
    for l in range(1,k+1):
      ans+=gcd(i,j,l)
print(ans)

Fixed submission:
import math
from functools import reduce
k=int(input())
def gcd(*numbers):
    return reduce(math.gcd, numbers)
ans=0
for i in range(1,k+1):
  for j in range(i,k+1):
    for l in range(j,k+1):
      if l==i:
        ans+=gcd(i,j,l)
      elif i==j or j==l:
        ans+=3*gcd(i,j,l)
      else:
        ans+=6*gcd(i,j,l)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
ans=0
n=int(input())
k=str(input())
r=k.count("R")
b=k.count("B")
g=k.count("G")
ans+=r*b*g
    
for i in range(n-2):
  ii=k[i]
  for j in range(i+1,n-1):
    jj=k[j]
    l=j+(j-i)
    #print(l)
    if jj!=ii and l<n:
      #print(i,j)
      ll=k[l]
      if ii!=ll and jj!=ll:
        ans-=1
          #print(i,j,l)
print(ans)

Fixed submission:
ans=0
n=int(input())
k=str(input())
r=k.count("R")
b=k.count("B")
g=k.count("G")
ans+=r*b*g
    
for i in range(n-2):
  ii=k[i]
  for j in range(i+1,(n-i)//2+1+i):
    jj=k[j]
    l=j+(j-i)
    #print(l)
    if jj!=ii and l<n:
      #print(i,j)
      ll=k[l]
      if ii!=ll and jj!=ll:
        ans-=1
          #print(i,j,l)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
mod=1000000007
n=int(input())
s=str(input())
ans=1
for i in range(1,n+1):
  i=i%mod
  ans=ans*i
  ans=ans%mod
d={"B":1,"W":0}
sg=[]
now=1
ss=0
gg=0
for i in range(n):
  if d[s[i]]==now%2:
    sg.append("S")
    now+=1
    ss+=1
  else:
    sg.append("G")
    now-=1
    gg+=1
now=1
sg1=[]
for i in range(1,n+1):
  #print("now",now,s[-1*i])
  if d[s[-1*i]]==now%2:
    sg1.insert(0,"G")
    now+=1
    gg+=1
  else:
    sg1.insert(0,"S")
    now-=1
    ss+=1
sg2=sg+sg1
#print(sg2)
sss=0
for i in sg2:
  if i=="S":
    sss+=1
  else:
    if sss>=0:
      ans*=sss
      ans=ans%mod
      sss-=1
    else:
      print(0)
      sys.exit()
  #print(i,ans,sss)      
if sss==0:
  print(ans)
else:
  print(0)
    

Fixed submission:
import sys
mod=1000000007
n=int(input())
s=str(input())
ans=1
for i in range(1,n+1):
  i=i%mod
  ans=ans*i
  ans=ans%mod
d={"B":1,"W":0}
sg=[]
now=1
sss=0
for i in range(2*n):
  if d[s[i]]==now%2:
    sss+=1
    now+=1
    a="S"
  else:
    a="G"
    now-=1
    if sss>=0:
      ans*=sss
      ans=ans%mod
      sss-=1
    else:
      ans=0
  #print("i",i,a,sss,ans)
if sss==0:
  print(ans)
else:
  print(0)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
C=[]
A=[]
B=[]
ans=0
for i in range(N):
  a=str(input())
  C.append(a)
for i in C:
  ab=[j for j in i]
  ab.sort()
  aaa="".join(ab)
  #print(aaa)
  if aaa in A:
    i=A.index(aaa)
    ans+=B[i]
    B[i]+=1
  else:
    A.append(aaa)
    B.append(1)
print(ans)

Fixed submission:
N=int(input())
C=[]
dic={}
ans=0
for i in range(N):
  a=str(input())
  C.append(a)
for i in C:
  ab=[j for j in i]
  ab.sort()
  aaa="".join(ab)
  #print(aaa)
  if aaa in dic:
    ans+=dic[aaa]
    dic[aaa]+=1
  else:
    dic[aaa]=1
print(ans)
#print(dic)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[]
B=[]
ans=0
for i in range(N):
  a=str(input())
  aa=[]
  for i in a:
    aa.append(i)
  aa.sort()
  aaa=str("0123456789")
  for i in range(len(aa)):
    aaa=aaa.replace(str(i),aa[i])
  if aaa in A:
    i=A.index(aaa)
    ans+=B[i]
    B[i]+=1
  else:
    A.append(aaa)
    B.append(1)
print(ans)
  

Fixed submission:
N=int(input())
C=[]
dic={}
ans=0
for i in range(N):
  a=str(input())
  C.append(a)
for i in C:
  ab=[j for j in i]
  ab.sort()
  aaa="".join(ab)
  #print(aaa)
  if aaa in dic:
    ans+=dic[aaa]
    dic[aaa]+=1
  else:
    dic[aaa]=1
print(ans)
#print(dic)
Buggy python submission (verdict: Runtime Error):
import heapq
N,M=map(int,input().split())
l=[[] for i in range(M+1)]
#print(l)
for i in range(N):
  a,b=map(int,input().split())
  #print(a,b)
  #print(l[a])
  l[a].append(b)
#print(l)
ans=0
que=[]
for i in range(1,M+1):
  for j in l[i]:
    heapq.heappush(que,-j)
  if len(que)>0:
    #print(i,que)
    ans-=heapq.heappop(que)
    
    
print(ans)

Fixed submission:
import heapq
N,M=map(int,input().split())
l=[[] for i in range(M+1)]
#print(l)
for i in range(N):
  a,b=map(int,input().split())
  if a<=M:
  #print(a,b)
  #print(l[a])
    l[a].append(b)
#print(l)
ans=0
que=[]
for i in range(1,M+1):
  for j in l[i]:
    heapq.heappush(que,-j)
  if len(que)>0:
    #print(i,que)
    ans-=heapq.heappop(que)
    
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
l=[]
for i in range(N):
  a=list(map(int,input().split()))
  l.append(a)
l.sort(key=lambda x: x[0])
#print(l)
p=[]
ans=0
for j in range(1,M+1):
  if len(l)!=0:
    while l[0][0]<=j:
      a=l.pop(0)
      p.append(a[1])
      if len(l)==0: break
  if len(p)!=0:
    b=max(p)
    p.remove(b)
    ans+=b
print(ans)

Fixed submission:
import heapq
N,M=map(int,input().split())
l=[[] for i in range(M+1)]
#print(l)
for i in range(N):
  a,b=map(int,input().split())
  if a<=M:
  #print(a,b)
  #print(l[a])
    l[a].append(b)
#print(l)
ans=0
que=[]
for i in range(1,M+1):
  for j in l[i]:
    heapq.heappush(que,-j)
  if len(que)>0:
    #print(i,que)
    ans-=heapq.heappop(que)
    
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
ans=0
A=[]
for i in range(N):
  a,b=map(int,input().split())
  if a<=M:
    d=[a,b]
    A.append(d)
ans=0
now=0
sortedA=sorted(A, key=lambda x: x[0])
#print("sortedA",sortedA)
after=[]
i=0
stop=0
while sortedA or i<M:
  i+=1
  #print("i",i)
  if len(sortedA)==0 and len(after)!=0:
    ans+=after[-1][1]
    after.pop(-1)
    #print("ans",ans,"after",after,"sortedA" ,sortedA)
  elif sortedA:
    while sortedA[0][0]==i:
      a=sortedA.pop(0)
      after.append(a)
      if len(sortedA)==0: break
    after.sort(key=lambda x:x[1])
    if after:
      ans+=after[-1][1]
      after.pop(-1)
    #print("ans",ans,"after",after,"sortedA" ,sortedA)
print(ans)




Fixed submission:
import heapq
N,M=map(int,input().split())
l=[[] for i in range(M+1)]
#print(l)
for i in range(N):
  a,b=map(int,input().split())
  if a<=M:
  #print(a,b)
  #print(l[a])
    l[a].append(b)
#print(l)
ans=0
que=[]
for i in range(1,M+1):
  for j in l[i]:
    heapq.heappush(que,-j)
  if len(que)>0:
    #print(i,que)
    ans-=heapq.heappop(que)
    
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[]
for i in range(N):
  a=int(input())
  A.append(a)
  
ans=max(A)
for i in range(N):
  if A[i]==ans:
    b=A[:i]
    c=A[i+1:]
    aa=b+c
    print(max(aa))
  else:
    print(ans)

Fixed submission:
N=int(input())
A=[]
for i in range(N):
  a=int(input())
  A.append(a)
  
ans=max(A)
for i in range(N):
  if A[i]==ans:
    b=A[:i]
    c=A[i+1:]
    aa=b+c
    an=max(aa)
    if an==ans:
      for j in range(N-i):
        print(ans)
      break
    else:
      print(an)
  else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[]
for i in range(N):
  a=int(input())
  A.append(a)
  
print(max(A[1:]))
for i in range(1,N-1):
  b=A[:i]
  c=A[i+1:]
  aa=b+c
  print(max(aa))
  
print(max(A[:N-1]))

Fixed submission:
N=int(input())
A=[]
for i in range(N):
  a=int(input())
  A.append(a)
  
ans=max(A)
for i in range(N):
  if A[i]==ans:
    b=A[:i]
    c=A[i+1:]
    aa=b+c
    an=max(aa)
    if an==ans:
      for j in range(N-i):
        print(ans)
      break
    else:
      print(an)
  else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())

#kaijou
kk=[1]
a=1
for i in range(0,N):
  a=a*(i+1)
  kk.append(a)
#print(kk)
  
for i in range(0,K):
  j=i+1
  if N-K-j+1<0:
    print("0")
  else:
    aaa=int(kk[N-K+1]/(kk[N-K-j+1]*kk[j]))
    bbb=int(kk[K-1]/(kk[K-j]*kk[j-1]))
    #print(aaa,"aaa",bbb,"bbb")
    ccc=aaa*bbb
    print(ccc%(10**9+7))
  

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

#kaijou
kk=[1]
a=1
for i in range(0,N):
  a=a*(i+1)
  kk.append(a)
#print(kk)
  
for i in range(0,K):
  j=i+1
  if N-K-j+1<0:
    print("0")
  else:
    aaa=(kk[N-K+1]//(kk[N-K-j+1]*kk[j]))%(10**9+7)
    bbb=(kk[K-1]//(kk[K-j]*kk[j-1]))%(10**9+7)
    #print(j,aaa,"aaa",bbb,"bbb")
    ccc=aaa*bbb
    print(int(ccc%(10**9+7)))

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

#kaijou
kk=[1]
a=1
for i in range(0,N-K+5):
  a=a*(i+1)
  kk.append(a)
#print(kk)
  
for i in range(0,K):
  j=i+1
  if N-K-j+1<0:
    print("0")
  else:
    aaa=int(kk[N-K+1]/(kk[N-K-j+1]*kk[j]))
    bbb=int(kk[K-1]/(kk[K-j]*kk[j-1]))
    #print(aaa,"aaa",bbb,"bbb")
    ccc=aaa*bbb
    print(ccc%(10**9+7))
  

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

#kaijou
kk=[1]
a=1
for i in range(0,N):
  a=a*(i+1)
  kk.append(a)
#print(kk)
  
for i in range(0,K):
  j=i+1
  if N-K-j+1<0:
    print("0")
  else:
    aaa=(kk[N-K+1]//(kk[N-K-j+1]*kk[j]))%(10**9+7)
    bbb=(kk[K-1]//(kk[K-j]*kk[j-1]))%(10**9+7)
    #print(j,aaa,"aaa",bbb,"bbb")
    ccc=aaa*bbb
    print(int(ccc%(10**9+7)))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))

n=0
sm=0
if A[0]>0:
  mn=A[0]
else:
  mn=(-1)*A[0]


for i in range(0,N):
  if A[i]<0:
    n=n+1
    AA=A.pop(i)
    A.insert(i,(-1)*AA)
    sm=sm+AA*(-1)
    if (-1)*AA<mn:
      mn=(-1)*AA
  else:
    sm=sm+A[i]
    if A[i]<mn:
      mn=A[i]

if n%2==0:
  print(sm)
else:
  print(sm-2*mn)

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

n=0
sm=0
if A[0]>0:
  mn=A[0]
else:
  mn=(-1)*A[0]


for i in range(0,N):
  if A[i]<0:
    n=n+1
    sm=sm-A[i]
    if (-1)*A[i]<mn:
      mn=(-1)*A[i]
  else:
    sm=sm+A[i]
    if A[i]<mn:
      mn=A[i]
if n%2==0:
  print(sm)
else:
  print(sm-2*mn)

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

n=0
for i in range(0,N):
  if A[i]<0:
    n=n+1
    AA=A.pop(i)
    A.insert(i,(-1)*AA)

if n%2==0:
  print(sum(A))
else:
  print(sum(A)-2*min(A))

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

n=0
sm=0
if A[0]>0:
  mn=A[0]
else:
  mn=(-1)*A[0]


for i in range(0,N):
  if A[i]<0:
    n=n+1
    sm=sm-A[i]
    if (-1)*A[i]<mn:
      mn=(-1)*A[i]
  else:
    sm=sm+A[i]
    if A[i]<mn:
      mn=A[i]
if n%2==0:
  print(sm)
else:
  print(sm-2*mn)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()


num=S.count("#")
if num>S.count("."):#全部黒にする
  num=S.count(".")
  
for i in range(0,N): #i番目まで白
  n=S.count("#",0,i)+S.count(".",i+1,N)

  if n<num:
    num=n
 
print(num)

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


num=S.count("#")
if num>S.count("."):#全部黒にする
  num=S.count(".")
  
  
c_w=0
c_b=S.count(".")

for i in range(0,N): #i番目まで白
  if S[i]=="#":
    c_w+=1
  else:
    c_w=c_w
    c_b-=1
  num=min(num,c_w+c_b)
 
print(num)

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


num=S.count("#")
if num>S.count("."):#全部黒にする
  num=S.count(".")
  
for i in range(0,N): #i番目まで白
  n=0
  for j in range(0,i):
    if S[j]=="#":
      n=n+1
      if n>=num: break
  for k in range(i,N):
    if S[k]==".":
      n=n+1    
      if n>=num: break
  if n<num:
    num=n
 
print(num)

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


num=S.count("#")
if num>S.count("."):#全部黒にする
  num=S.count(".")
  
  
c_w=0
c_b=S.count(".")

for i in range(0,N): #i番目まで白
  if S[i]=="#":
    c_w+=1
  else:
    c_w=c_w
    c_b-=1
  num=min(num,c_w+c_b)
 
print(num)

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


num=S.count("#")
if num>S.count("."):#全部黒にする
  num=S.count(".")
  
for i in range(0,N): #i番目まで白
  n=0
  for j in range(0,i):
    if S[j]=="#":
      n=n+1
  for k in range(i,N):
    if S[k]==".":
      n=n+1    
  if n<num:
    num=n
 
print(num)

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


num=S.count("#")
if num>S.count("."):#全部黒にする
  num=S.count(".")
  
  
c_w=0
c_b=S.count(".")

for i in range(0,N): #i番目まで白
  if S[i]=="#":
    c_w+=1
  else:
    c_w=c_w
    c_b-=1
  num=min(num,c_w+c_b)
 
print(num)
Buggy python submission (verdict: Runtime Error):
data=[]
N=0

for i in range(0,X):
  while N<K:
    for j in range(0,Y):
      while N<K:
        for k in range(0,Z):
          while N<K:
            data.append(int(A[i]+B[j]+C[k]))
            N=N+1
    
data.sort()
data.reverse()

for l in range(K):
  print(data[l])


Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
f=[a,b,c,d,e]
ma=max(f)
mi=min(f)
if ma-mi>k:
  print(":(")
else:
  print("Yay!")
Buggy python submission (verdict: Time Limit Exceeded):
X,Y,Z,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

data=[]
N=0
while N<K:
  for i in range(0,X):
  
    for j in range(0,Y):
    
      for k in range(0,Z):
        data.append(int(A[i]+B[j]+C[k]))
        N=N+1
    
data.sort()
data.reverse()

for l in range(K):
  print(data[l])


Fixed submission:
X,Y,Z,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
A.reverse()
B.reverse()
C.reverse()

data=[]

for i in range(0,X):
  if i+1>K: break
    
  for j in range(0,Y):
    if (i+1)*(j+1)>K: break
    
    for k in range(0,Z):
      if (i+1)*(j+1)*(k+1)>K: break
      data.append(int(A[i]+B[j]+C[k]))
        
    
data.sort()
data.reverse()

for l in range(K):
  print(data[l])

Buggy python submission (verdict: Time Limit Exceeded):
X,Y,Z,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

data=[]

for i in range(0,X):
  
  for j in range(0,Y):
    
    for k in range(0,Z):
      data.append(int(A[i]+B[j]+C[k]))
    
data.sort()
data.reverse()

for l in range(K):
  print(data[l])


Fixed submission:
X,Y,Z,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
A.reverse()
B.reverse()
C.reverse()

data=[]

for i in range(0,X):
  if i+1>K: break
    
  for j in range(0,Y):
    if (i+1)*(j+1)>K: break
    
    for k in range(0,Z):
      if (i+1)*(j+1)*(k+1)>K: break
      data.append(int(A[i]+B[j]+C[k]))
        
    
data.sort()
data.reverse()

for l in range(K):
  print(data[l])

Buggy python submission (verdict: Time Limit Exceeded):
X,Y,Z,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

A.sort()
B.sort()
C.sort()

data=[]

for i in range(0,X):
  a=int(A[i])
  
  for j in range(0,Y):
    b=int(B[j])
    
    for k in range(0,Z):
      c=int(C[k])
      data.append(int(a+b+c))
    
data.sort()
data.reverse()

for l in range(K):
  print(data[l])


Fixed submission:
X,Y,Z,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
A.reverse()
B.reverse()
C.reverse()

data=[]

for i in range(0,X):
  if i+1>K: break
    
  for j in range(0,Y):
    if (i+1)*(j+1)>K: break
    
    for k in range(0,Z):
      if (i+1)*(j+1)*(k+1)>K: break
      data.append(int(A[i]+B[j]+C[k]))
        
    
data.sort()
data.reverse()

for l in range(K):
  print(data[l])
Buggy python submission (verdict: Runtime Error):
D,N=map(int,input().split())
if N<100:
  F=100**D
  print(F*N)

else:
  print(F*101)

Fixed submission:
D,N=map(int,input().split())
F=100**D
if N<100:
  print(F*N)

else:
  print(F*101)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate


def main():
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    accumulateA = list(accumulate(A))
    accumulateB = list(accumulate(B))
    accumulateA.insert(0, 0)
    accumulateB.insert(0, 0)
    count = 0
    for i in range(N+1):
        for j in range(M+1):
            if accumulateA[i] + accumulateB[j] <= K:
                count = max(count, i + j)
    print(count)


if __name__ == "__main__":
    main()


Fixed submission:
from itertools import accumulate
import bisect


def main():
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    accumulateA = list(accumulate(A))
    accumulateB = list(accumulate(B))
    accumulateA.insert(0, 0)
    accumulateB.insert(0, 0)
    count = 0
    for i in range(N+1):
        j = bisect.bisect(accumulateB, K - accumulateA[i]) - 1
        if j >= 0:
            count = max(count, i + j)
    print(count)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
x, n = map(int, input().split())
ps = list(map(int, input().split()))
nums = list(range(1, 101))
for p in ps:
    nums.remove(p)
for i, num in enumerate(nums):
    if num > x:
        break
if i - 1 < 0:
    print(nums[i])
else:
    diff1 = abs(nums[i - 1] - x)
    diff2 = abs(nums[i] - x)
    if diff1 < diff2:
        print(nums[i - 1])
    elif diff1 > diff2:
        print(nums[i])
    else:
        print(nums[i-1])


Fixed submission:
x, n = map(int, input().split())
ps = list(map(int, input().split()))
nums = list(range(-1, 102))
for p in ps:
    nums.remove(p)
min_diff = float("inf")
min_original = float("inf")
for num in nums:
    diff = abs(num - x)
    if diff < min_diff:
        min_diff = diff
        min_original = num
    elif diff == min_diff:
        if num < min_original:
            min_original = num
print(min_original)
Buggy python submission (verdict: Runtime Error):
def main():
    A, B = input().split()
    A = int(A)
    B_big, B_small = B.split(".")
    B_big = int(B_big)
    B_small = int(B_small)
    print(A*B + int(A*B_small/100))


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    A, B = input().split()
    A = int(A)
    B_big, B_small = B.split(".")
    B_big = int(B_big)
    B_small = int(B_small)
    print(A*B_big + A*B_small//100)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
from math import sqrt
from bisect import bisect


def main():
    N = int(input())
    factor = {}
    max_count = 1
    while N > 1:
        for i in range(2, int(sqrt(N))+1):
            if N % i == 0:
                N = N // i
                if i in factor:
                    factor[i] += 1
                    if max_count < factor[i]:
                        max_count = factor[i]
                else:
                    factor[i] = 1
                break
        else:
            if N in factor:
                factor[N] += 1
                if max_count < factor[i]:
                    max_count = factor[i]
            else:
                factor[N] = 1
            N = 1
    sum_up = [n * (n + 1) // 2 for n in range(max_count+1)]
    ans = 0
    for prime, count in factor.items():
        ans += bisect(sum_up, count)-1
    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
from math import sqrt
from bisect import bisect


def main():
    N = int(input())
    factor = {}
    max_count = 1
    while N > 1:
        for i in range(2, int(sqrt(N)) + 1):
            if N % i == 0:
                N = N // i
                if i in factor:
                    factor[i] += 1
                    if max_count < factor[i]:
                        max_count = factor[i]
                else:
                    factor[i] = 1
                break
        else:
            if N in factor:
                factor[N] += 1
                if max_count < factor[N]:
                    max_count = factor[N]
            else:
                factor[N] = 1
            N = 1
    sum_up = [n * (n + 1) // 2 for n in range(max_count + 1)]
    ans = 0
    for prime, count in factor.items():
        ans += bisect(sum_up, count)-1
    print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
n = int(input())
leaves = list(map(int, input().split()))

ans = 0
nodes_min = [0] * (n + 1)
nodes_max = [0] * (n + 1)
nodes_min[n] = leaves[n]
nodes_max[n] = leaves[n]

for depth in range(n, 0, -1):
    root_min = nodes_min[depth] // 2 + nodes_min[depth] % 2
    nodes_min[depth - 1] = leaves[depth - 1] + root_min
    root_max = nodes_max[depth]
    nodes_max[depth - 1] = leaves[depth - 1] + root_max
nodes = [0] * (n + 1)
nodes[0] = 1
for depth in range(n):
    roots = nodes[depth]-leaves[depth]
    if nodes[depth] < nodes_min[depth]:
        print(-1)
        break
    nodes[depth + 1] = min(roots * 2, nodes_max[depth + 1])
else:
    if nodes[n] < nodes_min[depth]:
        print(-1)
    else:
        print(sum(nodes))

Fixed submission:
n = int(input())
leaves = list(map(int, input().split()))

ans = 0
nodes_min = [0] * (n + 1)
nodes_max = [0] * (n + 1)
nodes_min[n] = leaves[n]
nodes_max[n] = leaves[n]

for depth in range(n, 0, -1):
    root_min = nodes_min[depth] // 2 + nodes_min[depth] % 2
    nodes_min[depth - 1] = leaves[depth - 1] + root_min
    root_max = nodes_max[depth]
    nodes_max[depth - 1] = leaves[depth - 1] + root_max
nodes = [0] * (n + 1)
nodes[0] = 1
for depth in range(n):
    roots = nodes[depth]-leaves[depth]
    if nodes[depth] < nodes_min[depth]:
        print(-1)
        break
    nodes[depth + 1] = min(roots * 2, nodes_max[depth + 1])
else:
    if nodes[n] < nodes_min[n]:
        print(-1)
    else:
        print(sum(nodes))
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

if S == [T:-1]:
    print("Yes")
else:
    print("No")


Fixed submission:
S = input()
T = input()

for i, s in enumerate(S):
    if s != T[i]:
        print("No")
        break
else:
    print("Yes")

Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

if S == [T:-1]:
    print("Yes")
else:
    print("No")


Fixed submission:
S = input()
T = input()

for i, s in enumerate(S):
    if s != T[i]:
        print("No")
        break
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
import numpy as np
from itertools import product
INF = 10**9

N, M, X = map(int, input().split())
C = [None]*N
A = [None]*N
for i in range(N):
    line = list(map(int, input().split()))
    C[i] = line[0]
    A[i] = np.array(line[1:])

choose = [True, False]

min_price = INF

for s in product([True, False], repeat=N):
    price = 0
    knowledge = np.zeros(M)
    for i in range(N):
        if s >> i & 1:
            knowledge += A[i]
            price += C[i]
    if np.any(knowledge < X):
        continue
    if min_price == -1:
        min_price = price
    min_price = min(min_price, price)

if min_price == INF:
    print(-1)
else:
    print(min_price)


Fixed submission:
from itertools import product
import numpy as np

N, M, X = map(int, input().split())
C = [None]*N
A = [None]*N
for i in range(N):
    line = list(map(int, input().split()))
    C[i] = line[0]
    A[i] = np.array(line[1:])

choose = [True, False]

min_price = -1

for books in product(choose, repeat=N):
    price = 0
    knowledge = np.zeros(M)
    for i in range(N):
        if books[i]:
            knowledge += A[i]
            price += C[i]
    if np.any(knowledge < X):
        continue
    if min_price == -1:
        min_price = price
    min_price = min(min_price, price)

if min_price == -1:
    print(-1)
else:
    print(min_price)