Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

from collections import deque

def main():
	h,w,m=MI()
	A=[0]*(h+1)
	B=[0]*(w+1)
	C=[[] for _ in range(h+1)]

	for _ in range(m):
		hh,ww=MI()
		A[hh]+=1
		B[ww]+=1
		C[hh].append(ww)


	for i in range(h+1):
		C[i].sort()

	AA=max(A)
	BB=max(B)

	x=[]
	y=[]

	for i,v in enumerate(A):
		if v==AA:
			x.append(i)

	for i,v in enumerate(B):
		if v==BB:
			y.append(i)

	#print(x,y,AA,BB)
	ans=0

	for i in x:
		#print("a")
		#print(C[i])
		#print(y)
		a=0
		for j in y:
			while True:
				if j==C[i][a]:
					a+=1
					break
				elif j<C[i][a]:
					print(AA+BB)
					exit()
				else:
					break

	print(AA+BB-1)
















if __name__ == "__main__":
	main()


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

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

from collections import deque

def main():
	h,w,m=MI()
	A=[0]*(h+1)
	B=[0]*(w+1)
	C=[[] for _ in range(h+1)]

	for _ in range(m):
		hh,ww=MI()
		A[hh]+=1
		B[ww]+=1
		C[hh].append(ww)


	for i in range(h+1):
		C[i].sort()

	AA=max(A)
	BB=max(B)

	x=[]
	y=[]

	for i,v in enumerate(A):
		if v==AA:
			x.append(i)

	for i,v in enumerate(B):
		if v==BB:
			y.append(i)

	#print(x,y,AA,BB)
	#print(C)
	ans=0

	for i in x:
		C[i].append(10**7)
		#print("a")
		#print(C[i])
		#print(y)
		a=0
		for j in y:
			while a<len(C[i]):
				if j==C[i][a]:
					a+=1
					break
				elif j<C[i][a]:
					print(AA+BB)
					exit()
				else:
					a+=1

	print(AA+BB-1)
















if __name__ == "__main__":
	main()
Buggy python submission (verdict: Time Limit Exceeded):
#import sys
#input = sys.stdin.readline
#input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np
from collections import defaultdict

def main():

	mod=10**9+7

	n=II()
	s=input()
	s=len(s)

	pp=[1]
	for i in range(n+10):
		pp.append(pp[-1]*25%mod)


	nn=n+s

	comb=[1]
	for i in range(1,n+10):
		comb.append(comb[-1]*(nn-i+1)*pow(i,mod-2,mod)%mod)
	#print(comb)


	ans=0

	for i in range(n+1):
		ans+=(pp[i]*comb[i])%mod
		ans%=mod
	print(ans)












if __name__ == "__main__":
	main()


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


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np
from collections import defaultdict

def main():

	mod=10**9+7

	n=II()
	s=input()
	s=len(s)

	pp=[1]
	for i in range(n+10):
		pp.append(pp[-1]*25%mod)


	nn=n+s

	comb=[1]
	for i in range(1,n+10):
		comb.append(comb[-1]*(nn-i+1)*pow(i,mod-2,mod)%mod)
	#print(comb)


	ans=0

	for i in range(n+1):
		ans+=(pp[i]*comb[i])%mod
		ans%=mod
	print(ans)












if __name__ == "__main__":
	main()
Buggy python submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	a,b=MI()
	print(a*b)


if __name__ == "__main__":
	main()


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


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	n=II()
	A=LI()

	ans=1
	A.sort()
	for i in range(n):
		ans*=A[i]
		if ans>10**18:
			print(-1)
			exit(0)

	print(ans)


if __name__ == "__main__":
	main()
Buggy python submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

import numpy as np

def main():
	n,s=MI()
	A=LI()

	li=[0]*(s+10)
	li=np.array(li)
	li[0]=1
	#print(li)

	for i in A:
		tmp=li.copy()
		li*=2
		if i<n:
			li[i:]+=tmp[:s+10-i]
		li%=998244353
		#print(li)
	print(li[s])



if __name__ == "__main__":
	main()


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


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

import numpy as np

def main():
	n,s=MI()
	A=LI()

	li=[0]*(3010)
	li=np.array(li)
	li[0]=1
	#print(li)

	for i in A:
		tmp=li.copy()
		li*=2
		li[i:]+=tmp[:3010-i]
		li%=998244353
		#print(li)
	print(li[s])



if __name__ == "__main__":
	main()

Buggy python submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

import numpy as np

def main():
	n,s=MI()
	A=LI()

	li=[0]*(s+10)
	li=np.array(li)
	li[0]=1
	#print(li)

	for i in A:
		tmp=li.copy()
		li*=2
		li[i:]+=tmp[:s+10-i]
		li%=998244353
		#print(li)
	print(li[s])



if __name__ == "__main__":
	main()


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


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

import numpy as np

def main():
	n,s=MI()
	A=LI()

	li=[0]*(3010)
	li=np.array(li)
	li[0]=1
	#print(li)

	for i in A:
		tmp=li.copy()
		li*=2
		li[i:]+=tmp[:3010-i]
		li%=998244353
		#print(li)
	print(li[s])



if __name__ == "__main__":
	main()
Buggy python submission (verdict: Runtime Error):
import sys

input=sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()


def II(): return int(input())


def MI(): return map(int,input().split())


def MF(): return map(float,input().split())


def LI(): return list(map(int,input().split()))


def LF(): return list(map(float,input().split()))


def TI(): return tuple(map(int,input().split()))


# rstrip().decode('utf-8')

import numpy as np

def main():
	n,m,x=MI()
	C=[]
	A=[]
	for _ in range(n):
		c_,*A_=LI()
		C.append(c_)
		A.append(A_)
	A=np.array(A)
	
	ans=10**10
	
	for i in range(1<<n):
		B=np.zeros(m)
		cnt=0
		for j in range(n):
			if 1<<j&i:
				cnt+=C[j]
				B+=A[j]
		if np.min(B)>=x:
			ans=min(ans,cnt)
	print(ans if ans!=10**10 else -1)
	





if __name__=="__main__":
	main()


Fixed submission:
import sys

input=sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()


def II(): return int(input())


def MI(): return map(int,input().split())


def MF(): return map(float,input().split())


def LI(): return list(map(int,input().split()))


def LF(): return list(map(float,input().split()))


def TI(): return tuple(map(int,input().split()))


# rstrip().decode('utf-8')

import numpy as np

def main():
	n,m,x=MI()
	C=[]
	A=[]
	for _ in range(n):
		c_,*A_=LI()
		C.append(c_)
		A.append(A_)
	A=np.array(A)
	
	ans=10**10
	
	for i in range(1<<n):
		B=np.zeros(m)
		cnt=0
		for j in range(n):
			if 1<<j&i:
				cnt+=C[j]
				B+=A[j]
		if np.min(B)>=x:
			ans=min(ans,cnt)
	print(ans if ans!=10**10 else -1)
	





if __name__=="__main__":
	main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
#input = sys.stdin.buffer.readline


# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np

def main():
	s = input()
	n = int(input())
	f = 0
	l = ""
	r = ""
	for i in range(n):
		q=input().split()
		if q[0] == "1":
			f ^= 1
		else:
			if (f == 0 and q[1] == "1") or (f == 1 and q[1] == "2"):
				l = l + q[2]
			else:
				r = r + q[2]
	if f == 0:
		ans = l[::-1] + s + r
	else:
		ans = r[::-1] + s[::-1] + l
	print(ans)


if __name__ == "__main__":
	main()


Fixed submission:
s=input()
n=int(input())
f=0
l=""
r=""
for i in range(n):
	q=input().split()
	if q[0]=="1":
		f^=1
	else:
		if (f==0 and q[1]=="1") or (f==1 and q[1]=="2"):
			l=l+q[2]
		else:
			r=r+q[2]

if f==0:
	ans=l[::-1]+s+r
else:
	ans=r[::-1]+s[::-1]+l

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
n=int(input())
f=0
l=""
r=""
for i in range(n):
	q=input().split()
	if q[0]=="1":
		f^=1
	else:
		if (f==0 and q[1]=="1") or (f==1 and q[1]=="2"):
			l=l+q[2]
		else:
			r=r+q[2]

if f==0:
	ans=l[::-1]+s+r
else:
	ans=r[::-1]+s[::-1]+l

print(ans)







Fixed submission:
s=input()
n=int(input())
f=0
l=""
r=""
for i in range(n):
	q=input().split()
	if q[0]=="1":
		f^=1
	else:
		if (f==0 and q[1]=="1") or (f==1 and q[1]=="2"):
			l=l+q[2]
		else:
			r=r+q[2]

if f==0:
	ans=l[::-1]+s+r
else:
	ans=r[::-1]+s[::-1]+l

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()


def main():
	r1,c1,r2,c2=MI()
	m=10**9+7

	ff=[1]

	for i in range(1,10**6+5):
		ff.append(ff[-1]*i%m)


	def f(r,c):
		return (ff[r+c]*pow(ff[r],m-2,m)*pow(ff[c],m-2,m))%m

	ans=0
	ans+=f(r2+1,c2+1)
	ans+=f(r1,c1)
	ans-=f(r2+1,c1)
	ans-=f(r1,c2+1)

	print(ans%m)














if __name__ == "__main__":
	main()


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

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()


def main():
	r1,c1,r2,c2=MI()
	m=10**9+7

	ff=[1]

	for i in range(1,2*10**6+5):
		ff.append(ff[-1]*i%m)


	def f(r,c):
		return (ff[r+c]*pow(ff[r],m-2,m)*pow(ff[c],m-2,m))%m

	ans=0
	ans+=f(r2+1,c2+1)
	ans+=f(r1,c1)
	ans-=f(r2+1,c1)
	ans-=f(r1,c2+1)

	print(ans%m)



if __name__ == "__main__":
	main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines

#mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np


def main():
	h,n=map(int,input().split())
	AB=[list(map(int,input().split())) for _ in range(n)]
	
	li=[10**10]*(10**5)
	li[0]=0
	
	for i in range(h):
		if li[i]==10**10:
			continue
		else:
			for a,b in AB:
				li[i+a]=min(li[i+a],li[i]+b)
	
	print(min(li[h:]))
	
	
	
	
	
	

if __name__ == "__main__":
	main()


Fixed submission:
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines

#mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np


def main():
	h,n=map(int,input().split())
	AB=[list(map(int,input().split())) for _ in range(n)]
	
	li=[10**10]*(10**5)
	li[0]=0
	
	for i in range(h):
		if li[i]==10**10:
			continue
		else:
			for a,b in AB:
				li[i+a]=min(li[i+a],li[i]+b)
	
	print(min(li[h:]))
	
	
	
	
	
	

if __name__ == "__main__":
	main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np

def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod



def main():
	n,k=map(int,input().split())
	A=list(map(int,input().split()))
	A.sort()
	ans=0
	for i in range(n-k+1):
		ans+=((comb(k-1+i,k-1,mod)*A[k-1+i])-(comb(k-1+i,k-1,mod)*A[n-k-i]))%mod
		ans=ans%mod
	print(ans)


if __name__ == "__main__":
	main()


Fixed submission:
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np


def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def main():
	n,k=map(int,input().split())
	A=list(map(int,input().split()))
	A.sort()
	
	comb=[1]
	for i in range(n-k):
		comb.append((comb[-1]*(k+i)*pow(i+1,mod-2,mod))%mod)
	ans=0
	
	for i in range(n-k+1):
		ans+=((comb[i]*A[k-1+i])-(comb[i]*A[n-k-i]))%mod
		ans=ans%mod
	print(ans)


if __name__ == "__main__":
	main()
Buggy python submission (verdict: Runtime Error):
import sys
#input = sys.stdin.buffer.readline
input = sys.stdin.readline

# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np


def main():
	n=int(input())
	s=[]
	t=[]
	for i in range(n):
		a,b=input().split()
		s.append(a)
		t.append(int(b))
	x=input()

	for i in range(n):
		if x==s[i]:
			print(sum(t[i+1:]))
            exit(0)













if __name__ == "__main__":
	main()


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

# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np


def main():
	n=int(input())
	s=[]
	t=[]
	for i in range(n):
		a,b=input().split()
		s.append(a)
		t.append(int(b))
	x=input()
	for i in range(n):
		if x==s[i]:
			ans=sum(t[i+1:])
			print(ans)
			exit(0)


if __name__ == "__main__":
	main()
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n,m=map(int,input().split())
A=list(map(int,input().split()))
A.sort()

def hand(x):
  cnt=0
  for i in range(n):
    p=x-A[i]
    cnt+=n-bisect.bisect_left(A,p)
  return cnt


l=0
h=10**15+3
mid=(l+h)//2

while l+1<h:
  mid=(l+h)//2
  if hand(mid)<m:
    h=mid
  else:
    l=mid

B=A[::-1]

for i in range(n-1):
  B[i+1]+=B[i]

B=B[::-1]

ans=0
cnt=0


for i in range(n):
  y=l-A[i]+1
  index=bisect.bisect_left(A,y)
  if n==index:
    continue
  else:
    ans+=(n-index)*A[i]+B[index]
    cnt+=(n-index)

ans+=(m-cnt)*l
print(ans)
  

  
  

Fixed submission:
import sys
 
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines

import bisect

n,m=map(int,input().split())
A=list(map(int,input().split()))
A.sort()

def hand(x):
  cnt=0
  for i in range(n):
    p=x-A[i]
    cnt+=n-bisect.bisect_left(A,p)
  return cnt

def main():
  l=0
  h=10**15+3
  mid=(l+h)//2
  
  while l+1<h:
    mid=(l+h)//2
    if hand(mid)<m:
      h=mid
    else:
      l=mid
  
  B=A[::-1]
  
  for i in range(n-1):
    B[i+1]+=B[i]
  
  B=B[::-1]
  
  ans=0
  cnt=0
  
  
  for i in range(n):
    y=l-A[i]+1
    index=bisect.bisect_left(A,y)
    if n==index:
      continue
    else:
      ans+=(n-index)*A[i]+B[index]
      cnt+=(n-index)
  
  ans+=(m-cnt)*l
  print(ans)

if __name__ == "__main__":
	main()

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n,m=map(int,input().split())
A=list(map(int,input().split()))
A.sort()

def hand(x):
  cnt=0
  for i in range(n):
    p=x-A[i]
    cnt+=n-bisect.bisect_left(A,p)
  return cnt


l=0
h=10**15+3
mid=(l+h)//2

while l+1<h:
  mid=(l+h)//2
  if hand(mid)<m:
    h=mid
  else:
    l=mid

B=A[::-1]

for i in range(n-1):
  B[i+1]+=B[i]

B=B[::-1]

ans=0
cnt=0


for i in range(n):
  y=l-A[i]+1
  index=bisect.bisect_left(A,y)
  if n==index:
    continue
  else:
    ans+=(n-index)*A[i]+B[index]
    cnt+=(n-index)

ans+=(m-cnt)*l
print(ans)
  

  
  

Fixed submission:
import sys
 
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines

import bisect

n,m=map(int,input().split())
A=list(map(int,input().split()))
A.sort()

def hand(x):
  cnt=0
  for i in range(n):
    p=x-A[i]
    cnt+=n-bisect.bisect_left(A,p)
  return cnt

def main():
  l=0
  h=10**15+3
  mid=(l+h)//2
  
  while l+1<h:
    mid=(l+h)//2
    if hand(mid)<m:
      h=mid
    else:
      l=mid
  
  B=A[::-1]
  
  for i in range(n-1):
    B[i+1]+=B[i]
  
  B=B[::-1]
  
  ans=0
  cnt=0
  
  
  for i in range(n):
    y=l-A[i]+1
    index=bisect.bisect_left(A,y)
    if n==index:
      continue
    else:
      ans+=(n-index)*A[i]+B[index]
      cnt+=(n-index)
  
  ans+=(m-cnt)*l
  print(ans)

if __name__ == "__main__":
	main()
Buggy python submission (verdict: Runtime Error):
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
import numpy as np

def main():
	n,m=map(int,input().split())
	s=input().rstrip().decode('utf-8')
	t=s[::-1]
	
	ans=[]
	
	now=0
	while now<n:
		for i in range(min(m,n-now),0,-1):
			
			if t[now+i]=="0":
				now+=i
				ans.append(i)
				break
			else:
				continue
		else:
			print(-1)
			exit(0)
	
	print(*ans[::-1])
	
	
	
	
	
	
	



if __name__ == "__main__":
	main()


Fixed submission:
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np

def main():
	n,m=map(int,input().split())
	s=input().rstrip().decode('utf-8')
	t=s[::-1]
	
	ans=[]
	
	now=0
	while now<n:
		for i in range(min(m,n-now),0,-1):
			
			if t[now+i]=="0":
				now+=i
				ans.append(i)
				break
			else:
				continue
		else:
			print(-1)
			exit(0)
	
	print(*ans[::-1])
	
	
	
	
	
	
	



if __name__ == "__main__":
	main()
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

import numpy as np

def main():
	n=II()
	A=LI()

	A=np.array(A)

	B=np.cumsum(A)
	C=np.cumsum(A[::-1])

	#print(B,C)

	D=abs(B[:-1]-C[:-1][::-1])
	#print(D)

	print(np.min(D))









if __name__ == "__main__":
	main()


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

# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np


def main():
	n=int(input())
	A=list(map(int,input().split()))

	ans=10**18
	cnt=0

	Asum=sum(A)
	for i in range(n):
		cnt+=A[i]
		ans=min(ans,abs(Asum-2*cnt))
	print(ans)









if __name__ == "__main__":
	main()