Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import numpy as np
n=int(input())
mod=10**9+7
def searchPrimeNum(N):
    max = int(np.sqrt(N))
    searchList = [i for i in range(2,N+1)]
    primeNum = []
    while searchList[0] <= max:
        primeNum.append(searchList[0])
        tmp = searchList[0]
        searchList = [i for i in searchList if i % tmp != 0]
    primeNum.extend(searchList)
    return primeNum
l=len(searchPrimeNum(n))
plist=searchPrimeNum(n)
cnt=[0]*l
for i in range(l):
  k=1 
  while plist[i]**k<n:
    cnt[i]+=n//(plist[i]**k)
    k+=1
ans=1
for i in cnt:
  ans=(ans*(i+1))%mod
print(ans)


Fixed submission:
import sys
import numpy as np
n=int(input())
mod=10**9+7
if n==1:print(1);sys.exit()
def searchPrimeNum(N):
    max = int(np.sqrt(N))
    searchList = [i for i in range(2,N+1)]
    primeNum = []
    while searchList[0] <= max:
        primeNum.append(searchList[0])
        tmp = searchList[0]
        searchList = [i for i in searchList if i % tmp != 0]
    primeNum.extend(searchList)
    return primeNum
l=len(searchPrimeNum(n))
plist=searchPrimeNum(n)
cnt=[0]*l
for i in range(l):
  k=1 
  while plist[i]**k<=n:
    cnt[i]+=n//(plist[i]**k)
    k+=1
ans=1
for i in cnt:
  ans=(ans*(i+1))%mod
print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np
n=int(input())
mod=10**9+7
def searchPrimeNum(N):
    max = int(np.sqrt(N))
    searchList = [i for i in range(2,N+1)]
    primeNum = []
    while searchList[0] <= max:
        primeNum.append(searchList[0])
        tmp = searchList[0]
        searchList = [i for i in searchList if i % tmp != 0]
    primeNum.extend(searchList)
    return primeNum
l=len(searchPrimeNum(n))
plist=searchPrimeNum(n)
cnt=[0]*l
for i in range(l):
  k=1 
  while plist[i]**k<n:
    cnt[i]+=n//(plist[i]**k)
    k+=1
ans=1
for i in cnt:
  ans=(ans*i)%mod
print(ans)

Fixed submission:
import sys
import numpy as np
n=int(input())
mod=10**9+7
if n==1:print(1);sys.exit()
def searchPrimeNum(N):
    max = int(np.sqrt(N))
    searchList = [i for i in range(2,N+1)]
    primeNum = []
    while searchList[0] <= max:
        primeNum.append(searchList[0])
        tmp = searchList[0]
        searchList = [i for i in searchList if i % tmp != 0]
    primeNum.extend(searchList)
    return primeNum
l=len(searchPrimeNum(n))
plist=searchPrimeNum(n)
cnt=[0]*l
for i in range(l):
  k=1 
  while plist[i]**k<=n:
    cnt[i]+=n//(plist[i]**k)
    k+=1
ans=1
for i in cnt:
  ans=(ans*(i+1))%mod
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
n=int(input())
mod=10**9+7
if n==1:print(1);sys.exit()
def searchPrimeNum(N):
    max = int(np.sqrt(N))
    searchList = [i for i in range(2,N+1)]
    primeNum = []
    while searchList[0] <= max:
        primeNum.append(searchList[0])
        tmp = searchList[0]
        searchList = [i for i in searchList if i % tmp != 0]
    primeNum.extend(searchList)
    return primeNum
l=len(searchPrimeNum(n))
plist=searchPrimeNum(n)
cnt=[0]*l
for i in range(l):
  k=1 
  while plist[i]**k<=n:
    cnt[i]+=n//(plist[i]**k)
    k+=1
ans=1
for i in cnt:
  ans=(ans*(i+1))%mod
print(ans)


Fixed submission:
import sys
import numpy as np
n=int(input())
mod=10**9+7
if n==1:print(1);sys.exit()
def searchPrimeNum(N):
    max = int(np.sqrt(N))
    searchList = [i for i in range(2,N+1)]
    primeNum = []
    while searchList[0] <= max:
        primeNum.append(searchList[0])
        tmp = searchList[0]
        searchList = [i for i in searchList if i % tmp != 0]
    primeNum.extend(searchList)
    return primeNum
l=len(searchPrimeNum(n))
plist=searchPrimeNum(n)
cnt=[0]*l
for i in range(l):
  k=1 
  while plist[i]**k<=n:
    cnt[i]+=n//(plist[i]**k)
    k+=1
ans=1
for i in cnt:
  ans=(ans*(i+1))%mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
K,S=map(int,input().split())
ans=0
for X in range(0,K+1):
  for Y in range(0,K+1):
    for Z in range(0,K+1):
      if X+Y+Z==S:
        ans+=1
print(ans)

Fixed submission:
k,s=map(int,input().split())
ans=0
def als(n):
  if 0<=n<=k:
    return n+1
  elif k+1<=n<=2*k:
    return 2*k+1-n
  else:
    return 0
for i in range(k+1):
  ans+=als(s-i)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
k,s=map(int,input().split())
ans=0
for i in range(k+1):
  for j in range(k+1):
    for h in range(k+1):
      if i+j+h==s:
        ans+=1
print(ans)


Fixed submission:
k,s=map(int,input().split())
ans=0
def als(n):
  if 0<=n<=k:
    return n+1
  elif k+1<=n<=2*k:
    return 2*k+1-n
  else:
    return 0
for i in range(k+1):
  ans+=als(s-i)
print(ans)

Buggy python submission (verdict: Runtime Error):
k,s=map(int,input().split())
ans=0
for i in range(k):
  for j in range(k):
    fpr h in range(k):
      if i+j+h==s:
        ans+=1
print(ans)

Fixed submission:
k,s=map(int,input().split())
ans=0
def als(n):
  if 0<=n<=k:
    return n+1
  elif k+1<=n<=2*k:
    return 2*k+1-n
  else:
    return 0
for i in range(k+1):
  ans+=als(s-i)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s=input()[::-1]
p=["maerd","remaerd","resare","esare"]
while True:
  if s[:5]==p[0]:s=s.replace(p[0],"",1)
  elif s[:5]==p[3]:s=s.replace(p[3],"",1)
  elif s[:7]==p[1]:s=s.replace(p[1],"",1)
  elif s[:6]==p[2]:s=s.replace(p[2],"",1)
  else:
    if s=="":print("YES");break
    else:print("NO");break


Fixed submission:
s=input()[::-1]
p=["maerd","remaerd","resare","esare"]
while True:
  if s[:5]==p[0]:s=s[5:]
  elif s[:5]==p[3]:s=s[5:]
  elif s[:7]==p[1]:s=s[7:]
  elif s[:6]==p[2]:s=s[6:]
  else:
    if s=="":print("YES");break
    else:print("NO");break

Buggy python submission (verdict: Time Limit Exceeded):
s=input()[::-1]
p=["maerd","remaerd","resare","esare"]
while True:
  if s[:5]==p[0]:s.replace(p[0],"",1)
  elif s[:5]==p[3]:s.replace(p[3],"",1)
  elif s[:7]==p[1]:s.replace(p[1],"",1)
  elif s[:6]==p[2]:s.replace(p[2],"",1)
  else:
    if s=="":print("YES");break
    else:print("NO");break

Fixed submission:
s=input()[::-1]
p=["maerd","remaerd","resare","esare"]
while True:
  if s[:5]==p[0]:s=s[5:]
  elif s[:5]==p[3]:s=s[5:]
  elif s[:7]==p[1]:s=s[7:]
  elif s[:6]==p[2]:s=s[6:]
  else:
    if s=="":print("YES");break
    else:print("NO");break
Buggy python submission (verdict: Runtime Error):
a=list(map(int,input().split()))
print("A"+a[1][0]+"C")


Fixed submission:
a=list(map(str,input().split()))
print("A"+a[1][0]+"C")
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
d=max(a,max(b,c))
if 2*d=(a+b+c):
  print("Yes")
else:
  print("No")

Fixed submission:
a,b,c=map(int,input().split())
d=max(a,max(b,c))
if 2*d==(a+b+c):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n,x=map(int,input().split())
if x==1 or x==2*n-1:print("No")
else:
  print("Yes")
  b=[0]*n
  b[n//2]=x
  b[n//2-1]=x-1
  b[n//2+1]=x+1
  tor=[i+1 for i in range(n)]
  del tor[x-2:x+1]
  for i in range(n):
    if b[i]==0:
      b[i]=tor.pop()
  for i in b:
    print(i)


Fixed submission:
N=int(input())
s=input()
t=input()
for i in range(1,N+1)[::-1]:
  if s[N-i:]==t[:i]:
    print(2*N-i)
    exit()
print(2*N)

Buggy python submission (verdict: Runtime Error):
n,x=map(int,input().split())
if x==1 or x==n:print("No")
else:
  print("Yes")
  b=[0]*n
  b[n//2]=x
  b[n//2-1]=x-1
  b[n//2+1]=x+1
  tor=[i+1 for i in range(n)]
  del tor[x-2:x+1]
  print(tor)
  for i in range(n):
    if b[i]==0:
      b[i]=tor.pop()
  for i in b:
    print(i)


Fixed submission:
N=int(input())
s=input()
t=input()
for i in range(1,N+1)[::-1]:
  if s[N-i:]==t[:i]:
    print(2*N-i)
    exit()
print(2*N)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
  if a[a[i]-1]=i+1:ans+=1
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
  if a[a[i]-1]==i+1:ans+=1
print(ans//2)
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
print(((a+b)*h)//2)
  

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
print(((a+b)*c)//2)
Buggy python submission (verdict: Runtime Error):
import itertools
s=input()
ans=0
L=len(s)
for sta in itertools.product(range(2),L):
  cut=[-1]+[i for i in range(L) if sta[i]]+[L-1]
  for i in range(len(cut)-1):
    ans+=int(s[cut[i]+1:cut[i+1]+1])
print(ans)

Fixed submission:
import itertools
s=input()
ans=0
L=len(s)
for sta in itertools.product(range(2),repeat=L-1):  
  cut=[-1]+[i for i in range(L-1) if sta[i]]+[L-1]
  for i in range(len(cut)-1):
    ans+=int(s[cut[i]+1:cut[i+1]+1])
print(ans)
Buggy python submission (verdict: Runtime Error):
a=list(map(int,input().split()))
a.sort()
if a%2!=0 and b%2!=0 and c%2!=0:
  print(a[0]*a[1])
else:
  print("0")


Fixed submission:
a=list(map(int,input().split()))
a.sort()
if a[0]%2!=0 and a[1]%2!=0 and a[2]%2!=0:
  print(a[0]*a[1])
else:
  print("0")

Buggy python submission (verdict: Runtime Error):
a=list(map(int,input().split()))
a.sort()
if a%2!=0 and b%2!=0 and c%2!=0:
  print(a[0]*a[1])
elif:
  print("0")

Fixed submission:
a=list(map(int,input().split()))
a.sort()
if a[0]%2!=0 and a[1]%2!=0 and a[2]%2!=0:
  print(a[0]*a[1])
else:
  print("0")
Buggy python submission (verdict: Runtime Error):
from collections import Counter
s=input()
c=Counter(s)
flag=0
a=c.values()
for i in range(len(a)):
  if a[i]%2==1:
    flag=1
    break
if flag==0:
  print("Yes")
else:
  print("No")


Fixed submission:
from collections import Counter
s=input()
c=Counter(s)
flag=0
a=list(c.values())
for i in range(len(a)):
  if a[i]%2==1:
    flag=1
    break
if flag==0:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
from collections import Counter
s=input()
c=Counter(s)
flag=0
for i in range(len(c.value)):
  if c.value[i]%2==1:
    flag=1
    break
if flag==0:
  print("Yes")
else:
  print("No")

Fixed submission:
from collections import Counter
s=input()
c=Counter(s)
flag=0
a=list(c.values())
for i in range(len(a)):
  if a[i]%2==1:
    flag=1
    break
if flag==0:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n,a=map(int,input().split())
x=list(map(int,input().split()))
dp=[[[0 for i in range(2501)] for j in range(n+1)] for k in range(n+1)]
#dp[i][j][k]:=i枚目まで見てj枚選んで和がkとなるようなカードの取り方の数
dp[0][0][0]=1
for i in range(n):
    see=x[i]
    for j in range(i+2):
        for k in range(2501):
            dp[i+1][j][k]+=dp[i][j][k]
            if see>k or j==0:continue
            dp[i+1][j][k]+=dp[i][j-1][k-see]
ans=0
for i in range(1,n+1):
    ans+=dp[-1][i][i*a]
print(ans)

Fixed submission:
n,a=map(int,input().split())
x=list(map(int,input().split()))
dp=[[[0 for i in range(2501)] for j in range(k+2)] for k in range(n+1)]
#dp[i][j][k]:=i枚目まで見てj枚選んで和がkとなるようなカードの取り方の数
dp[0][0][0]=1
for i in range(n):
    see=x[i]
    for j in range(i+2):
        for k in range(2501):
            dp[i+1][j][k]+=dp[i][j][k]
            if see>k or j==0:continue
            dp[i+1][j][k]+=dp[i][j-1][k-see]
ans=0
for i in range(1,n+1):
    ans+=dp[-1][i][i*a]
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=[int(input()) for i in range(n)]
ans=0
for i in range(n):
  ans+=(l[i]-l[i]%2)//2
  l[i]%=2
  if l[i]==1
    if i==n-1:break
    ans+=1
    l[i]=0;l[i+1]-=1
print(ans)


Fixed submission:
s=input()
a =["N","S","W","E"]
flag1=0
flag2=0
if a[0] in s and a[1] in s:
  flag1=1
if a[0] not in s and a[1] not in s:
  flag1=1
if a[2] in s and a[3] in s:
  flag2=1
if a[2] not in s and a[3] not in s:
  flag2=1
if flag1+flag2==2:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
s=input()
a =["N","S","W","E"]
flag1=0
flag2=0
if a[0] in s and a[1] in s:
  flag1=1
if a[0] not in s and a[1] not in s:
  flag1=1
if a[2] in s and a[3] in s:
  flag2=1
if a[2] not in s and a[3] not in s:
  flag2=1
if flag1+flag2=2:
  print("Yes")
else:
  print("No")

Fixed submission:
s=input()
a =["N","S","W","E"]
flag1=0
flag2=0
if a[0] in s and a[1] in s:
  flag1=1
if a[0] not in s and a[1] not in s:
  flag1=1
if a[2] in s and a[3] in s:
  flag2=1
if a[2] not in s and a[3] not in s:
  flag2=1
if flag1+flag2==2:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=[int(input()) for i in range(n)]
ans=0
for i in range(n):
  ans+=(l[i]-l[i]%2)//2
  l[i]%=2
  if l[i]==1
    ans+=1
    l[i]=0;l[i+1]-=1
print(ans)


Fixed submission:
n=int(input())
ans=0
check=0
for i in range(n):
  s=int(input())
  if i==n-1:
    check+=s
    ans+=check//2
  elif s!=0:
    check+=s
  else:
    ans+=check//2
    check=0
print(ans)
Buggy python submission (verdict: Runtime Error):
s=list(input())
ans=""
l=len(s)
n=0
for i in range(l):
  if s[i]=="0"or s[i]=="1":
    ans+=s[i]
    n+=1
  elif s[i]=="B" and n==0:
    pass
  else:
    ans-=ans[-1]
    n-=1
print(ans)

Fixed submission:
s=list(input())
ans=""
l=len(s)
n=0
for i in range(l):
  if s[i]=="0"or s[i]=="1":
    ans+=s[i]
    n+=1
  elif s[i]=="B" and n==0:
    pass
  else:
    ans= ans[:n-1]
    n-=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n,l=map(int,input().split())
r=list(map(int,input().split()))
last=0;tiepoint=0
for i in range(n-1):
  if r[i]+r[i+1]>last:
    last=r[i]+r[i+1]
    tiepoint=i
if last>=l:
  print("Possible")
  for i in range(n-1):
    if i==tiepoint:continue
    print(i+1)
  print(tiepoint+1)
else:print("Impossible")


Fixed submission:
a,b=map(int,input().split())
if a*b<=0:
  print('Zero')
else:
  if a>0 and b>0:
    print('Positive')
  elif (b-a)%2==0:
    print('Negative')
  else:
    print('Positive')
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionimit(200000)
n,l=map(int,input().split())
r=list(map(int,input().split()))
last=0;tiepoint=0
for i in range(n-1):
  if r[i]+r[i+1]>last:
    last=r[i]+r[i+1]
    tiepoint=i
if last>=l:
  print("Possible")
  for i in range(tiepoint-1):
    print(i+1)
  for i in range(tiepoint+1,n)[::-1]:
      print(i+1)
  print(tiepoint+1)
else:print("Impossible")


Fixed submission:
import sys
sys.setrecursionlimit(200000)
n,l=map(int,input().split())
r=list(map(int,input().split()))
last=0;tiepoint=0
for i in range(n-1):
  if r[i]+r[i+1]>last:
    last=r[i]+r[i+1]
    tiepoint=i
if last>=l:
  print("Possible")
  for i in range(tiepoint):
    print(i+1)
  for i in range(tiepoint+1,n-1)[::-1]:
      print(i+1)
  print(tiepoint+1)
else:print("Impossible")

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionimit(200000)
n,l=map(int,input().split())
r=list(map(int,input().split()))
last=0;tiepoint=0
for i in range(n-1):
  if r[i]+r[i+1]>last:
    last=r[i]+r[i+1]
    tiepoint=i
if last>=l:
  print("Possible")
  for i in range(n-1):
    if i==tiepoint:continue
    print(i+1)
  print(tiepoint+1)
else:print("Impossible")


Fixed submission:
import sys
sys.setrecursionlimit(200000)
n,l=map(int,input().split())
r=list(map(int,input().split()))
last=0;tiepoint=0
for i in range(n-1):
  if r[i]+r[i+1]>last:
    last=r[i]+r[i+1]
    tiepoint=i
if last>=l:
  print("Possible")
  for i in range(tiepoint):
    print(i+1)
  for i in range(tiepoint+1,n-1)[::-1]:
      print(i+1)
  print(tiepoint+1)
else:print("Impossible")

Buggy python submission (verdict: Runtime Error):
n,l=map(int,input().split())
r=list(map(int,input().split()))
last=0;tiepoint=0
for i in range(n-1):
  if r[i]+r[i+1]>last:
    last=r[i]+r[i+1]
    tiepoint=i
if last>=l:print("Possible")
  for i in range(n):
    if i==tiepoint:continue
    print(i)
else:print("Impossible")

Fixed submission:
import sys
sys.setrecursionlimit(200000)
n,l=map(int,input().split())
r=list(map(int,input().split()))
last=0;tiepoint=0
for i in range(n-1):
  if r[i]+r[i+1]>last:
    last=r[i]+r[i+1]
    tiepoint=i
if last>=l:
  print("Possible")
  for i in range(tiepoint):
    print(i+1)
  for i in range(tiepoint+1,n-1)[::-1]:
      print(i+1)
  print(tiepoint+1)
else:print("Impossible")
Buggy python submission (verdict: Runtime Error):
n,l=map(int,input().split())
words=[]
for i in range(n):
  words.append(input())
for i in range(n-1,-1,-1):
  words.sort(key=lambda x:ord(x[i]))
ans=""
for i in range(n):
  ans+=words[i]
print(ans)


Fixed submission:
n,l=map(int,input().split())
words=[]
for i in range(n):
  words.append(input())
for i in range(l-1,-1,-1):
  words.sort(key=lambda x:ord(x[i]))
ans=""
for i in range(n):
  ans+=words[i]
print(ans)

Buggy python submission (verdict: Runtime Error):
n,l=map(int,input().split())
words=[]
for i in range(n):
  words.append(input())
for i in range(n-1,0,-1):
  words.sort(key=lambda x:ord(x[i]))
ans=""
for i in range(n):
  ans+=words[i]
print(ans)

Fixed submission:
n,l=map(int,input().split())
words=[]
for i in range(n):
  words.append(input())
for i in range(l-1,-1,-1):
  words.sort(key=lambda x:ord(x[i]))
ans=""
for i in range(n):
  ans+=words[i]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=-10**10
for i in range(n):
	loop=[0]
	now=i
	while True:
		now=p[now]-1
		loop.append(loop[-1]+c[now])
		if now==i:
			break
	L=len(loop)-1
	if k<=L:
		score=max(loop[1:k+1])
		ans=max(score,ans)
	else:
		score=max(loop[-1],0)*(k//L-1)
		ans=max(ans,score)
		for j in range(k%L+L):
			score+=loop[j%L+1]-loop[j%L]
			ans=max(score,ans)
print(ans)

Fixed submission:
n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=-10**10
for i in range(n):
	loop=[0]
	now=i
	while True:
		now=p[now]-1
		loop.append(loop[-1]+c[now])
		if now==i:
			break
	L=len(loop)-1
	if k<=L:
		score=max(loop[1:k+1])
		ans=max(score,ans)
	else:
		score=max(loop[-1],0)*(k//L-1)
		ans=max(ans,score)
		for j in range(k%L+L):
			score+=loop[j%L+1]-loop[j%L]
			ans=max(score,ans)
print(ans)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=-10**10
for i in range(n):
	K=k
	score=0
	pre_score=0
	visit=[0]*n
	now=i
	cnt=0
	while visit[now]==0:
		cnt+=1
		visit[now]=1
		now=p[now]-1
		pre_score+=c[now]
		if cnt!=1:
			score=max(score,pre_score)
		else:
			score=pre_score
		K-=1
		if K==0:
			break
	ans=max(score,ans)
	if K==0:
		print(2/0)
		continue
	loop=[0]
	NOW=now
	#NOWはループ元
	for j in range(n):
		now=p[now]-1
		loop.append(loop[-1]+c[now])
		if NOW==now:
			break
	pre_score+=max(loop[-1],0)*(K//(len(loop)-1))
	K%=(len(loop)-1)
	pre_score+=max(loop[:K+1])
	score=max(score,pre_score)
	ans=max(ans,score)
print(ans)


Fixed submission:
n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=-10**10
for i in range(n):
	loop=[0]
	now=i
	while True:
		now=p[now]-1
		loop.append(loop[-1]+c[now])
		if now==i:
			break
	L=len(loop)-1
	if k<=L:
		score=max(loop[1:k+1])
		ans=max(score,ans)
	else:
		score=max(loop[-1],0)*(k//L-1)
		ans=max(ans,score)
		for j in range(k%L+L):
			score+=loop[j%L+1]-loop[j%L]
			ans=max(score,ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=-1
r=max(a)+1
while r-l>1:
	cnt=0
	mid=(l+r)//2
	for x in a:
		if x>1:
			cnt+=(x-1)//mid
	if cnt<=k:
		r=mid
	else:
		l=mid
print(r)


Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=0
r=max(a)+1
while r-l>1:
	cnt=0
	mid=(l+r+1)//2
	if mid==0:
		print(1)
		exit()
	for x in a:
		if x>1:
			cnt+=(x-1)//mid
	if cnt<=k:
		r=mid
	else:
		l=mid
print(r)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=-1
r=max(a)+1
while r-l>1:
	cnt=0
	mid=(l+r)//2
	for x in a:
		cnt+=(x-1)//mid
	if cnt<=k:
		r=mid
	else:
		l=mid
print(r)


Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=0
r=max(a)+1
while r-l>1:
	cnt=0
	mid=(l+r+1)//2
	if mid==0:
		print(1)
		exit()
	for x in a:
		if x>1:
			cnt+=(x-1)//mid
	if cnt<=k:
		r=mid
	else:
		l=mid
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappop,heappush
from math import ceil
n,k=map(int,input().split())
a=list(map(int,input().split()))
hq=[]
for x in a:
	heappush(hq,[-x,1])
for i in range(k):
	r=heappop(hq)
	heappush(hq,[r[0]*r[1]/(r[1]+1),r[1]+1])
ans=-heappop(hq)[0]
print(ceil(ans))

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=0
r=max(a)+1
while r-l>1:
	cnt=0
	mid=(l+r+1)//2
	if mid==0:
		print(1)
		exit()
	for x in a:
		if x>1:
			cnt+=(x-1)//mid
	if cnt<=k:
		r=mid
	else:
		l=mid
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappop,heappush
from math import ceil
from fractions import Fraction as F
n,k=map(int,input().split())
a=list(map(int,input().split()))
hq=[]
for x in a:
	heappush(hq,[-x,1])
for i in range(k):
	r=heappop(hq)
	heappush(hq,[F(r[0]*r[1],(r[1]+1)),r[1]+1])
ans=-heappop(hq)[0]
print(ceil(ans))

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=0
r=max(a)+1
while r-l>1:
	cnt=0
	mid=(l+r+1)//2
	if mid==0:
		print(1)
		exit()
	for x in a:
		if x>1:
			cnt+=(x-1)//mid
	if cnt<=k:
		r=mid
	else:
		l=mid
print(r)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
n,q=map(int,input().split())
c=list(map(int,input().split()))
ab=[[]for i in range(n)]
lr=[[]for i in range(n)]
num=[-1]*n
for i in range(n):
	if num[c[i]-1]!=-1:
		ab[num[c[i]-1]].append(i)
	num[c[i]-1]=i
for i in range(q):
	l,r=map(int,input().split())
	lr[l-1].append((r-1,i))
ans=[-1]*q
BIT=[0]*n
for i in range(n-1,-1,-1):
	for x in ab[i]:
		x+=1
		while x<=n:
			BIT[x-1]+=1
			x=x+(x&-x)
	for x,y in lr[i]:
		X=x
		x+=1
		ret=0
		while x!=0:
			ret+=BIT[x-1]
			x=x-(x&-x)
		ans[y]=X-i+1-ret
for x in ans:
	print(x)

Fixed submission:
def main():
	import sys
	input=sys.stdin.readline
	n,q=map(int,input().split())
	c=list(map(int,input().split()))
	ab=[[]for i in range(n)]
	lr=[[]for i in range(n)]
	num=[-1]*n
	for i in range(n):
		if num[c[i]-1]!=-1:
			ab[num[c[i]-1]].append(i)
		num[c[i]-1]=i
	for i in range(q):
		l,r=map(int,input().split())
		lr[l-1].append((r-1,i))
	ans=[-1]*q
	BIT=[0]*n
	for i in range(n-1,-1,-1):
		for x in ab[i]:
			x+=1
			while x<=n:
				BIT[x-1]+=1
				x=x+(x&-x)
		for x,y in lr[i]:
			X=x
			x+=1
			ret=0
			while x!=0:
				ret+=BIT[x-1]
				x=x-(x&-x)
			ans[y]=X-i+1-ret
	for x in ans:
		print(x)
if __name__ == '__main__':
	main()
Buggy python submission (verdict: Runtime Error):
n=int(input())
x=input()
one=x.count("1")
amari_m=0
amari_p=0
for i in range(n):
	if x[-i-1]=="1":
		amari_p+=pow(2,i,one+1)
		amari_m+=pow(2,i,one-1)
		amari_p%=one+1
		amari_m%=one-1
for i in range(n):
	cnt=0
	if x[i]=="1":
		r=(amari_m-pow(2,(n-i-1),one-1))%(one-1)
	else:
		r=(amari_p+pow(2,(n-i-1),one+1))%(one+1)
	while r:
		r%=bin(r).count("1")
		cnt+=1
	print(cnt+1)


Fixed submission:
n=int(input())
x=input()
one=x.count("1")
amari_m=0
amari_p=0
for i in range(n):
	if x[-i-1]=="1":
		amari_p+=pow(2,i,one+1)
		if one==1:
			amari_m=-1
		else:
			amari_m+=pow(2,i,one-1)
		amari_p%=one+1
		if one!=1:
			amari_m%=one-1
for i in range(n):
	cnt=0
	if x[i]=="1":
		if one==1:
			print(0)
			continue
		r=(amari_m-pow(2,(n-i-1),one-1))%(one-1)
	else:
		r=(amari_p+pow(2,(n-i-1),one+1))%(one+1)
	while r:
		r%=bin(r).count("1")
		cnt+=1
	print(cnt+1)