Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
x,k,d=map(int,input().split())

x=abs(x)

if x>k*d:
    print(x-k*d)
else:
    r=k-x//d
    if r%2==0:
        print(x%d)
    else:
        print(d-x%d)


Fixed submission:
S=input()
S=list(S)
c=0
max=0
for i in S:
    if i=="R":
        c+=1
    else:
        if max<c:
            max=c
            c=0

if max<c:
    max=c
    c=0

print(max)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

R,C,K=map(int,input().split())
V=np.zeros((R,C),dtype=np.int64)

for i in range(K):
    r,c,v=map(int,input().split())
    V[r-1][c-1]=v

dp=np.zeros((C+1,4),dtype=np.int64)
for i in range(R):
    ndp=np.zeros((C+1,4),dtype=np.int64)
    for j in range(C):
        ndp[j][0]=max(dp[j])

    for j in range(C):
        v=V[i][j]
        for n in range(1,4):
            ndp[j][n]=max(ndp[j-1][n-1]+v,dp[j][3]+v,ndp[j-1][n])

    dp=ndp

print(max(dp[C-1]))


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

V=[[0 for _ in range(C)] for _ in range(R)]

for i in range(K):
    r,c,v=map(int,input().split())
    V[r-1][c-1]=v

dp=[[0 for _ in range(4)] for _ in range(C+1)]
for i in range(R):
    ndp=[[0 for _ in range(4)] for _ in range(C+1)]
    for j in range(C):
        ndp[j][0]=max(dp[j])

    for j in range(C):
        v=V[i][j]
        for n in range(1,4):
            ndp[j][n]=max(ndp[j-1][n-1]+v,dp[j][3]+v,ndp[j-1][n])

    dp=ndp

print(max(dp[C-1]))
Buggy python submission (verdict: Time Limit Exceeded):
import math
import numpy as np
n,k = map(int,input().split())
a = [int(i) for i in input().split()]

cut = [1] *n
r = []
for i in a:
    r.append(i)

for i in range(k):
    max_n = 0
    max_i = -1
    for i in range(n):
        if max_n < r[i]:
            max_n = r[i]
            max_i = i
    cut[max_i] += 1
    r[max_i] = a[max_i] / cut[max_i]

print(math.ceil(max(r)))

Fixed submission:
import math

n,k = map(int,input().split())
a = [int(i) for i in input().split()]

a.sort()
r = a[n-1]
l = 0


def calc(t,x):
    return math.ceil(t / x) - 1


while r - l > 1:
    mid = (r+l)//2
    count = 0
    for i in a:
        count += calc(i,mid)
    if count > k:
        l = mid
    else:
        r = mid

print(r)

Buggy python submission (verdict: Time Limit Exceeded):
import math
n,k = map(int,input().split())
a = [int(i) for i in input().split()]

cut = [1] *n
r = []
for i in a:
    r.append(i)

for i in range(k):
    max_value = max(r)
    max_index = r.index(max_value)
    cut[max_index] += 1
    r[max_index] = a[max_index] / cut[max_index]

print(math.ceil(max(r)))

Fixed submission:
import math

n,k = map(int,input().split())
a = [int(i) for i in input().split()]

a.sort()
r = a[n-1]
l = 0


def calc(t,x):
    return math.ceil(t / x) - 1


while r - l > 1:
    mid = (r+l)//2
    count = 0
    for i in a:
        count += calc(i,mid)
    if count > k:
        l = mid
    else:
        r = mid

print(r)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]

max = 1000
for i in range(2**(N-1)):
    possess = 1000
    for j in range(N-1):
        if (i >> j) & 1:
            stock = possess // A[j]
            possess = possess % A[j] + A[j+1] * stock
    if possess > max:
        max = possess

print(max)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

possess = 1000

for i in range(N-1):
    if A[i] < A[i+1]:
        stock = possess//A[i]
        possess = possess % A[i] + A[i+1] * stock


print(possess)
Buggy python submission (verdict: Runtime Error):
X, N = map(int,input().split())
p_list = list(map(int, input().split()))

p_list.sort()
r = 200
answer = 101

for i in range(0, 102):
    if i in p_list:
        continue
    else:
        if r > abs(i - X):
            r = abs(i - X)
            answer = i
        else:
            print(answer)
            break


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

for i in a:
    if i == 0:
        print(count)
        break
    count+=1
Buggy python submission (verdict: Runtime Error):
x, y = map(int,input(),split())

if y % 2 == 0 and y >= x*2 and y <= x*4:
    print('Yes')
else:
    print('No')


Fixed submission:
x, y = map(int,input().split())

if y % 2 == 0 and y >= x*2 and y <= x*4:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A_list = list(map(int, input().split()))
A_list.sort()
A_max = A_list[N-1]

is_prime = [True] * (A_max+1)
is_prime[0] = False

for i in range(1, A_max):
    if i not in A_list:
        is_prime[i] = False


for i in A_list:
    if not is_prime[i]:
        continue
    for j in range(i*2, A_max+1, i):
        is_prime[j] = False
    if A_list.count(i) >= 2:
        is_prime[i] = False

print(is_prime.count(True))


Fixed submission:
N = int(input())
A_list = list(map(int, input().split()))
A_list.sort()
A_max = A_list[N-1]

is_prime = [False] * (A_max+1)


for i in A_list:
    is_prime[i] = True

x = -1
for i in A_list:
    if not is_prime[i]:
        continue
    elif x == i:
        is_prime[i] = False
        continue
    for j in range(i*2, A_max+1, i):
        is_prime[j] = False
    x = i

count = 0
for i in A_list:
    if is_prime[i]:
        count += 1


print(count)

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

is_prime = [True] * N
for i in range(N):
    if is_prime[i] == False:
        continue
    for j in range(i+1, N):
        if A_list[j] % A_list[i] == 0:
            is_prime[j] = False
    if i != N-1:
        if A_list[i] == A_list[i+1]:
            is_prime[i] = False

print(is_prime.count(True))


Fixed submission:
N = int(input())
A_list = list(map(int, input().split()))
A_list.sort()
A_max = A_list[N-1]

is_prime = [False] * (A_max+1)


for i in A_list:
    is_prime[i] = True

x = -1
for i in A_list:
    if not is_prime[i]:
        continue
    elif x == i:
        is_prime[i] = False
        continue
    for j in range(i*2, A_max+1, i):
        is_prime[j] = False
    x = i

count = 0
for i in A_list:
    if is_prime[i]:
        count += 1


print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n,a,b=map(int,input().split())

p = 10 ** 9 + 7

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, n + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

ans=pow(2,n)%p-1-cmb(n,a,p)-cmb(n,b,p)

print(ans%p)


Fixed submission:
n,a,b=map(int,input().split())
c=max(a,b)
b=min(a,b)
a=c
MOD = pow(10,9) + 7

X=1
Y=1

for i in range(1,a+1):
    X=X*(n+1-i)%MOD
    Y=Y*i%MOD
    if i==b:
        b_X=X
        b_Y=Y
a_X=X
a_Y=Y
def calc(X,Y,MOD):
    return X*pow(Y,MOD-2,MOD)

ans=pow(2,n,MOD)%MOD-1-calc(a_X,a_Y,MOD)-calc(b_X,b_Y,MOD)

print(ans%MOD)
Buggy python submission (verdict: Time Limit Exceeded):
N ,M = map(int, input().split())
A_list = [int(i) * (-1) for i in input().split()]


import heapq
for i in range(M):
    heapq.heapify(A_list)
    x = heapq.heappop(A_list) / 2
    heapq.heappush(A_list, (-1)*int(-x))

print(-sum(A_list))


Fixed submission:
N ,M = map(int, input().split())
A_list = [int(i) * (-1) for i in input().split()]


import heapq

heapq.heapify(A_list)
for i in range(M):
    x = heapq.heappop(A_list)
    heapq.heappush(A_list, (-1)*(-x//2))

print(-sum(A_list))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(1000000)


n,m=map(int,input().split())

p=[[] for _ in range(n)]

for _ in range(m):
    x,y=map(int,input().split())
    p[x-1].append(y-1)

f=[-1 for _ in range(n)]

def calc(x):
    if len(p[x])==0:
        f[x]=0
        return 0
    f[x]=max([calc(i) for i in p[x]])+1
    return f[x]

m=0
for i in range(n):
    if f[i]!=-1:
        continue
    m=max(m,calc(i))
print(m)


Fixed submission:
import sys
sys.setrecursionlimit(1000000)


n,m=map(int,input().split())

p=[[] for _ in range(n)]

for _ in range(m):
    x,y=map(int,input().split())
    p[x-1].append(y-1)

f=[-1 for _ in range(n)]

def calc(x):
    if f[x]!=-1:
        return f[x]
    if len(p[x])==0:
        f[x]=0
        return 0
    f[x]=max([calc(i) for i in p[x]])+1
    return f[x]

m=0
for i in range(n):
    if f[i]!=-1:
        continue
    m=max(m,calc(i))
print(m)

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

p=[[] for _ in range(n)]

for _ in range(m):
    x,y=map(int,input().split())
    p[x-1].append(y-1)



def calc(x):
    if len(p[x])==0:
        return 0
    return max([calc(i) for i in p[x]])+1

m=0
for i in range(n):
    j=calc(i)
    if m<j:
        m=j
print(m)


Fixed submission:
import sys
sys.setrecursionlimit(1000000)


n,m=map(int,input().split())

p=[[] for _ in range(n)]

for _ in range(m):
    x,y=map(int,input().split())
    p[x-1].append(y-1)

f=[-1 for _ in range(n)]

def calc(x):
    if f[x]!=-1:
        return f[x]
    if len(p[x])==0:
        f[x]=0
        return 0
    f[x]=max([calc(i) for i in p[x]])+1
    return f[x]

m=0
for i in range(n):
    if f[i]!=-1:
        continue
    m=max(m,calc(i))
print(m)
Buggy python submission (verdict: Runtime Error):
import numpy as np
from numba import njit
N=int(input())
a=np.array([int(i) for i in input().split()],dtype=np.int64)
a.dtype
dp=np.full((N,N),-1,dtype=np.int64)
dp.dtype
for i in range(N):
    dp[i][i]=a[i]

@njit('i8(i8,i8,i8[:,:],i8[:])', cache=True)
def calc(i,j,dp,a):
    if dp[i][j]!=-1:
        return dp[i][j]
    dp[i][j]=max(a[i]-calc(i+1,j,dp,a),a[j]-calc(i,j-1,dp,a))
    return dp[i][j]

calc(0,N-1,dp,a)
print(dp[0][N-1])


Fixed submission:
import numpy as np
from numba import njit
N=int(input())
a=np.array([int(i) for i in input().split()],dtype=np.int64)
dp=np.full((N,N),-1,dtype=np.int64)
for i in range(N):
    dp[i][i]=a[i]

@njit('i8(i8,i8,i8[:,:],i8[:])', cache=True)
def calc(i,j,dp,a):
    if dp[i][j]!=-1:
        return dp[i][j]
    dp[i][j]=max(a[i]-calc(i+1,j,dp,a),a[j]-calc(i,j-1,dp,a))
    return dp[i][j]

calc(0,N-1,dp,a)
print(dp[0][N-1])
Buggy python submission (verdict: Runtime Error):
import numpy as np
from numba import njit
N=int(input())
a=np.array([int(i) for i in input().split()],dtype=np.int64)

s=[0]

dp=np.array([[-1 for i in range(N)] for _ in range(N)],dtype=np.int64)

for i in range(1,N+1):
    s.append(s[i-1]+a[i-1])

s=np.array(s,dtype=np.int64)
for i in range(N):
    dp[i][i]=0

@njit('i8(i8,i8,i8[:,:],i8[:])', cache=True)
def calc(i,j,dp,s):
    if dp[i][j]!=-1:
        return dp[i][j]
    m=float('inf')
    for k in range(i,j):
        m=min(m,calc(i,k,dp,s)+calc(k+1,j,dp,s)+s[j+1]-s[i])
    dp[i][j]=m
    return dp[i][j]

print(calc(0,N-1,dp,s))


Fixed submission:
import numpy as np
from numba import njit
N=int(input())
a=np.array([int(i) for i in input().split()],dtype=np.int64)

s=[0]

dp=np.array([[-1 for i in range(N)] for _ in range(N)],dtype=np.int64)

for i in range(1,N+1):
    s.append(s[i-1]+a[i-1])

s=np.array(s,dtype=np.int64)
for i in range(N):
    dp[i][i]=0

@njit('i8(i8,i8,i8[:,:],i8[:])', cache=True)
def calc(i,j,dp,s):
    if dp[i][j]!=-1:
        return dp[i][j]
    m=10**14
    for k in range(i,j):
        m=min(m,calc(i,k,dp,s)+calc(k+1,j,dp,s)+s[j+1]-s[i])
    dp[i][j]=m
    return dp[i][j]

print(calc(0,N-1,dp,s))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
h=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]

dp=[0 for _ in range(N+1)]

for i in range(0,N):
    x=h[i]
    dp[x]=max(dp[:x+1])+a[i]

print(max(dp))


Fixed submission:
class SegTree():
    # init_valは配列の初期値、self.numはn以上の最小のべき乗 O(N)
    def __init__(self,init_val,segfunc,ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n-1).bit_length()
        # self.treeは0～2n-2の配列を使う
        self.tree = [ide_ele] * 2 * self.num
        for i in range(n):
            self.tree[self.num + i - 1] = init_val[i]

        for i in range(self.num-2,-1,-1):
            self.tree[i]=self.segfunc(self.tree[2*i+1],self.tree[2*i+2])

    # k番目をxに更新 O(logN)
    def update(self,k,x):
        k += self.num - 1
        self.tree[k]=x
        while k:
            k=(k-1)//2
            self.tree[k]=self.segfunc(self.tree[2*k+1],self.tree[2*k+2])

    # 区間[l,r)でsegfuncした結果を返す O(logN)
    def query(self,l,r):
        res = self.ide_ele

        l += self.num-1
        r += self.num-2
        while r>=l:
            if l & 1 == 0:
                res = self.segfunc(res,self.tree[l])
            if r & 1 == 1:
                res = self.segfunc(res,self.tree[r])
                r -= 1
            l = l // 2
            r = (r-1) // 2
        return res

N=int(input())
h=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]


dp=[0 for _ in range(N+1)]

def segfunc(x,y):
    return max(x,y)

ide_ele=-100

seg=SegTree(dp,segfunc,ide_ele)

for i in range(0,N):
    x=h[i]
    A=seg.query(0,x+1)
    seg.update(x,A+a[i])


print(seg.query(0,N+1))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
s=input()
dp=[[0 for _ in range(N+1)] for i in range(N+1)]
MOD=10**9+7
dp[0][N]=1
dp[1]=[1]*N+[0]
for i in range(1,N):
    if s[i-1]=='<':
        for j in range(1,N+1-i):
            for x in range(j):
                dp[i+1][x] =(dp[i+1][x] + dp[i][j])%MOD
    else:
        for j in range(0,N-i):
            for x in range(j,N-i+2):
                dp[i+1][x]=(dp[i+1][x] + dp[i][j])%MOD

print(dp[N][0])


Fixed submission:
N=int(input())
s=input()
dp=[[0 for _ in range(N+1)] for i in range(N+1)]
MOD=10**9+7
dp[0][N]=1
dp[1]=[1]*N+[0]

cum=[0 for _ in range(N+2)]
for i in range(1,N):
    cum[0]=0
    for z in range(1,N-i+2):
        cum[z]=(cum[z-1]+dp[i][z-1])%MOD

    if s[i-1]=='<':
        for j in range(0,N-i):
            dp[i+1][j] =(dp[i+1][j] +cum[N-i+1]-cum[j+1])%MOD
    else:
        for j in range(0,N-i):
            dp[i+1][j]=(dp[i+1][j] + cum[j+1])%MOD

print(dp[N][0])
Buggy python submission (verdict: Runtime Error):
S=input()
K=int(input())
S=list(S)

for j in range(len(S)):
    if S[j]=='1':
        if j==K:
            ans=1
    else:
        x=[i for i in S if i!="1"]
        ans=x[0]

print(ans)


Fixed submission:
S=input()
K=int(input())
S=list(S)

for j in range(len(S)):
    if S[j]=='1':
        if j==K-1:
            ans=1
            break
    else:
        x=[i for i in S if i!='1']
        ans=x[0]
        break

print(ans)

Buggy python submission (verdict: Runtime Error):
S=input()
K=int(input())
S=list(S)

for j in range(len(S)):
    if S[j]=='1':
        if j==K:
            ans=1
    else:
        x=[i for i in S if i!="1"]
        ans=x[0]

print(ans)


Fixed submission:
S=input()
K=int(input())
S=list(S)

for j in range(len(S)):
    if S[j]=='1':
        if j==K-1:
            ans=1
            break
    else:
        x=[i for i in S if i!='1']
        ans=x[0]
        break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,c = map(int,input().split())

D_list = [[int(i) for i in input().split()] for _ in range(c)]
c_list = [[int(i) for i in input().split()] for _ in range(n)]


ans = 10 ** 10
for i in range(1,c**3):
    x=i%c
    y=(i%c**2)//c
    z=i//c**2
    if x==y or y==z or z==x:
        continue
    else:
        color=[x,y,z]
        count = 0
        for a in range(n):
            for b in range(n):
                if color[(a+b+2)%3] != c_list[b][a]-1:
                    count+=D_list[c_list[b][a]-1][color[(a+b+2)%3]]
        if count < ans:
            ans = count

print(ans)


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

D_list = [[int(i) for i in input().split()] for _ in range(c)]
c_list = [[int(i) for i in input().split()] for _ in range(n)]

c_num=[[0 for _ in range(3)] for __ in range(c)]

for a in range(n):
    for b in range(n):
        c_num[c_list[b][a]-1][(a+b+2)%3] += 1


ans = 10 ** 10
for i in range(1,c**3):
    x=i%c
    y=(i%c**2)//c
    z=i//c**2
    if x==y or y==z or z==x:
        continue
    else:
        color=[x,y,z]
        count = 0
        for s in range(3):
            for t in range(c):
                count += c_num[t][s] *D_list[t][color[s]]

        if count < ans:
            ans = count

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
s=input()
s_list=list(s)
length=len(s)
K=int(input())
o=[]
x=deque(sorted(set(s)))



while len(o) < K:
    letter=x.popleft()
    X=[i for i , x in enumerate(s_list) if x==letter]
    for i in X:
        for j in range(i+1,length+1):
            if not s[i:j] in o:
                o.append(s[i:j])




o.sort()
print(o[K-1])


Fixed submission:
from collections import deque
s=input()
s_list=list(s)
length=len(s)
K=int(input())
o=[]
x=deque(sorted(set(s)))

while len(o) < K:
    letter=x.popleft()
    X=[i for i , x in enumerate(s_list) if x==letter]
    for i in X:
        for j in range(i+1,length+1):
            if not s[i:j] in o:
                o.append(s[i:j])
            if j-1-i == 5:
                break

o.sort()
print(o[K-1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a=[int(i) for i in input().split()]

sum_a=sum(a)
ans = 10**11
for i in range(N-1):
    x = abs(sum_a - 2 * sum(a[:i+1]))
    if x<ans:
        ans=x


print(ans)


Fixed submission:
N = int(input())
a=[int(i) for i in input().split()]

sum_a=sum(a)
ans = 10**11
x=0
for i in range(N-1):
    x += a[i]
    diff = abs(sum_a - 2 * x)
    if diff<ans:
        ans=diff


print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())

ans = {i for i in range(1,n+1)}

sum=n*(n+1)//2

for i in range(n,0,-1):
    if sum-i >n:
        ans.remove(i)
        sum -= i
    elif sum-i == n:
        ans.remove(i)
        break

for i in ans:
    print(i)


Fixed submission:
n=int(input())

t=int(2*n**0.5)
ans = {i for i in range(1,t+1)}

sum=t*(t+1)//2


for i in range(t,0,-1):
    if sum-i >n:
        ans.remove(i)
        sum -= i
    elif sum-i == n:
        ans.remove(i)
        break

for i in ans:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
S=input()
dp=[[0]*13 for i in range(len(S)+1)]
dp[0][0]=1
mod=10**9+7
for i in range(len(S)):
  if(S[i]=='?'):
    for j in range(13):
      for k in range(10):
        l=(j*10+k)%13
        dp[i+1][l]+=dp[i][j]
    for j in range(13):
      dp[i+1][j]%=mod
  else:
    k=int(S[i])
    for j in range(13):
      l=(j*10+k)%13
      dp[i+1][l]+=dp[i][j]
    for j in range(13):
      dp[i+1][j]%=mod
print(dp[len(S)][5])

Fixed submission:
S=input()
dp=[[0]*13 for i in range(len(S)+1)]
dp[0][0]=1
mod=10**9+7
for i in range(len(S)):
  if(S[i]=='?'):
    for j in range(13):
      for k in range(10):
        l=(j*10+k)%13
        dp[i+1][l]+=dp[i][j]
    for j in range(13):
      dp[i+1][j]%=mod
  else:
    k=int(S[i])
    for j in range(13):
      l=(j*10+k)%13
      dp[i+1][l]+=dp[i][j]
    for j in range(13):
      dp[i+1][j]%=mod
print(dp[len(S)][5])

Buggy python submission (verdict: Time Limit Exceeded):
S=input()
dp=[[0]*13 for i in range(len(S)+1)]
dp[0][0]=1
mod=10**9+7
for i in range(len(S)):
  if(S[i]=='?'):
    for j in range(13):
      for k in range(10):
        dp[i+1][(j*10+k)%13]=(dp[i+1][(j*10+k)%13]+dp[i][j])%mod
  else:
    k=int(S[i])
    for j in range(13):
      dp[i+1][(j*10+k)%13]=(dp[i+1][(j*10+k)%13]+dp[i][j])%mod
print(dp[len(S)][5])

Fixed submission:
S=input()
dp=[[0]*13 for i in range(len(S)+1)]
dp[0][0]=1
mod=10**9+7
for i in range(len(S)):
  if(S[i]=='?'):
    for j in range(13):
      for k in range(10):
        l=(j*10+k)%13
        dp[i+1][l]+=dp[i][j]
    for j in range(13):
      dp[i+1][j]%=mod
  else:
    k=int(S[i])
    for j in range(13):
      l=(j*10+k)%13
      dp[i+1][l]+=dp[i][j]
    for j in range(13):
      dp[i+1][j]%=mod
print(dp[len(S)][5])
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
S=input()
X,Y=[],[]
M=0
for i in range(len(S)):
  if(S[i]=='1' and M==0):
    X.append(i)
    M+=1
  elif(S[i]=='1'):
    M+=1
  else:
    if(M):
      Y.append(i-1)
    M=0
if(M):
  Y.append(len(S)-1)
ans=0
if(len(X)>=K):
  for i in range(len(X)-K):
    ans=max(ans,Y[i+K]-X[i]+1)
else:
  ans=len(S)
ans=max(ans,Y[min(K-1,len(X)-1)]+1)
ans=max(ans,len(S)-X[max(len(X)-K,0)])
print(ans)

Fixed submission:
N,K=map(int,input().split())
S=input()
X,Y=[],[]
M=0
for i in range(len(S)):
  if(S[i]=='1' and M==0):
    X.append(i)
    M+=1
  elif(S[i]=='1'):
    M+=1
  else:
    if(M):
      Y.append(i-1)
    M=0
if(M):
  Y.append(len(S)-1)
ans=0
if(len(X)>=K):
  for i in range(len(X)-K):
    ans=max(ans,Y[i+K]-X[i]+1)
else:
  ans=len(S)
if(len(X)):
  ans=max(ans,Y[min(K-1,len(X)-1)]+1)
  ans=max(ans,len(S)-X[max(len(X)-K,0)])
print(ans)

Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
S=input()
X,Y=[],[]
M=0
for i in range(len(S)):
  if(S[i]=='1' and M==0):
    X.append(i)
    M+=1
  elif(S[i]=='1'):
    M+=1
  else:
    if(M):
      Y.append(i-1)
    M=0
if(M):
  Y.append(len(S)-1)
ans=0
if(len(X)>=K):
  for i in range(len(X)-K):
    ans=max(ans,Y[i+K]-X[i]+1)
else:
  ans=len(S)
ans=max(ans,Y[min(K-1,len(X))]+1)
ans=max(ans,len(S)-X[max(len(X)-K,0)])
print(ans)

Fixed submission:
N,K=map(int,input().split())
S=input()
X,Y=[],[]
M=0
for i in range(len(S)):
  if(S[i]=='1' and M==0):
    X.append(i)
    M+=1
  elif(S[i]=='1'):
    M+=1
  else:
    if(M):
      Y.append(i-1)
    M=0
if(M):
  Y.append(len(S)-1)
ans=0
if(len(X)>=K):
  for i in range(len(X)-K):
    ans=max(ans,Y[i+K]-X[i]+1)
else:
  ans=len(S)
if(len(X)):
  ans=max(ans,Y[min(K-1,len(X)-1)]+1)
  ans=max(ans,len(S)-X[max(len(X)-K,0)])
print(ans)

Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
S=input()
X,Y=[],[]
M=0
for i in range(len(S)):
  if(S[i]=='1' and M==0):
    X.append(i)
    M+=1
  elif(S[i]=='1'):
    M+=1
  else:
    if(M):
      Y.append(i-1)
    M=0
if(M):
  Y.append(len(S)-1)
ans=0
for i in range(max(len(X)-K,0)):
  ans=max(ans,Y[i+K]-X[i]+1)
ans=max(ans,Y[min(K-1,len(X))]+1)
ans=max(ans,len(S)-X[max(len(X)-K,0)])
print(ans)

Fixed submission:
N,K=map(int,input().split())
S=input()
X,Y=[],[]
M=0
for i in range(len(S)):
  if(S[i]=='1' and M==0):
    X.append(i)
    M+=1
  elif(S[i]=='1'):
    M+=1
  else:
    if(M):
      Y.append(i-1)
    M=0
if(M):
  Y.append(len(S)-1)
ans=0
if(len(X)>=K):
  for i in range(len(X)-K):
    ans=max(ans,Y[i+K]-X[i]+1)
else:
  ans=len(S)
if(len(X)):
  ans=max(ans,Y[min(K-1,len(X)-1)]+1)
  ans=max(ans,len(S)-X[max(len(X)-K,0)])
print(ans)
Buggy python submission (verdict: Runtime Error):
X=[0]*4
for i in range(3):
  A,B=map(int,input().split())
  X[A-1]+=1
  X[B-1]+=1
X.sort()
if(X[0]==1 and X[1]==1 and X[2]==2):
  print("YES")
else:
  print("NO")

Fixed submission:
N,K=map(int,input().split())
if(K*2-1<=N):
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Time Limit Exceeded):

n = map(int, input())
data = list(map(int, input().split()))

ans = 1
flag = 1
flag2 = 0

for d in data:
  if d == 0:
    flag2 = 1

for d in data:
  ans = ans * d
  if ans > 1e18:
    flag = 0

if(flag2):
  print(0)
elif(flag):
  print(ans)
else:
  print(-1)

Fixed submission:

n = map(int, input())
data = list(map(int, input().split()))
INF = 1e18
ans = 1

for d in data:
  ans = ans * d
  if ans > INF:
    ans = -1
    break

if 0 in data:
  ans = 0

print(ans)