Harryxun/stf_run huggingface dataset:
# -*- Coding: utf-8 -*-

n = int(input())
A = [list(map(int,input().split())) for i in range(n-1)]
C = list(map(int,input().split()))

C2 = []
for i in range(n):
    C2.append([C[i],i])

C2.sort()

ans = sum(C)-C2[-1][0]

T = [[] for i in range(n)]
for i in range(len(A)):
    T[A[i][0]-1].append(A[i][1]-1)
    T[A[i][1]-1].append(A[i][0]-1)
#print(T)


E = [[0,i] for i in range(n)]
E[1][0]=1
# co = 0
# while co < n-1:
#     #print(co)
#     t = 0
#     while t < n+1 :
#         if len(T[t]) == 1:
#             E.append(t)
#             if co == n-2 :
#                 E.append(T[t][0])
#             T[T[t][0]].remove(t)
#             T[t] = []
#             co += 1
#         t += 1

def ho(u):
    p = E[u][0]
    for j in range(len(T[u])):
        if E[T[u][j]][0] == 0:
            E[T[u][j]][0] = p+1
            ho(T[u][j])
ho(1)
#print(E)
E.sort(reverse=1)


#print(E)

D = [0 for i in range(n)]
for i in range(n):
    D[E[i][1]] = C2[i][0]

print(ans)
s = ""
for i in range(n):
    s += str(D[i])
    s += " "

print(s)


### FIXED CODE ###

# -*- Coding: utf-8 -*-

n = int(input())
A = []
A = [list(map(int,input().split())) for i in range(n-1)]
C = list(map(int,input().split()))

C2 = []
for i in range(n):
    C2.append([C[i],i])

C2.sort()

ans = sum(C)-C2[-1][0]

T = [[] for i in range(n)]
for i in range(len(A)):
    T[A[i][0]-1].append(A[i][1]-1)
    T[A[i][1]-1].append(A[i][0]-1)
#print(T)


E = [[0,i] for i in range(n)]
E[0][0]=1
# co = 0
# while co < n-1:
#     #print(co)
#     t = 0
#     while t < n+1 :
#         if len(T[t]) == 1:
#             E.append(t)
#             if co == n-2 :
#                 E.append(T[t][0])
#             T[T[t][0]].remove(t)
#             T[t] = []
#             co += 1
#         t += 1

holist=[0]
hot = 0

def ho(u):
    p = E[u][0]
    for j in range(len(T[u])):
        if E[T[u][j]][0] == 0:
            E[T[u][j]][0] = p+1
            holist.append(T[u][j])

while hot < len(holist):
    ho(holist[hot])
    hot += 1
#print(E)
E.sort(reverse=1)


#print(E)

D = [0 for i in range(n)]
for i in range(n):
    D[E[i][1]] = C2[i][0]

print(ans)
s = ""
for i in range(n):
    s += str(D[i])
    s += " "

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

A.sort()
max_a = -1
min_diff = K
for i in range(N):
    a = A[i]
    if a == K:
        print("POSSIBLE")
        exit()
    if a > max_a:
        max_a = a
    if i < N-1:
        diff = A[i+1]-A[i]
        if diff < min_diff:
            min_diff = diff

if max_a < K:
    print("IMPOSSIBLE")
    exit()
else:
    for a in A:
        if (K-a) % min_diff == 0:
            print("POSSIBLE")
            exit()

print("IMPOSSIBLE")

### FIXED CODE ###

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

def get_gcd(a,b):
    if b > a:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b

gcd  = A[0]
max_a = A[0]
for i in range(1, N):
    a = A[i]
    if a == K:
        print("POSSIBLE")
        exit()
    if a > max_a:
        max_a = a
    gcd = get_gcd(gcd, a)

if max_a < K:
    print("IMPOSSIBLE")
    exit()
else:
    if K % gcd == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
import sys

line = sys.stdin.readline()
     x, y = line.split(" ")

x = int(x)
y = int(y)

divide = 1

if x > y:
    x, y = y, x

for i in range(2, x + 1):
    if x % i == 0 and y % i == 0:
        divide = divide * i
        x = x / i
        y = y / i
        i -= 1

print divide

### FIXED CODE ###

import sys

def div(x, y):
    if x % y == 0:
        print y
    else:
        div(y, x%y)


line = sys.stdin.readline()
x, y = line.split(" ")

x = int(x)
y = int(y)

if x < y:
    x, y = y, x

if x == y:
    print x

else:
    div(x, y)
N, M = open(0).readline().split()
from collections import Counter
cnt = Counter([x for x in open(0).read().split()])
print('\n'.join(map(str,cnt.values())))

### FIXED CODE ###

N, M, *cnt = open(0).read().split()
from collections import Counter
cnt = Counter(cnt)
for i in range(1,int(N)+1):
    print(cnt[str(i)])
import random
list = []
for i in range(31):
  list.append(random.randint(0,10000))
print(list)
K = int(input())
print(list[K-1])


### FIXED CODE ###

list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(list[K-1])
A,B = map(int,input().split())
count = 0

for i in range(A,B+1):
  if i[0] == i[4] and i[1] == i[3]:
    count += 1
    
print(count)

### FIXED CODE ###

A,B = map(int,input().split())
count = 0
 
for i in range(A,B+1):
  i = str(i)
  if i[0] == i[4] and i[1] == i[3]:
    count += 1
    
print(count)
n, y = map(int, input().split())

# n, y = 1000, 1234000

flg = False
for i in range(y//10000 + 1):
    for j in range(n-i+1):
        k = n - i - j
        if i*10000+j*5000+k*1000 == y:
            print(i, j, k)
            return
print('-1 -1 -1')


### FIXED CODE ###

import sys

n, y = map(int, input().split())

# n, y = 1000, 1234000

flg = False
for i in range(y//10000 + 1):
    for j in range(n-i+1):
        k = n - i - j
        if i*10000+j*5000+k*1000 == y:
            print(i, j, k)
            sys.exit(0)
print('-1 -1 -1')
n, x, m = map(int, input().split())

l = [x]
s = {x}
prev = x

for i in range(1, m):
    next = prev ** 2
    next = next % m
    if next in s:
        break
    s.add(next)
    l.append(next)
    prev = next
start = l.index(next)
length = i - start

ans = 0
if n < start + length:
    ans += sum(l[:n])
else:
    ans += sum(l[:start])
    ans += sum(l[start:]) * ((n - start) // length)
    ans += sum(l[start:(start + ((n - start) % length))])

print(ans)


### FIXED CODE ###

import sys

n, x, m = map(int, input().split())

if x == 0:
    print(0)
    sys.exit()

l = [x]
s = {x}
prev = x

for i in range(1, m):
    next = prev ** 2
    next = next % m
    if next in s:
        break
    s.add(next)
    l.append(next)
    prev = next
start = l.index(next)
length = i - start

ans = 0
if n < start + length:
    ans += sum(l[:n])
else:
    ans += sum(l[:start])
    ans += sum(l[start:]) * ((n - start) // length)
    ans += sum(l[start:(start + ((n - start) % length))])

print(ans)
S, T = map(int, input().split())
print(T + S)

### FIXED CODE ###

S, T = input().split()
print(T + S)
from collections import defaultdict,deque
import math
import copy
def main():
    x,k,d=map(int, input().split())
    res = float('inf')
    l = 0
    r = k+1
    tmp_res = 0
    while(l+1!=r):
        mid = (l+r)//2
        tmp_res = copy.deepcopy(res)
        if((k-mid)%2==1):
         	res = min(res, abs(abs(x)-(mid+1)*d))
            res = min(res, abs(abs(x)-(mid-1)*d))
            mid+=1
        if((k-mid)%2==0):
            res = min(res, abs(abs(x)-mid*d))
            res = abs(res)
        if(abs(abs(x)-mid*d) > x):
            r = mid
        else:
            l = mid
        if tmp_res == res:
            break

    print(res)




if __name__ == '__main__':
    main()



### FIXED CODE ###

from collections import defaultdict,deque
import math
import copy
def main():
    x,k,d=map(int, input().split())
    res = float('inf')
    x = abs(x)

    if(k*d <= x):
        print(x-k*d)
    else:
        if(k%2 == x//d%2):
            print(x%d)
        else:
            print(d-x%d)




if __name__ == '__main__':
    main()
import numpy as np

N = int(input())
# P = np.array(input().split(' '), dtype = int)
P = np.array(list(map(int, input().split(' '))))

counta = 0
for i in range(N):
    counta += (min(P[:i+1]) == P[i])
print(counta

### FIXED CODE ###

N = int(input())
# P = np.array(input().split(' '), dtype = int)
P = list(map(int, input().split(' ')))

p_min = P[0]
ans = 0
for p in P:
    if p <= p_min:
        p_min = p
        ans += 1
print(ans)
num1 = int(input())
num2 = int(input())
num3 = int(input())
if num1+num2+num3 >= 22:
    print('bust')
else:
    print('win')

### FIXED CODE ###

num = input().split()
result = list(map(int, num))
if sum(result) >= 22:
    print('bust')
else:
    print('win')
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,m = map(int,input().split())

def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        count=0
        while n % i==0:
            count+=1
            n = n//i
        if count!=0:
            ass.append((i,count))
    if n != 1:
        ass.append((n,1))
    return ass


ass = prime_factor(m)
ans = 1
for i, amount in ass:
  ans = ans * len(itertools.combinations_with_replacement(range(n-1),amount)) % mod
print(ans)
# print(ass)


### FIXED CODE ###

#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,m = map(int,input().split())
class InverseTable:
    __slots__ = ['In', 'fac', 'Ifac']

    def __init__(self, mod, maxnum):
        self.In = [0, 1]; self.fac = [1, 1]; self.Ifac = [1, 1]
        for i in range( 2, maxnum + 1 ):
            self.In.append( ( -self.In[mod % i] * (mod//i) ) % mod )
            self.fac.append( ( self.fac[-1] * i ) % mod )
            self.Ifac.append( (self.Ifac[-1] * self.In[-1]) % mod )
        
    def cmb(self, n, r):
        if ( r<0 or r>n ): return 0
        r = min(r, n-r)
        return self.fac[n] * self.Ifac[r] * self.Ifac[n-r] % mod
    
    def per(self, n, r):
        if ( r<0 or r>n ): return 0
        return self.fac[n] * self.Ifac[n-r] % mod

invt = InverseTable(mod, 10**6)
# maxnum=10**6だとテーブル生成に200ms程かかるので（Pythonだと1000msほど）
# 最大生成領域は問題ごとに要検討

def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        count=0
        while n % i==0:
            count+=1
            n = n//i
        if count!=0:
            ass.append((i,count))
    if n != 1:
        ass.append((n,1))
    return ass


ass = prime_factor(m)
ans = 1
for i, amount in ass:
  ans = ans * invt.cmb(amount+n-1,amount) % mod
print(ans)
# print(ass)
from collections import deque
import numpy as np

def bfs(sy, sx):
    #max = 0
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    que = deque([])
    que.append((sy, sx))
    d[sy][sx] = 0

    while que:
        p = que.popleft()

        for i in range(4):
            nx = p[1] + dx[i]
            ny = p[0] + dy[i]
            #a = temp[ny][nx]
            if 0<=nx<W and 0<=ny<H and maze[ny][nx]!="#":
                #que.append((nx))
                temp[ny][nx] = d[p[0]][p[1]] + 1
                a = temp[ny][nx]
                #d[ny][nx] = d[p[0]][p[1]] + 1
                if a < d[ny][nx]:
                    que.append((ny, nx))
                    d[ny][nx] = a
                    #if max < d[ny][nx]:
                        #max = d[ny][nx]

    return np.max(np.array(d))

H, W = map(int, input().split())
d = [[float("inf")]*W for i in range(H)]
temp = [[float("inf")]*W for i in range(H)]
#maze = [list(input()) for i in range(H)]
slist = []
for i in range(H):
    #for j in range(W):
    maze[i] = list(input())
    if "#" in maze[i]
        slist.append((i, maze[i].index("#")))



for i in slist:
    s = bfs(i[0], i[1])

print(s)


### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
grid = [input() for i in range(H)]

# 初期の黒('#')の位置からの距離
dist = [[-1]*W for _ in range(H)]

# '#'の位置をキューに追加（＝今回はこれが複数あるので、複数スタートとなる）
black_cells = deque()
for h in range(H):
    for w in range(W):
        if grid[h][w] == '#':
            black_cells.append((h, w))
            dist[h][w] = 0

def bfs(black_cells, dist):
    """
    BFSを用いて、全マス目を黒くする回数を求める

    Args:
        black_cells: 「開始時の黒マス」の座標が入ったキュー（複数座標あり）
        dist: 「開始時の黒マス」からの距離の入ったリスト  [[-1, -1, 0], ...]
        　　　（白マスの初期値は0）

    Returns:
        g: 操作を繰り返した数
    """
    d = 0
    while black_cells:
        # キューとして使うのでpop()ではなくpopleft()
        h, w = black_cells.popleft()
        d = dist[h][w]
        for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            new_h = h + dy
            new_w = w + dx
            if new_h < 0 or H <= new_h or new_w < 0 or W <= new_w:
                continue
            if dist[new_h][new_w] == -1:  # セルが白('.')であるのと同義
                dist[new_h][new_w] = d+1
                black_cells.append((new_h, new_w))
    return d

d = bfs(black_cells, dist)
print(d)
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 20 13:50:17 2019

@author: yama
"""

n = int(input())
l = list(map(int, input().split()))

l = l+l
xl = []
for i in range(2):
    a = 0
    m = False
    for j in range(i, n+i):
        if m is False:
            a += l[j]
            m = True
        else:
            a -= l[j]
            m = False
    xl.append(a)
    
for i in range(2, n):
    xl.append3(xl[-2] - l[i-2]*2 + l[i-1]*2)
    
print(" ".join(map(str, xl)))

### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))

l = l+l
xl = []
for i in range(2):
    a = 0
    m = False
    for j in range(i, n+i):
        if m is False:
            a += l[j]
            m = True
        else:
            a -= l[j]
            m = False
    xl.append(a)
    
for i in range(2, n):
    xl.append(xl[-2] - l[i-2]*2 + l[i-1]*2)
    
print(" ".join(map(str, xl)))
# -*- coding: utf-8 -*-

i = input()

c = 0
c_list = []

if len(i) == 1:
    if i in ['A', 'C', 'G', 'T']:
        print(1)
        exit()
    else:
        print(0)
        exit()

for moji in i:
    if moji in ['A', 'C', 'G', 'T']:
        c += 1
    else:
        c_list.append(c)
        c = 0

print(max(c_list))

### FIXED CODE ###

# -*- coding: utf-8 -*-

i = input()

c = 0
c_list = []

if len(i) == 1:
    if i in ['A', 'C', 'G', 'T']:
        print(1)
        exit()
    else:
        print(0)
        exit()

for moji in i:
    if moji in ['A', 'C', 'G', 'T']:
        c += 1
        c_list.append(c)
    else:
        c_list.append(c)
        c = 0

print(max(c_list))
n,k=map(int,input().split())
num=[0]*k
for i in range(n):
    num[i%k]+=1
for a in range(k):
    b=(k-a)%k
    c=(k-a)%k
    if (b+c)%k!=0:continue
    res+=num[a]*num[b]*num[c]
print(res)


### FIXED CODE ###

n,k=map(int,input().split())
num=[0]*k
for i in range(1,n+1):
    num[i%k]+=1
res=0
for a in range(k):
    b=(k-a)%k
    c=(k-a)%k
    if (b+c)%k!=0:continue
    res+=num[a]*num[b]*num[c]
print(res)
n=int(input())
sum=0
while (n != 0):
  sum = sum + n % 10; 
  n = n/10; 
if(sum%9==0):
  print("Yes")
else:
  print("No")    
     

### FIXED CODE ###

n=str(input())
sum=0
for i in range(len(n)):
    sum+=int(n[i]); 
if(sum%9==0):
  print("Yes")
else:
  print("No")
a,b=map(int,input().split())
if (a+b) % 4 ==0:
  print(int((a+b)/4))
  else:
    print("IMPOSSIBLE")

### FIXED CODE ###

a,b=map(int,input().split())
if (a+b) % 2 ==0:
  print(int((a+b)/2))
else:
  print("IMPOSSIBLE")
D = map(int(),input().split())

if D[2] > D[0] + D[1]:
  print(No)
else:
  print(Yes)

### FIXED CODE ###

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

if D[2] > D[0] + D[1]:
  print("No")
else:
  print("Yes")
s=input()
n=len(s)
def dfs(i,k):
  if i<n-1:
    return dfs(i+1,k+s[i+1])+dfs(i+1,k+"+"+s[i+1])
  return sum(list(map(int,input().split("+"))))
print(dfs(0,s[0])

### FIXED CODE ###

def dfs(i,k):
  if i<n-1:
    return dfs(i+1,k+s[i+1])+dfs(i+1,k+"+"+s[i+1])
  return sum(list(map(int,k.split("+"))))
s=input()
n=len(s)
print(dfs(0,s[0]))
o=input()
e=input()
ans=""
for i in range(len(e)):
    ans+=o[i]
    ans+=e[i]
if len(o)!=len(e):
    ans+=o[len(o)-1]
print(ans)


### FIXED CODE ###

a,b,c=map(int,input().split())
if b-a==c-b:
    print("YES")
else:
    print("NO")
BIG = 10**9+7

N,M = map(int,input().split())
a = []
for i in range(M):
    a.append(int(input()))

pre = a[0]
dame = False
for i in range(1,len(a)):
    if a[i]==pre:
        dame = True
    pre=a[i]

dp = [0 for i in range(N+1)]
for item in a:
    dp[item]=-1
if a[0]!=0:
    dp[0] = 1
if a[0]!=0:
    if (len(a)>1 and a[1]!=0) or a[0]!=1:
        dp[1] = 2

if a[0] == 1:
    dp[1] = 0

for i in range(2,N+1):
    if dp[i]!= -1:
        dp[i] = dp[i-1]+dp[i-2]
        dp[i] = dp[i]%BIG
    else:
        dp[i]=0

#print(dp)

if dame:
    print(0)
else:
    print(dp[-1])

### FIXED CODE ###

BIG = 10**9+7

N,M = map(int,input().split())
a = []
for i in range(M):
    a.append(int(input()))


dp = [0 for i in range(N+1)]
for item in a:
    dp[item]=-1
dp[0]=1
if 1 in a:
    dp[1] = 0
else:
    dp[1] = 1

for i in range(2,N+1):
    if dp[i]!= -1:
        dp[i] = dp[i-1]+dp[i-2]
        dp[i] = dp[i]%BIG
    else:
        dp[i]=0

print(dp[-1])
n, m = map(int, input().split())
L = [0] * m
R = [0] * m
for i in range(m):
    L[i], R[i] = map(int, input().split())
print(min(R) - max(L) + 1 if min(R) >= max(L else 0))

### FIXED CODE ###


n, m = map(int, input().split())
L = [0] * m
R = [0] * m
for i in range(m):
    L[i], R[i] = map(int, input().split())
print(min(R) - max(L) + 1 if min(R) >= max(L) else 0)
N, T = map(int, input().split())
A = list(map(int, input().split()))

max_bef = 0
cnt = 0
A_min = A[0]

for i in range(1,N):
    tmp = A[i] - A_min
    if max_bef < tmp:
        max_bef = tmp
        cnt = 1
    if max_bef == tmp:
        cnt += 1
    a_min = min(a_min, a[i])

print(cnt)


### FIXED CODE ###

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

max_bef = 0
cnt = 0
A_min = A[0]

for i in range(1,N):
    tmp = A[i] - A_min
    if max_bef < tmp:
        max_bef = tmp
        cnt = 0
    if max_bef == tmp:
        cnt += 1
    A_min = min(A_min, A[i])

print(cnt)
# 最大公約数gcd, 
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

# 最小公倍数lcm
def lcm(a, b):
    return (a*b) // gcd(a,b)

a, b, c, d = (int(i) for i in input().split())

cd = lcm(c,d)
r = b-a+1

min_c = math.ceil(a/c)
max_c = math.floor(b/c)
min_d = math.ceil(a/d)
max_d = math.floor(b/d)
min_cd = math.ceil(a/cd)
max_cd = math.floor(b/cd)

c_num = max_c-min_c+1
d_num = max_d-min_d+1
cd_num = max_cd-min_cd+1

print(r-c_num-d_num+cd_num)


### FIXED CODE ###

import math
# 最大公約数gcd, 
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

# 最小公倍数lcm
def lcm(a, b):
    return (a*b) // gcd(a,b)

a, b, c, d = (int(i) for i in input().split())

cd = lcm(c,d)
r = b-a+1

min_c = a//c + (1 if a%c!=0 else 0)
max_c = b//c
min_d = a//d + (1 if a%d!=0 else 0)
max_d = b//d
min_cd = a//cd + (1 if a%cd!=0 else 0)
max_cd = b//cd

c_num = max_c-min_c+1
d_num = max_d-min_d+1
cd_num = max_cd-min_cd+1

print(r-c_num-d_num+cd_num)
N = int(input())
l = []
for i in range(N):
    A = int(input())
    if A in l:
        print("NO")
        exit()
    l.append(i)
print("YES")

### FIXED CODE ###

N = int(input())
A = set(map(int, input().split()))
print("YES" if len(A) == N else "NO")
def check(list,a,b,c,d):
    if c==d:
        return False
    i=a
    counter1=0
    while i<b:
        if list[i]=='#':
            counter1+=1
        else:
            counter1=0
        if counter1>=2:
            return False
        i+=1
    counter1=0
    check2,counter2=0,0
    i+=1
    while i<min(c,d):
        if list[i]=='#':
            counter1+=1
            counter2=0
        else:
            counter2+=1
            counter1=0
        if counter1>=2:
            return False
        if counter2>=3:
            check2+=1
        i+=1
    i+=1
    counter1=0
    while i<max(c,d):
        if list[i]=='#':
            counter1+=1
        else:
            counter1=0
        if counter1>=2:
            return False
        i+=1
    if d>c:
        return True
    else:
        if check2>=1:
            return True
        else:
            return False
m=list(map(int,input().strip().split()))
l=list(input())
if check(l,m[1],m[2],m[3],m[4]):
    print('Yes')
else:
    print('No')


### FIXED CODE ###

def give(list):
    i=0
    count=0
    count1=0
    while i<len(list)-2:
        if list[i]=='A':
            count1+=1
            if list[i]=='A' and list[i+1]=='B' and list[i+2]=='C':
                list[i+2]='A'
                
                i+=2
                count+=count1
                count1-=1
                
            else:
                i+=1
        else:
            count1=0
            i+=1
    return count
s=list(input())
print(give(s))
g=raw_input().split()
a=int(g[0])
b=int(g[1])
if a%2=b%2:
  print((a+b)/2)
else:
  print("IMPOSSIBLE")

### FIXED CODE ###

g=raw_input().split()
a=int(g[0])
b=int(g[1])
if a%2==b%2:
  print((a+b)/2)
else:
  print("IMPOSSIBLE")
def solve(S):
    if S in ["dream","dreamer","erase","eraser"]:
        return True
    elif len(S) <= 7:
        return False

    if S[0:7] == "dreamer":
        return solve(S[7:]) or solve(S[5:])
    elif S[0:5] == "dream":
        return solve(S[5:])
    if S[0:6] == "eraser":
        return solve(S[6:])
    elif S[0:5] == "erase":
        return solve(S[5:])

    return False

print("YES" if solve(input()) else "NO")

### FIXED CODE ###

s = input()[::-1]
flag = 1
i = 0
while i < len(s):
    if s[i:i+5] == "maerd" or s[i:i+5] == "esare":
        i += 5
    elif s[i:i+6] == "resare":
        i += 6
    elif s[i:i+7] == "remaerd":
        i += 7
    else:
        flag = 0
        break

print("YES" if flag else "NO")
x = raw_input().split()
m = map(int,x)

m.sort()
a = m[0]
b = m[1]
c = m[2]

print a,b,c

### FIXED CODE ###

a = list(map(int,input().split()))
for i in range(len(a)):
    for j in range(i,len(a)):
        if a[i] > a[j]:
            ret = a[i]
            a[i] = a[j]
            a[j] = ret
print(" ".join(list(map(str,a))))
import itertools
L,R=map(int,input().split())
c=list(itertools.combinations(range(L,R+1),2))
_min=2018
for i in c:
  a=(i[0]*i[1])%2019
  if a<_min:
    _min=a
print(_min)    


### FIXED CODE ###

L,R=map(int,input().split())
_min=2018
if L==0:
  _min=0
else:  
  for l in range(L,L+2019):
    if l>R:
      break
    for r in range(l+1,l+2020):
      if r>R:
        break
      m=(l*r)%2019
      if _min>m:
        _min=m
print(_min)
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

ABC = []
for i in range(X):
    for j in range(Y):
        if i + 1 + j + 1 > K:
            break
        for k in range(Z):
            if i + 1 + j + 1 + k + 1 > K:
                break
            ABC.append(A[i] + B[j] + C[k])

ABC.sort(reverse=True)
for i in range(K):
    print(ABC[i])


### FIXED CODE ###


list = []
for i in range(6):
    a = int(input())
    list.append(a)

flag = False
for i in range(5):
    for j in range(i+1, 5):
        if list[j] - list[i] > list[5]:
            flag = True

if flag:
    print(':(')
else:
    print('Yay!')
import math

def P(n, r):
    return math.factorial(n)//math.factorial(n-r)

def C(n, r):
    return P(n, r)//math.factorial(r)

bignum = 1000000007

N,K = map(int,input().split())
R = N - K

for i in range(1,K+1):
    tmp = C(R+1,i) * C(K-1,i-1)
    print(tmp % bignum)

### FIXED CODE ###

import math

def combi(n ,k):
    return math.factorial(n)//(math.factorial(k)*math.factorial(n-k))

N,K = map(int,input().split())
R = N - K

for i in range(1,K+1):
    if R + 1 >= i:
        tmp = combi(R+1,i) * combi(K-1,i-1)
    else:
        tmp = 0
    print(tmp % (10**9+7))
N = int(input())
R = int(input())

if(N<10):
  print(R+100*(10-N))
else:
  print(R)

### FIXED CODE ###

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

if(N<10):
  print(R+100*(10-N))
else:
  print(R)