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

Fixed submission:
import sys
import math
from statistics import mean
from functools import reduce, lru_cache
from itertools import permutations


@lru_cache()
def distance(p1, p2):
    return math.sqrt(sum([(a - b) ** 2 for a, b in zip(p1, p2)]))


def distances(arr):
    return [distance(arr[i], arr[i+1]) for i in range(len(arr)-1)]


def main(n: int, points: list):
    ret = []
    for x in permutations(points):
        ret.append(sum(distances(x)))

    print(mean(ret))


if __name__ == '__main__':
    n = int(input())
    a = [input() for i in range(n)]

    points = [s.split(' ') for s in a]

    main(
        n,
        [(int(p[0]), int(p[1])) for p in points]
    )

Buggy submission (verdict: Runtime Error):
import sys
import math
from statistics import mean
from functools import reduce, lru_cache
from itertools import permutations


@lru_cache()
def distance(p1, p2):
    return math.sqrt(sum([(a - b) ** 2 for a, b in zip(p1, p2)]))


def distances(arr):
    return [distance(arr[i], arr[i+1]) for i in range(len(arr)-1)]


def main(n: int, points: list):
    ret = []
    for x in permutations(points):
        ret.append(sum(distances(x)))

    print(mean(ret))


if __name__ == '__main__':
    a = []
    while True:
        l = input()
        if l:
            a.append(l)
        else:
            break

    args = '\n'.join(a)
    points = [s.split(' ') for s in a[1:]]

    main(
        int(a[0]),
        [(int(p[0]), int(p[1])) for p in points]
    )

Buggy submission (verdict: Runtime Error):
import sys
import math
from statistics import mean
from functools import reduce, lru_cache
from itertools import permutations


@lru_cache()
def distance(p1, p2):
    return math.sqrt(sum([(a - b) ** 2 for a, b in zip(p1, p2)]))


def distances(arr):
    return [distance(arr[i], arr[i+1]) for i in range(len(arr)-1)]


def main(n: int, points: list):
    ret = []
    for x in permutations(points):
        ret.append(mean(distances(x)))

    print(mean(ret))


if __name__ == '__main__':
    a = []
    while True:
        l = input()
        if l:
            a.append(l)
        else:
            break

    args = '\n'.join(a)
    points = [s.split(' ') for s in a[1:]]

    main(
        int(a[0]),
        [(int(p[0]), int(p[1])) for p in points]
    )
Problem p02657 (python)

Fixed submission:
N, M = map(int, input().split())
print(N * M)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
purint(N * M)
Problem p02658 (python)

Fixed submission:
# -*- coding: utf-8 -*-
N = int(input())
numlist = list(map(int, input().split()))
if 0 < numlist.count(0):
    print('0')
    quit()

total = 1
for i in numlist:
  total *= i
  if 10 ** 18 < total:
    print('-1')
    quit()

print(total)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N = int(input())
numlist = list(map(int, input().split()))
if 0 < numlist.count(0):
    print('0')
    quit()

total = 1
for i in numlist:
  total *= abs(i)

if 10 ** 18 < total:
  print('-1')
else:
  print(sign * total)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N = int(input())
numlist = list(map(int, input().split()))
if 0 < numlist.count(0):
    print('0')
    quit()

total = 1
for i in numlist:
  total *= abs(i)
  if 10 ** 18 < total:
    print('-1')
    quit()

print(sign * total)
Problem p03337 (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 -*-
n = int(input())
ln = list(map(int, input().replace('W', '0 ').replace('E', '1 ').split()))

# 先頭だけ先に計算（do-while相当）
w_sum = 0                           # 西側で振り返る人
sum_min = e_sum = sum(ln) - ln[0]   # 東側で振り返る人

for i in range(1, n-1):
    #sum_min = min(sum_min, sum(ln[i+1:n]) + (i - sum(ln[0:i])))
    w_sum += 1 if ln[i-1] == 0 else 0
    e_sum -= ln[i]
    sum_min = min(sum_min, w_sum + e_sum)

# 末尾も個別に計算
else:
    w_sum += 1 if ln[n-1] == 0 else 0
    sum_min = min(sum_min, w_sum)

print(sum_min)
Problem p04043 (python)

Fixed submission:
# -*- coding: utf-8 -*-
# 整数の入力
lst = list(map(int, input().split()))

if lst[0] == 5:
    if (lst[1] == 7 and lst[2] == 5) or (lst[1] == 5 and lst[2] == 7):
        print("YES")
        exit()

elif lst[0] == 7:
    if lst[1] == 5 and lst[2] == 5:
        print("YES")
        exit()

print("NO")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
def forgive(num):
    for i in range(10):
        if ((num + i) % 10) in unforgiven:
            continue
        else:
            return num + i


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

price = [int(x) for x in str(N)]
purchase = 0
dig = 0
for num in reversed(price):
    purchase += forgive(num) * (10 ** dig)
    dig += 1

print(purchase)
Problem p02646 (python)

Fixed submission:

def main():
    A,V = map(int, input().split())
    B,W = map(int, input().split())
    T = int(input())
    #print(A,V,B,W,T)

    if( (V-W)*T - abs(B - A) >= 0 ):
        return print('YES')
    else:
        return print('NO')


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):

def main():
    A,V = map(int, input().split())
    B,W = map(int, input().split())
    T = int(input())
    #print(A,V,B,W,T)

    if( )

    if( (V-W)*T - abs(B - A) >= 0 ):
        return print('YES')
    else:
        return print('NO')


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):

def main():
    A,V = map(int, input().split())
    B,W = map(int, input().split())
    T = int(input())
    #print(A,V,B,W,T)

    if( )

    if( (V-W)*T - abs(B - A) >= 0 ):
        return print('YES')
    else:
        return print('NO')


if __name__ == '__main__':
    main()
Problem p03168 (python)

Fixed submission:

n=int(input())
arr = list(map(float,input().split()))
dp = [[-1]*(n+1) for i in range(n+1)]
def func(n,x):
    for i in range(0,n+1):
        for j in range(0,n+1):
            if j==0:
                dp[i][j] = 1
            elif i==0:
                dp[i][j]=0
            else:
                p=(arr[i-1])*dp[i-1][j-1]
                q=(1-arr[i-1])*dp[i-1][j]
                dp[i][j] = p+q 
    
    return dp[n][x]

print("%0.10f"%func(n,(n+1)//2))

Buggy submission (verdict: Runtime Error):

n=int(input())
arr = list(map(float,input().split()))
dp = [[-1]*(3001) for i in range(3001)]

def func(n,x):
    if x==0:
        return 1
    if dp[n][x]>-0.9:
        return dp[n][x]  
    if n==0:
        return 0
    
    dp[n][x] = (arr[n-1])*func(n-1,x-1) + (1-arr[n-1])*func(n-1,x)
    return dp[n][x]

print("%0.10f"%func(n,(n+1)//2))

Buggy submission (verdict: Runtime Error):
n=int(input())
arr = list(map(float,input().split()))
dp = [[-1]*(3001) for i in range(3001)]

def func(n,x):
    if x==0:
        return 1
    if dp[n][x]>-0.9:
        return dp[n][x]  
    if n==0:
        return 0
    
    dp[n][x] = (arr[n-1])*func(n-1,x-1) + (1-arr[n-1])*func(n-1,x)
    return dp[n][x]

print("%0.10f"%func(n,(n+1)//2))

Buggy submission (verdict: Runtime Error):
n=int(input())
arr = list(map(float,input().split()))
dp = [[-1]*(3001) for i in range(3001)]

def func(n,x):
    if x==0:
        return 1
    if dp[n][x]>-0.9:
        return dp[n][x]
    
    if n==0:
        return 0
    
    dp[n][x] = (arr[n-1])*func(n-1,x-1) + (1-arr[n-1])*func(n-1,x)
    return dp[n][x]

print("%0.10f"%func(n,(n+1)//2))

Buggy submission (verdict: Runtime Error):
n=int(input())
arr = list(map(float,input().split()))
dp = [[-1]*(n+1) for i in range(n+1)]

def func(n,x):
    if n==0 and x==0:
        return 1
    if dp[n][x]!=-1:
        return dp[n][x]
    
    if n==0 and x!=0:
        return 0
    
    if x==0 and n!=0:
        return 1
    
    dp[n][x] = (arr[n-1])*func(n-1,x-1) + (1-arr[n-1])*func(n-1,x)
    return dp[n][x]

print("%0.10f"%func(n,(n+1)//2))
Problem p02612 (python)

Fixed submission:
N = int(input())
if (N % 1000) != 0:
    ans = 1000 - N % 1000
else:
    ans = 0
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
if (N % 1000) != 0:
    ans = 1000 - N % 1000
elif:
    ans = 0
print(ans)
Problem p02615 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A = sorted(A, reverse = True)

L = len(A) // 2

if len(A) % 2 == 0:
    #偶数の時
    ans = sum(A[:L]) + sum(A[1:L])
else:
    #奇数の時
    ans = sum(A[:L]) + sum(A[1:L+1])

print(ans)

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

L = len(P) // 2

if len(A) % 2 == 0:
    #偶数の時
    ans = sum(A[:L]) + sum(A[1:L])
else:
    #奇数の時
    ans = sum(A[:L]) + sum(A[1:L+1])

print(ans)
Problem p02934 (python)

Fixed submission:
n = int(input())
a = map(int, input().split())
print('{:.16g}'.format(1/sum(1/x for x in a)))

Buggy submission (verdict: Runtime Error):
n = int(input())
number = map(int,input().split())
print('{:.16g}').format(1/x for x in number)

Buggy submission (verdict: Runtime Error):
n = int(input())
numbers = []
i = 0
while i <= n:
  numbers.append(int(input()))
  i += 1

j = 0
s = 0
while n >= j:
  s += 1/numbers[j]
  j += 1

print(1/s)

Buggy submission (verdict: Runtime Error):
n = int(input())
numbers = []
for number in numbers:
  numbers.append(int(input))

i = 0
s = 0
while i >= n:
  s += 1/numbers[i]
  i += 1

print(1/s)
Problem p02945 (python)

Fixed submission:
n = list(int(i) for i in input().split())
print(max(sum(n), n[0]-n[1], n[0]*n[1]))

Buggy submission (verdict: Runtime Error):
n = map(int, input().split())
print(max(sum(n), n(0)-n(1), n(0)*n(1)))
Problem p03136 (python)

Fixed submission:
N = int(input())
L = list(map(int, input().split()))
L.sort()
if L[-1] < (sum(L) - L[-1]):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
L = list(map(int, int(input())))
L.sort()
if L[-1] > (sum(L) - L[-1]):
    print("Yes")
else:
    print("No")
Problem p02993 (python)

Fixed submission:
s = input()
flag = False
for i in range(len(s)-1):
    if int(s[i]) == int(s[i+1]):
        flag = True

if flag:
    print('Bad')
else:
    print('Good')

Buggy submission (verdict: Runtime Error):
from fractions import gcd
A,B,C,D = map(int, input().split())

A =A-1
CD = int(C * D / gcd(C, D))
num_A_C = int(A / C)
num_A_D = int(A / D)
num_A_CD = int(A / CD)
num_B_C = int(B / C)
num_B_D = int(B / D)
num_B_CD = int(B / CD)

num_C =num_B_C - num_A_C
num_D =num_B_D - num_A_D
num_CD =num_B_CD - num_A_CD

ans = B - A -num_C - num_D + num_CD
print(ans)

Buggy submission (verdict: Runtime Error):
flag = False
for i in range(len(s)-1):
    if int(s[i]) == int(s[i+1]):
        flag = True

if flag:
    print('Bad')
else:
    print('Good')
Problem p02608 (python)

Fixed submission:
from collections import Counter
n = int(input())
ans_list = [0]*(10**6)
for i in range(1, 100):
  for j in range(1, 100):
    for k in range(1, 100):
      ans = i**2 + j**2 + k**2 + i*j + j*k + k*i
      ans_list[ans-1] += 1
for i in ans_list[:n]:
  print(i)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
ans_list = [0]*(10**4)
for i in range(1, 100):
  for j in range(1, 100):
    for k in range(1, 100):
      ans = i**2 + j**2 + k**2 + i*j + j*k + k*i
      ans_list[ans-1] += 1
for i in ans_list[:n]:
  print(i)
Problem p02642 (python)

Fixed submission:
from collections import deque
n = int(input())
a = list(map(int, input().split()))
a.sort()
a = deque(a)
b = [0]*(10**6 +1)
ans = 0
for _ in range(n):
  x = a.popleft()
  if b[x] == 0:
    ans += 1
    b[x] = 2
    tmp = 2 * x
    while tmp <= 10**6:
      b[tmp] = 1
      tmp += x
  elif b[x] == 2:
    ans -=1
    b[x] = 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
ans = 0
if a[-2] == a[-1]:
  ans -= 1
for i, num in enumerate(a):
  b = make_divisors(num)
  if set(a[i+1:]).isdisjoint(set(b)):
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
ans = 0
if a[-2] == a[-1]:
  ans -= 1
for i, num in enumerate(a):
  b = make_divisors(num)
  if set(a[i+1:]).isdisjoint(set(b)):
    ans += 1
print(ans)
Problem p02690 (python)

Fixed submission:
x = int(input())
a = []
for i in range(-200, 200):
  for j in range(-200, 200):
    if i**5 - j**5 == x:
      a.append([i, j])
      break
      
print(*a[0])

Buggy submission (verdict: Runtime Error):
x = int(input())
a = []
for i in range(-50, 50):
  for j in range(-50, 50):
    if i**5 - j**5 == x:
      a.append([i, j])
      break
      
print(*a[0])

Buggy submission (verdict: Runtime Error):
x = int(input())
a = []
for i in range(-90, 90):
  for j in range(-90, 90):
    if i**5 - j**5 == x:
      a.append([i, j])
      break
      
print(*a[0])

Buggy submission (verdict: Runtime Error):
x = int(input())
a = []
for i in range(-100, 100):
  for j in range(-100, 100):
    if i**5 - j**5 == x:
      a.append([i, j])
      break
      
print(*a[0])

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
h = list(map(int, input().split()))
a = [0]*n
ans = n
for i in range(m):
  b, c = map(int, input().split())
  b -= 1
  c -= 1
  a[b] += 1
  a[c] += 1
  if h[b] == h[c]:
    if a[b] == 1 and a[c] == 1:
      ans -= 2
    elif a[b] == 1 and a[c] != 1:
      ans -= 1
    elif a[b] != 1 and a[c] == 1:
      ans -= 1
  if h[b] > h[c]:
    a[b] -= 1
    if a[c] == 1:
      ans -= 1
  if h[b] < h[c]:
    a[c] -= 1
    if a[b] == 1:
      ans -= 1
print(ans)
Problem p02697 (python)

Fixed submission:
n, m = map(int, input().split())
if n%2 == 1:
  for i in range(m):
    print(m-i, m+1+i)
else:
  for i in range(m):
    if 4*(i+1) > n:
      print(m-i, m+2+i)
    else:
      print(m-i, m+1+i)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
if n%2 == 1:
  for i in range(m):
    print(m-i, m+1+i)
else:
  for i in range(m):
    if 4*(i+1) > n:
      print(m-1, m+2+i)
    else:
      pritn(m-1, m+1+i)
Problem p02713 (python)

Fixed submission:
a = int(input())
from math import gcd
b = 0
for i in range(1, a + 1):
  for j in range(1, a + 1):
    for k in range(1, a + 1):
      b += gcd(gcd(i, j), k)
      
print(b)

Buggy submission (verdict: Runtime Error):
a = int(input())
from math import gcd
b = 0
for i in range(1, n + 1):
  for j in range(1, n + 1):
    for k in range(1, n + 1):
      b += gcd(gcd(i, j), k)
      
print(b)
Problem p02714 (python)

Fixed submission:
n=int(input())
s=list(input())
ans=s.count('R')*s.count('G')*s.count('B')
for i in range(n):
  if s[i]=='R':
    s[i]=1
  elif s[i]=='G':
    s[i]=2
  elif s[i]=='B':
    s[i]=4
for i in range(n):
   for j in range(i+1,n):
      k=2*j-i
      if k>=n:
        continue
      if s[i]+s[j]+s[k]==7:
        ans-=1
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input())
ans=s.count('R')*s.count('G')*s.count('B')
for i in range(n):
  if s[i]=='R':
    s[i]=1
    elif s[i]=='G':
      s[i]=2
    elif s[i]=='B':
      s[i]=4
for i in range(n):
   for j in range(i+1,n):
      k=2*j-i
      if k>=n:
        continue
      if s[i]+s[j]+s[k]==7:
        ans-=1
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input())
ans=s.count('R')*s.count('G')*s.count('B')
for i in range(n):
  if s[i]=='R':
    s[i]=1
    elif s[i]=='G':
      s[i]
    elif s[i]=='B':
      s[i]=4
for i in range(n):
   for j in range(i+1,n):
      k=2*j-i
      if k>=n:
        continue
      if s[i]+s[j]+s[k]==7:
        ans-=1
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input())
ans=s.count('R')*s.count('G')*s.count('B')
for i in range(n):
   if s[i]=='R':
       s[i]=1
   elif s[i]=='G':
       s[i]
   elif s[i]=='B':
       s[i]=4
for i in range(n):
   for j in range(i+1,n):
     k=2*j-i
     if k>=n:
       continue
     if s[i]+s[j]+s[k]==7:
         ans-=1
print(ans)
Problem p02718 (python)

Fixed submission:
category_number, popular_product_number = input().split()
product = input().split()
product_list = [int(i) for i in product]
votes_number = sorted(product_list)[-int(popular_product_number)]
border = sum(product_list)/4/int(popular_product_number)
if votes_number < border:
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
category_number, popular_product_number = input().split()
product_list = input().split()
votes_number = sorted(product_list)[-popular_product_number]
border = sum(product_list)/4/popular_product_number
if votes_number < border:
  print('No')
else:
  print('Yes')
Problem p02730 (python)

Fixed submission:
s = list(input())
s_reverse = s[::-1]
a = int((len(s) - 1)/2)
b = s[:a]
c = b[::-1]
if b == c and s == s_reverse:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
s = list(input())
a = (len(s) - 1)/2
b = s[:a]
c = b[::-1]
if b == c:
  print('Yes')
else:
  print('No')
Problem p02760 (python)

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

for _ in range(n):
  b = int(input())
  for y in range(3):
    for x in range(3):
      if a[y][x] == b:
        a[y][x] = -1

for y in range(3):
  f = True
  for x in range(3):
    if a[y][x] != -1:
      f = False
  if f:
    print('Yes')
    exit()
    
for x in range(3):
  f = True
  for y in range(3):
    if a[y][x] != -1:
      f = False
  if f:
    print('Yes')
    exit()
    
f = True
for x in range(3):
  if a[x][x] != -1:
    f = False
if f:
  print('Yes')
  exit()
  
f = True
for x in range(3):
  if a[x][2-x] != -1:
    f = False
if f:
  print('Yes')
  exit()
  
print('No')

Buggy submission (verdict: Runtime Error):
60 88 34
92 41 43
65 73 48
10
60
43
88
11
48
73
65
41
92
34
Problem p02761 (python)

Fixed submission:
n, m = map(int, input().split())
s = []
c = []
for i in range(m):
  S, C = map(int, input().split())
  s.append(S)
  c.append(C)
for i in range(10 **(n + 1)):
  tmp = str(i)
  if len(tmp) == n and all([tmp[s[j] - 1] == str(c[j]) for j in range(m)]):
    print(tmp)
    exit()
print(-1)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
s = []
c = []
for i in range(n):
  S, C = map(int, input().split())
  s.append(S)
  c.append(C)
for i in range(10 **(n + 1)):
  tmp = str(i)
  if len(tmp) == n and all([tmp[s[j] - 1] == str(c[j]) for j in range(m)]):
    print(tmp)
    exit()
print(-1)
Problem p03557 (python)

Fixed submission:
import bisect
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
ans = 0
for i in b:
  d = bisect.bisect_left(a, i)
  e = bisect.bisect_right(c, i)
  if d > 0 and e < len(c):
    ans += d*(n-e)
print(ans)

Buggy submission (verdict: Runtime Error):
import bisect
n = int(input())
a = list(map(int, input()))
b = list(map(int, input()))
c = list(map(int, input()))
a.sort()
ans = 0
for i in b:
  d = bisect.bisect_left(a, i)
  e = bisect.bisect_right(c, i)
  if d > 0 and e < len(c):
    ans += d*(n-e)
print(ans)
Problem p03854 (python)

Fixed submission:
s = input()
dp = [0]*(len(s) + 1)
dp[0] = 1
judge = 'NO'
words = ['dream', 'dreamer', 'erase', 'eraser']
for i in range(len(s)):
  if dp[i] == 0:
    continue
  for w in words:
    if s[i:i+len(w)] == w:
      dp[i+len(w)] = 1
    if dp[len(s)] == 1:
      judge = 'YES'
      break
print(judge)

Buggy submission (verdict: Runtime Error):
s = input()
dp = [0]*(len(s) + 1)
dp[0] = 1
judge = 'NO'
word = ['dream', 'dreamer', 'erase', 'eraser']
for i in range(len(s)):
  if d[i] = 0:
    continue
  for w in words():
    if s[i:i+len(w)] == w:
      dp[i+len(w)] = 1
    if dp[len(s)] == 1:
      judge = 'YES'
      break
print(judge)

Buggy submission (verdict: Runtime Error):
s = input()
dp = [0]*(len(s) + 1)
dp[0] = 1
judge = 'NO'
word = ['dream', 'dreamer', 'erase', 'eraser']
for i in range(len(s)):
  if d[i] = 0:
    continue
  for w in words():
    if s[i:i+len(w)] == w:
      dp[i+len(w)] = 1
    if dp[len(s)] == 1:
      judge = 'YES'
      break
print(judge)

Buggy submission (verdict: Runtime Error):
s = input()
dp = [0]*(len(s) + 1)
dp[0] = 1
judge = 'No'
word = ['dream', 'dreamer', 'erase', 'eraser']
for i in range(len(s)):
  if d[i] = 0:
    continue
  for w in words():
    if s[i:i+len(w)] == w:
      dp[i+len(w)] = 1
    if dp[len(s)] == 1:
      judge = 'Yes'
      break
print(judge)
Problem p02660 (python)

Fixed submission:
n=int(input())

arr = []
temp = n
for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
        cnt=0
        while temp%i==0:
            cnt+=1
            temp //= i
        arr.append([i, cnt])

if temp!=1:
    arr.append([temp, 1])

if arr==[]:
    arr.append([n, 1])

if arr==[[1,1]]:
    print(0)

else:
    total=0
    for i in range(len(arr)):
        x=1
        s=0
        c=-1
        while s<=arr[i][1]:
            s+=x
            x+=1
            c+=1
        total+=c
    print(total)

Buggy submission (verdict: Runtime Error):
arr = []
temp = n
for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
        cnt=0
        while temp%i==0:
            cnt+=1
            temp //= i
        arr.append([i, cnt])

if temp!=1:
    arr.append([temp, 1])

if arr==[]:
    arr.append([n, 1])

if arr==[[1,1]]:
    print(0)

else:
    # print(arr)
    total=0
    for i in range(len(arr)):
        x=1
        s=0
        c=-1
        while s<=arr[i][1]:
            s+=x
            x+=1
            c+=1
        total+=c
    print(total)

Buggy submission (verdict: Runtime Error):
arr = []
temp = n
for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
        cnt=0
        while temp%i==0:
            cnt+=1
            temp //= i
        arr.append([i, cnt])

if temp!=1:
    arr.append([temp, 1])

if arr==[]:
    arr.append([n, 1])

if arr==[[1,1]]:
    print(0)

else:
    # print(arr)
    total=0
    for i in range(len(arr)):
        x=1
        s=0
        c=-1
        while s<=arr[i][1]:
            s+=x
            x+=1
            c+=1
        total+=c
    print(total)
Problem p02678 (python)

Fixed submission:
from collections import deque

N, M = map(int, input().split())
l =[[] for _ in range(N)]

q=deque([0])

TFl=[0]*N
TFl[0]=1
ml=[-1]*N

for i in range(M):
  A,B=map(int,input().split())
  l[B-1].append(A-1)
  l[A-1].append(B-1)

while q:
  p = q.popleft()
  for i in l[p]: #普通に1行ずつ回してるイメージ
    if TFl[i]==1:
      continue
    TFl[i]=1
    ml[i]=p
    q.append(i)

if all([i==1 for i in TFl]):
  print('Yes')
  for i in range(1, N):
    print(ml[i]+1)

else:
  print('No')

Buggy submission (verdict: Runtime Error):
from collections import deque

N, M = map(int, input().split())
l =[[] for _ in range(N)]

q=deque([0])

TFl=[0]*N
TFl[0]=1
ml=[-1]*N

for i in range(M):
  A,B=map(int,input().split())
  l[B-1].append(A-1)
  l[A-1].append(B-1)

while q:
  p = q.popleft()
  for i in l[p]: #普通に1行ずつ回してるイメージ
    if TFl[i]==1:
      continue
    TFl[i]=1
    ml=p
    q.append(i)

if all([i==1 for i in TFl]):
  print('Yes')
  for i in range(1, N):
    print(ml[i]+1)

else:
  print('No')
Problem p02681 (python)

Fixed submission:
lS=list(input())
T=input()

lT=list(T)
if lS==lT[0:len(lT)-1]:
  print('Yes')

else:
  print('No')

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

ca=[list(map(int,input().split())) for _ in range(n)]

res=float('inf')

for i in range(2**n):
  sc=0
  a=[0]*m
  for j in range(n):
    if ((i >> j) & 1) :
      sc=+ca[j][0]
      a+=ca[j][1:]
  if min(a)>=x:
    res=min (sc,res)

if res == INF:
    print(-1)
else:
    print(res)