TnT/CodeNet4Repair huggingface dataset:
Problem:
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.  The problem has N test cases.  For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.  See the Output section for the output format.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
S = list()
for i in range(N):
    S.append(input())

for k in ['AC', 'TLE', 'WA', 'RE']:
    print('{0} x {1}'.format(k, S.count(k)))

Fixed, accepted submission:
N = int(input())
S = list()
for i in range(N):
    S.append(input())

for k in ['AC', 'WA', 'TLE', 'RE']:
    print('{0} x {1}'.format(k, S.count(k)))
Problem:
Sitting in a station waiting room, Joisino is gazing at her train ticket.  The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive).  In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds.  The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.

Incorrect submission (verdict: Wrong Answer):
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    *S, = iss()
    print(S)
    E = ['+', '-']
    tmp = [0] * 7
    for e in E:
        tmp[0] = S[0]
        tmp[1] = e
        for e in E:
            tmp[2] = S[1]
            tmp[3] = e
            for e in E:
                tmp[4] = S[2]
                tmp[5] = e
                tmp[6] = S[3]
                ans = ''.join(map(str, tmp))
                if eval(ans) == 7:
                    print(ans + '=7')
                    exit()


if __name__ == '__main__':
    main()


Fixed, accepted submission:
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    *S, = iss()
    E = ['+', '-']
    tmp = [0] * 7
    for e in E:
        tmp[0] = S[0]
        tmp[1] = e
        for e in E:
            tmp[2] = S[1]
            tmp[3] = e
            for e in E:
                tmp[4] = S[2]
                tmp[5] = e
                tmp[6] = S[3]
                ans = ''.join(map(str, tmp))
                if eval(ans) == 7:
                    print(ans + '=7')
                    exit()


if __name__ == '__main__':
    main()
Problem:
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.

Incorrect submission (verdict: Wrong Answer):
n=int(input())

for i in range(n):
  if (float.is_integer(n**0.5)):
    print(n)
  else:
    n=n-1
  
               

Fixed, accepted submission:
n=int(input())

a=n

for i in range(n):
  if (float.is_integer(a**0.5)):
    print(a)
    break
  else:
    a=a-1
Problem:
You are going out for a walk, when you suddenly encounter a monster. Fortunately, you have N katana (swords), Katana 1, Katana 2, …, Katana N, and can perform the following two kinds of attacks in any order:    * Wield one of the katana you have. When you wield Katana i (1 ≤ i ≤ N), the monster receives a_i points of damage. The same katana can be wielded any number of times.   * Throw one of the katana you have. When you throw Katana i (1 ≤ i ≤ N) at the monster, it receives b_i points of damage, and you lose the katana. That is, you can no longer wield or throw that katana.  The monster will vanish when the total damage it has received is H points or more. At least how many attacks do you need in order to vanish it in total?

Incorrect submission (verdict: Wrong Answer):
import math

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

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

swords_T = [list(x) for x in zip(*swords)]

#print(swords_T)

swing_max = max(swords_T[0])

order = sorted(swords_T[1])
print(order)
count = 0

while H > 0 and len(order) != 0:
    tmp = order.pop()
    if tmp > swing_max:
        H -= tmp
        count += 1
#print(f'{H=}')

count += math.ceil(H/swing_max)

print(count)

Fixed, accepted submission:
import math

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

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

swords_T = [list(x) for x in zip(*swords)]

#print(swords_T)

swing_max = max(swords_T[0])

order = sorted(swords_T[1])
#print(order)
count = 0

while H > 0 and len(order) != 0:
    tmp = order.pop()
    if tmp > swing_max:
        H -= tmp
        count += 1
#print(f'{H=}')
if H > 0:
    count += math.ceil(H/swing_max)

print(count)
Problem:
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total?  Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.

Incorrect submission (verdict: Wrong Answer):
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0

for i in range(a):
  for j in range(b):
    for k in range(c):
      if (a * 500 + b* 100 + c * 50 == x):
        ans += 1

print(ans)

Fixed, accepted submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0

for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if ((i * 500 + j * 100 + k * 50) == x):
        ans += 1

print(ans)
Problem:
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.

Incorrect submission (verdict: Wrong Answer):
num = list(map(int, input().split(' ')))
if num[0] <= num[2] and num[1] >= num[2]:
    print("yes")
else:
    print("no")

Fixed, accepted submission:
num = list(map(int, input().split(' ')))
if num[0] <= num[2] and num[1] >= num[2]:
    print("Yes")
else:
    print("No")
Problem:
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`.  You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.

Incorrect submission (verdict: Wrong Answer):
a,b = map(int,input().split())
s = input()
s_list = list(s)
if len(s) == (a+b+1) and s_list[a] == "-" and s.count("-") == 1:
  print("YES")
else:
  print("NO")

Fixed, accepted submission:
a,b = map(int,input().split())
s = input()
s_list = list(s)
if len(s) == (a+b+1) and s_list[a] == "-" and s.count("-") == 1:
  print("Yes")
else:
  print("No")
Problem:
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times:    * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.  What is the largest possible sum of the integers written on the blackboard after K operations?

Incorrect submission (verdict: Wrong Answer):
A = list(map(int, input().split()))
K = int(input())
print(2**K * max(A))

Fixed, accepted submission:
A = list(map(int, input().split()))
K = int(input())
print((2**K - 1) * max(A) + sum(A))
Problem:
There is a set A = \\{ a_1, a_2, \ldots, a_N \\} consisting of N positive integers. Taro and Jiro will play the following game against each other.  Initially, we have a pile consisting of K stones. The two players perform the following operation alternately, starting from Taro:    * Choose an element x in A, and remove exactly x stones from the pile.  A player loses when he becomes unable to play. Assuming that both players play optimally, determine the winner.

Incorrect submission (verdict: Wrong Answer):
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

dp = [None] * (K + 1)  
dp[0] = False
for k in range(1, K + 1):
    for a in A:
        if a <= k:
            dp[k] = not dp[k - a]
            break
    if dp[k] is None:
        dp[k] = False

print('First' if dp[-1] else 'Second')

Fixed, accepted submission:
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

dp = [False] * (K + 1)  
# dp[0] = False
for k in range(1, K + 1):
    for a in A:
        if a <= k and not dp[k - a]:
            dp[k] = True
            break

print('First' if dp[-1] else 'Second')
Problem:
AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of   AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.

Incorrect submission (verdict: Wrong Answer):
w,a,b=map(int,input().split())
print(max(0,min(b-a-w,a-b-w)))

Fixed, accepted submission:
w,a,b=map(int,input().split())
if b<=a<=b+w or a<=b<=a+w:
  print(0)
else:
  print(min(abs(b-a-w),abs(a-b-w)))
Problem:
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.

Incorrect submission (verdict: Wrong Answer):
import math
x=int(input())
root_x=int(math.sqrt(x))
print(x*x)

Fixed, accepted submission:
import math
x=int(input())
log_x=int(math.log(x,2))
cand=[0 for i in range(1001)]
cand[0]=1
for i in range(2,1000):
    cand[i]=int(pow(x,1.0/i))**i
cand[1000]=1000
print(max(cand[:x+1]))
Problem:
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.

Incorrect submission (verdict: Wrong Answer):
a,b = map(int, input().split())
n = 10*a + b
sq_l = []
for i in range(n):
  sq = i **2
  sq_l.append(sq)
if n in sq_l:
  print("Yes")
else:
  print("No")
  

Fixed, accepted submission:
n = int(input().replace(" ",""))
if n == int(n**0.5)**2:
  print("Yes")
else:
  print("No")
Problem:
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?

Incorrect submission (verdict: Wrong Answer):
table = input().split()
N,M = int(table[0]),int(table[1])
hyou = []
for i in range(M):
    ith = input().split()
    hyou += ith
hyou = list(map(int,hyou))
print(hyou)
j = 1
while j <= N:
    print(hyou.count(j))
    j += 1

Fixed, accepted submission:
table = input().split()
N,M = int(table[0]),int(table[1])
hyou = []
for i in range(M):
    ith = input().split()
    hyou += ith
hyou = list(map(int,hyou))
j = 1
while j <= N:
    print(hyou.count(j))
    j += 1
Problem:
Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise.  You are given Smeke's current rating, x. Print `ABC` if Smeke will participate in ABC, and print `ARC` otherwise.

Incorrect submission (verdict: Wrong Answer):
a = int(input())
print('ABC') if a>=1200else print('ARC')

Fixed, accepted submission:
a = int(input())
print('ARC') if a>=1200 else print('ABC')
Problem:
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?

Incorrect submission (verdict: Wrong Answer):
n=int(input())

if n%2==0:
    print((n/2)-1)
else:
    print(n/2)

Fixed, accepted submission:
n=int(input())

if n%2==0:
    print(int((n/2)-1))
else:
    print(int(n/2))
Problem:
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.

Incorrect submission (verdict: Wrong Answer):
s = input()
res = s[0]

for i in range(len(s)):
    if i>0:
        if i%2==0:
            res += s[i]

Fixed, accepted submission:
s = input()
res = s[0]

for i in range(len(s)):
    if i>0:
        if i%2==0:
            res += s[i]
print(res)
Problem:
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10.  Given an integer N, determine whether it is a Harshad number.

Incorrect submission (verdict: Wrong Answer):
# coding:utf-8

INF = float('inf')


def inpl(): return list(map(int, input().split()))


def is_harshad(n):
    p = n
    tmp = 0
    while p >= 10:
        p, q = divmod(p, 10)
        tmp += q
    tmp += p
    print(tmp)
    if n % tmp == 0:
        return True
    else:
        return False


N = int(input())

if is_harshad(N):
    print('Yes')
else:
    print('No')

Fixed, accepted submission:
# coding:utf-8

INF = float('inf')


def inpl(): return list(map(int, input().split()))


def is_harshad(n):
    p = n
    tmp = 0
    while p >= 10:
        p, q = divmod(p, 10)
        tmp += q
    tmp += p

    if n % tmp == 0:
        return True
    else:
        return False


N = int(input())

if is_harshad(N):
    print('Yes')
else:
    print('No')
Problem:
We have N sticks with negligible thickness. The length of the i-th stick is A_i.  Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
vals = list(map(int, input().split()))
d= {}
a = [0, 0]

for i in range(n):
    if(vals[i] in d.keys()):
        d[vals[i]] += 1
    else:
        d[vals[i]] = 1

print(d)

for i in d.keys():
    if(d[i] >= 2):
        a.append(i)
a.sort()

print(a[-1]*a[-2])

Fixed, accepted submission:
n = int(input())
vals = list(map(int, input().split()))
d= {}
a = [0, 0]

for i in range(n):
    if(vals[i] in d.keys()):
        d[vals[i]] += 1
    else:
        d[vals[i]] = 1


for i in d.keys():
    if(d[i] >= 4):
        a.append(i)
        a.append(i)
    elif(d[i] >= 2):
        a.append(i)
a.sort()

print(a[-1]*a[-2])
Problem:
Joisino is planning to open a shop in a shopping street.  Each of the five weekdays is divided into two periods, the morning and the evening. For each of those ten periods, a shop must be either open during the whole period, or closed during the whole period. Naturally, a shop must be open during at least one of those periods.  There are already N stores in the street, numbered 1 through N.  You are given information of the business hours of those shops, F_{i,j,k}. If F_{i,j,k}=1, Shop i is open during Period k on Day j (this notation is explained below); if F_{i,j,k}=0, Shop i is closed during that period. Here, the days of the week are denoted as follows. Monday: Day 1, Tuesday: Day 2, Wednesday: Day 3, Thursday: Day 4, Friday: Day 5. Also, the morning is denoted as Period 1, and the afternoon is denoted as Period 2.  Let c_i be the number of periods during which both Shop i and Joisino's shop are open. Then, the profit of Joisino's shop will be P_{1,c_1}+P_{2,c_2}+...+P_{N,c_N}.  Find the maximum possible profit of Joisino's shop when she decides whether her shop is open during each period, making sure that it is open during at least one period.

Incorrect submission (verdict: Wrong Answer):
N = int(input())

F,P,b,T = [],[],1,-9999999999

for i in range(N):
    F.append(list(map(int,input().split())))
for i in range(N):
    P.append(list(map(int,input().split())))

while b < 1 << 10:
    bs = "{0:10b}".format(b)
    bsi = 0
    S = [0]*N
    for c in bs:
        if c == "1":
            for i in range(N):
                S[i] += F[i][bsi]
        bsi += 1
    t = 0
    for i in range(N):
        t += P[i][S[i]]
    if T < t:
        print("T",T,"t",t)
        T = t
    b += 1
print(T)



Fixed, accepted submission:
N = int(input())
F = ["".join(input().split()) for _ in range(N)]
P = [list(map(int,input().split())) for _ in range(N)]

Ans = -9999999999
for i in range(1 << 10):
    xx = bin(i)[2::].zfill(10)
    if xx == "0000000000":
        continue
    
    ans = 0
    for i in range(N):
        cnt = 0
        for j in range(10):
            if xx[j]=="1" and F[i][j]=="1":
                cnt += 1
        ans += P[i][cnt]

    Ans = max(Ans,ans)

print(Ans)
Problem:
Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.

Incorrect submission (verdict: Wrong Answer):
aopb = input().split()
print(aopb)

if aopb[1] == '+':
    print(int(aopb[0]) + int(aopb[2]))
else:
    print(int(aopb[0]) - int(aopb[2]))


Fixed, accepted submission:
aopb = input().split()

if aopb[1] == '+':
    print(int(aopb[0]) + int(aopb[2]))
else:
    print(int(aopb[0]) - int(aopb[2]))
Problem:
Write a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:                 SelectionSort(A) 1 for i = 0 to A.length-1 2     mini = i 3     for j = i to A.length-1 4         if A[j] < A[mini] 5             mini = j 6     swap A[i] and A[mini]   Note that, indices for array elements are based on 0-origin.  Your program should also print the number of swap operations defined in line 6 of the pseudocode in the case where i ≠ mini.

Incorrect submission (verdict: Wrong Answer):
i=input
N=int(i())
A=list(map(int,i().split()))
r = range
c=0
for i in r(N):
    minj=i
    for j in r(i,N):
        if A[j] < A[minj]:
            minj = j
        A[i],A[minj] = A[minj],A[i]
        c+=1
print(*A)
print(c)

Fixed, accepted submission:
i=input
N=int(i())
A=list(map(int,i().split()))
r=range
c=0
for i in r(N):
    m=i
    for j in r(i,N):
        if A[j] < A[m]:m=j
    if i!=m:A[i],A[m]=A[m],A[i];c+=1
print(*A)
print(c)
Problem:
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.  To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.

Incorrect submission (verdict: Wrong Answer):
print("A,B,Cの値を入力してください")
A,B,C = map(int,input().split())

if(A+B+C==17):
    if((A==5 or A==7) and (B==5 or B==7) and (C==5 or C==7)):
        print("YES")
    else:
        print("NO")
else:
    print("NO")


Fixed, accepted submission:

input_list = list(map(int,input().split()))

sort_list = sorted(input_list)

if(sum(sort_list) == 17):
    if(sort_list[0]==5 and sort_list[1]==5 and sort_list[2]==7):
        print("YES")
    else:
        print("NO")
else:
    print("NO")
Problem:
You are given a string S consisting of digits between `1` and `9`, inclusive. You can insert the letter `+` into some of the positions (possibly none) between two letters in this string. Here, `+` must not occur consecutively after insertion.  All strings that can be obtained in this way can be evaluated as formulas.  Evaluate all possible formulas, and print the sum of the results.

Incorrect submission (verdict: Wrong Answer):
import math

def func(n_str, ptr):
    print(n_str)
    if len(n_str)==ptr:
        return int(eval(n_str))
    return func(n_str, ptr+1) + func(n_str[:ptr]+"+"+n_str[ptr:], ptr+2)
s = input()    
print(func(s, 1))


Fixed, accepted submission:
import math

def func(n_str, ptr):
#    print(n_str)
    if len(n_str)==ptr:
        return int(eval(n_str))
    return func(n_str, ptr+1) + func(n_str[:ptr]+"+"+n_str[ptr:], ptr+2)
s = input()    
print(func(s, 1))
Problem:
You are given an integer N. Find the number of the positive divisors of N!, modulo 10^9+7.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
m = pow(10, 9) + 7
primes = [2,3,5,7,11,13,17,19,23,29,31]
D = [0]*32

for i in range(2, n+1):
    for p in primes:
        print(i, p)
        while(i % p == 0):
            D[p] += 1
            i //= p
        if i == 1:
            break

print(D)
score = 1
for p in primes:
    score = score * (D[p] + 1)
print(score)
print(score % m)


Fixed, accepted submission:
n = int(input())
m = 10**9+7
primes = [2,3,5,7,11,13,17,19,23,29,31]
D = [0]*1001

for i in range(2, n+1):
    for p in primes:
        while(i % p == 0):
            D[p] += 1
            i //= p
    if i > 1:
        D[i] += 1

score = 1
for d in D:
    score = (score * (d + 1)) % m
print(score)
Problem:
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`.  You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.

Incorrect submission (verdict: Wrong Answer):
A,B = map(int,input().split())
S = input()
flag = True
for i in range(A):
  if not '0' <= S[i] <= '9':
    flag = False
if S[A] != '-':
  flag = False
for i in range(B):
  if not '0' <= S[A+i] <= '9':
    flag = False
if flag:
  print('Yes')
else:
  print('No')

Fixed, accepted submission:
A,B = map(int,input().split())
S = input()
flag = True

for i in range(A):
  if not '0' <= S[i] <= '9':
    flag = False

if S[A] != '-':
  flag = False

for i in range(B):
  if not '0' <= S[A+i+1] <= '9':
    flag = False

if flag:
  print('Yes')
else:
  print('No')
Problem:
You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print `None` instead.

Incorrect submission (verdict: Wrong Answer):
word = input()
print(word)

Fixed, accepted submission:
#from collections import Counter
word = list(input())
word.sort()
#print(set(word))
#print(word)
ans = []
for i in [chr(i) for i in range(97, 97+26)]:
  n = word.count(i)
  if n == 0:
    ans.append(i)
    break
else:
    ans.append('None')
    
    
print(ans[0])
Problem:
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.  The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)  Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?

Incorrect submission (verdict: Wrong Answer):
import math
X = int(input())
Z = 100
res = 0
while (X >= Z):
     Z += Z*0.01
     Z = math.floor(Z)
     res += 1 
print(res)

Fixed, accepted submission:
import math
X = int(input())
Z = 100
res = 0
while (X > Z):
     Z += Z*0.01
     Z = math.floor(Z)
     res += 1 
print(res)
Problem:
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times:    * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.

Incorrect submission (verdict: Wrong Answer):
a=input()
l=["dreamer","eraser","dream","erase"]
for i in range(len(a)//5):
    for i in l:
        if a[-7:]==i:
            a=a[:-7]
        elif a[-6:]==i:
            a=a[:-6]
        elif a[-5:]==i:
            a=a[:-5]
        else:
            pass
if len(a)==0: 
    print("Yes")
else:
    print("No")

Fixed, accepted submission:
a=input()
l=["dreamer","eraser","dream","erase"]
for i in range(len(a)//5):
    for i in l:
        if a[-7:]==i:
            a=a[:-7]
        elif a[-6:]==i:
            a=a[:-6]
        elif a[-5:]==i:
            a=a[:-5]
        else:
            pass
if len(a)==0: 
    print("YES")
else:
    print("NO")