Harryxun/stf_run huggingface dataset:
import numpy as np

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

memo = np.zeros((n,2))
memo[0][1] = 1

for i in range(n):
    memo[i][0] = 1

tmp1 = 0
tmp2 = 0

for j in range(m):
    tmp1 = l[j][0]-1
    tmp2 = l[j][1]-1
    memo[tmp1][0] -= 1
    memo[tmp2][0] += 1
    
    if memo[tmp2][1] == 0 and memo[tmp1][1] == 1:
        memo[tmp2][1] = 1
    
    if memo[tmp1][1] == 1 and memo[tmp1][0] == 0:
        memo[tmp1][1] = 0

ans = 0
for k in range(n):
    ans += memo[k][1]

print(int(ans))


### FIXED CODE ###

import numpy as np

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

memo = np.zeros((n,2))
memo[0][1] = 1

for i in range(n):
    memo[i][0] = 1

tmp1 = 0
tmp2 = 0

for j in range(m):
    tmp1 = l[j][0]-1
    tmp2 = l[j][1]-1
    memo[tmp1][0] -= 1
    memo[tmp2][0] += 1
    
    if memo[tmp2][1] == 0 and memo[tmp1][1] == 1:
        memo[tmp2][1] = 1
    
    if memo[tmp1][1] == 1 and memo[tmp1][0] == 0:
        memo[tmp1][1] = 0

ans = 0
for k in range(n):
    ans += memo[k][1]

print(int(ans))
k,n=map(input(),int.split())
a=list(input(),int.split())

m=0
for i in range(n-1):
    d=a[i+1]-a[i]
    m=max(d,m)
d_last=a[0]+k-a[n-1]
m=max(d_last,m)

ans=k-m
print(ans)

### FIXED CODE ###

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

m=0
for i in range(n-1):
    d=a[i+1]-a[i]
    m=max(d,m)
d_last=a[0]+k-a[n-1]
m=max(d_last,m)

ans=k-m
print(ans)
def pow2(n, mod):
    p = 2
    r = 1
    while n:
        if n % 2:
            r = r * p % mod
        p = (p * p) % mod
        n //= 2
    return r

g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

def nCr(n, r, mod):
    t = 1
    for i in range(n - r + 1, n + 1):
        t = t * i % mod
    return t * g2[r] % mod



def prep(n, mod):
    for i in range(2, n):
        g1.append((g1[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod // i)) % mod)
        g2.append((g2[-1] * inverse[-1]) % mod)

def main():
    n, a, b = list(map(int, input().split()))
    mod = 10 ** 9 + 7
    prep(2 * (10 ** 5), mod)
    print((pow2(n, mod) - 1 - nCr(n, a, mod) - nCr(n, b, mod))% mod)


main()


### FIXED CODE ###

def pow2(n, mod):
    p = 2
    r = 1
    while n:
        if n % 2:
            r = r * p % mod
        p = (p * p) % mod
        n //= 2
    return r

g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

def nCr(n, r, mod):
    t = 1
    r = min(r, n - r)
    for i in range(n - r + 1, n + 1):
        t = t * i % mod
    return t * g2[r] % mod



def prep(n, mod):
    for i in range(2, n):
        g1.append((g1[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod // i)) % mod)
        g2.append((g2[-1] * inverse[-1]) % mod)

def main():
    n, a, b = list(map(int, input().split()))
    mod = 10 ** 9 + 7
    prep(2 * (10 ** 5) + 1, mod)
    print((pow2(n, mod) - 1 - nCr(n, a, mod) - nCr(n, b, mod))% mod)


main()
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
MOD = 998244353

n, s = map(int, input().split())
a = [int(item) for item in input().split()]

dp = [[0] * (s+1) for _ in range(n)]
dp[0][0] = 1
if a[0] <= s:
    dp[0][a[0]] = 1
ans = 0
for i, item in enumerate(a[1:]):
    for j in range(s+1):
        # Not use item
        dp[i+1][j] += dp[i][j]
        dp[i+1][j] %= MOD
        # Do use item
        if j + item <= s:
            dp[i+1][j + item] += dp[i][j]
            dp[i+1][j + item] %= MOD
    # Start from i
    dp[i+1][item] += 1
    dp[i+1][0] += 1
    ans += dp[i+1][s]

print(ans)

### FIXED CODE ###

#!/usr/bin/env python3
import sys
input = sys.stdin.readline
MOD = 998244353

n, s = map(int, input().split())
a = [int(item) for item in input().split()]

dp = [[0] * (s+1) for _ in range(n)]
dp[0][0] = 1
if a[0] <= s:
    dp[0][a[0]] = 1
ans = 0
for i, item in enumerate(a[1:]):
    for j in range(s+1):
        # Not use item
        dp[i+1][j] += dp[i][j]
        dp[i+1][j] %= MOD
        # Do use item
        if j + item <= s:
            dp[i+1][j + item] += dp[i][j]
            dp[i+1][j + item] %= MOD
    # Start from i
    if item <= s:
        dp[i+1][item] += 1
    dp[i+1][0] += 1
    ans += dp[i+1][s]
    ans %= MOD

print(ans)
# ABC149C - Next Prime
def is_prime_miller_rabin(n: int) -> bool:
    """Miller–Rabin primality test in O(k log^3 n).
    https://twitter.com/kiri8128/status/1241033090773860353
    https://www.wikiwand.com/en/Miller%E2%80%93Rabin_primality_test
    """
    # cut out small primes and 87% of composite numbers.
    if n < 2:
        return False
    elif n in {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67}:
        return True
    elif (
        n % 2 == 0
        or n % 3 == 0
        or n % 5 == 0
        or n % 7 == 0
        or n % 11 == 0
        or n % 13 == 0
        or n % 17 == 0
        or n % 19 == 0
        or n % 23 == 0
        or n % 29 == 0
        or n % 31 == 0
        or n % 37 == 0
        or n % 41 == 0
        or n % 43 == 0
        or n % 47 == 0
        or n % 53 == 0
        or n % 59 == 0
        or n % 61 == 0
        or n % 67 == 0
    ):
        return False

    # find the most suitable witnesses for n
    if n < 2_047:
        witnesses = [2]
    elif n < 1_373_653:
        witnesses = [2, 3]
    elif n < 9_080_191:
        witnesses = [31, 73]
    elif n < 25_326_001:
        witnesses = [2, 3, 5]
    elif n < 3_215_031_751:
        witnesses = [2, 3, 5, 7]
    elif n < 4_759_123_141:
        witnesses = [2, 7, 61]
    elif n < 1_122_004_669_633:
        witnesses = [2, 13, 23, 1662803]
    elif n < 2_152_302_898_747:
        witnesses = [2, 3, 5, 7, 11]
    elif n < 3_474_749_660_383:
        witnesses = [2, 3, 5, 7, 11, 13]
    elif n < 341_550_071_728_321:
        witnesses = [2, 3, 5, 7, 11, 13, 17]
    elif n < 3_825_123_056_546_413_051:
        witnesses = [2, 3, 5, 7, 11, 13, 17, 19, 23]
    elif n < 318_665_857_834_031_151_167_461:
        witnesses = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]
    else:  # precisely, n < 3_317_044_064_679_887_385_961_981 (3.3 * 10^24)
        witnesses = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41]

    d = n - 1
    d = d // (d & -d)

    for a in witnesses:
        y = pow(a, d, n)
        if y == 1:
            continue
        t = d
        while y != n - 1:
            y = (y * y) % n
            if y == 1 or t == n - 1:
                return False
            t <<= 1
    return True


def main():
    N = int(input())
    if N != 2 and N % 2 == 0:
        N += 1
    while not is_prime_miller_rabin(N):
        N += 2
    print(N)


if __name__ == "__main__":
    main()


### FIXED CODE ###

# ABC149C - Next Prime
def is_prime(n: int) -> bool:
    """
    Evaluate whether a number is prime or not.

    Args:
        n: a number to evaluate

    Returns: whether n is prime or not
    """
    if n == 2:
        return True
    if n == 1 or n % 2 == 0:
        return False
    for i in range(3, int(n ** 0.5) + 1, 2):
        if n % i == 0:
            return False
    return True


def main():
    N = int(input())
    if N != 2 and N % 2 == 0:
        N += 1
    while not is_prime(N):
        N += 2
    print(N)


if __name__ == "__main__":
    main()
input();
al=[int(i) for i in input().split()]
al.sort()[::-1]
print(sum(al[::2])-sum(al[1::2]))

### FIXED CODE ###

input();
al=[int(i) for i in input().split()]
al.sort()
al = al[::-1]
print(sum(al[::2])-sum(al[1::2]))
x = input().split(' ')
x = list(map(int, x)).sort()

print(x[0], x[1], x[2])

### FIXED CODE ###

(a, b, c) = input().split(' ')
a = int(a)
b = int(b)
c = int(c)
 
if a < b < c:
    print(a, b, c)
elif a < c < b:
    print(a, c, b)
elif b <= a <= c:
    print(b, a, c)
elif b <= c <= a:
    print(b, c, a)
elif c <= a <= b:
    print(c, a, b)
else:
    print(c, b, a)
N, M = map(int, input().split())
class uft:
  def __init__(self, N):
    self.__N = N
    self.__arr = [-1] * (N + 1)
  def fp(self, x):
    if self.__arr[x] < 0:
      return x
    else:
      self.__arr[x] = self.fp(self.__arr[x])
      return self.__arr[x]
  def add(self, x, y):
    if x > y:
      x, y = y, x
    px = self.fp(x)
    py = self.fp(y)
    self.__arr[px] += self.__arr[py]
    self.__arr[py] = px
  def groups(self):
    ret = -1
    for i in self.__arr:
      if i < 0:
        ret += 1
    return ret
UFT = uft(N)

for i in range(M):
  A, B = map(int, input().split())
  UFT.add(A,B)
print(UFT.groups() -1)

### FIXED CODE ###

import sys
sys.setrecursionlimit(int(1e9))

class uft:
  def __init__(self, N):
    self.__N = N
    self.__arr = [-1] * (N + 1)
  def fp(self, x):
    if self.__arr[x] < 0:
      return x
    else:
      self.__arr[x] = self.fp(self.__arr[x])
      return self.__arr[x]
  def add(self, x, y):
    px = self.fp(x)
    py = self.fp(y)
    if px > py:
      px, py = py, px
    if px == py:
      return 1
    self.__arr[px] += self.__arr[py]
    self.__arr[py] = px
  def groups(self):
    ret = -1
    for i in self.__arr:
      if i < 0:
        ret += 1
    return ret
  def show_arr(self):
    print(self.__arr)
  
N, M = map(int, input().split()) 
UFT = uft(N)

for i in range(M):
  A, B = map(int, input().split())
  UFT.add(A,B)
print(UFT.groups() -1)
n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))
ttl=[]
cnt=[]
count=0
for i in range(n):
  nxt=i+1
  grp=[]
  count=0
  pnt=[]
  pnt.append(0)
  for j in range(n):
    nxt=p[nxt-1]
    grp.append(nxt)
    pnt.append(pnt[j]+c[nxt-1])
    count+=1
    if nxt==i+1:
      del pnt[0]
      ttl.append(pnt)
      cnt.append(len(grp))
      break
ans=[]
for i in range(n):
  peak=ttl[i].index(max(ttl[i]))
  if k<=cnt[i]:
    ans.append(max(ttl[i][:k]))
  else:
    if ttl[i][-1]<0:
      ans.append(max(ttl[i][:k]))
    else:
      ans.append(max((k//cnt[i])*ttl[i][-1]+max(ttl[i][0:k%cnt[i]]),((k-peak)//cnt[i])*ttl[i][-1]+ttl[i][peak]))
print(max(ans))

### FIXED CODE ###

n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))
ttl=[]
cnt=[]
count=0
for i in range(n):
  nxt=i+1
  grp=[]
  count=0
  pnt=[]
  pnt.append(0)
  for j in range(n):
    nxt=p[nxt-1]
    pnt.append(pnt[j]+c[nxt-1])
    count+=1
    if nxt==i+1:
      del pnt[0]
      ttl.append(pnt)
      cnt.append(count)
      break
ans=[]
for i in range(n):
  peak=ttl[i].index(max(ttl[i]))
  if k<=cnt[i]:
    ans.append(max(ttl[i][:k]))
  else:
    if ttl[i][-1]<0:
      ans.append(ttl[i][peak])
    else:
      if k%cnt[i]==0:
        ans.append(((k-peak-1)//cnt[i])*ttl[i][-1]+ttl[i][peak])
      else:
        ans.append(max((k//cnt[i])*ttl[i][-1]+max(ttl[i][0:k%cnt[i]]),((k-peak-1)//cnt[i])*ttl[i][-1]+ttl[i][peak]))
print(max(ans))
import numpy as np
import math
n=int(input())
A=np.empty((n))
B=np.zeros((n))
count=0

for i in range(n):
    A[i]=int(input())


for i in range(n):
    if A[i]==1:
        B[i]=1
    elif A[i]==2:
        B[i]=0
    elif A[i]==3:
        B[i]=0
    elif A[i]==5:
        B[i]=0
    elif A[i]%2==0 :
        B[i]=1
    elif A[i]%3==0:
        B[i]=1
    elif A[i]%5==0:
        B[i]=1
    else:
        for j in range(2,int(math.sqrt(A[i]))):
            if A[i]%j==0:
                B[i]=1 
                break



for i in range(n):
    if B[i]==0:
        count=count+1

print(count)


### FIXED CODE ###

from math import sqrt

n=int(input())

count=0

for i in range(n):
    x=int(input())
    if x==1:
        count=count+1
    elif x!=2 and x%2==0:
        count=count+1
    elif x==2 or x==3 or x==5:
        count=count
    else:
        for j in range(2,int(sqrt(x))+1): 
            if x%j==0:
                count=count+1
                break


print(n-count)
A, B = map(int, input())
C = A + B
if C %2 == 0:
  print(C//2)
else:
  print('IMPOSSIBLE')


### FIXED CODE ###

A, B = map(int, input().split())
C = A + B
if C %2 == 0:
  print(C//2)
else:
  print('IMPOSSIBLE')
n = int(input())

for _ in range(n):
    train = ''
    seq = input()
    for i in range(len(seq) // 3 + 1):
        if i == 0:
            train += seq[i]
        if seq[3 * i - 2] == '-' and train[-1] == seq[3 * (i - 1)]:
            train = train + seq[3 * i]
        if seq[3 * i - 2] == '<' and train[0] == seq[3 * (i - 1)]:
            train = seq[3 * i] + train
    print(train)



### FIXED CODE ###

n = int(input())

for _ in range(n):
    train = ''
    seq = input()
    for i in range(0, len(seq), 3):
        if i == 0:
            train += seq[i]
        if seq[i - 2:i] == '->' and train[-1] == seq[i - 3]:
            train = train + seq[i]
        if seq[i - 2:i] == '<-' and train[0] == seq[i - 3]:
            train = seq[i] + train
    print(train)
L = [map(int,input().split()) for _ in range(3)]
L.sort()
M = []
a = L.count('1')
b = L.count('2')
c = L.count('3')
d = L.count('4')
M.append(a)
M.append(b)
M.append(c)
M.append(d)
M.sort()
if M == [1,1,2,2]:
  print('YES')
else:
  print('NO')

### FIXED CODE ###

L = []
for _ in range(3):
  A,B = map(int,input().split()) 
  L.append(A)
  L.append(B)
L.sort()
M = []
a = L.count(1)
b = L.count(2)
c = L.count(3)
d = L.count(4)
M.append(a)
M.append(b)
M.append(c)
M.append(d)
M.sort()
if M == [1,1,2,2]:
  print('YES')
else:
  print('NO')
N,K = map(int,input().split())
 
P = [0 for i in range(N)]
m = 0
for i in range(K):
  a = int(input())
  b = list(int,input().split())
  for j in range(a):
    P[b[j]-1] = 1
    j += 1
    
for l in range(N):
  if P[l] == 0:
    m += 1
    
print(m)


### FIXED CODE ###

n, k = map(int, input().split())
 
m = [0]*n
 
for i in range(k):
    d = int(input())
    a = [int(x) for x in input().split()]
    for j in range(d):
        m[a[j]-1] += 1
 
print(m.count(0))
# ここから入力
from itertools import combinations_with_replacement
n, m, q = map(int, input().split())
lst = []
for i in range(q):
    a = list(map(int, input().split()))
    lst.append(a)
# ここまで入力
x = 0
# 重複組合せ
for i in combinations_with_replacement(range(1, m + 1), n):
    s = 0
    for j in a:
        if i[j[1] - 1] - i[j[0] - 1] == j[2]:
            s += j[3]
    if x < s:
        x = s
print(x)

### FIXED CODE ###

# ここから入力
from itertools import combinations_with_replacement
from itertools import accumulate
n, m, q = map(int, input().split())
a = []
for i in range(q):
    a.append(list(map(int, input().split())))
# ここまで入力
# 重複組合せ
x = 0
for i in combinations_with_replacement(range(1, m + 1), n):
    ans = []
    for j in a:
        if i[j[1] - 1] - i[j[0] - 1] == j[2]:
            ans.append(j[3])
    if x < sum(ans):
        x = sum(ans)
print(x)
cases = int(input())

account = {'AC': 0, 'WA' : 0, 'TLE':0, 'RE':0}

while cases > 0:
  account[input()]++
  cases--
  
print('AC x '+ account['AC'])
print('WA x '+ account['WA'])
print('TLE x '+ account['TLE'])
print('RE x '+ account['RE'])

### FIXED CODE ###

import sys
input = sys.stdin.readline

cases = int(input())
account = {'AC': 0, 'WA' : 0, 'TLE':0, 'RE':0}

while cases > 0:
  account[input().split()[0]] += 1
  cases -= 1
  
print('AC x '+ str(account['AC']))
print('WA x '+ str(account['WA']))
print('TLE x '+ str(account['TLE']))
print('RE x '+ str(account['RE']))
x = int(input().split())
a = int(input().split())
b = int(input().split())

print((x - a)%b)



### FIXED CODE ###

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

print((x - a)%b)
#52
A=int(input())
B=int(input())
C=int(input())
D=int(input())
if A*B>c*D:
    print(A*B)
else:
    print(C*D)

### FIXED CODE ###

#52
A,B,C,D=map(int,input().split())
if (A*B)>(C*D):
    print(A*B)
else:
    print(C*D)
a,b,c = map(int, input().split())
cnt = 0
if b > 10 ** 9:
        cnt = (b-a) / c
        print (cnt)
else:
    for i in range(a,b+1):
        if i % c == 0:
            cnt += 1
    print (cnt)

### FIXED CODE ###

a,b,x = map(int, raw_input().split())
print b / x - (a-1) / x
n = int(input())
a = [int(input()) for i in range(n)]
ma = a[1]-a[0]
mi = a[0]
for i in range(1,n+1):
    mi = min(mi, a[i])
    ma = max(ma, a[i] - mi)
print(ma)
        


### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
ma = a[1]-a[0]
mi = a[0]
for i in range(1,n):
    ma = max(ma, a[i] - mi)
    mi = min(mi, a[i])
    
print(ma)
#n = 5
#C = list(map(int,"1 2 3 4 5".split()))
#line = ["1 2", "2 3", "3 4", "3 5"]


n = int(input())
C = list(map(int,input().split()))
 
ci = [set() for _ in range(n)]
for i,c in enumerate(C):
    ci[c-1].add(i)

path = [set() for _ in range(n)]
 
#line = ["1 2", "2 3"]
    
for i in range(n-1):
    a,b = map(int,input().split())
    #a,b = map(int,line[i].split())
    a -= 1
    b -= 1
    path[a].add(b)
    path[b].add(a)
    
ans = [n*(n+1)//2]*n
size = [0]*n
cparent = [[] for _ in range(n)]
reached = [False]*n
root_size = [n]*n

def dfs (p):
    c = C[p] - 1
    cparent[c].append(p)
    s = 1
    for nxt in path[p]:
        #print (nxt)
        size[p] = 0
        if reached[nxt]:
            continue
        reached[nxt] = True
        ret = dfs(nxt)
        s += ret
        size[p] +=ret
        ans[c] -= size[p] * (size[p] + 1)//2
    cparent[c].pop()
    if cparent[c]:
        size[cparent[c][-1]] -=s
    else:
        root_size[c] -=s    
    return s

reached[0] = True
dfs (0)

for i in range(n):
    print (ans[i]-root_size[i]*(root_size[i]+1)//2)


### FIXED CODE ###

r = int(input())
print (r*3.1415*2)
A,B,K = map(int, input().split())
L = list(range(A,B+1))
l = L[:K]
r = L[-K:]
N = sorted(list(set(l + r)))
for i in range(len(N)):
  print(N[i])

### FIXED CODE ###

a,b,k = map(int,input().split())
if (b-a+1) >= (2*k):
  for i in range(k):
    print(a+i)
  for i in reversed(range(0,k)):
    print(b-i)
else:
  for i in range(a,b+1):
    print(i)
l,r = map(int,input().split())

if (r-l) >= 2019:
      print(0)
else:
      m = float('inf')
      for i in range(l,r+1):
            for j in range(i+1,r+1):
                  m = min(m,(i*j)%2019,)
print(m)
            

### FIXED CODE ###

from itertools import combinations

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

if r - l >= 2019:
    print(0)
else:
    m = 2019
    for i, j in combinations(range(l, r+1),2):
        tmp = i*j % 2019
        if m > tmp:
            m = tmp
    print(m)
# -*- coding: utf-8 -*-
"""
Created on Sat Feb 16 20:59:16 2019

@author: doppe
"""

N, M = map(int, input().split())
likeList = []

for i in range(0, N):
    L = [int(i) for i in input().split()]
    likeListTmp = []
    if (i == 0):
        likeList = L
    else:
        for j in range(1, L[0] + 1):
            if (L[j] in likeList):
                likeListTmp.append(L[j])
        likeList = likeListTmp

print(len(likeList))

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sat Feb 16 20:59:16 2019

@author: doppe
"""

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

if (B % A == 0):
    print(A + B)
else:
    print(B - A)
i = input()
ans = 'Yes' if '7' in 1 else 'No'
print(ans)

### FIXED CODE ###

i = input()
ans = 'Yes' if '7' in i else 'No'
print(ans)
N, Y = map(int, input().split())
yukichi = -1
ichiyo = -1
hideyo = -1
for a in range(N+1):
    for b in range(N+1):
        c = N - a - b
        total = 10000*a + 5000*b + 1000*c
        if total == Y and c >= 0:
            yukichi = a
            ichiyo = b
            hideyo = c

print(f'{yukichi} {ichiyo} {hideyo}')

### FIXED CODE ###

N, Y = map(int, input().split())
for a in range(N+1):
    for b in range(N+1-a):
        c = N - a - b
        total = 10000*a + 5000*b + 1000*c
        if total == Y:
            print(a, b, c)
            exit()
print('-1 -1 -1')
n = int(input())
costs = map(int, input().split())
a, b = cost[0], cost[0] + abs(costs[1]-cost[0])
i = 2
while i < n:
  a, b = b, min(abs(cost[i] - cost[i-1]) + b, abs(cost[i] - cost[i-2]) + a)
  i += 1
print(b)

### FIXED CODE ###

n = int(input())
costs = list(map(int, input().split()))
a, b = 0, abs(costs[1]-costs[0])
i = 2
while i < n:
	a, b = b, min(abs(costs[i] - costs[i-1]) + b, abs(costs[i] - costs[i-2]) + a)
	i += 1
print(b)
n = int(input())
L = [int(i) for i in input().split()]

L.sort()
ans = 0
for i in range(0, 2*N, 2):
    ans += min(L[i], L[i+1])

print(ans)

### FIXED CODE ###

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

L.sort()
ans = 0
for i in range(0, 2*n, 2):
    ans += min(L[i], L[i+1])

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

if l[0] < l[1] and l[1] < l[2]:
    print("Yes")

else:
    print("No")

### FIXED CODE ###

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

if l[0] < l[1] and l[1] < l[2]:
    print("Yes")

else:
    print("No")
n, k = map(int, input().split())
a = list(map(int, input().split()))
s = set()
s.add(1)
former = []
latter = []
temp = [1]
idx = 0
cur = a[idx]
buf = 0

while True:
    if cur not in s:
        s.add(cur)
        temp.append(cur)
        cur = a[cur-1]
    else:
        buf = temp.index(cur)
        former = temp[:buf]
        latter = temp[buf:]
        break

# print('buf:', buf)
# print('former:', former)
# print('latter:', latter)

if k <= len(former):
    print(former[k])
else:
    mod = k % len(latter)
    # print('mod:', mod)
    idx = mod - len(former)
    print(latter[idx])


### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
s = set()
s.add(1)
former = []
latter = []
temp = [1]
cur = a[0]
buf = 0

while True:
    if cur not in s:
        s.add(cur)
        temp.append(cur)
        cur = a[cur-1]
    else:
        buf = temp.index(cur)
        former = temp[:buf]
        latter = temp[buf:]
        break

# print('buf:', buf)
# print('former:', former)
# print('latter:', latter)

if len(latter) == 0:
    mod = k % len(temp)
    print(temp[mod])
    exit()

if k <= len(former):
    # print(former[k])
    print(temp[k])
else:
    # mod = k % len(latter)
    mod = (k-len(former)) % len(latter)
    # print('mod:', mod)
    # idx = mod - len(former)
    idx = mod
    
    print(latter[idx])
sa = list(reversed(input()))
sb = list(reversed(input()))
sc = list(reversed(input()))

turn = sa.pop()

while True:
    if turn == 'a':
        turn = sa.pop()
    elif turn == 'b':
        turn = sb.pop()
    else:
        turn = sc.pop()
    if (turn == 'a' and not sa) or (
            turn == 'b' and not sb) or (turn == 'c' and not sc):
        break

print(turn.upper())


### FIXED CODE ###

sa = list(reversed(input()))
sb = list(reversed(input()))
sc = list(reversed(input()))

turn = sa.pop()

while True:
    if (turn == 'a' and not sa) or (
            turn == 'b' and not sb) or (turn == 'c' and not sc):
        break
    if turn == 'a':
        turn = sa.pop()
    elif turn == 'b':
        turn = sb.pop()
    else:
        turn = sc.pop()

print(turn.upper())