Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
mxn = 10**6 + 11
arr = []
for i in range(1,mxn):
    if i % 3 == 0 and i % 5 == 0:
        arr.append(0)
    elif i % 3 == 0:
        arr.append(0)
    elif i%5 == 0:
        arr.append(0)
    else:
        arr.append(i)

n = int(input())
print(sum[:n])


Fixed submission:
mxn = 10**6 + 11
arr = []
for i in range(1,mxn):
    if i % 3 == 0 and i % 5 == 0:
        arr.append(0)
    elif i % 3 == 0:
        arr.append(0)
    elif i%5 == 0:
        arr.append(0)
    else:
        arr.append(i)

n = int(input())
print(sum(arr[:n]))
Buggy python submission (verdict: Runtime Error):
import math
n , a , b  = map(int, input().split())
if b == 0: exit(print(n))
if a >= n : exit(print(n))
if a == 0: exit(print(0))
ans = n//(a+b)
#print("ans",ans)
print(ans*a+(n-ans*a-ans*b))


Fixed submission:
s = list(input())
if len(set(s)) == 1:
    print("No")
else:
    print("Yes")

Buggy python submission (verdict: Runtime Error):
import math
n , a , b  = map(int, input().split())
if a >= n : exit(print(n))
if a == 0: exit(print(0))
ans = n//(a+b)
#print("ans",ans)
print(ans*a+(n-ans*a-ans*b))


Fixed submission:
s = list(input())
if len(set(s)) == 1:
    print("No")
else:
    print("Yes")

Buggy python submission (verdict: Runtime Error):
import math
n , a , b  = map(int, input().split())
if a >= n : exit(print(n))
ans = n//(a+b)
#print("ans",ans)
print(ans*a+(n-ans*a-ans*b))

Fixed submission:
s = list(input())
if len(set(s)) == 1:
    print("No")
else:
    print("Yes")

Buggy python submission (verdict: Runtime Error):
import math
n , a , b  = map(int, input().split())
if a >= n : exit(print(n))
ans = n//(a+b)
#print("ans",ans)
print(ans*a+(n-ans*a-ans*b))

Fixed submission:
s = list(input())
if len(set(s)) == 1:
    print("No")
else:
    print("Yes")

Buggy python submission (verdict: Runtime Error):
import math
n , a , b  = map(int, input().split())
if a >= n : exit(print(n))
ans = n/(a+b)
print(math.floor(ans*a))

Fixed submission:
s = list(input())
if len(set(s)) == 1:
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
import math
a,b = map(int, input().split())
for i in range(1 , 1e5):
    a2 = math.floor(i*0.08)
    b2 = math.floor(i*0.1)
    if a2 == a and b2 == b:
        exit(print(i))
    print(-1)

Fixed submission:
import math
a,b = map(int, input().split())
for i in range(1 , 100000):
    a2 = math.floor(i*0.08)
    b2 = math.floor(i*0.1)
    if a2 == a and b2 == b:
        exit(print(i))
print(-1)
Buggy python submission (verdict: Runtime Error):
N,X,M=map(int,input().split())
l=[X]
p=[-1]*(M+1)
p[X]=0
for i in range(N-1):
    x=(l[-1]**2)%M
    if p[x]>=0:
        break
    l.append(x)
    p[x]=i+1
x=p[x]
y=len(l)-x
print(sum(l[:x])+(N-x)//y*sum(l[x:])+sum(l[x:x+(N-x)%y]))

Fixed submission:
N,X,M=map(int,input().split())
l=[X]
p=[-1]*(M+1)
p[X]=0
x=0
for i in range(N-1):
    x=(l[-1]**2)%M
    if p[x]>=0:
        break
    l.append(x)
    p[x]=i+1
x=p[x]
y=len(l)-x
print(sum(l[:x])+(N-x)//y*sum(l[x:])+sum(l[x:x+(N-x)%y]))

Buggy python submission (verdict: Runtime Error):
N,X,M=map(int,input().split())
l=[X]
p=[-1]*M
p[X]=0
for i in range(N-1):
    x=(l[-1]**2)%M
    if p[x]>=0:
        break
    l.append(x)
    p[x]=i+1
if i==N-2:
    print(sum(l))
else:
    x=p[x]
    y=len(l)-x
    print(sum(l[:x])+(N-x)//y*sum(l[x:])+sum(l[x:x+(N-x)%y]))

Fixed submission:
N,X,M=map(int,input().split())
l=[X]
p=[-1]*(M+1)
p[X]=0
x=0
for i in range(N-1):
    x=(l[-1]**2)%M
    if p[x]>=0:
        break
    l.append(x)
    p[x]=i+1
x=p[x]
y=len(l)-x
print(sum(l[:x])+(N-x)//y*sum(l[x:])+sum(l[x:x+(N-x)%y]))
Buggy python submission (verdict: Runtime Error):
code = r"""
# distutils: language=c++
# distutils: include_dirs=[/home/contestant/.local/lib/python3.8/site-packages/numpy/core/include,/opt/atcoder-stl]
# cython: boundscheck=False
# cython: wraparound=False
from libcpp cimport bool
from libcpp.vector cimport vector
cdef extern from "/opt/atcoder-stl/atcoder/dsu.hpp" namespace "atcoder":
    cpdef cppclass dsu:
        dsu(int n)
        int merge(int a, int b)
        bool same(int a, int b)
        int leader(int a)
        int size(int a)
        vector[vector[int]] groups()
cdef class dsu_:
    cdef dsu *ptr
    def __cinit__(self, int n): self.ptr = new dsu(n)
    def __dealloc__(self): del self.ptr
    cpdef int merge(self,a,b): return self.ptr.merge(a,b)
    cpdef bool same(self,a,b): return self.ptr.same(a,b)
    cpdef int leader(self,a): return self.ptr.leader(a)
    cpdef int size(self,a): return self.ptr.size(a)
    cpdef vector[vector[int]] groups(self): return self.ptr.groups()

cdef extern from "/opt/atcoder-stl/atcoder/fenwicktree.hpp" namespace "atcoder":
    cdef cppclass fenwick_tree[T]:
        fenwick_tree(int n)
        void add(int p, T x)
        T sum(int l, int r)
cdef class fenwick_tree_:
    cdef fenwick_tree[long] *ptr
    def __cinit__(self, int n): self.ptr = new fenwick_tree[long](n)  
    def __dealloc__(self): del self.ptr
    cpdef void add(self, int p, long x): self.ptr.add(p, x)
    cpdef long sum(self, int l, int r): return self.ptr.sum(l, r)
"""
import os
try:
    from atcoder import *
except:
    open('atcoder.pyx', 'w').write(code)
    os.system('cythonize -i -3 -b atcoder.pyx')

N,Q=map(int,input().split())
A=list(map(int,input().split()))
QRS=[list(map(int,input().split())) for i in range(Q)]
f=fenwick_tree_(N)
for i in range(N):
    f.add(i,A[i])
a=[]
for q,r,s in QRS:
    if q==0:
        f.add(r,s)
    else:
        a.append(f.sum(r,s))
print(*a,sep='\n')



Fixed submission:
code = r"""
# distutils: language=c++
# distutils: include_dirs=/home/contestant/.local/lib/python3.8/site-packages/numpy/core/include
# cython: boundscheck=False
# cython: wraparound=False
from libcpp cimport bool
from libcpp.vector cimport vector
cdef extern from "/opt/atcoder-stl/atcoder/dsu.hpp" namespace "atcoder":
    cpdef cppclass dsu:
        dsu(int n)
        int merge(int a, int b)
        bool same(int a, int b)
        int leader(int a)
        int size(int a)
        vector[vector[int]] groups()
cdef class dsu_:
    cdef dsu *ptr
    def __cinit__(self, int n): self.ptr = new dsu(n)
    def __dealloc__(self): del self.ptr
    def merge(self,a,b): return self.ptr.merge(a,b)
    def same(self,a,b): return self.ptr.same(a,b)
    def leader(self,a): return self.ptr.leader(a)
    def size(self,a): return self.ptr.size(a)
    def groups(self): return self.ptr.groups()
"""
import os
try:
    from dsu import *
except:
    open('dsu.pyx', 'w').write(code)
    os.system('cythonize -i -3 -b dsu.pyx')

N,Q=map(int,input().split())
TUV=[list(map(int,input().split())) for i in range(Q)]
d=dsu_(N)
for t,u,v in TUV:
    if t==0:
        d.merge(u,v)
    else:
        print(1 if d.same(u,v) else 0)
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=list(map(int,input().split()))
l,r=0,10**9+1
while r-l>1:
    t=(l+r)//2
    k=sum([(a+t-2)//(t-1)-1 for a in A])
    if K<k:
        l=t
    else:
        r=t
print(l)

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
l,r=1,10**9+1
while r-l>1:
    t=(l+r)//2
    k=sum([(a+t-2)//(t-1)-1 for a in A])
    if K<k:
        l=t
    else:
        r=t
print(l)
Buggy python submission (verdict: Runtime Error):
N=int(input())
X=input()
c=X.count('1')
r1=int(X,2)%(c-1)
r2=int(X,2)%(c+1)
d=[0]*(N+1)
for i in range(N):
    d[i+1]=d[(i+1)%bin(i+1).count('1')]+1
for i in range(N):
    if X[i]=='0':
        n=(r2+pow(2,N-i-1,c+1))%(c+1)
    else:
        if c==1:
            print(0)
            continue
        n=(r1-pow(2,N-i-1,c-1))%(c-1)
    print(d[n]+1)

Fixed submission:
N=int(input())
X=input()
c=X.count('1')
r1=int(X,2)%(c-1) if c>1 else 0
r2=int(X,2)%(c+1)
d=[0]*(N+1)
for i in range(N):
    d[i+1]=d[(i+1)%bin(i+1).count('1')]+1
for i in range(N):
    if X[i]=='0':
        n=(r2+pow(2,N-i-1,c+1))%(c+1)
    else:
        if c==1:
            print(0)
            continue
        n=(r1-pow(2,N-i-1,c-1))%(c-1)
    print(d[n]+1)
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=list(map(int,input().split()))
m,p,z=[],[],0
for a in A:
    if a<0:
        m.append(a)
    elif a>0:
        p.append(a)
    else:
        z+=1
m.sort()
p.sort()
mod=10**9+7
from functools import reduce
if (len(p) or K%2==0) and K<len(m)+len(p) or K==len(m)+len(p) and len(m)%2==0:
    r=1
    i,j=0,0
    while i+j<K:
        if i<len(m)-1 and i+j<K-1 and m[i]*m[i+1]>p[-j-1]*p[-j-2]:
            r=r*m[i]*m[i+1]%mod
            i+=2
        else:
            r=r*p[-j-1]%mod
            j+=1
    print(r)
elif z:
    print(0)
else:
    print(reduce(lambda x,y:x*y%mod,(m+p)[-K:]))

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
m,p,z=[],[],0
for a in A:
    if a<0:
        m.append(a)
    elif a>0:
        p.append(a)
    else:
        z+=1
m.sort()
p.sort()
mod=10**9+7
from functools import reduce
if (len(p) or K%2==0) and K<len(m)+len(p) or K==len(m)+len(p) and len(m)%2==0:
    r=1
    i,j=0,0
    while i+j<K:
        if i<len(m)-1 and i+j<K-1 and (j>=len(p)-1 or m[i]*m[i+1]>p[-j-1]*p[-j-2]):
            r=r*m[i]*m[i+1]%mod
            i+=2
        else:
            r=r*p[-j-1]%mod
            j+=1
    print(r)
elif z:
    print(0)
else:
    print(reduce(lambda x,y:x*y%mod,(m+p)[-K:]))

Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=list(map(int,input().split()))
m,p,z=[],[],0
for a in A:
    if a<0:
        m.append(a)
    elif a>0:
        p.append(a)
    else:
        z+=1
m.sort()
p.sort()
mod=10**9+7
from functools import reduce
if len(p) and (K<len(m)+len(p) or K==len(m)+len(p) and len(m)%2==0):
    r=1
    i,j=0,0
    while i+j<K:
        if i<len(m)-1 and m[i]*m[i+1]>p[-j-1]*p[-j-2]:
            r=r*m[i]*m[i+1]%mod
            i+=2
        else:
            r=r*p[-j-1]%mod
            j+=1
    print(r)
elif z:
    print(0)
else:
    print(reduce(lambda x,y:x*y%mod,(m+p)[-K:]))

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
m,p,z=[],[],0
for a in A:
    if a<0:
        m.append(a)
    elif a>0:
        p.append(a)
    else:
        z+=1
m.sort()
p.sort()
mod=10**9+7
from functools import reduce
if (len(p) or K%2==0) and K<len(m)+len(p) or K==len(m)+len(p) and len(m)%2==0:
    r=1
    i,j=0,0
    while i+j<K:
        if i<len(m)-1 and i+j<K-1 and (j>=len(p)-1 or m[i]*m[i+1]>p[-j-1]*p[-j-2]):
            r=r*m[i]*m[i+1]%mod
            i+=2
        else:
            r=r*p[-j-1]%mod
            j+=1
    print(r)
elif z:
    print(0)
else:
    print(reduce(lambda x,y:x*y%mod,(m+p)[-K:]))
Buggy python submission (verdict: Time Limit Exceeded):
K=int(input())
L=len(input())
m=10**9+7
from numba import*
@njit(cache=1)
def f():
    max_n=2*10**6
    fac=[1]*(max_n+1)
    inv=[1]*(max_n+1)
    ifac=[1]*(max_n+1)
    for n in range(2,max_n+1):
        fac[n]=(fac[n-1]*n)%m
        inv[n]=m-inv[m%n]*(m//n)%m
        ifac[n]=(ifac[n-1]*inv[n])%m
    return fac,inv,ifac
fac,inv,ifac=f()
def comb(n,k):
    if n<k or n<0 or k<0:
        return 0
    return (fac[n]*ifac[k]*ifac[n-k])%m
d=[1]*(K+1)
d2=[1]*(K+1)
for i in range(K):
    d[i+1]=d[i]*25%m
    d2[i+1]=d2[i]*26%m
print(sum([comb(L+i-1,i)*d[i]*d2[K-i]%m for i in range(K+1)])%m)

Fixed submission:
K=int(input())
L=len(input())
from numba import*
@njit(cache=1)
def f():
    m=10**9+7
    max_n=2*10**6
    fac=[1]*(max_n+1)
    inv=[1]*(max_n+1)
    ifac=[1]*(max_n+1)
    for n in range(2,max_n+1):
        fac[n]=(fac[n-1]*n)%m
        inv[n]=m-inv[m%n]*(m//n)%m
        ifac[n]=(ifac[n-1]*inv[n])%m
    d=[1]*(K+1)
    d2=[1]*(K+1)
    for i in range(K):
        d[i+1]=d[i]*25%m
        d2[i+1]=d2[i]*26%m
    a=0
    for i in range(K+1):
        a=(a+fac[L+i-1]*ifac[i]%m*ifac[L-1]%m*d[i]%m*d2[K-i]%m)%m
    return a
print(f())
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
A=list(map(int,input().split()))
for i in range(K):
    d=[0]*(N+1)
    for j,a in enumerate(A):
        d[max(0,j-a)]+=1
        d[min(N,j+a+1)]-=1
    b=1
    for j in range(N):
        d[j+1]+=d[j]
        if d[j+1]!=N:
            b=0
    A=d[:-1]
    if b:
        break
print(*A)

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
for i in range(K):
    d=[0]*(N+1)
    for j,a in enumerate(A):
        d[max(0,j-a)]+=1
        d[min(N,j+a+1)]-=1
    b=1
    for j in range(N):
        if d[j]!=N:
            b=0
        d[j+1]+=d[j]
    A=d[:-1]
    if b>0:
        break
print(*A)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
x=1
f=0
for a in A:
    x*=a
    if x>10**18:
        f=1
print(0 if 0 in A else -1 if f else x)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
x=1
f=0
for a in A:
    x*=a
    if x>10**18:
        f=1
        break
print(0 if 0 in A else -1 if f else x)
Buggy python submission (verdict: Runtime Error):
N,M,Q=map(int,input().split())
ABCD=[list(map(int,input().split())) for i in range(Q)]
from itertools import combinations
ans=0
for p in combinations(range(N+M),M):
    r=0
    for a,b,c,d in ABCD:
        if p[b-1]-b+1-p[a-1]+a-1==c:
            r+=d
    ans=max(ans,r)
print(ans)

Fixed submission:
N,M,Q=map(int,input().split())
ABCD=[list(map(int,input().split())) for i in range(Q)]
from itertools import combinations
ans=0
for p in combinations(range(N+M-1),N):
    r=0
    for a,b,c,d in ABCD:
        if p[b-1]-b+1-(p[a-1]-(a-1))==c:
            r+=d
    ans=max(ans,r)
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
UV=[list(map(int,input().split())) for i in range(N-1)]
c=[[] for i in range(N)]
for i,j in UV:
    c[i-1].append(j-1)
    c[j-1].append(i-1)
v=[0]*N
d=[10**9+1]*N
stk=[]
ans=[0]*N
from bisect import bisect_left
def dfs(p,l):
    i=bisect_left(d,A[p])
    stk.append((i,d[i]))
    d[i]=A[p]
    if i==l:
        l+=1
    ans[p]=l
    for n in c[p]:
        if v[n]==0:
            v[n]=1
            dfs(n,l)
    i,x=stk.pop()
    d[i]=x
v[0]=1
dfs(0,0)
print(*ans,sep='\n')

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
UV=[list(map(int,input().split())) for i in range(N-1)]
c=[[] for i in range(N)]
for i,j in UV:
    c[i-1].append(j-1)
    c[j-1].append(i-1)
v=[0]*N
d=[10**9+1]*N
stk=[]
ans=[0]*N
from bisect import bisect_left
import sys
sys.setrecursionlimit(10**9)
def dfs(p,l):
    i=bisect_left(d,A[p])
    stk.append((i,d[i]))
    d[i]=A[p]
    if i==l:
        l+=1
    ans[p]=l
    for n in c[p]:
        if v[n]==0:
            v[n]=1
            dfs(n,l)
    i,x=stk.pop()
    d[i]=x
v[0]=1
dfs(0,0)
print(*ans,sep='\n')
Buggy python submission (verdict: Time Limit Exceeded):
N,M,S=map(int,input().split())
UVAB=[list(map(int,input().split())) for i in range(M)]
C,D=zip(*[list(map(int,input().split())) for i in range(N)])
c=[[] for i in range(N)]
A=[[] for i in range(N)]
B=[[] for i in range(N)]
for u,v,a,b in UVAB:
    c[u-1].append(v-1)
    c[v-1].append(u-1)
    A[u-1].append(a)
    A[v-1].append(a)
    B[u-1].append(b)
    B[v-1].append(b)
inf=10**20
from heapq import heappop,heappush
X=50*(N-1)
def dij(p,s):
    d=[[inf]*(X+1) for i in range(N)]
    d[p][s]=0
    q=[]
    heappush(q,(0,(p,s)))
    while q:
        t,(p,s)=heappop(q)
        for i in range(1,(X+1-s)//C[p]):
            if X<s+i*C[p] or d[p][s+i*C[p]]<=d[p][s]+i*D[p]:break
            d[p][s+i*C[p]]=d[p][s]+i*D[p]
            heappush(q,(d[p][s]+i*D[p],(p,s+i*C[p])))
        for j,n in enumerate(c[p]):
            if 0<=s-A[p][j] and d[n][s-A[p][j]]>d[p][s]+B[p][j]:
                d[n][s-A[p][j]]=d[p][s]+B[p][j]
                heappush(q,(d[n][s-A[p][j]],(n,s-A[p][j])))
    return d
d=dij(0,min(S,X))
print(*[min(x) for x in d[1:]],sep='\n')

Fixed submission:
N,M,S=map(int,input().split())
UVAB=[list(map(int,input().split())) for i in range(M)]
C,D=zip(*[list(map(int,input().split())) for i in range(N)])
c=[[] for i in range(N)]
A=[[] for i in range(N)]
B=[[] for i in range(N)]
for u,v,a,b in UVAB:
    c[u-1].append(v-1)
    c[v-1].append(u-1)
    A[u-1].append(a)
    A[v-1].append(a)
    B[u-1].append(b)
    B[v-1].append(b)
inf=10**20
from heapq import heappop,heappush
X=50*(N-1)
def dij(p,s):
    d=[[inf]*(X+1) for i in range(N)]
    d[p][s]=0
    q=[]
    heappush(q,(0,(p,s)))
    while q:
        t,(p,s)=heappop(q)
        for i in range(1,(X+1-s)//C[p]):
            if X<s+i*C[p] or d[p][s+i*C[p]]<=d[p][s]+i*D[p]:break
            d[p][s+i*C[p]]=d[p][s]+i*D[p]
            heappush(q,(d[p][s]+i*D[p],(p,s+i*C[p])))
        for j,n in enumerate(c[p]):
            if 0<=s-A[p][j] and d[n][s-A[p][j]]>d[p][s]+B[p][j]:
                d[n][s-A[p][j]]=d[p][s]+B[p][j]
                heappush(q,(d[n][s-A[p][j]],(n,s-A[p][j])))
    return d
d=dij(0,min(S,X))
print(*[min(x) for x in d[1:]],sep='\n')
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
from collections import deque
q=deque([(-1,0,-2,0)])
ans=-10**18
for i,a in enumerate(A):
    while q and q[0][0]<i:
        j,n,r,x=q.popleft()
        if r<-1:
            if n==N//2-1:
                ans=max(ans,x+a)
            else:
                q.append((i,n+1,-1,x+a))
        if (j+1)//2<=n:
            q.append((i,n,r-1,x))
print(ans)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
from collections import deque
q=deque([(-1,0,-2,0)])
ans=-10**18
for i,a in enumerate(A):
    d={}
    while q and q[0][0]<i:
        j,n,r,x=q.popleft()
        if r<-1:
            if n==N//2-1:
                ans=max(ans,x+a)
            elif n not in d:
                d[n]=x
            elif d[n]<x:
                d[n]=x
        if (j+1)//2<=n:
            q.append((i,n,r-1,x))
    for n,x in d.items():
        q.append((i,n+1,-1,x+a))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
from collections import deque
q=deque([(-1,0,-2,0)])
ans=-10**18
for i,a in enumerate(A):
    while q and q[0][0]<i:
        j,n,r,x=q.popleft()
        if r<-1:
            if n==N//2-1:
                ans=max(ans,x+a)
            else:
                q.append((i,n+1,-1,x+a))
        if (j+1)//2<=n:
            q.append((i,n,r-1,x))
print(ans)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
from collections import deque
q=deque([(-1,0,-2,0)])
ans=-10**18
for i,a in enumerate(A):
    d={}
    while q and q[0][0]<i:
        j,n,r,x=q.popleft()
        if r<-1:
            if n==N//2-1:
                ans=max(ans,x+a)
            elif n not in d:
                d[n]=x
            elif d[n]<x:
                d[n]=x
        if (j+1)//2<=n:
            q.append((i,n,r-1,x))
    for n,x in d.items():
        q.append((i,n+1,-1,x+a))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K,C=map(int,input().split())
S=input()
i=0
d1=[-1]*N
for k in range(K):
    try:
        i+=S[i:].index('o')
    except:
        break
    d1[i]=k
    i+=C+1
i=0
d2=[-1]*N
for k in range(K-1,-1,-1):
    try:
        i+=S[N-1-i::-1].index('o')
    except:
        break
    d2[N-1-i]=k
    i+=C+1
print(*[i+1 for i in range(N) if d1[i]==d2[i]>=0],sep='\n')

Fixed submission:
N,K,C=map(int,input().split())
S=input()
i=0
d1=[-1]*N
for k in range(K):
    while S[i]=='x' and i<N:
        i+=1
    if i==N:break
    d1[i]=k
    i+=C+1
i=0
d2=[-1]*N
for k in range(K-1,-1,-1):
    while S[N-1-i]=='x' and i<N:
        i+=1
    if i==N:break
    d2[N-1-i]=k
    i+=C+1
print(*[i+1 for i in range(N) if d1[i]==d2[i]>=0],sep='\n')

Buggy python submission (verdict: Time Limit Exceeded):
N,K,C=map(int,input().split())
S=input()
i=0
d1=[-1]*N
for k in range(K):
    try:
        i=S.index('o',i)
    except:
        break
    d1[i]=k
    i+=C+1
i=0
d2=[-1]*N
for k in range(K-1,-1,-1):
    try:
        i=S[::-1].index('o',i)
    except:
        break
    d2[N-1-i]=k
    i+=C+1
print(*[i+1 for i in range(N) if d1[i]==d2[i]>=0],sep='\n')

Fixed submission:
N,K,C=map(int,input().split())
S=input()
i=0
d1=[-1]*N
for k in range(K):
    while S[i]=='x' and i<N:
        i+=1
    if i==N:break
    d1[i]=k
    i+=C+1
i=0
d2=[-1]*N
for k in range(K-1,-1,-1):
    while S[N-1-i]=='x' and i<N:
        i+=1
    if i==N:break
    d2[N-1-i]=k
    i+=C+1
print(*[i+1 for i in range(N) if d1[i]==d2[i]>=0],sep='\n')
Buggy python submission (verdict: Runtime Error):
N=input()
K=int(input())
l=len(N)
dp=[[0]*(l+1) for i in range(K+1)]
dp[0][0]=1
x=0
for i,n in enumerate(N):
    n=int(n)
    dp[0][i+1]=1
    if n==0:
        for j in range(1,K+1):
            dp[j][i+1]=dp[j][i]+dp[j-1][i]*9
    else:
        for j in range(1,K+1):
        dp[j][i+1]=dp[j][i]+dp[j-1][i]*9 if i-j>-1 else 0 if i-j<-1 else n if i==0 else (dp[j-1][i]-1)*9+n
print(dp[-1][-1])

Fixed submission:
N=input()
K=int(input())
l=len(N)
dp=[[0]+[1]*l]+[[0]*(l+1) for i in range(K)]
dp2=[[1]+[0]*l]+[[0]*(l+1) for i in range(K)]
for i,n in enumerate(N):
    n=int(n)
    for j in range(K):
        dp[j+1][i+1]=dp[j][i]*9+dp[j+1][i]+(dp2[j][i]*(n-1)+dp2[j+1][i] if n>0 else 0)
        dp2[j+1][i+1]=dp2[j][i] if n>0 else dp2[j+1][i]
print(dp[-1][-1]+dp2[-1][-1])
Buggy python submission (verdict: Runtime Error):
r,c,R,C=map(int,input().split())
m=10**9+7
max_n=2*10**6
fac=[1]*(max_n+1)
inv=[1]*(max_n+1)
ifac=[1]*(max_n+1)
for n in range(2,max_n+1):
    fac[n]=(fac[n-1]*n)%m
    inv[n]=m-inv[m%n]*(m//n)%m
    ifac[n]=(ifac[n-1]*inv[n])%m
def comb(n,k):
    if n<k or n<0 or k<0:
        return 0
    return (fac[n]*ifac[k]*ifac[n-k])%m
def f(r,c):
    return sum([comb(i+1+c,c) for i in range(r+1)])%m
print((f(R,C)-f(R,c-1)-f(r-1,C)+f(r-1,c-1))%m)

Fixed submission:
r,c,R,C=map(int,input().split())
m=10**9+7
max_n=2*10**6+1
fac=[1]*(max_n+1)
inv=[1]*(max_n+1)
ifac=[1]*(max_n+1)
for n in range(2,max_n+1):
    fac[n]=(fac[n-1]*n)%m
    inv[n]=m-inv[m%n]*(m//n)%m
    ifac[n]=(ifac[n-1]*inv[n])%m
def comb(n,k):
    if n<k or n<0 or k<0:
        return 0
    return (fac[n]*ifac[k]*ifac[n-k])%m
def f(r,c):
    return sum([comb(i+1+c,c) for i in range(r+1)])%m
print((f(R,C)-f(R,c-1)-f(r-1,C)+f(r-1,c-1))%m)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
def prime_factorization(n):
    r={}
    for i in range(2,int(n**.5)+1):
        num=0
        while(True):
            x,y=divmod(n,i)
            if y!=0:
                break
            n=x
            num+=1
        if num>0:
            r[i]=num
    if n>1:
        r[n]=1
    return r
mod=10**9+7
def mul(a,b):
    return ((a%mod)*(b%mod))%mod
def div(a,b):
    return mul(a,pow(b,mod-2,mod))
from collections import defaultdict
d=defaultdict(int)
for a in A:
    r=prime_factorization(a)
    for k,v in r.items():
        d[k]=max(d[k],v)
X=1
for k,v in d.items():
    X=X*pow(k,v,mod)%mod
r=0
for a in A:
    r=(r+div(X,a))%mod
print(r)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
def prime_factorization(n):
    r={}
    for i in range(2,int(n**.5)+1):
        num=0
        while(True):
            x,y=divmod(n,i)
            if y!=0:
                break
            n=x
            num+=1
        if num>0:
            r[i]=num
    if n>1:
        r[n]=1
    return r
mod=10**9+7
def mul(a,b):
    return ((a%mod)*(b%mod))%mod
def div(a,b):
    return mul(a,pow(b,mod-2,mod))
from collections import defaultdict
d=defaultdict(int)
for a in A:
    r=prime_factorization(a)
    for k,v in r.items():
        d[k]=max(d[k],v)
X=1
for k,v in d.items():
    X=X*pow(k,v,mod)%mod
r=0
for a in A:
    r=(r+div(X,a))%mod
print(r)