Harryxun/stf_run huggingface dataset:
import sys
sys.setrecursionlimit(10000000000000000)

tree = dict()
cost = dict()

N = int(input())
for i in range(N - 1):
    a, b, c = map(int, input().split())
    if a in tree:
        tree[a].append(b)
    else:
        tree[a] = []
        tree[a].append(b)
    if b in tree:
        tree[b].append(a)
    else:
        tree[b] = []
        tree[b].append(a)
    cost[(a, b)] = c
    cost[(b, a)] = c
starts = []
ends = []
Q, K = map(int, input().split())
for i in range(Q):
    x, y = map(int, input().split())
    starts.append(x)
    ends.append(y)

depth = [10000000000000000 for i in range(N)]

def dps(position, total_cost):
    if depth[position - 1] > total_cost:
        depth[position - 1] = total_cost
    for next_position in tree[position]:
        if depth[next_position - 1] == 10000000000000000:
            dps(next_position, depth[position - 1] + cost[(position, next_position)])

depth[K-1] = 0
dps(K, 0)

for start, end in zip(starts, ends):
    print(depth[start - 1] + depth[end - 1])

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

tree = dict()
cost = dict()

N = int(input())
for i in range(N - 1):
    a, b, c = map(int, input().split())
    if a in tree:
        tree[a].append(b)
    else:
        tree[a] = []
        tree[a].append(b)
    if b in tree:
        tree[b].append(a)
    else:
        tree[b] = []
        tree[b].append(a)
    cost[(a, b)] = c
    cost[(b, a)] = c
starts = []
ends = []
Q, K = map(int, input().split())
for i in range(Q):
    x, y = map(int, input().split())
    starts.append(x)
    ends.append(y)

depth = [1000000000000000 for i in range(N)]

def dps(position, total_cost):
    if depth[position - 1] > total_cost:
        depth[position - 1] = total_cost
    for next_position in tree[position]:
        if depth[next_position - 1] == 1000000000000000:
            dps(next_position, depth[position - 1] + cost[(position, next_position)])

depth[K-1] = 0
dps(K, 0)

for start, end in zip(starts, ends):
    print(depth[start - 1] + depth[end - 1])
while 1:
    n, m = map(int, raw_input().split())
    if n == m == 0:
        break
    S = map(int, raw_input().split())
    left = -1; right = max(S)+2
    def check(mid):
        if 1+mid <= S[0]:
            return 10**9
        cnt = 0; l = 1
        target = S[n-1] - mid
        for i in xrange(n-1):
            assert S[i]<l+mid
            while l <= S[i] and cnt <= m and l<=target:
                l += max(1, mid-(S[i]-l))
                cnt += 1
            if l+mid <= S[i+1] and cnt<=m and l<=target:
                l += max(1, mid-(l-S[i]))
                cnt += 1

                if l <= S[i+1]-mid and l<=target:
                    cnt += min(S[i+1]-mid,target)-l+1
                    l = min(S[i+1]-mid,target)+1
        return cnt
    while left+1 < right:
        mid = (left + right) / 2
        if m <= check(mid):
            left = mid
        else:
            right = mid
    if 10**8 < check(left):
        print -1
    else:
        print right

### FIXED CODE ###

while 1:
    n, m = map(int, raw_input().split())
    if n == m == 0:
        break
    S = map(int, raw_input().split())
    left = 0; right = sum(S)+2
    def check(mid):
        if 1+mid <= S[0]:
            return 10**9
        cnt = 0; l = 1
        target = S[n-1] - mid
        for i in xrange(n-1):
            while l <= S[i] and cnt<=m and l<=target:
                l += mid-(S[i]-l)
                cnt += 1
            if (l+mid <= S[i+1] or abs(l-S[i]) < abs(l-S[i+1])) and cnt<=m and l<=target:
                l += max(1, mid-(l-S[i]))
                cnt += 1
                if l+mid <= S[i+1]:
                    cnt += S[i+1]-mid+1-l
                    l = S[i+1]-mid+1
        return cnt
    while left+1 < right:
        mid = (left + right) / 2
        if m-1 <= check(mid):
            left = mid
        else:
            right = mid
    if 10**8 < check(left):
        print -1
    else:
        print left
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	A,B = MI()
	if(A <= B*2):
		print(0):
	else:
		print(A-2*B)

main()

### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	A,B = MI()
	if(A <= B*2):
		print(0)
	else:
		print(A-2*B)

main()
import numpy as np
from numba import jit

@jit
def do():
    data = np.array(input().split(" "), dtype="int64")
    life = np.array(input().split(" "), dtype="int64")
    monsters = data[0]
    smash = data[1]
    if smash == 0:
        print(np.sum(life))
    elif smash >= monsters:
        print(0)
    else:
        a = np.sort(life)[-smash]
        leftover = np.where(life < a, life, 0)
        print(np.sum(leftover))

do()

### FIXED CODE ###

import numpy as np

def do():
    data = np.array(input().split(" "), dtype="int64")
    life = np.array(input().split(" "), dtype="int64")
    monsters = data[0]
    smash = data[1]
    if smash == 0:
        print(np.sum(life))
    elif smash >= monsters:
        print(0)
    else:
        a = np.sort(life)[-smash]
        leftover = np.where(life < a, life, 0)
        print(np.sum(leftover))

do()
import numpy as np

def Probability(p,n):
    dp = np.zeros((n+1 ,n+1)) 
    for i in range(n+1):
        for j in range(n+1):
            dp[i][j] = 0.0 
    dp[0][0] = 1.0
    
    for i in range(1,n+1):
        for j in range(i+1):
            if j==0:
                dp[i][j] = dp[i - 1][j] * (1.0 - p[i-1]) 
            else : 
                dp[i][j] = (dp[i - 1][j] * (1.0 - p[i-1]) +
                            dp[i - 1][j - 1] * p[i-1])  
    ans=0.0
    for i in range((n+1)//2,n+1):
        ans+=dp[n][i]
    return ans 

n=int(input())
a=list(map(float,input().split()))

 

print(Probability(a,n))



    
        
    
    

### FIXED CODE ###


    

n=int(input())
p=list(map(float,input().split()))

 
dp = [[0 for i in range(n+1)] for j in range(n+1)]
   
dp[0][0] = 1.0

for i in range(1,n+1):
    for j in range(0,n+1):
        if j==0:
            dp[i][j] = dp[i - 1][j] * (1.0 - p[i-1]) 
        else : 
            dp[i][j] = (dp[i - 1][j] * (1.0 - p[i-1]) +
                        dp[i - 1][j - 1] * p[i-1])  
ans=0.0
for i in range((n+1)//2,n+1):
    ans+=dp[n][i]
print( ans)
import math
a,b,c = map(int(input().split()))
if ((math.sqrt(a) + math.sqrt(b)) < math.sqrt(c)):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a,b,c = map(int,input().split(" "))
if (c-a-b)**2 > a*b*4 and c > a + b:
  print("Yes")
else:
  print("No")
N=int(input())
l=list(map(int,input().split()))
a=l.sort()
count=0
for i in range(0,len(l)):
  if l[i]==a[i]:
    count+=1
if count >= N-2:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

N=int(input())
l=list(map(int,input().split()))
a=list(range(1,N+1))
count=0
for i in range(0,len(l)):
  if l[i]==a[i]:
    count+=1
if count >= N-2:
  print("YES")
else:
  print("NO")
N, K, L = map(int, input().split())
#Parent List(PL)
road = [i for i in range(N)]
rail = [i for i in range(N)]

def fp(x,P): #findParent
    if x == P[x]:
        return x
    else:
        P[x] = fp(P[x])
        return P[x]

for i in range(K+L):
    PL = (lambda x:road if x < K else rail)(i)
    p, q = map(lambda x:int(x)-1, input().split())
    p, q = fp(p,PL), fp(q,PL)
    PL[p] = PL[q] = min(p, q)

from collections import defaultdict as dd
Wconnected = dd(lambda:0)
for i in range(N):
    Wconnected[fp(i,road),fp(i,rail)] += 1
print(*[Wconnected[fp(i,road),fp(i,rail)] for i in range(N)])

### FIXED CODE ###

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

def fp(x, parentList): #findParent
    if parentList[x] == x:
        return x
    else:
        parentList[x] = fp(parentList[x], parentList)
        return parentList[x]

#各ノードのparentをリストで表現(連結前は自身がparent)
road = [i for i in range(N)]
rail = [i for i in range(N)]

for _ in range(K):
    p, q = map(int, input().split())
    par_p, par_q = fp(p-1, road), fp(q-1, road) #p, qのparent 
    #連結する際、若い番号をparentとする
    if par_p < par_q:
        road[par_q] = par_p
    else:
        road[par_p] = par_q

#railについても同様
for _ in range(L):
    s, t = map(int, input().split())
    par_s, par_t = fp(s-1, rail), fp(t-1, rail)
    if par_s < par_t:
        rail[par_t] = par_s
    else:
        rail[par_s] = par_t

#連結成分の要素をカウント
cnt = {}
for i in range(N):
    key = (fp(i,road),fp(i,rail))
    if key in cnt:
        cnt[key] += 1
    else:
        cnt[key] = 1
#出力
for i in range(N):
    key = (fp(i,road),fp(i,rail))
    ans = cnt[key]
    print(ans, end=" ")
X, N = map(int, input().split())
P = list(map(int, input().split()))
Q = [i for i in range(1, 101)]
P = list(set(Q) - set(P))
dif = 100
for p in P:
    if abs(X-p) < dif:
        dif = abs(X-p)
        ans = p
print(ans)

### FIXED CODE ###

X, N = map(int, input().split())
P = list(map(int, input().split()))
Q = [i for i in range(-150, 150)]
P = list(set(Q) - set(P))
P.sort()
dif = 100
for p in P:
    if abs(X-p) < dif:
        dif = abs(X-p)
        ans = p
print(ans)
a, b, c = map(int, input().split())
print(a + b + c)


### FIXED CODE ###

a, b, c = map(int, input())
print(a + b + c)
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]
#まず,足場k+1番目までについて,それぞれ最小コスト入れる
for i in range(k):
  dp.append(abs(h[i+1]-h[0]))

#k+2番目以降について,それぞれ最小コストを求める
for i in range(k+1,n):
  #最小のものの候補配列を作る
  temp=[]
  for j in range(k):
    temp.append(abs(h[i]-h[i-j-1])+dp[i-j-1])
  dp.append(min(temp))
print(dp[-1])

### FIXED CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]
#まず,足場k+1番目までについて,それぞれ最小コスト入れる
if n>k-1:
  for i in range(k):
    dp.append(abs(h[i+1]-h[0]))
else:
  print(abs(h[n-1]-h[0]))
  exit()


#k+2番目以降について,それぞれ最小コストを求める
for i in range(k+1,n):
  #最小のものの候補配列を作る
  temp=[]
  for j in range(k):
    temp.append(abs(h[i]-h[i-j-1])+dp[i-j-1])
  dp.append(min(temp))

print(dp[n-1])
import os, sys, re, math

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

match = [-1,2,5,5,4,5,6,3,7,6]
memo = {}

def doit(m):
    if m in memo:
        return memo[m]
    if m == 0:
        return ""

    ret = None
    for a in A:
        tmp = None
        if m - match[a] >= 0:
            tmp = doit(m - match[a])
            if tmp is not None:
                tmp = str(a) + tmp
                if ret is not None:
                    if len(ret) < len(tmp) or (len(ret) == len(tmp) and tmp > ret):
                        ret = tmp
                else:
                    ret = tmp

    memo[m] = ret
    return ret

print(doit(N))


### FIXED CODE ###

import os, sys, re, math
sys.setrecursionlimit(100000)
N,M = list(map(int,input().split(' ')))
A = list(map(int,input().split(' ')))

match = [100,2,5,5,4,5,6,3,7,6]
memo = {}

def doit(m):
    if m in memo:
        return memo[m]
    if m == 0:
        return ""

    ret = None
    for a in A:
        tmp = None
        if m - match[a] >= 0:
            tmp = doit(m - match[a])
            if tmp is not None:
                tmp = str(a) + tmp
                if ret is not None:
                    if len(ret) < len(tmp) or (len(ret) == len(tmp) and tmp > ret):
                        ret = tmp
                else:
                    ret = tmp

    memo[m] = ret
    return ret

print(doit(N))
n = int(input(n))
a = list(map(int,input().split()))

yen = 1000

kabu = 0

for i in range(n-1):
    if a[i] < a[i+1]:
        kabu_today = yen // a[i]
        kabu += kabu_today
        yen = yen % a[i]
        
    else:
        yen += kabu * a[i]
        kabu = 0
    
#    print(yen, kabu,a[i], a[i] < a[i+1])

yen += kabu * a[n-1]
kabu = 0

print(yen)

### FIXED CODE ###

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

yen = 1000

kabu = 0

for i in range(n-1):
    if a[i] < a[i+1]:
        kabu_today = yen // a[i]
        kabu += kabu_today
        yen = yen % a[i]
        
    else:
        yen += kabu * a[i]
        kabu = 0
    
#    print(yen, kabu,a[i], a[i] < a[i+1])

yen += kabu * a[n-1]
kabu = 0

print(yen)
s = input()
a=1
for i in range(len(s)):
  if(s[i]!=s[-i-1]):
    a=0
    break
for i in range((len(s)-1)//2):
  if(s[i]!=s[(len()-3)//2]):
    a=0
if(a==1):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

s=input()
a=1
for i in range(len(s)):
  if(s[i]!=s[-i-1]):
    a=0
    break
for i in range((len(s)-1)//2):
  if(s[i]!=s[(len(s)-3)//2-i]):
    a=0
    break
if(a==1):
  print("Yes")
else:
  print("No")
n = input()
t, a = map(int, input().split())
h_list = list(map(int, input().split()))

temp = abs(a - (t - h[0] * 0.006))
result = 1
i=1
for h in h_list:
    if abs(a - (t - h * 0.006)) < temp:
        temp = abs(a - (t - h * 0.006))
        result = i
    i += 1
print(i)

### FIXED CODE ###

n = input()
t, a = map(int, input().split())
h_list = list(map(int, input().split()))

temp = abs(a - (t - h_list[0] * 0.006))
result = 1
i=1
for h in h_list:
    if abs(a - (t - h * 0.006)) < temp:
        temp = abs(a - (t - h * 0.006))
        result = i
    i += 1
print(result)
n = int(input())

satsu = n / 1000

printf(satsu+1)

### FIXED CODE ###

n = int(input())

if n % 1000 == 0:
    print(0)
else:
    print(1000-n%1000)
N: int = int(input())
graph = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    graph[u].append((v, w))
    graph[v].append((u, w))
qu = [0]
colors = [0 for _ in range(N)]
visited = set()
while len(qu) != 0:
    cur = qu.pop()
    visited.add(cur)
    for nxt, weight in graph[cur]:
        if nxt not in visited:
            colors[nxt] = (colors[cur] + weight)%2
            qu.append(nxt)
for v in colors:print(v)


### FIXED CODE ###

N = int(input())
graph = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    graph[u].append((v, w))
    graph[v].append((u, w))
qu = [0]
colors = [0 for _ in range(N)]
visited = set()
while len(qu) != 0:
    cur = qu.pop()
    visited.add(cur)
    for nxt, weight in graph[cur]:
        if nxt not in visited:
            colors[nxt] = (colors[cur] + weight)%2
            qu.append(nxt)
for v in colors:print(v)
import math
a,b = map(int,input().split())
n = len(b)

c = a*n+b
d = int(math.sqrt(c))
if d**2 == c:
  print("Yes")
else:
  print("No")





### FIXED CODE ###

import math
a,b = map(int,input().split())
n = len(str(b))
     
c = a*(10**n)+b
d = int(math.sqrt(c))
if d**2 == c:
  print("Yes")
else:
  print("No")
import math

A, B, C = map(int, input().split())
maxN = max([A, B, C])
minN = min([A, B, C])
for n in [A, B, C]:
    if n != maxN and n != minN:
        midN = n
diff1 = maxN - midN
diff2 = maxN - minN

if (diff1 % 2 == 0 and diff2 % 2 == 0) or (diff1 % 2 != 0 and diff2 % 2 != 0):
    print((diff1 + diff2) // 2)
else:
    print(math.ceil((diff1 + diff2) / 2) + 1)

### FIXED CODE ###

A, B, C = map(int, input().split())
N = [A, B, C]
maxN = max(N)
sumN = sum(N)
if (3 * maxN - sumN) % 2 != 0:
    maxN += 1
print((3 * maxN - sumN) // 2)
N,M=map(int,input().split())
from collections import defaultdict
branch=defaultdict(set)
for i in range(M):
    a,b=map(int,input().split())
    branch[a]|={b}
    branch[b]|={a}
jisuu=[len(branch[i]) for i in range(N+1)]
def dfs1(check,visited,P):
    while len(check)>0:
        now=check.pop()
        for nex in branch[now]:
            if nex not in visited:
                if jisuu[nex]==1:
                    return P[now]+[nex]
                else:
                    check|={nex}
                    visited|={nex}
                    P[nex]=P[now]+[nex]
def dfs2(check,visited,P,goal):
    while len(check)>0:
        now=check.pop()
        for nex in branch[now]:
            if nex not in visited:
                if nex==goal:
                    return P[now]+[nex]
                else:
                    check|={nex}
                    visited|={nex}
                    P[nex]=P[now]+[nex]
if jisuu.count(1)>=2:
    start=jisuu.index(1)
    visited={start}
    check={start}
    P=[0]*(N+1)
    P[start]=[start]
    path=dfs1(check,visited,P)
    print(1)
    exit()
else:
    for i in range(1,1+N):
        if jisuu[i]==2:
            a,b=list(branch[i])
            if jisuu[a]==2:
                start=i
                goal=a
                nex=b
                break
            elif jisuu[b]==2:
                start=i
                goal=b
                nex=a
                break
    visited={start,nex}
    check={nex}
    P=[0]*(N+1)
    P[start]=[start]
    P[nex]=[start,nex]
    path=dfs2(check,visited,P,goal)
print(len(path))
print(" ".join(map(str,path)))

### FIXED CODE ###

N,M=map(int,input().split())
from collections import deque,defaultdict
branch=defaultdict(set)
for i in range(M):
    a,b=map(int,input().split())
    branch[a-1]|={b-1}
    branch[b-1]|={a-1}
path=deque([0])
for x in branch[0]:
    path.append(x)
    break
used=set(path)
while True:
    A,B=False,False
    if len(branch[path[0]]-used)==0:
        A=True
    else:
        for x in branch[path[0]]:
            if x in used:
                continue
            path.appendleft(x)
            used|={x}
            break
    if len(branch[path[-1]]-used)==0:
        B=True
    else:
        for x in branch[path[-1]]:
            if x in used:
                continue
            path.append(x)
            used|={x}
            break
    if A and B:
        break
path=[p+1 for p in path]
print(len(path))
print(" ".join(map(str,path)))
import math

N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

t1 = math.floor(N / A)
B = (t1 -1 ) * B
N = max(N % A,N-B)

t2 = math.floor(N / B)
C = (t2 -1 ) * C
N = max(N % B,N-C)

t3 = math.floor(N / C)
D = (t3 -1 ) * D
N = max(N % C,N-D)

t4 = math.floor(N / D)
E = (t4 -1 ) * E
N = max(N % D,N-E)

t5 = math.floor(N / E)

print(int(t1+t2+t3+t4+t5))

### FIXED CODE ###

import math

N=int(input())
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())

print( math.ceil( N / min(A,B,C,D,E) ) +4 )
from bisect import bisect_left, bisect_right

H, W, M = map(int,input().split())
targets = [list(map(lambda x: int(x) - 1, input().split())) for i in range(M)]

cnth = [0] * H
cntw = [0] * W
wlist = [[] for i in range(H)]

for i in range(M):
	hi, wi = targets[i]
	cnth[hi] += 1
	cntw[wi] += 1
	wlist[hi].append(wi)

maxhi = []
maxwi = []
maxh = max(cnth)
maxw = max(cntw)

for i in range(H):
	wlist[i].sort()
	if cnth[i] == maxh:
		maxhi.append(i)
for i in range(W):
	if cntw[i] == maxw:
		maxwi.append(i)

for i in range(len(maxhi)):
	for j in range(len(maxwi)):
		if bisect_right(wlist[maxhi[i]], maxwi[j]) - bisect_left(wlist[maxhi[i]], maxwi[j]) == :
			print(maxh + maxw)
			exit()
print(maxh + maxw - 1)

### FIXED CODE ###

from bisect import bisect_left, bisect_right

def exists(ite, x):
	return bool(bisect_right(ite, x) - bisect_left(ite, x))

H, W, M = map(int,input().split())
targets = [list(map(lambda x: int(x) - 1, input().split())) for i in range(M)]

cnth = [0] * H
cntw = [0] * W
wlist = [[] for i in range(H)]

for i in range(M):
	hi, wi = targets[i]
	cnth[hi] += 1
	cntw[wi] += 1
	wlist[hi].append(wi)

maxhi = []
maxwi = []
maxh = max(cnth)
maxw = max(cntw)

for i in range(H):
	wlist[i].sort()
	if cnth[i] == maxh:
		maxhi.append(i)
for i in range(W):
	if cntw[i] == maxw:
		maxwi.append(i)

for i in range(len(maxhi)):
	for j in range(len(maxwi)):
		if not exists(wlist[maxhi[i]], maxwi[j]):
			print(maxh + maxw)
			exit()
print(maxh + maxw - 1)
A, B = map(int,input(.split()))
print((A+B)%24)

### FIXED CODE ###

A, B = map(int,input().split())
print((A+B)%24)
a, b, n = map(int, input().split())
 
tmp = 0
for x in (range(1, b+1, b//2) if b<=n else range(1, n+1, n-1)):
#for x in range(1, n+1):
    calc = a*x//b - a*(x//b)
    if calc > tmp:
        tmp = calc
 
print(tmp)

### FIXED CODE ###

a, b, n = map(int, input().split())
 
tmp = 0
for x in (range(1, b+1, b-2) if b<=n else range(1, n+1, n-1)):
#for x in range(1, n+1):
    calc = a*x//b - a*(x//b)
    if calc > tmp:
        tmp = calc
 
print(tmp)
s = input()
while len(s) > 0 :
    if s[:7] == 'dreamer':
        del s[:7]
    elif s[:7] == 'eraser':
        del s[:7]
    elif s[:5] == 'dream':
        del s[:5]
    elif s[:5] == 'erase':
        del s[:5]
    else:
        break
print(('NO','Yes')[len(s)==0])

### FIXED CODE ###

s = input()[::-1]
while len(s) > 0 :
    if s[:7] == 'remaerd':
        s = s[7:]
    elif s[:6] == 'resare':
        s = s[6:]
    elif s[:5] == 'maerd':
        s = s[5:]
    elif s[:5] == 'esare':
        s = s[5:]
    else:
        break
print(('NO','YES')[len(s)==0])
N, K = input().split()
S = input()

if K==1 :
    str1 = ''
else :
    str1 = S[0:K-2]

if K==N:
    str3 = ''
else :
    str3 = S[K:N]

before = S[K-1]
str2 = before.lower()

print(str1+str2+str3)

### FIXED CODE ###

#INPUT
#N K
#S

#1≤N≤50
#1≤K≤N
#Sは A, B, C からなる長さNの文字列

#ex
#3 1
#ABC

#OUTPUT
#文字列SのK文字目を小文字に書き換え、新しくできたSを出力せよ。

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

if K==1 :
    str1 = ''
else :
    str1 = S[0:K-1]

if K==N:
    str3 = ''
else :
    str3 = S[K:N]

before = S[K-1]
str2 = before.lower()

print(str1+str2+str3)
print(int(input) ** 2 * 3)

### FIXED CODE ###

r = int(input())
print(3 * r ** 2)
import sys
input = sys.stdin.readline
import numpy as np
from scipy.sparse.csgraph import *

xs,ys,xt,yt = map(int,input().split())
N = int(input())
XYR = np.empty((3,N+2),dtype=np.int64)
XYR[:,:2] = [[xs,xt],[ys,yt],[0,0]]

XYR[:,2:] = np.array([input().split() for _ in range(N)], dtype=np.int64).T

X,Y,R = XYR

dist = np.sqrt(np.square(X[:,None] - X[None,:]) + np.square(Y[:,None] - Y[None,:])) # euclid
dist -= R[:,None] + R[None,:]
np.maximum(dist, 0, out = dist)
dist[range(N+2), range(N+2)] = np.inf

graph = csgraph_from_dense(dist, null_value = np.inf)

answer = dijkstra(graph, indices = 0)[1]

print(answer)

### FIXED CODE ###

import sys
input = sys.stdin.readline
import numpy as np
from scipy.sparse.csgraph import csgraph_from_dense, dijkstra

xs,ys,xt,yt = map(int,input().split())
N = int(input())
XYR = np.empty((3,N+2),dtype=np.int64)
XYR[:,:2] = [[xs,xt],[ys,yt],[0,0]]

XYR[:,2:] = np.array([input().split() for _ in range(N)], dtype=np.int64).T

X,Y,R = XYR

dist = np.sqrt(np.square(X[:,None] - X[None,:]) + np.square(Y[:,None] - Y[None,:])) # euclid
dist -= R[:,None] + R[None,:]
np.maximum(dist, 0, out = dist)
dist[range(N+2), range(N+2)] = np.inf

graph = csgraph_from_dense(dist, null_value = np.inf)

answer = dijkstra(graph, indices = 0)[1]

print(answer)
N = int(input())
A = [input() for i in range(N)]
ans = 0
Max1 = max(A)
Max2 = sorted(set(A))[-2]
indexes = [i for i, x in enumerate(A) if x == Max1]
for i in range(N):
    ans = Max2 if len(indexes) < 2 and A[i] == Max1 else Max1
    print(ans)

### FIXED CODE ###

N = int(input())
A = [int(input()) for i in range(N)]
ans = 0
Max1 = max(A)
indexes = [i for i, x in enumerate(A) if x == Max1]
if len(A) == len(indexes):
    for i in A:
        print(i)
else:
    Max2 = sorted(set(A))[-2]
    if len(indexes) >= 2:
        for i in range(N):
            print(Max1)
    else:
        for i in range(N):
            ans = Max2 if A[i] == Max1 else Max1
            print(ans)
n = input().split()
N = int(n[0])
L = int(n[1])
a = []
for i in range(L):
    b = input()
    a.append(b)
A = sorted(a)
print(''.join(A))

### FIXED CODE ###

n = input().split()
N = int(n[0])
L = int(n[1])
a = []
for i in range(N):
    b = input()
    a.append(b)
A = sorted(a)
print(''.join(A))