Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
def main():
    n=int(input())
    dis=[[10**20 for i in range(n)] for i in range(n)]
    g=[[] for i in range(n)]
    for _ in range(n-1):
        a,b,c = map(int,input().split())
        g[a-1].append(b-1)
        g[b-1].append(a-1)
        dis[a-1][b-1] = c
        dis[b-1][a-1] = c
    q,k = map(int,input().split())
    k-=1
    d=deque([k])
    f=[False for i in range(n)]
    dis[k][k]=0
    while d:
        s= d.popleft()
        f[s]= True
        for sg in g[s]:
            if not f[sg]:
                dis[k][sg]= dis[k][s]+dis[s][sg]
                d.append(sg)
    lq=[]
    for _ in range(q):
        lq.append(list(map(int,input().split())))
    for sq in lq:
        print(dis[k][sq[0]-1]+dis[k][sq[1]-1])

main()

Fixed submission:
from collections import deque
import sys
sys.setrecursionlimit(10**7)
n=int(input())
d=[10**20 for i in range(n)] 
g=[[] for i in range(n)]
for _ in range(n-1):
    a,b,c = map(int,input().split())
    g[a-1].append([b-1,c])
    g[b-1].append([a-1,c])
q,k = map(int,input().split())
k-=1
f=[False for i in range(n)]
d[k]=0

def dfs(s,c):
    f[s]=True
    d[s]=c
    for sg in g[s]:
        if not f[sg[0]]:
            dfs(sg[0],c+sg[1])
dfs(k,0)

lq=[]
for _ in range(q):
    lq.append(list(map(int,input().split())))
for sq in lq:
    print(d[sq[0]-1]+d[sq[1]-1])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
def main():
    n=int(input())
    dis=[[10**20 for i in range(n)] for i in range(n)]
    g=[[] for i in range(n)]
    for _ in range(n-1):
        a,b,c = map(int,input().split())
        g[a-1].append(b-1)
        g[b-1].append(a-1)
        dis[a-1][b-1] = c
        dis[b-1][a-1] = c
    q,k = map(int,input().split())
    k-=1
    d=deque([k])
    f=[False for i in range(n)]
    dis[k][k]=0
    while d:
        s= d.popleft()
        f[s]= True
        for sg in g[s]:
            if not f[sg]:
                dis[k][sg]= dis[k][s]+dis[s][sg]
                d.append(sg)
    lq=[]
    for _ in range(q):
        lq.append(list(map(int,input().split())))
    for sq in lq:
        print(dis[k][sq[0]-1]+dis[k][sq[1]-1])

main()

Fixed submission:
from collections import deque
import sys
sys.setrecursionlimit(10**7)
n=int(input())
d=[10**20 for i in range(n)] 
g=[[] for i in range(n)]
for _ in range(n-1):
    a,b,c = map(int,input().split())
    g[a-1].append([b-1,c])
    g[b-1].append([a-1,c])
q,k = map(int,input().split())
k-=1
f=[False for i in range(n)]
d[k]=0

def dfs(s,c):
    f[s]=True
    d[s]=c
    for sg in g[s]:
        if not f[sg[0]]:
            dfs(sg[0],c+sg[1])
dfs(k,0)

lq=[]
for _ in range(q):
    lq.append(list(map(int,input().split())))
for sq in lq:
    print(d[sq[0]-1]+d[sq[1]-1])
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()

lcount = 0
rcount = 0

while s[lcount] == ")":
    lcount += 1

while s[n-1-rcount] == "(":
    rcount += 1

res = "(" * lcount + s + ")" * rcount

l = s.count("(")
r = s.count(")")

if l > r:
    res = res + ")" * (l-r)

elif r > l:
    res = "(" * (r-l) + res

print(res)

Fixed submission:
n = int(input())
s = input()
l = s.count("(")
r = s.count(")")
lmax = 0
if n == 1:
    print("()")
elif l == 0:
    print("("* r + s)
elif r == 0:
    print(s + ")"*l)
else:
    l = 0
    r = 0
    for c in s:
        if c == "(":
            l += 1
        else:
            r += 1
        lmax = max(r-l, lmax,0)
    
    res = "(" * lmax + s 

    l = res.count("(")
    r = res.count(")")

    if l > r:
        res = res + ")" * (l-r)

    elif r > l:
        res = "(" * (r-l) + res

    print(res)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
x=int(input())
l=[(i*(i+1))//2 for i in range(100000000)]
print(bisect.bisect_left(l,x))

Fixed submission:
import bisect
x=int(input())
l=[(i*(i+1))//2 for i in range(100000)]
print(bisect.bisect_left(l,x))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
res = 1
for i in range(1, n + 1):
    res *= i
res = res % (10 ** 9 + 7)

print(res)


Fixed submission:
n = int(input())
res = 1
for i in range(0,n):
    res *= (i+1)
    if res > 10**9+7:
        res = res % (10**9+7)
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
res = 1
for i in range(1, n + 1):
    res *= i
res = res % (10 ** 9 + 7)

print(res)


Fixed submission:
n = int(input())
res = 1
for i in range(0,n):
    res *= (i+1)
    if res > 10**9+7:
        res = res % (10**9+7)
print(res)
Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    a=[]
    b=[]
    if n == 1:
        a=int(input())
        print(0)
    else:
        for i in range(n//2):
            a.append(int(input()))
            b.append(int(input()))

        if n % 2 == 1:
            a.append(int(input()))

        a.sort()
        b.sort()
        ta=a[0]
        tb=b[0]
        if ta < tb:
            res = 0
        else:
            tb = ta
            res = 1

        for i in range(1,n//2+1):
            if a[i] < tb:
                ta = tb
                res += 1
            else:
                ta = a[i]
            if b[i] < ta:
                tb =ta
                res += 1
            else:
                tb = b[i]
        if n % 2 == 1:
            if a[-1] < tb:
                res += 1

        print(res)
main()

Fixed submission:
import bisect

def main():
    n = int(input())
    l = [[i,int(input())] for i in range(n)]
    l.sort(key=lambda x:x[1])
    res =0
    for i in range(n):
        if i % 2 != l[i][0] % 2:
            res += 1
    print(res // 2)


main()
Buggy python submission (verdict: Runtime Error):
s=input()
n=len(s)
res = -1
leng = 0
for i in range(n-2):
    if s[i] == s[i+1]:
        res = i+1
        leng = 2
        break
    elif s[i] == s[i+2]:
        res = i+1
        leng = 3
        break
if s[-2] == s[-1]:
    res = i+1
    leng = 2

if res == -1:
    print("-1 -1")
elif leng == 2:
    print(str(res)+" "+str(res+1))
else:
    print(str(res)+" "+str(res+2))

Fixed submission:
s=input()
n=len(s)
res = -1
leng = 0
for i in range(n-2):
    if s[i] == s[i+1]:
        res = i+1
        leng = 2
        break
    elif s[i] == s[i+2]:
        res = i+1
        leng = 3
        break
if s[-2] == s[-1]:
    res = n-1
    leng = 2

if res == -1:
    print("-1 -1")
elif leng == 2:
    print(str(res)+" "+str(res+1))
else:
    print(str(res)+" "+str(res+2))
Buggy python submission (verdict: Runtime Error):
import sys
import math
input = sys.stdin.readline

############ ---- Input Functions ---- ############
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()

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

def solve(s,k):
    len1 = len(s)
    if len1 > k:
        corte = ''
        for i in range(k):
            corte += s[i]
        corte += '...'
        return corte
	else :
      return s
def main():
    k = inp()
    print(solve(input(),k))


main()




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

if len(S) > K:

    for i in range(0,K):

        print(S[i], end="")

    print("...")

else:

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

############ ---- Input Functions ---- ############
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()

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

def solve(s,k):
    len1 = len(s)
    if len1 > k:
        corte = ''
        for i in range(k):
            corte += s[i]
        corte += '...'
        return corte
      
	return s

def main():
    k = inp()
    print(solve(input(),k))


main()




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

############ ---- Input Functions ---- ############
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))

def solve(a,b,c,d):
    angle = abs(0.5 * (60 * c + d) - 6 * d)
    distance = math.sqrt(pow(a,2) + pow(b,2) - (2*a*b*math.cos(math.radians(angle))))
    return distance

def main():
    a,b,c,d = invr()
    print(solve(a,b,c,d))

main()
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
l = [a,b,c,d,e]
h = 0
j =[]
for i in range(0, 5):
    f = l[i] // 10
    g = l[i] % 10
    if not(g == 0):
        f = f + 1
        j.append(g)
    f = f * 10
    h = h + f
    
if not(g == []):
    h = h + min(j) -10
print(h)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
l = [a,b,c,d,e]
h = 0
j =[]
for i in range(0, 5):
    f = l[i] // 10
    g = l[i] % 10
    if not(g == 0):
        f = f + 1
        j.append(g)
    f = f * 10
    h = h + f
    
if not(j == []):
    h = h + min(j) -10
print(h)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = 1

for i in range(N):
    ans *= A[i]
    if 0 in A:
        ans = 0
        break
    if ans > 1000000000000000000:
        ans = -1
        break

print(ans)

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


if 0 in A:
    ans = 0
else:
    for i in range(N):
        ans *= A[i]
        if ans > 1000000000000000000:
            ans = -1
            break

print(ans)
Buggy python submission (verdict: Runtime Error):
N, K = map(int,input().split())
li = []

for i in range(N):
        li.append(int(input()))

li.sort()

co = K - 1
hmin = 1000000
for i in range(N-K+2):
        if hmin > li[i+co] - li[i]:
                hmin = li[i+co] - li[i]
                if hmin == 0:
                        break
print(hmin)

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

for i in range(N):
        li.append(int(input()))

li.sort()

co = K - 1
hmin = li[co] - li[0]
for i in range(N-K+1):
        if hmin > li[i+co] - li[i]:
                hmin = li[i+co] - li[i]
                if hmin == 0:
                        break
print(hmin)

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

for i in range(N):
        li.append(int(input()))

li.sort()

co = K - 1
hmin = 1000000
for i in range(N):
        if hmin > li[i+co] - li[i]:
                hmin = li[i+co] - li[i]
                if hmin == 0:
                        break
print(hmin)

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

for i in range(N):
        li.append(int(input()))

li.sort()

co = K - 1
hmin = li[co] - li[0]
for i in range(N-K+1):
        if hmin > li[i+co] - li[i]:
                hmin = li[i+co] - li[i]
                if hmin == 0:
                        break
print(hmin)
Buggy python submission (verdict: Runtime Error):
N = int(input())
s = input().split()
count = 1
for i in range(N):
  s[i] = int(s[i])
for i in range(1,N+1):
  t = s[:i]
  if max(t) <= s[i]:
    count = count + 1
print(count)


Fixed submission:
N = int(input())
s = input().split()
count = 1
for i in range(N):
  s[i] = int(s[i])
for i in range(1,N):
  t = s[:i]
  if max(t) <= s[i]:
    count = count + 1
print(count)

Buggy python submission (verdict: Runtime Error):
N = input()
s = input().split()
count = 1
for i in range(N):
  s[i] = int(s[i])
for i in range(1,N+1):
  t = s[:i]
  if max(t) <= s[i]:
    count = count + 1
print(count)


Fixed submission:
N = int(input())
s = input().split()
count = 1
for i in range(N):
  s[i] = int(s[i])
for i in range(1,N):
  t = s[:i]
  if max(t) <= s[i]:
    count = count + 1
print(count)

Buggy python submission (verdict: Runtime Error):
N = input()
s = input().split()
count = 1
for i in range(1,N+1):
  t = s[:i]
  if max(t) <= s[i]:
    count = count + 1
print(count)


Fixed submission:
N = int(input())
s = input().split()
count = 1
for i in range(N):
  s[i] = int(s[i])
for i in range(1,N):
  t = s[:i]
  if max(t) <= s[i]:
    count = count + 1
print(count)

Buggy python submission (verdict: Runtime Error):
N = input()
s = input().split()
count = 0
for i in range(N):
  t = s[:i]
  if max(t) <= s[i]:
    count = count + 1
print(count)

Fixed submission:
N = int(input())
s = input().split()
count = 1
for i in range(N):
  s[i] = int(s[i])
for i in range(1,N):
  t = s[:i]
  if max(t) <= s[i]:
    count = count + 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
S = input()
l = [1]
for i in range(N-1):
    if S[i] == S[i+1]:
        l[-1] += 1
    else:
        l.append(1)
if S[0] == "0":
    l = [0] + l
if S[-1] == "0":
    l += [0]

if len(l) <= 2*K + 1:
    print(sum(l))
else:
    cnt = 0
    for i in range((len(l)-2*K-1)//2+1):
        cnt = max(cnt,sum(l[2*i:2*i+2*K+1]))
    print(cnt)

Fixed submission:
N,K = map(int,input().split())
S = input()
l = [1]
for i in range(N-1):
    if S[i] == S[i+1]:
        l[-1] += 1
    else:
        l.append(1)
if S[0] == "0":
    l = [0] + l
if S[-1] == "0":
    l += [0]
s = [0]
for i in range(len(l)):
    s.append(s[-1]+l[i])
if len(l) <= 2*K + 1:
    print(s[-1])
else:
    cnt = 0
    for i in range((len(l)-2*K-1)//2+1):
        cnt = max(cnt,s[2*K+2*i+1]-s[2*i])
    print(cnt)
Buggy python submission (verdict: Runtime Error):
a = int(input().split())
b = int(input().split())
c = int(input().split())
d = int(input().split())
e = int(input().split())
k = int(input().split())
if (e-a)>k:
    print(":(")
else:
    print("Yay!")

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if (e-a)>k:
    print(":(")
else:
    print("Yay!")
Buggy python submission (verdict: Time Limit Exceeded):
n,a,b,c,d,e = int(input()),int(input()),int(input()),int(input()),int(input()),int(input())
p = [n,0,0,0,0,0]
def time(q):
    A = min(q[0],a)
    B = min(q[1],b)
    C = min(q[2],c)
    D = min(q[3],d)
    E = min(q[4],e)
    q[0] -= A
    q[1] += A-B
    q[2] += B-C
    q[3] += C-D
    q[4] += D-E
    q[5] += E
count = 0
while p[5] < n:
    time(p)
    count += 1
print(count)

Fixed submission:
import math
N,A,B,C,D,E = int(input()),int(input()),int(input()),int(input()),int(input()),int(input())
print(math.ceil(N/min(A,B,C,D,E)+4))

Buggy python submission (verdict: Time Limit Exceeded):
n,a,b,c,d,e = int(input()),int(input()),int(input()),int(input()),int(input()),int(input())
p = [n,0,0,0,0,0]
def time(q):
    change = []
    if q[0] < a:
        change.append(q[0])
    else:
        change.append(a)
    if q[1] < b:
        change.append(q[1])
    else:
        change.append(b)
    if q[2] < c:
        change.append(q[2])
    else:
        change.append(c)
    if q[3] < d:
        change.append(q[3])
    else:
        change.append(d)
    if q[4] < e:
        change.append(q[4])
    else:
        change.append(e)
    q[0] += change[0]
    q[1] += change[0]-change[1]
    q[2] += change[1]-change[2]
    q[3] += change[2]-change[3]
    q[4] += change[3]-change[4]
    q[5] += change[4]
count = 0
while p[5] < n:
    time(p)
    count += 1
print(count)

Fixed submission:
import math
N,A,B,C,D,E = int(input()),int(input()),int(input()),int(input()),int(input()),int(input())
print(math.ceil(N/min(A,B,C,D,E)+4))
Buggy python submission (verdict: Time Limit Exceeded):
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = sorted(list(map(int,input().split())))
S = []
for x in A:
    for y in B:
        S.append(x+y)
S.sort(reverse = True)
S1 = []
for i in range(min(K,X*Y)):
    for j in range(min(len(C),K)):
        S1.append(S[i]+C[j])
S1.sort(reverse = True)
for i in range(K):
    print(S1[i])

Fixed submission:
from heapq import nlargest

x,y,z,k = map(int,input().split())
A,B,C = [list(map(int,input().split())) for _ in [0]*3]

AB = nlargest(k,[a+b for a in A for b in B])
ABC = nlargest(k,[ab+c for ab in AB for c in C])
print("\n".join(map(str,ABC)))

Buggy python submission (verdict: Time Limit Exceeded):
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
S = []
for x in A:
    for y in B:
        S.append(x+y)
S.sort(reverse = True)
S1 = []
for i in range(min(K,X*Y)):
    for z in C:
        S1.append(S[i]+z)
S1.sort(reverse = True)
for i in range(K):
    print(S1[i])

Fixed submission:
from heapq import nlargest

x,y,z,k = map(int,input().split())
A,B,C = [list(map(int,input().split())) for _ in [0]*3]

AB = nlargest(k,[a+b for a in A for b in B])
ABC = nlargest(k,[ab+c for ab in AB for c in C])
print("\n".join(map(str,ABC)))

Buggy python submission (verdict: Time Limit Exceeded):
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
S = []
for x in A:
    for y in B:
        for z in C:
            S.append(x+y+z)
S.sort(reverse = True)
for i in range(K):
    print(S[i])

Fixed submission:
from heapq import nlargest

x,y,z,k = map(int,input().split())
A,B,C = [list(map(int,input().split())) for _ in [0]*3]

AB = nlargest(k,[a+b for a in A for b in B])
ABC = nlargest(k,[ab+c for ab in AB for c in C])
print("\n".join(map(str,ABC)))
Buggy python submission (verdict: Runtime Error):
s = input()
lis=[]
for i in range(len(s)):
    if s[i] not in "ACGT":
        lis.append(i)
len_max = 0
for i in range(len(lis)-1):
    len_max = max(len_max,lis[i+1]-lis[i]-1)
print(max(len_max,lis[0],len(s)-lis[-1]-1))

Fixed submission:
s = input()
lis=[]
for i in range(len(s)):
    if s[i] not in "ACGT":
        lis.append(i)
len_max = 0
for i in range(len(lis)-1):
    len_max = max(len_max,lis[i+1]-lis[i]-1)

if lis != []:
    print(max(len_max,lis[0],len(s)-lis[-1]-1))
else:
    print(len(s))
Buggy python submission (verdict: Time Limit Exceeded):
N,Q =map(int,input().split())
S = input()

pos = []
for i in range(N-1):
    if S[i:i+2] == "AC":
        pos.append(i)
def count(l,r):
    return len([x for x in pos if l-1 <= x  <= r-2])

for i in range(Q):
    l,r = map(int,input().split())
    print(count(l,r))

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

t = [0]
for i in range(N):
    t.append(t[-1]+1 if S[i:i+2] == "AC" else t[-1])
for i in range(Q):
    l,r = map(int,input().split())
    print(t[r-1]-t[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())
S = input()
def count(l,r):
    s = S[l-1:r]
    cnt = 0
    for i in range(len(s)-1):
        if s[i] == "A" and s[i+1] == "C":
            cnt += 1
    return cnt
    
for i in range(Q):
    l,r = map(int,input().split())
    print(count(l,r))

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

t = [0]
for i in range(N):
    t.append(t[-1]+1 if S[i:i+2] == "AC" else t[-1])
for i in range(Q):
    l,r = map(int,input().split())
    print(t[r-1]-t[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())
S = input()
for i in range(Q):
    l,r = map(int,input().split())
    print(S[l-1:r].count("AC"))

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

t = [0]
for i in range(N):
    t.append(t[-1]+1 if S[i:i+2] == "AC" else t[-1])
for i in range(Q):
    l,r = map(int,input().split())
    print(t[r-1]-t[l-1])
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = np.zeros(N, dtype=int)
h = np.array(h)
 
for i in range(1, N):
    start = max(0, i-K)
    dp[i] = min(dp[start:i] + np.abs(h[i] - h[start:i]))
 
print(dp[-1])

Fixed submission:
import numpy as np

N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = np.zeros(N, dtype=int)
h = np.array(h)
 
for i in range(1, N):
    start = max(0, i-K)
    dp[i] = min(dp[start:i] + np.abs(h[i] - h[start:i]))
 
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
h = list(map(int,input().split()))
if N <= K+1:
    print(abs(h[0]-h[-1]))
else:
    dp = [0]*N
    for i in range(K+1):
        dp[i] = abs(h[i]-h[0])
    for i in range(K+1,N):
        m = float("inf")
        for j in range(1,K+1):
            m = min(m,dp[i-j]+abs(h[i]-h[i-j]))
        dp[i] = m
    print(dp[-1])

Fixed submission:
import numpy as np

N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = np.zeros(N, dtype=int)
h = np.array(h)
 
for i in range(1, N):
    start = max(0, i-K)
    dp[i] = min(dp[start:i] + np.abs(h[i] - h[start:i]))
 
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N,W = map(int,input().split())
wv = [list(map(int,input().split())) for _ in [0]*N]
dp = np.zeros((N+1,W+1),dtype = int)
for i in range(1,N+1):
    for j in range(1,W+1):
        if j < wv[i-1][0]:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j],dp[i-1][j-wv[i-1][0]]+wv[i-1][1])
print(dp[N][W])

Fixed submission:
import numpy as np
N,W = map(int,input().split())
w,v = [],[]
for i in range(N):
    a,b = map(int,input().split())
    w += [a]
    v += [b]
dp = np.zeros(W+1,dtype = int)
for i in range(N):
    dp[w[i]:] = np.maximum(dp[:-w[i]]+v[i],dp[w[i]:])
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
import numpy as np
N,W = map(int,input().split())
w,v = [],[]
for i in range(N):
    a,b = map(int,input().split())
    w += [a]
    v += [b]
dp = np.zeros(W+1,dtype = int)
for i in range(N):
    dp[w[i]:] = np.maximum(dp[:-w[i]]+v[i],dp[w[i]:])
print(dp[-1])

Fixed submission:
import numpy as np
N,W=map(int,input().split())
dp=np.ones(10**5+1, dtype='int64')
dp[0]=0
dp[1:]=dp[1:]*(10**9+1)
for i in range(N):
    wi,vi=map(int,input().split())
    dp[vi:]=np.minimum(dp[vi:],dp[:-vi]+wi)
print(np.max(np.where(dp <= W)))
Buggy python submission (verdict: Runtime Error):
X= input()
X = int(X)
if X == 7 or X == 5 or X == 3:
  print "YES"
else:
  print "NO"

Fixed submission:
N = input()
N = int(N)
if N == 7 or N == 5 or N == 3:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
a = [list(map(int,input().split())) for i in range(m)]
for i in range(m):
    b = []
    for j in range(m):
        if a[i][0] == a[j][0]:
            b.append(a[j])
    b.sort(key =lambda x: x[1])
    x = str(b.index(a[i])+1)
    p = str(a[i][0])
    while len(x) < 6:
        x = "0"+x
    while len(p) < 6:
        p = "0"+p
    print(p+x)

Fixed submission:
N, M = map(int, input().split())
pairs = [list(map(int,input().split())) for i in range(M)]

p_count = [1] * (N + 1)
for r in sorted(pairs, key=lambda x: x[1]):
    r.append("{:06}{:06}".format(r[0], p_count[r[0]]))
    p_count[r[0]] += 1

print("\n".join((r[2] for r in pairs)))
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
i = N
while M%i != 0:
    i += 1
print(M//i)

Fixed submission:
N,M = map(int,input().split())
divisors = []
for i in range(1,int(M**.5)+1):
    if M%i == 0:
        divisors.append(i)
        if M//i != i:
            divisors.append(M//i)
ans = 1
for x in divisors:
    if x <= M//N:
        ans = max(ans,x)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

n = int(input())
v = list(map(int,input().split()))
v1 = v[::2]
v2 = v[1::2]
v1_n = Counter(v1)
v1_N =v1_n.most_common()
v2_n = Counter(v2)
v2_N = v2_n.most_common()
if len(v1_N) == 1 and len(v2_N) == 1 and v1_N[0][0] == v2_N[0][0]:
    print(int(n/2))
elif len(([k[0] for k in v1_n.items() if k[1] == max(v1_n.values())])) == 1 and len(([k[0] for k in v2_n.items() if k[1] == max(v2_n.values())])) == 1 and v1_N[0][0] == v2_N[0][0]:
    print(min(n-v1_N[0][1]-v2_N[1][1],n-v1_N[1][1]-v2_N[0][1]))
else:
    print(n-v1_N[0][1]-v2_N[0][1]) 

Fixed submission:
from collections import Counter

n = int(input())
v = list(map(int,input().split()))
v1 = v[::2]
v2 = v[1::2]
v1_N = Counter(v1).most_common()
v2_N = Counter(v2).most_common()
if len(v1_N) == 1 and len(v2_N) == 1 and v1_N[0][0] == v2_N[0][0]:
    print(int(n/2))
elif v1_N[0] == v2_N[0]:
    print(min(n-v1_N[0][1]-v2_N[1][1],n-v1_N[1][1]-v2_N[0][1]))
else:
    print(n-v1_N[0][1]-v2_N[0][1])