Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from sys import stdin

n = int(stdin.readline().rstrip())
an = list(map(int, input().split()))

m = []
p = []
z = 0

for i in range(n):
  if(an[i]<0):
    m.append(an[i])
  if(an[i]>0):
    p.append(an[i])
  if(an[i]==0):
    z=1

if ( z==1 ):
  ans = sum(p) - sum(m)
else:
  if ( len(m) == 0):
    ans = sum(p)
  else:
    if ( len(m)%2 == 0):
      ans = sum(p) - sum(m)
    else:
      minm = 0
      if ( min(p) < (-max(m)) ):
        minm = min(p)
      else:
        minm = -max(m)
      ans  = sum(p) - sum(m) - (minm*2)

print(ans)

Fixed submission:
from sys import stdin

n = int(stdin.readline().rstrip())
an = list(map(int, input().split()))

m = []
p = []
z = 0

for i in range(n):
  if(an[i]<0):
    m.append(an[i])
  if(an[i]>0):
    p.append(an[i])
  if(an[i]==0):
    z=1

if ( z==1 ):
  ans = sum(p) - sum(m)
elif ( len(m) == 0):
    ans = sum(p)
else:
  if ( len(p) == 0):
    if ( len(m)%2 == 0):
      ans = - sum(m)
    else:
        minm = -max(m)
        ans = -sum(m) - (minm*2)
  else:
    if ( len(m)%2 == 0):
      ans = sum(p) - sum(m)
    else:
      minm = 0
      if ( min(p) < (-max(m)) ):
        minm = min(p)
      else:
        minm = -max(m)
      ans  = sum(p) - sum(m) - (minm*2)

print(ans)

Buggy python submission (verdict: Runtime Error):
from sys import stdin

n = int(stdin.readline().rstrip())
an = list(map(int, input().split()))

m = []
p = []
z = 0

for i in range(n):
  if(an[i]<0):
    m.append(an[i])
  if(an[i]>0):
    p.append(an[i])
  if(an[i]==0):
    z=1

if ( z==1 ):
  ans = sum(p) - sum(m)
else:
  if ( len(m)%2 == 0):
    ans = sum(p) - sum(m)
  else:
    minm = 0
    if ( min(p) < (-max(m)) ):
      minm = min(p)
    else:
      minm = -max(m)
    ans  = sum(p) - sum(m) - (minm*2)

print(ans)

Fixed submission:
from sys import stdin

n = int(stdin.readline().rstrip())
an = list(map(int, input().split()))

m = []
p = []
z = 0

for i in range(n):
  if(an[i]<0):
    m.append(an[i])
  if(an[i]>0):
    p.append(an[i])
  if(an[i]==0):
    z=1

if ( z==1 ):
  ans = sum(p) - sum(m)
elif ( len(m) == 0):
    ans = sum(p)
else:
  if ( len(p) == 0):
    if ( len(m)%2 == 0):
      ans = - sum(m)
    else:
        minm = -max(m)
        ans = -sum(m) - (minm*2)
  else:
    if ( len(m)%2 == 0):
      ans = sum(p) - sum(m)
    else:
      minm = 0
      if ( min(p) < (-max(m)) ):
        minm = min(p)
      else:
        minm = -max(m)
      ans  = sum(p) - sum(m) - (minm*2)

print(ans)
Buggy python submission (verdict: Runtime Error):
k = int(input())
a, b = map(int, input().split())
if b < k:
  print("NG")
else:
  i = 1
  while i*k <= b:
    if i*k >= a:
      print("OK")
      break
    else:
      i += 1
if i*k > b:
  print("NG")

Fixed submission:
k = int(input())
a, b = map(int, input().split())
i = 1
while k*i < a:
  i += 1
if k*i <= b:
  print("OK")
else:
  print("NG")
Buggy python submission (verdict: Time Limit Exceeded):
n, x, y = map(int, input().split())
li = []
x -= 1
y -= 1
for i in range(n-1):
  li_i = []
  for j in range(i+1, n):
    li_i.append(min(j-i, abs(x-i)+abs(y-j)+1))
  li.append(li_i)
for i in range(1,n):
  a = 0
  for j in range(n-1):
    for k in range(n-1-j):
      if li[j][k] == i:
        a += 1
  print(a)
    

Fixed submission:
n, x, y = map(int, input().split())
li = [0 for i in range(n-1)]
x -= 1
y -= 1
for i in range(n-1):
  for j in range(i+1, n):
    a = min(j-i, abs(x-i)+abs(y-j)+1)
    li[a-1] += 1
for x in li:
  print(x)
Buggy python submission (verdict: Time Limit Exceeded):
n, a, b = map(int, input().split())
ans = 0
mod = 10**9 + 7
ncr = 1
ans = 0
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
N = n
g1 = [1, 1]
g2 = [1, 1] 
inverse = [0, 1] 

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
for i in range(1, n+1):
  if i == a or i == b:
    continue
  else:
    ans = (ans + cmb(n, i, mod))%mod
print(ans)

Fixed submission:
n, a, b = map(int, input().split())
mod = 10**9 + 7
def comb(n,k):
    if n<k:
        return 0
    if n<0 or k<0:
        return 0
    k=min(n-k,k)
    ans=1
    inv=[1]*(k+1)
    if k>=1:
        ans*=(n-k+1)%mod
    for i in range(2,k+1):
        inv[i]=mod-inv[mod%i]*(mod//i)%mod
        ans=ans*(n-k+i)*inv[i]%mod
    return ans
c = comb(n, a)
d = comb(n, b)
answer = pow(2, n, mod) - 1
print((answer-c-d)%mod)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li = []
for i in range(n):
  li.append(input())
dic = {}
li_a = []
for x in li:
  if x not in li_a:
    dic[x] = 1
    li_a.append(x)
  else:
    dic[x] += 1
li_s = sorted(li_a)
li_ans = []
for x in li_s:
  li_ans.append(dic[x])
for i in range(len(li_ans)):
  if li_ans[i] == max(li_ans):
    print(li_s[i])
               
  

Fixed submission:
n = int(input())
li = []
for i in range(n):
  li.append(input())
from collections import Counter
s = Counter(li)
a = list(s.values())
b = list(s.keys())
ans = []
m = 0
for x in a:
  m = max(m, x)
for i in range(len(a)):
  if a[i] == m:
    ans.append(b[i])
ans_a = sorted(ans)
ans_b = "\n".join(ans_a)
print(ans_b)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li = []
for i in range(n):
  li.append(input())
dic = {}
li_a = []
for x in li:
  if x not in li_a:
    dic[x] = 1
    li_a.append(x)
  else:
    dic[x] += 1
li_s = sorted(li_a)
li_ans = []
for x in li_s:
  li_ans.append(dic[x])
for i in range(len(li_ans)):
  if li_ans[i] == max(li_ans):
    print(li_s[i])
               
  

Fixed submission:
n = int(input())
li = []
for i in range(n):
  li.append(input())
from collections import Counter
s = Counter(li)
a = list(s.values())
b = list(s.keys())
ans = []
m = 0
for x in a:
  m = max(m, x)
for i in range(len(a)):
  if a[i] == m:
    ans.append(b[i])
ans_a = sorted(ans)
ans_b = "\n".join(ans_a)
print(ans_b)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li = []
for i in range(n):
  li.append(input())
li_a = sorted(list(set(li)))
li_ans = [0 for i in range(len(li_a))]
for x in li:
  b = li_a.index(x)
  li_ans[b] += 1
for i in range(len(li_ans)):
  if li_ans[i] == max(li_ans):
    print(li_a[i])


Fixed submission:
n = int(input())
li = []
for i in range(n):
  li.append(input())
from collections import Counter
s = Counter(li)
a = list(s.values())
b = list(s.keys())
ans = []
m = 0
for x in a:
  m = max(m, x)
for i in range(len(a)):
  if a[i] == m:
    ans.append(b[i])
ans_a = sorted(ans)
ans_b = "\n".join(ans_a)
print(ans_b)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li = []
for i in range(n):
  li.append(input())
li_a = sorted(list(set(li)))
li_ans = [0 for i in range(len(li_a))]
for x in li:
  b = li_a.index(x)
  li_ans[b] += 1
for i in range(len(li_ans)):
  if li_ans[i] == max(li_ans):
    print(li_a[i])

Fixed submission:
n = int(input())
li = []
for i in range(n):
  li.append(input())
from collections import Counter
s = Counter(li)
a = list(s.values())
b = list(s.keys())
ans = []
m = 0
for x in a:
  m = max(m, x)
for i in range(len(a)):
  if a[i] == m:
    ans.append(b[i])
ans_a = sorted(ans)
ans_b = "\n".join(ans_a)
print(ans_b)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
li_p = list(map(int, input().split()))
def kitaichi(a):
  b = 0
  for i in range(1, a+1):
    b += i
  return b/a
li_s = []
for x in li_p:
  li_s.append(kitaichi(x))
ans = []
d = 0
for i in range(k):
  d += li_s[i]
  ans.append(d)
for j in range(k, n):
  d += li_s[j]
  d -= li_s[j-k]
  ans.append(d)
print(max(ans))

Fixed submission:
n, k = map(int, input().split())
li_p = list(map(int, input().split()))
def kitaichi(a):
  b = 0
  for i in range(1, a+1):
    b += i
  return b/a
li_s = []
for x in li_p:
  li_s.append(kitaichi(x))
ans = []
d = 0
for i in range(k):
  d += li_s[i]
  ans.append(d)
for j in range(k, n):
  d += li_s[j]
  d -= li_s[j-k]
  ans.append(d)
print(max(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
li_p = list(map(int, input().split()))
def kitaichi(a):
  b = 0
  for i in range(1, a+1):
    b += i
  return b/a
li_s = []
for x in li_p:
  li_s.append(kitaichi(x))
ans = []
for i in range(n-k+1):
  c = 0
  for j in range(i, i+k):
    c += li_s[j]
    ans.append(c)
print(max(ans))

Fixed submission:
n, k = map(int, input().split())
li_p = list(map(int, input().split()))
def kitaichi(a):
  b = 0
  for i in range(1, a+1):
    b += i
  return b/a
li_s = []
for x in li_p:
  li_s.append(kitaichi(x))
ans = []
d = 0
for i in range(k):
  d += li_s[i]
  ans.append(d)
for j in range(k, n):
  d += li_s[j]
  d -= li_s[j-k]
  ans.append(d)
print(max(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
li = list(map(int, input().split()))
li_a = sorted(li)
if k == 0:
  print(sum(li_a))
elif k >= n:
  print(0)
else:
  for i in range(k):
    a = li_a[-1]
    li_a.remove(a)
  print(sum(li_a))

Fixed submission:
n, k = map(int, input().split())
li = list(map(int, input().split()))
li_a = sorted(li)
if k == 0:
  print(sum(li_a))
elif k >= n:
  print(0)
else:
  for i in range(k):
    li_a.pop()
  print(sum(li_a))

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
li = list(map(int, input().split()))
if k >= 1 and k < n:
  for i in range(k):
    li.remove(max(li))
  print(sum(li))
elif k == 0:
  print(sum(li))
elif k >= n:
  print(0)

Fixed submission:
n, k = map(int, input().split())
li = list(map(int, input().split()))
li_a = sorted(li)
if k == 0:
  print(sum(li_a))
elif k >= n:
  print(0)
else:
  for i in range(k):
    li_a.pop()
  print(sum(li_a))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0
for i in range(1, 10):
  for j in range(1, 10):
    a = 0
    b = 0
    for k in range(1, n+1):
      K = str(k)
      if int(K[0]) == i and int(K[-1]) == j:
        a += 1
      if int(K[0]) == j and int(K[-1]) == i:
        b += 1
    ans += a*b
print(ans)

Fixed submission:
n = int(input())
li_a = []
for i in range(9):
  li_a.append([0,0,0,0,0,0,0,0,0])
for i in range(1, n+1):
  k = str(i)
  k0 = int(k[0])
  k1 = int(k[-1])
  if k0*k1 != 0:
    li_a[k0-1][k1-1] += 1
ans = 0
for i in range(9):
  for j in range(9):
    ans += li_a[i][j]*li_a[j][i]
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
li = []
for i in range(1, 10**5+1):
  if a%i=0 and b%i=0:
    li.append(i)
print((a*b)/li[-1])
    

Fixed submission:
a, b = map(int, input().split())
li = []
for i in range(1, 10**5+1):
  if a%i==0 and b%i==0:
    li.append(i)
print(int((a*b)/li[-1]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
l =[]
for i in range(1,1000000):
  if type(N/i) == int:
    l.append(i + N/i)
print(min(l)-2)

Fixed submission:
N = float(input())
l = []
for i in range(1,1000001):
  a = N/i
  if a.is_integer():
    l.append(i + N/i)
print(int(min(l)-2))

Buggy python submission (verdict: Runtime Error):
N = int(input())
l = []
for i in range(1, N-1):
  if type(N/i) == int:
    l.append(i + N/i)
print(min(l)-2)
    

Fixed submission:
N = float(input())
l = []
for i in range(1,1000001):
  a = N/i
  if a.is_integer():
    l.append(i + N/i)
print(int(min(l)-2))
Buggy python submission (verdict: Runtime Error):
n = int(input())
li =list(input().split())
a=0
for i in range(n-1):
  if li[i] == li[i+1]:
    a += 1
print(n-a)


Fixed submission:
a,b=map(int,input().split())
if a >= 2*b:
  print(a-2*b)
else:
  print(0)

Buggy python submission (verdict: Runtime Error):
n = int(input())
li =list(input().split())
for i in range(n-1):
  if li[i] == li[i+1]:
    li.remove(li[i])
print(len(li))


Fixed submission:
a,b=map(int,input().split())
if a >= 2*b:
  print(a-2*b)
else:
  print(0)

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input()split())
if a >= 2*b:
  print(a-2*b)
else:
  print(0)

Fixed submission:
a,b=map(int,input().split())
if a >= 2*b:
  print(a-2*b)
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
n = int(input())
li =list(input())
for i in range(n-1):
  if li[i] == li[i+1]:
    li.remove(li[i])
print(len(li))


Fixed submission:
n = int(input())
li =list(input())
a=0
for i in range(n-1):
  if li[i] == li[i+1]:
    a += 1
print(n-a)

Buggy python submission (verdict: Runtime Error):
n = int(input())
li =list(input())
for i in range(n-1):
  if li[i] == li[i+1]:
    li.remove(li[i])
print(len(li))


Fixed submission:
n = int(input())
li =list(input())
a=0
for i in range(n-1):
  if li[i] == li[i+1]:
    a += 1
print(n-a)

Buggy python submission (verdict: Runtime Error):
n = int(input())
li =list(input().split())
for i in range(n-1):
  if li[i] == li[i+1]:
    li.remove(li[i])
print(len(li))


Fixed submission:
n = int(input())
li =list(input())
a=0
for i in range(n-1):
  if li[i] == li[i+1]:
    a += 1
print(n-a)

Buggy python submission (verdict: Runtime Error):
n = int(input())
li =list(input().split())
for i in range(n):
  if li[i] == li[i+1]:
    li.remove(li[i])
print(len(li))

Fixed submission:
n = int(input())
li =list(input())
a=0
for i in range(n-1):
  if li[i] == li[i+1]:
    a += 1
print(n-a)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
li = list(map(int, input().split()))
for i in range(N):
  print(li.index(i+1) + 1, end = " ")

Fixed submission:
N = int(input())
li = list(map(int, input().split()))
ans = [0]*N
for i in range(N):
  ans[li[i]-1] = i+1
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
li = list(map(int, input().split()))
for i in range(N):
  ans = str(li.index(i+1) + 1)
  print(ans, end = " ")

Fixed submission:
N = int(input())
li = list(map(int, input().split()))
ans = [0]*N
for i in range(N):
  ans[li[i]-1] = i+1
print(*ans)
Buggy python submission (verdict: Runtime Error):
for i in range(N-1):
  if li[i] == li[i+1]:
    b += 1
  else:
    a += 1
for j in range(K):
  if a >= 2:
    a -= 2
    b += 2
  elif a == 1:
    a -= 1
    b += 1
  else:
    break
print(b)

Fixed submission:
N, K = map(int, input().split())
li = list(input())
a = 0
b = 0
for i in range(N-1):
  if li[i] == li[i+1]:
    b += 1
  else:
    a += 1
for j in range(K):
  if a >= 2:
    a -= 2
    b += 2
  elif a == 1:
    a -= 1
    b += 1
  else:
    break
print(b)
Buggy python submission (verdict: Runtime Error):
n = int(input())
li = list(map(int, input().split()))
li_a = []
for i in range(n-1):
  if li[i] < li[i+1]:
    li_a.append(i+1)
if len(li_a) == 1:
  print(n - li_a[0] - 1)
else:
  li_b = []
  for j in range(len(li_a)-2):
    li_b.append(li_a[j+1]-li_a[j]-1)
  li_b.append(n - li_a[-1] - 1)
  print(max(li_b))

Fixed submission:
n = int(input())
li = list(map(int, input().split()))
li_a = []
for i in range(n-1):
  if li[i] < li[i+1]:
    li_a.append(i+1)
if len(li_a) == 1:
  print(n - li_a[0] - 1)
elif len(li_a) == 0:
  print(n-1)
else:
  li_b = []
  for j in range(len(li_a)-2):
    li_b.append(li_a[j+1]-li_a[j]-1)
  li_b.append(n - li_a[-1] - 1)
  print(max(li_b))

Buggy python submission (verdict: Runtime Error):
n = int(input())
li = list(map(int, input().split()))
li_a = []
for i in range(n-1):
  if li[i] < li[i+1]:
    li_a.append(i+1)
if len(li_a) == 1:
  print(n - li_a[0] - 1)
else:
  li_b = []
  for j in range(len(li_a)-2):
    li_b.append(li_a[j+1]-li_a[j]-1)
  li_b.append(n - li_a[-1] - 1)
  print(max(li_b))
print(li_a)
  

Fixed submission:
n = int(input())
li = list(map(int, input().split()))
li_a = []
for i in range(n-1):
  if li[i] < li[i+1]:
    li_a.append(i+1)
if len(li_a) == 1:
  print(n - li_a[0] - 1)
elif len(li_a) == 0:
  print(n-1)
else:
  li_b = []
  for j in range(len(li_a)-2):
    li_b.append(li_a[j+1]-li_a[j]-1)
  li_b.append(n - li_a[-1] - 1)
  print(max(li_b))

Buggy python submission (verdict: Runtime Error):
n = int(input())
li = list(map(int, input().split()))
li_a = []
for i in range(n-1):
  if li[i] >= li[i+1]:
    li_a.append(i)
li_b = []
for j in range(len(li_a)-2):
  li_b.append(li_a[j+1]-li_a[j])
li_b.append(li_a[0])
li_b.append(n - li_a[-1])
print(max(li_b))
  

Fixed submission:
n = int(input())
li = list(map(int, input().split()))
li_a = []
for i in range(n-1):
  if li[i] < li[i+1]:
    li_a.append(i+1)
if len(li_a) == 1:
  print(n - li_a[0] - 1)
elif len(li_a) == 0:
  print(n-1)
else:
  li_b = []
  for j in range(len(li_a)-2):
    li_b.append(li_a[j+1]-li_a[j]-1)
  li_b.append(n - li_a[-1] - 1)
  print(max(li_b))
Buggy python submission (verdict: Runtime Error):
N = int(input())
li_p = list(map(int, input().split()))
li = set(li_p)
li_a = []
li_b = []
for i in range(N):
  if li_p[i] != li[i]:
    li_a.append(li_p[i])
    li_b.append(li[i])
    if len(li_a) == 2:
      if li_a[0] == li_b[1]:
        print("YES")
      else:
        print("NO")
    elif len(li_a) > 2:
      print("NO")
    elif len(li_a) == 0:
      print("YES")
    
  
  

Fixed submission:
N = int(input())
li_p = list(map(int, input().split()))
li_a = sorted(li_p)
#print(li_a)
#print(li_p)
a = 0
for i in range(N):
  if li_p[i] != li_a[i]:
    a += 1
    
if a <= 2:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
L, R = map(int, input().split())
li = []
for i in range(L, R+1):
  li.append(i%2019)
#print(li)
a = min(li)
li.remove(min(li))
b = min(li)
li.remove(min(li))
print(a*b)
       

Fixed submission:
N, A, B = map(int, input().split())
print(min(B, A*N))

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())
print(min(B, A*N))
Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())
li = []
if R-L+1 >= 2019:
  print(0)
else:
  for i in range(L, R+1):
    for j in range(L, R+1):
      if i != j:
        a = i*j
        if a < 2019:
          li.append(a)
        else:
          while a > 2019:
            a %= 2019
            li.append(a)
      else:
        li.append(2018)
  print(min(li))

Fixed submission:
L, R = map(int, input().split())
li = []
li_a =[]
if R-L+1 >= 2019:
  print(0)
else:
  for i in range(L, R+1):
    li.append(i%2019)
  for x in li:
    for y in li:
      if x != y:
        li_a.append((x*y)%2019)
  print(min(li_a))

Buggy python submission (verdict: Runtime Error):
L, R = map(int, input().split())
li = []
for i in range(L, min(L+4038, 2000000000, R)):
  li.append(i%2019)
a = min(li)
li.remove(min(li))
b = min(li)
li.remove(min(li))
print(a*b)

Fixed submission:
L, R = map(int, input().split())
li = []
li_a =[]
if R-L+1 >= 2019:
  print(0)
else:
  for i in range(L, R+1):
    li.append(i%2019)
  for x in li:
    for y in li:
      if x != y:
        li_a.append((x*y)%2019)
  print(min(li_a))
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
li = list(map(int, input().split()))
a = 0
i = 0
while a < x and i < n+1:
  a += li[i]
  i += 1
if a == x:
  i += 1
print(i)
  

Fixed submission:
n, x = map(int, input().split())
li = list(map(int, input().split()))
li.append(0)
a = 0
i = 0
while a <= x and i < n+1:
  a += li[i]
  i += 1
print(i)
Buggy python submission (verdict: Runtime Error):
W, H, x, y = map(int, input().split())
a = x*H
b = y*W
if x != 0 and x != W and y != 0 and y != H:
  if a < b:
    print(str(a) + " " + str(0))
  elif b < a:
    print(str(b) + " " + str(0))
  else:
    print(str(a) + " " + str(1))
else:
  print(str((H*W)/2) + " " + 0)

Fixed submission:
W, H, x, y = map(int, input().split())
if x == W/2 and y == H/2:
  print(str((H*W)/2) + " " + "1")
else:
  print(str((H*W)/2) + " " + "0")
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = [int(i) for i in input().split()]
dp = [0]*n
dp[1] = abs(h[0] - h[1])
for i in range(2, n):
  if i <= k:
    dp[i] = abs(h[0] - h[i])
  else:
    dp[i] = min(dp[i-j] + abs(h[i-j]-h[i])
    for j in range(1, k+1))
print(dp[-1])


Fixed submission:
n, k = map(int, input().split())
h = [int(i) for i in input().split()]
dp = [0]*n
dp[1] = abs(h[0] - h[1])
for i in range(2, n):
  if i <= k:
    dp[i] = abs(h[0] - h[i])
  else:
    dp[i] = min(dp[i-j] + abs(h[i-j]-h[i])
    for j in range(1, k+1))
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
n = int(input())
li = []
for i in range(n):
  a = list(map(int, input().split()))
  li.append(a)
dp = []
for i in range(3):
  dp.append([0 for j in range(n)])
dp[0][0] = li[0][0]
dp[0][1] = li[0][1]
dp[0][2] = li[0][2]
for i in range(1, n):
  dp[i][0] = li[i][0] + max(dp[i-1][1], dp[i-1][2])
  dp[i][1] = li[i][1] + max(dp[i-1][0], dp[i-1][2])
  dp[i][2] = li[i][2] + max(dp[i-1][0], dp[i-1][1])
print(max(dp[n-1][0], dp[n-1][1], dp[n-1][2]))

Fixed submission:
n = int(input())
li = []
for i in range(n):
  a = list(map(int, input().split()))
  li.append(a)
dp = []
for i in range(n):
  dp.append([0 for j in range(3)])
dp[0][0] = li[0][0]
dp[0][1] = li[0][1]
dp[0][2] = li[0][2]
for i in range(1, n):
  dp[i][0] = li[i][0] + max(dp[i-1][1], dp[i-1][2])
  dp[i][1] = li[i][1] + max(dp[i-1][0], dp[i-1][2])
  dp[i][2] = li[i][2] + max(dp[i-1][0], dp[i-1][1])
print(max(dp[n-1][0], dp[n-1][1], dp[n-1][2]))

Buggy python submission (verdict: Runtime Error):
n = int(inut())
li = []
for i in range(n):
  a = list(map(int, input().split()))
  li.append(a)
dp = []
for i in range(3):
  dp.append([0 for j in range(n)])
dp[0][0] = li[0][0]
dp[0][1] = li[0][1]
dp[0][2] = li[0][2]
for i in range(1, n):
  dp[i][0] = li[i][0] + max(dp[i-1][1], dp[i-1][2])
  dp[i][1] = li[i][1] + max(dp[i-1][0], dp[i-1][2])
  dp[i][2] = li[i][2] + max(dp[i-1][0], dp[i-1][1])
print(max(dp[n][0], dp[n][1], dp[n][2]))

Fixed submission:
n = int(input())
li = []
for i in range(n):
  a = list(map(int, input().split()))
  li.append(a)
dp = []
for i in range(n):
  dp.append([0 for j in range(3)])
dp[0][0] = li[0][0]
dp[0][1] = li[0][1]
dp[0][2] = li[0][2]
for i in range(1, n):
  dp[i][0] = li[i][0] + max(dp[i-1][1], dp[i-1][2])
  dp[i][1] = li[i][1] + max(dp[i-1][0], dp[i-1][2])
  dp[i][2] = li[i][2] + max(dp[i-1][0], dp[i-1][1])
print(max(dp[n-1][0], dp[n-1][1], dp[n-1][2]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
li = list(map(int, input().split()))
a = 0
while any(j % 2 == 0 for j in li):
  for i in range(N):
    if li[i]%2 == 0:
      li[i] = li[i]/2
      a += 1
      break
print(a)

Fixed submission:
a, b = map(int, input().split())
if a <= 8 and b <= 8:
  print("Yay!")
else:
  print(":(")
Buggy python submission (verdict: Time Limit Exceeded):
n, p = list(map(int, input().split()))
if(n == 1):
  print(p)
elif(p == 1):
  print(1)
else:
  ans = 1
  tmp = 2
  while(tmp**n <= p):
    if((p%(tmp**n)) == 0): ans = tmp
    tmp+=1
  print(ans)

Fixed submission:
n, p = list(map(int, input().split()))
if(n == 1):
  print(p)
elif(p == 1):
  print(1)
elif(n > 64):
  print(1)
else:
  ans = 1
  tmp = 2
  while(tmp**n <= p):
    if((p%(tmp**n)) == 0): ans = tmp
    tmp+=1
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def ris(): return list(input())
def pli(a): return "".join(list(map(str, a)))

N, M = rli()
keiro = [[False for i in range(N+1)] for j in range(N+1)]
for i in range(M):
    a, b = rli()
    keiro[a][b] = True
    keiro[b][a] = True

flag = False
for i in range(N):
    if(keiro[i][1] and keiro[i][N]):
        flag = True
if(flag):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Fixed submission:
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def ris(): return list(input())
def pli(a): return "".join(list(map(str, a)))

N, M = rli()
keiro = [[False for i in range(2)] for j in range(N+1)]
for i in range(M):
    a, b = rli()
    if(b == 1 or b == N):
        keiro[a][1 if b == 1 else 0] = True
    elif(a == 1 or a == N):
        keiro[b][1 if a == 1 else 0] = True

flag = False
for i in range(2, N):
    if(keiro[i][1] and keiro[i][0]):
        flag = True
if(flag):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")