Harryxun/stf_run huggingface dataset:
from itertools import product
h,w,k=map(int,input().split())
idxs=[]
cols=[0]*w
clis=[]
al=0
k_score=0
def nir(x):
  if x=='#':return 1
  else:return 0
  
for _ in range(h):
  tmp=list(map(nir, list(input())))
  clis.append(tmp)
  idxs.append(sum(tmp))
  al+=sum(tmp)
  for q in range(w):
    cols[q]+=tmp[q]
uu=product((0,1),repeat=h+w)
for bits in uu:
  idd=[]
  coll=[]
  for i in range(h):
    if bits[i]==1:idd.append(i)
  
  for i in range(w):
    if bits[i+h]==1:coll.append(i)
  
  s=al
  if not coll:
    for x in idd:s-=idxs[x]
  elif not idd:
    for y in coll:s-=cols[y]
  else:
    for x in idd:s-=idxs[x]
    for y in coll:s-=cols[y]
    for x in idd:
      for y in coll:
        s+=clis[x][y]
        
  if s==k:k_score+=1
    
print(k_score)

### FIXED CODE ###

n=int(input())
s=n%1000
if s==0:s=1000
print(1000-s)
from sys import exit
n=int(input())
s=input()
w=[]
w.append(s)
for i in range(n-1):
  s=input()
  if w[i][-1]!=a[0] or s in w:
    print('No')
    exit()
  else:
    w.append(s)
print('Yes')
  

### FIXED CODE ###

from sys import exit
n=int(input())
s=input()
w=[]
w.append(s)
for i in range(n-1):
  s=input()
  if w[i][-1]!=s[0] or s in w:
    print('No')
    exit()
  else:
    w.append(s)
print('Yes')
import collections
n = int(input())
vlist = list(map(int,input().split()))
list_odd = [vlist[i] for i in  range(n) if i % 2 ==0]
list_even = [vlist[i] for i in range(n) if i % 2 !=0]

def f(list1):
  ary1 = [0] * 10**5
  ary1 = [[0,i] for i in range(10**5+1)]
  len1 = len(list1)
  for i in range(len1):
    ary1[list1[i]+1][0] += 1
  ary2 = sorted(ary1)
  return [ary2[-1],ary2[-2]]

list3 = f(list_odd)
list4 = f(list_even)

if list3[0][1] != list4[0][1]:
  print(n-list3[0][0]-list4[0][0])
else:
  if list3[0][0] >= list4[0][0]:
    print(n-list3[0][0]-list4[1][0])
  else:
    print(n-list3[1][0]-list4[0][0])

### FIXED CODE ###

import collections
n = int(input())
vlist = list(map(int,input().split()))
list_odd = [vlist[i] for i in  range(n) if i % 2 ==0]
list_even = [vlist[i] for i in range(n) if i % 2 !=0]

def f(list1):
  ary1 = [[0,i] for i in range(10**5+2)]
  len1 = len(list1)
  for i in range(len1):
    ary1[list1[i]+1][0] += 1
  ary2 = sorted(ary1)
  return [ary2[-1],ary2[-2]]

list3 = f(list_odd)
list4 = f(list_even)


if list3[0][1] != list4[0][1]:
  print(n-list3[0][0]-list4[0][0])
else:
  x1 = n-list3[0][0]-list4[1][0]
  x2 = n-list3[1][0]-list4[0][0]
  print(min(x1,x2))
import sys
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit(1)
p = [int(x) for x in input().split()]
k = 0
while x in p:
    if not x - k in p:
        print(x - k)
        exit(1)
    elif not x + k in p:
        print(x + k)
        exit(1)
    else:
        k += 1
        continue
print(x)


### FIXED CODE ###

x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    p = [int(x) for x in input().split()]
    for i in range(n + 1):
        if not x - i in p:
            print(x - i)
            break
        elif not x + i in p:
            print(x + i)
            break
        else:
            continue
import sys

lines = sys.stdin.readlines()

H, M = list(map(int, lines[0].split()))
AB = []

max_at = 0
min_mg = sys.maxsize
at_min_mg = 0
for i in range(M):
  t = tuple(map(int, lines[i+1].split()))
  AB.append(t)
  if t[0]>=max_at:
    max_at = t[0]
  if t[1]<=min_mg:
    min_mg = t[1]
    at_min_mg = t[0]

ABlen = len(AB)

DP = [0]
for i in range(1, at_min_mg+1):
  DP.append(min_mg)
  
for i in range(at_min_mg+1,H+max_at):
  mm = 99999999
  for j in range(ABlen):
    if i-AB[j][0]<0:
      continue
    if mm > DP[i-AB[j][0]]+AB[j][1]:
      mm = DP[i-AB[j][0]]+AB[j][1]
  DP.append(mm)
print(min(DP[H:H+max_at-1]))

### FIXED CODE ###

import sys

lines = sys.stdin.readlines()

H, M = list(map(int, lines[0].split()))
AB = []

max_at = 0
min_mg = sys.maxsize
at_min_mg = 0
for i in range(M):
  t = tuple(map(int, lines[i+1].split()))
  AB.append(t)
  if t[0]>=max_at:
    max_at = t[0]
  if t[1]<=min_mg:
    min_mg = t[1]
    at_min_mg = t[0]

ABlen = len(AB)

DP = [0]
for i in range(1, at_min_mg+1):
  DP.append(min_mg)
  
for i in range(at_min_mg+1,H+max_at+1):
  mm = sys.maxsize
  for j in range(ABlen):
    if i-AB[j][0]<0:
      continue
    if mm > DP[i-AB[j][0]]+AB[j][1]:
      mm = DP[i-AB[j][0]]+AB[j][1]
  DP.append(mm)
print(min(DP[H:H+max_at]))
n, k = map(int, input().split())

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

x = gcd(max(k, n), min(k, n))
if n % k == 0:
    print(0)
elif n < k:
    exit(1)
    print(min(n, abs(n - k)))
else:
    print(1)


### FIXED CODE ###

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

print(min(n % k, k - (n % k)))
import sys,collections,math,random,fractions,bisect;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t if len(t) > 1 else t[0]
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]

H,N = I()
A = I()
if sum(A) >= H:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

import sys,collections,math,random,fractions,bisect;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]
 
H,N = I()
A = I()
if sum(A) >= H:
    print("Yes")
else:
    print("No")
a,b,k = map(int,input().split())
if a + b <= k:
    print(0,0)
elif a <= k:
    print(0, a+b-k)
else 
    print(a-k,b)

### FIXED CODE ###

a,b,k = map(int,input().split())
if a + b <= k:
    print(0,0)
elif a <= k:
    print(0, a+b-k)
else:
    print(a-k,b)
#!/usr/bin/env python3
import numpy as np
N, A, B = map(int, input().split())
X = np.array(list(map(int, input().split())))
diff = np.diff(X)
ans = 0
for d in diff:
    if d * A <= B:
        ans += d * A
    else:
        ans += B
print(ans)

### FIXED CODE ###

#!/usr/bin/env python3
import numpy as np
N, A, B = map(int, input().split())
X = np.array(list(map(int, input().split())))
diff = np.diff(X)
ans = 0
for d in diff:
    if d * A <= B:
        ans += d * A
    else:
        ans += B
print(ans)
a=input().split(" ")
part=0

for i in range(a[0]):
	if i==0:
		part=a[1]
	else:
		part=part*(a[1]-1)

print(part)
				

### FIXED CODE ###

a=input().split(" ")
part=0
 
for i in range(int(a[0])):
	if i==0:
		part=int(a[1])
	else:
		part=part*(int(a[1])-1)
 
print(part)
import itertools
import numpy as np

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

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

	allCandidates = []
	for i in range(int(K / 2) + 1):
		for one in range(0, K - i + 1):
			allCandidates.extend([[0] * one + [1] * (K - i - one) + [-1] * i])

	maxScore = 0
	for candidate in allCandidates:
		have = []
		zeroCount = 0
		oneCount = 0
		for k in candidate:
			if k == 0:
				have.append(Vs[0 + zeroCount])
				zeroCount += 1
			if k == 1:
				have.append(Vs[-1 - oneCount])
				oneCount += 1
			if k == -1:
				del have[np.argmin(have)]
		score = sum(have)

		if score > maxScore:
			maxScore = score
	print(maxScore)



if __name__ == '__main__':
	main()


### FIXED CODE ###

import itertools
import numpy as np
import copy

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

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

	allCandidates = []
	for i in range(K + 1):
		for one in range(0, K - i + 1):
			allCandidates.extend([[0] * one + [1] * (K - i - one) + [-1] * i])

	maxScore = 0
	for candidate in allCandidates:
		have = []
		vs = copy.deepcopy(Vs)
		exceptFlag = False
		for k in candidate:
			if k == 0:
				try:
					have.append(vs[0])
					del vs[0]
				except:
					exceptFlag = True
					break
			if k == 1:
				try:
					have.append(vs[-1])
					del vs[-1]
				except:
					exceptFlag = True
					break
			if k == -1:
				try:
					if have[np.argmin(have)] < 0:
						del have[np.argmin(have)]
				except:
					exceptFlag = True
					break
		if not exceptFlag:
			score = sum(have)
			if score > maxScore:
				maxScore = score

	print(maxScore)

if __name__ == '__main__':
	main()
s = input()
count = 0
first_half, second_half = s[:len(s)//2], s[(len(s)+1)//2:]
if first_half == reversed(second_half):
    print(count)
else:
    for x in range(len(first_half)):
        if first_half[x] != second_half[len(second_half)-x-1]:
            count += 1
    print(count)


### FIXED CODE ###

s = input()
count = 0
first_half, second_half = s[:len(s)//2], s[(len(s)+1)//2:]
if first_half == reversed(second_half):
    print(count)
else:
    for x in range(len(first_half)):
        if first_half[x] != second_half[len(second_half)-x-1]:
            count += 1
    print(count)
#%%
n = int(input())
flag = True
for i in range(n):
    a[i] = int(input())
    if a[i] % 2 == 1:
        flag = False

if flag:
    print('first')
else:
    print('second')

### FIXED CODE ###

#%%
n = int(input())
a = [0] * n
flag = True
for i in range(n):
    a[i] = int(input())
    if a[i] % 2 == 1:
        flag = False

if not flag:
    print('first')
else:
    print('second')
a, b = map(int, input.split())
if a // 2 == 1 and b // 2 == 1:
  print("Odd")
else:
  print("Even")

### FIXED CODE ###

a, b = map(int, input().split())
if (a % 2 == 1) and (b % 2 == 1):
  print("Odd")
else:
  print("Even")
from collections import deque

H, W = map(int, input().split())
S = [input() for _ in range(H)]

def solve(s):
    bias = [(1, 0), (-1, 0), (0, 1), (0, -1)]

    visited = [[-1] * W for _ in range(H)]
    visited[0][0] = 0
    
    if visited[s[1]][s[0]] == "#":
        return visited

    q = deque()
    q.append(s)  # x, y, c

    while q:
        x, y, c = q.popleft()
        visited[y][x] = c

        for u, v in bias:
            if not (0 <= x + u < W) or not (0 <= y + v < H):
                continue

            if visited[y + v][x + u] > -1 or S[y + v][x + u] == "#":
                continue

            q.append((x + u, y + v, c + 1))
            
    return visited

ans_1 = (0, 0, 0)
for y, v in enumerate(solve((0, 1, 1))):
    for x, c in enumerate(v):
        if c >= ans_1[2]:
            ans_1 = (x, y, c)
        
ans_2 = (0, 0, 0)
for y, v in enumerate(solve((1, 0, 1))):
    for x, c in enumerate(v):
        if c >= ans_2[2]:
            ans_2 = (x, y, c)
        
if ans_1[0] == ans_2[0] and ans_1[1] == ans_2[1]:
    print(min(ans_1[2], ans_2[2]))
else:
    print(ans_1[2] + ans_2[2])


### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
S = [input() for _ in range(H)]

def solve(x, y):
    offset = [(1, 0), (-1, 0), (0, 1), (0, -1)]
    visited = [[-1] * W for _ in range(H)]
    visited[y][x] = 0
    
    q = deque()
    q.append((x, y))

    while q:
        x, y = q.popleft()

        for u, v in offset:
            if not (0 <= x + u < W) or not (0 <= y + v < H):
                continue

            if visited[y + v][x + u] > -1 or S[y + v][x + u] == "#":
                continue

            visited[y + v][x + u] = visited[y][x] + 1
            q.append((x + u, y + v))
            
    return visited

ans = 0
for y, ss in enumerate(S):
    for x, s in enumerate(ss):
        if s == ".":
            ans = max(ans, max(max(v) for v in solve(x, y)))

print(ans)
N, X = [int(line) for line in input().split()]
L = [int(line) for line in input().split()]

D = [0]#D1 = 0
for i in range(1,N+1):#座標Dの配列を作る
    Di = D[i-1] + L[i-1]
    D.append(Di)

for i in range(len(D)):#
    if D[i] == X:
        index = i
        break
    elif D[i] > X:
        index = i - 1
        break
ans = index + 1
print(ans)

### FIXED CODE ###

N, X = [int(line) for line in input().split()]
L = [int(line) for line in input().split()]

D = [0]#D1 = 0
for i in range(1,N+1):#座標Dの配列を作る
    Di = D[i-1] + L[i-1]
    D.append(Di)

ans = 0
for i in range(len(D)):#
    if D[i] <= X:
      ans += 1
print(ans)
t=input()
n=len(t)
s=""
for i in range(n):
  if p[i]=="P":
    s+="P"
  else:
    s+="D"
print(s)

### FIXED CODE ###

t=input()
n=len(t)
s=""
for i in range(n):
  if t[i]=="P":
    s+="P"
  else:
    s+="D"
print(s)
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)

Alice = Sum(a[::2])
Bob = Sum(a[1::2])

print(Alice - Bob)


### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)

Alice = sum(a[::2])
Bob = sum(a[1::2])

print(Alice - Bob)
N = int(input())
A = list(map(int, input().split()))

import collections
dic=dict(collections.Counter(A))
li=list(dic.values())

ho=list(dic.keys())
x=ho[0]
y=ho[1]
z=ho[2]

ans='No'

if len(li)==3:
    if N%3 == 0:
        if li[0]== N//3 and li[1]==N//3 and x^y^z == 0:
            ans='Yes'           
elif len(li)==2:
    if N%3 == 0:
        if li[0]== 2*N//3 or li[1]==2*N//3:
            ans='Yes'
elif len(li)==1:
        if list(dic.keys())[0]==0:
            ans='Yes'

print(ans)

### FIXED CODE ###

#!/usr/bin/env python3
import sys
from collections import Counter

def main():
    N = int(input())
    a = list(map(int, input().split()))
    l = Counter(a)
    if len(l)==1 and 0 in l:
        print('Yes')
        exit()
    if N%3==0 and len(l)==2 and 0 in l and l[0] == N//3:
        print('Yes')
        exit()
    if N%3==0 and len(l)==3:
        x,y,z = l.keys()
        if l[x] == l[y] == N//3 and x^y^z == 0:
            print('Yes')
            exit()
    print('No')

    

if __name__ == '__main__':
    main()
an = []
for i in range(5):
    an.append(int(input()))
k=int(input())+1
if(an[]-an[]<k and an[]-an[]<k and an[]-an[]<k and an[]-an[]<k):
    print("Yay!")
else:
    print(":(")

### FIXED CODE ###

an = []
for i in range(5):
    an.append(int(input()))
k=int(input())+1
if(an[4]-an[0]<k):
    print("Yay!")
else:
    print(":(")
def not_found_minchar(S):
    sorted_S = sorted(list(set(S)))
    idx = 0
    for o in range(ord('a'), ord('z') + 1):
        if o < ord(sorted_S[idx]):
            return chr(o)
        idx += 1
    return "None"

S = raw_input()
print not_found_minchar(S)


### FIXED CODE ###

def not_found_minchar(S):
    for o in range(ord('a'), ord('z') + 1):
        if chr(o) not in S:
            return chr(o)
    return "None"

S = raw_input()
print not_found_minchar(S)
S = input()
T = input()

S1 = sorted(S)
T1 = sorted(T)

count1 = 0
count2 = 0

for j in range(26):
    for i in range(len(S1)):
        if string.ascii_lowercase[j] == S1[i]:
            count1 += 1
            break
    for i in range(len(T1)):
        if string.ascii_lowercase[j] == T1[i]:
            count2 += 1
            break

if count1 == count2:
    print("Yes")
else:
    print("N0")

### FIXED CODE ###

import string

S = input()
T = input()

count1 = [0] * 26
count2 = [0] * 26


for j in range(26):
    count1[j] = S.count(string.ascii_lowercase[j])
    count2[j] = T.count(string.ascii_lowercase[j])

hantei = 1

for i in range(0,len(S)+1):
    count_tmp1 = 0
    count_tmp2 = 0
    for j in range(26):
        if i == count1[j] :
            count_tmp1 += 1
    for j in range(26):
        if i == count2[j] :
            count_tmp2 += 1
    if count_tmp1 != count_tmp2:
        hantei = 0
        break

if hantei == 0:
    print("No")
else:
    print("Yes")
S = input()
X, Y = map(int, input().split())

if S.find("F") < 0:
    if X != 0 or Y != 0:
        print("No")
    else:
        print("Yes")
    exit()

n = len(S)
d = list(map(len, S.split("T")))
xs = d[::2]
ys = d[1::2]

dpx = [set() for _ in range(len(xs))]
dpx[0].add(0)
for i in range(len(xs)):
    for j in dpx[i]:
        dpx[i + 1].add(j + xs[i])
        dpx[i + 1].add(j - xs[i])

dpy = [set() for _ in range(len(ys) + 1)]
dpy[0].add(0)
for i in range(len(ys)):
    for j in dpy[i]:
        dpy[i + 1].add(j + ys[i])
        dpy[i + 1].add(j - ys[i])

ans = (X in dpx[-1]) & (Y in dpy[-1])
print("Yes" if ans else "No")


### FIXED CODE ###

S = input()
X, Y = map(int, input().split())

if S.find("F") < 0:
    if X != 0 or Y != 0:
        print("No")
    else:
        print("Yes")
    exit()

n = len(S)
d = list(map(len, S.split("T")))
xs = d[::2]
ys = d[1::2]

dpx = [set() for _ in range(len(xs))]
for i in range(len(xs)):
    if i == 0:
        d = (-1) ** S.find("F")
        dpx[i].add(d * xs[i] + n)
        continue
    
    for j in dpx[i - 1]:
        dpx[i].add(j + xs[i])
        dpx[i].add(j - xs[i])

dpy = [set() for _ in range(len(ys) + 1)]
dpy[0].add(n)
for i in range(len(ys)):
    for j in dpy[i]:
        dpy[i + 1].add(j + ys[i])
        dpy[i + 1].add(j - ys[i])

ans = (X + n in dpx[-1]) & (Y + n in dpy[-1])
print("Yes" if ans else "No")
import numpy as np
import sys
sys.setrecursionlimit(20000)

def decide_col(colors, edges, node, org, excl_color,max_col):
    if len(edges[node]) > 1:
        i = 1
        for elem in edges[node]:
            next_node = elem[0]
            ind = elem[1]
            if next_node != org:
                while i == excl_color:
                    i = i%max_col + 1
                colors[ind] = i
                decide_col(colors, edges, next_node, node, i,max_col)
                i += 1
    

def det_color(N,edges,start,max_col):
    colors = [0]*(N-1)
    i=1
    for elem in edges[start]:
        node = elem[0]
        ind = elem[1]
        colors[ind] = i
        decide_col(colors, edges, node, start, i, max_col)
        i += 1
    return colors
        

N = int(input())
edges = {}
edge_list = []

for i in range(N):
    edges[i] = []
count = [0]*N

for i in range(N-1):
    A, B = map(int,input().split())
    edge_list.append([A-1,B-1])
    edges[A-1].append([B-1,i])
    edges[B-1].append([A-1,i])
    count[A-1] += 1
    count[B-1] += 1

max_col = max(count)
print(max_col)
start_ind = np.argmax(count)
if type(start_ind)==list:
    start = start_ind[0]
else:
    start = start_ind
colors = det_color(N,edges,start,max_col)

for i in range(N-1):
    print(colors[i])

### FIXED CODE ###

import numpy as np
import sys
sys.setrecursionlimit(200000)

def decide_col(colors, edges, node, org, excl_color,max_col):
    if len(edges[node]) > 1:
        i = 1
        for elem in edges[node]:
            next_node = elem[0]
            ind = elem[1]
            if next_node != org:
                while i == excl_color:
                    i = i%max_col + 1
                colors[ind] = i
                decide_col(colors, edges, next_node, node, i,max_col)
                i += 1
    

def det_color(N,edges,start,max_col):
    colors = [0]*(N-1)
    i=1
    for elem in edges[start]:
        node = elem[0]
        ind = elem[1]
        colors[ind] = i
        decide_col(colors, edges, node, start, i, max_col)
        i += 1
    return colors
        

N = int(input())
edges = {}
edge_list = []

for i in range(N):
    edges[i] = []
count = [0]*N

for i in range(N-1):
    A, B = map(int,input().split())
    edge_list.append([A-1,B-1])
    edges[A-1].append([B-1,i])
    edges[B-1].append([A-1,i])
    count[A-1] += 1
    count[B-1] += 1

max_col = max(count)
print(max_col)
start_ind = np.argmax(count)
if type(start_ind)==list:
    start = start_ind[0]
else:
    start = start_ind
colors = det_color(N,edges,start,max_col)

for i in range(N-1):
    print(colors[i])
s = input()

cnt = s.count('o')

print(s + 100 * cnt)

### FIXED CODE ###

s = input()

cnt = s.count('o')

print(700 + 100 * cnt)
n, k = map(int, input().split())
s = str(input())

if s[k-1] == 'A':
    print(s[:k-1]　+ 'a' + s[k:])

elif s[k-1] == 'B':
    print(s[:k-1] + 'b' + s[k:])

else:
    print(s[:k-1] + 'c' + s[k:])

### FIXED CODE ###

n, k = map(int, input().split())
s = str(input())

if s[k-1] == 'A':
    print(s[:k-1] + 'a' + s[k:])

elif s[k-1] == 'B':
    print(s[:k-1] + 'b' + s[k:])

else:
    print(s[:k-1] + 'c' + s[k:])
a,b=map(int,input().split())
d=a//b
r=a%b
f=float(a/b)
print(f"{d r f: f5}")

### FIXED CODE ###

a,b=map(int,input().split())
d=a//b
r=a%b
f=float(a/b)
print('{0} {1} {2:0.5f}'.format(d, r, f))
m = input()
print(48 - m)

### FIXED CODE ###

m = int(input())
print(48 - m)
MAX = 100
INF = 1000000
WHITE = 0
GRAY = 1
BLACK = 2
n = int(raw_input())

def prim():
    for i in range(n):
        d[i] = INF
        p[i] = -1
        Color[i] = WHITE
    d[0] = 0
    
    while True:
        minv = INF
        u = -1
        for i in range(n):
            if minv > d[i] and Color[i] != BLACK:
                u = i
                minv = d[i]
        if u == -1:
            break
        Color[u] = BLACK
        for v in range(n):
            if Color[v] != BLACK and M[u][v] != INF:
                if d[v] > M[u][v]:
                    d[v] = M[u][v]
                    p[v] = u
                    Color[v] = GRAY
    sum = 0
    for i in range(n):
        if p[i] != -1:
            sum += M[i][p[i]]
    return sum
    
for i in range(n):
    a = map(int, raw_input().split())
    for j in range(n):
        e = a[j]
        if e == -1:
            M[i][j] = INF
        else:
            M[i][j] = e
            
print prim()

### FIXED CODE ###

MAX = 100
INF = 1000000
WHITE = 0
GRAY = 1
BLACK = 2
n = int(raw_input())

M = [[0 for i in range(n)]for j in range(n)]
d = [0 for i in range(MAX)]
p = [0 for i in range(MAX)]
Color = [0 for i in range(MAX)]
for i in range(n):
    a = map(int, raw_input().split())
    for j in range(n):
        e = a[j]
        if e == -1:
            M[i][j] = INF
        else:
            M[i][j] = e

#def prim():
for i in range(n):
    d[i] = INF
    p[i] = -1
    Color[i] = WHITE
d[0] = 0
    
while True:
    minv = INF
    u = -1
    for i in range(n):
        if minv > d[i] and Color[i] != BLACK:
            u = i
            minv = d[i]
    if u == -1:
        break
    Color[u] = BLACK
    for v in range(n):
        if Color[v] != BLACK and M[u][v] != INF:
            if d[v] > M[u][v]:
                d[v] = M[u][v]
                p[v] = u
                Color[v] = GRAY
sum = 0
for i in range(n):
    if p[i] != -1:
        sum += M[i][p[i]]
print sum
from decimal import *
import math
h=input().split()
a,b,c=int(h[0]),int(h[1]),int(h[2])
e=Decimal(math.sqrt(a))
f=Decimal(math.sqrt(b))
g=Decimal(math.sqrt(c))
if(e+f==g):
  print('No')
elif(e+f>g):
  print('No')
else:
  print('Yes')

### FIXED CODE ###

a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
b=int(input())
print(a[b-1])
a,b,c = map(int, raw_input().split())
aa[0] = a
aa[1] = b
aa[2] = c

sorted(aa)

print aa[0],aa[1],aa[2]

### FIXED CODE ###

a,b,c = sorted(map(int, raw_input().split()))
print a,b,c
n, k = map(int, input().split())

import sys

sys.setrecursionlimit(20000)

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

def first_search(first, depth):
    record = 0
    for i in l[first]:
        temp = search(first, i, depth-1)
        if record < temp:
            record = temp
    return record + 1

def search(before, now, depth):
    if depth <= 0:
        return 1
    else:
        ans = 1
        for i in l[now]:
            if before != i:
                ans += search(now, i, depth-1)
        return ans

ret = 0    
for i in range(n):
    temp = first_search(i, k)
    if temp > ret:
        ret = temp
        
if ret > n:
    print(0)
else:
    print(n-ret)

### FIXED CODE ###

n = int(input())

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

ans = 0

l = sorted(l)

for i in range(n):
    ans += l[2*i]
    
print(ans)