Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
c1 = map(int,input().split())
c2 = map(int,input().split())
c3 = map(int,input().split())

d1 = [c2[i] - c1[i] for i in range(3)]
d2 = [c3[i] - c1[i] for i in range(3)]

if(d1[0] == d1[1] and d1[0] == d1[2] and d2[0] ==d2[1] and d2[0] == d2[2]):
  print("Yes")
else:
  print("No")

Fixed submission:
c1 = list(map(int,input().split()))
c2 = list(map(int,input().split()))
c3 = list(map(int,input().split()))
 
d1 = [c2[i] - c1[i] for i in range(3)]
d2 = [c3[i] - c1[i] for i in range(3)]
 
if(d1[0] == d1[1] and d1[0] == d1[2] and d2[0] ==d2[1] and d2[0] == d2[2]):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
# スペース区切りの整数の入力
b, c = map(int, input().split())
# 文字列の入力
s = input()
# 出力
print("{} {}".format(a+b+c, s))

Fixed submission:
a = input()

if a.isupper():
    print('A')
else:
    print('a')
Buggy python submission (verdict: Runtime Error):
k = int(input())
a, b = map(int, input().split())

if b%k == 0: 
  print(“OK”)
else:
  tmp = b//k
  tmp *= k
  if tmp>=a:
    print("OK")
  else:
    print("NG")

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

if b%k == 0: 
  print("OK")
else:
  tmp = b//k
  tmp *= k
  if tmp>=a:
    print("OK")
  else:
    print("NG")
Buggy python submission (verdict: Runtime Error):
a ,b = map(int,input().split())

if a <=b:print(“unsafe”)
else:print(“safe”)


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

if s>w: print('safe')
else: print('unsafe')

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

if a <=b; print(“unsafe”)
else; print(“safe”)

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

if s>w: print('safe')
else: print('unsafe')
Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, d = map(int, input().split())

while (a>0) & (c>0):
  tmp1 = c-b
  tmp2 = a-d
  if tmp1<=0: 
    print('Yes')
    break
  elif tmp2<=0: 
    print('No')
    break


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

num1 = (a-1)//d
num2 = (c-1)//b

print('Yes' if num1>=num2 else'No')

Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())

while (a>0) & (c>0):
  tmp1 = c-b
  tmp2 = a-d
  if temp1<=0: print('Yes')
  elif temp2<=0: print('No')

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

num1 = (a-1)//d
num2 = (c-1)//b

print('Yes' if num1>=num2 else'No')
Buggy python submission (verdict: Runtime Error):
r =int(input())
print(r*pi)

Fixed submission:
import numpy as np

r = int(input())
print(2*r*np.pi)
Buggy python submission (verdict: Runtime Error):
a, _ =map(int,input().split())
li = [x for x in input().split()]
s = sum(li)
print(a-s)

Fixed submission:
a, _ =map(int,input().split())
li = [int(x) for x in input().split()]
s = sum(li)
print(max(a-s, -1))
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int(), input().split())
print(a +' '+b+' '+c)


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

Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
print(a +' '+b+' '+c)

Fixed submission:
a, b, c = input().split()
print(c +' '+a+' '+b)
Buggy python submission (verdict: Runtime Error):
n, m = map(int,input().split())
A = list(map(int,input().split()))

lim = 1/(4*m)
A = A/sum(A)
ans = 0
for a in A:
  if a>=lim:
    ans += 1
    
if ans >= m:
  print("Yes")
else:
  print("No")


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

lim = 1/(4*m)

ans = 0
for a in A:
  a /= sum(A)
  if a>=lim:
    ans += 1
    
if ans >= m:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N = input()
S = input()

n = str.count('ABC')
print(n)

Fixed submission:
N = input()
S = input()

n = S.count('ABC')
print(n)
Buggy python submission (verdict: Runtime Error):
N = int(input())
s, t = input().split()

for i in range(N):
  print(s[i], t[i], seq = '')
  
  


Fixed submission:
N = int(input())
s, t = input().split()

new = list()
for i in range(N):
  new.append(s[i])
  new.append(t[i])
  
print(*new, sep='')

Buggy python submission (verdict: Runtime Error):
N = int(input())
s, t = map(input().split())

for i in range(N):
  print(s[i], t[i], seq = '')
  
  

Fixed submission:
N = int(input())
s, t = input().split()

new = list()
for i in range(N):
  new.append(s[i])
  new.append(t[i])
  
print(*new, sep='')
Buggy python submission (verdict: Runtime Error):
s = input()
sr = s[::-1]

ans = 0

for i in range(s//2):
  if s[i] != sr[i]:
    ans += 1
    
print(ans)

Fixed submission:
s = input()
sr = s[::-1]

ans = 0

for i in range(len(s)//2):
  if s[i] != sr[i]:
    ans += 1
    
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np

def solve(n, k, aaa, fff):
  aaa = np.sort(aaa)
  fff = np.sort(fff)[::-1]
  
  l = 0
  r = 10**12
  while l<=r:
    m = (l+r)//2
    req = np.clip(aaa - m//fff, 0, None).sum()

    if req < k:
      r = m-1
    else:
      l = m+1

  return l


N, K = map(int,input().split())
aaa = np.array(list(map(int,input().split())))
fff = np.array(list(map(int,input().split())))

print(solve(N, K, aaa, fff)


Fixed submission:
import numpy as np

def solve(n, k, aaa, fff):
  aaa = np.sort(aaa)
  fff = np.sort(fff)[::-1]
  
  l = 0
  r = 10**12
  while l<=r:
    m = (l+r)//2
    req = np.clip(aaa - m//fff, 0, None).sum()

    if req <= k:
      r = m-1
    else:
      l = m+1

  return l


N, K = map(int,input().split())
aaa = np.array(list(map(int,input().split())))
fff = np.array(list(map(int,input().split())))

print(solve(N, K, aaa, fff))

Buggy python submission (verdict: Runtime Error):
import numpy as np

def solve(n, k, aaa, fff):
  aaa = np.sort(aaa)
  fff = np.sort(fff)[::-1]
  
  l = 0
  r = 10**12
  while l<=r:
    m = (l+r)//2
    req = np.clip(aaa - m//fff, 0, Nonw).sum()

    if req < k:
      r = m-1
    else:
      l = m+1

  return l


N, K = map(int,input().split())
aaa = np.array(list(map(int,input().split())))
fff = np.array(list(map(int,input().split())))

print(solve(N, K, aaa, fff)


Fixed submission:
import numpy as np

def solve(n, k, aaa, fff):
  aaa = np.sort(aaa)
  fff = np.sort(fff)[::-1]
  
  l = 0
  r = 10**12
  while l<=r:
    m = (l+r)//2
    req = np.clip(aaa - m//fff, 0, None).sum()

    if req <= k:
      r = m-1
    else:
      l = m+1

  return l


N, K = map(int,input().split())
aaa = np.array(list(map(int,input().split())))
fff = np.array(list(map(int,input().split())))

print(solve(N, K, aaa, fff))
Buggy python submission (verdict: Runtime Error):
import bisect

N = int(input())
li = list(map(int, input().split()))
li.sort()

ans = 0
for i in range(N-1):
  k = li[i]
  for j in range(i+1, N):
    l = li[j]
    tmp = bisect_left(li, k+l)
    ans += tmp - j -1
    
    
print(ans)


Fixed submission:
import bisect

N = int(input())
A = list(map(int,input().split()))
A.sort()
ans = 0

for i in range(N-1):
  k = A[i]
  for j in range(i+1, N):
    l = A[j]
    res = bisect.bisect_left(A, k+l)
    ans += res-j-1
    
print(ans)

Buggy python submission (verdict: Runtime Error):
import bisect

N = int(input())
li = list(map(int, input().split()))

ans = 0
for i in range(N-1):
  k = li[i]
  for j in range(i+1, N):
    l = li[j]
    tmp = bisect_left(li, k+l)
    ans += tmp - i -1
    
    
print(ans)

Fixed submission:
import bisect

N = int(input())
A = list(map(int,input().split()))
A.sort()
ans = 0

for i in range(N-1):
  k = A[i]
  for j in range(i+1, N):
    l = A[j]
    res = bisect.bisect_left(A, k+l)
    ans += res-j-1
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N = int(input())
A = list(map(int,input().split()))

res = list(itertools.combinations(A, 3))

ans = 0
for i in range(len(res)):
  if max(res[i])*2 < sum(res[i]):
    ans += 1
    
    
print(ans)

Fixed submission:
import bisect

N = int(input())
A = list(map(int,input().split()))
A.sort()
ans = 0

for i in range(N-1):
  k = A[i]
  for j in range(i+1, N):
    l = A[j]
    res = bisect.bisect_left(A, k+l)
    ans += res-j-1
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
stu = list(map(int,input().split()))

ans = [0 for _ in range(N)]

for i in range(N):
  ind = stu.index(min(stu))
  ans[i]=ind+1
  stu[ind] = N+1
  
print(*ans)

Fixed submission:
N = int(input())
stu = list(map(int,input().split()))

ans = [0 for _ in range(N)]

for i in range(N):
  ind = stu[i]-1
  ans[ind]=i+1

  
print(*ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
li = list(map(int,input().split())).reverse()

dp = [0]*N

for i in range(N-1):
  if li[i+1] >= li[i]:
    dp[i+1] = dp[i]+1
  else:
    dp[i+1] = 0
    
print(max(dp))



Fixed submission:
N = int(input())
li = list(map(int,input().split()))
li.reverse()

dp = [0]*N

for i in range(N-1):
  if li[i+1] >= li[i]:
    dp[i+1] = dp[i]+1
  else:
    dp[i+1] = 0
    
print(max(dp))
Buggy python submission (verdict: Runtime Error):
M,D = map(int,input().split())
ans =0

if D <22:
  print("0")
  sys.exit()

for i in range(1,M+1):
  for r in range(22,D+1):
    d_tens,d_ones = divmod(r,10)
    
    if d_ones == 0 or d_ones == 1:
      continue
    elif i == d_tens*d_ones:
      ans+=1
    else:
      continue
      
print(ans)


Fixed submission:
M,D = map(int,input().split())
ans = 0

for i in range(1,M+1):
  for j in range(10,D+1):
    a,b = divmod(j,10)
    
    if a>=2 and b>=2:
      if i ==a*b:
        ans += 1
       
      
      
print(ans)

Buggy python submission (verdict: Runtime Error):
M,D = map(int,input().split())
ans =0

if D <10:
  print("0")
  sys.exit()

for i in range(1,M+1):
  for r in range(10,D+1):
    d_tens,d_ones = divmod(r,10)
    
    if d_ones == 0 or d_ones == 1:
      continue
    elif i == d_tens*d_ones:
      ans+=1
    else:
      continue
      
print(ans)

Fixed submission:
M,D = map(int,input().split())
ans = 0

for i in range(1,M+1):
  for j in range(10,D+1):
    a,b = divmod(j,10)
    
    if a>=2 and b>=2:
      if i ==a*b:
        ans += 1
       
      
      
print(ans)

Buggy python submission (verdict: Runtime Error):
M,D = map(int,input().split())
ans =0

if D <10:
  print("0")
  break

for i in range(1,M+1):
  for r in range(10,D+1):
    d_tens,d_ones = divmod(r,10)
    
    if i == d_tens*d_ones:
      ans+=1
    else:
      continue
      
print(ans)

Fixed submission:
M,D = map(int,input().split())
ans = 0

for i in range(1,M+1):
  for j in range(10,D+1):
    a,b = divmod(j,10)
    
    if a>=2 and b>=2:
      if i ==a*b:
        ans += 1
       
      
      
print(ans)
Buggy python submission (verdict: Runtime Error):
K , X = map (int , input().split())

min = X - K + 1
max = X + K 

for i in range(min , max ):
    print("{} "). format(i)

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

min = X - K + 1
max = X + K 

for i in range(min , max ):
    print("{} ". format(i))

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

min = X - K + 1
max = X + K - 1

for i in range(min , max + 1):
    print("{} "). format(i)

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

min = X - K + 1
max = X + K 

for i in range(min , max ):
    print("{} ". format(i))
Buggy python submission (verdict: Time Limit Exceeded):
N= int(input())
li = [list(input()) for i in range(N)]

ans= 0
for i in range (N):
  li[i].sort()
  
for i in range(N-1):
  for j in range(i+1,N):
    if li[i] == li[j]:
      ans+=1
    else: continue
      
print(ans)

Fixed submission:

def inp():
  return list(input())

N = int(input())
res = {}

for i in range(N):
  s = str(sorted(inp()))
  
  if s in res:
    res[s] += 1
  else:
    res[s] = 1
    

ans = 0
for num in res.values():
  ans += num*(num-1)/2
  
print(int(ans))
Buggy python submission (verdict: Runtime Error):
N = int(input())
li = list(map(int,input().split()))

for i in range(N-1):
  if li[i+1] >= li[i]+2:
    print("No")
    sys.exit()
    
  elif li[i+1] == li[i]+1:
    li[i+1] = li[i]
    
  else: continue
    
print("Yes")

Fixed submission:
import sys

N = int(input())
li = list(map(int,input().split()))
li.reverse()

for i in range(N-1):
  if li[i+1] >= li[i]+2:
    print("No")
    sys.exit()
    
  elif li[i+1] == li[i]+1:
    li[i+1] = li[i]
    
  else: continue
    
print("Yes")
Buggy python submission (verdict: Runtime Error):
N=int(input())
num = list(map(int,input().split()))

num_sort = num.sorted()
ans = 0

for i in range(N):
  if num[i] == num_sorted[i]:
    continue
  else:
    ans += 1
    
if ans <= 2:
  print("YES")
else:
  print("NO")

Fixed submission:
N=int(input())
num = list(map(int,input().split()))

num_sort = sorted(num)
ans = 0

for i in range(N):
  if num[i] == num_sort[i]:
    continue
  else:
    ans += 1
    
if ans <= 2:
  print("YES")
else:
  print("NO")

Buggy python submission (verdict: Runtime Error):
N = int(input())
 
p = list()
 
p = map(int, input().split())
 
k = 0
 
for i in range(0, len(p)-1 ):
  if (p[i] > p[ i + 1 ]):
    k += 1
    
    
if ( k <= 1 ):
  print("YES")
else:
  print("NO")
  

Fixed submission:
N=int(input())
num = list(map(int,input().split()))

num_sort = sorted(num)
ans = 0

for i in range(N):
  if num[i] == num_sort[i]:
    continue
  else:
    ans += 1
    
if ans <= 2:
  print("YES")
else:
  print("NO")

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

p = list()

p = map(int, input().split())

k = 0

for i,number in enumerate(p):
  if (number > p[ i + 1 ]):
    k += 1

if ( k <= 1 ):
  print("YES")
else:
  print("NO")
  

Fixed submission:
N=int(input())
num = list(map(int,input().split()))

num_sort = sorted(num)
ans = 0

for i in range(N):
  if num[i] == num_sort[i]:
    continue
  else:
    ans += 1
    
if ans <= 2:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
N = int(input())
li = list(map(int,input().split()))

lis = sorted(li)
for i in range(N):
  if lis[-1] == li[i]:
    print(lis[-2])
  else: print(lis[-1])
    


Fixed submission:
N = int(input())
li = [int(input()) for _ in range(N)]

lis = sorted(li)
for i in range(N):
  if lis[-1] == li[i]:
    print(lis[-2])
  else: print(lis[-1])

Buggy python submission (verdict: Runtime Error):
N = int(input())
li = list(map(int,inpur().split()))

lis = sorted(li)
for i in range(N):
  if lis[-1] == li[i]:
    print(lis[-2])
  else: print(lis[-1])
    


Fixed submission:
N = int(input())
li = [int(input()) for _ in range(N)]

lis = sorted(li)
for i in range(N):
  if lis[-1] == li[i]:
    print(lis[-2])
  else: print(lis[-1])

Buggy python submission (verdict: Runtime Error):
N = int(input())
li = list(map(int,inpur().split()))

lis = li.sorted()
for i in range(N):
  if lis[-1] == li[i]:
    print(lis[-2])
  else: print(lis[-1])
    

Fixed submission:
N = int(input())
li = [int(input()) for _ in range(N)]

lis = sorted(li)
for i in range(N):
  if lis[-1] == li[i]:
    print(lis[-2])
  else: print(lis[-1])

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

number = list()

for i in range( N - 1 ):
  number.append(int(input()))

for i in range( N - 1 ):
  del number[i]
  print( max( number ) )
  

Fixed submission:
N = int(input())
li = [int(input()) for _ in range(N)]

lis = sorted(li)
for i in range(N):
  if lis[-1] == li[i]:
    print(lis[-2])
  else: print(lis[-1])
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = [int(input()) for _ in range(M)]

dp = [0]*(N+1)
dp[0]=1
if 1 not in a:dp[1] = 1

for i in range(2,N+1):
  if i in a: continue
  dp[i] =dp[i-1]+dp[i-2]
  print(dp)
print(dp[-1])


Fixed submission:
N,M = map(int,input().split())
a = set([int(input()) for _ in range(M)])
mod = 10**9+7
dp=[0]*(N+1)
dp[0]=1


for i in range(N):
  if i+1 not in a:
    dp[i+1]+=dp[i]
    dp[i+1] %= mod
  if i+2 <= N and i+2 not in a:
    dp[i+2]+=dp[i]
    dp[i+2]%=mod
  
print(dp[-1])

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = [int(input()) for _ in range(M)]

dp = [0]*(N+1)
if 1 in a: continue
else: dp[1]=1

for i in range(1,N):
  if i in a: continue
  dp[i+1] = dp[i]+dp[i-1]
  
print(dp[-1])

Fixed submission:
N,M = map(int,input().split())
a = set([int(input()) for _ in range(M)])
mod = 10**9+7
dp=[0]*(N+1)
dp[0]=1


for i in range(N):
  if i+1 not in a:
    dp[i+1]+=dp[i]
    dp[i+1] %= mod
  if i+2 <= N and i+2 not in a:
    dp[i+2]+=dp[i]
    dp[i+2]%=mod
  
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
A,P = map(int,input.split())

P += 3*A
print(P//2)

Fixed submission:
A,P = map(int,input().split())

P += 3*A
print(P//2)
Buggy python submission (verdict: Runtime Error):
n = int(input())
G = [[] for _ in range(n)]
for i in range(n-1):
  uvw = list(map(int, input().split()))
  u = uvw[0]-1
  v = uvw[1]-1
  w = uvw[2]
  G[u].append([v, w])
  G[v].append([u, w])
  
color = [-1]*n
def dfs(G, v, cur = 0):
  if color[v] == -1:
    
    color[v] = cur
    for next_v, w in G[v]:
     
      if color[next_v]==-1:
        if (w % 2 != 0):
          dfs(G, next_v, 1-cur)
        if (w% 2 == 0):
          dfs(G, next_v, cur)
        continue
      


        

for v in range(n):
  if color[v] != -1:
    continue
  else:
    dfs(G, v)


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

Fixed submission:
import sys
sys.setrecursionlimit(10**7)

n = int(input())
G = [[] for _ in range(n)]
for i in range(n-1):
  uvw = list(map(int, input().split()))
  u = uvw[0]-1
  v = uvw[1]-1
  w = uvw[2]
  G[u].append([v, w])
  G[v].append([u, w])
  
color = [-1]*n
def dfs(G, v, cur = 0):
  if color[v] == -1:
    
    color[v] = cur
    for next_v, w in G[v]:
     
      if color[next_v]==-1:
        if (w % 2 != 0):
          dfs(G, next_v, 1-cur)
        if (w% 2 == 0):
          dfs(G, next_v, cur)
        continue
      


        

for v in range(n):
  if color[v] != -1:
    continue
  else:
    dfs(G, v)


print(*color, sep='\n')
Buggy python submission (verdict: Runtime Error):
N, M, K =map(int,input().aplit())
bases = list(map(int,input().split()))
ans=0

for i in range(M):
  A = list(map(int,input().split()))
  tmp=0
  for j in range(3):
    tmp+= bases[j]*A[j]
  if tmp>0:
    ans+=1
    
print(ans)


Fixed submission:
N, M, K =map(int,input().split())
bases = list(map(int,input().split()))
ans=0

for i in range(N):
  a= list(map(int,input().split()))
  tmp=0
  for j in range(M):
    tmp+= bases[j]*a[j]
  
  if tmp+K>0:
    ans+=1
    
print(ans)

Buggy python submission (verdict: Runtime Error):
N, M, K =map(int,input().aplit())
bases = list(map(int,input()))
ans=0

for i in range(M):
  A = list(map(int,input().split()))
  tmp=0
  for j in range(3):
    tmp+= bases[j]*A[j]
  if tmp>0:
    ans+=1
    
print(ans)


Fixed submission:
N, M, K =map(int,input().split())
bases = list(map(int,input().split()))
ans=0

for i in range(N):
  a= list(map(int,input().split()))
  tmp=0
  for j in range(M):
    tmp+= bases[j]*a[j]
  
  if tmp+K>0:
    ans+=1
    
print(ans)

Buggy python submission (verdict: Runtime Error):
N, M, K =map(int().input().aplit())
bases = list(map(int,input()))
ans=0

for i in range(M):
  A = list(map(int,input().split()))
  tmp=0
  for j in range(3):
    tmp+= bases[j]*A[j]
  if tmp>0:
    ans+=1
    
print(ans)

Fixed submission:
N, M, K =map(int,input().split())
bases = list(map(int,input().split()))
ans=0

for i in range(N):
  a= list(map(int,input().split()))
  tmp=0
  for j in range(M):
    tmp+= bases[j]*a[j]
  
  if tmp+K>0:
    ans+=1
    
print(ans)
Buggy python submission (verdict: Runtime Error):
A,B,K = map(int,input().split())
li = []

for i in range(1,min(A,B)):
  if A % i == 0 and B % i == 0:
    li.append(i)
    
print(li[K-1])

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

for i in range(1,min(A,B)+1):
  if A % i == 0 and B % i == 0:
    li.append(i)

print(li[len(li)-K])
Buggy python submission (verdict: Runtime Error):
N = int(input())

cost = [int(input()) for _ in range(N)]

Sum = list(0,abs(cost[0]-cost[1]))

for i in range(2,N):
  Sum[i] = min(Sum[i-1] + abs(cost[i]-cost[i-1]), Sum[i-2] + abs(Sum[i-2] - Sum[i]))
  
print(Sum[N-1])

Fixed submission:
N = int(input())

cost = [int(i) for i in input().split()]

dp = [0]*N

dp[1] = abs(cost[0] - cost[1])

for i in range(2,N):
  dp[i] = min (dp[i-1] + abs(cost[i] - cost[i-1]), dp[i-2] + abs(cost[i-2] - cost[i]))
  
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
import numpy as np

N,K = map(int, input().split())
h = np.array(list(map(int,input().split())))

dp = np.zeros(N, dtype = int)

for i in range(1,N):
  s = max(i-k,0)
  dp[i] = np.min(dp[s:i]+ np.abs(h[s:i] - h[i]))
  
print(dp[-1])
    


Fixed submission:
import numpy as np

N,K = map(int, input().split())
h = np.array(list(map(int,input().split())))

dp = np.zeros(N, dtype = int)

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

Buggy python submission (verdict: Runtime Error):
import numpy as np

N,K = map(int, input().split())
h = np.array(list(map(int,input().split())))

dp = np.zeros(N, dtype = int)

for i in range(1,N):
  s = max(i-k,0)
  dp[i] = np.min(dp[s:i]+ np.abs(h[s:i] - h[i]))
  
print(dp[-1])
    

Fixed submission:
import numpy as np

N,K = map(int, input().split())
h = np.array(list(map(int,input().split())))

dp = np.zeros(N, dtype = int)

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

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
h = list(map(int,input().split()))

dp = [float('inf') for i in range(N-1)]

for i in range(N-1):
  for j in range(1,K+1):
    if i+j>N: continue
    dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]))
    
print(dp[-1])

Fixed submission:
import numpy as np

N,K = map(int, input().split())
h = np.array(list(map(int,input().split())))

dp = np.zeros(N, dtype = int)

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

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
h = list(map(int,input().split()))

dp = [[] for i in range(N)]

for i in range(N-1):
  for j in range(1,K+1):
    dp[i+j] = min(dp[i] + abs(h[i] - h[i+j]), dp[i+j])
    
print(dp[-1])

Fixed submission:
import numpy as np

N,K = map(int, input().split())
h = np.array(list(map(int,input().split())))

dp = np.zeros(N, dtype = int)

for i in range(1,N):
  s = max(i-K,0)
  dp[i] = np.min(dp[s:i]+ np.abs(h[s:i] - h[i]))
  
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
N = int(input())
li = [list(map(int,input().split())) for _ in range(N)]

dp = [0,0,0]*N
dp[0] = li[0]

for i in range(N-1):
  for j in range(3):
    for k in range(3):
      if j == k: continue
      dp[i+1][j] = dp[i][k] + li[i+1][j]
print(max(dp[-1]))

Fixed submission:
N = int(input())
li = [list(map(int,input().split())) for _ in range(N)]

dp = [[0,0,0] for _ in range(N)]
dp[0] = li[0]

for i in range(N-1):
  for j in range(3):
    for k in range(3):
      if j == k: continue
      dp[i+1][j] = max(dp[i+1][j], dp[i][k] + li[i+1][j])
print(max(dp[-1]))

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = B = C = 0

for i in range(N):
  a,b,c = map(int,input())
  A,B,C = max(B + a,C+a),max(A+b,C+b),max(A+c,B+c)
 
print(max(A,B,C))

Fixed submission:
N = int(input())
li = [list(map(int,input().split())) for _ in range(N)]

dp = [[0,0,0] for _ in range(N)]
dp[0] = li[0]

for i in range(N-1):
  for j in range(3):
    for k in range(3):
      if j == k: continue
      dp[i+1][j] = max(dp[i+1][j], dp[i][k] + li[i+1][j])
print(max(dp[-1]))
Buggy python submission (verdict: Runtime Error):
N,W = map(int,input().split())
li = [list(map(int,input().split())) for _ in range(N)]

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

for i in range(N):
  for j in range(W+1):
    if j < li[i][0]: continue
    
    dp[i+1][j] = max(dp[i+1][j], dp[i][j-li[i][0]] + li[i+1][1])
    
print(dp[-1][-1])

Fixed submission:
import numpy as np

N,W = map(int,input().split())

item = [list(map(int,input().split())) for _ in range(N)]

val = np.zeros(W+1,dtype = int)

for i in range(N):
  item_weight = item[i][0]
  val[item_weight :] = np.maximum(val[item_weight :], val[:-item_weight] + item[i][1])
  
print(max(val))