Harryxun/stf_run huggingface dataset:
#初期入力
import sys
input = sys.stdin.readline
import random
N = int(input())
connection   ={i:set() for i in range(1,N+1)}
A            ={i:tuple() for i in range(1,N+1)}
for i in range(N-1):
    a,b = (int(x) for x in input().split())
    connection[a].add(b) # つながりを逆向きも含めて入力
    connection[b].add(a) # 
    A[i]=a,b             #色を出力するため

#色の数(各頂点の最大値)
color_max =0
for i in connection.values():
    color_max =max(color_max, len(i) )

#各頂点に色を準備⇒辺の色決定
color_vertex ={i:set() for i in range(1,N+1)} #辺につながっている頂点に使った色
color_side =[0]*(N-1)
color =0
color_all =set(j for j in range(1,color_max +1) )
for i in range(N-1):
    v_a,v_b = A[i] #i番目の辺とつながっている頂点
    #while True:
    color =(color_all - color_vertex[v_a] -color_vertex[v_b]).pop() #全ての色-使った色[a]-使った色[b]
    #if color not in color_vertex[A[i]] :  #使った色リストに入っているか？
    color_side[i] =color          #辺の色を出力用に決める（2行上の＋１）
    color_vertex[v_a].add(color)    #前の頂点に使った色として追加
    color_vertex[v_b].add(color)    #先の頂点に使った色として追加
          
        #    break
        #else:
         #   color +=1
    
#出力
print(color_max)
print(*color_side, sep="\n")

### FIXED CODE ###

"""
参考    yy4さん 2019-11-24 21:24:43
516 ms          PyPy3 (2.4.0)
"""
#def solve():
from collections import deque
import sys

input = sys.stdin.readline

n = int(input())

g = tuple(set() for _ in range(n))
for idx in range(n - 1):
    a, b = (int(x) - 1 for x in input().split())
    g[a].add((b, idx))
    g[b].add((a, idx))

q = deque()
q.append((0, -1, -1))

e = [-1] * n  # e[-1]は使わない
used = [False] * n
used[0] = True
while q:
    v, v_idx, prev_color = q.popleft()
    curr = 1 if prev_color != 1 else 2
    for u, u_idx in g[v]:
        if used[u]:
            continue
        used[u] = True
        e[u_idx] = curr
        q.append((u, u_idx, curr))
        curr += 1
        if curr == prev_color:
            curr += 1

ret = e[:-1]
#return len(set(ret)), ret

    
#l, ret = solve()
l=len(set(ret))
print(l)
print(*ret, sep='\n')
import sys
sys.setrecursionlimit(10000000)
N = int(input())
JU = [-1] * N

LI = [[] for _ in range(N)]
for _ in range(N-1):
    u,v,w = map(int,input().split())
    W = w%2
    LI[u-1].append([v-1,W])
    LI[v-1].append([u-1,W])
def dfs(x):
    for i in range(len(LI[x])):
        j = LI[x][i][0]
        k = LI[x][i][1]
        if JU[j] == -1:
            if JU[i] == 0:
                if k == 0:
                    JU[j] = 0
                    dfs(j)
                else:
                    JU[j] = 1
                    dfs(j)
            else:
                if k == 0:
                    JU[j] = 1
                    dfs(j)
                else:
                    JU[j] = 0
                    dfs(j)
	return

JU[0] = 0
dfs(0)
for i in range(N):
    print(JU[i])


### FIXED CODE ###

import sys
sys.setrecursionlimit(10000000)
N = int(input())
JU = [-1 for _ in range(N)]

LI = [[] for _ in range(N)]
for _ in range(N-1):
    u,v,w = map(int,input().split())
    W = w%2
    LI[u-1].append([v-1,W])
    LI[v-1].append([u-1,W])
def dfs(x):
    for i in range(len(LI[x])):
        j = LI[x][i][0]
        k = LI[x][i][1]
        if JU[j] == -1:
            if JU[x] == 0:
                if k == 0:
                    JU[j] = 0
                    dfs(j)
                else:
                    JU[j] = 1
                    dfs(j)
            else:
                if k == 0:
                    JU[j] = 1
                    dfs(j)
                else:
                    JU[j] = 0
                    dfs(j)

JU[0] = 0
dfs(0)
for i in range(N):
    print(JU[i])
li = input()
li2 =[]
for n in li:
    if n == "0":
        li2.append("0")
    elif n == "1":
        li2.append("1")
    elif n == "B":
        if not len.li2 == 0:
            li2.pop()
print("".join(li2))


### FIXED CODE ###

li = input()
li2 =[]
for n in li:
    if n == "0":
        li2.append("0")
    elif n == "1":
        li2.append("1")
    elif n == "B":
        if not len(li2) == 0:
            li2.pop()
print("".join(li2))
N,Q=map(int,input().split())
S=input()

lis = [0] * (len(S)+1)
for i in range(len(S)+1):

  if i>0:
    lis[i] += lis[i-1]
  if i < len(S) and S[i] == 'A' and S[i+1] == 'C':
    lis[i+1] += 1

    
for _ in range(Q):
  L = tuple(map(int, input().split()))

  c = 0
  print(lis[L[1]-1]-lis[L[0]-1])

### FIXED CODE ###

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

lis = [0] * len(S)
for i in range(len(S)):

  if i>0:
    lis[i] += lis[i-1]
  if i < len(S)-1 and S[i] == 'A' and S[i+1] == 'C':
    lis[i+1] += 1


for _ in range(Q):
  L = tuple(map(int, input().split()))

  c = 0
  print(lis[L[1]-1]-lis[L[0]-1])
A = [int(i) for i in input().split(" ")]
ans = A[0] * A[1] - (1 * A[0] + 1 * A[1] -1)

print(ans)

### FIXED CODE ###

A = [int(i) for i in input().split(" ")]
ans = A[0] * A[1] - (1 * A[0] + 1 * A[1] -1)

print(ans)
def fiv(n):
    return (((1+(5)**(1/2))/2)** (n + 1) - ((1-(5)**(1/2))/2)** (n + 1))/(5**(1/2))

n, m = map(int, input().split())
broken = []
for i in range(m):
	broken.extend(map(int, input()))

p = [0] * (m + 1) #broken間の登り方list

for i in range(m + 1):
    if i == 0: #a1 さいしょ
        if broken[0] == 1:
            p[0] = 1
        else:
            p[0] = fiv(broken[0] - 1)
    if i == m: #am さいご
        if broken[m] == n - 1:
            p[m] = 1
        else:
            p[m] = fiv(n - broken[0] - 1)
    
    else:
        if broken[i] - broken[i - 1] - 1 == 0:
            print('0')
            exit()
        else:
            p[i] = fiv(broken[i] - broken[i - 1] - 1)

ans = 1
for i in range(m + 1):
    ans = ans * p[i]

print(ans)


### FIXED CODE ###

n, m = map(int, input().split())
mod = 10 ** 9 + 7
dp = [-1 for i in range(n + 1)]
dp[0], dp[1] = 1, 1
for _ in range(m):
    dp[int(input())] = 0
for i in range(2, n + 1):
    if dp[i] != 0:
        dp[i] = (dp[i - 1] + dp[i - 2]) % mod
print(dp[n])
a = int(input())
if i%2 == 0:
  print(1/2)
else:
  print((a/2+1)/a)

### FIXED CODE ###

a = int(input())
if a%2 == 0:
  print(1/2)
else:
  print((a//2+1)/a)
import sys
h, w, k = map(int, input().split())
grid = [[int(v) for v in input()] for _ in range(h)]
if h == 0 or w == 0:
    print(-1)
    sys.exit(0)
for row in grid:
    if len(row) != w:
        print(-1)
        sys.exit(0)


def count_ones(i):
    cnt = 0
    while i:
        if i & 1:
            cnt += 1
        i >>= 1
    return cnt

ans = h + w

for state in range(1 << h):
    j = 0
    vcnt = 0
    counters = [0] * (h + 1)
    is_ok = True
    while j < w:
        hi = 0
        i = 0
        local_counters = [0] * (h + 1)
        while i < h:
            if (1 << i) & state:
                hi = i
            # print(hi, i, j)
            # print(grid[i])
            local_counters[hi] += grid[i][j]
            i += 1
        for i, v in enumerate(local_counters):
            if v > k:
                is_ok = False
                break
            counters[i] += local_counters[i]
        if not is_ok:
            break
        if max(counters) > k:
            counters = local_counters.copy()
            vcnt += 1

        j += 1


    if is_ok and ans > count_ones(state) + vcnt:
        ans = count_ones(state) + vcnt
print(ans)



### FIXED CODE ###

import sys
def ass(v):
    if not v:
        print(-1)
        sys.exit(0)

h, w, k = map(int, input().split())
grid = [[1 if v == '1' else 0 for v in input()] for _ in range(h)]


ass(h > 0 and w > 0 and k > 0)
for row in grid:
    ass(len(row) == w)


def count_ones(i):
    cnt = 0
    while i:
        if i & 1:
            cnt += 1
        i >>= 1
    return cnt

ans = h + w

for state in range(1 << h):
    j = 0
    vcnt = 0
    counters = [0] * (h + 1)
    is_ok = True
    while j < w:
        hi = 0
        i = 0
        local_counters = [0] * (h + 1)
        ass(len(counters) == len(local_counters))
        while i < h:
            if (1 << i) & state:
                hi = i
            # print(hi, i, j)
            # print(grid[i])
            ass(len(local_counters) > hi)
            ass(i < h and j < w)
            ass(len(grid) > i)
            ass(len(grid[i]) > j)
            local_counters[hi] += grid[i][j]
            i += 1
        for i, v in enumerate(local_counters):
            if v > k:
                is_ok = False
                break
            counters[i] += local_counters[i]
        if not is_ok:
            break
        # ass(len(counters))
        # ass(k)
        if max(counters) > k:
            counters = local_counters[:]
            vcnt += 1

        j += 1


    if is_ok and ans > count_ones(state) + vcnt:
        ans = count_ones(state) + vcnt
print(ans)
def main():
    N, K = map(int, input().split())
    mod = 10**9 + 7
    A = list(map(int, input().split()))
    B = [(abs(x), x) for x in A]
    B.sort(reverse=True)
    plus = []
    minus = []

    ans = 1

    if N == K:
        for x in A:
            ans *= x
            ans %= mod
        print(ans)
        return
    minus_count = 0
    for i in range(K):
        if B[i][-1] < 0:
            minus_count += 1
            minus.append(B[i][-1])
        else:
            plus.append(B[i][-1])
        ans *= B[i][-1]
        ans %= mod

    if minus_count % 2 == 0:
        print(ans)
        return

    else:
        if len(plus) > 0 and len(minus) > 0:
            S = 1
            for i in range(len(plus)-1):
                S *= plus[i]
                S %= mod
            for i in range(len(minus)-1):
                S *= minus[i]
                S %= mod
            plus_sub = -1
            mimus_sub = -1
            for i in range(K, N):
                if B[i][-1] >= 0:
                    plus_sub = B[i][-1]*plus[-1]
                    break
            for i in range(K, N):
                if B[i][-1] < 0:
                    minus_sub = B[i][-1]*minus[-1]
            print(S*max(plus_sub, minus_sub) % mod)
            return

        else:
            for i in range(K, N):
                if B[i][-1] >= 0:
                    minus.append(B[i][-1])
                    break
            if minus[-1] >= 0:
                res = 1
                for i in range(K-1):
                    res *= minus[i]
                    res %= mod
                res *= mimus[-1]
                print(res % mod)
                return
            else:
                A.sort(reverse=True)
                res = 1
                for i in range(K):
                    res *= A[i]
                    res %= mod
                print(res)
                return


main()

### FIXED CODE ###

#時間の無駄なのでクソ問と割り切って飛ばす
def prod(array):
    res = 1
    for a, _ in array:
        res *= a
        res %= MOD
    return res

MOD = 10**9 + 7
N, K = map(int, input().split())
if N==K:
    res = 1
    for a in map(int, input().split()):
        res *= a
        res %= MOD
    print(res)
    exit()
A = []
allsgn = 0
for a in map(int, input().split()):
    A.append((abs(a), a < 0))
    allsgn += a<0
A.sort(reverse=True)
sgn = 0
s0 = -1
lastA = -1
for i, p in enumerate(A[:K]):
    a, s = p
    sgn += s
    if s != s0:
        lastA = i-1
    s0 = s
lasts = s0
if allsgn==N:
    if K%2==1:
        print((-prod(A[-K:]))%MOD)
        exit()
    else:
        print(prod(A[:K])%MOD)
        exit()
if sgn%2==0:
    print(prod(A[:K])%MOD)
    exit()
if lasts != A[K][1]:
    res = prod(A[:K-1])*A[K][0]
else:
    firstA = None
    for i, p in enumerate(A[K:],start=K):
        a, s = p
        if s != lasts:
            firstA = i
            break
    if lastA == -1 or (firstA is not None and A[K][0]/A[lastA][0] < A[firstA][0]/A[K-1][0]):
        res = prod(A[:K - 1]) * A[firstA][0]
    else:
        res = prod(A[:lastA]) * prod(A[lastA + 1:K + 1])
print(res%MOD)
"""
6 3
5 -3 -3 -3 -3 -2

10 7
-10 -10 -10 -10 10 10 10 10 10 10
"""
2 10 3

### FIXED CODE ###

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

if b-a+1 <= k*2:
    for h in range(a, b+1):
        print(h)

else:
    for i in range(a, a+k):
        print(i)
    for j in range(b-k+1, b+1):
        print(j)
n,m = map(int,input().split())

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

di=[1,-1,0,0]
dj=[0,0,1,-1]
for i in range(1,n-1):
    for j in range(1,m-1):
        if s[i][j]=='#':
            found=False
            for k in range(4):
                i2=i+di[k]
                j2=j+dj[k]
                if 0<=i2 and i2<n and 0<=j2 and j2<m:
                    if s[i2][j2]=='#':
                        found=True
            if not found:
                print('No')
                sys.exit()

print('Yes')

### FIXED CODE ###

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

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

di=[1,-1,0,0]
dj=[0,0,1,-1]
for i in range(n):
    for j in range(m):
        if s[i][j]=='#':
            found=False
            for k in range(4):
                i2=i+di[k]
                j2=j+dj[k]
                if 0<=i2 and i2<n and 0<=j2 and j2<m:
                    if s[i2][j2]=='#':
                        found=True
            if not found:
                print('No')
                exit()

print('Yes')
x, k, d = map(int, input().split())

lo = 0
hi = k

while (lo < hi) :
  mid = lo + (hi - lo) // 2 + 1
  if (x >= 0) :
    if (x - mid * d >= 0) : 
      lo = mid;
    else :
      hi = mid - 1
  else :
    if (x + mid * d <= 0) :
      lo = mid;
    else :
      hi = mid - 1;

if (x >= 0) x -= d * hi;
else x += d * hi;

k -= hi;

if ( (k % 2) == 0):
  if (k == 0) :
    print(abs(x))
  else :
    print(min(abs(x), abs(x - d - d), abs(x + d + d)));
else :
  if (k == 1) :
    print(min(abs(x - d), abs(x + d)))
  else :
    print(min(abs(x - d), abs(x + d), abs(x + d + d + d), abs(x - d - d - d)));


### FIXED CODE ###

x, k, d = map(int, input().split())

lo = 0
hi = k

while (lo < hi) :
  mid = lo + (hi - lo) // 2 + 1
  if (x >= 0) :
    if (x - mid * d >= 0) : 
      lo = mid;
    else :
      hi = mid - 1
  else :
    if (x + mid * d <= 0) :
      lo = mid;
    else :
      hi = mid - 1;

if (x >= 0) :
  x -= d * hi
else :
  x += d * hi

k -= hi;

if ( (k % 2) == 0):
  if (k == 0) :
    print(abs(x))
  else :
    print(min(abs(x), abs(x - d - d), abs(x + d + d)));
else :
  if (k == 1) :
    print(min(abs(x - d), abs(x + d)))
  else :
    print(min(abs(x - d), abs(x + d), abs(x + d + d + d), abs(x - d - d - d)));
N,A,B,C,D = map(int,input().split())
S = input()
A -= 1
B -= 1
C -= 1
D -= 1

if S[A:max(C,D)+1].count("##") == 0 :
    elif C < D :
        print("Yes")
    else :
        if S[B-1:D+2].count("...") :
            print("Yes")
        else :
            print("No")
else :
    print("No")

### FIXED CODE ###

N,a,b,c,d = map(int,input().split())
S = input()
a -= 1
b -= 1
c -= 1
d -= 1

if c < d :
    if (S[b:d+1].count("##") == 0) and (S[a:c+1].count("##") == 0) :
        ans = "Yes"
    else :
        ans = "No"
else :
    if (S[b:d+1].count("##") == 0) and (S[a:c+1].count("##") == 0) :
        flg1 = 1
    else :
        flg1 = 0
    

    if S[a:d+1].count("...") >= 1 :
        flg2 = 1
    else :
        flg2 = 0
        
    for i in range(b,d+1) :
        if (S[i-1]+S[i]+S[i+1] == "...") :
            flg3 = 1
            break
    else :
        flg3 = 0
    
    
    if flg1*flg3 :
        ans = "Yes"
    else :
        ans = "No"
print(ans)
# -*- coding: utf-8 -*-
from copy import copy
a = list(input())
cur_min = 100001
def remove_max(cubes):
    global cur_min
    for i in range(len(cubes)-1):
        if cubes[i] != cubes[i+1]:
            z = copy(cubes)
            z.pop(i)
            z.pop(i)
            if len(z) == 0:
                cur_min=0
            if len(z) <= cur_min:
                cur_min = len(z)
                remove_max(z)
remove_max(a)
if cur_min==100001:
    print(0)
else:
    print(len(a) - cur_min)


### FIXED CODE ###

# -*- coding: utf-8 -*-
a = input()
len_a = len(a)
sum_a = sum(list(map(int,list(a))))
ret = min(sum_a,len_a-sum_a) * 2
print(ret)
import numpy as np
n,q=list(map(int, input().split()))
result = {i+1:0 for i in range(n)}
ar = np.eye(n)

for i in range(n-1):
    a,b = list(map(int, input().split()))
    ar[0:a,a-1:b] += 1
for i in range(q):
    a,b = list(map(int, input().split()))
    m = ar[a-1]
    for j in range(len(m)):
        if m[j] != 0:
            result[j+1] += b
        else:
            result[j+1] += 0
r = list(result.values())
res = map(str, r)
print(' '.join(res))

### FIXED CODE ###

a = int(input())
s = input()
if a >= 3200:
  print(s)
else:
  print('red')
import sys
sys.setrecursionlimit(10**9)

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

A = sorted(A)

fac = [1]*(A[-1]+1)

for i in range(2,len(fac)) :
    fac[i] = i * fac[i-1]

ans1 = A[-1]
ans2 = 0

c = 0

for i in range(N) :
    a = A[i]
    calc = fac[ans1]//(fac[a] * fac[ans1-a])

    if c < calc :
        ans2 = a
        c = calc

print(ans1,ans2)


### FIXED CODE ###

import bisect

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

A = sorted(A)

ans1 = A[-1]

ind = bisect.bisect_left(A, ans1/2)


c = float("inf")
for i in range(max(0,ind-1), min(N-1,ind+2)) :
    calc = abs(ans1/2 - A[i])
    if calc < c :
        ans2 = A[i]
        c = calc
print(ans1,ans2)
k,x=map(int,input().split())
a=x-k+1
b=x+k-1
a=min(a,-1000000)
b=max(b,1000000)
c=range(a,b+1)
c=' '.join(c)
print(c)


### FIXED CODE ###

k,x=map(int,input().split())
a=x-k+1
b=x+k-1
a=max(a,-1000000)
b=min(b,1000000)
c=[k for k in range(a,b+1)]
for i in c:
  print('%d '%i),
N=int(input())
ans=0
for i in range(1,N):
    count=0
    for j in range(i):
        if i%j==0:
            count+=1
    if count==9:
        ans+=1
        
print(ans)

### FIXED CODE ###

N=int(input())
ans=0
for i in range(1,N+1):
    count=0
    for j in range(1,i+1):
        if i%j==0:
            count+=1
    if count==8 and i%2!=0:
        ans+=1
        
print(ans)
import copy

def main():
    def gcd(a, b):
        if b == 0:
            return a
        else:
            return gcd(b, a%b)

    def lcm(a, b):
        return int(a / gcd(a, b)) * b

    n, m = map(int, input().split())
    # これだと72がREになる
    A = set([int(x) for x in input().split()])
    # これだと74も78もREになる
    # A = [int(x) for x in input().split()]
    A_ = copy.deepcopy(A)
    a_lcm = A.pop()
    # Aの要素が複数ならlcmを計算する
    if len(A) >= 1:
        for a in A:
            a_lcm = lcm(a_lcm, a)
    # 元のAの値とlcmの半分の値を割り切れるものがあったら0
    for i in A_:
        if (a_lcm / 2) % i != 0:
            continue
        else:
            print(0)
            exit()
    # mがlcmの半分よりも小さかったら0
    if a_lcm / 2 > m:
        print(0)
    else:
        # あとは定数倍の数調べて終わり
        # ans = int((m - (a_lcm / 2))) // a_lcm + 1
        ans = int((m - (a_lcm / 2)) // a_lcm) + 1
        print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import copy
# from math import gcd


def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

def lcm(a, b):
    return (a // gcd(a, b)) * b
def main():
    n, m = map(int, input().split())
    A = set([int(x) for x in input().split()])
    a_lcm = 1
    for a in A:
        a_lcm = lcm(a_lcm, a)
        # mがlcmの半分よりも小さかったら0
        if (a_lcm / 2) > m:
            print(0)
            exit()
    for a in A:
        if (a_lcm / 2) % a == 0:
            print(0)
            exit()
    # # あとは定数倍の数調べて終わり
    ans = int((m - (a_lcm / 2)) // a_lcm) + 1
    print(ans)

if __name__ == '__main__':
    main()
candy = N * N /2 + N /2

print(candy)

### FIXED CODE ###

N = int( input() )

candy = int( N * ( N + 1 ) / 2 )

print(candy)
from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# strlist = "abcdefghijklmnopqrstuvwxyz"
a,b,k = map(int,input().split())

def makedivs(n):
    divs = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divs.append(i)
            if i != n // i:
                divs.append(n//i)
    # divs.sort()
    return divs

c = gcd(a,b)
anslis = makedivs(c)
anslis.sort()

print(anslis[-k])
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


### FIXED CODE ###

# from math import factorial,sqrt,ceil
# from itertools import permutations as permus
from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# strlist = "abcdefghijklmnopqrstuvwxyz"
a,b,k = map(int,input().split())

def makedivs(n):
    divs = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divs.append(i)
            if i != n // i:
                divs.append(n//i)
    # divs.sort()
    return divs

c = gcd(a,b)
anslis = makedivs(c)
anslis.sort()

print(anslis[-k])
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))
N = int(input())
K = int(input())
p = list(map(int, input().split()))
lists = []
for l in itertools.combinations(p, 3):
  sums = sum(list(l))
  return lists.append(sums)

print(min(lists))
  
  


### FIXED CODE ###

S = list(map(int, input().strip().split()))
N = S[0]
K = S[1]
p = list(map(int, input().strip().split()))
lists = []
for l in range(K):
  lists.append(min(p))
  p.remove(min(p))
  
print(sum(lists))
N, M = map(int,input().split())

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

def waribiki(X,Y):
    return X//(2**Y)

A.sort(reverse=True)
while M>0:
    A[0] = waribiki(A[0],1)
    M -= 1
    if len(A)>1:
        if A[0] < A[1]:
            i=0
            while A[i] < A[i+1]:
                tmp = A[i+1]
                A[i+1]=A[i]
                A[i]=tmp
                i+=1

print(sum(A))


### FIXED CODE ###

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

def intm(x):
    return int(x)*-1
A = list(map(intm, input().split()))

import heapq

heapq.heapify(A)
while M>0:
    a = -heapq.heappop(A) // 2
    heapq.heappush(A,-a)
    M -= 1
   

print(-sum(A))
enkitsui = {'A':'T','C':'G','T':'A','G':'C'}
print(enkitsui[b])

### FIXED CODE ###

b = input()
enkitsui = {'A':'T','C':'G','T':'A','G':'C'}
print(enkitsui[b])
N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = [0]*N
dp[0] = 0
dp[1]=abs(h[1]-h[0])
for i in range(2,N):
  dp[i] += min(dpj+abs(hj-h[i]) for dpj,hj in zip(dp[i-k:i],h[i-k:i])
print(dp[-1])

### FIXED CODE ###

import numpy as np
N,K = map(int,input().split())
h = list(map(int,input().split()))
h = np.array(h)
dp = [0]*N
dp = np.array(dp)
dp[1]=abs(h[1]-h[0])
for i in range(1,N):
  j = max(0,i-K)
  dp[i] = min(dp[j:i]+abs(h[i]-h[j:i]))
print(dp[N-1])
x=[int(input()) for _ in range(5)]
y=[x[_]%10 for _ in range(5)]
y.sort()
s=0
for _ in range(5):
  if y[_]!=0:
    a=y[_]
    s=-1
    break
for _ in range(5):
  s=s-(-x[_] // 10)
print((s)*10+a)

### FIXED CODE ###

x=[int(input()) for _ in range(5)]
y=[x[_]%10 for _ in range(5)]
y.sort()
s=0
a=0
for _ in range(5):
  if y[_]!=0:
    a=y[_]
    s=-1
    break
for _ in range(5):
  s=s-(-x[_] // 10)
print((s)*10+a)
a, b = map(int, input().split())
s = list(input())
s[b] = s[b].lower()
s = str(s)
print('{}'.format(s))

### FIXED CODE ###

a, b = map(int, input().split())
c = input()
c = list(c)
if (c[b-1] == 'A'):
    c[b-1] = 'a'
if (c[b-1] == 'B'):
    c[b-1] = 'b'
if (c[b-1] == 'C'):
    c[b-1] = 'c'
c = ''.join(c)
print('{}'.format(c))