Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as	np
N,K=map(int,input().replace('\n','').split())
P=list(map(int,input().replace('\n','').split()))

m=-1.0
for i in range(N-K+1):
  if np.sum(P[i:i+K])>=m:
    m=np.sum(P[i:i+K])
    ml=P[i:i+K]

print((m+K)/2)

Fixed submission:
import numpy as	np
N,K=map(int,input().replace('\n','').split())
P=list(map(int,input().replace('\n','').split()))

s=np.sum(P[0:K])
m=s
for i in range(1,N-K+1):
  s=s-P[i-1]+P[i+K-1]
  if s>=m:
    m=s
	
print((m+K)/2)
Buggy python submission (verdict: Runtime Error):
a,b,k = map(int,input().spit())
if a > k:
  print(a-k, b)
elif a+b >k:
  print(0, a+b -k)
else:
  print(0,0)

Fixed submission:
A, B, K = map(int, input().split())
if A > K:
    print(A-K, B)
elif A+B > K:
    print(0, A+B-K)
else:
    print(0, 0)
Buggy python submission (verdict: Runtime Error):
n,a,b = map(int, input().split())
print( min(n*a,b)

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

d = n * a
t = b

ans = min([d,t])
print(ans)
Buggy python submission (verdict: Runtime Error):
n= int(input())
list = [int(x) for x in input().split()]

if max(list) <  (sum(list) - max(list)):
  print('Yes')
else:
  print('No'

Fixed submission:
n= int(input())
l = [int(x) for x in input().split()]
print('Yes' if max(l)<sum(l)-max(l) else 'No')
Buggy python submission (verdict: Runtime Error):
A=int(input())
B=int(input())

print((A-1)*(B-1))

Fixed submission:
a,b =map(int, input().split())
print((a-1)*(b-1))
Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())

if n %k !=0:
  print(m%k)
else:
  print(0)

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

if n %k :
  print(1)
else:
  print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int() for _ in input().split()]
cnt =0
while all(i%2==0 for i in a):
    a = [int(i//2) for i in a]
    cnt +=1
print(cnt)

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
c = 0
while all(a%2 == 0 for a in A) :
    for i in range(len(A)): A[i] = A[i]/2
    c += 1
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int() for _ in input().split()]
cnt =0
while all(i%2==0 for i in a):
  a = [int(i//2) for i in a]
  cnt +=1
print(cnt)

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
c = 0
while all(a%2 == 0 for a in A) :
    for i in range(len(A)): A[i] = A[i]/2
    c += 1
print(c)
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = [2,1]
for i in range(2,100):
  a = l[i-2]+l[i-1]
  l.append(a)
print(l[int(input())])

Fixed submission:

l = [2,1]
for i in range(2,100):
  a = l[i-2]+l[i-1]
  l.append(a)
print(l[int(input())])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = []
ans =0
for i in range(n):
  a = int(input())
  l.append(a)
b = set(l)
for j in b:
  if l.count(j) %2 !=0:
    ans +=1
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
l = [0] * n
ans =0
for i in range(n):
  l[i] = int(input())
print( sum(s%2 for s in Counter(l).values()))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = []
ans =0
for i in range(n):
  a = int(input())
  l.append(a)
b = set(l)
for j in b:
  if l.count(j) %2 !=0:
    ans +=1
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
l = [0] * n
ans =0
for i in range(n):
  l[i] = int(input())
print( sum(s%2 for s in Counter(l).values()))
Buggy python submission (verdict: Runtime Error):
n=int(input())
m=int(input())
print((n-1)*(m-1))

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

print((n-1)*(m-1))
Buggy python submission (verdict: Runtime Error):
a,b,c = map(input().split(","))
print(a,b,c)

Fixed submission:
a,b,c = input().split(",")
print(a,b,c)

Buggy python submission (verdict: Runtime Error):
a,b,c = map(input().split(","))
print(A,b,c)

Fixed submission:
a,b,c = input().split(",")
print(a,b,c)

Buggy python submission (verdict: Runtime Error):
a,b,c = map(int().split(","))
print(A,b,c)

Fixed submission:
a,b,c = input().split(",")
print(a,b,c)
Buggy python submission (verdict: Time Limit Exceeded):
k,s = map(int, input().split())
cnt =0
for i in range(k+1):
  for j in range(k+1):
    for k in range(k+1):
      if i+j+k == s:
        cnt +=1
print(cnt)

Fixed submission:
k,s = map(int, input().split())

cnt = 0

for i in range(k+1):
  for j in range(k+1):
    if 0<= s -i -j <= k:
      cnt +=1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,x = map(int, input().split())
cnt=0
for i in range(a,b+1):
  if i%x ==0:
    cnt +=1
print(cnt)

Fixed submission:
a,b,x = map(int, input().split())
if a %x==0:
  print(b//x - a//x+1)
else:
  print(b//x - a//x)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,x = map(int, input().split())
s =[]
cnt=0
for i in range(a,b+1):
  s.append(i)
for j in s:
  if j %x==0:
    cnt +=1
print(cnt)

Fixed submission:
a,b,x = map(int, input().split())
if a %x==0:
  print(b//x - a//x+1)
else:
  print(b//x - a//x)
Buggy python submission (verdict: Runtime Error):
h,n = map(int,input().split())
a = [list(map(int,input().split()))for _ in range(n)]
z1 = [0,0]
z2 = [w,h]
for i in range (n):
    if a[i][2] == 1 and z1[0] <= a[i][0]:
        z1[0] = a[i][0]
    elif a[i][2] == 2 and z2[0] >= a[i][0]:
        z2[0] = a[i][0]
    elif a[i][2] == 3 and z1[1] <= a[i][1] :
        z1[1] = a[i][1]
    elif a[i][2] == 4 and z2[1] >= a[i][1] :
        z2[1] = a[i][1]
if z2[0] > z1[0] and z2[1] > z1[1]:
    print((z2[0]-z1[0])*(z2[1]-z1[1]))
else:
    print(0)

Fixed submission:
w,h,n = map(int,input().split())
a = [list(map(int,input().split()))for _ in range(n)]
z1 = [0,0]
z2 = [w,h]
for i in range (n):
    if a[i][2] == 1 and z1[0] <= a[i][0]:
        z1[0] = a[i][0]
    elif a[i][2] == 2 and z2[0] >= a[i][0]:
        z2[0] = a[i][0]
    elif a[i][2] == 3 and z1[1] <= a[i][1] :
        z1[1] = a[i][1]
    elif a[i][2] == 4 and z2[1] >= a[i][1] :
        z2[1] = a[i][1]
if z2[0] > z1[0] and z2[1] > z1[1]:
    print((z2[0]-z1[0])*(z2[1]-z1[1]))
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
a,b = map(int, input().split())
l = [i for i in range(a,b+1)]
ans =1
for i in range(len(l)):
  ans = ans *l[i]
if ans <0:
  print('Negative')
elif ans >0:
  print('Positive')
else:
  print('Zero')

Fixed submission:
a, b = map(int, input().split())

if a>0 and b>0:
  print('Positive')
elif a <= 0 and b >=0:
  print('Zero')
else:
  print('Positive' if (b-a +1)%2 ==0 else 'Negative')
Buggy python submission (verdict: Runtime Error):
n,l = map(int,input().split())
ss =[]
for i in range(n):
  s = input()
  ss.append(s)
ss.sort()
print(''.join(ss)

Fixed submission:
n,l = map(int,input().split())
s = list(input() for i in range(n))

c = sorted(s)
ans =''.join(c)
print(ans)
Buggy python submission (verdict: Runtime Error):
s,t=input().split()
a,b=map(int,input().split())
u=input()
if u = s:
  a -=1
else:
  b -=1
print(a,b)

Fixed submission:
s,t=input().split()
a,b=map(int,input().split())
u=input()
if u == s:
  a -=1
else:
  b -=1
print(a,b)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())

l=[]
for i in range(n):
  a,b=map(int, input().split())
  l.append([a]*b)
ll=[]
for i in l:
  for j in i:  
    ll.append(j)
 
ll=sorted(ll)
print(ll[k-1])


Fixed submission:
n,k=map(int,input().split())
li = [list(map(int, input().split())) for i in range(n)]
li.sort()
c=0
for i in range(n):
  c+=li[i][1]
  if c>=k:
    print(li[i][0])
    
    break

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
l=[]
for i in range(n):
  a,b=map(int,input().split())
  for j in range(b):
    l.append(a)
l=sorted(l)
print(l[k-1])

Fixed submission:
n,k=map(int,input().split())
li = [list(map(int, input().split())) for i in range(n)]
li.sort()
c=0
for i in range(n):
  c+=li[i][1]
  if c>=k:
    print(li[i][0])
    
    break
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
arr = map(int, raw_input().split())
new = [0 for i in range(n)]

for i in range(n):
    new[i] = arr.index(i+1)+1

for k in new:
    print k,


Fixed submission:
n = input()
arr = map(int, raw_input().split())
new = [0 for i in range(n)]


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

for k in new:
    print k,
Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
nd = len(str(n))

a3 = [357, 375, 537, 573, 735, 753]
arr_a = [[]for i in range(nd-2)]
arr_a[0] = a3
all_num = [357, 375, 537, 573, 735, 753]
for i in range(1, nd-2):
    for j in arr_a[i-1]:
        arr_a[i].append(j*10+3)
        arr_a[i].append(j*10+5)
        arr_a[i].append(j*10+7)
    for k in arr_a[i]:
        all_num.append(k)
# print arr_a

def only_2kind(a,b,n):
    if n <= 3:
        return []
    else:
        all_num = []
        o = [10 * a + b, 10 * b + a, 10 * a + a, 10 * b + b]
        for j in range(n-3):
            o2 = []
            for i in range(len(o)):
                o2.append(o[i]*10+a)
                o2.append(o[i] * 10 + b)
            # print o2
            for i in range(len(o2)):
                if o2[i] != int(str(a)*(j+3)) and o2[i] != int(str(b) * (j + 3)):
                    all_num.append(o2[i]*10+(15-a-b))
            o = o2
        return all_num

all_num+=(only_2kind(3,5,nd)+only_2kind(5,7,nd)+only_2kind(3,7,nd))
all_num.append(n)
all_num.sort()
# print len(all_num)
# for i in all_num:
#     print i
print all_num.index(n)

Fixed submission:
n = int(raw_input().split()[0])

o1 = [3,5,7]
arr = [n]
ans = 0
def check(num):
    l = len(str(num))
    s = []
    for i in range(l):
        if str(num)[i] not in s:
            s.append(str(num)[i])
    if len(s) == 3:
        return True
    else:
        return False

for i in range(8):
    o2 = []
    for num in o1:
        new1 = num*10+3
        new2 = num*10+5
        new3 = num*10+7
        o2.append(new1)
        o2.append(new2)
        o2.append(new3)
        if check(new1):
            arr.append(new1)
            if n == new1:
                ans += 1
        if check(new2):
            arr.append(new2)
            if n == new2:
                ans += 1
        if check(new3):
            arr.append(new3)
            if n == new3:
                ans += 1
    o1 = o2
arr.sort()
print arr.index(n) + ans
Buggy python submission (verdict: Time Limit Exceeded):
h, w, k = map(int, raw_input().split())
arr = [1, 2, 3, 5, 8, 13, 21, 34]


def p(num):
    return max(0, num)


def dp(i, j):

    if i == 0:
        if j == 0:
            r = 1
        else:
            r = 0
    else:
        y = dp(i - 1, j)
        if j - 1 < 0:
            x = 0
        else:
            x = dp(i - 1, j - 1)
        if j + 1 > w - 1:
            z = 0
        else:
            z = dp(i - 1, j + 1)
        r = x * arr[p(j-2)] * arr[p(w-j-2)] + \
            y * arr[p(j-1)] * arr[p(w-j-2)] + \
            z * arr[p(j-1)] * arr[p(w-j-3)]

    return r % (10**9+7)

print dp(h, k-1)

Fixed submission:
h, w, k = map(int, raw_input().split())
arr = [1, 2, 3, 5, 8, 13, 21, 34]


def p(num):
    return max(0, num)

r = [[0 for i in range(w)] for i in range(h+1)]
for i in range(h+1):
    for j in range(w):

        if i == 0:
            if j == 0:
                r[i][j] = 1
            else:
                r[i][j] = 0
        else:
            y = r[i - 1][j]
            if j - 1 < 0:
                x = 0
            else:
                x = r[i - 1][j - 1]
            if j + 1 > w - 1:
                z = 0
            else:
                z = r[i - 1][j + 1]
            r[i][j] = (x * arr[p(j-2)] * arr[p(w-j-2)] + \
                y * arr[p(j-1)] * arr[p(w-j-2)] + \
                z * arr[p(j-1)] * arr[p(w-j-3)]) % (10**9+7)
    

print r[h][k-1]
Buggy python submission (verdict: Runtime Error):
n, m = map(int, raw_input().split())

yueshu = []
for i in range(1, int(m**0.5)+1):
    if m % i == 0:
        yueshu.insert(0, m/i)
        if i >= n:
            print m / i
            break
for i in range(int(m**0.5)+1, m):
    if m % i == 0:
        if i >= n:
            print m / i
            break





Fixed submission:
n, m = map(int, raw_input().split())

yueshu = []
state = 0
if m % n == 0:
    print m / n
else:
    for i in range(1, int(m**0.5)+1):
        if m % i == 0:
            yueshu.insert(0, m/i)
            if i >= n:
                print m / i
                state = 1
                break
    if state == 0:
        for i in yueshu:
            if m % i == 0:
                if i >= n:
                    print m / i
                    state = 1
                    break
    if state == 0:
        print 1
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,raw_input().split())
if a+b=>c:
  print "Yes"
else:
  print "No"


Fixed submission:
a, b, c = map(int, raw_input().split())
if a + b >= c:
  print "Yes"
else:
  print "No"
Buggy python submission (verdict: Runtime Error):
s,b = input().split()
d = {}
d[s],d[b] = [int(x) for x in input().split()]
d[input] -= 1
print(d[s],d[b])

Fixed submission:
s,b = input().split()
d = {}
d[s],d[b] = [int(x) for x in input().split()]
d[input()] -= 1
print(d[s],d[b])
Buggy python submission (verdict: Time Limit Exceeded):
n, k = [int(x) for x in input().split()]
p = [1/2 + int(x)/2 for x in input().split()]
max_t = 0
for i in range(n - k + 1):
    buf = sum(p[i:i + k])
    if max_t < buf:
        max_t = buf
print(max_t)

Fixed submission:
n, k = [int(x) for x in input().split()]
p = [1/2 + int(x)/2 for x in input().split()]
sum_p =[]
buf = 0
for i in p:
    buf += i
    sum_p.append(buf)
max_t = 0
for i in range(n - k + 1):
    buf = sum_p[i+k-1]
    if i > 0:
        buf -= sum_p[i-1]
    if max_t < buf:
        max_t = buf
print(max_t)

Buggy python submission (verdict: Runtime Error):
n,k = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
max_t = 0
ans = 0
for i in range(n - k +1):
	buf = sum(p(i:i+k))
	if max_t < buf:
		max_t = buf
		ans = 0
		for j in range(k):
			ans += (1+p[i+j]) * p[i+j] / 2
print(ans)

Fixed submission:
n, k = [int(x) for x in input().split()]
p = [1/2 + int(x)/2 for x in input().split()]
sum_p =[]
buf = 0
for i in p:
    buf += i
    sum_p.append(buf)
max_t = 0
for i in range(n - k + 1):
    buf = sum_p[i+k-1]
    if i > 0:
        buf -= sum_p[i-1]
    if max_t < buf:
        max_t = buf
print(max_t)

Buggy python submission (verdict: Runtime Error):
n,k = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
max_t = 0
ans = 0
for i in range(n - k +1):
  buf = sum(p(i:i+k))
  if max_t < buf:
  	max_t = buf
    ans = 0
    for j in range(k):
      ans += (1+p[i+j]) * p[i+j] / 2
print(ans)

Fixed submission:
n, k = [int(x) for x in input().split()]
p = [1/2 + int(x)/2 for x in input().split()]
sum_p =[]
buf = 0
for i in p:
    buf += i
    sum_p.append(buf)
max_t = 0
for i in range(n - k + 1):
    buf = sum_p[i+k-1]
    if i > 0:
        buf -= sum_p[i-1]
    if max_t < buf:
        max_t = buf
print(max_t)
Buggy python submission (verdict: Runtime Error):
n,k = input().split()
m = [int(x) for x in input().split()]
m.sort()
for i in range(k):
  if len(m) == 0:
    break
  m.pop(len(m))
print(sum(m))

Fixed submission:
n,k = [int(x) for x in input().split()]
m = [int(x) for x in input().split()]
m.sort()
if n<k:
  k = n
print(sum(m[0:n-k]))
Buggy python submission (verdict: Runtime Error):
print(2**(len(bin(int(nput()))) - 2) - 1)

Fixed submission:
print(2**(len(bin(int(input()))) - 2) - 1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
p = [int(x) for x in input.split()]
ans = 0
mn = n
for i in p:
  if mn > i:
    mn = i
  if mn >= i:
    ans += 1
print(ans)

Fixed submission:
n = int(input())
p = [int(x) for x in input().split()]
ans = 0
mn = n
for i in p:
  if mn > i:
    mn = i
  if mn >= i:
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
  print(chr(ord(s)+1))

Fixed submission:
s = input()
print(chr(ord(s)+1))
Buggy python submission (verdict: Runtime Error):
n = int(input())
print((n-n//2)/n))

Fixed submission:
n = int(input())
print((n-n//2)/n)
Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = map(int, input().split())
PO = [K]*N
while Q:
  c = int(input())
  for i in range(N):
    if i==(c-1):
      pass
    else:
      PO[i]-=1
  Q-=1
for i in range(N):
  if PO[i]>0:
    print("Yes")
  else:
    print("No")
    

Fixed submission:
n, k, q = map(int, input().split())
po = [0]*n
r = q-k
while q:
  c = int(input())
  po[c-1]+=1
  q-=1
for i in range(n):
  if po[i]>r:
    print('Yes')
  else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
print((n*(n-1)//2)

Fixed submission:
n = int(input())
print((n*(n-1))//2)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
print(sum(range(1,n)))

Fixed submission:
n = int(input())
print((n*(n-1))//2)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
sum = 0
n1 = n
for i in range(n-1,0,-1):
  sum+=i%n1
  n1-=1
print(sum)

Fixed submission:
n = int(input())
print((n*(n-1))//2)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans1,ans2=0,0
i = 0
while i < n-1:
    j = i+1
    while j < n:
        if a[i]>a[j]:
            ans1+=1
        j+=1
    i+=1
i = 0
while i < 2*n-1:
    j = i+1
    while j < 2*n:
        if a[i%n]>a[j%n]:
            ans2+=1
        j+=1
    i+=1
print((ans1*((1+k)*k)//2+(ans2-3*ans1)*((1+(k-1))*(k-1))//2)%(10**9+7))

Fixed submission:
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans1 = 0
ans3 = 0
for i in range(n-1):
    for j in range(i+1,n):
        if a[i]>a[j]:
            ans1+=1
        elif a[i]==a[j]:
            ans3+=1
ans2 = (n*(n-1))//2 - ans1 - ans3
print((ans1*((1+k)*k)//2+ans2*(k*(k-1))//2)%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans1,ans2=0,0
for i in range(n-1):
    for j in range(i+1,n):
        if a[i]>a[j]:
            ans1+=1
for i in range(2*n-1):
    for j in range(i+1,2*n):
        if a[i%n]>a[j%n]:
            ans2+=1
print((ans1*((1+k)*k)//2+(ans2-3*ans1)*((1+(k-1))*(k-1))//2)%(10**9+7))

Fixed submission:
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans1 = 0
ans3 = 0
for i in range(n-1):
    for j in range(i+1,n):
        if a[i]>a[j]:
            ans1+=1
        elif a[i]==a[j]:
            ans3+=1
ans2 = (n*(n-1))//2 - ans1 - ans3
print((ans1*((1+k)*k)//2+ans2*(k*(k-1))//2)%(10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())

listA=[]

try:
    listA = list(input().split())
    #listA<-[1,2,2,3,1]
    #print(listA)
    #ここに逐次処理を書けばいいと思う。
except:
    quit();
    #または、quit(),os.exit()をして止める。


for i in listA:
    if listA.count(i) >= 2:
        print('NO')
        quit();

print('YES')

Fixed submission:
N=int(input())

listA=[]

try:
    listA = list(input().split())
    #listA<-[1,2,2,3,1]
    #print(listA)
    #ここに逐次処理を書けばいいと思う。
except:
    quit();
    #または、quit(),os.exit()をして止める。


listA.sort()


for i in range(len(listA)-1):
    if listA[i] == listA[i+1]:
        print('NO')
        quit();

print('YES')
Buggy python submission (verdict: Runtime Error):
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

try:
    listA = list(input().split())
    #listA<-[1,2,2,3,1]
    #print(listA)
    #ここに逐次処理を書けばいいと思う。
except:
    quit();
    #または、quit(),os.exit()をして止める。

a=int(listA[0])
b=int(listA[1])

print(lcm(a, b))

Fixed submission:
def gcd(a, b):
    if a < b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b

def lcm(x, y):
    return (x * y) // gcd(x, y)

try:
    listA = list(input().split())
    #listA<-[1,2,2,3,1]
    #print(listA)
    #ここに逐次処理を書けばいいと思う。
except:
    quit();
    #または、quit(),os.exit()をして止める。

a=int(listA[0])
b=int(listA[1])

print(lcm(a, b))
Buggy python submission (verdict: Runtime Error):
import numpy as np

list1=[]

try:
    list1=list(map(int, input().split()))
except:
    quit();

N=list1[0]
W=list1[1]

inp=[]

for _ in range(N):
    try:
        inp.append(list(map(int, input().split())))
    except:
        quit();

inp=np.array(inp)
inp=inp.T
wlist=inp[0]
vlist=inp[1]

dp=np.zeros((N+1,W+1))

for i in range(N+1):
    if i >= 1:
        for j in range(W+1):
            if wlist[i-1] > j:
                dp[i][j]=dp[i-1][j]
            else:
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-wlist[i-1]]+vlist[i-1])

print(int(dp[N][W]))


Fixed submission:
N=int(input())

try:
    h = list(input().split())
    #listA<-[1,2,2,3,1]
    #print(listA)
    #ここに逐次処理を書けばいいと思う。
except:
    quit();
    #または、quit(),os.exit()をして止める。

dp=[]

for i in range(N):
    dp.append(0)

dp[1]=abs(int(h[0])-int(h[1]))

for j in range(2,N):
    min=float('inf')
    for i in range(j-2,j):
        num=abs(int(h[i])-int(h[j])) + dp[i]
        if num < min:
            min=num
    dp[j]=min

print(dp[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
try:
    inp = list(input().split())
    #listA<-[1,2,2,3,1]
    #print(listA)
    #ここに逐次処理を書けばいいと思う。
except:
    quit();
    #または、quit(),os.exit()をして止める。

try:
    h = list(input().split())
    #listA<-[1,2,2,3,1]
    #print(listA)
    #ここに逐次処理を書けばいいと思う。
except:
    quit();
    #または、quit(),os.exit()をして止める。

N=int(inp[0])
K=int(inp[1])

dp=[0]*N



for j in range(1,N):
    min=float('inf')

    if j-K>=0:
        bnum=j-K
    else:
        bnum=0

    for i in range(bnum,j):
        num=abs(int(h[i])-int(h[j])) + dp[i]
        if num < min:
            min=num
    dp[j]=min

print(dp[N-1])



Fixed submission:
import sys
import numpy as np
input = sys.stdin.readline

try:
    inp = list(input().split())
    #listA<-[1,2,2,3,1]
    #print(listA)
    #ここに逐次処理を書けばいいと思う。
except:
    quit();
    #または、quit(),os.exit()をして止める。

try:
    h = list(map(int, input().split()))
    #listA<-[1,2,2,3,1]
    #print(listA)
    #ここに逐次処理を書けばいいと思う。
except:
    quit();
    #または、quit(),os.exit()をして止める。

N=int(inp[0])
K=int(inp[1])

dp=[0]*N

dp=np.array(dp)
h=np.array(h)

for j in range(1,N):
    bnum=max(0,j-K)
    dp[j]=np.min(np.abs(h[bnum:j]-h[j]) + dp[bnum:j])

print(dp[N-1])

Buggy python submission (verdict: Time Limit Exceeded):
try:
    inp = list(input().split())
    #listA<-[1,2,2,3,1]
    #print(listA)
    #ここに逐次処理を書けばいいと思う。
except:
    quit();
    #または、quit(),os.exit()をして止める。

try:
    h = list(input().split())
    #listA<-[1,2,2,3,1]
    #print(listA)
    #ここに逐次処理を書けばいいと思う。
except:
    quit();
    #または、quit(),os.exit()をして止める。

N=int(inp[0])
K=int(inp[1])

dp=[]

for i in range(N):
    dp.append(0)



for j in range(1,N):
    min=float('inf')

    if j-K>=0:
        bnum=j-K
    else:
        bnum=0

    for i in range(bnum,j):
        num=abs(int(h[i])-int(h[j])) + dp[i]
        if num < min:
            min=num
    dp[j]=min

print(dp[N-1])



Fixed submission:
import sys
import numpy as np
input = sys.stdin.readline

try:
    inp = list(input().split())
    #listA<-[1,2,2,3,1]
    #print(listA)
    #ここに逐次処理を書けばいいと思う。
except:
    quit();
    #または、quit(),os.exit()をして止める。

try:
    h = list(map(int, input().split()))
    #listA<-[1,2,2,3,1]
    #print(listA)
    #ここに逐次処理を書けばいいと思う。
except:
    quit();
    #または、quit(),os.exit()をして止める。

N=int(inp[0])
K=int(inp[1])

dp=[0]*N

dp=np.array(dp)
h=np.array(h)

for j in range(1,N):
    bnum=max(0,j-K)
    dp[j]=np.min(np.abs(h[bnum:j]-h[j]) + dp[bnum:j])

print(dp[N-1])