CodeEff/ECCO huggingface dataset:
# Original solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, M = list(map(int, readline().split()))

e_IN = [[] for _ in range(N+1)]
e_OUT = [[] for _ in range(N+1)]

for _ in range(M):
    l, r, d = list(map(int, readline().split()))
    e_OUT[l].append((r, d))
    e_IN[r].append((l, d))

posx = [-1] * (N + 1)


def dfs(v):
    #　0<=x<=10**9に注意
    node = [v]
    posx[v] = 0
    diameter = 0
    while node:
        s = node.pop()
        ds = posx[s]
        for t, dt in e_OUT[s]:
            dist = ds + dt
            if posx[t] != -1:
                if posx[t] != dist:
                    return False
                else:
                    continue
            posx[t] = dist
            node.append(t)
            diameter = max(diameter, dist)
    if diameter <= 10 ** 9:
        return True
    else:
        return False


ans = "Yes"
for i in range(N + 1):
    if len(e_IN[i]) == 0:
        posx[i] = 0
        bl = dfs(i)
        if not bl:
            ans = "No"
            break

if - 1 in posx:
    ans = "No"

print(ans)

# Optimized solution
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N, M = list(map(int, input().split()))
edge = [[] for _ in range(N + 1)]
for _ in range(M):
    s, t, d = list(map(int, input().split()))
    edge[s].append((t, d))
    edge[t].append((s, -d))

dist = [None] * (N + 1)


def isOK(v):
    node = [v]
    if dist[v] is None:
        dist[v] = 0

    while node:
        s = node.pop()
        for t, d in edge[s]:
            if dist[t] is None:
                dist[t] = dist[s] + d
                node.append(t)
            else:
                if dist[t] != dist[s] + d:
                    return False
    return True


ans = "Yes"
for i in range(1, N + 1):
    if dist[i] is not None:
        continue

    if not isOK(i):
        ans = "No"
        break
print(ans)
# Original solution
n, m = list(map(int, input().split()))
inf = 10**10
G = [{} for i in range(n)]
for i in range(m):
    l, r, d = list(map(int, input().split()))
    G[l-1][r-1] = d
    G[r-1][l-1] = -d
V = [False for i in range(n)]
D = [inf for i in range(n)]
for i in range(n):
    if V[i]:
        continue
    Q = [i]
    D[i] = 0
    while Q:
        j = Q.pop()
        V[j] = True
        for k in list(G[j].keys()):
            if not V[k]:
                Q.append(k)
            if D[k] == inf:
                D[k] = D[j]+G[j][k]
            elif D[k] != D[j]+G[j][k]:
                print('No')
                exit()
print('Yes')


# Optimized solution
n, m = list(map(int, input().split()))
inf = 10**10
# G[i][j] = iからjへの距離
G = [{} for i in range(n)]
for i in range(m):
    l, r, d = list(map(int, input().split()))
    G[l-1][r-1] = d
    G[r-1][l-1] = -d
# D[j] = jの属する連結成分のトップからjへの距離
D = [inf for i in range(n)]
# まだ探索していないiをトップとして探索する
for i in range(n):
    if D[i] != inf:
        continue
    Q = [i]
    D[i] = 0
    while Q:
        j = Q.pop()
        for k in list(G[j].keys()):
            if D[k] == inf:
                Q.append(k)
            if D[k] == inf:
                D[k] = D[j]+G[j][k]
            elif D[k] != D[j]+G[j][k]:
                print('No')
                exit()
print('Yes')
# Original solution
import math

n = int(eval(input()))
for i in range(n):
    xa, ya, ra, xb, yb, rb = list(map(float, input().split()))
    d = math.sqrt((xb - xa) ** 2 + (yb - ya) ** 2)
    if d < ra - rb:
        print((2))
    elif d < rb - ra:
        print((-2))
    elif abs(rb - ra) <= d and d <= ra + rb:
        print((1))
    else:
        print((0))

# Optimized solution
import math

n = int(eval(input()))
for i in range(n):
    xa, ya, ra, xb, yb, rb = list(map(float, input().split()))
    d = math.sqrt((xb - xa) ** 2 + (yb - ya) ** 2)
    if d < ra - rb:
        print((2))
    elif d < rb - ra:
        print((-2))
    elif d <= ra + rb:
        print((1))
    else:
        print((0))
# Original solution
A, B, C, D, E, F = list(map(int, input().split()))
c = []
ans_list = []

for i in range(1, F // (100 * A) + 1):
    for j in range(F // (100 * B) + 1):
        a = 100 * A * i + 100 * B * j
        if a > F:
            break
        for k in range((F - a) // C + 1):
            for l in range((F - a) // D + 1):
                b = k * C + l * D
                if (A * i + B * j) * E >= b and a + b <= F:
                    c.append(100 * b / (a + b))
                    ans_list.append([a + b, b])
                else:
                    break

ans = ans_list[c.index(max(c))]

print((' '.join(map(str, ans))))


# Optimized solution
A, B, C, D, E, F = list(map(int, input().split()))
ans = [100 * A, 0]
c = 0

for i in range(1, F // (100 * A) + 1):
    for j in range(F // (100 * B) + 1):
        a = 100 * A * i + 100 * B * j
        if a > F:
            break
        for k in range((F - a) // C + 1):
            for l in range((F - a) // D + 1):
                b = k * C + l * D
                concentration = 100 * b / (a + b)
                if (A * i + B * j) * E >= b and a + b <= F:
                    if concentration > c:
                        c = concentration
                        ans = [a + b, b]
                else:
                    break

print((' '.join(map(str, ans))))
# Original solution
A, B, C, D, E, F = list(map(int, input().split()))
ans = [100 * A, 0]
c = 0

for i in range(1, F // (100 * A) + 1):
    for j in range((F - 100 * A * i) // (100 * B) + 1):
        a = 100 * A * i + 100 * B * j
        if a > F:
            break
        for k in range((F - a) // C + 1):
            for l in range((F - a - C * k) // D + 1):
                b = k * C + l * D
                concentration = 100 * b / (a + b)
                if (A * i + B * j) * E >= b and a + b <= F:
                    if concentration > c:
                        c = concentration
                        ans = [a + b, b]
                else:
                    break

print((' '.join(map(str, ans))))

# Optimized solution
A, B, C, D, E, F = list(map(int, input().split()))
ans = [100 * A, 0]
c = 0

for i in range(1, F // (100 * A) + 1):
    for j in range((F - 100 * A * i) // (100 * B) + 1):
        a = 100 * A * i + 100 * B * j
        for k in range((F - a) // C + 1):
            for l in range((F - a - C * k) // D + 1):
                b = k * C + l * D
                concentration = 100 * b / (a + b)
                if (A * i + B * j) * E >= b:
                    if concentration > c:
                        c = concentration
                        ans = [a + b, b]
                else:
                    break

print((' '.join(map(str, ans))))
# Original solution
A, B, C, D, E, F = list(map(int, input().split()))
ans = [100 * A, 0]
c = 0

for i in range(1, F // (100 * A) + 1):
    for j in range((F - 100 * A * i) // (100 * B) + 1):
        a = 100 * A * i + 100 * B * j
        for k in range((F - a) // C + 1):
            for l in range((F - a - C * k) // D + 1):
                b = k * C + l * D
                concentration = 100 * b / (a + b)
                if (A * i + B * j) * E >= b:
                    if concentration > c:
                        c = concentration
                        ans = [a + b, b]
                else:
                    break

print((' '.join(map(str, ans))))

# Optimized solution
A, B, C, D, E, F = list(map(int, input().split()))
water = set([])

for i in range(1, F // (100 * A) + 1):
    water1 = i * 100 * A
    for j in range((F - water1) // (100 * B) + 1):
        water2 = j * 100 * B
        water.add(water1 + water2)

ans = [100 * A, 0]
c = 0

for i in water:
    max_sugar = min(i // 100 * E, F - i)
    sugar = [0]
    for j in range(max_sugar // C + 1):
        for k in range((max_sugar - j * C) // D + 1):
            sugar.append(j * C + k * D)
    max_sugar = max(sugar)
    concentration = max_sugar / (i + max_sugar)
    if c < concentration:
        c = concentration
        ans = [i + max_sugar, max_sugar]

print((' '.join(map(str, ans))))
# Original solution
A, B, C, D, E, F = list(map(int, input().split()))
water = set([])

for i in range(1, F // (100 * A) + 1):
    water1 = i * 100 * A
    for j in range((F - water1) // (100 * B) + 1):
        water2 = j * 100 * B
        water.add(water1 + water2)

ans = [100 * A, 0]
c = 0

for i in water:
    max_sugar = min(i // 100 * E, F - i)
    sugar = 0
    for j in range(max_sugar // C + 1):
        for k in range((max_sugar - j * C) // D + 1):
            sugar = max(sugar, j * C + k * D)
    concentration = sugar / (i + sugar)
    if c < concentration:
        c = concentration
        ans = [i + sugar, sugar]

print((' '.join(map(str, ans))))

# Optimized solution
A, B, C, D, E, F = list(map(int, input().split()))
water = set([])

for i in range(1, F // (100 * A) + 1):
    water1 = i * 100 * A
    for j in range((F - water1) // (100 * B) + 1):
        water2 = j * 100 * B
        water.add(water1 + water2)

ans = [100 * A, 0]
c = 0

for i in water:
    max_sugar = min(i // 100 * E, F - i)
    sugar = 0
    for j in reversed(list(range(max_sugar // C + 1))):
        for k in range((max_sugar - j * C) // D + 1):
            sugar = max(sugar, j * C + k * D)
            if max_sugar == sugar:
                break
        else:
            continue
        break
    concentration = sugar / (i + sugar)
    if c < concentration:
        c = concentration
        ans = [i + sugar, sugar]

print((' '.join(map(str, ans))))
# Original solution
import sys
import math
cadena = list()
sub = list()
sub2 =list()
s  =""" Since <fontstyle="vertical−align:inherit;"><fontstyle="vertical−align:inherit;">1+2=3<⁄font><⁄font>, the output should be <fontstyle="vertical−align:inherit;"><fontstyle="vertical−align:inherit;">3<⁄font><⁄font>."""
salida = """<fontstyle="vertical−align:inherit;"><fontstyle="vertical−align:inherit;">3<⁄font><⁄font>."""

kl = salida.find(">3<")


x = s.split()
j = s.find("1+2=3")
l = s.find(">3<")
sub2.append(s[l+1])

sub.append(s[j:j+5])
c = sub[0]
from itertools import permutations

lines = sys.stdin.readlines()
for linea in lines:
    c = linea.split()
    c = list(map(str,c))


x1 = int(c[0])
x2 =int(c[2])

operador = c[1]

if operador == "+":
  op = x1+x2
if operador == "-":
  op = x1-x2
elif operador == "*":
  op = x1*x2
if operador == "/":
  op = x1/x2      
str(op)
operacion1 = s[j:j+2]
my_lst_str = ''.join(map(str, c)) 
operacion1 = s[j:j+3]
men = s.replace(operacion1, my_lst_str)
s = men
numero =s[j+4]
men1 = salida.replace(salida[74], str(op))
men = s.replace(numero, str(op))
print(op)


# Optimized solution
s = input().split()
if s[1] == "-":
    print((int(s[0])-int(s[2])))
if s[1] == "+":
    print((int(s[0])+int(s[2])))
# Original solution
a, op, b = input().split()
a, b = int(a), int(b)

if op == '+':
    print((a + b))
else:
    print((a - b))


# Optimized solution
print((eval(input())))
# Original solution
l = input().split()
print((int(l[0]) + int(l[2]) if l[1] == '+' else int(l[0]) - int(l[2])))


# Optimized solution
print((eval(input())))
# Original solution
print((eval(input())))

# Optimized solution
a,b,c=input().split()
if b=="-":
  print((int(a)-int(c)))
else:
  print((int(a)+int(c)))
# Original solution
val = input().split()
if val[1] == "+":
    print((int(val[0])+int(val[2])))
else:
    print((int(val[0]) - int(val[2])))


# Optimized solution
print((eval(input())))
# Original solution
def main():
    A, op, B = input().split()
    A = int(A)
    B = int(B)

    if op == "+":
        print((A + B))
    else:
        print((A - B))


if __name__ == "__main__":
    main()

# Optimized solution
print((eval(input())))
# Original solution
print((eval(''.join(input().split()))))

# Optimized solution
print((eval(input())))
# Original solution
S = input().split()
a, b = int(S[0]), int(S[2])
if S[1] == '+':
    print((a + b))
else:
    print((a - b))


# Optimized solution
print((eval(input())))
# Original solution
print((eval(input().replace(' ',''))))

# Optimized solution
print((eval(input())))
# Original solution
a = input().split()

if a[1] == '+':
    ans = int(a[0]) + int(a[2])
else:
    ans = int(a[0]) - int(a[2])

print(ans)


# Optimized solution
print((eval(input())))
# Original solution
'''
ABC050 A - Addition and Subtraction Easy
https://atcoder.jp/contests/abc050/tasks/abc050_a
'''
a, op, b = input().split()
a, b = int(a), int(b)

if op == '+':
    ans = a+b
elif op == '-':
    ans = a-b
print(ans)


# Optimized solution
'''
ABC050 A - Addition and Subtraction Easy
https://atcoder.jp/contests/abc050/tasks/abc050_a
'''
def main():
    a, op, b = input().split()
    a, b = int(a), int(b)

    if op == '+':
        ans = a+b
    elif op == '-':
        ans = a-b
    print(ans)

if __name__ == '__main__':
    main()
# Original solution
A, op, B = input().split()
print((int(A) + int(B) if op == '+' else int(A) - int(B)))

# Optimized solution
A, op, B = input().split()
A = int(A); B = int(B)
print((A + B if op == '+' else A - B))
# Original solution
import functools

import os
import sys

sys.setrecursionlimit(10000)
INF = float('inf')


def inp():
    return int(eval(input()))


def inpf():
    return float(eval(input()))


def inps():
    return eval(input())


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def inpm(line):
    return [inp() for _ in range(line)]


def inpfm(line):
    return [inpf() for _ in range(line)]


def inpsm(line):
    return [inps() for _ in range(line)]


def inlm(line):
    return [inl() for _ in range(line)]


def inlfm(line):
    return [inlf() for _ in range(line)]


def inlsm(line):
    return [inls() for _ in range(line)]


def Yesif(cond):
    print(('Yes' if cond else 'No'))


def YESIF(cond):
    print(('YES' if cond else 'NO'))


def yesif(cond):
    print(('yes' if cond else 'no'))

a, o, b = inls()
if o=='+':
    print((int(a) + int(b)))
else:
    print((int(a) - int(b)))


# Optimized solution
import functools

import os
import sys

sys.setrecursionlimit(10000)
INF = float('inf')


def inp():
    return int(eval(input()))


def inpf():
    return float(eval(input()))


def inps():
    return eval(input())


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def inpm(line):
    return [inp() for _ in range(line)]


def inpfm(line):
    return [inpf() for _ in range(line)]


def inpsm(line):
    return [inps() for _ in range(line)]


def inlm(line):
    return [inl() for _ in range(line)]


def inlfm(line):
    return [inlf() for _ in range(line)]


def inlsm(line):
    return [inls() for _ in range(line)]


def Yesif(cond):
    print(('Yes' if cond else 'No'))


def YESIF(cond):
    print(('YES' if cond else 'NO'))


def yesif(cond):
    print(('yes' if cond else 'no'))


print((eval(input())))
# Original solution
s = list((input().split()))

if s[1] =='+':
  ans = int(s[0]) + int(s[2])
elif s[1] =='-':
  ans = int(s[0]) - int(s[2])

print(ans)

# Optimized solution
s = input().split()
if s[1] =='+':
  print((int(s[0])+ int(s[2])))
else:
  print((int(s[0])- int(s[2])))
# Original solution
a,o,b=input().split()
a=int(a)
b=int(b)
print(([a+b,a-b][o=="-"]))

# Optimized solution
print((eval(input())))
# Original solution
A,op,B=input().split() 
if op=="+": 
    print((int(A)+int(B))) 
else: 
    print((int(A)-int(B)))

# Optimized solution
A,op,B=input().split()
print((int(A)+int(B)if op=="+" else int(A)-int(B)))
# Original solution
A,op,B=input().split()
A,B=list(map(int,[A,B]))
print((A+B if op=="+" else A-B))

# Optimized solution
print((eval(input())))
# Original solution
print((eval(input())))

# Optimized solution
print(eval(input()))
# Original solution
print(eval(input()))

# Optimized solution
print((eval(input())))
# Original solution
a,op,b=[i for i in input().split()]
print((int(a)+int(b) if op=='+' else int(a)-int(b)))

# Optimized solution
print((eval(input())))
# Original solution
a, op, b = input().split()
print((eval(a+op+b)))

# Optimized solution
A, op, B = input().split()
print((int(A) + int(B) if op == '+' else int(A) - int(B)))
# Original solution
import sys
input = sys.stdin.readline
from collections import deque, Counter

N = int(input())
X = [[] for i in range(N)]
L = [0]*N
for i in range(N-1):
    x, y = map(int, input().split())
    X[x-1].append(y-1)
    X[y-1].append(x-1)
    L[x-1] += 1
    L[y-1] += 1

P = [-1] * N
Q = deque([0])
R = []
while Q:
    i = deque.popleft(Q)
    R.append(i)
    for a in X[i]:
        if a != P[i]:
            P[a] = i
            X[a].remove(i)
            deque.append(Q, a)

C = Counter(P)
##### Settings
unit = 0
merge = lambda a, b: a + b
adj_bu = lambda a, i: (a+1)/C[P[i]]
adj_td = lambda a, i, p: ((XX[P[i]]*L[P[i]]-XX[i]*C[P[i]])/max(1,L[P[i]]-1)+1)/max(1,C[i])
adj_fin = lambda a, i: a*max(1,C[i])/L[i]
#####

ME = [unit] * N
XX = [0] * N
TD = [unit] * N
for i in R[1:][::-1]:
    XX[i] = adj_bu(ME[i], i)
    p = P[i]
    ME[p] = merge(ME[p], XX[i])
XX[R[0]] = adj_fin(ME[R[0]], R[0])

for i in R:
    ac = TD[i]
    for j in X[i]:
        TD[j] = ac
        ac = merge(ac, XX[j])

    ac = unit
    for j in reversed(X[i]):
        TD[j] = adj_td(merge(TD[j], ac), j, i)
        ac = merge(ac, XX[j])
        XX[j] = adj_fin(merge(ME[j], TD[j]), j)

print(*XX, sep = "\n")


# Optimized solution
import sys
input = sys.stdin.readline
from collections import deque, Counter

N = int(input())
X = [[] for i in range(N)]
L = [0]*N
for i in range(N-1):
    x, y = map(int, input().split())
    X[x-1].append(y-1)
    X[y-1].append(x-1)
    L[x-1] += 1
    L[y-1] += 1

P = [-1] * N
Q = deque([0])
R = []
while Q:
    i = deque.popleft(Q)
    R.append(i)
    for a in X[i]:
        if a != P[i]:
            P[a] = i
            X[a].remove(i)
            deque.append(Q, a)

C = Counter(P)
##### Settings
unit = 0
merge = lambda a, b: a + b
adj_bu = lambda a, i: (a+1)/C[P[i]]
adj_td = lambda a, i, p: ((XX[p]*L[p]-XX[i]*C[p])/max(1,L[p]-1)+1)/max(1,C[i])
adj_fin = lambda a, i: a*max(1,C[i])/L[i]
#####

ME = [unit] * N
XX = [0] * N
TD = [unit] * N
for i in R[1:][::-1]:
    XX[i] = adj_bu(ME[i], i)
    p = P[i]
    ME[p] = merge(ME[p], XX[i])
XX[R[0]] = adj_fin(ME[R[0]], R[0])

for i in R:
    ac = TD[i]
    for j in X[i]:
        TD[j] = ac
        ac = merge(ac, XX[j])

    ac = unit
    for j in reversed(X[i]):
        TD[j] = adj_td(merge(TD[j], ac), j, i)
        ac = merge(ac, XX[j])
        XX[j] = adj_fin(merge(ME[j], TD[j]), j)

print(*XX, sep = "\n")
# Original solution
import sys,os,io
input = sys.stdin.readline
#input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
N = int(input())
edge = [[] for _ in range(N)]
for i in range(N-1):
  a,b = map(int, input().split())
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)

def dfs(start):
  stack = [start]
  parent = [N]*N
  parent[start] = -1
  while stack:
    v = stack[-1]
    marker = 0
    for u in edge[v]:
      if u==parent[v]:
        continue
      if parent[u]==N: #子へ降ろす
        marker = 1
        parent[u]=v
        stack.append(u)
      else: #子から吸い上げる
        pass
        #吸い上げる際の個々の処理
        ans[v] += ans[u]+1
    if marker==0:
      stack.pop()
      if v==start:
        #根へ吸い上げる時のまとめ処理
        ans[v] /= len(edge[v])
      elif ans[v]>0:
        ans[v] /= len(edge[v])-1
  return

def dfs2(start):
  stack = [start]
  parent = [N]*N
  parent[start] = -1
  p_value = [0]*N
  while stack:
    v = stack.pop()
    for i,u in enumerate(edge[v]):
      if u==parent[v]:
        continue
      parent[u] = v
      if len(edge[v])==1:
        p_value[u] = 0
      else:
        p_value[u] = (ans[v]*len(edge[v])-(ans[u]+1))/(len(edge[v])-1)
      ans[u] *= len(edge[u])-1
      ans[u] += p_value[u]+1
      ans[u] /= len(edge[u]) 
      stack.append(u)
  return

ans = [0]*N
dfs(0)
dfs2(0)
print(*ans, sep='\n')


# Optimized solution
import sys,os,io
# input = sys.stdin.readline
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
N = int(input())
edge = [[] for _ in range(N)]
for i in range(N-1):
  a,b = map(int, input().split())
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)

def dfs(start):
  stack = [start]
  parent = [N]*N
  parent[start] = -1
  while stack:
    v = stack[-1]
    marker = 0
    for u in edge[v]:
      if u==parent[v]:
        continue
      if parent[u]==N: #子へ降ろす
        marker = 1
        parent[u]=v
        stack.append(u)
      else: #子から吸い上げる
        pass
        #吸い上げる際の個々の処理
        ans[v] += ans[u]+1
    if marker==0:
      stack.pop()
      if v==start:
        #根へ吸い上げる時のまとめ処理
        ans[v] /= len(edge[v])
      elif ans[v]>0:
        ans[v] /= len(edge[v])-1
  return

def dfs2(start):
  stack = [start]
  parent = [N]*N
  parent[start] = -1
  p_value = [0]*N
  while stack:
    v = stack.pop()
    for i,u in enumerate(edge[v]):
      if u==parent[v]:
        continue
      parent[u] = v
      if len(edge[v])==1:
        p_value[u] = 0
      else:
        p_value[u] = (ans[v]*len(edge[v])-(ans[u]+1))/(len(edge[v])-1)
      ans[u] *= len(edge[u])-1
      ans[u] += p_value[u]+1
      ans[u] /= len(edge[u]) 
      stack.append(u)
  return

ans = [0]*N
dfs(0)
dfs2(0)
print(*ans, sep='\n')
# Original solution

import itertools

[n,k] = [int(x) for x in input().split()]
data = [int(x) for x in input().split()]

kumi = list(itertools.combinations(list(range(n)), k))
answer = sum(data)

for comb in kumi:
    total = 0
    for x in comb:
        total += data[x]
    if total < answer:
        answer = total

print(answer)



# Optimized solution
[n,k] = [int(x) for x in input().split()]
data = [int(x) for x in input().split()]
data.sort()

print((sum(data[:k])))
# Original solution
def main():
    N , K = list(map(int, input().split()))

    A_list = [A for A in input().split()]
    A_list = list(map(int, A_list))

    import itertools
    p = itertools.permutations(A_list, K)
    ans = 100000000000
    for val in p :
        ans_new = sum(val)
        if ans_new < ans :
            ans = ans_new
        #print(val)

    print(ans)

if __name__ == '__main__':
    main()


# Optimized solution
def main():
    N , K = list(map(int, input().split()))

    A_list = [A for A in input().split()]
    A_list = list(map(int, A_list))

    A_list.sort()
    #print(A_list)
    ans = 0
    for i in range(0,K) :
        ans = ans + A_list[i]

    print(ans)

if __name__ == '__main__':
    main()
# Original solution
import sys

N, K = list(map(int, sys.stdin.readline().strip().split()))
P = list(map(int, sys.stdin.readline().strip().split()))

ans = 0
for i, p in enumerate(sorted(P)):
    if i == K:
        break
    ans += p

print(ans)

# Optimized solution
import sys

N, K = list(map(int, sys.stdin.readline().split()))
P = list(map(int, sys.stdin.readline().split()))

P.sort()
print((sum(P[0:K])))
# Original solution
l=list(map(int,open(0).read().split()));print((sum(sorted(l[2:])[:l[1]])))

# Optimized solution
a,b,*l=list(map(int,open(0).read().split()));print((sum(sorted(l)[:b])))
# Original solution
import itertools
n,k = list(map(int,input().split()))
p = [int(i) for i in input().split()]
ans = []

combi = list(itertools.combinations(p,k))
for i in range(len(combi)) :
    ans.append(sum(combi[i]))
print((min(ans)))

# Optimized solution
n,k = list(map(int,input().split()))
p = [int(i) for i in input().split()]
p.sort()
s = 0
for i in range(k) :
    s += p[i]
print(s)
# Original solution
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
a.sort()
ans=0
for i in range(k):
  ans+=a[i]
print(ans)

# Optimized solution
n,k=list(map(int,input().split()))
p=list(map(int,input().split()))
p.sort()
ans=0
for i in range(k):
  ans+=p[i]
print(ans)
# Original solution
N,K = list(map(int,input().split()))
P = list(map(int,input().split()))

def bubblesort(l):
    for index in range(len(l)-1, 0, -1):
        for low in range(index):
            if l[low] > l[low+1]:
                tmp = l[low+1]
                l[low+1] = l[low]
                l[low] = tmp
    return l

bubblesort(P)
sum = 0
for i in range(K):
	sum = sum + P[i]
print(sum)

# Optimized solution
N,K = list(map(int,input().split()))
p = list(map(int,input().split()))

p.sort()
#print(p)

sum = 0
for i in range(K):
	sum = sum + p[i]
print(sum)