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

Fixed submission:
import bisect
A,B,Q = map(int, input().split())
S,T,X = [],[],[]
for i in range(A):
  S.append(int(input()))
for i in range(B):
  T.append(int(input()))
for i in range(Q):
  X.append(int(input()))

for i in range(Q):
  ans = []
  sin = bisect.bisect_left(S, X[i])
  if sin == 0:
    s1,s2 = S[sin], -(10**12)
  elif sin == A:
    s1,s2 = (10**12),S[sin-1]
  else:
    s1,s2 = S[sin],S[sin-1]
  tin = bisect.bisect_left(T, X[i])
  if tin == 0:
    t1,t2 = T[tin], -(10**12)
  elif tin == B:
    t1,t2 = (10**12),T[tin-1]
  else:
    t1,t2 = T[tin],T[tin-1]
  for j in [s1,s2]:
    for k in [t1,t2]:
      for l in [0,1]:
        if l ==0:
          ans.append(abs(j-X[i])+abs(k-j))
        else:
          ans.append(abs(k-X[i])+abs(j-k)) 
          
  print(min(ans))

Buggy submission (verdict: Runtime Error):
import bisect
A,B,Q = map(int, input().split())
S,T,X = [],[],[]
for i in range(A):
  S[i] = int(input())
for i in range(B):
  T[i] = int(input())
for i in range(Q):
  X[i] = int(input())

for i in range(Q):
  ans = []
  sin = bisect.bisect_left(S, X[i])
  if sin == 0:
    s1,s2 = S[sin], -(10**9)
  elif sin == A:
    s1,s2 = (10**9),S[sin-1]
  else:
    s1,s2 = S[sin],S[sin-1]
  tin = bisect.bisect_left(T, X[i])
  if tin == 0:
    t1,t2 = T[tin], -(10**9)
  elif tin == B:
    t1,t2 = (10**9),T[tin-1]
  else:
    t1,t2 = T[tin],T[tin-1]
  for j in [s1,s2]:
    for k in [t1,t2]:
      for l in [0,1]:
        if l ==0:
          ans.append(abs(j-X[i])+abs(k-j))
        else:
          ans.append(abs(k-X[i])+abs(j-k)) 
          
  print(min(ans))

Buggy submission (verdict: Runtime Error):
import bisect
A,B,Q = map(int, input().split())
S,T,X = [],[],[]
for i in range(A):
  S[i] = int(input())
for i in range(B):
  T[i] = int(input())
for i in range(Q):
  X[i] = int(input())
 for i in range(Q):
  ans = []
  sin = bisect.bisect_left(S, X[i])
  if sin == 0:
    s1,s2 = S[sin], -(10**9)
  elif sin == A:
    s1,s2 = (10**9),S[sin-1]
  else:
    s1,s2 = S[sin],S[sin-1]
  tin = bisect.bisect_left(T, X[i])
  if tin == 0:
    t1,t2 = T[tin], -(10**9)
  elif tin == B:
    t1,t2 = (10**9),T[tin-1]
  else:
    t1,t2 = T[tin],T[tin-1]
  for j in [s1,s2]:
    for k in [t1,t2]:
      for l in [0,1]:
        if l ==0:
          ans.append(abs(j-X[i])+abs(k-j))
        else:
          ans.append(abs(k-X[i])+abs(j-k)) 
          
  print(min(ans))
Problem p03138 (python)

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

np = [0]*40

for i in range(40):
  for j in A:
    if j&(1<<i):
      np[i] += 1

v = 0
for i in range(39,-1,-1):
  if v + (1<<i) > K:
    continue
  elif np[i] < N - np[i]:
    v += (1<<i)
    
ans = 0
for i in A:
  ans += (v^i)

print(ans)

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

ans = []
for i in range(K+1):
  temp = 0
  for j in range(A):
    temp += i^j
  ans.append(temp)

print(max(ans))
Problem p03148 (python)

Fixed submission:
n, k = map(int, input().split())
TD = [[] for i in range(n)]
for i in range(n):
  TD[i] = list(map(int, input().split()))
  
TD.sort(key = lambda x:x[1], reverse = True)

ans = 0
huku = []
su = set([])

for i, j in TD[:k]:
  ans += j
  if i in su:
    huku.append([i,j])
  su.add(i)
ans += len(su)**2
huku.sort(key = lambda x:x[1], reverse = True)

ansl = []
ansl.append(ans)
for i,j in TD[k:]:
  if i in su:
    continue
  elif huku == []:
    break
  else:
    temp = ansl[-1] + j - huku.pop()[1] + (len(su)+1)**2 -len(su)**2
    su.add(i)
    ansl.append(temp)

print(max(ansl))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
TD = [[] for i in range(n)]
for i in range(n):
  TD[i] = list(map(int, input().split()))
  
TD.sort(key = lambda x:x[1], reverse = True)

ans = 0
huku = []
su = set([])

for i, j in TD[:k]:
  ans += j
  if i in su:
    huku.append([i,j])
  su.add(i)
ans += len(su)**2
huku.sort(key = lambda x:x[1], reverse = True)

ansl = []
ansl.append(ans)
for i,j in TD[k:]:
  if i in su:
    continue
  elif:
    huku == []
    break
  else:
    temp = ansl[-1] + j - huku.pop()[1] + (len(su)+1)**2 -len(su)**2
    su.add(i)
    ansl.append(temp)

print(max(ansl))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
TD = [[] for i in range(n)]
for i in range(n):
  TD[i] = list(map(int, input().split()))
  
TD.sort(key = lambda x:x[1], reverse = True)

ans = 0
huku = []
su = set([])

for i, j in TD[:k]:
  ans += j
  if i in su:
    huku.append([i,j])
  su.add(i)
ans += len(su)**2
huku.sort(key = lambda x:x[1], reverse = True)

ansl = []
ansl.append(ans)
for i,j in TD[k:]:
  if i in su:
    continue
  else:
    temp = ansl[-1] + j - huku.pop()[1] + (len(su)+1)**2 -len(su)**2
    su.add(i)
    ansl.append(temp)

print(max(ansl))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
TD = [[] for i in range(n)]
for i in range(n):
  TD[i] = list(map(int, input().split()))
  
TD.sort(key = lambda x:x[1], reverse = True)

ans = 0
huku = []
su = set([])

for i, j in TD[:k]:
  ans += j
  if i in su:
    huku.append([i,j])
  su.add(i)
ans += len(su)**2

huku.sort(key = lambda x:x[1], reverse = True)

for i,j in TD[k:]:
  if i in su:
    continue
  else:
    su.add(i)
    temp = ans + j - huku.pop()[1] + len(su)**2 -(len(su)-1)**2
    ans = max(ans, temp)

print(ans)
Problem p03160 (python)

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

A = [0]*N
A[1] = abs(H[1] - H[0])

for i in range(2,N):
  on = A[i-1] + abs(H[i] - H[i-1])
  tw = A[i-2] + abs(H[i] - H[i-2])
  A[i] = min(on , tw)

print(A[N-1])

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

A = [0]*N
A[1] = abs(H[1] - H[0])

for i in range(2,N):
  on = A[i-1] + abs(H[i] - H[i-1])
  tw = A[i-2] + abs(H[i] - H[i-2])
  A[i] = min(on , tw)

print(A[N])

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

A = [0]*N
A[1] = abs(H[1] - H[0])

for i in range(2,N):
  on = A[i-1] + abs(H[i] - H[i-1])
  tw = A[i-2] + abs(H[i] - H[i-2])
  A[i] = min(on , tw)

print(A[N])
Problem p03161 (python)

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

A = [0]*N

for i in range(1,N):
  A[i] = min([(A[i-j]+abs(H[i]-H[i-j])) for j in range(1,min(K+1,i+1))])

print(A[N-1])

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

A = [0]*N

for i in range(1,N):
  A[i] = min[(A[i-j]+abs(H[i]-H[i-j])) for j in range(1,min(K+1,i+1))]

print(A[N-1])
Problem p03162 (python)

Fixed submission:
n= int(input())
ABC = [0]*n
for i in range(n):
  ABC[i]= list(map(int, input().split()))

dp = [[0 for i in range(3)] for j in range(n)]
dp[0] = ABC[0]

for i in range(1,n):
  for j in range(3):
    dp[i][j] = ABC[i][j]+max(dp[i-1][j-1],dp[i-1][j-2])
    
print(max(dp[n-1]))

Buggy submission (verdict: Runtime Error):
n= int(input())
ABC = [[0]*3]*n
for i in range(n):
  ABC[i][0],ABC[i][1],ABC[i][2] = map(int, input().split())

dp = [[0]*3]*n
dp[0] = ABC[0]

for i in range(1,n):
  for j in range(3):
    dp[i][j] = ABC[i][j]+max(dp[i][j-1],dp[i][j-2])
    
print(max(dp[n]))
Problem p03212 (python)

Fixed submission:
n = int(input())

def dts(s):
  if int(s) > n:
    return 0
  ret = 1 if all(s.count(_) for _ in '753') else 0
  for i in '753':
    ret += dts(s+i)
  return ret
  
print(dts('0'))

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

def dts(s):
  if int(s) > n:
    return 0
  if ret = 1 if all(s.count(_) for _ in '753') else 0
  for i in '753':
    ret += dts(s+i)
  return ret
  
dts('0')
Problem p03213 (python)

Fixed submission:
n = int(input())

l = [0]*(n+1)
for i in range(2, n+1):
  cur = i
  for j in range(2, i+1):
    while cur % j == 0:
      cur //= j
      l[j] += 1

def num(s):
  return len(list(filter(lambda x: x >= s-1, l)))

print(num(75)+num(25)*(num(3)-1)+num(15)*(num(5)-1)+num(5)*(num(5)-1)*(num(3)-2)//2)

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

l = [0]*(n+1)
for i in range(2, n+1):
  cur = i
  for j in range(2, i+1):
    while cur % j == 0:
      cur //= j
      l[j] == 1

def num(s):
  return len(list(filter(lambda x: x >= m-1, l)))

print(num(75)+num(25)*(num(3)-1)+num(15)*(num(5)-1)+num(5)*(num(5)-1)*(num(3)-2)//2)

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

l = [0]*(n+1)
for i in range(2, n+1):
  cur = i
  for j in range(2, i+1):
    while cur % j == 0:
      cur //= j
      l[j] == 1

def num(s):
  return len(list(filter(lambda x: x >= m-1, l)))

print(num(75)+num(25)*(num(3)-1)+num(15)*(num(5)-1)+(num(5)*(num(5)-1)*(num(3)-2))//2)

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

l = [0]*(n+1)
for i in range(2, n+1):
  cur = i
  for j in range(2, i+1):
    while cur % j == 0:
      cur //= j
      l[j] == 1

def num(s):
  return len(list(filter(lambda x: m-1 =< x, l)))

print(num(75)+num(25)*(num(3)-1)+num(15)*(num(5)-1)+(num(5)*(num(5)-1)*(num(3)-2))//2)

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

l = [0]*(n+1)
for i in range(2, n+1):
  cur = i
  for j in range(2, i+1):
    while cur % j == 0:
      cur //= j
      l[j] == 1

def num(s):
  return len(list(filter(lambda x: m-1 > x, l)))

print(num(75)+num(25)*(num(3)-1)+num(15)*(num(5)-1)+(num(5)*(num(5)-1)*(num(3)-2))//2)
Problem p03240 (python)

Fixed submission:
n = int(input())
XYH = [list(map(int, input().split())) for _ in range(n)]
  
XYH.sort(key=lambda x:x[2],reverse=True)
sx = XYH[0][0]
sy = XYH[0][1]
sh = XYH[0][2]
  
for i in range(0,101):
  for j in range(0,101):
    anss = sh + abs(sx-i) + abs(sy-j)
    for k in range(n):
      if XYH[k][2] == max(anss - abs(XYH[k][0]-i) - abs(XYH[k][1]-j),0):
        pass
      else:
        break
    else:
      an = [i, j, anss]
      print(*an)
      exit()

Buggy submission (verdict: Runtime Error):
n = int(input())
XYH = list(map(int, input().split()) for _ in range(n))
  
XYH.sort(lambda x:x[2],reverse=True)
sx = XYH[0][0]
sy = XYH[0][1]
sh = XYH[0][2]
  
for i in range(0,101):
  for j in range(0,101):
    anss = sh + abs(sx-i) + abs(sy-j)
    for k in range(n):
      if H[k] == 0:
        continue
      if anss == XYH[k][2] + abs(XYH[k][0]-i) + abs(XYH[k][1]-j):
        continue
      else:
        break
    else:
      an = [sx, sy, sh]
      print(*an)
      exit()
Problem p03244 (python)

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

from collections import Counter

v1 = []
v2 = []
for i in range(0,n-1,2):
  v1.append(V[i])
for i in range(1,n,2):
  v2.append(V[i])
  
c1 = Counter(v1).most_common() + [(0,0)]
c2 = Counter(v2).most_common() + [(0,0)]

if c1[0][0] == c2[0][0]:
  a1 = n -c1[1][1]-c2[0][1]
  a2 = n -c1[0][1]-c2[1][1]
  ans = min(a1,a2)
  
else:
  ans = n-c1[0][1]-c2[0][1]

print(ans)

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

from collections import Counter

v1 = []
v2 = []
for i in range(0,n,2):
  v1.append(V[i])
for i in range(1,n,2):
  v2.append(V[i])
  
c1 = Counter(v1)
c2 = Counter(v2)

if list(c1.keys())[0] == list(c2.keys())[0]:
  a1 = sum(list(c1.values())[1:])+list(c2.values())[0]+sum(list(c2.values()[2:]))
  a2 = sum(list(c2.values())[1:])+list(c1.values())[0]+sum(list(c1.values()[2:]))
           
  ans = min(a1,a2)
  
else:
  ans = sum(list(c1.values())[1:])+sum(list(c2.values())[1:])

print(ans)
Problem p03361 (python)

Fixed submission:
H, W = map(int, input().split())
S = [input() for i in range(H)]

for i in range(H):
  for j in range(W):
    if S[i][j] == "#":
      bk = sum([t[j].count("#") for t in S[max(0,i-1):min(H,i+2)]])
      bk += S[i][max(0,j-1):min(W,j+2)].count("#")-1
      if bk == 1:
        print("No")
        exit()

print("Yes")

Buggy submission (verdict: Runtime Error):
H,W = map(int, input().split())
S = [input() for i in range(H)]

for i in range(H):
  for j in range(W):
    if S[i][j] == "#":
      b = sum([t[j].count("#") for t in S[max(0,i-1):min(H,i+1)]])
      b += S[i][max(0,j-1):min(W,j+1)].count("#")-1
      if b == 1:
        print("No")
        c = 1
        break
  else:
    continue
  break

if c !=1:
  print("Yes")
Problem p03436 (python)

Fixed submission:
H, W = map(int, input().split())
S = [list(input()) for i in range(H)]

C = 0
for i in range(H):
  for j in range(W):
    if S[i][j] == ".":
      C += 1
    
S[0][0] = 0
for l in range(C-1):
  for i in range(H):
    for j in range(W):
      if S[i][j] == l:     
        for k in [[0,1],[1,0],[-1,0],[0,-1]]:
          if not(0 <= i + k[0] < H):
            continue
          elif not(0 <= j + k[1] < W):
            continue
          elif S[i+k[0]][j+k[1]] != ".":
            continue
          else:
            S[i+k[0]][j+k[1]] = S[i][j]+1
        
if S[H-1][W-1] == ".":
  print(-1)
  exit()
  
ans = C - S[H-1][W-1] -1
print(ans)

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
S = [list(input()) for i in range(H)]

C = 0
for i in range(H):
  for j in range(W):
    if S[i][j] == ".":
      C += 1

S[0][0] = 0
for i in range(H):
  for j in range(W):
    if S[i][j] != "#":     
      for k in [[0,1],[1,0],[-1,0],[0,-1]]:
        if not(0 <= i + k[0] < H):
          continue
        elif not(0 <= j + k[1] < W):
          continue
        elif S[i+k[0]][j+k[1]] != ".":
          continue
        else:
          S[i+k[0]][j+k[1]] = S[i][j]+1
        
if S[H-1][W-1] == ".":
  print(-1)
  exit()
  
ans = C - S[H-1][W-1] -1
print(ans)
Problem p03680 (python)

Fixed submission:
n = int(input())
lista = []
for i in range(n):
  lista.append(int(input()))

count = 1
fp = lista[0]
if fp == 2:
  print(count)
  exit()

for i in range(n):
  fp = lista[fp-1]
  count += 1
  if fp == 2:
    print(count)
    exit()
print(-1)

Buggy submission (verdict: Runtime Error):
n = int(input())
lista = []
for i in range(n):
  lista.append(int(input()))

count = 1
fp = lista[0]
for i in range(n):
  fp = lista[fp]
  count += 1
  if fp == 2:
    print(count)
    exit()
print(-1)
Problem p03730 (python)

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

for i in range(B):
  if A * i % B == C:
    print("YES")
    exit()
  else:
    continue
print("NO")

Buggy submission (verdict: Runtime Error):
A, B, C = map(int,input().split())

for i in range(B):
  if A * i % B == C:
    print("YES")
    flag = True
    exit()
  else:
    continue

if flag != True:
  print("NO")

Buggy submission (verdict: Runtime Error):
A, B, C = map(int,input().split())

for i in range(B):
  if A * i % B == C:
    print("YES")
    flag = True
    exit()
  else:
    continue

if flag != True:
  print("No")

Buggy submission (verdict: Runtime Error):
A, B, C = map(int,input().split())

n = 100 * B

for i in range(1, n, B):
  if A * i % B == C:
    print("YES")
    flag = True
    break
  else:
    continue

if flag != True:
  print("No")

Buggy submission (verdict: Runtime Error):
A, B, C = map(int,input().split())

n = 100 * B

for i in range(1, n, B):
  if A * i % B == C:
    print("YES")
    flag = True:
    break
  else:
    continue

if flag != True:
  print("No")

Buggy submission (verdict: Runtime Error):
A, B, C = map(int,input().split())

n = 100 * B

for i in range(1, n, B):
  if A * i % B = C:
    print("YES")
    flag == True:
    break
  else:
    continue

if flag != True:
  print("No")
Problem p03796 (python)

Fixed submission:
n = int(input())
import math
p = math.factorial(n)
ap = p%1000000007
print(ap)

Buggy submission (verdict: Runtime Error):
n = int(input())
p = 1
for i in range(1,n+1):
  p = p*i
ap = p/1000000007
print(ap)

Buggy submission (verdict: Runtime Error):
n = int(input())
p = 1
for i in range(n):
  p = p*2^i
ap = p/(1000000007)
print(ap)
Problem p03861 (python)

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

print(b//x-(a-1)//x)

Buggy submission (verdict: Runtime Error):
a, b, x = map(int, input().split())
n = 0
for i in range(a, b+1):
  if i%x == 0:
    p = i
    n += 1
    break

while p < b:
  p += x
  n += 1

n -= 1
print(n)
Problem p03963 (python)

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

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

Buggy submission (verdict: Runtime Error):
N, K = map(int, imput().split())
p = K*(K-1)^(N-1)
print(p)
Problem p02983 (python)

Fixed submission:
l,r=map(int,input().split())
s=[]
if ((r//2019)!=(l//2019)):
    a=0
    s.append(a)
elif((r-l!=1)):
    for i in range(l,r-1):
        for j in range(i+1,r+1):
            #print(i,j)
            a=(i*j)%2019
            #print(a)
            s.append(a)
            if (a==0):
                break
else:
    a=(l*r)%2019
    s.append(a)
print(min(s))

Buggy submission (verdict: Runtime Error):
l,r=map(int,input().split())
s=[]
if ((r//2019)!=(l//2019)):
        a=0
    s.append(a)
elif((r-l!=1)):
    for i in range(l,r-1):
        for j in range(l+1,r):
            #print(i,j)
            a=(i*j)%2019
            #print(a)
            s.append(a)
            if (a==0):
                break
else:
    a=(l*r)%2019
    s.append(a)
print(min(s))

Buggy submission (verdict: Runtime Error):
l,r=map(int,input().split())
s=[]
rr=r-1
for i in range(l,rr):
    for j in range(l+1,r):
        #print(i,j)
        a=(i*j)%2019
        #print(a)
        s.append(a)
print(min(s))
Problem p02899 (python)

Fixed submission:
import numpy as np
n = int(input())
l = list(map(int, input().split()))
res = list(np.argsort(l)+1)
print(" ".join(map(str, res)))

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list(map(int, input().split()))
res = list(np.argsort(l)+1)
print(" ".join(map(str, res)))
Problem p02924 (python)

Fixed submission:
import numpy as np
n = int(input())
print(n*(n-1)//2)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = np.array(range(1,n+1))
b = np.array([a[(i+1)%n] for i in range(n)])
sum(a%b)import numpy as np
n = int(input())
a = np.array(range(1,n+1))
b = np.array([a[(i+1)%n] for i in range(n)])
print(sum(a%b))
Problem p02922 (python)

Fixed submission:
a, b = map(int, input().split())
num_tap = 0
output = 0
if b == 1:
  print(0)
else:
  for i in range(30):
    output += 1
    if i == 0:
      num_tap += a
    else:
      num_tap += a-1
    if num_tap >= b:
      break
  print(output)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
num_tap = 0
output = 0
if b == 1:
  print(0)
else:
  for i in range(30):
  output += 1
  if i == 0:
    num_tap += a
  else:
    num_tap += a-1
  if num_tap >= b:
    break
  print(output)
Problem p03043 (python)

Fixed submission:
N, K = map(int, input().split())
import math
def deno(x):
    if x >= K:
        return 1
    else:
        count = math.ceil(math.log(K/x, 2))
        return 1 / (2 ** count)
pro = sum(map(deno, range(1,N+1))) / N
print(pro)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
import math
def deno(x):
    if x >= K:
        return 1
    else:
        count = math.ceil(math.log(K/x, 2))
        return 1 / (2 ** count)
pro = sum(list(map(deno, np.arange(1,N+1)))) / N
print(pro)
Problem p03243 (python)

Fixed submission:
n = int(input())

ans_list = [100*x+10*x+x for x in range(10)]

for v in ans_list:
    if v >= n:
        ans = v
        break
        
print(ans)

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

ans_list = [100*x+10*x+x for x in range(10)]

for v in ans_list:
    if v > n:
        ans = v
        break
        
print(ans)
Problem p03282 (python)

Fixed submission:
s = input()
k = int(input())

import numpy as np

ind = np.inf

for i in range(len(s)):
    if int(s[i]) != 1:
        ind = i
        ans = int(s[i])
        break
if ind >= k:
    ans = 1
    
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())

for i in range(len(s)):
    if int(s[i]) != 1:
        ans = int(s[i])
        break
        
print(ans)
Problem p03351 (python)

Fixed submission:
a, b, c, d = map(int,input().split(" "))
ans = "No"
if abs(c-a) <= d:
    ans = "Yes"
elif abs(b-a) <= d and abs(c-b) <= d:
    ans = "Yes"
print(ans)

Buggy submission (verdict: Runtime Error):
x = int(input())
import math
flag = False
for i in range(x):
    ans = x - i
    for j in range(2,x):
        b = math.pow(ans, 1/j)
        if b % 1 == 0:
            flag = True
            break
        elif b < 1:
            break
    if flag:
        break
print(ans)
Problem p03109 (python)

Fixed submission:
yr,mn,dy=map(int,input().split('/'))
if yr <2019:
  print("Heisei")
elif yr >2019:
  print("TBD")
else:
  if mn<4:
    print("Heisei")
  elif mn>4:
    print("TBD")
  else:
    print("Heisei")

Buggy submission (verdict: Runtime Error):
date=input()
yr=slice(int[0:4])
mn=slice(int[5:7])
dy=slice(int[8:10])
if yr <2019:
  print("Heisei")
elif yr >2019:
  print("TBD")
else:
  if mn<4:
    print("Heisei")
  elif mn>4:
    print("TBD")
  else:
    print("Heisei")
Problem p03501 (python)

Fixed submission:
n,a,b=map(int,input().split())
ans=min(n*a,b)
print(ans)

Buggy submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
if n*a>b:
  print(b)
else n*a<=b:
  print(n*a)
Problem p03547 (python)

Fixed submission:
x,y=input().split()
s="ABCDEF"
for i in range(0,6):
  if s[i]==x:
    x=int(i)
  if s[i]==y:
    y=int(i)
if x>y:
  print(">")
elif x<y:
  print("<")
else:
  print("=")

Buggy submission (verdict: Runtime Error):
x,y=map(input().split())
s="ABCDEF"
for i in range(0,6):
  if s[i]==x:
    x=int(i)
  if s[i]==y:
    y=int(i)
if x>y:
  print(">")
elif x<y:
  print("<")
else:
  print("=")
Problem p03161 (python)

Fixed submission:
ni,ki = [int(i) for i in input().split()]
arri = [int(i) for i in input().split()]
    
def getRes(arr,n,k):
    dp = [0]*n
    for i in range(1,n):
        H = arr[i]
        dp[i] = min([dp[j]+abs(arr[j]-H) for j in range(max(0,i-k),i)])
    return dp[-1]

print(getRes(arri,ni,ki))

Buggy submission (verdict: Runtime Error):
n,k = [int(i) for i in input().split()]
arr = [int(i) for i in input().split()]

dif = lambda x,y: abs(x-y)

dp = [0,dif(arr[0],arr[1])]

for i in range(2,n):
    minCost = 10000
    H = arr[i]
    for j in range(i-k,i):
        cost = dp[j]+dif(arr[j],H)
        if cost<minCost:
            minCost = cost
    dp.append(minCost)

print(dp[-1])