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

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
c = 0
for i in range(N-1):
  if H[i] > H[i+1]:
    H[i+1] = H[i+1] + 1
  if H[i] <= H[i+1]:
    c += 1
if c == N-1:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
c = 0
for i in range(N-1):
  if H[i] > H[i+1]:
    H[i+1] = H[i+1] + 1
  if H[i] <= H[i+1]:
    C += 1
if C == N-1:
  print('Yes')
else:
  print('No')
Problem p02945 (python)

Fixed submission:
a, b = (int(i) for i in input().split())
print(max(a+b, a-b, a*b))

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

return max(A+B, A-B, A*B)

Buggy submission (verdict: Runtime Error):
return max(A+B, A-B, A*B)
Problem p03105 (python)

Fixed submission:
a, b, c = map(int, input().split())
res = b // a
if res > c:
  res = c
print(res)

Buggy submission (verdict: Runtime Error):
L = list(input())
L_ = []
a = L.pop(0)
cnt = 0

while True:
    if len(L) == 0:
        break
    else:
        b = L.pop(0)
    if a is not b:
        cnt += 1
        # L = L_ + L
        # L_ = []
        a = L_.pop(0)
    elif a is b:
        L_.append(a)
        a = b
    # print(L_, a,  L)

print(cnt * 2)
Problem p02945 (python)

Fixed submission:
a, b = map(int, input().split(' '))
ans = max(a+b, a-b, a*b)
print(ans)

Buggy submission (verdict: Runtime Error):
a, b = input().split(' ')
index = a + b
if(a - b > index):
  index = a - b
elif(a * b > index):
  index = a * b
print(index)
Problem p02946 (python)

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

if(k == 1):
    print(x)
else:
    ans = [i for i in range(x-k+1, x+k)]
    print(" ".join(map(str, ans)))

Buggy submission (verdict: Runtime Error):
a = 2000001
b = 1000000
k, x = map(int, input().split())

if(k == 1):
    print(x)
else:
    ans = [i for i in range(x-k+1, x+k-1)]
    print(" ".join(ans))
Problem p02945 (python)

Fixed submission:
a, b = map(int, input().split())
print(max(a + b, a - b, a * b))

Buggy submission (verdict: Runtime Error):
a, b = map(int input().split())
print(max(a + b, a - b, a * b))
Problem p04044 (python)

Fixed submission:
N = list(map(int, input().split()))
string = [input() for s in range(N[0])]
string.sort()
print(''.join(string))

Buggy submission (verdict: Runtime Error):
N = list(map(int, input().split()))
string = [input() for s in range(N[1])]
string.sort()
print(''.join(string))

Buggy submission (verdict: Runtime Error):
N = list(map(int, input().split()))
string = [input() for s in range(N[1])]
string.sort()
print(string)
Problem p02945 (python)

Fixed submission:
# your code goes here
a, b = map(int,input().split())
c1 = a+b
c2 = a-b
c3 = a*b
if c1>c2 and c1>c3:
	print(c1)
elif c2>c3:
	print(c2)
else:
	print(c3)

Buggy submission (verdict: Runtime Error):
# your code goes here
a, b = int(input().split())
c1 = a+b
c2 = a-b
c3 = a*b
if c1>c2 and c1>c3:
	print(c1)
elif c2>c3:
	print(c2)
else:
	print(c3)
Problem p03379 (python)

Fixed submission:
n = int(input())
x = [int(i) for i in input().split()]
a = x[:]
a.sort()

mid = n //2
m1 = a[mid-1]
m2 = a[mid]
for i in range(n):
    if x[i] <= m1:
        ans = m2
    else:
        ans = m1
 
    print(ans)

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

for i in range(n):
    a = x[:]
    del a[i]
    a.sort()
    print(a[(n-1)/2-1])
Problem p03623 (python)

Fixed submission:
x, a, b = (int(i) for i in input().split())
if abs(x-a) < abs(x-b):
    print('A')
else:
    print('B')

Buggy submission (verdict: Runtime Error):
x, a, b = (int(i) for i in input().split())
if abs(x-a) < abs(x-b):
    print(A)
else:
    print(B)
Problem p03624 (python)

Fixed submission:
alphabet = ([chr(ord('a') + i) for i in range(26)])
str = input()
str = list(str)
ans = alphabet

for i in str:
    try:
        ans.remove(i)
    except:
        continue
try:
    print(ans[0])
except:
    print("None")

Buggy submission (verdict: Runtime Error):
import sys

args = sys.argv
alphabet = ([chr(ord('a') + i) for i in range(26)])
str = args[1]
str = list(str)
ans = alphabet

for i in str:
    try:
        ans.remove(i)
    except:
        continue
try:
    print(ans[0])
except:
    print("None")

Buggy submission (verdict: Runtime Error):
import sys

args = sys.argv
alphabet = ([chr(ord('a') + i) for i in range(26)])
str = args[1]
str = list(str)
ans = alphabet

for i in str:
    ans.remove(i)

try:
    print(ans[0])
except:
    print("None")

Buggy submission (verdict: Runtime Error):
import sys

args = sys.argv
alphabet = ([chr(ord('a') + i) for i in range(26)])
str = args[1]
ans = alphabet

for i in alphabet:
    if i in str:
        ans.remove(i)

print(ans[0])

Buggy submission (verdict: Runtime Error):
import sys

args = sys.argv
alphabet = ([chr(ord('a') + i) for i in range(26)])
str = args[1]
ans = alphabet

for i in alphabet:
    if i in str:
        ans.remove(i)

print(ans[0])
Problem p02945 (python)

Fixed submission:
# -*- coding: utf-8 -*-
# 整数の入力
# a = int(input())
# スペース区切りの整数の入力
a, b = map(int, input().split())
# 文字列の入力
# s = input()
# 出力
print("{}".format(max(max(a+b, a-b), a*b)))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
# スペース区切りの整数の入力
ar = []
for i in range(n):
  ar.append("".join(sorted(input())))

#for t in ar:
#  print(t)
#for i in range(n):
#  for j in range(i+1, n):
#    if ar[i] == ar[j]:
#      ar[j] = ar[i]

count = 0
#for i in range(n):
#  for j in range(i+1, n):
#    if ar[i] is ar[j]:
#      count = count + 1

for i in range(n):
  count = count + ar[i+1:].count(ar[i])

print(count)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
# a = int(input())
# スペース区切りの整数の入力
a, b = map(int, input().split())
# 文字列の入力
# s = input()
# 出力
print("{}".format(max(max(a+b, a-b), a*b))
Problem p02947 (python)

Fixed submission:
# -*- coding: utf-8 -*-
# 整数の入力
N = int(input())

# スペース区切りの整数の入力
ar = []
for i in range(N):
  l = list(input())
  l.sort()
  ar.append("".join(l).__hash__())

# 数を数える
list = {}
for i in ar:
  if i in list:
    list[i] = list[i] + 1
  else:
    list[i] = 1
  
count = 0
for i in list.values():
  n = i - 1
  count = count + int(((n * (n + 1)) / 2))

print(count)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N, M = map(int, input().split())
A = [] # 日後
B = [] # 報酬
for i in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)

c = 0
for i in range(M):
  if A[i] + i < M:
    c = c + B[i]
  
# 文字列の入力
# s = input()
# 出力
print(c)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
# スペース区切りの整数の入力
ar = []
for i in range(n):
  ar.append("".join(list(input()).sort()))

count = 0

for i in range(n):
  count = count + ar[i+1:].count(ar[i])

print(count)
Problem p02982 (python)

Fixed submission:
def distance(a, b):
    s = 0
    for i in range(len(a)):
        s += (a[i] - b[i]) ** 2

    return s ** 0.5

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

X = []

for i in range(N):
    X.append([int(x) for x in input().split()])

count = 0

for i in range(N):
    for j in range(i+1, N):
        if distance(X[i], X[j]).is_integer():
            count += 1

print(count)

Buggy submission (verdict: Runtime Error):
def distance(a, b):
    s = 0
    for i in range(len(a)):
        s += (a[i] - b[i]) ** 2

    return s ** 0.5

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

X = []

for i in range(D):
    X.append([int(x) for x in input().split()])

count = 0

for i in range(D):
    for j in range(i+1, D):
        if distance(X[i], X[j]).is_integer():
            count += 1

print(count)
Problem p02945 (python)

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

tasu = a+b
kakeru = a*b
hiku = a-b

print(max(tasu,kakeru,hiku))

Buggy submission (verdict: Runtime Error):
a,b = int(input().split())

tasu = a+b
kakeru = a*b
hiku = a-b

print(max(tasu,kakeru,hiku))

Buggy submission (verdict: Runtime Error):
a,b = int(input())

tasu = a+b
kakeru = a*b
hiku = a-b

print(max(tasu,kakeru,hiku))
Problem p02971 (python)

Fixed submission:
n = int(input())
a = list(int(input()) for _ in range(n))

max_list = sorted(a,reverse=True)[:2]
num = max_list[0]
num2 = max_list[1]

for i in range(n):
    if a[i] < num:
        print(num)
    else:
        print(num2)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(int(input()) for _ in range(n))

num = max(a)
try:
    num2 = max([k for k in a if k != num])
except:
    pass
for i in range(n):
    if a[i] < num:
        print(num)
    else:
        print(num2)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(int(input()) for _ in range(n))

num = max(a)
num2 = max([k for k in a if k != num])
for i in range(n):
    if a[i] < num:
        print(num)
    else:
        print(num2)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(int(input()) for _ in range(n))

num = max(a)
for i in range(n):
    if a[i] < num:
        print(num)
    else:
        b = a.copy()
        int(b.pop(i))
        print(max(b))
Problem p03068 (python)

Fixed submission:
import sys

n = int(input()) 
s = list(input()) 
k = int(input()) 

word = s[k-1]
for i in s:
    if i != word:
        sys.stdout.write('*')
    else:
        sys.stdout.write(i)

Buggy submission (verdict: Runtime Error):
import sys

n = int(input()) 
s = list(input()) 
k = int(input()) 

word = s[k]
for i in s:
    if i != word:
        sys.stdout.write('*')
    else:
        sys.stdout.write(i)
Problem p03086 (python)

Fixed submission:
S = list(input())

num = 0
num_list = [0]
for i in S:
    if i == "A" or i == "T" or i == "G" or i == "C":
        num += 1
        num_list.append(num)
    else:
        num_list.append(num)
        num = 0
print(max(num_list))

Buggy submission (verdict: Runtime Error):
S = list(input())

num = 0
num_list = []
for i in S:
    if i == "A" or i == "T" or i == "G" or i == "C":
        num += 1
    else:
        num_list.append(num)
        num = 0
print(max(num_list))

Buggy submission (verdict: Runtime Error):
S = list(input())

num = 0
num_list = []
for i in S:
    if i == "A" or i == "T" or i == "G" or i == "C":
        num += 1
    else:
        num_list.append(num)
        num = 0
print(max(num_list))

Buggy submission (verdict: Runtime Error):
S = list(input())

num = 0
num_list = []
for i in S:
    if i == "A" or i == "T" or i == "G" or i == "C":
        num += 1
    else:
        num_list.append(num)
print(max(num_list))
Problem p02945 (python)

Fixed submission:
#AtCoder Beginner Contest 127
array = list(map(int, input().split()))

plus = array[0] + array[1]
minus = array[0] - array[1]
product = array[0] * array[1]

print(max(plus, minus, product))

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

s = []
for i in range(N):
    s.append(''.join(sorted(input())))

s = sorted(s)

tmp_count = 1
count = 0
for i in range(0, len(s)-1):
    if s[i] == s[i+1]:
        tmp_count += 1
    else:
        count += tmp_count * (tmp_count - 1) // 2
        tmp_count = 1
count += tmp_count * (tmp_count - 1) // 2
print(count)
Problem p02945 (python)

Fixed submission:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
a, b = map(int, input().split())

# 出力
print(max([a+b, a-b, a*b]))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
# スペース区切りの整数の入力
b = int(input())

# 出力
print(max([a+b, a-b, a*b]))
Problem p02945 (python)

Fixed submission:
a,b=map(int, input().split())
print(sorted([a+b,a-b,a*b])[-1])

Buggy submission (verdict: Runtime Error):
a,b=map(int, input().split())
print(sort([a+b,a-b,a*b][-1]))
Problem p02947 (python)

Fixed submission:
from collections import Counter
n = int(input())
word_l = list()
for _ in range(n):
  word = ''.join(sorted(list(input())))
  word_l.append(word)
  
word_counter = Counter(word_l)
print('{}'.format(sum(map(lambda x: sum(range(x)), word_counter.values()))))

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
word_l = list()
for _ in range(n):
  word = ''.join(sorted(list(input())))
  word_l.append(word)
  
word_counter = Counter(word_l)
print('{}'.format(sum(word_counter.values()) - n)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
word_l = list()
for _ in range(n):
  word = ''.join(sort(list(input())))
  word_l.append(word)
  
word_counter = Counter(word_l)
print('{}'.format(sum(word_counter.values()) - n))

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
word_l = list()
for _ in range(n):
  word = ''.join(sort(list(input())))
  word_l.append(word)
  
word_counter = Counter(word_l)
print('{}'.format(sum(word_counter.values()) - n))

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
word_l = list()
for _ in range(n):
  word = ''.join(sort(list(input())))
  word_l.append(word)
  
word_counter = Counter(word_l)
print('{}'.format(sum(word_counter.values()) - n)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
for _ in range(n):
  word = ''.join(sort(list(input())))
  word_l.append(word)
  
word_counter = Counter(word_l)
print('{}'.format(sum(word_counter.values()) - n)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = 5
for _ in range(n):
  word = ''.join(sort(list(input())))
  word_l.append(word)
  
word_counter = Counter(word_l)
print('{}'.format(sum(word_counter.values()) - n)
Problem p02945 (python)

Fixed submission:
a, b = [int(i) for i in input().split()]

print(max([a + b, a - b, a * b]))

Buggy submission (verdict: Runtime Error):
a,b = [int(i) for i in input()]

print(max([a + b, a - b, a * b]))
Problem p03160 (python)

Fixed submission:
n = int(input())
h = [int(hi) for hi in input().split()]

inf = float('inf')

dp = [inf] * n

dp[0] = 0

for i in range(n):
  dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
  dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

print(dp[-1])

Buggy submission (verdict: Runtime Error):
n, k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
 
INF = float("inf")
 
dp = [INF] * n
 
dp[0] = 0
 
for i in range(1, n):
  for j in range(1, k+1):
    if 0 <= (i-j):
      dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]))
 
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
def rec(i):

  if dp[i] < inf:
    return dp[i]

  if i == 0:
    return 0

  res = inf
  res = min(res, rec(i-1) + abs(h[i] - h[i-1]))
  if i > 1:
    res = min(res, rec(i-2) + abs(h[i] - h[i-2]))

  dp[i] = res

  return res


n = int(input())
h = [int(hi) for hi in input().split()]

inf = float('inf')

dp = [inf] * n

print(rec(n-1))
Problem p03164 (python)

Fixed submission:
N, W = [int(x) for x in input().split()]

w, v = [], []
MAX_V = 100001
INF = 1000000000001

for i in range(N):
  wi, vi = [int(x) for x in input().split()]
  w.append(wi)
  v.append(vi)

dp = []
for i in range(N+1):
  dp.append([INF] * MAX_V)

dp[0][0] = 0

for i in range(N):
  for sum_v in range(MAX_V):
    if sum_v - v[i] >= 0:
      dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v - v[i]] + w[i])
      
    dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v])


res = 0
for sum_v in range(MAX_V):
  if dp[N][sum_v] <= W:
    res = sum_v
  
print(res)

Buggy submission (verdict: Runtime Error):
N, W = [int(x) for x in input().split()]

w, v = [], []
MAX_V = 10100
INF = 100000000001

for i in range(N):
  wi, vi = [int(x) for x in input().split()]
  w.append(wi)
  v.append(vi)

dp = []
for i in range(N+1):
  dp.append([INF] * MAX_V)

dp[0][0] = 0

for i in range(N):
  for sum_v in range(MAX_V):
    if sum_v - v[i] >= 0:
      dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v - v[i]] + w[i])
      
    dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v])


res = 0
for sum_v in range(MAX_V):
  if dp[N][sum_v] <= W:
    res = sum_v
  
print(res

Buggy submission (verdict: Runtime Error):
n, w = [int(x) for x in input().split()]
W = []
V = []
for i in range(n):
  wi, vi = [int(x) for x in input().split()]
  W.append(wi)
  V.append(vi)
 
dp = []
for i in range(n+1):
  dp.append([0]*(w+1))
 
for i in range(n):
  for sum_w in range(w + 1):
    # 選ぶ場合
    if sum_w - W[i] >= 0:
      dp[i+1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w - W[i]] + V[i])
 
    # 選ばない場合
    dp[i+1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w])
 
print(dp[n][w])
Problem p03494 (python)

Fixed submission:
n = input()
a = [int(value) for value in input().split()]

def num_two(input_number):
  number = input_number
  count = 0
  while True:
    if number % 2 == 0:
      count += 1
      number = number / 2
    else:
      break
  return count

num_twos = [num_two(ai) for ai in a]
# print(num_twos)
print(min(num_twos))

Buggy submission (verdict: Runtime Error):
n = input()
a = [int(value) for value in input()]

def num_two(input_number):
  number = input_number
  count = 0
  while True:
    if number / 2 == 0:
      count += 1
      number = number / 2
    else:
      break
  return count

num_twos = [num_two(ai) for ai in a]
print(min(num_twos))
Problem p03076 (python)

Fixed submission:
l = list(int(input()) for i in range(5))
A=[]
sum=0

for i in range(5):
    if l[i]%10 == 0:
        A.append(0)
    else:
        A.append(10-(l[i]%10))
    
if A[0]==A[1]==A[2]==A[3]==A[4]==0:
    print(l[0]+l[1]+l[2]+l[3]+l[4])
else:
    for k in range(5):
        sum += l[k]+A[k]
    print(sum-max(A))

Buggy submission (verdict: Runtime Error):
l = list(int(input()) for i in range(5))
A=[]
sum1=0
sum2=0

for i in range(5):
    if l[i]%10 == 0:
        A.append(0)
    else:
        A.append(10-(l[i]%10))
    
if A[0]==A[1]==A[2]==A[3]==A[4]==0:
    print(sum1 = l[0]+l[1]+l[2]+l[3]+l[4])
else:
    for k in range(5):
        sum2 += l[k]+A[k]
    print(sum2-max(A))
Problem p03106 (python)

Fixed submission:
A,B,K = map(int,input().split())
l=[]
for i in range(1,min(A,B)+1):
    if (A%i + B%i) == 0:
        l.append(i)
    else:
        pass
print(l[-K])

Buggy submission (verdict: Runtime Error):
A,B,K = map(int,input().split())
l=[]
for i in range(1,max(A,B)):
    if (A%i + B%i) == 0:
        l.append(i)
    else:
        pass
if A == 1 & B == 1:
    print(1)
else:
    print(l[-K])
Problem p03109 (python)

Fixed submission:
y,m,d = list(input().split("/"))
s = int(y+m+d)

if s <= 20190430:
    print("Heisei")
else:
    print("TBD")

Buggy submission (verdict: Runtime Error):
y,m,d = list(input().split("/"))
s = y+m+d

if s <= 20190430:
    print("Heisei")
else:
    print("TBD")
Problem p02945 (python)

Fixed submission:
A, B = [int(i) for i in input().split()]

print(max(A+B, A-B, A*B))

Buggy submission (verdict: Runtime Error):
from itertools import combinations

N = int(input())
s = [sorted(input(i)) for i in range(N)]

c = len([i for i in combinations(s, 2) if i[0] == i[1]])
print(c)
Problem p02999 (python)

Fixed submission:
X, A = input().split(" ")
print(0 if X < A else 10)

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

N, K = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
a.insert(0, 0)
a_sum = np.tile(np.cumsum(np.array(a, dtype=np.int64)), (N+1, 1))
print(np.count_nonzero(a_sum - a_sum.T >= K))
Problem p03001 (python)

Fixed submission:
W, H, x, y = map(int, input().split(" "))
area = W * H / 2
isMultiple = 1 if W/2 == x and H/2 == y else 0

print("{area} {isMultiple}".format(area=area, isMultiple=isMultiple))

Buggy submission (verdict: Runtime Error):
W, H, x, y = map(int, input().split(" "))
area = W * H / 2
isMultiple = 1 if W/2 == x and H/2 == y else 0

print(f"{area} {isMultiple}")
Problem p02945 (python)

Fixed submission:
a, b = map(int, input().split())
print(max({a+b,a-b,a*b}))

Buggy submission (verdict: Runtime Error):
a,b = map(int, input().split())
print(max({a+b,a-b,a*b})
Problem p03001 (python)

Fixed submission:
W,H,x,y = map(int, input().split())
out1 = W*H/2
out2 = 0
if (x,y) == (W/2,H/2):
  out2 = 1
print(out1, out2)

Buggy submission (verdict: Runtime Error):
W,H,x,y = map(int, input().split())
out1 = W*H/2
out2 = 0
if (x,y) = (W/2,H/2):
  out2 = 1
print(out1, out2)
Problem p04044 (python)

Fixed submission:
n,l=map(int,input().split())
s=sorted([input() for i in range(n)])
print(*s,sep="")

Buggy submission (verdict: Runtime Error):
N, L = map(int, input().split())
S = [input() for i in range(L)]
print(*(sorted(S)), sep='')

Buggy submission (verdict: Runtime Error):
N, L = map(int, input().split())
S = [input() for i in range(L)]
print(*S, sep='')
Problem p03854 (python)

Fixed submission:
S=input()
l=len(S)
r=0
list5 = ['dream', 'erase']
list81 = ['dreamdre', 'dreamera', 'erasedre', 'eraseera']
list82 = ['dreamerd', 'dreamere']
list83 = ['eraserdr', 'eraserer']
if l<=4:
    print('NO')

while l>=5:
    if S[r:r+5] in list5:
        if r+5==l:
            print('YES')
            break
        elif r+5 == l-1:
            if S[r:r+6] == 'eraser':
                print('YES')
            else:
                print('NO')
            break
        elif r+5 == l-2:
             if S[r:r+7] == 'dreamer':
                 print('YES')
             else:
                 print('NO')
             break
        elif r+5 == l-3 or r+5 == l-4:
            print('NO')
            break
        else:
            if S[r:r+8] in list81:
                r=r+5
            elif S[r:r+8] in list82:
                r=r+7
            elif S[r:r+8] in list83:
                r=r+6
            else:
                print('NO')
                break
    else:
        print('NO')
        break

Buggy submission (verdict: Runtime Error):
S=input()
l=len(S)
r=0
list5 = ['dream', 'erase']
list81 = ['dreamdre', 'dreamera', 'erasedre', 'eraseera']
list82 = ['dreamerd', 'dreamere']
list83 = ['eraserdr', 'eraserer']
if l<=4:
    print(NO)

while l>=5:
    if S[r:r+5] in list5:
        if r+5==l:
            print(YES)
            break
        elif r+5 == l-1:
            if S[r:r+6] == 'eraser':
                print(YES)
            else:
                print(NO)
            break
        elif r+5 == l-2:
             if S[r:r+7] == 'dreamer':
                 print(YES)
             else:
                 print(NO)
             break
        elif r+5 == l-3 or r+5 == l-4:
            print(NO)
            break
        else:
            if S[r:r+8] in list81:
                r=r+5
            elif S[r:r+8] in list82:
                r=r+7
            elif S[r:r+8] in list83:
                r=r+6
            else:
                print(NO)
                break
    else:
        print(NO)
        break
Problem p02952 (python)

Fixed submission:
n = int(input())

if n <10:
    count = n
elif n <100:
    count = 9
elif n <1000:
    count = n-90
elif n < 10000:
    count = 909
elif n < 100000:
    count = n-9090
else:
    count = 90909

print(count)

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

if n <10:
    count += n
elif n <100:
    count += 9
elif n <1000:
    count += n-90
elif n < 1000:
    count += 909
elif n < 10000:
    count += n-9090
elif n < 100000:
    count += 90909
else:
    count += 90910

print(count)