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

n,k,c = map(int, input().split())
s = str(input())
t = []
u = []
i,x,y,j = 0,0,0,n-1
while i < n and x < k:
    if s[i] == "o":
        t.append(i)
        x += 1
        i += c
    i += 1

while j >= 0 and y < k:
    if s[j] == "o":
        u.insert(0,j)
        y += 1
        j += -c
    j += -1

for i in range(0,k):
    if t[i] == u[i]:
        print(t[i]+1)

### FIXED CODE ###

n,k,c = map(int, input().split())
s = str(input())
t = []
u = []
i,x,y,j = 0,0,0,n-1
while i < n and x < k:
    if s[i] == "o":
        t.append(i)
        x += 1
        i += c
    i += 1
 
while j >= 0 and y < k:
    if s[j] == "o":
        u.append(j)
        y += 1
        j += -c
    j += -1
 
for i in range(0,k):
    if t[i] == u[k-1-i]:
        print(t[i]+1)
### BUGGY CODE ###

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

w = []
v = []

for i in range(N):
    a, b = map(int, input().split())
    w.append(a)
    v.append(b)

dp = [[0] * (W+1) for _ in range(N+1)]

for i in range(N):
    for j in range(0, W+1):
        if j - w[i] >= 0:  # i 番目の品物が容量 j に対して（他を0個以上捨てれば）入れられる場合
            dp[i+1][j] = max(dp[i+1][j], dp[i][j - w[i]] + v[i])

        dp[i+1][j] = max(dp[i+1][j], dp[i][j]) # i 番目の品物を入れた場合と入れなかった場合の比較

print(dp[N][W])


### FIXED CODE ###

def dp():
    n, W = map(int, input().split())
    wv = (map(int, input().split()) for _ in range(n))
    dp = [0] * (W+1)

    for w, v in wv:
        for j in range(W, w-1, -1):
            DP = dp[j-w] + v
            if dp[j] < DP:
                dp[j] = DP
    return max(dp)
print(dp())
### BUGGY CODE ###


H,W,D = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(H)]
Q = int(input())
LR = [list(map(int,input().split())) for _ in range(Q)]


numlist = [[0,0]] * (H*W+1)
for i in range(H):
    for j in range(W):
        numlist[A[i][j]] = [i,j]

'''
ruisekiwa = [0] * (H*W+1)
tmp = 0
x,y = numlist[1]

for i in range(2,H*W+1):
    x2,y2 = numlist[i]
    tmp += abs(x-x2)+abs(y-y2)
    x,y = x2,y2
    ruisekiwa[i] = tmp
'''  

for i in range(Q):
    ans = 0
    start,goal = LR[i]
    x,y = numlist[start]
    xg,yg = numlist[goal]
    now = start
    while now != goal:
        now += D
        xn,yn = numlist[now]
        ans += abs(x-xn) + abs(y-yn)
        x,y = xn,yn
        
    print(ans)
    
    

### FIXED CODE ###


H,W,D = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(H)]
Q = int(input())
LR = [list(map(int,input().split())) for _ in range(Q)]


numlist = [[0,0]] * (H*W+1)
for i in range(H):
    for j in range(W):
        numlist[A[i][j]] = [i,j]

ruisekiwa = [0] * (H*W+1)
for d in range(1,D+1):
    x,y = numlist[d]
    tmp = 0
    for i in range(d,H*W+1,D):
        x2,y2 = numlist[i]
        tmp += abs(x-x2)+abs(y-y2)
        x,y = x2,y2
        ruisekiwa[i] = tmp

for i in range(Q):
    start,goal = LR[i]
    ans = ruisekiwa[goal] - ruisekiwa[start]
    
    print(ans)
### BUGGY CODE ###

import sys,math,collections,itertools
input = sys.stdin.readline

N,M=list(map(int,input().split()))
mn = M//N
ml = M%N
if ml == 0:
    print(mn)
    exit()
ans = 0
for i in range(1,mn+1):
    tmp = math.gcd(i,M-i*(N-1))
    ans = max(ans,tmp)
print(ans)


### FIXED CODE ###

import sys,math,collections,itertools
input = sys.stdin.readline

N,M=list(map(int,input().split()))
mn = M//N
ml = M%N
if ml == 0:
    print(mn)
    exit()
ans = 0
for i in range(mn+1,0,-1):
    if i < ans:
        break
    tmp = math.gcd(i,M-i*(N-1))
    ans = max(ans,tmp)
print(ans)
### BUGGY CODE ###

import math
import numpy as np

def main():
    h,w,k = tuple([int(t)for t in input().split()])

    s = [[int(i) for i in list(input())] for _ in range(h)]
    
    s = np.array(s)

    candidates = []

    for i in range(1<<h-1):
        s_subs = divide(s,i)
        cutnum = 0
        pos = 0
        subsum = np.array([0]*len(s_subs))
        j = 0
        while j<w:
            temp = np.array([np.sum(s_[:,j]) for s_ in s_subs])
            if any([s_>k for s_ in temp]):
                cutnum = -1-bin(i).count('1')
                break

            subsum = subsum+temp
            if any([s_>k for s_ in subsum]):
                cutnum+=1
                subsum = np.array([0]*len(s_subs))
                j-=1
            
            j+=1

        candidates.append((bin(i).count('1')+cutnum))

    print(min([t for t in candidates if t>=0]))

def divide(s,i):
    subs = []
    counter = 0
    pos = 0
    while i!= 0:
        counter +=1
        if i%2==1:
            subs.append(s[pos:counter])
            pos = counter
        i >>=1

    subs.append(s[pos:])
    return subs
    
if __name__ == "__main__":
    main()

### FIXED CODE ###

import math
import functools
from operator import add

def main():
    h,w,k = tuple([int(t)for t in input().split()])

    s = [[int(i) for i in list(input())] for _ in range(h)]
    
    cusum = [accumelist(s_) for s_ in s]

    candidates = []

    for i in range(1<<(h-1)):
        subcu = divide(cusum,i)
        subs = divide(s,i)

        subcusum = []

        rowsum = []

        for sub_ in subcu:
            subcusum.append(functools.reduce((lambda a,b:list(map(add,a,b))),sub_))

        for sub_ in subs:
            rowsum.append(functools.reduce((lambda a,b:list(map(add,a,b))),sub_))


        cutnum = 0

        temp = [0]*len(subcusum)

        for j in range(w):
            for l in range(len(subcusum)):
                if subcusum[l][j]-temp[l]>k:
                    if rowsum[l][j]>k:
                        cutnum+=10000
                    temp = [x[j-1] for x in subcusum]
                    cutnum+=1
                    break
        
        candidates.append(cutnum+bin(i).count('1'))

    print(min(candidates))
            
def divide(s,i):
    subs = []
    counter = 0
    pos = 0
    while i!= 0:
        counter +=1
        if i%2==1:
            subs.append(s[pos:counter])
            pos = counter
        i >>=1
 
    subs.append(s[pos:])
    return subs

def accumelist(s):
    if s == []:
        return []
    res = [s[0]]
    for i in range(1,len(s)):
        res.append(res[i-1]+s[i])

    return res

def _add_(a,b):
    return map(add,a,b)
    
if __name__ == "__main__":
    main()
### BUGGY CODE ###

import numpy as np

# N, M = 10, 3
# ARR = [1, 8, 5, 7, 100, 4, 52, 33, 13, 5]
# BRR = [
#     [3, 10],
#     [4, 30],
#     [1, 4]
# ]
N,M = map(int,input().split())
ARR = list(map(int,input().split()))
BRR = []
for i in range(M):
    BRR.append(list(map(int,input().split())))

def calculate(n, m, arr, brr):
    arr = np.array(arr)
    brr = sorted(brr, key=lambda x: -x[1])
    arr.sort()
    result = 0
    sIndex = 0
    for br in brr:
        kIndex = min(sum(arr[sIndex:len(arr)] < br[1]), br[0])
        if kIndex == 0:
            break
        result = result + kIndex*br[1]
        sIndex = sIndex + kIndex

    result = result + sum(arr[sIndex:len(arr)])

    print(result)


calculate(N, M, ARR, BRR)


### FIXED CODE ###

# N, M = 10, 3
# ARR = [1, 8, 5, 7, 100, 4, 52, 33, 13, 5]
# BRR = [
#     [3, 10],
#     [4, 30],
#     [1, 4]
# ]


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

def calculate(n, m, arr, brr):
    raw = []
    for ar in arr:
        raw.append([ar, 1])
    for br in brr:
        raw.append([br[1], br[0]])

    raw = sorted(raw,key=lambda x:-x[0])
    # print(raw)

    offset = 0
    sum = 0
    for ra in raw:
        if offset + ra[1] <= n:
            sum = sum + ra[1] * ra[0]
            offset = offset + ra[1]
        else:
            sum = sum + (n - offset) * ra[0]
            offset = n
            break
    print(sum)

calculate(N, M, ARR, BRR)
### BUGGY CODE ###

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

baitos = sorted(baitos)
# print(sorted(baitos))
# print(baitos)

money = 0
for i in range(m):
    max = [0, 0]
    for baito in baitos:
        if baito[0] > i + 1:
            break
        elif max[1] < baito[1]:
            max = baito
    if max != [0, 0]:
        # print(max[1])
        money += max[1]
        baitos.remove(max)

print(money)


### FIXED CODE ###

import heapq

n, m = map(int, input().split())
baitos = [list(map(int, input().split())) for _ in range(n)]

baitos = sorted(baitos)
# print(sorted(baitos))
# print(baitos)

money = 0
avail = []
# heapq.heapify(avail)
index = 0
for day in range(m):
    while index < n and baitos[index][0] <= day + 1:
        heapq.heappush(avail, -baitos[index][1])
        index += 1
        # baitos.remove(baitos[0])
    # for baito in baitos:
    #     print(baito)
    #     if baito[0] > day + 1:
    #         print("break")
    #         break
    #     else:
    #         heapq.heappush(avail, -baito[1])
    #         baitos.remove(baito)
    # print("baitos", baitos)
    # print("avail", avail)
    if avail:

        money += -heapq.heappop(avail)
        # print(day, money)
    # money += max[1]
    # baitos.remove(max)

print(money)
### BUGGY CODE ###

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

dp = [[[ 0 for _ in range(50*N + 5)] for _ in range(N+1) ] for _ in range(N+1)]

dp[0][0][0] = 1
for i in range(1, N+1):
    for j in range(N+1):
        for k in range(50*N+1):
            dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-X[i-1]]

ans = 0
for i in range(1, N+1):
    ans += dp[N][i][A * i]
print(ans)


### FIXED CODE ###

N, A = map(int,input().split())
X = list(map(int,input().split()))
dp = [[[0 for _ in range(50*50 + 1)] for _ in range(N+1)] for _ in range(N+1)]

dp[0][0][0] = 1
for i in range(1, N+1):
    for j in range(i+1):
        for k in range(50*j+1):
            dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-X[i-1]]

ans = 0
for i in range(1, N+1):
    ans += dp[N][i][A * i]
print(ans)
### BUGGY CODE ###

n, k = map(int, input().split())
xlis = list(map(int, input().split()))
ret = 10 ** 100
for i in range(n-k+1):
    cand = xlis[i:k+i]
    min_val = cand[0]
    max_val = cand[-1]
    if min_val * max_val >= 0:
        tmp = max(abs(min_val), abs(max_val))
        ret = min(ret, tmp)
    else:
        fst = min(abs(min_val), abs(max_val))
        lst = max(abs(min_val), abs(max_val))
        tmp = fst * 2 + lst
        ret = min(ret, tmp)

print(ret)


### FIXED CODE ###

n, k = map(int, input().split())
xlis = list(map(int, input().split()))
ret = 10 ** 100
for i in range(n-k+1):
    min_val = xlis[i]
    max_val = xlis[k+i-1]
    if min_val * max_val >= 0:
        tmp = max(abs(min_val), abs(max_val))
        ret = min(ret, tmp)
    else:
        fst = min(abs(min_val), abs(max_val))
        lst = max(abs(min_val), abs(max_val))
        tmp = fst * 2 + lst
        ret = min(ret, tmp)

print(ret)
### BUGGY CODE ###

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

def calc_primes(n):
    data = [i for i in range(2, n + 1)]
    for d in data:
        data = [x for x in data if (x == d or x % d != 0)]
    return data

primes = calc_primes(int(math.sqrt(10**6)))

is_pairwise = True
prod = 1
all_gcd = A[0]
for a in A:
    all_gcd = math.gcd(all_gcd, a)
    if is_pairwise:
        g = math.gcd(prod, a)
        if g > 1:
            is_pairwise = False
        prod *= a

if is_pairwise:
    print('pairwise coprime')
elif all_gcd == 1:
    print('setwise coprime')
else:
    print('not coprime')



### FIXED CODE ###

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

is_pairwise = True

def calc_primes(n):
    data = [i for i in range(2, n + 1)]
    for d in data:
        data = [x for x in data if (x == d or x % d != 0)]
    return data

primes = calc_primes(int(math.sqrt(10**6)))
used = set()

def factorize(n):
    for prime in primes:
        if n == 1:
            break
        is_used = False
        while n % prime == 0:
            if prime in used:
                return False
            n //= prime
            is_used = True
        if is_used:
            used.add(prime)
    if n > 1:
        if n in used:
            return False
        used.add(n)
    return True

all_gcd = A[0]
for a in A:
    all_gcd = math.gcd(all_gcd, a)
    if is_pairwise:
        if not factorize(a):
            is_pairwise = False

if is_pairwise:
    print('pairwise coprime')
elif all_gcd == 1:
    print('setwise coprime')
else:
    print('not coprime')
### BUGGY CODE ###

n = int(input())
b = []
st = input().split()
for i in range(n):
    k = int(st[i])
    if i % 2 == 0:
        b.insert(0, k)
    else:
        b.append(k)
if n % 2 == 0:
    b= list(reversed(b))
s = ""
for k in b:
    s += str(k) + " "
print(s)


### FIXED CODE ###

n = int(input())
b = []
a = input().split()
if n % 2 == 0:
    m = n // 2
    for i in range(m):
        b.append(a[n-2*i-1])
    for i in range(m):
        b.append(a[2*i])
else:
    m = n // 2
    for i in range(m+1):
        b.append(a[n-2*i-1])
    for i in range(m):
        b.append(a[2*i+1])
s = ""
for k in b:
    s += k + " "
print(s)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)

def solve(): 
  n,q = map(int,input().split())
  G = [[] for i in range(n)]
  for i in range(n-1):  
    a,b = map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

  P = [0]*n
  for i in range(q):
    p,x = map(int,input().split())
    P[p-1] += x

  def dfs(v,pv):      
    for nv in G[v]:
      if nv != pv:
        P[nv] += P[v]
        dfs(nv,v)

  dfs(0,0)
  print(*P)

if __name__ == "__main__":
    solve()

### FIXED CODE ###

from collections import deque

n,q = map(int,input().split())
cnt = [0]*(n+1)
g=[[] for _ in range(n+1)]

for _ in range(n-1):
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
  
for _ in range(q): 
  v,val=map(int,input().split())
  cnt[v]+=val    
  
q = deque()
q.append(1)
checked = [0]*(n+1) 
while q:
  v = q.pop()
  checked[v] = 1
  for vc in g[v]:
    if checked[vc] == 1:
      continue
    else:
      cnt[vc] += cnt[v]
      q.append(vc)
    
print(*cnt[1:])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    S=input()
    k=int(input())
    n=len(S)
    D=set()
    for j in range(n+1):
        for i in range(j):
            D.add(S[i:j])
    print(sorted(D)[k-1])
resolve()

### FIXED CODE ###

import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()

class SuffixArray(object):
    def __init__(self,s):
        self.__s=s
        self.__n=len(s)
        self.__suffix_array()
        self.__lcp_array()
        self.__sparse_table()

    def __suffix_array(self):
        s=self.__s; n=self.__n
        sa=list(range(n))
        rank=[ord(s[i]) for i in range(n)]
        tmp=[0]*n
        k=1
        cmp_key=lambda i:(rank[i],rank[i+k] if i+k<n else -1)
        while(k<=n):
            sa.sort(key=cmp_key)
            tmp[sa[0]]=0
            for i in range(1,n):
                tmp[sa[i]]=tmp[sa[i-1]]+(cmp_key(sa[i-1])<cmp_key(sa[i]))
            rank=tmp[:]
            k<<=1
        self.__sa=sa
        self.__rank=rank

    def __lcp_array(self):
        s=self.__s; n=self.__n
        sa=self.__sa; rank=self.__rank
        lcp=[0]*n
        h=0
        for i in range(n):
            j=sa[rank[i]-1]
            if(h>0): h-=1
            if(rank[i]==0): continue
            while(j+h<n and i+h<n and s[j+h]==s[i+h]): h+=1
            lcp[rank[i]]=h
        self.__lcp=lcp

    def __sparse_table(self):
        n=self.__n
        logn=max(0,(n-1).bit_length())
        table=[[0]*n for _ in range(logn)]
        table[0]=self.__lcp[:]
        from itertools import product
        for i,k in product(range(1,logn),range(n)):
            if(k+(1<<(i-1))>=n): table[i][k]=table[i-1][k]
            else: table[i][k]=min(table[i-1][k],table[i-1][k+(1<<(i-1))])
        self.__table=table

    @property
    def suffix(self):
        return self.__sa

    def lcp(self,a,b):
        if(a==b): return self.__n-a
        l,r=self.__rank[a],self.__rank[b]
        l,r=min(l,r)+1,max(l,r)+1
        i=max(0,(r-l-1).bit_length()-1)
        table=self.__table
        return min(table[i][l],table[i][r-(1<<i)])

def resolve():
    S=input()
    n=len(S)
    k=int(input())

    if(n==1):
        print(S)
        return

    sa=SuffixArray(S)
    D=set()
    for i in sa.suffix:
        for j in range(i+1,n+1):
            D.add(S[i:j])
            if(len(D)==k):
                print(sorted(D)[-1])
                return
resolve()
### BUGGY CODE ###

import math

n = int(input())
x = list(map(int, input().split()))
ans = 0
p = math.factorial(n-1)
for i in range(n-1):
  k = p//(i+1) % 1000000007
  ans += k * (x[n-1]-x[i])
  ans %= 1000000007
print(ans)

### FIXED CODE ###

n = int(input())
x = list(map(int, input().split()))
ans = 0
mod = 1000000007
p = 1
for i in range(1, n):
  p *= i
  p %= mod
for i in range(n-1):
  ans += (x[n-1]-x[i])*pow(i+1, mod-2, mod)
ans *= p
ans %= 1000000007
print(ans)
### BUGGY CODE ###

from functools import reduce
from operator import mul

N = int(input())

A = [int(i) for i in input().split()]

if 0 in A:
  print(0)
  exit();
  
B = reduce(mul,A)

print(B if B <= 10**18 else '-1')

### FIXED CODE ###

N = int(input())

A = sorted([int(i) for i in input().split()],reverse=True)

if 0 in A:
  print(0)
  exit();

x = A[0]  
for i in A[1:]:
  x *= i
  if x > 10**18:
    print('-1')
    exit();
    
print(x)
### BUGGY CODE ###

def main():
    n = int(input())
    A = input().split()
    ans = []
    if n % 2 == 0:
        for i in range(0, n - 1, 2):
            ans.append(A[i])
            ans.insert(0, A[i + 1])
    else:
        for i in range(0, n - 1, 2):
            ans.append(A[i + 1])
            ans.insert(0, A[i])
        ans.insert(0, A[-1])
    print(' '.join(ans))


main()


### FIXED CODE ###

def main():
    n = int(input())
    A = input().split()
    B = [0] * n
    k = n % 2
    l = n // 2
    if k == 0:
        l -= 1
    r = l + 1
    for i in range(n):
        if i % 2 != k:
            B[l] = A[i]
            l -= 1
        else:
            B[r] = A[i]
            r += 1
    print(' '.join(B))


main()
### BUGGY CODE ###

N = int(input())
A = sorted([int(input()) for i in range(N)])
ans1 = [A[N-1]]
ans2 = [A[0]]

f = 0
b = N - 2
s = True
while f <= b:
    if s:
        ans1.append(A[f])
        f += 1
        if f <= b:
            #ans1 = [A[f]] + ans1
            ans1.insert(0, A[f])
            f += 1
    else:
        ans1.append(A[b])
        b -= 1
        if f <= b:
            ans1.insert(0, A[b])
            #ans1 = [A[b]] + ans1
            b -= 1
    s = not s

f = 1
b = N - 1
s = True
while f <= b:
    if s:
        ans2.append(A[b])
        b -= 1
        if f <= b:
            ans2.insert(0, A[b])
            #ans2 = [A[b]] + ans2
            b -= 1
    else:
        ans2.append(A[f])
        f += 1
        if f <= b:
            ans2.insert(0, A[f])
            #ans2 = [A[f]] + ans2
            f += 1
    s = not s

a1 = a2 = 0
for i in range(N-1):
    a1 += abs(ans1[i] - ans1[i+1])

for i in range(N-1):
    a2 += abs(ans2[i] - ans2[i+1])

print(max(a1,a2))

### FIXED CODE ###

N = int(input())
A = sorted([int(input()) for i in range(N)])

a = [0] * N
b = [0] * N
j = 1

for i in range(N-1):    
    a[i] += -j
    a[i+1] += j
    b[i] += j
    b[i+1] += -j    
    j = -j

a.sort()
b.sort()
s1 = sum([i*j for i,j in zip(a, A)])
s2 = sum([i*j for i,j in zip(b, A)])
print(max(s1,s2))
### BUGGY CODE ###

#! env python
# -*- coding: utf-8 -*-

import os
import sys


# ac_py.main
# Date: 2020/06/16
# Filename: main 
# Author: acto_mini

def main():
    K, S = map(int, input().split())

    ans = 0
    for i in range(K + 1):
        for j in range(K + 1):
            for p in range(K + 1):
                if (i + j + p) == S: ans += 1
    print(ans)
    return


if __name__ == '__main__':
    main()


### FIXED CODE ###

#! env python
# -*- coding: utf-8 -*-

import os
import sys


# ac_py.main
# Date: 2020/06/16
# Filename: main 
# Author: acto_mini

def main():
    K, S = map(int, input().split())

    ans = 0
    for i in range(K + 1):
        for j in range(K + 1):
            if 0 <= (S - i - j) <= K:
                ans += 1
    print(ans)
    return


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

def merge(A, left, mid, right):
    global count
    n1 = mid - left
    n2 = right - mid
    banpei = 10 ** 9 + 1
    L = [A[left + i] for i in range(n1)] + [banpei]
    R = [A[mid + i] for i in range(n2)] + [banpei]

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


def merge_Sort(A, left, right):
    if 1 < right - left:
        mid = int((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, n)
print(' '.join(map(str, A)))
print(count)

### FIXED CODE ###

def merge(A, left, mid, right):
    global count
    banpei = 1000000001
    L = A[left:mid] + [banpei]
    R = A[mid:right] + [banpei]

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


def merge_Sort(A, left, right):
    if 1 < right - left:
        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, n)
print(*A)
print(count)
### BUGGY CODE ###

import numpy as np
import math
from itertools import permutations
N = int(input())
coodinate = [list(map(int,input().split())) for _ in range(N)]
coodinate = np.array(coodinate)
SumDistance = 0
for val in permutations(coodinate):
    for i in range(N-1):
        SumDistance += ((val[i+1][0] - val[i][0]) ** 2 + (val[i+1][1] - val[i][1]) ** 2) ** (1 / 2)
print(SumDistance / math.factorial(N))

### FIXED CODE ###

import math
from itertools import permutations
N = int(input())
coodinate = [list(map(int,input().split())) for _ in range(N)]
f_N = math.factorial(N)
SumDistance = 0
j = 0
for val in permutations(coodinate):
    #if j >= math.factorial(N) // 2:
    #    break
    #print(val)
    for i in range(N-1):
        SumDistance += ((val[i+1][0] - val[i][0]) ** 2 + (val[i+1][1] - val[i][1]) ** 2) ** (1 / 2)
    #j += 1

print(SumDistance / math.factorial(N))
### BUGGY CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*len(h)

for i in range(1,min(k,n)):
    temp=10**10
    for j in range(i):
        temp=min(temp,dp[j]+abs(h[i]-h[j]))
    dp[i]+=temp 
for p in range(min(k,n),n):
    temp=10**10
    for q in range(k):
        temp=min(temp,dp[p-k+q]+abs(h[p]-h[p-k+q]))
    dp[p]+=temp 
print(dp[-1])

### FIXED CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*len(h)

for i in range(1,min(k,n)):
    temp=10**10
    for j in range(i):
        temp=min(temp,dp[j]+abs(h[i]-h[j]))
    dp[i]+=temp 
for p in range(min(k,n),n):
    temp=10**10
    for q in range(k):
        temp=min(temp,dp[p-k+q]+abs(h[p]-h[p-k+q]))
    dp[p]+=temp 
print(dp[-1])
### BUGGY CODE ###

x = list(map(int,input().split()))
N = x[0]
X = x[1]
Y = x[2]

import numpy as np
ans = np.zeros(N)

for i in range(1,N+1):
    for j in range(i,N+1):
        k = min(abs(i-j),abs(X-i)+1+abs(j-Y),abs(Y-i)+1+abs(j-X))
        ans[k] += 1

[print(int(x)) for x in ans[1:]]

### FIXED CODE ###

x = list(map(int,input().split()))
N = x[0]
X = x[1]
Y = x[2]

ans = [0] * N

for i in range(1,N+1):
    for j in range(i,N+1):
        k = min(abs(i-j),abs(X-i)+1+abs(j-Y),abs(Y-i)+1+abs(j-X))
        ans[k] += 1

[print(int(x)) for x in ans[1:]]