Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
p=list(map(int,input().split()))
ans=0
res=[]
for i in range(n):
    if i+k>n:break
    tmp=sum(p[i:i+k])
    ans=max(ans, tmp)
    if ans==tmp:
        res=p[i:i+k]
ans=0
for j in res:
    ans+=(1+j)/2
print(ans)

Fixed submission:
n,k=map(int,input().split())
p=[(i+1)/2 for i in map(float,input().split())]
MAX=sum(p[0:k])
s=[MAX]*n
for i in range(0,n-k):
    s[i+1]=p[i+k]+s[i]-p[i]
    MAX=max(MAX,s[i+1])
print(MAX)

Buggy python submission (verdict: Runtime Error):
import numpy as np
n,k=map(int,input().split())
P=list(map(int,input().split()))
p=np.cumsum(P)
s=[0]*(n//k+1)
MAX=p[0]
ans=0
for i in range(0,n-k):
    MAX=max(MAX,p[i+k]-p[i])
    if MAX==p[i+k]-p[i]:
        s=i
for j in P[s+1:s+k+1]:
    ans+=(1+j)/2
print(ans)

Fixed submission:
n,k=map(int,input().split())
p=[(i+1)/2 for i in map(float,input().split())]
MAX=sum(p[0:k])
s=[MAX]*n
for i in range(0,n-k):
    s[i+1]=p[i+k]+s[i]-p[i]
    MAX=max(MAX,s[i+1])
print(MAX)

Buggy python submission (verdict: Runtime Error):
import numpy as np
n,k=map(int,input().split())
P=list(map(int,input().split()))
p=np.cumsum(P)
s=[0]*(n//k+1)
MAX=p[0]
ans=0
for i in range(0,n-k):
    MAX=max(MAX,p[i+k]-p[i])
    if MAX==p[i+k]-p[i]:
        s=i
for j in P[s+1:s+k+1]:
    ans+=np.cumsum(range(1,j+1))[-1]/j
print(ans)

Fixed submission:
n,k=map(int,input().split())
p=[(i+1)/2 for i in map(float,input().split())]
MAX=sum(p[0:k])
s=[MAX]*n
for i in range(0,n-k):
    s[i+1]=p[i+k]+s[i]-p[i]
    MAX=max(MAX,s[i+1])
print(MAX)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
p=list(map(int,input().split()))
ans=0
res=[]
for i in range(n):
    if i+k>n:break
    tmp=sum(p[i:i+k])
    ans=max(ans, tmp)
    if ans==tmp:
        res=p[i:i+k]
ans=0
for j in res:
    ans+=sum(range(1,j+1))/j
print(ans)

Fixed submission:
n,k=map(int,input().split())
p=[(i+1)/2 for i in map(float,input().split())]
MAX=sum(p[0:k])
s=[MAX]*n
for i in range(0,n-k):
    s[i+1]=p[i+k]+s[i]-p[i]
    MAX=max(MAX,s[i+1])
print(MAX)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
p=[sum(range(1,i+1))/i for i in list(map(int,input().split()))]
ans=0
for i in range(n):
    if i+k>n:break
    ans=max(ans, sum(p[i:i+k]))
print(ans)

Fixed submission:
n,k=map(int,input().split())
p=[(i+1)/2 for i in map(float,input().split())]
MAX=sum(p[0:k])
s=[MAX]*n
for i in range(0,n-k):
    s[i+1]=p[i+k]+s[i]-p[i]
    MAX=max(MAX,s[i+1])
print(MAX)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
H=list(map(int,input().split()))
for _ in range(k):
    if not H:
        break
    H.pop(H.index(max(H)))
print(sum(H))

Fixed submission:
n,k=map(int,input().split())
H=list(map(int,input().split()))
H=sorted(H,reverse=True)
idx=k if k<=len(H) else len(H)
H=H[idx:]
print(sum(H))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
p=list(map(int,input().split()))
cnt=1
for i in range(1,n):
    x=p[i]
    if x<=min(p[:p.index(x)]):
        cnt+=1
    else: continue
print(cnt)

Fixed submission:
n=int(input())
p=list(map(int,input().split()))
cnt=1
min_p=p[0]
for i in range(1,n):
    x=p[i]
    if x<=min_p:
        cnt+=1
        min_p=min(min_p,x)
    else: continue
print(cnt)
Buggy python submission (verdict: Runtime Error):
import itertools

n = int(input())
N = [i for i in range(1,n+1)]
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

for i, j in enumerate(itertools.permutations(N)):
    if j == P:
        a = i + 1
    elif j == Q:
        b = i + 1
print(abs(a - b))

Fixed submission:
import itertools
n=int(input())
r=list(itertools.permutations(range(1,n+1)))
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))
print(abs(r.index(p)-r.index(q)))
Buggy python submission (verdict: Time Limit Exceeded):
a,b,k=map(int,input().split())
for _ in range(k):
	if a > 0:
		a-=1
	elif b > 0:
		b-=1
	else:
		break
print(a,b)

Fixed submission:
a,b,k=map(int,input().split())
if k<=a:
    print(a-k,b)
elif a<k<=a+b:
    print(0,b-(k-a))
else:
    print(0,0)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,k=map(int,input().split())
for _ in range(k):
	if a > 0:
		a-=1
	elif b > 0:
		b-=1
	else:
		break
print(a,b)

Fixed submission:
a,b,k=map(int,input().split())
if k<=a:
    print(a-k,b)
elif a<k<=a+b:
    print(0,b-(k-a))
else:
    print(0,0)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(20000)
x = int(input())

def mody(x,n):
	if n == 1:
		return 1
	if x%n == 0:
		return x
	else:
		return mody(x,n-1)

for i in range(0,10**5-x):
	n = mody(x+i,x+i-1)
	if n == 1:
		ans = x+i
		break
print(ans)

Fixed submission:
def is_prime(x):
    if x<= 1: return False
    i=2
    while i*i<=x:
        if x%i==0:
            return False
        i+=1
    return True

ans = int(input())
while not is_prime(ans):
    ans+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**5)
x = int(input())

def mody(x,n):
	if n == 1:
		return 1
	if x%n == 0:
		return x
	else:
		return mody(x,n-1)

for i in range(0,10**5-x):
	n = mody(x+i,x+i-1)
	if n == 1:
		ans = x+i
		break
print(ans)

Fixed submission:
def is_prime(x):
    if x<= 1: return False
    i=2
    while i*i<=x:
        if x%i==0:
            return False
        i+=1
    return True

ans = int(input())
while not is_prime(ans):
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
s = list(input())
t=-1
cnt=0

for i in s[:m]:
    if i != s[t]:
        cnt+=1
    t-=1
    
print(cnt)

Fixed submission:
s = list(input())
m=len(s)//2
t=-1
cnt=0

for i in s[:m]:
    if i != s[t]:
        cnt+=1
    t-=1
    
print(cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())
testimony = [[] for _ in range(n)]

for i in range(n):
    num = int(input())
    for j in range(num):
        person, state = map(int, input().split())
        testimony[i].append([person-1], state)

honest = 0
for i in range(1, 2**n):
    flag = 0
    for j in range(n):
        if (i>>j)&1 == 1:
            for x, y in testimony[j]:
                if (i>>x)&1 != y:
                    flag = 1
    if flag == 0:
        honest = max(honest, bin(i)[2:].count('1'))

print(honest)

Fixed submission:
n = int(input())
testimony = [[] for _ in range(n)]

for i in range(n):
    num = int(input())
    for j in range(num):
        person, state = map(int, input().split())
        testimony[i].append([person-1, state])

honest = 0
for i in range(1, 2**n):
    flag = 0
    for j in range(n):
        if (i>>j)&1 == 1:
            for x, y in testimony[j]:
                if (i>>x)&1 != y:
                    flag = 1
    if flag == 0:
        honest = max(honest, bin(i)[2:].count('1'))

print(honest)

Buggy python submission (verdict: Runtime Error):
n = int(input())
testimony = [[] for _ in range(n)]

for i in range(n):
    num = int(input())
    for j in range(num):
        person, state = map(int, input().split())
        testimony[i].append([person-1], state)

honest = 0
for i in range(1, 2**n):
    flag = 0
    for j in range(n):
        if (i>>j)&1 == 1:
            for x, y in testimony[j]:
                if (i>>x)&1 != y:
                    flag = 1
                    break
    if flag == 0:
        honest = max(honest, bin(i)[2:].count('1'))

print(honest)

Fixed submission:
n = int(input())
testimony = [[] for _ in range(n)]

for i in range(n):
    num = int(input())
    for j in range(num):
        person, state = map(int, input().split())
        testimony[i].append([person-1, state])

honest = 0
for i in range(1, 2**n):
    flag = 0
    for j in range(n):
        if (i>>j)&1 == 1:
            for x, y in testimony[j]:
                if (i>>x)&1 != y:
                    flag = 1
    if flag == 0:
        honest = max(honest, bin(i)[2:].count('1'))

print(honest)
Buggy python submission (verdict: Runtime Error):
m,d=int(input()),input()
M,D=int(input()),input()

if M - m == 1:
  print('1')
else:
  print('0')

Fixed submission:
m=input().split()
M=input().split()
 
if int(M[0]) - int(m[0]) == 1:
  print('1')
else:
  print('0')
Buggy python submission (verdict: Runtime Error):
N=int(input())
print(rount(N/2)-1)

Fixed submission:
N=int(input())
c=-(-N//2)-1
print(c)

Buggy python submission (verdict: Runtime Error):
N=int(input())/2
print(int(N)

Fixed submission:
N=int(input())
c=-(-N//2)-1
print(c)

Buggy python submission (verdict: Runtime Error):
ans=0
N=int(input())
c=round(N/2)
for i in range(1,c):
    for j in range(c,i,-1):
        cnt=i+j
        if cnt=N:
            ans+=1
print(ans)

Fixed submission:
N=int(input())
c=-(-N//2)-1
print(c)

Buggy python submission (verdict: Runtime Error):
ans=0
N=int(input())
c=round(N/2)
for i in range(1,c):
    for j in range(1,c-i):
        cnt=i+j
        if cnt=N:
            ans+=1
print(ans)

Fixed submission:
N=int(input())
c=-(-N//2)-1
print(c)

Buggy python submission (verdict: Runtime Error):
ans=0
N=int(input())
c=round(N/2)
for i in range(1,c):
	for j in range(1,N-c):
    	cnt=i+j
        if cnt=N:
        	ans+=1
print(ans)

Fixed submission:
N=int(input())
c=-(-N//2)-1
print(c)

Buggy python submission (verdict: Runtime Error):
ans=1
N=int(input())
c=int((N-1)/2)
for i in range(c):
	for j in range(c):
    	cnt=i+j
        if cnt=N:
        	ans+=1
print(ans)

Fixed submission:
N=int(input())
c=-(-N//2)-1
print(c)

Buggy python submission (verdict: Runtime Error):
ans=1
N=int(input())
for i in range(N-1):
	for j in range(N-1):
    	cnt=i+j
        if cnt=N:
        	ans+=1
print(ans)

Fixed submission:
N=int(input())
c=-(-N//2)-1
print(c)
Buggy python submission (verdict: Runtime Error):
import math
a, b, x = map(int, input().split())
if a**2*b/2 >= 2*x:
    c = (2*x)/(a*b)
    print(math.degrees(math.atan(b, c)))
else:
    d = 2*(b-x/a/a)
    print(math.degrees(math.atan(d, a)))

Fixed submission:
import math
a, b, x = map(int, input().split())
c = (2*x)/(a**2)-b
if c <= 0:
    c = (2*x)/(a*b)
    print(math.degrees(math.atan2(b, c)))
else:
    print(math.degrees(math.atan2(b-c, a)))
Buggy python submission (verdict: Time Limit Exceeded):
N,K,Q=map(int,input().split())
players=[K for _ in range(N)]
for _ in range(Q):
    i=int(input())-1
    players[i]+=1
    for i in range(len(players)):
        players[i]-=1
for num,p in enumerate(players):
    if p<=0:print('No')
    else: print('Yes')

Fixed submission:
N,K,Q=map(int,input().split())
players=[K-Q]*N
for _ in range(Q):
    i=int(input())-1
    players[i]+=1
for num,p in enumerate(players):
    if p<=0:print('No')
    else: print('Yes')

Buggy python submission (verdict: Time Limit Exceeded):
N,K,Q=map(int, input().split())
A=[int(input()) for i in range(0,Q)]
k=[K for i in range(0,N)]
for i in A:
    t=k[i-1]
    for n in range(0,N):
        k[n]-=1
    k[i-1]=t
for r in k:
    if r>=1:
        print('Yes')
    else:
        print('No')

Fixed submission:
N,K,Q=map(int,input().split())
players=[K-Q]*N
for _ in range(Q):
    i=int(input())-1
    players[i]+=1
for num,p in enumerate(players):
    if p<=0:print('No')
    else: print('Yes')
Buggy python submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
ans=0
step=0
for i in range(n):
    cnt=0
    for j in range(n):
        if h[step]<h[step+1]: step+=1; break
        cnt+=1; step+=1
        if step+1==n:break
    ans=max(ans,cnt)
    if step+1==n: break
print(ans)

Fixed submission:
n=int(input())
if n==1:print('0'); exit()
h=list(map(int,input().split()))
ans=0
step=0
for i in range(n):
    cnt=0
    for j in range(n):
        if h[step]<h[step+1]: step+=1; break
        cnt+=1; step+=1
        if step+1==n: break
    ans=max(ans,cnt)
    if step+1==n: break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
h=list(map(int,input().split()))
ans=0
for i in range(n):
    cnt=0
    step=h[i]
    for j in range(i+1,n):
        if step<h[j]: break
        step=h[j]
        cnt+=1
    ans=max(ans,cnt)
print(ans)

Fixed submission:
n=int(input())
if n==1:print('0'); exit()
h=list(map(int,input().split()))
ans=0
step=0
for i in range(n):
    cnt=0
    for j in range(n):
        if h[step]<h[step+1]: step+=1; break
        cnt+=1; step+=1
        if step+1==n: break
    ans=max(ans,cnt)
    if step+1==n: break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans = 0
for i in range(1,N):
    ans += i
print(ans)

Fixed submission:
from math import ceil
N = int(input())
n = N -1
if n == 1:
    ans = 1
elif n%2 != 0:
    ans = (1+n)*(n//2) + ceil(n/2)
else:
    ans = (1+n)*(n//2)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans = 0
for i in range(1,N+1):
    ans += i%N
print(ans)

Fixed submission:
from math import ceil
N = int(input())
n = N -1
if n == 1:
    ans = 1
elif n%2 != 0:
    ans = (1+n)*(n//2) + ceil(n/2)
else:
    ans = (1+n)*(n//2)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
S=[list(input()) for _ in range(n)]
Ds=[]
cnt=0; c=0
for s in S:
    d={}
    for t in s:
        if t not in d.keys(): d[t]=1
        else: d[t]+=1
    Ds.append(d)

for i in range(n):
    for j in range(i+1,n):
        if i==j: continue
        for k in Ds[i].keys():
            if k not in Ds[j].keys():c=0; break
            if Ds[i][k]!=Ds[j][k]:c=0; break
            c=1
        if c==1: cnt+=1
print(cnt)

Fixed submission:
n=int(input())
dic={}
ans=0
for _ in range(n):
    S=''.join(sorted(list(input())))
    if S not in dic.keys():
        dic[S]=1
    else:
        ans+=dic[S]
        dic[S]+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(input()) for _ in range(n)]
temp=0
for i in range(n):
    temp=a.pop(0)
    print(max(a))
    a.append(temp)

Fixed submission:
n=int(input())
A=[int(input()) for _ in range(n)]
maxm=sorted(A)
ans=[]
for i in range(n):
    if A[i]==maxm[-1]:
        ans.append(maxm[-2])
    else:
        ans.append(maxm[-1])
for a in ans:
    print(a)
Buggy python submission (verdict: Time Limit Exceeded):
L,R=map(int,input().split())
if L-R>=2019:
    print(0)
else:
    x=[i*j%2019 for i in range(L,R) for j in range(i+1,R+1)]
    print(min(x))

Fixed submission:
L,R=map(int,input().split())
if R-L>=2019:
    print(0)
else:
    x=[i*j%2019 for i in range(L,R) for j in range(i+1,R+1)]
    print(min(x))
Buggy python submission (verdict: Runtime Error):
from math import gcd
a,b,c,d=map(int,input().split())
cd=(c*d)//gcd(c,d)
print(b-(b//c+b//d-b//cd)-((a-1)-((a-1)//c+(a-1)//d-(a-1)//cd)))

Fixed submission:
from fractions import gcd
a,b,c,d=map(int,input().split())
cd=(c*d)//gcd(c,d)
print(b-(b//c+b//d-b//cd)-((a-1)-((a-1)//c+(a-1)//d-(a-1)//cd)))
Buggy python submission (verdict: Runtime Error):
n=int(input())
L=[]
for i in range(n):
    s,p=input().split()
    L.append(s,-int(p),i+1)
for l in sorted(L):
    print(l[2])

Fixed submission:
n=int(input())
L=[]
for i in range(n):
    s,p=input().split()
    L.append([s,-int(p),i+1])
for l in sorted(L):
    print(l[2])
Buggy python submission (verdict: Runtime Error):
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
L = [A[0]]
R = [A[-1]]

for i in range(N-1):
    L.append(gcd(L[-1], A[i+1]))
    R.append(gcd(R[-1], A[N-i-2]))
    print(L, R)
ans = max(L[-2], R[-2])
for i in range(1, N-1):
    ans = max(ans, gcd(L[i-1], R[-i-2]))

print(ans)

Fixed submission:
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
L = [A[0]]
R = [A[-1]]

for i in range(N-1):
    L.append(gcd(L[-1], A[i+1]))
    R.append(gcd(R[-1], A[N-i-2]))

ans = max(L[-2], R[-2])
for i in range(1, N-1):
    ans = max(ans, gcd(L[i-1], R[-i-2]))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import re
from collections import Counter
n, q = map(int, input().split())
s = input()
word = re.findall('AC', s)
C1 = Counter(word)
for _ in range(q):
    l, r = map(int, input().split())
    C2 = Counter(re.findall('AC', s[:l]))
    C3 = Counter(re.findall('AC', s[r-1:]))
    print(C1['AC']-(C2['AC']+C3['AC']))

Fixed submission:
n, q = map(int, input().split())
s = input()
t = [0] * (n + 1)
for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2]=='AC' else 0)
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):
import re
from collections import Counter
n, q = map(int, input().split())
s = input()
for _ in range(q):
    l, r = map(int, input().split())
    word = re.findall('AC', s[l-1:r])
    C = Counter(word)
    print(C['AC'])

Fixed submission:
n, q = map(int, input().split())
s = input()
t = [0] * (n + 1)
for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2]=='AC' else 0)
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 _ 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] * (n + 1)
for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2]=='AC' else 0)
for i in range(q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])
Buggy python submission (verdict: Runtime Error):
from datetime import datetime as dt
import datetime
d1=dt.fromisoformat('2019/04/30'.replace('/', '-'))
d2=dt.fromisoformat(input().replace('/', '-'))
delta=d1-d2
print('Heisei' if delta.days >= 0 else 'TBD')

Fixed submission:
print('Heisei' if input()<='2019/04/30' else 'TBD')

Buggy python submission (verdict: Runtime Error):
from datetime import datetime as dt
d1=dt.fromisoformat('2019/04/30'.replace('/', '-'))
d2=dt.fromisoformat(input().replace('/', '-'))
delta=d1-d2
print('Heisei' if delta.days >= 0 else 'TBD')

Fixed submission:
print('Heisei' if input()<='2019/04/30' else 'TBD')
Buggy python submission (verdict: Runtime Error):
ans=0
n=int(input())
for _ in range(n):
    x,u=input().split()
    if x=='JPY':
        ans+=int(u)
    else:
        ans+=(float(u)*380000.0)
print(ans)

Fixed submission:
ans=0
n=int(input())
for _ in range(n):
    x,u=input().split()
    if u=='JPY':
        ans+=int(x)
    else:
        ans+=(float(x)*380000.0)
print(ans)

Buggy python submission (verdict: Runtime Error):
ans=0
n=int(input())
for _ in range(n):
    x,u=input().split()
    if x=='JPY':
        ans+=int(u)
    else:
        ans+=(int(u)*380000)
    ans=int(ans)
print(ans)

Fixed submission:
ans=0
n=int(input())
for _ in range(n):
    x,u=input().split()
    if u=='JPY':
        ans+=int(x)
    else:
        ans+=(float(x)*380000.0)
print(ans)

Buggy python submission (verdict: Runtime Error):
ans=0
n=int(input())
for _ in range(n):
    x,u=input().split()
    if x=='JPY':
        ans+=int(u)
    else:
        ans+=(int(u)*380000)
print(ans)

Fixed submission:
ans=0
n=int(input())
for _ in range(n):
    x,u=input().split()
    if u=='JPY':
        ans+=int(x)
    else:
        ans+=(float(x)*380000.0)
print(ans)

Buggy python submission (verdict: Runtime Error):
ans=0
n=int(input())
for _ in range(n):
    x,u=input().split()
    ans+=int(u) if x=='JPY' else int(u)*380000
print(ans)

Fixed submission:
ans=0
n=int(input())
for _ in range(n):
    x,u=input().split()
    if u=='JPY':
        ans+=int(x)
    else:
        ans+=(float(x)*380000.0)
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
l=list(map(int,input().split()))
dp=[math.inf for _ in range(n)]
dp[0]=0
dp[1]=abs(l[1]-l[0])

for i in range(2,n):
    single=abs(l[i]-l[i-1])+dp[i-1]
    double=abs(l[i]-l[i-2])+dp[i-2]
    dp[i]=min(single,double)

print(dp[n-1])

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
dp=[0 for _ in range(n)]
dp[1]=abs(l[1]-l[0])

for i in range(2,n):
    single=abs(l[i]-l[i-1])+dp[i-1]
    double=abs(l[i]-l[i-2])+dp[i-2]
    dp[i]=min(single,double)

print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
H = list(map(int, input().split()))

DP = [10**9]*N
DP[0] = 0
DP[1] = abs(H[1]-H[0])

for k in range(2,N+1):
    for l in range(1,K+1):
        if k-l < 0 or k > N-1:
            break
        DP[k] = min(DP[k], DP[k-l]+abs(H[k]-H[k-l]))

print(DP[-1])

Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*n

for i in range(1,n):
    dp[i]=min(dp[j] + abs(h[j]-h[i]) for j in range(max(0,i-k),i))

print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
H=list(map(int,input().split()))
dp=[10**9]*n
dp[0]=0

i=0
for i in range(n):
    min_step=10**9
    for j in range(1,k+1):
        if i+j>=n:break
        step=abs(H[i]-H[i+j])
        dp[i+j]=min(dp[i]+step,dp[i+j])

print(dp[-1])

Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*n

for i in range(1,n):
    dp[i]=min(dp[j] + abs(h[j]-h[i]) for j in range(max(0,i-k),i))

print(dp[-1])
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

n, m = map(int, input().split())
PY = [tuple(map(int, input().split())) for _ in range(m)]
ypi = sorted((y, p) for i, (p, y) in enumerate(PY))
d = defaultdict(lambda: 0)

ans = [None]*m

for y, p in ypi:
    d[p] += 1
    ans[i] = str(p).zfill(6) + str(d[p]).zfill(6)

print(*ans, sep='\n')

Fixed submission:
from collections import defaultdict

n, m = map(int, input().split())
PY = [tuple(map(int, input().split())) for _ in range(m)]
ypi = sorted((y, p, i) for i, (p, y) in enumerate(PY))
d = defaultdict(lambda: 0)

ans = [None]*m

for y, p, i in ypi:
    d[p] += 1
    ans[i] = str(p).zfill(6) + str(d[p]).zfill(6)

print(*ans, sep='\n')
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
C1 = []
C2 = []
for i in range(n)[::2]:
    C1.append(v[i])
    C2.append(v[i+1])

C1 = Counter(C1).most_common()
C2 = Counter(C2).most_common()

if C1[0][0] != C2[0][0]:
    print(n-C1[0][1]-C2[0][1])
else:
    ans1 = n-C1[0][1]-C2[1][1]
    ans2 = n-C1[1][1]-C2[0][1]
    print(min(ans1, ans2))

Fixed submission:
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
v1 = Counter(v[::2])
v2 = Counter(v[1::2])
E = v1.most_common()
O = v2.most_common()
if E[0][0] == O[0][0]:
    tmp1 = E[1][1] if len(E) > 1 else 0
    tmp2 = O[1][1] if len(O) > 1 else 0
    ans = min(n-E[0][1]-tmp2, n-tmp1-O[0][1])
else:
    ans = n-E[0][1]-O[0][1]
print(ans)
Buggy python submission (verdict: Runtime Error):
import bisect
N, X = map(int, input().split())
x = sorted(list(map(int, input().split()))+[X])

i = bisect.bisect_left(x, X)
print(min(abs(x[i-1]-x[i]), abs(x[i]-x[i+1])))

Fixed submission:
from fractions import gcd
N, X = map(int, input().split())
L = sorted(list(map(int, input().split())))

ans = abs(L[0]-X)
for x in L[1:]:
    ans = gcd(ans, abs(x-X))
print(ans)

Buggy python submission (verdict: Runtime Error):
import bisect
N, X = map(int, input().split())
x = sorted(list(map(int, input().split())))

i = bisect.bisect_left(x, X)
print(min(abs(x[i-1]-X), abs(X-x[i])))

Fixed submission:
from fractions import gcd
N, X = map(int, input().split())
L = sorted(list(map(int, input().split())))

ans = abs(L[0]-X)
for x in L[1:]:
    ans = gcd(ans, abs(x-X))
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(innput())
f = 4
s = 7
for i in range(30):
  f = f*i
  for j in range(30):
    s = s*j
    if n%s == 0 or n%f == 0 or n%(f+s)==0:
      print('Yes')
      quit()
    if n < f+s:
      break
print('No')

Fixed submission:
n = int(input())
for i in range(100):
  for j in range(100):
    if 4*i+7*j == n:
        print('Yes')
        exit(0)
print('No')

Buggy python submission (verdict: Runtime Error):
n = int(innput())
f = 4
s = 7
for i in range(30):
  f = f*i
  for j in range(30):
    s = s*j
    if n%s == 0 or n%f == 0 or n%(f+s)==0:
      print('Yes')
      quit()
   	if n < f+s:
      break
print('No')
      

Fixed submission:
n = int(input())
for i in range(100):
  for j in range(100):
    if 4*i+7*j == n:
        print('Yes')
        exit(0)
print('No')