Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

def solve():
    s = input()
    t = input()
    for i in range(len(s)):
        if s[i] != t[i]:
            tmp = s[i]
            s = s.replace(s[i], '*')
            s = s.replace(t[i], tmp)
            s = s.replace('*', t[i])
    if s == t:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    solve()


### FIXED CODE ###

from collections import Counter
def solve():
    s = input()
    t = input()
    s_cnt = Counter(s)
    t_cnt = Counter(t)
    if all(sv == tv for sv, tv in zip(sorted(s_cnt.values()), sorted(t_cnt.values()))):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    solve()
### BUGGY CODE ###

n = int(input())

s = []
for i in range(n):
    s.append(input())

result = 0
for offset in range(n):
    is_symmetry = True
    for i in range(n):
        for j in range(i+1, n):
            if s[i][(j+offset)%n] != s[j][(i+offset)%n]:
                is_symmetry = False
                break
        if not is_symmetry:
            break
    if is_symmetry:
        result += n

print(result)

### FIXED CODE ###

n = int(input())

s = []
for i in range(n):
    s.append(input())

result = 0

def judge(board):
    for i in range(n):
        for j in range(i+1, n):
            if board[i][j] != board[j][i]:
                return 0
    return 1

result = 0
for i in range(n):
    board = s[i:] + s[:i]
    result += n * judge(board)

print(result)
### BUGGY CODE ###

import sys

def input(): return sys.stdin.readline().strip()

h, w, k = map(int, input().split())
s = []
for i in range(h):
    s.append(list(map(int, input())))

ans = h + w - 2
for i in range(1<<(h-1)):
    l = []
    tmp = s[0]
    for j in range(h-1):
        if i >> j & 1:
            tmp = [tmp[m] + s[j+1][m] for m in range(w)]
        else:
            l.append(tmp)
            tmp = s[j+1]
    l.append(tmp)
    c = [0] * len(l)
    cnt = 0
    flag = False
    j = 0
    while j < w:
        for m in range(len(l)):
            c[m] += l[m][j]
            if c[m] > k:
                flag = True
        if flag:
            c = [0] * len(l)
            cnt += 1
            flag = False
            j -= 1
        j += 1
    ans = min(ans, len(l) + cnt - 1)

print(ans)

### FIXED CODE ###

H, W, K = map(int, input().split())
S = [list(input()) for _ in range(H)]

res = float('inf')
for i in range(2**(H-1)):
    c = bin(i).count('1')
    cnt = c
    sum_l = [0] * (c+1)
    j = 0
    flag = True
    while j < W:
        tmp = sum_l.copy()
        pos = 0
        for k in range(H):
            if S[k][j] == '1':
                tmp[pos] += 1
            if (i >> k) & 1:
                pos += 1
        if max(tmp) <= K:
            sum_l = tmp.copy()
            j += 1
            flag = False
        else:
            if flag:
                cnt = float('inf')
                break
            cnt += 1
            flag = True
            sum_l = [0] * (c+1)

    res = min(res, cnt)

print(res)
### BUGGY CODE ###

import bisect

n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = []
for _ in range(m):
    tmp = list(map(int,input().split()))
    bc.append(tmp[::-1])

a.sort()
bc.sort(reverse=True)

ans = 0
num = 0
for i in range(m):
    index = bisect.bisect_left(a[num:],bc[i][0])
    if index == 0:
        break
    if bc[i][1] > index:
        ans += bc[i][0] * index
        num += index
    else:
        ans += bc[i][0] * bc[i][1]
        num += bc[i][1]

print(ans + sum(a[num:]))


### FIXED CODE ###

import sys

def main():
    input = sys.stdin.readline

    n,m = map(int,input().split())
    a = list(map(int,input().split()))
    bc = []
    for _ in range(m):
        bc.append(list(map(int,input().split())))

    a.sort()
    a = tuple(a)

    bc.sort(key=lambda x: x[1], reverse=True)

    num = 0
    ans = 0

    for i in range(m):
        b = bc[i][0]
        c = bc[i][1]
        for j in range(num,min(num+b,n)):
            if c > a[j]:
                ans += c
            else:
                ans += a[j]

        num += b
        if num >= n:
            break

    if num < n:
        print(ans + sum(a[num:]))
    else:
        print(ans)
if __name__ == '__main__':
    main()
### BUGGY CODE ###

n, k = map(int, input().split())
mod = 10**9 + 7

def factorial(n):
	total = 1
	for i in range(1, n+1):
		total *= i
	return total

def nck(a,b):
    return factorial(a) // (factorial(b) * factorial(a - b))

for i in range(1, k + 1):
	print((nck(n-k+1,i) * factorial(k-1) // (factorial(i-1) * factorial(k-i))) % mod)


### FIXED CODE ###

n, k = map(int, input().split())
mod = 10**9 + 7

fact = [1] * (n+1)

for i in range(2, n+1):
	fact[i] = fact[i-1] * i


def nck(a,b):
    return fact[a] // (fact[b] * fact[a - b])

for i in range(1, k + 1):
	print((nck(n-k+1,i) * fact[k-1] // (fact[i-1] * fact[k-i])) % mod)
### BUGGY CODE ###

import sys

input = sys.stdin.buffer.readline

n, x, mod = map(int, input().split())
ans = 0
temp = x
num = 1
while temp < mod:
    temp *= x
    num += 1


A = [0] * (mod + 1)

if temp == mod:
    A[1] = x % mod
    ans += A[1]
    for i in range(2, num + 1):
        A[i] = A[i - 1] * A[i - 1] % mod
        ans += A[i]
        # print(ans)
    print(ans)
    exit()

kouho = {}
if n < mod:
    A[1] = x % mod
    ans += A[1]
    for i in range(2, n + 1):
        A[i] = A[i - 1] * A[i - 1] % mod
        ans += A[i]
        # print(ans)
else:
    A[1] = x
    ans += A[1]
    kouho[A[1]] = 1
    for i in range(2, mod + 1):
        A[i] = A[i - 1] * A[i - 1] % mod
        if A[i] in kouho:
            migi = i
            break
        kouho[A[i]] = i
    saisho = 0
    hidari = kouho[A[i]]
    for i in range(1, hidari):
        saisho += A[i]

    cycle_val = 0
    for i in range(hidari, migi):
        cycle_val += A[i]

    cycle = migi - hidari
    kaisu = n // cycle
    amari = n % cycle - (hidari - 1)
    amari %= cycle
    kaisu = (n - (amari + hidari - 1)) // cycle
    amari_val = 0
    for i in range(hidari, hidari + amari):
        amari_val += A[i]
    ans = saisho + cycle_val * kaisu + amari_val
print(ans)



### FIXED CODE ###

import sys

input = sys.stdin.buffer.readline

n, x, mod = map(int, input().split())
ans = 0
temp = x
num = 1
# while temp < mod:
#     temp *= x
#     num += 1


A = [0] * (mod + 1)

kouho = {}
if n < mod:
    A[1] = x % mod
    ans += A[1]
    for i in range(2, n + 1):
        A[i] = A[i - 1] * A[i - 1] % mod
        ans += A[i]
        # print(ans)
else:
    A[1] = x
    ans += A[1]
    kouho[A[1]] = 1
    temp = A[1]
    i = 1
    migi = 1
    for i in range(2, mod + 1):
        A[i] = temp * temp % mod
        if A[i] in kouho:
            migi = i
            break
        kouho[A[i]] = i
        temp = A[i]
    saisho = 0
    hidari = kouho[A[i]]
    saisho = sum(A[1:hidari])
    # for i in range(1, hidari):
    #     saisho += A[i]
    cycle_val = sum(A[hidari:migi])
    # cycle_val = 0
    # for i in range(hidari, migi):
    #     cycle_val += A[i]
    cycle = migi - hidari
    if cycle >= 2:

        kaisu = n // cycle
        amari = n % cycle - (hidari - 1)
        amari %= cycle
        kaisu = (n - (amari + hidari - 1)) // cycle
        amari_val = sum(A[hidari : hidari + amari])
        # amari_val = 0
        # for i in range(hidari, hidari + amari):
        #     amari_val += A[i]
        ans = saisho + cycle_val * kaisu + amari_val
    else:
        ans = 0
        if cycle == 0:
            for j in range(1, i + 1):
                ans += A[j]
        else:
            for j in range(1, i + 1):
                ans += A[j]
            ans += (n - i) * A[j]
print(ans)
### BUGGY CODE ###

import math

n = int(input())

for i in range(1, n+1):
  if i <= 5:
    print(0)
  else:
    max = math.floor(math.sqrt(i-5))
    cnt = 0
    for x in range(1, max+1):
      for y in range(1, max+1):
        for z in range(1, max+1):
          if x**2 + y**2 + z**2 + x*y + y*z + z*x == i:
            cnt += 1
    print(cnt)


### FIXED CODE ###

n = int(input())

ans = [0 for _ in range(10001)]
for x in range(1, 100):
  for y in range(1, 100):
    for z in range(1, 100):
      v = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if v < 10001:
        ans[v] += 1

for i in range(n):
  print(ans[i+1])
### BUGGY CODE ###

import collections
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
val = list(c.values())
key = list(c.keys())
cosum = 0
for i in val:
    cosum += (i*(i-1))//2
for i in range(n):
    ind = key.index(a[i])
    count = cosum
    count -= val[ind]-1
    print(count)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = [0]*n
for i in range(n):
    b[a[i]-1] += 1
c = sum([(i*(i-1))//2 for i in b])
for i in a:
    print(c-(b[i-1]-1))
### BUGGY CODE ###

def sq(a, b, mod):  # aのb乗を剰余,kは初期値#20191116-D-Knight
    if b == 0:
        return 1
    elif b % 2 == 0:
        return sq(a, b // 2, mod)**2 % mod
    else:
        return sq(a, b - 1, mod) * a % mod


def nCk(n, k, mod=10 ** 9 + 7):
    x = max(k, n - k)
    y = min(k, n - k)
    kkai = 1
    for i in range(2, y + 1):
        kkai = (kkai * i) % mod
    nkkai = 1
    for i in range(x + 1, n + 1):
        nkkai = (nkkai * i) % mod
    answer = sq(kkai, mod - 2, mod) * nkkai % mod
    return answer
ans = 0
mod = 10**9+7

n, a, b = map(int, input().split())
for i in range(1, n+1):
    if i == a or i == b:
        continue
    ans += nCk(n, i)
    ans %= mod
print(ans)

### FIXED CODE ###

def sq(a, b, mod):  # aのb乗を剰余,kは初期値#20191116-D-Knight
    if b == 0:
        return 1
    elif b % 2 == 0:
        return sq(a, b // 2, mod)**2 % mod
    else:
        return sq(a, b - 1, mod) * a % mod


def nCk(n, k, mod=10 ** 9 + 7):
    x = max(k, n - k)
    y = min(k, n - k)
    kkai = 1
    for i in range(2, y + 1):
        kkai = (kkai * i) % mod
    nkkai = 1
    for i in range(x + 1, n + 1):
        nkkai = (nkkai * i) % mod
    answer = sq(kkai, mod - 2, mod) * nkkai % mod
    return answer

mod = 10**9+7
n, a, b = map(int, input().split())

def modpow(x, y):
    res = 1
    while y > 0:
        if y & 1:
            res = res*x % (10**9+7)
        x = x*x%(10**9+7)
        y >>= 1
        y = int(y)
    return res
ans = 0
ans -= nCk(n, b)
ans -= nCk(n, a)
ans -= 1
ans += modpow(2, n)
print((ans+10**9+7)%(10**9+7))
### BUGGY CODE ###

S = list(input())
s = sorted(S)[::-1]
def change(x):
    n = len(x) - 1
    rev = x[::-1]
    indexB = x.index('B')
    indexW = n -  rev.index('W')
    x[indexB] = 'W'
    x[indexW] = 'B'
    return indexW - indexB
cnt = 0 
while True:
    if s == S:
        break
    cnt += change(S)
print(cnt)


### FIXED CODE ###

N = input()
cnt1 = 0
for x in N:
  if x == 'B':
    cnt1 += 1
N = N[::-1]
ans =  0
cnt2 = 0
for i in range(len(N)):
  if N[i] == 'B':
    ans += i - cnt2
    cnt2 += 1
print(ans)
### BUGGY CODE ###

n, x, y = map(int, input().split())
x, y = x-1, y-1


def update(dist, queue, d, x):
    if dist[x] >= 0: return dist, queue
    dist[x] = d+1
    queue.append(x)
    return dist, queue

ans = [0 for _ in range(n)]
for i in range(n):
    dist = [-1 for _ in range(n)]
    dist[i] = 0
    queue = [i]
    while True:
        if len(queue) == 0: break
        now = queue.pop(0)
        d = dist[now]
        if now-1 >= 0:
            dist, queue = update(dist, queue, d, now-1)
        if now+1 < n:
            dist, queue = update(dist, queue, d, now+1)
        if now == x:
            dist, queue = update(dist, queue, d, y)
        if now == y:
            dist, queue = update(dist, queue, d, x)
    for d in dist:
        ans[d] += 1

for a in ans[1:]:
    print(a//2)

### FIXED CODE ###

n, x, y = map(int, input().split())
x, y = x-1, y-1


def update(dist, queue, d, x):
    if dist[x] >= 0: return dist, queue
    dist[x] = d+1
    queue.append(x)
    return dist, queue

ans = [0 for _ in range(n)]
for i in range(n):
    dist = [-1 for _ in range(n)]
    dist[i] = 0
    queue = [i]
    while True:
        if len(queue) == 0: break
        now = queue.pop(0)
        d = dist[now]
        if now-1 >= 0:
            dist, queue = update(dist, queue, d, now-1)
        if now+1 < n:
            dist, queue = update(dist, queue, d, now+1)
        if now == x:
            dist, queue = update(dist, queue, d, y)
        if now == y:
            dist, queue = update(dist, queue, d, x)
    for d in dist:
        ans[d] += 1

for a in ans[1:]:
    print(a//2)
### BUGGY CODE ###

n = int(input())
a_list = [int(input()) for _ in range(n)]

for i in range(n):
  print(max(a_list[:i]+a_list[i+1:])) 

### FIXED CODE ###

n = int(input())
a_list = [int(input()) for _ in range(n)]
m1 = max(a_list)
k = a_list.index(m1)
m2 = max(a_list[:k]+a_list[k+1:])
for i in range(n):
  if i == k:
    print(m2)
  else:
    print(m1)
### BUGGY CODE ###

import copy
S=list(input())

dp=[0 for i in range(13)]
dp[0] = 1

i=0
for k in reversed(S):
    dpcopy=dp.copy()
    dp=[0 for i in range(13)]
    if k=='?':
        for s in range(10):
            for j in range(13):               
                dp[(s * 10**(i) + j) % 13] += dpcopy[j]%(10**9+7)
    else:
        k=int(k)
        for j in range(13):
            dp[(k * 10**(i) + j) % 13] += dpcopy[j]%(10**9+7)
    i += 1


print(dp[5]%(10**9+7))

### FIXED CODE ###

S = [int(x) if x != '?' else - 1 for x in input()]
le=len(S)

dp = [[0]*13 for i in range(le+1)]
dp[0][0] = 1

i=0
for k in S:
    if k==-1:
        for s in range(10):
            for j in range(13):
                dp[i + 1][(s + j*10) % 13] += dp[i][j]%(10**9+7)

    else:
        k=int(k)
        for j in range(13):
            dp[i + 1][(j *10 + k) % 13] += dp[i][j]%(10**9+7)
        
    i += 1


print(dp[le][5]%(10**9+7))
### BUGGY CODE ###

n = int(input())
startlist=[]
for _ in range(n):
    startlist.append(input())
dictlist=sorted(startlist)
setlist=sorted(list(set(dictlist)))
countlist=[0]*(int(len(setlist)))
count=1
count2=1
for i in range(n):
    if i==n-1:
        countlist[i-count2+1]+=count
    elif dictlist[i+1]==dictlist[i]:
        count+=1
        count2+=1
    else:
        countlist[i-count2+1]+=count
        count=1
indexlist=[i for i,x in enumerate(countlist) if x==max(countlist)]
for j in tuple(indexlist):
    print(setlist[j])

### FIXED CODE ###

n = int(input())
countmax=0
anslist=[]
dic={}
for i in range(n):
    a=input()
    if a in dic:
        dic[a]+=1
    else:
        dic[a]=1
    if dic[a]>countmax:
        countmax=dic[a]
for j in dic.keys():
    if dic[j]==countmax:
        anslist.append(j)
b=sorted(anslist)
for i in b:
    print(i)
### BUGGY CODE ###


def resolve():
    # 達成スコアを決める
    # 修行回数がK以下を達成できるスコアを二分探索
    def check(X):
        cnt = 0
        for i in range(N):
            a = X // F[i]
            if a < A[i]:  # 修行をしてスコアを最小化する
                cnt += A[i] - a
        return cnt <= K

    N, K = map(int, input().split())
    A = sorted(map(int, input().split()))
    F = sorted(map(int, input().split()), reverse=True)

    ok = 10 ** 18
    ng = -1
    while ok - ng > 1:
        X = (ok + ng) // 2
        if check(X):
            ok = X
        else:
            ng = X

    print(ok)


if __name__ == "__main__":
    resolve()

### FIXED CODE ###


def resolve():
    # 達成スコアを決める
    # 修行回数がK以下を達成できるスコアを二分探索
    def check(X):
        cnt = 0
        for i in range(N):
            a = X // F[i]
            if a < A[i]:  # 修行をしてスコアを最小化する
                cnt += A[i] - a
        return cnt <= K

    N, K = map(int, input().split())
    A = sorted(map(int, input().split()))
    F = sorted(map(int, input().split()), reverse=True)

    ok = 10 ** 12 # 最大スコア a: 10**6 * x:10**6
    ng = -1
    while ok - ng > 1:
        X = (ok + ng) // 2
        if check(X):
            ok = X
        else:
            ng = X

    print(ok)


if __name__ == "__main__":
    resolve()
### BUGGY CODE ###

s = list(input())

ans = 0
i = 0
while i+2 < len(s):
    if s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C':
        ans += 1
        s[i] = 'B'
        s[i+1] = 'C'
        s[i+2] = 'A'
        i = max(0,i-1)
    else:
        i += 1

print(ans)

### FIXED CODE ###

s = input()

s = s.replace('BC', 'D')
ans = 0
a = 0
for c in s:
    if c == 'A':
        a += 1
    elif c == 'D':
        ans += a
    else:
        a = 0

print(ans)
### BUGGY CODE ###

S = str(input())
count = 0;
while(True):
  if 'BW' in S:
    count=count+S.count('BW');
    S = S.replace('BW','WB');
  else:
    break;
print(count)

### FIXED CODE ###

S = input()
ans = 0
tmp = 0
for i in range(len(S)):
  if S[i] == 'W':
    ans+=i-tmp
    tmp+=1
print(ans)
### BUGGY CODE ###

def main():
    from sys import stdin
    from collections import deque
    import sys
    H, W = map(int, stdin.readline().split())
    ch, cw = map(int, stdin.readline().split())
    dh, dw = map(int, stdin.readline().split())
    ch, cw, dh, dw = ch-1, cw-1, dh-1, dw-1
    S = [input() for _ in range(H)]
    d = [[0]*W for _ in range(H)]

    que = deque([[cw, ch]])
    count = 0
    while que:
        while que:
            x, y = que.popleft()
            if x == dw and y == dh:
                print(count)
                sys.exit()
                
            d[y][x] = -1
            for i in range(-2, 3):
                for j in range(-2, 3):
                    nnx, nny = x+i, y+j
                    if 0<=nnx<W and 0<=nny<H and d[nny][nnx]==0 and S[nny][nnx]!='#':
                        d[nny][nnx] = 1
        
            for dx, dy in [1, 0], [0, 1], [-1, 0], [0, -1]:
                nx, ny = x+dx, y+dy
                if 0<=nx<W and 0<=ny<H and S[ny][nx]!='#' and d[ny][nx]!=-1:
                    if nx == dw and ny == dh:
                        print(count)
                        sys.exit()
                
                    d[ny][nx] = -1
                    for i in range(-2, 3):
                        for j in range(-2, 3):
                            nnx, nny = nx+i, ny+j
                            if 0<=nnx<W and 0<=nny<H and d[nny][nnx]==0 and S[nny][nnx]!='#':
                                d[nny][nnx] = 1
                    que.append([nx, ny])
                
        for i in range(W):
            for j in range(H):
                if d[j][i] == 1:
                    d[j][i] == -1
                    que.append([i, j])
        count += 1
    print(-1)

main()


### FIXED CODE ###

from collections import deque
H, W = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
ch, cw, dh, dw = ch-1, cw-1, dh-1, dw-1
s = [input() for _ in range(H)]

d = [[-1]*W for _ in range(H)]

que = deque([[cw, ch, 0]])
while que:
    x, y, cost = que.popleft()
    if d[y][x]==-1 or d[y][x]>cost:
        d[y][x] = cost
        for dx in range(-2, 3):
            for dy in range(-2, 3):
                nx, ny = x+dx, y+dy
                if 0<=nx<W and 0<=ny<H and s[ny][nx]!='#':
                    if abs(dx)+abs(dy) == 1:
                        que.appendleft([nx, ny, cost])
                    else:
                        que.append([nx, ny, cost+1])  
print(d[dh][dw])
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n,k,q = map(int,input().split())
A = []
for i in range(q):
    A.append(int(input()))

for i in range(1,n+1):
    if A.count(i) > q-k:
        print('Yes')
    else:
        print('No')



### FIXED CODE ###

import sys
input = sys.stdin.readline
n,k,q = map(int,input().split())
A = [0]*n
for i in range(q):
    A[int(input())-1] +=1

for i in range(n):
    if A[i] > q-k:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

N,K = map(int,input().split())
S = input()

if S.count('1') == N or S.count('0') == N:
  print(N)
  exit()

S += '2'
s = S[0]
L0 = []
if s == '0':
  L1 = [0]
else:
  L1 = []
c = 1
for i in range(1,N+1):
  if S[i] != s:
    if s == '0':
      L0.append(c)
    else:
      L1.append(c)
    s = S[i]
    c = 1
  else:
    c += 1
L1 += [0]
#print(L0)
#print(L1)

if len(L0) <= K:
  print(N)
  exit()

ans = 0
for i in range(len(L0)-K+1):
    ans = max(ans,sum(L0[i:i+K])+sum(L1[i:i+K+1]))
print(ans)


### FIXED CODE ###

N,K = map(int,input().split())
S = input()

if S.count('1') == N or S.count('0') == N:
  print(N)
  exit()

S += '2'
s = S[0]
L0 = []
if s == '0':
  L1 = [0]
else:
  L1 = []
c = 1
for i in range(1,N+1):
  if S[i] != s:
    if s == '0':
      L0.append(c)
    else:
      L1.append(c)
    s = S[i]
    c = 1
  else:
    c += 1
L1 += [0]
#print(L0)
#print(L1)

if len(L0) <= K:
  print(N)
  exit()

SL0 = [0 for _ in range(len(L0)+1)]
for i in range(1,len(L0)+1):
  SL0[i] = SL0[i-1] + L0[i-1]
SL1 = [0 for _ in range(len(L1)+1)]
for i in range(1,len(L1)+1):
  SL1[i] = SL1[i-1] + L1[i-1]

ans = 0
for i in range(len(L0)-K+1):
    #ans = max(ans,sum(L0[i:i+K])+sum(L1[i:i+K+1]))
    ans = max(ans,SL0[i+K]-SL0[i] + SL1[i+K+1]-SL1[i])
print(ans)
### BUGGY CODE ###

import sys
# import numpy as np
from copy import deepcopy
input = sys.stdin.readline


def main():
    N = int(input())
    # A = np.array([int(input()) for _ in range(N)])
    A = [int(input()) for _ in range(N)]
    # print(A)

    for j in range(N):
        B = deepcopy(A)
        del B[j]
        print(max(B))
        # if j != A.index(max(A)):
        #     print(max(A))
        # else:
        #     ans = [x for i, x in enumerate(A) if i != j]
        #     print(max(ans))


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    n = int(input())
    As = [int(input()) for _ in range(n)]

    As_sort = sorted(As)
    second, first = As_sort[-2:]
    for i in range(n):
        if As[i] == first:
            print(second)
        else:
            print(first)


if __name__ == "__main__":
    main()
### BUGGY CODE ###

import numpy as np
from scipy.sparse.csgraph import shortest_path

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

matrix = [[0]*n for _ in range(n)]

for i in range(n-1):
    matrix[i][i+1] = 1
    matrix[i+1][i] = 1


matrix[x-1][y-1] = 1
matrix[y-1][x-1] = 1

matrix = np.array(matrix)

result = shortest_path(matrix)

for k in range(1, n):
    answer = np.sum(result==k) // 2
    print(answer)

### FIXED CODE ###

import numpy as np
from scipy.sparse.csgraph import shortest_path
from scipy.sparse import csr_matrix

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

v = [x-1]
u = [y-1]
for i in range(n-1):
    v.append(i)
    u.append(i+1)

csr = csr_matrix(([1]*n, (v, u)), shape=(n, n))
result = shortest_path(csr, method='D', directed=False).astype(int)
ans = np.bincount(result.ravel(), minlength=n) // 2
print(*ans[1:], sep='\n')
### BUGGY CODE ###

s = input()
s = s[::-1]
lis = ['remaerd', 'resare', 'esare', 'maerd']
i = 0
j = 0
#s = s[::-1]
while i < len(s):
    while True:
        #print(s[i : j])
        if len(s[i : j]) == 8:
            print('NO')
            #quit()
        elif s[i : j] in lis:
            i = j
            break
        else:
            j += 1
print('YES')

### FIXED CODE ###

s = input()
s = s[::-1]
lis = ['remaerd', 'resare', 'esare', 'maerd']
i = 0
j = 0
#s = s[::-1]
while i < len(s):
    tmp = ''
    while j < len(s):
        tmp += s[j]
        #print(tmp)
        if len(tmp) == 8:
            print('NO')
            quit()
        elif tmp in lis:
            i = j + 1
            j = i
            break
        else:
            j += 1
print('YES')