Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
a,b = map(int,input().split())
ret = 0
for i in range(a,b+1):
    ret = ret^i
print(ret)

Fixed submission:
a,b = map(int,input().split())
if a % 2 ==0:
    if (b - a + 1) % 4 == 0:
        print(0)
    if (b - a + 1) % 4 == 1:
        print(b)
    if (b - a + 1) % 4 == 2:
        print(b ^ (b -1))
    if (b - a + 1) % 4 == 3:
        print(b ^ (b -1) ^ (b-2))
else :
    if (b - a + 1) % 4 == 0:
        print(a ^ b ^ (b -1) ^ (b-2))
    if (b - a + 1) % 4 == 1:
        print(a)
    if (b - a + 1) % 4 == 2:
        print(a ^ b)
    if (b - a + 1) % 4 == 3:
        print(a ^ b ^ (b -1))
Buggy python submission (verdict: Runtime Error):
s = input()
times = 0
is01 = s.find("01")
is10 = s.find("10")
while is01 != -1 or is10 != -1:
    times += 1
    if is01 != -1:
        s = s[:is01] + s[is01+2:]
    else :
        s = s[:is10] + s[is10+2:]
    is01 = s.find("01")
    is10 = s.find("10")
    print(s)
print(times*2)

Fixed submission:
s = input()
one = s.count("0")
zero = s.count("1")
print(min(one,zero) * 2)
Buggy python submission (verdict: Runtime Error):
dt = [for int(i) in input().split("/")]
if dt[0] >= 2019 and dt[1] >= 5:
    print("TBD")
else :
    print("Heisei")

Fixed submission:
dt = [int(i) for i in input().split("/")]

if dt[0] >= 2019 and dt[1] >= 5:
    print("TBD")
else :
    print("Heisei")

Buggy python submission (verdict: Runtime Error):
from dateutil.parser import parse
dt = parse(input())
if dt.year >= 2019 and dt.month >= 5:
    print("TBD")
else :
    print("Heisei")

Fixed submission:
dt = [int(i) for i in input().split("/")]

if dt[0] >= 2019 and dt[1] >= 5:
    print("TBD")
else :
    print("Heisei")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = len(str(n))
lst = [[3,5,7]]
tfs = [3,5,7]
for i in range(1,a):
    l = []
    for v in lst[i-1]:
        for t in tfs:
            l.append(int(str(v) + str(t)))
    lst.append(l)
s = 0
for l in lst:
    for v in l:
        if is753(v) and v <= n:
            s+=1
print(s)

Fixed submission:
def is753(n):
    if n % 10 != 3 and n % 10 != 5 and n % 10 !=7:
        return False
    exist3 = False
    exist5 = False
    exist7 = False
    a = str(n)
    for i in range (len(a)):
        x = n % 10
        if x == 3 :
            exist3 = True
        elif x == 5 :
            exist5 = True
        elif x == 7 :
            exist7 = True
        else :
            return False
        n = n // 10
    if exist3 and exist5 and exist7:
        return True
    else :
        return False

n = int(input())
a = len(str(n))
lst = [[3,5,7]]
tfs = [3,5,7]
for i in range(1,a):
    l = []
    for v in lst[i-1]:
        for t in tfs:
            l.append(int(str(v) + str(t)))
    lst.append(l)
s = 0
for l in lst:
    for v in l:
        if is753(v) and v <= n:
            s+=1
print(s)
Buggy python submission (verdict: Runtime Error):
import collections
n = int(input())
v = input().split()
v_int = [int(i) for i in v]
v_odd = []
v_even = []
for i in range(int(n/2)):
  v_even.append(v_int[i*2])
  v_odd.append(v_int[i*2+1])
c_odd = collections.Counter(v_odd)
c_even = collections.Counter(v_even)
max_odd = 0
second_odd = 0
max_key_odd = 0
for key in c_odd:
  if max_odd < c_odd[key]:
    second_odd = max_odd
    max_odd = c_odd[key]
    max_key_odd = key
  elif second_odd < c_odd[key]:
    second_odd = c_odd[key]
    
max_even = 0
second_even = 0
max_key_even = 0
for key in c_even:
  if max_even < c_even[key]:
    second_even = max_even
    max_even = c_even[key]
    max_key_even = key
  elif second_even < c_even[key]:
    second_even = c_even[key]
    
if max_key_even != max_key_odd:
  print(int(n)- max_even - max_odd)
else:
  if max_even > max_odd:
    if max_even == second_even:
      print(int(n) - max_even - max_odd)
    else:
      print(int(n) - max_even - second_odd)
  elif max_even < max_odd:
    if max_odd == second_odd:
      print(int(n) - max_odd - max_even)
    else:
      print(int(n) - max_odd - second_even)
  else : 
    if second_odd > second_even:
      print(int(n) - max_even - second_odd)
    else :
      print(int(n) - max_odd - second_even)

Fixed submission:
a = input()
l = [int(x) for x in list(str(a))]
s = ""
for i in l:
  if i == 1:
    s += "9"
  elif i == 9:
    s += "1"
print(int(s))

Buggy python submission (verdict: Runtime Error):
import collections
n = int(input())
v = input().split()
v_int = [int(i) for i in v]
v_odd = []
v_even = []
for i in range(int(n/2)):
  v_even.append(v_int[i*2])
  v_odd.append(v_int[i*2+1])
c_odd = collections.Counter(v_odd)
c_even = collections.Counter(v_even)
max_odd = 0
second_odd = 0
max_key_odd = 0
for key in c_odd:
  if max_odd < c_odd[key]:
    second_odd = max_odd
    max_odd = c_odd[key]
    max_key_odd = key
  elif second_odd < c_odd[key]:
    second_odd = c_odd[key]
    
max_even = 0
second_even = 0
max_key_even = 0
for key in c_even:
  if max_even < c_even[key]:
    second_even = max_even
    max_even = c_even[key]
    max_key_even = key
  elif second_even < c_even[key]:
    second_even = c_even[key]
    
if max_key_even != max_key_odd:
  print(int(n)- max_even - max_odd)
else:
  if max_even > max_odd:
    if max_even == second_even:
      print(int(n) - max_even - max_odd)
    else:
      print(int(n) - max_even - second_odd)
  elif max_even < max_odd:
    if max_odd == second_odd:
      print(int(n) - max_odd - max_even)
    else:
      print(int(n) - max_odd - second_even)
  else : 
    if second_odd > second_even:
      print(int(n) - max_even - second_odd)
    else :
      print(int(n) - max_odd - second_even)

Fixed submission:
a = input()
l = [int(x) for x in list(str(a))]
s = ""
for i in l:
  if i == 1:
    s += "9"
  elif i == 9:
    s += "1"
print(int(s))
Buggy python submission (verdict: Runtime Error):
import collections
n = int(input())
v = input().split()
v_int = [int(i) for i in v]
v_odd = []
v_even = []
for i in range(int(n/2)):
  v_even.append(v_int[i*2])
  v_odd.append(v_int[i*2+1])
print(v_even)
print(v_odd)
c_odd = collections.Counter(v_odd)
c_even = collections.Counter(v_even)
max_odd = 0
second_odd = 0
max_key_odd = 0
for key in c_odd:
  if max_odd < c_odd[key]:
    second_odd = max_odd
    max_odd = c_odd[key]
    max_key_odd = key
  elif second_odd < c_odd[key]:
    second_odd = c_odd[key]
    
max_even = 0
second_even = 0
max_key_even = 0
for key in c_even:
  if max_even < c_even[key]:
    second_even = max_even
    max_even = c_even[key]
    max_key_even = key
  elif second_even < c_even[key]:
    second_even = c_even[key]
    
print(second_odd)
print(second_even)
if max_key_even != max_key_odd:
  print(int(n)- max_even - max_odd)
else:
  if max_even > max_odd:
    if max_even == second_even:
      print(int(n) - max_even - max_odd)
    else:
      print(int(n) - max_even - second_odd)
  else:
    if max_odd = second_odd:
      print(int(n) - max_odd - max_even)
    else:
      print(int(n) - max_odd - second_even)

Fixed submission:
import collections
n = int(input())
v = input().split()
v_int = [int(i) for i in v]
v_odd = []
v_even = []
for i in range(int(n/2)):
  v_even.append(v_int[i*2])
  v_odd.append(v_int[i*2+1])
c_odd = collections.Counter(v_odd)
c_even = collections.Counter(v_even)
max_odd = 0
second_odd = 0
max_key_odd = 0
for key in c_odd:
  if max_odd < c_odd[key]:
    second_odd = max_odd
    max_odd = c_odd[key]
    max_key_odd = key
  elif second_odd < c_odd[key]:
    second_odd = c_odd[key]
    
max_even = 0
second_even = 0
max_key_even = 0
for key in c_even:
  if max_even < c_even[key]:
    second_even = max_even
    max_even = c_even[key]
    max_key_even = key
  elif second_even < c_even[key]:
    second_even = c_even[key]
    
if max_key_even != max_key_odd:
  print(int(n)- max_even - max_odd)
else:
  if max_even > max_odd:
    if max_even == second_even:
      print(int(n) - max_even - max_odd)
    else:
      print(int(n) - max_even - second_odd)
  elif max_even < max_odd:
    if max_odd == second_odd:
      print(int(n) - max_odd - max_even)
    else:
      print(int(n) - max_odd - second_even)
  else : 
    if second_odd > second_even:
      print(int(n) - max_even - second_odd)
    else :
      print(int(n) - max_odd - second_even)
Buggy python submission (verdict: Runtime Error):
n, h, *t=map(int,open(0).read().split())
a = t[::2]
b = t[1::2]
ma = max(a)
b_high = [i for i in b if i > ma]
if sum(b_high) > h:
  ans = 0
  b_high = sorted(b_high)
  while h < 0:
    h = h - b_high.pop()
    ans += 1
  print(ans)
else:
  if (h - sum(b_high)) % ma == 0:
    print(len(b_high) + (h - sum(b_high)) // ma)
  else:
    print(len(b_high) + ((h - sum(b_high)) // ma) + 1)


Fixed submission:
s = input()
print(s.replace("2017", "2018"))
Buggy python submission (verdict: Time Limit Exceeded):
n, h, *t=map(int,open(0).read().split())
a = sorted(t[::2])
b = sorted(t[1::2])
b_high = [i for i in b if i >= max(a)]
if (h - sum(b_high)) % a[-1] == 0:
  print(len(b_high) + (h - sum(b_high)) // a[-1])
else:
  print(len(b_high) + ((h - sum(b_high)) // a[-1]) + 1)

Fixed submission:
n, h, *t=map(int,open(0).read().split())
a = t[::2]
b = t[1::2]
ma = max(a)
b_high = [i for i in b if i > ma]
if sum(b_high) > h:
  ans = 0
  b_high = sorted(b_high)
  while h > 0:
    h = h - b_high.pop()
    ans += 1
  print(ans)
else:
  if (h - sum(b_high)) % ma == 0:
    print(len(b_high) + (h - sum(b_high)) // ma)
  else:
    print(len(b_high) + ((h - sum(b_high)) // ma) + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n, h, *t=map(int,open(0).read().split())
b_high = [i for i in sorted(t[1::2]) if all(i >= j for j in sorted(t[::2]))]
if (h - sum(b_high)) % sorted(t[::2])[-1] == 0:
  print(len(b_high) + (h - sum(b_high)) // sorted(t[::2])[-1])
else:
  print(len(b_high) + ((h - sum(b_high)) // sorted(t[::2])[-1]) + 1)


Fixed submission:
n, h, *t=map(int,open(0).read().split())
a = t[::2]
b = t[1::2]
ma = max(a)
b_high = [i for i in b if i > ma]
if sum(b_high) > h:
  ans = 0
  b_high = sorted(b_high)
  while h > 0:
    h = h - b_high.pop()
    ans += 1
  print(ans)
else:
  if (h - sum(b_high)) % ma == 0:
    print(len(b_high) + (h - sum(b_high)) // ma)
  else:
    print(len(b_high) + ((h - sum(b_high)) // ma) + 1)

Buggy python submission (verdict: Runtime Error):
n, h, *t=map(int,open(0).read().split())
b_high = [i for i in sorted(t[1::2]) if all(i >= j for j in sorted(t[::2]))]
if (h - sum(b_high)) % a[-1] == 0:
  print(len(b_high) + (h - sum(b_high)) // sorted(t[::2])[-1])
else:
  print(len(b_high) + ((h - sum(b_high)) // sorted(t[::2])[-1]) + 1)


Fixed submission:
n, h, *t=map(int,open(0).read().split())
a = t[::2]
b = t[1::2]
ma = max(a)
b_high = [i for i in b if i > ma]
if sum(b_high) > h:
  ans = 0
  b_high = sorted(b_high)
  while h > 0:
    h = h - b_high.pop()
    ans += 1
  print(ans)
else:
  if (h - sum(b_high)) % ma == 0:
    print(len(b_high) + (h - sum(b_high)) // ma)
  else:
    print(len(b_high) + ((h - sum(b_high)) // ma) + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n, h, *t=map(int,open(0).read().split())
a = sorted(t[::2])
b = sorted(t[1::2])
b_high = [i for i in b if all(i >= j for j in a)]
if (h - sum(b_high)) % a[-1] == 0:
  print(len(b_high) + (h - sum(b_high)) // a[-1])
else:
  print(len(b_high) + ((h - sum(b_high)) // a[-1]) + 1)


Fixed submission:
n, h, *t=map(int,open(0).read().split())
a = t[::2]
b = t[1::2]
ma = max(a)
b_high = [i for i in b if i > ma]
if sum(b_high) > h:
  ans = 0
  b_high = sorted(b_high)
  while h > 0:
    h = h - b_high.pop()
    ans += 1
  print(ans)
else:
  if (h - sum(b_high)) % ma == 0:
    print(len(b_high) + (h - sum(b_high)) // ma)
  else:
    print(len(b_high) + ((h - sum(b_high)) // ma) + 1)
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(h)]
z=[]
for i in range(w):
  if i%2==0:
    for j in range(h):
      z.append([j,i])
  else:
    for j in range(h):
      z.append([h-j-1,i])
count=0
ans=[]
for i,(y,x) in enumerate(z):
  if a[y][x]%2!=0 and i<len(z):
    count+=1
    ans.append(i)
    a[z[i+1][0]][z[i+1][1]]+=1
print(count)
for i in ans:
  print(z[i][0]+1,z[i][1]+1,z[i+1][0]+1,z[i+1][1]+1)

Fixed submission:
h,w=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(h)]
z=[]
for i in range(w):
  if i%2==0:
    for j in range(h):
      z.append([j,i])
  else:
    for j in range(h):
      z.append([h-j-1,i])
count=0
ans=[]
for i,(y,x) in enumerate(z):
  if a[y][x]%2!=0 and i<len(z)-1:
    count+=1
    ans.append(i)
    a[z[i+1][0]][z[i+1][1]]+=1
print(count)
for i in ans:
  print(z[i][0]+1,z[i][1]+1,z[i+1][0]+1,z[i+1][1]+1)

Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(h)]
z=[]
for i in range(w):
  if i%2==0:
    for j in range(h):
      z.append([j,i])
  else:
    for j in range(h):
      z.append([h-j-1,i])
count=0
ans=[]
for i,(y,x) in enumerate(z):
  if a[y][x]%2!=0:
    count+=1
    ans.append(i)
    a[z[i+1][0]][z[i+1][1]]+=1
print(count)
for i in ans:
  print(z[i][0]+1,z[i][1]+1,z[i+1][0]+1,z[i+1][1]+1)

Fixed submission:
h,w=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(h)]
z=[]
for i in range(w):
  if i%2==0:
    for j in range(h):
      z.append([j,i])
  else:
    for j in range(h):
      z.append([h-j-1,i])
count=0
ans=[]
for i,(y,x) in enumerate(z):
  if a[y][x]%2!=0 and i<len(z)-1:
    count+=1
    ans.append(i)
    a[z[i+1][0]][z[i+1][1]]+=1
print(count)
for i in ans:
  print(z[i][0]+1,z[i][1]+1,z[i+1][0]+1,z[i+1][1]+1)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
count=0
if k%2==1:
  print((n//k)**3)
else:
  for i in range(k//2,n+1,k//2):
    for j in range(k//2,n+1,k//2):
      for l in range(k//2,n+1,k//2):
        if (i+j)%k==0 and (j+l)%k==0 and (l+i)%k==0:
          count+=1
  print(count)

Fixed submission:
n,k=map(int,input().split())
if k%2==1:
  print((n//k)**3)
else:
  print((n//k)**3+(n//(k//2)-n//k)**3)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
x=list(map(int,input().split()))
for i in range(n):
  if x[i]>=0:
    zero=i
    break
if n-zero+1>k:
  mindis=x[zero+k-1]
else:
  mindis=max(x[n-1],abs(x[n-k]))+min(x[n-1],abs(x[n-k]))*2
for i in range(1,k):
  if zero+k-i-1>n-1:
    continue
  if zero-i<0:
    break
  under=abs(x[zero-i])
  up=x[zero+k-i-1]
  tmp=max(under,up)+min(under,up)*2
  if tmp<mindis:
    mindis=tmp
print(mindis)

Fixed submission:
n,k=map(int,input().split())
x=list(map(int,input().split()))
mintime=abs(x[0])+abs(x[0]-x[n-1])
for i in range(n-k+1):
  r=abs(x[k+i-1])+abs(x[k+i-1]-x[i])
  l=abs(x[i])+abs(x[k+i-1]-x[i])
  if min(r,l)<mintime:
    mintime=min(r,l)
print(mintime)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
x=list(map(int,input().split()))
for i in range(n):
  if x[i]>=0:
    zero=i
    break
if n-zero+1>k:
  mindis=x[zero+k-1]
else:
  mindis=max(x[n-1],abs(x[n-k]))+min(x[n-1],abs(x[n-k]))*2
for i in range(1,k):
  if zero+k-i-1>n:
    continue
  if zero-i<0:
    break
  under=abs(x[zero-i])
  up=x[zero+k-i-1]
  tmp=max(under,up)+min(under,up)*2
  if tmp<mindis:
    mindis=tmp
print(mindis)

Fixed submission:
n,k=map(int,input().split())
x=list(map(int,input().split()))
mintime=abs(x[0])+abs(x[0]-x[n-1])
for i in range(n-k+1):
  r=abs(x[k+i-1])+abs(x[k+i-1]-x[i])
  l=abs(x[i])+abs(x[k+i-1]-x[i])
  if min(r,l)<mintime:
    mintime=min(r,l)
print(mintime)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [int(input()) for i in range(m)]
res_arr = [-1] * n

for i in a:
    res_arr[i] = 0

for i in range(1, n):
    if res_arr[i] == 0:
        next
    elif i == 1:
        res_arr[i] = 1
    elif i == 2:
        res_arr[i] = 1 + res_arr[i-1]
    else:
        res_arr[i] = res_arr[i-1] + res_arr[i-2]

res = res_arr[-1]+res_arr[-2]
if n == 1:
    res = res_arr[1]
elif n == 2:
    res = 1 + res_arr[1]
amari = res % 1000000007
print(amari)


Fixed submission:
arr = list(map(int, input().split()))
arr.sort()
print(arr[0]+arr[1])
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [int(input()) for i in range(m)]
res_arr = [-1] * n

for i in a:
    res_arr[i] = 0

for i in range(1, n):
    if res_arr[i] == 0:
        next
    elif i == 1:
        res_arr[i] = 1
    elif i == 2:
        res_arr[i] = 1 + res_arr[i-1]
    else:
        res_arr[i] = res_arr[i-1] + res_arr[i-2]

res = res_arr[-1]+res_arr[-2]
if n == 1:
    res = res_arr[1]
elif n == 2:
    res = 1 + res_arr[1]
amari = res % 1000000007
print(amari)


Fixed submission:
n, m = map(int, input().split())
a = [int(input()) for i in range(m)]
res_arr = [-1] * n

for i in a:
    res_arr[i] = 0

for i in range(1, n):
    if res_arr[i] == 0:
        next
    elif i == 1:
        res_arr[i] = 1
    elif i == 2:
        res_arr[i] = 1 + res_arr[i-1]
    else:
        res_arr[i] = res_arr[i-1] + res_arr[i-2]

if n == 1:
    res = 1
elif n == 2:
    res = 1 + res_arr[1]
else:
    res = res_arr[-1]+res_arr[-2]
amari = res % 1000000007
print(amari)

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [int(input()) for i in range(m)]
res_arr = [0] * n

for i in range(1, n):
    if i in a:
        res_arr[i] = 0
    elif i == 1:
        res_arr[i] = 1
    elif i == 2:
        res_arr[i] = 1 + res_arr[i-1]
    else:
        res_arr[i] = res_arr[i-1] + res_arr[i-2]

res = res_arr[-1]+res_arr[-2]
amari = res % 1000000007
print(amari)


Fixed submission:
n, m = map(int, input().split())
a = [int(input()) for i in range(m)]
res_arr = [-1] * n

for i in a:
    res_arr[i] = 0

for i in range(1, n):
    if res_arr[i] == 0:
        next
    elif i == 1:
        res_arr[i] = 1
    elif i == 2:
        res_arr[i] = 1 + res_arr[i-1]
    else:
        res_arr[i] = res_arr[i-1] + res_arr[i-2]

if n == 1:
    res = 1
elif n == 2:
    res = 1 + res_arr[1]
else:
    res = res_arr[-1]+res_arr[-2]
amari = res % 1000000007
print(amari)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

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

dp = np.array([np.inf] * N)
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2,N):
    for j in range(0,K+1):
        if i - j >= 0:
            dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
print(int(dp[N-1]))

Fixed submission:
import numpy as np

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

dp = np.array([np.inf] * N)
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2,N):
        if i - K >= 0:
            dp[i] = min(dp[i-K:i]+abs(h[i]-h[i-K:i]))
        else:
            dp[i] = min(dp[0:i]+abs(h[i]-h[0:i]))
print(int(dp[N-1]))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

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

dp = [np.inf] * N
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2,N):
    for j in range(0,K+1):
        if i - j >= 0:
            dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
print(dp[N-1])

Fixed submission:
import numpy as np

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

dp = np.array([np.inf] * N)
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2,N):
        if i - K >= 0:
            dp[i] = min(dp[i-K:i]+abs(h[i]-h[i-K:i]))
        else:
            dp[i] = min(dp[0:i]+abs(h[i]-h[0:i]))
print(int(dp[N-1]))

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

dp = [np.inf] * N
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2,N):
    for j in range(0,K+1):
        if i - j >= 0:
            dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
print(dp[N-1])

Fixed submission:
import numpy as np

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

dp = np.array([np.inf] * N)
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2,N):
        if i - K >= 0:
            dp[i] = min(dp[i-K:i]+abs(h[i]-h[i-K:i]))
        else:
            dp[i] = min(dp[0:i]+abs(h[i]-h[0:i]))
print(int(dp[N-1]))

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

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

dp = [np.inf] * N
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2,N):
    for j in range(0,K+1):
        if i - j >= 0:
            dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
print(dp[N-1])

Fixed submission:
import numpy as np

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

dp = np.array([np.inf] * N)
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2,N):
        if i - K >= 0:
            dp[i] = min(dp[i-K:i]+abs(h[i]-h[i-K:i]))
        else:
            dp[i] = min(dp[0:i]+abs(h[i]-h[0:i]))
print(int(dp[N-1]))
Buggy python submission (verdict: Runtime Error):
#問題C
import warnings
warnings.filterwarnings('ignore')
import pandas as pd
import numpy as np

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

h = h.reshape(7,3)

dp = np.array([[0] * h.shape[1]] * h.shape[0])
dp[0,:] = h[0,:]
for i in range(1,N):
    dp[i,0] = max(dp[i-1,1],dp[i-1,2])+h[i,0]
    dp[i,1] = max(dp[i-1,0],dp[i-1,2])+h[i,1]
    dp[i,2] = max(dp[i-1,0],dp[i-1,1])+h[i,2]

print(max(dp[-1,]))

Fixed submission:
# 問題C
import numpy as np
import warnings
warnings.filterwarnings('ignore')

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

h = h.reshape(N, 3)

dp = np.array([[0] * h.shape[1]] * h.shape[0])
dp[0, :] = h[0, :]
for i in range(1, N):
    dp[i, 0] = max(dp[i-1, 1], dp[i-1, 2])+h[i, 0]
    dp[i, 1] = max(dp[i-1, 0], dp[i-1, 2])+h[i, 1]
    dp[i, 2] = max(dp[i-1, 0], dp[i-1, 1])+h[i, 2]

print(max(dp[-1, ]))
Buggy python submission (verdict: Runtime Error):
import sys;
lines = sys.stdin.readlines();

#配列の宣言
alfabet = {};

#値の格納
alfabet['A'] = 1;
alfabet['B'] = 2;
alfabet['C'] = 3;
alfabet['D'] = 4;

for i, line in enumerate(lines):
    #値を受け取り格納
    first,second = line.split();

if(alfabet[first]<alfabet[second]):
    print ("<");
elif(alfabet[first]>alfabet[second]):
    print (">");
else:
    print("=");


Fixed submission:
import sys;
lines = sys.stdin.readlines();

#配列の宣言
alfabet = {};

#値の格納
alfabet['A'] = 1;
alfabet['B'] = 2;
alfabet['C'] = 3;
alfabet['D'] = 4;
alfabet['E'] = 5;
alfabet['F'] = 6;

for i, line in enumerate(lines):
    #値を受け取り格納
    first,second = line.split();

if(alfabet[first]<alfabet[second]):
    print ("<");
elif(alfabet[first]>alfabet[second]):
    print (">");
else:
    print("=");
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
count_li = Counter(A)
li = sorted(list(count_li.values()), reverse=True)
print(sum(li[K:]))

Fixed submission:
from collections import Counter
N, K = map(int, input().split())
A = list(map(int, input().split()))
count_li = Counter(A)
li = sorted(list(count_li.values()), reverse=True)
print(sum(li[K:]))
Buggy python submission (verdict: Runtime Error):
i = list(map(int, input().split()))
countFive = i.count(5)
countSeven = i.count(7)

if countFive == 2 & countSeven == 1
	print("YES")
else
	print("NO")

Fixed submission:
i = list(map(int, input().split()))
countFive = i.count(5)
countSeven = i.count(7)

if countFive == 2 and countSeven == 1 :
    print("YES")
else :
    print("NO")