Harryxun/stf_run huggingface dataset:
2 100
10 10

### FIXED CODE ###

def main(N, K, h):
    dp = [float('INF')] * N
    dp[0] = 0
    for i in range(N):
        for j in range(1,K+1):
            if i+j <= N-1:
                dp[i+j] = min(dp[i+j], dp[i] + (abs(h[i+j] - h[i])))
    return dp[-1]

N,K = map(int, input().split())
h = list(map(int,input().split()))
print(main(N, K, h))
import math
chou, tan, ji, hun = map(int,input().split())

kakudo = abs(((ji*30 + hun*.5) - (hun*6)))

if kakudo > 180:
    kakudo = abs(360 - kakudo)
print(kakudo)
kakudo = abs(math.cos((math.radians(kakudo))))
ans =( chou**2 + tan**2 - 2*chou*tan*kakudo)**.5
print(ans)

### FIXED CODE ###

n = int(input())%10
if n in {2, 4, 5, 7, 9}:
    print("hon") 
elif(n == 3):
    print("bon") 
else:
    print("pon")
k,m=map(input().split())
c=500*k
if(c<m):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

k,m=map(int,input().split())
c=500*k
if(c>=m):
  print("Yes")
else:
  print("No")
X,A,B=map(int,input().split())
if A-B>=0:
  print("delicious")
eilf B-A<=X:
  print("safe")
else:
  print("dangerous")

### FIXED CODE ###

X,A,B=map(int,input().split())
if A-B>=0:
  print("delicious")
elif B-A<=X:
  print("safe")
else:
  print("dangerous")
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
def I(): 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 LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline().rstrip()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
#input = sys.stdin.readline
from bisect import bisect_left

def dfs(i,before):
    global seq
    global ans
    added  = 0

    #現在地のAの値を、以前までのseqリストのどこに追加するか決める
    pos = bisect_left(seq,a[i-1])
    old = seq[pos]
    seq[pos]=a[i-1]
    ans[i-1]=bisect_left(seq,INF)

    #隣接する頂点に関して再帰
    for u in to[i]:
        if u==before:
            continue
        dfs(u,i)

    #seq配列をもとに戻す
    seq[pos]=old


N = I()
a = LI()
to = [[] for i in range(N+1)]
to[0] += [1]
for i in range(N-1):
    u,v = MI()
    to[u].append(v)
    to[v].append(u)
seq = [INF]*N
ans = [-1]*N

dfs(1,-1)
[print(i) for i in ans]


### FIXED CODE ###

import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
def I(): 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 LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline().rstrip()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
#input = sys.stdin.readline
from bisect import bisect_left

def dfs(i,before):
    global seq
    global ans
    added  = 0

    #現在地のAの値を、以前までのseqリストのどこに追加するか決める
    pos = bisect_left(seq,a[i-1])
    old = seq[pos]
    seq[pos]=a[i-1]
    ans[i-1]=bisect_left(seq,INF)

    #隣接する頂点に関して再帰
    for u in to[i]:
        if u==before:
            continue
        dfs(u,i)

    #seq配列をもとに戻す
    seq[pos]=old


N = I()
a = LI()
to = [[] for i in range(N+1)]
to[0] += [1]
for i in range(N-1):
    u,v = MI()
    to[u].append(v)
    to[v].append(u)
seq = [INF]*N
ans = [-1]*N

dfs(1,-1)
[print(i) for i in ans]
N, L = input().split()
apples = [x + int(L) for x in list(range(int(N)))]
abs_min_index = [abs(x) for x in apples].index(min(abs_apples))
print(sum(apples) - apples[abs_min_index])

### FIXED CODE ###

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

apples = list(range(N)) 
apples = [x + L for x in apples]
abs_apples = [abs(x) for x in apples]
abs_min_index = abs_apples.index(min(abs_apples))

print(sum(apples) - apples[abs_min_index])
S=input()
T=input()
T_0_equal=[]
for i in range(len(S)):
  if(T[0]==S[i]):
    T_0_equal.append(i)
#print(T_0_equal)
for i in range(len(T_0_equal)):
  count=0
  for j in range(len(S)):
    if(T[j]!=S[(j+T_0_equal[i])%len(S)]):
      break
    else:
      count+=1
  if(count==len(S)):
  	print('Yes')
  	exit()
print('No')  

### FIXED CODE ###

l=sorted(list(map(int,input().split())))
print(l[2]-l[0])
import math
a,b,c = list(map(int,input().split()))
A = math.sqrt(a)
B = math.sqrt(b)
C = math.sqrt(c)
AB = Decimal(A+B)
if AB < C:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

a,b,c = list(map(int,input().split()))
X = c-a-b
if X > 0 and X*X > 4*a*b:
    print("Yes")
else:
    print("No")
while True:
  H, W = map(int, raw_input().split())
  if H == 0 and W == 0:
    break
  print ("#"*W)
  for i in range(H-1):
    print ("#" + "."*(W-2) + "#")
  print ("#"*W)
 print ""

### FIXED CODE ###

while True:
  H, W = map(int, raw_input().split())
  if H == 0 and W == 0:
    break
  print "#"*W
  for i in range(H-2):
    if W > 2:
      print "#" + "."*(W-2) + "#"
    else:
      print "#"*W 
  print "#"*W
  print ""
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin


def main():
    n, q = (int(s) for s in stdin.readline().split())
    s = [{i} for i in range(n)]

    for _ in range(q):
        com, x, y = (int(s) for s in stdin.readline().split())
        if com:
            for si in s:
                if x in si and y in si:
                    print(1)
                    break
            else:
                print(0)
        else:
            for si in s:
                if x in si:
                    a = si
                elif y in si:
                    b = si
            s.append(a | b)
            s.remove(a)
            s.remove(b)


main()

### FIXED CODE ###

#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin


def main():
    n, q = (int(s) for s in stdin.readline().split())
    s = [{i} for i in range(n)]

    for _ in range(q):
        com, x, y = (int(s) for s in stdin.readline().split())
        if com:
            if x in s[x] and y in s[x]:
                print(1)
            else:
                print(0)
        else:
            a = s[x]
            b = s[y]
            if a is not b:
                a |= b
                for i in a:
                    s[i] = a


main()
N,M=list(map(int,input().split()))
L=[]
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)

    def find_root(self, x):
        if(self.root[x]<0):
            return x
        else:
            self.root[x] = self.find_root(self.root[x])
            return self.root[x]

    def Unite(self, x, y):
        x=self.find_root(x)
        y=self.find_root(y)

        if(x==y):
            return 
        elif(self.rnk[x]>self.rnk[y]):
            self.root[x]+=self.root[y]
            self.root[y]=x
        else:
            self.root[y]+=self.root[x]
            self.root[x]=y
            if(self.rnk[x]==self.rnk[y]):
                self.rnk[y]+=1
    def isSameGroup(self,x,y):
        if(self.find_root(x)==self.find_root(y)):
            return True
        else:
            False

    def Size(self,x):
        return -self.root[self.find_root(x)]

for i in range(M):
    li = list(map(int,input().split()))
    L.append(li)
L=L[::-1]

ans = [0]*(M)
ans[0] = N*(N-1)/2
T = UnionFind(N)
for i in range(N-1):
    if(T.isSameGroup(L[i][0],L[i][1])):
        ans[i+1] = ans[i]
        continue
    else:
        ans[i+1] = max(0, ans[i]-T.Size(L[i][0])*T.Size(L[i][1]))
        T.Unite(L[i][0],L[i][1])

for i in ans[::-1]:
    print(int(i))
#print(len(ans))

### FIXED CODE ###

N,M=list(map(int,input().split()))
L=[]
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)

    def find_root(self, x):
        if(self.root[x]<0):
            return x
        else:
            self.root[x] = self.find_root(self.root[x])
            return self.root[x]

    def Unite(self, x, y):
        x=self.find_root(x)
        y=self.find_root(y)

        if(x==y):
            return 
        elif(self.rnk[x]>self.rnk[y]):
            self.root[x]+=self.root[y]
            self.root[y]=x
        else:
            self.root[y]+=self.root[x]
            self.root[x]=y
            if(self.rnk[x]==self.rnk[y]):
                self.rnk[y]+=1
    def isSameGroup(self,x,y):
        if(self.find_root(x)==self.find_root(y)):
            return True
        else:
            False

    def Size(self,x):
        return -self.root[self.find_root(x)]

for i in range(M):
    li = list(map(int,input().split()))
    L.append(li)
L=L[::-1]

ans = [0]*(M)
ans[0] = N*(N-1)/2
T = UnionFind(N)
for i in range(M-1):
    if(T.isSameGroup(L[i][0],L[i][1])):
        ans[i+1] = ans[i]
        continue
    else:
        ans[i+1] = max(0, ans[i]-T.Size(L[i][0])*T.Size(L[i][1]))
        T.Unite(L[i][0],L[i][1])

for i in ans[::-1]:
    print(int(i))
#print(len(ans))
def inp():exec('global inppp\ninpmoto,inppp=input().split(),[]\nfor i in inpmoto:\n try:inppp.append(int(i))if float(i).is_integer()else inppp.append(float(i));\n except:\n  try:inppp.append(str(i))\n  except:print("error in inp")');return inppp[0]if len(inppp)==1else list(inppp)
a, b = inp()
c = inp()
d = []
for i in c:
    d.append(i-1)
itta = []
mati = 0
i = 0
while True:
    if mati in itta:
        saisyo = mati
        break
    else:
        itta.append(mati)
        mati = d[mati]
        i += 1
risuto = []
while True:
    if mati in risuto:
        break
    else:
        risuto.append(mati)
        mati = d[mati]
if b <= i-1:
    print(itta[b]+1)
else:
    print(risuto[(b-i)%3]+1)

### FIXED CODE ###

a, b = list(map(int, input().split()))
c = list(map(int, input().split()))
itta2 = set([])
mati = 1
i = 0
itta = []
while True:
    if mati in itta2:
        saisyo = mati
        break
    else:
        itta2.add(mati)
        itta.append(mati)
        mati = c[mati-1]
        i += 1
risuto2 = set([])
risuto = []

while True:
    if mati in risuto2:
        break
    else:
        risuto2.add(mati)
        risuto.append(mati)
        mati = c[mati-1]
if b <= i-1:
    print(itta[b])
else:
    print(risuto[(b-i) % len(risuto)])
a, b, c = map(int, input())

if a == b:
    print(c)
elif b == c:
    print(a)
else:
    print(b)

### FIXED CODE ###

a, b, c = map(int, input().split())

if a == b:
    print(c)
elif b == c:
    print(a)
else:
    print(b)
import math
a, b, h, m = map(int,input().split)
fine = math.cos((5h - m) * math.pi / 60)
c = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * fine)
print(c)


### FIXED CODE ###

import math
a, b, h, m = map(int,input().split())
fine = math.radians(30 * h - 11 * m / 2)
c = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(fine))
print(c)
a,b,c=map(int,raw_input().split(" ")
print a,b,c:("No","Yes")[a<b<c]

### FIXED CODE ###

a,b,c=map(int,raw_input().split())
print ("No","Yes")[a<b<c]
import math

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

x = (b-1) / (a-1)

print(math.ceil(x))



### FIXED CODE ###

import math
A, B = list(map(int, input().split()))
print(math.ceil((B-1)/(A-1)))
a=list(mao(int,input().split()))
if a[1]>=a[0]:
    print(a[0])
else:
    print(a[0]-1)

### FIXED CODE ###

a=list(map(int,input().split()))
if a[1]>=a[0]:
    print(a[0])
else:
    print(a[0]-1)
from math import gcd
a,b=map(int,input().split())
n=gcd(a,b)

#素数
def primes(n):
    n, correction = n-n%6+6, 2-(n%6>1)
    sieve = [True] * (n//3)
    for i in range(1, int(n**0.5)//3+1):
        if sieve[i]:
            k = 3*i+1|1
            sieve[k*k//3::2*k] = [False] * ((n//6-k*k//6-1)//k+1)
            sieve[k*(k-2*(i&1)+4)//3::2*k] = [False] * ((n//6-k*(k-2*(i&1)+4)//6-1)//k+1)
    return [2, 3] + [3*i+1|1 for i in range(1, n//3-correction) if sieve[i]]

#素因数分解
from collections import defaultdict
primelist=primes(int(n**0.5+1))+[n+1]
factors=defaultdict(lambda :0)
for prime in primelist:
    if prime>n:
        factors[n]+=1
        break
    while n%prime==0:
        n=n//prime
        factors[prime]+=1
factors[n]=1
print(len(factors))

### FIXED CODE ###

from fractions import gcd
a,b=map(int,input().split())
n=gcd(a,b)

#素数
def primes(n):
    n, correction = n-n%6+6, 2-(n%6>1)
    sieve = [True] * (n//3)
    for i in range(1, int(n**0.5)//3+1):
        if sieve[i]:
            k = 3*i+1|1
            sieve[k*k//3::2*k] = [False] * ((n//6-k*k//6-1)//k+1)
            sieve[k*(k-2*(i&1)+4)//3::2*k] = [False] * ((n//6-k*(k-2*(i&1)+4)//6-1)//k+1)
    return [2, 3] + [3*i+1|1 for i in range(1, n//3-correction) if sieve[i]]

#素因数分解
from collections import defaultdict
primelist=primes(int(n**0.5+1))+[n+1]
factors=defaultdict(lambda :0)
for prime in primelist:
    if prime>n:
        factors[n]+=1
        break
    while n%prime==0:
        n=n//prime
        factors[prime]+=1
factors[n]=1
factors[1]=0
print(len(factors))
try:
    x=int(input("Enter a number:"))
    y=int(input("Enter a number:"))
except:
    print("Please enter a int.")
if x<=100 and y<=100:
    if x>=0 and y>=0:
        print(x*y)
else:
    print("number not in range")

### FIXED CODE ###

a,b = [int(num) for num in input().split()]
print(a*b)
N=int(input())
a=input().split()
alice=0
bob=0
while len(a) !=0:
  alice+=max(a)
  a.remove(max(a))
  if len(a) !=0:
    bob+=max(a)
    a.remove(max(a))
  else: break
print(alice-bob)

### FIXED CODE ###

N=int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
S=0
for i in range(N):
  if i%2==0:
    S+=a[i]
  else:
    S-=a[i]
print(S)
A = int(input())
B = int(input())
ans = 0

if A > B:
    ans = A + (A - 1)
elif A == B:
    ans = A + B
elif A < B:
    ans = B + (B - 1)

print(ans)

### FIXED CODE ###

A, B = map(int, input().split())
ans = 0

if A > B:
    ans = A + (A - 1)
elif A == B:
    ans = A + B
elif A < B:
    ans = B + (B - 1)

print(ans)
#!/usr/bin/env python

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**6)
INF = float("inf")
MOD = 10**9+7

def popcount(n):
    ret = 0
    for i in range(18):
        if n>>i & 1:
            ret += 1
    return ret

def main():
    N = int(input())
    X = input().decode().rstrip()

    # X に含まれる "1" の数
    x_cnt = X.count("1")

    # i 桁目が 0 : x_cnt += 1
    # i 桁目が 1 : x_cnt -= 1
    # より, X mod x_cnt +1, X mod x_cnt-1 を事前計算しておく
    n_plus,n_minus = 0,0
    for i in range(N):
        if X[i]=="1":
            n_plus += 2**(N-1-i)
            n_plus %= x_cnt + 1
            n_minus += 2**(N-1-i)
            n_minus %= x_cnt - 1
    
    for i in range(N):
        ans = 1
        if X[i]=="1":
            # 1 -> 0 に変換した結果, １が全く存在しない場合
            if n_minus == 0:
                print(0)
                continue
            a = (n_minus - pow(2,(N-1-i), x_cnt-1)) % (x_cnt-1)
        else:
            a = (n_plus + pow(2,(N-1-i), x_cnt+1)) % (x_cnt+1)
        while a > 0:
            pop_cnt = popcount(a)
            a %= pop_cnt
            ans += 1
        print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

#!/usr/bin/env python

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**6)
INF = float("inf")

def popcount(n):
    ret = 0
    for i in range(18):
        if n>>i & 1:
            ret += 1
    return ret

def main():
    N = int(input())
    X = input().decode().rstrip()

    # X に含まれる "1" の数
    x_cnt = X.count("1")

    # i 桁目が 0 : x_cnt += 1
    # i 桁目が 1 : x_cnt -= 1
    # より, X mod x_cnt +1, X mod x_cnt-1 を事前計算しておく
    x_mod_pl,x_mod_mi = 0,0
    d_pl,d_mi = 1,1
    mod_pl,mod_mi = x_cnt+1,max(1,x_cnt-1)
    for i in range(N-1,-1,-1):
        if X[i]=="1":
            x_mod_pl = (x_mod_pl + d_pl) % mod_pl
            x_mod_mi = (x_mod_mi + d_mi) % mod_mi
        d_pl = (d_pl*2) % mod_pl
        d_mi = (d_mi*2) % mod_mi
    
    for i in range(N):
        ans = 1
        if X[i] == "1":
            # 1 -> 0 に変換した結果, １が全く存在しない場合
            if x_cnt == 1:
                print(0)
                continue
            a = (x_mod_mi - pow(2,(N-1-i), mod_mi)) % mod_mi
        else:
            a = (x_mod_pl + pow(2,(N-1-i), mod_pl)) % mod_pl

        while a > 0:
            pop_cnt = popcount(a)
            a %= pop_cnt
            ans += 1

        print(ans)

if __name__ == "__main__":
    main()
h, w = map(int, input().split())

s = [list(input()) for _ in range(h)]

DX = [-1, 0, 1, 0]
DY = [0, -1, 0, 1]

ans = True

for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            continue
        flag = False
        for k in range(4):    
            if not(0<=i+DX[k]<=w-1 and 0<=j+DY[k]<=h-1):
                continue
            if s[i + DX[k]][j + DY[k]] == "#":
                flag = True
        ans = flag
print("Yes" if ans else "No")

### FIXED CODE ###

h, w = map(int, input().split())

s = [list(input()) for _ in range(h)]

DX = [-1, 0, 1, 0]
DY = [0, -1, 0, 1]

ans = True

for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            continue
        flag = 0
        for k in range(4):    
            if not(0<=j+DX[k]<=w-1 and 0<=i+DY[k]<=h-1):
                continue
            if s[i + DY[k]][j + DX[k]] == "#":
                flag = 1
                break
        if flag == 0:
          ans = False
          break
print("Yes" if ans else "No")
n = int(input())
s = input()
x = len(s)
for i in range(x):
  a = s[i]
  b = ord(a)
  c = ord("A")
  d = (b + n - c)%26
  s[i] = chr(c + d)
print(s)

### FIXED CODE ###

n = int(input())
s = input()
x = len(s)
for i in range(x):
  a = s[i]
  b = ord(a)
  c = ord("A")
  d = (b + n - c)%26
  print(chr(c + d), end = '')
print()
a, b, c = map(int, input().split())
a_tmp = a ; b_tmp = b ; c_tmp = c
count = 0
while True :
    count += 1
    a = b_tmp/2 + c_tmp/2
    b = a_tmp/2 + c_tmp/2
    c = a_tmp/2 + b_tmp/2
    if a == a_tmp and b == b_tmp and c = c_tmp :
        print("-1")
        break
    a_tmp = a ; b_tmp = b ; c_tmp = c
    if a%2 == 1 or b%2 == 1 or c%2 == 1 :
        print(count)
        break
    else :
        continue


### FIXED CODE ###

a, b, c = map(int, input().split())
a_tmp = a ; b_tmp = b ; c_tmp = c
count = 0
while True :
    if a == b == c and a%2 == 0 :
        print("-1")
        break
    elif a%2 == 1 or b%2 == 1 or c%2 == 1 :
        print(count)
        break
    else :
        a = b_tmp/2 + c_tmp/2
        b = a_tmp/2 + c_tmp/2
        c = a_tmp/2 + b_tmp/2
        a_tmp = a ; b_tmp = b ; c_tmp = c
        count += 1
S = int(raw_input())

h = S / 3600
m = S - 3600*h
s = m % 60
m = m - s

S = h + ???:??? + m + ???:??? + s
print S

### FIXED CODE ###

S = int(raw_input())

h = S / 3600
m = S - 3600*h
s = m % 60
m = (m - s)/60

print str(h) + ":" + str(m) + ":" + str(s)
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int,input().split()))
ret = [0 for _ in range(n+1)]
#後ろから求める
for i,a_i in enumerate(a[-1::-1]):
    cur_ret_sum = sum(ret[n-i::n-i])%2
    if a_i!=cur_ret_sum:
        ret[n-i]=1

print(sum(ret[1::]))
print(" ".join(ret[1::]))

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int,input().split()))
ret = [0 for _ in range(n+1)]
#後ろから求める
for i,a_i in enumerate(a[-1::-1]):
    cur_ret_sum = sum(ret[n-i::n-i])%2
    if a_i!=cur_ret_sum:
        ret[n-i]=1
m = sum(ret[1::])
print(m)
if m > 0:
    print(" ".join([str(i) for i,v in enumerate(ret) if v==1]))
def merge(A, left, mid, right):
    L = A[left:mid] + [1000000]
    R = A[mid:right] + [1000000]
    # L.append(1000000)
    # R.append(1000000)

    i = 0
    j = 0
    global count
    
    for k in range(left, right):
        count += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def merge_sort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)

n = int(input())
A = list(map(int, input().split()))
count = 0
merge_sort(A, 0, len(A))

print(' '.join(list(map(str, A))))
print(count)


### FIXED CODE ###

def merge(A, left, mid, right):
    global count
    inf = 10 ** 9
    L = A[left:mid] + [inf]
    R = A[mid:right] + [inf]

    i = 0
    j = 0
    for k in range(left, right):
        count += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)

n = int(input())
A = list(map(int, input().split()))
count = 0
mergeSort(A, 0, n)

print(' '.join(list(map(str, A))))
print(count)
INP = input().split()
N = int(INP[0])
M = int(INP[N + 1])
ans = [0] * N

for i in range(N):
    for k in range(N):
        if INP[i + 1] == INP[k + 1]:
            ans[i] += 1
for i in range(N):
    for j in range(M):

        if INP[i+1] == INP[N + j + 1]:
            ans[i] -= 1

for i in range(N):
    if ans[i] < 0:
        ans[i] = 0
        
mx = max(ans)
print(mx)

### FIXED CODE ###

N = int(input())
INPn = [input() for i in range(N)]
M = int(input())
INPm = [input() for i in range(M)]

ans = [0] * N

for i in range(N):
    for k in range(N):
        if INPn[i] == INPn[k]:
            ans[i] += 1
for i in range(N):
    for j in range(M):

        if INPn[i] == INPm[j]:
            ans[i] -= 1

for i in range(N):
    if ans[i] < 0:
        ans[i] = 0
        
mx = max(ans)
print(mx)
a, b = int(input().split())

if a >= b:
    c = a
    a = a-1
    print(c + max(a,b))

else:
    c = b
    b = b-1
    print(c + max(a,b))

### FIXED CODE ###

a, b = map(int, input().split())

if a >= b:
    print(a + max(a-1, b))

else:
    print(b + max(a, b-1))
a =input()
aa=''
for i in range(a):
  if a[i]=='9':
    aa +='1'
  elif a[i]=='1':
    aa +='9'
print(aa)

### FIXED CODE ###

s = input()
a=''
for i in range(len(s)):
  if s[i]=='9':
    a += '1'
  elif s[i]=='1':
    a += '9'
  else:
    a += s[i]
print(a)
for i in input:
    if i >= 30:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

#at coder ABC174 A
X = int(input())
if X >= 30:
    print('Yes')
else:
    print('No')
s1,s2,s3 = list(map(str,input().split()))
res = ""

res.append(s1[0].upper())
res.append(s2[0].upper())
res.append(s3[0].upper())

print(res)

### FIXED CODE ###

a,b,c = map(str,input().split())

print(a[0].upper() + b[0].upper() + c[0].upper())