Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02678 (python)

Fixed submission:
import sys
from collections import deque
INF = float('inf')

input = sys.stdin.readline
n,m = map(int, input().split())
AB = [tuple(map(int,input().split())) for i in range(m)]
G = [[] for _ in range(n)]

for a, b in AB:
    a , b = a-1 , b-1
    G[a].append(b)
    G[b].append(a)

q = deque([0])
dist = [INF]*n
dist[0] = 0
back = [-1] * n
while q:
    v = q.popleft()
    for to in G[v]:
        if dist[v] + 1 >=dist[to]:continue
        dist[to] = dist[v]
        back[to] = v+1
        q.append(to)
print('Yes')
print(*back[1:],sep='\n')

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
from heapq import heappop, heappush


class Graph(object):
    """
    隣接リストによる有向グラフ
    """

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, src, dst, weight=1):
        self.graph[src].append((dst, weight))

    def get_nodes(self):
        return self.graph.keys()


class Dijkstra(object):
    """
    ダイクストラ法（二分ヒープ）による最短経路探索
    計算量: O((E+V)logV)
    """

    def __init__(self, graph, start):
        self.g = graph.graph

        # startノードからの最短距離
        # startノードは0, それ以外は無限大で初期化
        self.dist = defaultdict(lambda: float('inf'))
        self.dist[start] = 0

        # 最短経路での1つ前のノード
        self.prev = defaultdict(lambda: None)

        # startノードをキューに入れる
        self.Q = []
        heappush(self.Q, (self.dist[start], start))

        while self.Q:
            # 優先度（距離）が最小であるキューを取り出す
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:
                continue
            for v, weight in self.g[u]:
                alt = dist_u + weight
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(self.Q, (alt, v))

    def shortest_distance(self, goal):
        """
        startノードからgoalノードまでの最短距離
        """
        return self.dist[goal]

    def shortest_path(self, goal):
        """
        startノードからgoalノードまでの最短経路
        """
        path = []
        node = goal
        while node is not None:
            path.append(node)
            node = self.prev[node]
        return path[::-1]

n, m = map(int,input().split())
g =Graph()
for _ in range(m):
    x, y = map(int,input().split())
    g.add_edge(x-1,y-1,1)
    g.add_edge(y-1,x-1,1)
d = Dijkstra(g,0)

ans= [float("inf") for i in range(n)]
for i in range(m):
    x = d.shortest_distance(i)
    ans[i] = x
if float("inf") in ans:
    print('No')
else:
    print('Yes')
    for i in range(1,m):
        print(ans[i])
Problem p02690 (python)

Fixed submission:
import math
x = int(input())
y = []
for i in range(1000):
    y.append(i**5)
for j in range(1000):
    for k in range(j,1000):
        if y[k]+ y[j] == x:
            a = k
            b = -j 
        if y[k] - y [j] == x:
            a = k
            b = j
            
print(a,b)

Buggy submission (verdict: Runtime Error):
import math
x = int(input())
y = []
for i in range(1000):
    y.append(i**5)
for j in range(1000):
    for k in range(j,1000):
        if y[k]+ y[j] == x:
            a = k
            b = j    
                    
print(a,-b)

Buggy submission (verdict: Runtime Error):
import math
x = int(input())
y = []
for i in range(70):
    y.append(i**5)
for j in range(70):
    for k in range(j,70):
        if y[k]+ y[j] ==x:
            a = k
            b = j            
print(a,-b)

Buggy submission (verdict: Runtime Error):
import math
x = int(input())
y = []
for i in range(70):
    y.append(i**5)
    y.append(-i**5)
for j in range(130):
    for k in range(130):
        if y[k]-y[j] ==x:
            a = (k )//2
            b = (j )//2
             
print(a,-b)

Buggy submission (verdict: Runtime Error):
import math
x = int(input())
y = []
for i in range(70):
    y.append(i**5)
    y.append(-i**5)
for j in range(140):
    for k in range(140):
        if y[k]-y[j] ==x:
            a = (k )//2
            b = (j )//2
             
print(a,-b)
Problem p02696 (python)

Fixed submission:
a, b, n = map(int,input().split())
ans = 0
x = min(n , b-1)
print(x*a //b)

Buggy submission (verdict: Runtime Error):
import math
a, b, n = map(int,input().split())
ans = 0

for i in range(0,B+1):
    s = math.floor(a * i / b)
    t = math.floor (i/b)
    ans = max(ans,s - a*t) 

print(ans)
Problem p02786 (python)

Fixed submission:
h = int(input())
n = 0
l = []
ans = 1
for i in range(42):
    l.append(2**i)

for i in range(1,41):
    if l[i]<=h<l[i+1]:
        ans=sum(l[:i+1])

print(ans)

Buggy submission (verdict: Runtime Error):
h = int(input())
n = 0
l = []
for i in range(42):
    l.append(2**i)

for i in range(1,41):
    if l[i]<=h<l[i+1]:
        ans=sum(l[:i+1])

print(ans)
Problem p02911 (python)

Fixed submission:
n , k , q = map(int,input().split())
a = [int(input()) for x in range(q)]
P = [k-q]*(n+1)
for x in a:
    P[x] +=1

ans = '\n'.join('No'if x <=0 else 'Yes' for x in P[1:])
print(ans)

Buggy submission (verdict: Runtime Error):
n , k , q = map(int,input().split())
a = [int(input()) for x in range(q)]
P = [k-q]*n
for x in a:
    P[x] +=1

ans = '\n'.join('No'if x <=0 else 'Yes' for x in P[1:])
print(ans)
Problem p02947 (python)

Fixed submission:
from collections import defaultdict

n = int(input())
dct = defaultdict(int)

for i in range(n):
    s = input()
    sorted_s = "".join(sorted(s))
    dct[sorted_s] += 1

ans = 0
for a, b in dct.items():
    ans += b *(b-1)//2

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict

n = int(input())
dct = defaultdict(int)

for i in range(n):
    s = input()
    sorted_s = ''.join(sorted(s))
    dict[sorted_s] += 1

ans = 0
for a, b in dct.items():
    ans += b *(b-1)//2

print(ans)
Problem p03000 (python)

Fixed submission:
n , x = map(int,input().split())
L =list(map(int,input().split()))
ans = 1
D = [0]*(n+2)
for i in range(2,n+2):
    D[i] = D[i-1] + L[i-2]
    if D[i] <=x:
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n , x = map(int,input().split())
L =list(map(int,input().split()))
ans = 1
D = [0]*(n+1)
for i in range(2,n+2):
    D[i] = D[i-1] + L[i-2]
    if D[i] <=x:
        ans+=1
print(ans)
Problem p03031 (python)

Fixed submission:
import itertools
n , m = map(int,input().split())
sw = [[] for _ in range(m)]
for i in range(m):
    sw[i] = list(map(int,input().split()[1::]))
p = [int(x) for x in input().split()]
ans = 0

for tpl in itertools.product([0,1],repeat = n):
    bl = True
    for i in range(m):
        s = sum(tpl[s-1] for s in sw[i])
        if (s-p[i])%2 != 0:
            bl = False
            break
    if bl:
        ans +=1
print(ans)

Buggy submission (verdict: Runtime Error):
import intertools

n , m = map(int,input().split())
sw = [[] for _ in range(m)]
for i in range(m):
    sw[i] = list(map(int,input().split()[1::]))

ans = 0

for tpl in intertools.product([0,1],repeat = n):
    bl = True
    for i in range(m):
        s = sum(tpl[s-1] for s in sw[i])
        if (s-p[i])%2 != 0:
            bl = False
            break
    if bl:
        ans +=1
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int,input().split())
sw =[tuple(map(int,input().split())) for i in range(n)]
p = list(map(int,input().split()))

ans = 0
for b in range(1<<n):
    for i in range(m):
        c = 0
        for s in sw[i][1:]:
            if b &(1<<(s-1)):
                c += 1
        if c % 2 != p[i]:break
    else:
        ans +=1
print(ans)
Problem p03059 (python)

Fixed submission:
a, b, t=map(int,input().split())
print((t//a)*b)

Buggy submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main(){
  int a, b, t;
  cin >> a >> b >> t;
  cout << (t / a) * b << endl;
}
Problem p03109 (python)

Fixed submission:
S = input()
YMD = S.split('/')
MD = int(''.join(YMD[1:]))

ans = 'Heisei' if MD <= 430 else 'TBD'
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
YMD = S/split('/')
MD = int(''.join(YMD[1:]))

ans = 'Heisei' if MD <= 430 else 'TBD'
print(ans)
Problem p03110 (python)

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

Buggy submission (verdict: Runtime Error):
n = int(input())
li = [input().split() for i in range(n)]
ans = 0
for a,b in lis:
    if b =='JPY':
        ans += float(a)
    else:
        ans += float(a)*380000
print(ans)
Problem p03147 (python)

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

c = 0
i = 0

while sum(h) > 0 :
    if h[i]> 0 :
        j = i
        c = c + 1 
        while j < n and h[j] > 0 :
            h[j] = h[j] - 1
            j = j + 1
    else:
        i = i + 1

print(c)

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

c = 0
i = 0

while sum(h) > 0 :
    if h[i]> 0 :
        j = i
        c = c + 1 
        while j < n and h[j] > 0 :
            h[j] = h[j] - 1
            j = j + 1
        else:
            i = i + 1

print(c)
Problem p03220 (python)

Fixed submission:
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
ans = []
for i in range(n):
     ans.append(abs(a-(t-h[i]*6/1000)))
print(ans.index(min(ans))+1)

Buggy submission (verdict: Runtime Error):
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
ans = []
for i in range(n):
     ans.append(abs(a-(t-h[i]*6/1000))
print(ans.index(min(ans))+1)
Problem p03238 (python)

Fixed submission:
n = int(input())
if n ==1:
    print('Hello World')
else:
    a = int(input())
    b = int(input())
    print(a+b)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = int(input())
b = int(input())
if n ==1:
    print('Hello World')
if n ==2:
    print(a+b)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = int(input())
b = int(input())
if n ==1:
    print('Hello World')
if n ==2:
    print(a+b)
Problem p03262 (python)

Fixed submission:
import fractions
n , x = map(int,input().split())
X = list(map(int,input().split()))
Y =[]
for i in range(n):
    Y.append(abs(X[i]-x))
ans = Y[0]
for i in range(n):
    ans = fractions.gcd(ans, Y[i])
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n , x = map(int,input().split())
X = list(map(int,input().split()))
Y =[]
for i in range(n):
    Y.append(abs(X[i]-x))
ans = Y[0]
for i in range(n):
    ans = math.gcd(ans, Y[i])
print(ans)
Problem p03273 (python)

Fixed submission:
h , w = map(int,input().split())
a = [''] * h 
for i in range(h):
    a[i] = input()

row = [False]*h
col = [False]*w

for i in range(h):
    for j  in range(w):
        if a[i][j] =='#':
            row[i] = True
            col[j] = True

for i  in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j],end='')
        print()

Buggy submission (verdict: Runtime Error):
h , w = map(int,input().split())
a = [''] * h 
for i in range(n):
    a[i] = input()

row = [False]*h
col = [False]*w

for i in range(h):
    for j  in range(w):
        if a[i][j] =='#':
            row[i] = True
            col[j] = True

for i  in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j],end='')
        print()
Problem p03323 (python)

Fixed submission:
a ,b = map(int,input().split())
if a <= 8 and b <= 8:
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
a ,b = map(int,input().split())
if a =< 8 and b=<8:
    print("Yay")
else:
    print(":(")
Problem p03352 (python)

Fixed submission:
n = int(input())
ans =[]
for i in range(1,n//2+2):
     for j in range(2,10):
          if i**j <= n:
               ans.append(i**j)
print(max(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
ans =[]
for i in range(1,n//2+2):
     for j in range(2,10):
          if i**j <= n:
print(max(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
ans =[]
for i in range(1,n//2+1):
     for j in range(2,10):
          if i**j <= n:
               ans.append(i**j)

print(max(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
ans =[]
for i in range(1,n//2+1):
     for j in range(10):
          if i**j < n:
               ans.append(i**j)

print(max(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
ans =[]
for i in range(1,n//2):
     for j in range(1,10):
          if i**j < n:
               ans.append(i**j)

print(max(ans))
Problem p03471 (python)

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

for i in range(n+1):
   for j in range(n-i+1):
       if y-10000*i-5000*j == 1000*(n-i-j):
           print(i,j,n-i-j)
           exit()
print(-1,-1,-1)

Buggy submission (verdict: Runtime Error):
n,y = map(int, input(),split())

for i in range(n+1):
   for j in range(n-i+1):
       if k-10000*i-5000*j == 1000*(n-i-j):
           print(i,j,n-i-j)
           exit()
print(-1,-1,-1)
Problem p03486 (python)

Fixed submission:
s = input()
t = input()

S = ''.join(sorted(list(s)))
T = ''.join(sorted(list(t),reverse=True))

print('Yes' if S<T else 'No')

Buggy submission (verdict: Runtime Error):
s = input()
t = input()

S = ''join(sorted(list(s)))
T = ''join(sorted(list(t),reverse=True))

print('Yes' if S<T else 'No')
Problem p03632 (python)

Fixed submission:
a , b , c, d=map(int,input().split())
if b<=c and a<= c:
    print(0)
elif d >= b and c <= b and a <= c:
    print(b-c)
elif d >= b and a>=c:
    print(b-a)
elif b >=d and c>=a:
    print(d-c)
elif c <= a and d <=a:
    print(0) 
else:
    print(d-a)

Buggy submission (verdict: Runtime Error):
if b<=c and a<= d:
    print(0)
elif d >= a and c <= b and a >= c and b <= d:
    print(b-c)
elif d >= b and a>=c:
    print(b-a)
elif b >=d and c>=a:
    print(d-c)
elif c <= a and d <=a:
    print(0) 
else:
    print(d-a)
Problem p03633 (python)

Fixed submission:
n = int(input())

def gcd(a,b):
  while b:
    a,b = b,a%b
  return a
  
ans = 1
for _ in range(n):
    x = int(input())
    ans *=  x//gcd(ans,x)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
ans = 1
for _ in range(n):
    x = int(input())
    ans *=  x//math.gcd(ans,x)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
ans = 1
for _ in range(n):
    x = int(input())
    ans *=  x//math.gcd(ans,x)
print(ans)
Problem p03712 (python)

Fixed submission:
h , w = map(int,input().split())
lis = []
for i in range(h):
    lis.append(input())
print('#'*(w+2))
for i in range(h):
    print('#'+lis[i]+'#')
print('#'*(w+2))

Buggy submission (verdict: Runtime Error):
h , w = map(int,input().split())
lis = []
for i in range(w):
    lis.append(input())
print('#'*(w+2))
for i in range(h):
    print('#'+lis[i]+'#')
print('#'*(w+2))
Problem p03773 (python)

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

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a + b < 24:
    print(a + b)
    else:
    print(a + b -24)
Problem p03779 (python)

Fixed submission:
from math import ceil
x = int(input())
ans = ceil(((1+8*x)**.5 -1)/2)
print(ans)

Buggy submission (verdict: Runtime Error):
x = int(input())
for i in range(x):
    if i*(i+1)/2 >= x:
        ans =i
        break 
    else:
        continue
print(ans)

Buggy submission (verdict: Runtime Error):
x = int(input())
for i in range(x):
    if i*(i+1)/2 > x:
        ans =i
        break 
    else:
        continue
print(ans)

Buggy submission (verdict: Runtime Error):
# t を前から試してｘ以下か判定する
x = int(input())
for i in range(x):
    if i*(i+1)/2 > x:
        ans =i
        break 
print(ans)
Problem p03943 (python)

Fixed submission:
a,b,c = map(int,input().split())
if c == a+b or b == a+c or a == b+c:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a, b, c = map(int,input(),split())
if c == a + b:
    print("Yes")
if b == a + c:
    print("Yes")
if a == b + c:
    print("Yes")
else:
    print("No")
Problem p03962 (python)

Fixed submission:
mylist = input().split()
print(len(set(mylist)))

Buggy submission (verdict: Runtime Error):
N, K = map(int,input().split())
print(K*(K-1)**(N-1))

Buggy submission (verdict: Runtime Error):
N, K = map(int,input().split())
print(K * ((K-1)**(N-1)))

Buggy submission (verdict: Runtime Error):
N, K = map(int,input().split())
print(int(K * ((K-1)**(N-1))))

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
print(int(K * ((K-1) ** (N-1))))

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
print(K * ((K-1) ** (N-1)))
Problem p03963 (python)

Fixed submission:
N, K = map(int,input().split())
print(K*(K-1)**(N-1))

Buggy submission (verdict: Runtime Error):
N, K = [int(input()) for _ in range(2)]
A =int((K - 1) ** N)
print(int(A * K))
Problem p03998 (python)

Fixed submission:
S = dict()
S['a'] = list(input())[::-1]
S['b'] = list(input())[::-1]
S['c'] = list(input())[::-1]

player = 'a'

while S[player]:
    player = S[player].pop() 

ans = player.upper()
print(ans)

Buggy submission (verdict: Runtime Error):
S = dict()
S['A'] = list(input())[::-1]
S['B'] = list(input())[::-1]
S['C'] = list(input())[::-1]

print(S)
player = 'a'

while S[player]:
    player = S[player].pop() 

ans = player.upper()
print(ans)
Problem p04011 (python)

Fixed submission:
n = int(input())
k = int(input())
x = int(input())
y = int(input())
if n <= k:
    answer = n * x
else: 
    answer = (n-k) * y + k*x

print(answer)

Buggy submission (verdict: Runtime Error):
n = int(input())
k = int(input())
x = int(input())
y = int(input())
if n =< k:
    answer = k * x
else: 
    answer = (n-k) * y + int(answer)

print(answer)

Buggy submission (verdict: Runtime Error):
n = int(input())
k = int(input())
x = int(input())
y = int(input())
if n =< K:
    answer = k * x
    else answer = k * y:
print answer
Problem p04029 (python)

Fixed submission:
m = int(input())
result = 0
for i in range(1, m+1):
    result += i
print(result)

Buggy submission (verdict: Runtime Error):
x = 0
y = 1
n = int(input())
if y <= n:
    for y in range(1,n+1):
    x = x + y
    print(x)
    y = y + 1

Buggy submission (verdict: Runtime Error):
N = int(input())
result = 0
for i in range(1, N+1)
    result += i
print(result)
Problem p02612 (python)

Fixed submission:
import math
price = int(input())
 
comma_price = math.ceil(price / 1000)
comma_price *= 1000
 
print(comma_price - price)

Buggy submission (verdict: Runtime Error):
price = int(input())

comma_price = math.ceil(price / 1000)
comma_price *= comma_price

print(comma_price - price)
Problem p02687 (python)

Fixed submission:
N = input()
if N == "ABC" :
  print("ARC")
elif N == "ARC" :
  print("ABC")

Buggy submission (verdict: Runtime Error):
N = input()
if N = "ABC" :
  print("ARC")
elif N = "ARC" :
  print("ABC")
Problem p02882 (python)

Fixed submission:
from math import atan,degrees
a,b,x=map(int,input().split())
aab2 = a * a * b /2
if a*a*b==x:
  print(0)
elif x >= aab2:
  print(90-degrees(atan(a/(b-2 *(x-aab2)/(a*a)))))
else:
  print(90-degrees(atan((2*x/(a*b)/b))))

Buggy submission (verdict: Runtime Error):
from math import atan,degrees
a,b,x=map(int,input().split())
aab2 = a * a * b /2
if x >= aab2:
  print(90-degrees(atan(a/(b-2 *(x-aab2)/(a*a)))))
else:
  print(90-degrees(atan((2*x/(a*b)/b))))
Problem p03032 (python)

Fixed submission:
a,k=map(int,input().split())
L=list(map(int,input().split()))
ans=0

for i in range(min(k,a)+1):
  for j in range(min(k,a)-i+1):
    S=[0]+L[:i]+L[a-j:]
    S.sort()
    x=0
    while x < k-(j+i):
      if S[x]>=0:
        break
      x+=1
    ans=max(ans,sum(S)-sum(S[:x]))
    
print(ans)

Buggy submission (verdict: Runtime Error):
a,k=map(int,input().split())
L=list(map(int,input().split()))
ans=0

for i in range(min(k,n)+1):
  for j in range(min(k,n)-i+1):
    S=[0]+L[:i]+L[a-j:]
    S.sort()
    x=0
    while x < k-(j+i):
      if S[x]>=0:
        break
      x+=1
    ans=max(ans,sum(S)-sum(S[:x]))
    
print(ans)
Problem p03106 (python)

Fixed submission:
a,b,k=map(int,input().split())
print([i for i in range(1,min([a,b])+1) if a%i==0 and b%i==0][-k])

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
print([i for i in range(1,min([a,b])+1) if i%a==0 and i%b==0][-k])

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
print([i for i in range(min([a,b])) if i%a==0 and i%b==0][-k])

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
print([i for i in range(min(a,b)) if i%a==0 and i%b==0][-k])
Problem p03146 (python)

Fixed submission:
a=int(input())
s={a}
i=1
while True:
  i+=1
  if a % 2==1:
    a = a * 3 + 1
  else:
    a = a//2
    
  if a in s:
    break
  s|={a}
print(i)

Buggy submission (verdict: Runtime Error):
a=int(input())
s=set(a)
i=1
while True:
  if a % 2==1:
    a = a * 3 + 1
  else:
    a = a//2
    
  if a in s:
    break
  s|={a}
  i+=1
print(i)

Buggy submission (verdict: Runtime Error):
a=int(input())
s=set(a)
i=1
while True:
  if a % 2==1:
    a = a * 3 + 1
  else:
    a = a//2
    
  if a in s:
    break
  s|=｛a｝
  i+=1
print(i)
Problem p03149 (python)

Fixed submission:
print('YES' if sorted(input().split())==['1','4','7','9'] else 'NO')

Buggy submission (verdict: Runtime Error):
print('YES' if input().split().sort()==['1','4','7','9'])
Problem p03161 (python)

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l.append(min(l[j]+abs(b-a[j])for j in range(i-min(k,i),i)))
print(l[-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=tuple(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l+=[min(l[-j]+abs(b-a[-j])for j in range(1,min(i,k)+1))]
  if i>k:
    del a[0]
    del l[0]
print(l[-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=tuple(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l+=[min(l[-j]+abs(b-a[-j])for j in range(1,min(i,k)+1))]
  if i>=k:
    del a[0]
    del l[0]
print(l[-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=tuple(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l+=[min(l[-j]+abs(b-a[-j])for j in range(1,min(i,k)+1))]
  if i>=k:
    a.del(0)
    l.del(0)
print(l[-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=tuple(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l+=[min(l[-j]+abs(b-a[-j])for j in range(1,min(i+1,k)+1))]
print(l[-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=tuple(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l+=[min(l[-j]+abs(b-a[-j])for j in range(1,max(i,k)+1))]
print(l[-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  s=min(k,i)+1
  l+=[min(l[j]+abs(b-a[j])for j in range(s,i))]
print(l[-1])
Problem p03164 (python)

Fixed submission:
import numpy as np
IN = lambda:map(int, input().split())

n,k = IN()
dp = np.full(n*1000+1, k+1, dtype=int)
dp[0] = 0

for _ in range(n):
  w,v = IN()
  dp[v:] = np.minimum(dp[:-v]+w, dp[v:])

print(np.max(np.where(dp <= k)))

Buggy submission (verdict: Runtime Error):
import numpy as np
IN() = lambda:map(int, input().split())

n,k = IN()
dp = np.full(n*1000+1, k+1, dtype=int)
dp[0] = 0

for _ in range(n):
  w,v = IN()
  dp[v:] = np.minimum(dp[:-v]+w, dp[v:])

print(np.max(np.where(dp <= k)))