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

Fixed submission:
N, K = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
    
    
#s = [0] * (N-K)

s = 0
for j in range(K):
    s += p[j]

sm = s

for i in range(N-K):
 #   s[i] = 0
    s = s + p[K+i]- p[i]
    if s > sm:
        sm = s

print( sm/2+0.5*K)

Buggy submission (verdict: Runtime Error):
N, K = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
    
    
s = [0] * (N-K)

for i in range(N-K):
    s[i] = 0
    for j in range(K):         
      s[i] += p[i+j]# /2+0.5

print( (max(s))/2+0.5*K)

Buggy submission (verdict: Runtime Error):
N, K = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
    
    
    
s = [0] * (N-K)

for i in range(N-K):
    s[i] = 0
    for j in range(K):         
      s[i] += p[i+j]/2+0.5

print(max(s))
Problem p03076 (python)

Fixed submission:
import math
import numpy as np

a =  int(input())
b =  int(input())
c =  int(input())
d =  int(input())
e =  int(input())
x = []
s = 0

if a % 10 != 0:
  x.append(a % 10)

if b % 10 != 0:
  x.append(b % 10)

if c % 10 != 0:
  x.append(c % 10)


if d % 10 != 0:
  x.append(d % 10)


if e % 10 != 0:
  x.append(e % 10)

s = 0

if len(x) != 0:
  if np.amin(x) !=0:
    s = 10
  y = np.amin(x)
else:
  s = 0
  y = 0

print(math.ceil(a/10)*10 +  math.ceil(b/10)*10 +  math.ceil(c/10)*10 +  math.ceil(d/10)*10 +  math.ceil(e/10)*10 +  y -s )

Buggy submission (verdict: Runtime Error):

import math

a =  int(input())
b =  int(input())
c =  int(input())
d =  int(input())
e =  int(input())
x = []
s = 0

if a % 10 != 0:
  x.append(a % 10)
  if min(x) == a % 10:
      s = math.ceil(a/10)*10

if b % 10 != 0:
  x.append(b % 10)
  if min(x) == b % 10:
      s = math.ceil(b/10)*10

if c % 10 != 0:
  x.append(c % 10)
  if min(x) == c % 10:
      s = math.ceil(c/10)*10


if d % 10 != 0:
  x.append(d % 10)
  if min(x) == d % 10:
      s = math.ceil(d/10)*10


if e % 10 != 0:
  x.append(e % 10)
  if min(x) == e % 10:
      s = math.ceil(e/10)*10

s = 0

if min(x) !=0:
  s = 10

print(math.ceil(a/10)*10 +  math.ceil(b/10)*10 +  math.ceil(c/10)*10 +  math.ceil(d/10)*10 +  math.ceil(e/10)*10 + min(x) -s )

Buggy submission (verdict: Runtime Error):
import math

a =  int(input())
b =  int(input())
c =  int(input())
d =  int(input())
e =  int(input())
x = []
if a % 10 != 0:
  x.append(a % 10)

if b % 10 != 0:
  x.append(b % 10)

if c % 10 != 0:
  x.append(c % 10)

if d % 10 != 0:
  x.append(d % 10)

if e % 10 != 0:
  x.append(e % 10)

print(math.ceil(a/10)*10 +  math.ceil(b/10)*10 +  math.ceil(c/10)*10 +  math.ceil(d/10)*10 +  math.ceil(e/10)*10 + min(x))
Problem p03149 (python)

Fixed submission:

ll = [1, 9, 7, 4]

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

if ( a in ll ):
  ll.remove(a)
  if ( b in ll ):
    ll.remove(b)
    if ( c in ll ):
      ll.remove(c)
      if ( d in ll ):
        print("YES")
      else:
        print("NO")
    else:
      print("NO")
  else:
    print("NO")
else:
  print("NO")

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

N = int(input())

A = np.array(list(map(int, input().split())))
B = np.array(list(map(int, input().split())))

c = np.sort(A) > np.sort(B)
if np.sum(c) != N:
  print("NO")
else:
  print("YES")

Buggy submission (verdict: Runtime Error):
import re

a = input()
if re.match('(.*)keyence', a):
  print("YES")
else:
  if re.match('k(.*)eyence', a)
    print("YES")
  else:
    print("NO")

Buggy submission (verdict: Runtime Error):
import re

a = input()
if re.match('(.*)keyence', a):
  print("YES")
else:
  if re.match('k(.*)eyence', a)
    print("YES")
  else:
    if re.match('ke(.*)yence', a)
      print("YES")
    else:
      print("NO")

Buggy submission (verdict: Runtime Error):
import re

a = input()
if re.match('(.*)keyence', a):
  print("YES")
else:
  if re.match('k(.*)eyence', a)
    print("YES")
  else:
    if re.match('ke(.*)yence', a)
      print("YES")
    else:
      if re.match('key(.*)ence', a)
        print("YES")
      else:
        if re.match('keye(.*)nce', a)
          print("YES")
        else:
          if re.match('keyen(.*)ce', a)
            print("YES")
          else:
            if re.match('keyenc(.*)e', a)
              print("YES")
            else:
              if re.match('keyence(.*)', a)
                print("YES")
              else:
                print("NO")

Buggy submission (verdict: Runtime Error):

import re

a = input()
if re.match('(.*)keyence', a):
  print("YES")
  return
if re.match('k(.*)eyence', a)
  print("YES")
  return

if re.match('ke(.*)yence', a)
  print("YES")
  return

if re.match('key(.*)ence', a)
  print("YES")
  return

if re.match('keye(.*)nce', a)
  print("YES")
  return

if re.match('keyen(.*)ce', a)
  print("YES")
  return

if re.match('keyenc(.*)e', a)
  print("YES")
  return

if re.match('keyence(.*)', a)
  print("YES")
  return

print("NO")

Buggy submission (verdict: Runtime Error):

ll = [1, 9, 7, 4]

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

if ( a in ll ):
  ll.remove(a)
  if ( b in ll ):
    ll.remove(b)
    if ( c in ll ):
      ll.remove(bc)
      if ( d in ll ):
        print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
l = [1, 9, 7, 4]

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

if ( a in l && b in l && c in l && d in l):
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):

l = [1, 9, 7, 4]

a = int(input())
b = int(input())
c = int(input())
d = int(input())

if ( a in l && b in l && c in l && d in l):
  print("YES")
else:
  print("NO")
Problem p03150 (python)

Fixed submission:
import re

a = input()

if re.match('^([a-zA-Z]*?)keyence$', a):
  print("YES")
else:
  if re.match('^k([a-zA-Z]*?)eyence$', a):
    print("YES")
  else:
    if re.match('^ke([a-zA-Z]*?)yence$', a):
      print("YES")
    else:
      if re.match('^key([a-zA-Z]*?)ence$', a):
        print("YES")
      else:
        if re.match('^keye([a-zA-Z]*?)nce$', a):
          print("YES")
        else:
          if re.match('^keyen([a-zA-Z]*?)ce$', a):
            print("YES")
          else:
            if re.match('^keyenc([a-zA-Z]*?)e$', a):
              print("YES")
            else:
              if re.match('^keyence([a-zA-Z]*?)$', a):
                print("YES")
              else:
                print("NO")

Buggy submission (verdict: Runtime Error):
import re

m = re.match('.*k.*e.*y.*e.*n.*c.*e.*')
if m:
  print("YES")
else:
  print("NO")
Problem p02922 (python)

Fixed submission:
import math
A, B = map(int, input().split())
print(1+math.ceil((B-A)/(A-1)))

Buggy submission (verdict: Runtime Error):
import math
b,a = map(int,input().split())
print(math.ceil((b-1)/(a-1)))

Buggy submission (verdict: Runtime Error):
import math
a,b = map(int,input().split)
print(math.ceil((b-1)/(a-1)))
Problem p02582 (python)

Fixed submission:
S = input()
 
ans = 0
c = []
 
for i in range(len(S)):
    if S[i] =="R":
        ans += 1
    else:
        c.append(ans)
        ans = 0

c.append(ans)
 
print(max(c))

Buggy submission (verdict: Runtime Error):
S = input()
 
ans = 0
c = []
 
for i in range(len(S)):
  if S[i] =="R":
    ans += 1
  else:
    c.append(ans)
    ans = 0
 
 
print(max(c))

Buggy submission (verdict: Runtime Error):
S = input()
 
ans = 0
c = []
 
for i in range(len(S)):
  if S[i] =="R":
    ans += 1
  else:
    c.append(ans)
    ans = 0

 
print(max(c))
Problem p02727 (python)

Fixed submission:
X, Y, A, B, C = map(int,input().split())
P = [int(_) for _ in input().split()]
Q = [int(_) for _ in input().split()]
R = [int(_) for _ in input().split()]

P.sort()
Q.sort()
R.sort()
R.reverse()

P = P[A-X:]
Q = Q[B-Y:]

P.append(10**9+1)
Q.append(10**9+1)
R.append(0)


i = 0
j = 0


while min(P[i],Q[j])<R[i+j]:
    if P[i] < Q[j]:
        i += 1
    else:
        j += 1
    if i+j == C:
        break

P.remove(10**9+1)
Q.remove(10**9+1)
R.remove(0)

ans = 0
for e in P[i:]:
    ans = ans + e
for e in Q[j:]:
    ans = ans + e
for a in range(i+j):
    ans = ans + R[a]

print(ans)

Buggy submission (verdict: Runtime Error):
X, Y, A, B, C = map(int,input().split())
P = [int(_) for _ in input().split()]
Q = [int(_) for _ in input().split()]
R = [int(_) for _ in input().split()]

P.sort()
Q.sort()
R.sort()
R.reverse()

P = P[A-X:]
Q = Q[B-Y:]

i = 0
j = 0

while min(P[i],Q[j])<R[i+j]:
    if P[i] < Q[j]:
        i += 1
        if i+j == C:
            break
        if i == X-1:
            if Q[j] > R[i+j]:
                break
    else:
        j += 1
        if i+j == C:
            break
        if j == Y-1:
            if P[i] > R[i+j]:
                break
    if i+j == C:
        break

ans = 0
for e in P[i:]:
    ans = ans + e
for e in Q[j:]:
    ans = ans + e
for a in range(i+j):
    ans = ans + R[a]

print(ans)

Buggy submission (verdict: Runtime Error):
X, Y, A, B, C = map(int,input().split())
P = [int(_) for _ in input().split()]
Q = [int(_) for _ in input().split()]
R = [int(_) for _ in input().split()]

P.sort()
Q.sort()
R.sort()
R.reverse()

P = P[A-X:]
Q = Q[B-Y:]

i = 0
j = 0

while min(P[i],Q[j])<R[i+j]:
    if P[i] < Q[j]:
        i += 1
    else:
        j += 1
    if i+j == C:
        break

ans = 0
for e in P[i:]:
    ans = ans + e
for e in Q[j:]:
    ans = ans + e
for a in range(i+j):
    ans = ans + R[a]

print(ans)

Buggy submission (verdict: Runtime Error):
X, Y, A, B, C = map(int,input().split())
P = [int(_) for _ in input().split()]
Q = [int(_) for _ in input().split()]
R = [int(_) for _ in input().split()]

P.sort()
Q.sort()
R.sort()
R.reverse()

P = P[A-X:]
Q = Q[B-Y:]

i = 0
j = 0

while min(P[i],Q[j])<R[i+j] and i+j<C:
    if P[i] < Q[j]:
        i += 1
    else:
        j += 1
    if i+j == C:
        break

ans = 0
for e in P[i:]:
    ans = ans + e
for e in Q[j:]:
    ans = ans + e
for a in range(i+j):
    ans = ans + R[a]

print(ans)
Problem p03231 (python)

Fixed submission:
N, M = map(int, input().split())
S = input()
T = input()

def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    if x%y == 0:
        return y
    else:
        while x%y != 0:
            z = x%y
            x = y
            y = z
        else:
            return z

def lcm(m,n):
    return int(m * n /gcd(m,n))

d = gcd(N,M)
l = lcm(N,M)

s = [0 for i in range(0,d)]
t = [0 for i in range(0,d)]

a = int(l/M)
b = int(l/N)

for i in range(0,d):
    s[i] = S[i*a]
    t[i] = T[i*b]

if s == t:
    print(l)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
import math

N, M = map(int, input().split())
S = input()
T = input()

def lcm(x, y):
    return int((x * y) / math.gcd(x, y))

d = math.gcd(N,M)
l = lcm(N,M)

s = [0 for i in range(0,d)]
t = [0 for i in range(0,d)]

a = int(l/M)
b = int(l/N)

for i in range(0,d):
    s[i] = S[i*a]
    t[i] = T[i*b]

if s == t:
    print(l)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
import math

N, M = map(int, input().split())
S = input()
T = input()

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

d = math.gcd(N,M)
l = lcm(N,M)

s = [0 for i in range(0,d)]
t = [0 for i in range(0,d)]

a = l//M
b = l//N

for i in range(0,d):
    s[i] = S[i*a]
    t[i] = T[i*b]

if s == t:
    print(l)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
import math

N, M = map(int, input().split())
S = input()
T = input()

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

d = math.gcd(N,M)
l = lcm(N,M)

s = [0 for i in range(0,d)]
t = [0 for i in range(0,d)]

for i in range(0,d):
    s[i] = S[i*(l//M)]
    t[i] = T[i*(l//N)]

if s == t:
    print(l)
else:
    print(-1)
Problem p03244 (python)

Fixed submission:
n = int(input())
v = [int(i) for i in input().split()]
m = n//2

a = [v[2*i] for i in range(0,m)]
b = [v[2*i+1] for i in range(0,m)]

def mode(arr):
        r = [0] * (max(arr) + 1)
        for a in arr:
            r[a] += 1
        return r.index(max(r))

A = mode(a)
B = mode(b)

v.remove(A)

if v == []:
    print(m)
    exit()
if A == B:
    if a.count(A) < b.count(B):
        a.remove(A)
        C = mode(a)
        print(n - a.count(C) - b.count(B))
    else:
        if b.count(B) == m:
            print(n - m)
        else:
            if a.count(A) == b.count(B):
                t = a.count(A)
                a.remove(A)
                b.remove(B)
                D = mode(a)
                E = mode(b)
                if a.count(D) > b.count(E):
                    print(n - t - a.count(D))
                else:
                    print(n - t - b.count(E))
            else:
                b.remove(B)
                C = mode(b)
                print(n - a.count(A) - b.count(C))
else:
    print(n - a.count(A) - b.count(B))

Buggy submission (verdict: Runtime Error):
n = int(input())
v = [int(i) for i in input().split()]
m = n//2

a = [v[2*i] for i in range(0,m)]
b = [v[2*i+1] for i in range(0,m)]

def mode(arr):
        r = [0] * (max(arr) + 1)
        for a in arr:
            r[a] += 1
        return r.index(max(r))

A = mode(a)
B = mode(b)

if v.remove(A) == []:
    print(m)
    exit()
if A == B:
    if a.count(A) < b.count(B):
        C = mode(a.remove(A))
        print(n - a.count(C) - b.count(B))
    else:
        if b.count(B) == m:
            print(n)
        else:
            C = mode(b.remove(B))
            print(n - a.count(A) - b.count(C))
else:
    print(n - a.count(A) - b.count(B))

Buggy submission (verdict: Runtime Error):
n = int(input())
v = [int(i) for i in input().split()]
m = n//2

a = [v[2*i] for i in range(0,m)]
b = [v[2*i+1] for i in range(0,m)]

def mode(arr):
        r = [0] * (max(arr) + 1)
        for a in arr:
            r[a] += 1
        return r.index(max(r))

A = mode(a)
B = mode(b)

if v.remove(A) == []:
    print(m)
    exit()
if A == B:
    if a.count(A) < b.count(B):
        C = mode(a.remove(A))
        print(n - a.count(C) - b.count(B))
    else:
        if b.count(B) == m:
            print(n-m)
        else:
            C = mode(b.remove(B))
            print(n - a.count(A) - b.count(C))
else:
    print(n - a.count(A) - b.count(B))
Problem p02615 (python)

Fixed submission:
# Problem D - Chat in a Circle

from collections import deque

# input
N = int(input())
a_nums = list(map(int, input().split()))

# initialization
a_nums = sorted(a_nums, reverse=True)
point_list = deque([a_nums[0]])
point = 0

# count
for i in range(1, N):
    a = a_nums[i]
    point += point_list.popleft()
    point_list.append(a)
    point_list.append(a)

# output
print(point)

Buggy submission (verdict: Runtime Error):
# Problem D - Chat in a Circle

# input
N = int(input())
a_nums = list(map(int, input().split()))

# initialization
a_nums = sorted(a_nums, reverse=True) # sort
a_max = max(a_nums)
a_count_list = [0]*(a_max + 1)
a_count_list[a_nums[0]] += 1
point = 0
max_i = a_nums[0]

# count
for i in range(1, N):
    a = a_nums[i]
    while max_i>0 and a_count_list[max_i]==0:
        max_i -= 1
    a_count_list[max_i] -= 1
    point += max_i # add point
    a_count_list[a] += 2

# output
print(point)
Problem p02691 (python)

Fixed submission:
# Problem E - This Message Will Self-Destruct

# input
N = int(input())
a_nums = list(map(int, input().split()))

# initialization
num_dic = {}
ans = 0

# count
for i in range(1, N+1):
    a = a_nums[i-1] + i
    if not a in num_dic:
        num_dic[a] = 1
    else:
        num_dic[a] += 1

# count 2
for j in range(1, N+1):
    b = j - a_nums[j-1]
    if b in num_dic:
        ans += num_dic[b]

# output
print(ans)

Buggy submission (verdict: Runtime Error):
# Problem E - This Message Will Self-Destruct in 5s

# input
N = int(input())
a_nums = list(map(int, input().split()))

# initialization
tmp_1 = [0]*(10**6)
ans = 0

# count
for i in range(1, N+1):
    tmp_1[i + a_nums[i-1]] += 1

# count 2
for j in range(1, N+1):
    if j-a_nums[j-1]>=0:
        ans +=  tmp_1[j-a_nums[j-1]]

# output
print(ans)
Problem p02727 (python)

Fixed submission:
# Problem E - Red and Green Apples

from collections import deque

# input
X, Y, A, B, C = map(int, input().split())
red_apples = sorted(list(map(int, input().split())), reverse=True)
green_apples = sorted(list(map(int, input().split())), reverse=True)
mushoku_apples = sorted(list(map(int, input().split())), reverse=True)

# initialization
red_apples = red_apples[:X]
green_apples = green_apples[:Y]
ans_list = deque([])
for r in red_apples:
    ans_list.append(r)
for g in green_apples:
    ans_list.append(g)
for m in mushoku_apples:
    ans_list.append(m)
ans_list = sorted(ans_list, reverse=True)

# output
i = X+Y
ans = sum(ans_list[:i])
print(ans)

Buggy submission (verdict: Runtime Error):
# Problem E - Red and Green Apples

from collections import deque

# input
X, Y, A, B, C = map(int, input().split())
red_list = list(map(int, input().split())) # red apple
green_list = list(map(int, input().split())) # green apple
transparent_list = list(map(int, input().split())) # transparent apple

# initialization
red_list = deque(sorted(red_list, reverse=True))
green_list = deque(sorted(green_list, reverse=True))
transparent_list = deque(sorted(transparent_list, reverse=True))
ans_list = deque([])

# count
while X>0 or Y>0:
    red = -1
    green = -1
    toumei = -1
    if C>=0:
        toumei = transparent_list[0]
    max_v = 0

    if X>0:
        red = red_list[0]

    if Y>0:
        green = green_list[0]

    # max value check
    if red>=green and red>=toumei:
        max_v = red_list.popleft()
        X -= 1
    elif green>=red and green>=toumei:
        max_v = green_list.popleft()
        Y -= 1
    else:
        # min value check
        if X>0 and Y>0:
            if red<=green:
                max_v = transparent_list.popleft()
                X -= 1
                C -= 1
                red_list.popleft()
            else:
                max_v = transparent_list.popleft()
                Y -= 1
                C -= 1
                green_list.popleft()
        elif X>0:
            max_v = transparent_list.popleft()
            X -= 1
            C -= 1
            red_list.popleft()
        else:
            max_v = transparent_list.popleft()
            Y -= 1
            C -= 1
            green_list.popleft()

    # list insert
    ans_list.append(max_v)

# output
ans = sum(ans_list)
print(ans)
Problem p02756 (python)

Fixed submission:
# Problem D - String Formation

from collections import deque

# input process
S = input().replace("\n", "")
S = deque(list(S))
Q = int(input()) # query number

# initialization
sento = 1

# process
for i in range(Q):
    query_num = input()
    # クエリが１の時
    if query_num[0]=="1":
        # 反転処理
        if sento==1:
            sento = 10
        elif sento==10:
            sento = 1
    elif query_num[0]=="2":
        n, f, c = query_num.split()
        f = int(f)
        if f==1: # 先頭追加処理
            # 先頭の位置によって変わる
            if sento==1:
                S.appendleft(c)
            elif sento==10:
                S.append(c)
        elif f==2: # 末尾追加処理
            if sento==1:
                S.append(c)
            elif sento==10:
                S.appendleft(c)

# output process
if sento==1:
    print("".join(S))
else:
    print("".join(list(S)[::-1]))

Buggy submission (verdict: Runtime Error):
# Problem D - String Formation

# input process
S = input()
Q = int(input()) # query number

# initialization
sento = 1
mae = [] # mae queue
usiro = [] # usiro

# process
for i in range(Q):
    query_num = input()
    query_1 = int(query_num[0])
    # クエリが１の時
    if query_1==1 and sento==1:
        sento = 10
    elif query_1==1:
        sento = 1
    else: # query num 2
        n, f, c = query_num.split()
        f = int(f)
        if f==1: # 先頭追加処理
            # 先頭の位置によって変わる
            if sento==1:
                mae.append(c)
            else:
                usiro.append(c)
        else: # 末尾追加処理
            if sento==1:
                usiro.append(c)
            else:
                mae.append(c)

# output process
if sento==1:
    ans = ""
    mae.reverse()
    for m in mae:
        ans = ans + m
    ans = ans + S
    for u in usiro:
        ans = ans + s
    print(ans)
else:
    ans = ""
    usiro.reverse()
    for u in usiro:
        ans = ans + u
    ans = ans + S[::-1]
    for m in mae:
        ans = ans + m
    print(ans)

Buggy submission (verdict: Runtime Error):
# Problem D - String Formation

# input process
S = input()
Q = int(input()) # query number

# initialization
sento = 1
mae_str = []
usiro = []

# process
for i in range(Q):
    query_num = input()
    # クエリが１の時
    if query_num=="1" and sento==1:
        sento = 10
    elif query_num=="1":
        sento = 1
    else: # query num 2
        n, f, c = query_num.split()
        f = int(f)
        if f==1: # 先頭追加処理
            # 先頭の位置によって変わる
            if sento==1:
                mae_str.append(c)
            else:
                usiro.append(c)
        else: # 末尾追加処理
            if sento==1:
                usiro.append(c)
            else:
                mae_str.append(c)

# output process
if sento==1:
    ans = ""
    for m in mae_str[::-1]:
        ans = ans + m
    ans = ans + S
    for u in usiro:
        ans = ans + s
    print(ans)
else:
    ans = ""
    for u in usiro[::-1]:
        ans = ans + u
    ans = ans + S[::-1]
    for m in mae_str:
        ans = ans + m
    print(ans)
Problem p02783 (python)

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

count = 0
while H > 0:
    H = H - A
    count = count + 1

print(count)

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

memo_count = {}
def searchCount(h):
    if h==1: # 脱出条件
        return 1
    elif h in memo_count:
        return memo_count[h]
    else:
        h_half = int(h / 2)
        memo_count[h] = 1 + 2*searchCount(h_half)
        return memo_count[h]

print(searchCount(H))
Problem p02787 (python)

Fixed submission:
# ダイナミック・プログラミング
# PythonではTLEを起こしてしまう例

INF = float('inf')

H, N = map(int, input().split())
A = []
B = []

for i in range(N):
    a_i, b_i = map(int, input().split())
    A.append(a_i)
    B.append(b_i)

dp = [[INF]*(H+1) for i in range(N+1)] # DP用配列
dp[0][0] = 0 # 初期化処理
for i in range(0,N):
    for j in range(0,H+1):
        a, b = j+A[i], H
        min_h = a
        if a>b:
            min_h = b
        a, b = dp[i+1][j], dp[i][j]
        if a>b:
            dp[i+1][j] = b
        a, b = dp[i+1][min_h], dp[i+1][j]+B[i]
        if a>b:
            dp[i+1][min_h] = b

print(dp[N][H])

Buggy submission (verdict: Runtime Error):
# ダイナミック・プログラミング(DP)

H, N = map(int, input().split())
magic_list = []

for i in range(N):
    A, B = map(int, input().split())
    magic_list.append([A, B])


dp_memo = {} # メモ化再帰
def dp_magic_2(HP):
    mp_list = []
    if HP<=0:
        return 0
    elif HP in dp_memo:
        return dp_memo[HP]
    else:
        for m in magic_list:
            mp_list.append(dp_magic_2(HP-m[0]) + m[1])
        result_mp = sorted(mp_list)[0]
        dp_memo[HP] = result_mp
        return result_mp

print(dp_magic_2(H))

Buggy submission (verdict: Runtime Error):
# ダイナミック・プログラミング(DP)

H, N = map(int, input().split())
magic_list = []

for i in range(N):
    A, B = map(int, input().split())
    magic_list.append([A, B])


dp_memo = {} # メモ化再帰
def dp_magic_2(HP):
    mp_list = []
    if HP<=0:
        return 0
    elif HP in dp_memo:
        return dp_memo[HP]
    else:
        for m in magic_list:
            mp_list.append(dp_magic_2(HP-m[0]) + m[1])
        result_mp = min(mp_list)
        dp_memo[HP] = result_mp
        return result_mp

print(dp_magic_2(H))
Problem p03324 (python)

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


for i in range(1, 100000000):
    if i % (100 ** d) == 0 and i % (100 * 100 ** d) != 0:
        n -= 1
    if n == 0:
        print(i)
        exit()

Buggy submission (verdict: Runtime Error):
# Problem B - Ringo's Favorite Numbers

# input
D, N = map(int, input().split())

# initialization
ans = 0
tmp_list = []
tmp = 100**D

# calc
i = 1
while not i>N:
    ans = tmp * i
    if not ans%(tmp*100)==0:
        tmp_list.append(ans)
        i = i + 1
    else:
        i = i + 1

#output
ans = tmp_list[N-1]
print(ans)