Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
left, right = map(int, input().split())
imod = []
jmod = []

for i in range(left, right):
    imod.append(i % 2019)

for i in range(imod.index(min(imod))+1, len(imod)):
    jmod.append(imod[i])

print((min(imod) + min(jmod)) % 2019)


Fixed submission:
left, right = map(int, input().split())
mod = []
if right - left > 2019:
    print(0)
    exit()
else:
    for i in range(left, right):
        for j in range(left+1, right+1):
            mod.append(i*j%2019)
print(min(mod))

Buggy python submission (verdict: Runtime Error):
left, right = map(int, input().split())
imod = []
jmod = []

for i in range(left, right):
    imod.append(i % 2019)

for i in range(imod.index(min(imod))+1, len(imod)):
    jmod.append(imod[i])

print(min(imod) * min(jmod) % 2019)


Fixed submission:
left, right = map(int, input().split())
mod = []
if right - left > 2019:
    print(0)
    exit()
else:
    for i in range(left, right):
        for j in range(left+1, right+1):
            mod.append(i*j%2019)
print(min(mod))
Buggy python submission (verdict: Runtime Error):
n, k = int(input()).split()
print(n%k - 1)

Fixed submission:
n, k = map(int, input().split())
if n % k == 0:
    print(0)
else:
    print(1)
Buggy python submission (verdict: Runtime Error):
import math
def findSumOfDigits(n):
    sum =0
    while n > 0:
        sum += n % 10
        n = n//10
    return sum

N = int(input())
examples = list()

for i in range(N)[1:math.ceil(N/2)]:
    A = i
    B = N - i
    total = findSumOfDigits(A) + findSumOfDigits(B)
    examples.append(total)

print(min(examples))

Fixed submission:
def findSumOfDigits(n):
    sum =0
    while n > 0:
        sum += n % 10
        n = n//10
    return sum

N = int(input())
examples = list()

for i in range((N//2)+1)[1:]:
    A = i
    B = N - i
    total = findSumOfDigits(A) + findSumOfDigits(B)
    examples.append(total)

print(min(examples))

Buggy python submission (verdict: Runtime Error):
def findSumOfDigits(n):
    sum =0
    while n > 0:
        sum += n % 10
        n = n//10
    return sum

N = int(input())
examples = list()

for i in range(N)[1:round(N/2)]:
    A = i
    B = N - i
    total = findSumOfDigits(A) + findSumOfDigits(B)
    examples.append(total)

print(min(examples))

Fixed submission:
def findSumOfDigits(n):
    sum =0
    while n > 0:
        sum += n % 10
        n = n//10
    return sum

N = int(input())
examples = list()

for i in range((N//2)+1)[1:]:
    A = i
    B = N - i
    total = findSumOfDigits(A) + findSumOfDigits(B)
    examples.append(total)

print(min(examples))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
emp = list()
count = 0

for a in range(n)[1:]:
    for b in range(n)[1:]:
        if a + b == n:
            for i in str(a)+str(b):
                count += int(i)
            emp.append(count)

print(min(emp))

Fixed submission:
def findSumOfDigits(n):
    sum =0
    while n > 0:
        sum += n % 10
        n = n//10
    return sum

N = int(input())
examples = list()

for i in range((N//2)+1)[1:]:
    A = i
    B = N - i
    total = findSumOfDigits(A) + findSumOfDigits(B)
    examples.append(total)

print(min(examples))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Tue Jul  9 23:16:22 2019

@author: gtoky
"""

a = int(input()) > 0
b = int(input()) > 0


if (a * b) % 2 == 0:
    print("Even")
else:
    print("Odd")
    

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Tue Jul  9 23:16:22 2019

@author: gtoky
"""

a, b = map(int, input().split())
if (a*b) % 2:
    print("Odd")
else:
    print("Even")

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Tue Jul  9 23:16:22 2019

@author: gtoky
"""

a = int(input())
b = int(input())


if (a * b) % 2 == 0:
    print("Even")
else:
    print("Odd")
    

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Tue Jul  9 23:16:22 2019

@author: gtoky
"""

a, b = map(int, input().split())
if (a*b) % 2:
    print("Odd")
else:
    print("Even")
Buggy python submission (verdict: Runtime Error):
A, B, C= input(), input(), input()
if A[-1] == B[0] and B[-1] == C[0]:
    print('YES')
else:
    print('NO')

Fixed submission:
line = input()
Line = line.split()
A = Line[0]
B = Line[1]
C = Line[2]

if A[-1] == B[0] and B[-1] == C[0]:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
print(str.upper(input()[0]) + str.upper(input()[0]) + str.upper(input()[0]))


Fixed submission:
s1, s2, s3 = input().split()
print(str.upper(s1[0] + s2[0] + s3[0]))
Buggy python submission (verdict: Runtime Error):
print(*inpur().split(","))

Fixed submission:
s = input().split(",")
print(" ".join(s))
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
count = 0

for i in range(k + 1):
    for j in range(k + 1):
        if s - i - j in range(k + 1):
            count += 1

print(count)


Fixed submission:
k, s = map(int, input().split())
count = 0

for i in range(k + 1):
    for j in range(k + 1):
        if 0 <= s - i - j <= k:
            count += 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
count = 0

for i in range(k + 1):
    for j in range(k + 1):
        for n in range(k + 1):
            if i + j + n == s:
                count += 1

print(count)


Fixed submission:
k, s = map(int, input().split())
count = 0

for i in range(k + 1):
    for j in range(k + 1):
        if 0 <= s - i - j <= k:
            count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
n, k, x, y = [int(input()) for i in range(3)]
print(x*k + y*(n-k))


Fixed submission:
n = int(input())
k = int(input())
x = int(input())
y = int(input())

if n > k:
    print(k*x + (n - k)*y)
else:
    print(n*x)
Buggy python submission (verdict: Runtime Error):
n, l = map(int, input().split())
S = list()
result = ''
while l > 0:
    S.append(input())
    l -= 1

for i in sorted(S):
    result += i 

print(result)

Fixed submission:
n, l = map(int, input().split())
S = list()
result = ''
while n > 0:
    S.append(input())
    n -= 1

for i in sorted(S):
    result += i 

print(result)
Buggy python submission (verdict: Runtime Error):
x = map(int, input().split())

for i in range(5):
    if x[i] == 0:
        print(i+1)


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

for i in range(5):
    if x[i] == 0:
        print(i+1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

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

ans = 1


for a in A:
    if a == 0:
        print(0)
        sys.exit()
    ans *= a

if 10**18 < ans:
    print(-1)
else:
    print(ans)


Fixed submission:
import sys

N = int(input())
A = list(map(int, input().split()))

ans = 1

for a in A:
    if a == 0:
        print(0)
        sys.exit()

for a in sorted(A, reverse=True):
    ans *= a
    if 10**18 < ans:
        print(-1)
        sys.exit()


print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

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

ans = 1

for a in A:
    ans *= a

if 10**18 < ans:
    print(-1)
else:
    print(ans)


Fixed submission:
import sys

N = int(input())
A = list(map(int, input().split()))

ans = 1

for a in A:
    if a == 0:
        print(0)
        sys.exit()

for a in sorted(A, reverse=True):
    ans *= a
    if 10**18 < ans:
        print(-1)
        sys.exit()


print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
A,B,C,K = map(int, input().split())

score = 0

while K>0:
    if A>0:
        score += 1
        A-=1
        K-=1
    elif B>0:
        B-=1
        K-=1
    elif C>0:
        score -=1
        C-=1
        K-=1
    else:
        break
print(score)


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

score = 0


if K <= A+B:
    score = min(A,K)
else:
    score = A - min(C, (K - (A+B)))


print(score)
Buggy python submission (verdict: Runtime Error):
def ismonth(month):
    return 0 < month < 13


S = input()

former = int(S[:2])
latter = int(S[2:])

if former < 1 or latter < 1:
    ans = "NA"

elif ismonth(former) and ismonth(latter):
    ans = "AMBIGUOUS"

elif ismonth(former):
    ans = "MMYY"

elif ismonth(latter):
    ans = "YYMM"

print(ans)


Fixed submission:
from datetime import datetime

S = input()
former = int(S[:2])
latter = int(S[2:])
YYMM = False
MMYY = False

try:
    datetime(former + 2000, latter, 1)
    YYMM = True
except:
    pass

try:
    datetime(latter + 2000, former, 1)
    MMYY = True
except:
    pass

if YYMM and MMYY:
    print("AMBIGUOUS")
elif YYMM:
    print("YYMM")
elif MMYY:
    print("MMYY")
else:
    print("NA")
Buggy python submission (verdict: Runtime Error):
def third_select(S):
    right = N - 1
    change = 0
    sharp_appeared = False
    for i, s in enumerate(S[::-1]):
        if s == '#':
            sharp_appeared = True
        elif sharp_appeared:
            right = N - i
            break
        else:
            change += 1

    for s in S[:right]:
        if s == '#':
            change += 1

    for i,s in enumerate(S):
        if s == '#':
            left = i
            break

    return min(change, S[left:].count('.'))

N = int(input())
S = input()

ALL_period = S.count('#')
ALL_sharp = N - ALL_period



print(min(ALL_period, ALL_sharp, third_select(S)))


Fixed submission:
N = int(input())
S = input()
K = int(input())


print(''.join(list(map(lambda x : x if x == S[K-1] else '*', S))))
Buggy python submission (verdict: Runtime Error):
def third_select(S):
    right = N - 1
    change = 0
    sharp_appeared = False
    for i, s in enumerate(S[::-1]):
        if s == '#':
            sharp_appeared = True
        elif sharp_appeared:
            right = N - i
            break
        else:
            change += 1

    for s in S[:right]:
        if s == '#':
            change += 1

    for i,s in enumerate(S):
        if s == '#':
            left = i
            break

    return min(change, S[left:].count('.'))

N = int(input())
S = input()

ALL_period = S.count('#')
ALL_sharp = N - ALL_period



print(min(ALL_period, ALL_sharp, third_select(S)))


Fixed submission:
from itertools import accumulate

N = int(input())
S = input()
L = list()
for s in S:
    if s == '.':
        L.append(0)
    else:
        L.append(1)

sharp_cumsum = [0] + list(accumulate(L))
period_cumsum = ([0] + list(accumulate([x^1 for x in L[::-1]])))[::-1]

ans = 10 ** 9

for i in range(N):
    left = i
    right = i+1
    tmp_ans = sharp_cumsum[left] + period_cumsum[right]
    ans = tmp_ans if tmp_ans < ans else ans
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
X,Y,Z,K = map(int, input().split())
cakes = [list(map(int, input().split())) for _ in range(3)]
 
cakes = list(map(lambda x : sorted(x, reverse=True), cakes))
ans = list()
for i in range(X):
    if X>K:
        break
    for j in range(Y):
        for k in range(Z):
            ans.append(cakes[0][i] + cakes[1][j] + cakes[2][k])
ans.sort(reverse=True)
print("\n".join(map(str, ans[:K])))


Fixed submission:
X,Y,Z,K = map(int, input().split())
cakes = [list(map(int, input().split())) for _ in range(3)]
 
cakes = list(map(lambda x : sorted(x, reverse=True), cakes))
ans = list()
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1)>K:
                break
            ans.append(cakes[0][i] + cakes[1][j] + cakes[2][k])
ans.sort(reverse=True)
print("\n".join(map(str, ans[:K])))
Buggy python submission (verdict: Runtime Error):
N,Q = map(int, input().split())
S = input()
t = [0] * (N+1)

for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)

for i in range(Q):
    l,r = map(int, input().split())
    print(t[r-1] - t[l-1])


Fixed submission:
basis = input()
if basis == 'A':
    print('T')
elif basis == 'T':
    print('A')
elif basis == 'C':
    print('G')
elif basis == 'G':
    print('C')
Buggy python submission (verdict: Runtime Error):
N,Q = map(int, input.split())
S = input()
t = [0] * (N+1)

for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)

for i in range(Q):
    l,r = map(int, input.split())
    print(t[r-1] - t[l-1])


Fixed submission:
N,Q = map(int, input().split())
S = input()
t = [0] * (N+1)

for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)

for i in range(Q):
    l,r = map(int, input().split())
    print(t[r-1] - t[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
import re

N,Q = map(int, input().split())
S = input()
for _ in range(Q):
    l,r = map(int, input().split())
    s = S[l-1:r]
    ans = s.count('AC')
    print(ans)



Fixed submission:
N,Q = map(int, input().split())
S = input()
t = [0] * (N+1)

for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)

for i in range(Q):
    l,r = map(int, input().split())
    print(t[r-1] - t[l-1])
Buggy python submission (verdict: Runtime Error):
def extract(string, i):
    split = "".join(string.split("01")).split("10")
    i += len(split) - 1
    split_concat = "".join(split)
    if "01" in split_concat or "10" in split_concat:
        return extract(split_concat, i)
    else:
        return i * 2

S = input()
print(extract(S,0))


Fixed submission:
S = input()

print(min(S.count('0'), S.count('1')) * 2)

Buggy python submission (verdict: Runtime Error):
def extract(string, i):
    split = string.split("01")
    split = split.split("10")
    i += len(split) - 1
    split_concat = "".join(split)
    if "01" in split_concat or "10" in split_concat:
        return extract(split_concat, i)
    else:
        return i * 2

S = input()
print(extract(S,0))


Fixed submission:
S = input()

print(min(S.count('0'), S.count('1')) * 2)

Buggy python submission (verdict: Time Limit Exceeded):
import re

def extract(string, i):
    split = re.split('01|10', string)
    i += len(split) - 1
    split_concat = "".join(split)
    if "01" in split_concat or "10" in split_concat:
        return extract(split_concat, i)
    else:
        return i * 2

S = input()
print(extract(S,0))


Fixed submission:
S = input()

print(min(S.count('0'), S.count('1')) * 2)

Buggy python submission (verdict: Time Limit Exceeded):
def extract(string, i):
    import re
    split = re.split('01|10', string)
    i += len(split) - 1
    split_concat = "".join(split)
    if "01" in split_concat or "10" in split_concat:
        return extract(split_concat, i)
    else:
        return i * 2

S = input()

print(extract(S,0))


Fixed submission:
S = input()

print(min(S.count('0'), S.count('1')) * 2)
Buggy python submission (verdict: Runtime Error):
christmas_day = 25
d = int(input())
print("Christmas", " Eve" * christmas_day - d)

Fixed submission:
christmas_day = 25
d = int(input())
print("Christmas", " Eve" * (christmas_day - d))
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())

trees = []
for _i in range(n):
  trees.append(int(input())

trees.sort()
ans = float('inf')

for i in range(n - k + 1):
  diff = trees[i + k - 1] - trees[i]
  if ans > diff:
    ans = diff

print(ans)

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

trees = []
for _i in range(n):
  tree = int(input())
  trees.append(tree)

trees.sort()
ans = float('inf')

for i in range(n - k + 1):
  diff = trees[i + k - 1] - trees[i]
  if ans > diff:
    ans = diff

print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque
import sys

deque_s = deque(list(input()))
kyoto
deque_t = deque(list(input()))
tokyo

for _i in range(len(deque_s)):
    deque_s.rotate()
    if deque_s == deque_t:
        print('Yes')
        sys.exit()

print('No')

Fixed submission:
from collections import deque
import sys

deque_s = deque(list(input()))
deque_t = deque(list(input()))

for _i in range(len(deque_s)):
    deque_s.rotate()
    if deque_s == deque_t:
        print('Yes')
        sys.exit()

print('No')
Buggy python submission (verdict: Runtime Error):
_n = int(input())
lists = list(map(int(), input().split()))
lists.sort()

print(lists[-1] - lists[0])

Fixed submission:
_n = int(input())
lists = list(map(int, input().split()))
lists.sort()

print(lists[-1] - lists[0])

Buggy python submission (verdict: Runtime Error):
_n = int(input())
list = map(int(), input().split())
list.sort()

print(list[-1] - list[0])

Fixed submission:
_n = int(input())
lists = list(map(int, input().split()))
lists.sort()

print(lists[-1] - lists[0])
Buggy python submission (verdict: Runtime Error):
n = int(input())
ary = []
for i in range(n):
  tmp_ary = list(map(int, input().split()))
  if len(ary) == 0:
    ary = tmp_ary[:]
  else:
    t_rate = math.ceil(ary[0] / tmp_ary[0])
    a_rate = math.ceil(ary[1] / tmp_ary[1])
    rate = max([t_rate, a_rate])
    ary = list(map(lambda x: x * rate, tmp_ary))

print(ary[0] + ary[1])


Fixed submission:
n = int(input())
ary = list(map(int, input().split()))
for i in range(n - 1):
  tmp_ary = list(map(int, input().split()))
  t_rate = (ary[0] - 1) // tmp_ary[0] + 1
  a_rate = (ary[1] - 1) // tmp_ary[1] + 1
  rate = max([t_rate, a_rate])
  ary = list(map(lambda x: x * rate, tmp_ary))
print(int(ary[0] + ary[1]))
Buggy python submission (verdict: Runtime Error):
n=int(input())
k=int(input())
x=int(input())
y=int(input())

if n =< k:
  print(x * n)
else:
  print(k * x + (n - x) * y)

Fixed submission:
n=int(input())
k=int(input())
x=int(input())
y=int(input())

if n <= k:
  print(x * n)
else:
  print(k * x + (n - k) * y)
Buggy python submission (verdict: Runtime Error):
w = input()

ans = {}
for i in w:
  if i in ans:
    ans[i] += 1
  else:
    ans[i] = 1

if all[i % 2 == 0 for i in ans.values()]:
  print('Yes')
else:
  print('No')

Fixed submission:
w = input()

ans = {}
for i in w:
  if i in ans:
    ans[i] += 1
  else:
    ans[i] = 1

if all([i % 2 == 0 for i in ans.values()]):
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
w = input()

ans = {}
for i in w:
  if i in ans:
    ans[i] += 1
  else:
    ans[i] = 1

if all[i % 2 == 0 in i for ans.values()]:
  print('Yes')
else:
  print('No')

Fixed submission:
w = input()

ans = {}
for i in w:
  if i in ans:
    ans[i] += 1
  else:
    ans[i] = 1

if all([i % 2 == 0 for i in ans.values()]):
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
N,L=map(int, input().split())
str_lists = []
for i in ange(N):
  str_lists.append(input())
print(''.join(sorted(str_lists)))

Fixed submission:
N,L=map(int, input().split())
str_lists = []
for i in range(N):
  str_lists.append(input())

print(''.join(sorted(str_lists)))

Buggy python submission (verdict: Runtime Error):
N,L=map(int, input().split())
str_lists = []
for i in xrange(N):
  str_lists.append(input())
print(''.join(sorted(str_lists)))

Fixed submission:
N,L=map(int, input().split())
str_lists = []
for i in range(N):
  str_lists.append(input())

print(''.join(sorted(str_lists)))
Buggy python submission (verdict: Runtime Error):
total = 500 * int(input())
line = int(input())
if total >= line:
    print('Yes')
else:
    print('No')

Fixed submission:
k, x = map(int, input().split())
if (500 * k) >= x:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
A, B, M = map(int, input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
X = [input() for i in range(M)]

min_price = min(a) + min(b)

for i in X:
    min_price = min(min_price, a[int(i[0])-1] + b[int(i[2])-1] - int(i[4:]))

print(min_price)

Fixed submission:
A, B, M = map(int, input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
X = [list(map(int,input().split())) for i in range(M)]

min_price = min(a) + min(b)

for i in X:
    min_price = min(min_price, a[i[0]-1] + b[i[1]-1] - i[2])

print(min_price)
Buggy python submission (verdict: Runtime Error):
n=input()
print(1/2 if n%2==0 else (n-1)/2n)

Fixed submission:
n=int(input())
print(1/2 if n % 2 == 0 else (n+1)/(2*n))
Buggy python submission (verdict: Runtime Error):
n,m = input().split()
n = int(n)
m = int(m)

i = m - n

if i <= 0:
        print(0)
else:
        count = 1
        while i > 0:
                i -= n-1
                count += 1
        print(count)

Fixed submission:
a = input()
b = input()

x =0

for i in range(3):
    if a[i] == b[i]:
        x += 1

print(x)
Buggy python submission (verdict: Runtime Error):
s = list(input())
count = 0
a = []
for i in range(len(s)):
    if s[i] =="A" or s[i] =="T" or s[i] =="G" or s[i] =="C":
        count += 1
    else:
        a.append(count)
        count = 0
print(max(a))

Fixed submission:
s = list(input())
count = 0
a = []
for i in range(len(s)):
    if s[i] =="A" or s[i] =="T" or s[i] =="G" or s[i] =="C":
        count += 1
    else:
        a.append(count)
        count = 0
a.append(count)
print(max(a))
Buggy python submission (verdict: Runtime Error):
def dfs(string):
    can = ["dream", "dreamer", "erase", "eraser"]
    stack = []
    stack.append("dream")
    stack.append("dreamer")
    stack.append("erase")
    stack.append("eraser")
    while stack:
        judge = stack.pop()
        if judge == string:break
        for temp in can:
            ans = judge + temp
            print(ans)
            if ans == string[:len(ans)]:
                stack.append(ans)
    return "YES" if judge == string else "NO"

if __name__ == '__main__':
    s = input()
    print(dfs(s))

Fixed submission:
def judge(s):
    flag = True
    s = s[::-1]
    ans = ""
    pivot = 0
    while pivot < len(s):
        if s[pivot] == "m":
            ans += "maerd"
            pivot += 5
        elif s[pivot] == "e":
            ans += "esare"
            pivot += 5
        elif s[pivot:pivot+3] == "rem":
            ans += "remaerd"
            pivot += 7
        elif s[pivot:pivot+3] == "res":
            ans += "resare"
            pivot += 6
        else:
            flag = False
            break
    if flag == False:
        return "NO"
    elif s == ans:
        return "YES"
    else:
        return "NO"

if __name__ == '__main__':
    s = input()
    print(judge(s))

Buggy python submission (verdict: Runtime Error):
S = input()
T = ""

i = 0
while i <= len(S) - 7:
    if  S[i] == "d":
        if S[i+5] == "d" or S[i+7] == "a":
            T += "dream"
            i += 5
        else:
            T += "dreamer"
            i += 7
    else:
        if S[i+5] == "r":
            T += "eraser"
            i += 7
        else:
            T += "erase"
            i += 5

if S == T+"dream" or S == T+"dreamer" or S == T+"erase" or S == T+"eraser":
    print("YES")
else:
    print("NO")

Fixed submission:
def judge(s):
    flag = True
    s = s[::-1]
    ans = ""
    pivot = 0
    while pivot < len(s):
        if s[pivot] == "m":
            ans += "maerd"
            pivot += 5
        elif s[pivot] == "e":
            ans += "esare"
            pivot += 5
        elif s[pivot:pivot+3] == "rem":
            ans += "remaerd"
            pivot += 7
        elif s[pivot:pivot+3] == "res":
            ans += "resare"
            pivot += 6
        else:
            flag = False
            break
    if flag == False:
        return "NO"
    elif s == ans:
        return "YES"
    else:
        return "NO"

if __name__ == '__main__':
    s = input()
    print(judge(s))