Harryxun/stf_run huggingface dataset:
import sys
def input(): return sys.stdin.readline().strip()


def main():
    n, k = map(int, input().split())
    L = list(map(int, input().split()))
    L.sort(reverse=True)
    print(sum[:K])

if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().strip()


def main():
    n, k = map(int, input().split())
    L = list(map(int, input().split()))
    L.sort(reverse=True)
    print(sum(L[:k]))

if __name__ == "__main__":
    main()
# coding: utf-8
import math
H,W = list(map(int,input().split()))
ans = H/2
ans *= W
print(math.ceil(ans))

### FIXED CODE ###

# coding: utf-8
word=[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
]
n = int(input())
print(word[n-1])
s = input()
t = input()

s = sorted(s)
t = reversed(t)

if s < t:
    print('Yes')
else:
    print('No') 

### FIXED CODE ###

s = input()
t = input()

s = ''.join(sorted(s))
t = ''.join(sorted(t, reverse=True))

if s < t:
    print('Yes')
else:
    print('No')
n = input()
for i in range(3):
    if n[i] == '1':
        n[i] = '9'
    elif n[i] == '9':
        n[i] = '1'
print(n)

### FIXED CODE ###

n = input()
print(n.replace('1', 'a').replace('9','1').replace('a', '9'))
r = input()
s = r**2
print(s)

### FIXED CODE ###

r = int(input())
print(r**2)
def main():
    N = input()
    c_list = [c for c in N]
    if((c[0] == c[1] and c[0] == c[2]) or (c[1] == c[2] and c[1] == c[3])):
        print("Yes")
    else:
        print("No")

main()

### FIXED CODE ###

def main():
    N = input()
    c = [c for c in N]
    if((c[0] == c[1] and c[0] == c[2]) or (c[1] == c[2] and c[1] == c[3])):
        print("Yes")
    else:
        print("No")

main()
a,b=map(int,input().split())
if a > b:
  print(">")
else if a < b:
  print("<")
else:
  print("=")


### FIXED CODE ###

a,b=input().split()
if a > b:
  print(">")
elif a < b:
  print("<")
else:
  print("=")
N = input()
for i in range(N):
	l = []
	line = raw_input()
	l.append(int(line.split()[0]))
	l.append(int(line.split()[1]))
	l.append(int(line.split()[2]))
	l.sort()
	if l[0]*l[0]+l[1]*l[1]==l[2]*l[2]:
		print("YES")
	else:
		print("NO")

### FIXED CODE ###

N = int(input())
for i in range(N):
	line = input()
	l = [None]*3
	l[0] = int(line.split()[0])
	l[1] = int(line.split()[1])
	l[2] = int(line.split()[2])
	l.sort()
	if l[0]**2+l[1]**2==l[2]**2:
		print("YES")
	else:
		print("NO")
# coding: utf-8

def North(dice):
	new_dice = [0,0,0,0,0,0]
	new_dice[0] = dice[3]
	new_dice[1] = dice[0]
	new_dice[2] = dice[2]
	new_dice[3] = dice[5]
	new_dice[4] = dice[4]
	new_dice[5] = dice[1]
	return new_dice

def East(dice):
	new_dice = [0,0,0,0,0,0]
	new_dice[0] = dice[4]
	new_dice[1] = dice[1]
	new_dice[2] = dice[0]
	new_dice[3] = dice[3]
	new_dice[4] = dice[5]
	new_dice[5] = dice[2]
	return new_dice

def West(dice):
	new_dice = [0,0,0,0,0,0]
	new_dice[0] = dice[2] #3
	new_dice[1] = dice[1] #5
	new_dice[2] = dice[5] #6
	new_dice[3] = dice[3] #2
	new_dice[4] = dice[0] #1
	new_dice[5] = dice[4] #4
	return new_dice

def South(dice):
	new_dice = [0,0,0,0,0,0]
	new_dice[0] = dice[1] #5
	new_dice[1] = dice[5] #6
	new_dice[2] = dice[2] #3
	new_dice[3] = dice[0] #1
	new_dice[4] = dice[4] #4
	new_dice[5] = dice[3] #2
	return new_dice

def Right(dice):
	new_dice = [0,0,0,0,0,0]
	new_dice[0] = dice[0] #1
	new_dice[1] = dice[4] #4
	new_dice[2] = dice[1] #5
	new_dice[3] = dice[2] #3
	new_dice[4] = dice[3] #2
	new_dice[5] = dice[5] #6
	return new_dice

def Left(dice):
	new_dice = [0,0,0,0,0,0]
	new_dice[0] = dice[0] #1
	new_dice[1] = dice[2] #3
	new_dice[2] = dice[3] #2
	new_dice[3] = dice[4] #4
	new_dice[4] = dice[1] #5
	new_dice[5] = dice[5] #6
	return new_dice

while True:
	n = int(raw_input())
	if n == 0:
		break
	dice = [1,5,3,2,4,6] # ??? ??? ??± ??? ?\? ??? ??????
	sum = 1
	for i in range(n):
		instruct = raw_input()
		if instruct == "North":
			dice = North(dice)
		elif instruct == "East":
			dice = East(dice)
		elif instruct == "South":
			dice = South(dice)
		elif instruct == "West":
			dice = West(dice)
		elif instruct == "Right":
			dice = Right(dice)
		elif instruct == "Left":
			dice = Left(dice)
		#print("** {:} **".format(dice[0]))
		sum += dice[0]
	print(sum)

### FIXED CODE ###

while(1):
    num=int(raw_input())
    if num==0:
        break
    else:
        d=[0,1,2,3,4,5,6]
        sum=1
        for i in range(num):
            dir=num=raw_input()
            if dir=="North":
                d=[0,d[2],d[6],d[3],d[4],d[1],d[5]]
            elif dir=="East":
                d=[0,d[4],d[2],d[1],d[6],d[5],d[3]]
            elif dir=="West":
                d=[0,d[3],d[2],d[6],d[1],d[5],d[4]]
            elif dir=="South":
                d=[0,d[5],d[1],d[3],d[4],d[6],d[2]]
            elif dir=="Right":
                d=[0,d[1],d[3],d[5],d[2],d[4],d[6]]
            else:
                d=[0,d[1],d[4],d[2],d[5],d[3],d[6]]
            sum=sum+d[1]
        print sum
r = list(map(int, input().split()))
print('{0:f}'.format(((r[2] - r[0]) ** 2 + (r[3] - r[1]) ** 2) ** 0.5))

### FIXED CODE ###

r = list(map(float, input().split()))
print('{0:f}'.format(((r[2] - r[0]) ** 2 + (r[3] - r[1]) ** 2) ** 0.5))
# ABC148 E
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
import math
n=ni()

if n%2==1:
    print(0)
    exit()

five=math.floor(math.log(n,5))
ans=0

# for i in range(five):
for j in range(five):
    t=n//(5**(five-j))
    ans+=t//2
print(ans)


### FIXED CODE ###

# ABC148 E
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
import math
n=ni()

if n==0:
    print(0)
    exit()

if n%2==1:
    print(0)
    exit()

five=math.floor(math.log(n,5))
ans=0

# for i in range(five):
for j in range(five):
    t=n//(5**(five-j))
    ans+=t//2
print(ans)
m = lambda : (a:=list(map(int,input().split())) , c:=[x for x in range(1,1010) if int(x*0.08)==a[0] and int(x*0.1)==a[1]], min(c) if len(c)>0 else -1 )[2]
print(m)

### FIXED CODE ###

a, b = map(int, input().split())
def solve():
    for i in range(1, 1010):
        if int(i*0.08) == a and int(i*0.1) == b:
            print(i)
            return
    print(-1)

solve()
import math
n = int(input())
a = list(map(int, input().split()))
a.sort()
max_gcd = 1

def gcd_3(n1,n2,n3):
    return math.gcd(math.gcd(n1,n2),math.gcd(n1,n3))

if len(a) == 2:
    max_gcd = max(a)
elif len(a) == 3:
    gcd1 = math.gcd(a[0],a[1])
    gcd2 = math.gcd(a[1],a[2])
    gcd3 = math.gcd(a[0],a[2])
    max_gcd = max(gcd1,gcd2,gcd3)
else:
    gcd1 = gcd_3(a[0], a[1],a[2])
    gcd2 = gcd_3(a[1], a[2],a[3])
    gcd3 = gcd_3(a[2], a[0],a[3])
    gcd4 = gcd_3(a[0],a[1],a[3])
    max_gcd = max(gcd1,gcd2, gcd3, gcd4)

print(max_gcd)

### FIXED CODE ###

def gcd(a,b):
    l = max(a,b)
    s = min(a,b)
    if s == 0:
        return l
    else:
        return gcd(s, l%s)

n = int(input())
a = [0] + list(map(int, input().split())) + [0]
max_gcd = 1
L = [0] * (n+2)
R = [0] * (n+2)

for i in range(1,n+2):
    L[i] = gcd(a[i],L[i-1])
    R[n+1-i] = gcd(a[n+1-i], R[n+2-i])
for i in range(1,n+1):
    max_gcd = max(max_gcd,gcd(L[i-1], R[i+1]))

print(max_gcd)
#!/usr/bin/env python

def makesign(room, rw_lst, sign_lst, check_lst):
    check_lst[room] = True
    newways = []
    for way in rw_lst[room]:
        if sign_lst[way] == -1:
            newways.append(way)
            sign_lst[way] = room
    rw_lst[room] = newways

    for way in rw_lst[room]:
        makesign(way, rw_lst, sign_lst, check_lst)

def main():
    n, m = map(int, input().split())
    rw_lst = [[] for _ in range(n+1)]
    for _ in range(m):
        a, b = map(int, input().split())
        rw_lst[a].append(b)
        rw_lst[b].append(a)

    print(rw_lst)

    sign_lst = [-1] * (n+1)
    sign_lst[1] = 0
    check_lst = [False for _ in range(n+1)]
    check_lst[0] = True

    makesign(1, rw_lst, sign_lst, check_lst)

    check = True
    for i in range(1, n+1):
        check = check and check_lst[i]

    if check:
        print("Yes")
        for i in range(2, n+1):
    else:
        print("No")


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python
from collections import deque

def main():
    n, m = map(int, input().split())
    rw_lst = [[] for _ in range(n+1)]
    for _ in range(m):
        a, b = map(int, input().split())
        rw_lst[a].append(b)
        rw_lst[b].append(a)

    sign_lst = [-1 for _ in range(n+1)]
    sign_lst[1] = 0
    check_lst = [False for _ in range(n+1)]
    check_lst[1] = True

    queue = deque([1])
    while queue:
        room = queue.popleft()
        for way in rw_lst[room]:
            if not check_lst[way]:
                check_lst[way] = True
                sign_lst[way] = room
                queue.append(way)

    check = True
    for i in range(1, n+1):
        check = check and check_lst[i]

    if check:
        print("Yes")
        for i in range(2, n+1):
            print(sign_lst[i])
    else:
        print("No")


if __name__ == '__main__':
    main()
N = int(input())
a = list(int(i) for i in input().split())  

sum = 0
for k in range(N):
  if k == 0:
    sum += abs(a[k])
  elif k == (N-1):
    sum += abs(a[k] - a[k-1]) + abs(a[k])
  else:
    sum += abs(a[k] - a[k-1])

for j in range(N):
  if j == 0:
    if (a[j+1] - a[j]) * (a[j] -0) >= 0:
      print(sum)
    else:
      print(sum - 2 * min(abs(a[j]),abs(a[j]-a[j+1])))
  elif j == N-1:  
    if (a[j] - a[j-1]) * (0 - a[j]) >= 0:
      print(sum)
    else:
      print(sum - 2 * min(abs(a[j]-a[j-1]),abs(a[j]-a[j+1])))
  else:
    if (a[j] - a[j-1] ) * (a[j+1] - a[j]) >= 0:
      print(sum)
    else:
      print(sum - 2 * min(abs(a[j]-a[j-1]),abs(a[j+1]-a[j])))
    

### FIXED CODE ###

a = [int(input()) for i in range(2)]
b = [int(input()) for i in range(2)]
print(min(a)+min(b))
def itinokazu(A,i):#配列Aのi桁目の１の数を調べる
    kazu=0
    for a in A:
        bina=bin(a)
        if a>=2**(i-1):
            if bina[i*-1]=='1':
                kazu=kazu+1
    return kazu

import math
N,K=[int(i) for i in input().split()]
A=list(map(int,input().split()))
Maxkazu=max(max(A),K)#桁の上限を探す(Kの2進数での桁数を考える)
Keta=math.floor(math.log2(Maxkazu))+1
presentA=0
print(Keta)
presentAns=0
for i in reversed(range(Keta+1)):#i桁目(2^i-1)の位について
    ichinokazu=itinokazu(A,i)
    if (2*ichinokazu>N) or presentA+2**(i-1)>K:#i桁目が1のほうが多い、もしくは1にすると超えちゃう場合はAのi桁目は0
        presentAns=presentAns+((2**(i-1))*ichinokazu)
    else:
        presentA=presentA+2**(i-1)#そうでなければAのi桁目は1
        presentAns=presentAns+((2**(i-1))*(N-ichinokazu))
print(int(presentAns))

### FIXED CODE ###

T,X=[int(i)for i in input().split()]
print(T/X)
from math import gcd
n = int(input())
p = 10**9 + 7
iwashi = {}
bad = 0
ans = 1
for i in range(n):
    x, y = map(int, input().split())
    if(x == 0 and y == 0):
      bad += 1
      continue
    elif(x == 0):
        iwashi[(0, -1)] += 1
        continue
    elif(y == 0):
        iwashi[(1, 0)] += 1
        continue
    else:
        g = gcd(x, y)
        x, y = x // g, y // g
        if x < 0:
            x, y = -x, -y
        try:
        	iwashi[(x, y)] += 1
        except KeyError:
            iwashi[(x, y)] = 1
            
for x, y in iwashi:
    a = iwashi[(x, y)]
    if y > 0:
    	rx,ry = y, -x
    else:
      	rx,ry = -y, x
    try:
        b = iwashi[(rx,ry)]
        iwashi[(rx,ry)] = 0
    except KeyError:
      	b = 0
    ans *= pow(2, a, p) + pow(2, b, p) - 1
    ans %= p
    iwashi[(x, y)] = 0
print((ans + bad - 1) % p)


### FIXED CODE ###

from math import gcd
n = int(input())
p = 10**9 + 7
iwashi = {}
bad = 0
ans = 1
for i in range(n):
    x, y = map(int, input().split())
    if(x == 0 and y == 0):
      bad += 1
      continue
    elif(x == 0):
        try:
        	iwashi[(0, 1)] += 1
        except KeyError:
            iwashi[(0, 1)] = 1
            continue
    elif(y == 0):
        try:
        	iwashi[(1, 0)] += 1
        except KeyError:
            iwashi[(1, 0)] = 1
        continue
    else:
        g = gcd(x, y)
        x, y = x // g, y // g
        if x < 0:
            x, y = -x, -y
        try:
        	iwashi[(x, y)] += 1
        except KeyError:
            iwashi[(x, y)] = 1
            
for x, y in iwashi:
    a = iwashi[(x, y)]
    if y > 0:
    	rx,ry = y, -x
    else:
      	rx,ry = -y, x
    try:
        b = iwashi[(rx,ry)]
        iwashi[(rx,ry)] = 0
    except KeyError:
      	b = 0
    ans *= pow(2, a, p) + pow(2, b, p) - 1
    ans %= p
    iwashi[(x, y)] = 0
print((ans + bad - 1) % p)
import numpy as np
import sys

N = int(input())
A = input().split(' ')

an = np.array(A, dtype=np.int64)

chk = 0
for i in range(0,N+1):
   chk = chk ^ an[i] 

if(chk == 0):
   print('Yes')
else:
   print('No')
  





### FIXED CODE ###

import numpy as np
import sys

N = int(input())
A = input().split(' ')

an = np.array(A, dtype=np.int64)

chk = 0
for i in range(0,N):
   chk = chk ^ an[i] 

if(chk == 0):
   print('Yes')
else:
   print('No')
N, K, Q = map(int, input().split())
A = [list(map(int,input().split()))for i in range(Q)]
point_list = [K]*N
for answer in A:
    point_list = list(map(lambda x: x-1, point_list))
    point_list[answer-1] += 1
    
for ans in point_list:
    if ans > 0:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
seikaisuu = [0]*N
for answer in A:
    seikaisuu[answer-1] += 1
for x in seikaisuu:
    if K > Q - x:
        print("Yes")
    else:
        print("No")
import math
A,B = map(int,input().split())

def lcm(x,y):
    return (x*y) // math.gcd(x, y)

print(lcm(A,B))

### FIXED CODE ###

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

def lcm(x,y):
    return (x*y) // fractions.gcd(x, y)

print(lcm(A,B))
A = int(input())
B = input()
C = int(input())
d = b[k-1]
new = [e for e in b if e != d]
while(len(new)>i):
  f = new[i]
  b[f] = '*'
  i = i+1
print(b)

### FIXED CODE ###

N=int(input())
S=str(input())
K=int(input())
W=S[K-1]
for i in range(N):
  if S[i]!=W:
    S=S.replace(S[i],'*')
print(S)
#coding:utf-8

a, b, c, d = map(int, input().split())

print(max(b,d) - min(a,c))


### FIXED CODE ###

#coding:utf-8

n = list(input())

if n[0] == n[2]:
  print('Yes')
else:
  print('No')
A, B = map(int, input())
print((A * B) // 1)

### FIXED CODE ###

import decimal
A, B = map(decimal.Decimal, input().split())
print(int(A*B))
array = [int(i) for i in input().split()]

if sort(array) == [5,5,7]:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

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

if sorted(array) == [5,5,7]:
  print("YES")
else:
  print("NO")
s=input()
K=int(input())
li=[]
for i in range(len(s)):
  m=min(K,len(s)-i-1)
  for j in range(m):
    li.append(s[i:i+j+1])
li.sort()
print(li[K])

### FIXED CODE ###

s=input()
K=int(input())
li=[]
for i in range(len(s)):
  m=min(K,len(s)-i)
  for j in range(m):
    li.append(s[i:i+j+1])
li.sort(reverse=True)
st=[]
while len(st)<K:
  t=li.pop()
  if t not in st:
    st.append(t)
print(st[-1])
import sys
while(1):
  H,W = map(int, raw_input().split())
  if H==0 and W==0:
    break
  for i in range(H):
    sys.stdout.white("#")
    for j in range(2,W-1):
      if i == 1 or i == H:
        sys.stdout.write("#")
      else:
        sys.stdout.write(".")
    sys.stdout.white("#\n")
  print ""    

### FIXED CODE ###

while(1):
  H,W = map(int, raw_input().split())
  if H == 0 and W == 0:
    break
  for i in range(H):
    if i == 0 or i == H-1:
      print "#"*W
    else:
      print "#" + "."*(W-2) + "#"
  print ""
a, b, k = map(int, input().split())
da = []
db = []
dc = []
for i in range(1,a+1):
    if a%1 == 0:
    	da.append(i)

for j in range(1, b+1):
    if b%j == 0:
    	db.append(j)

for k in range da:
    if k in db:
    	dc.append(k)

dc.sort(reverse = True)
print(dc[k-1])

### FIXED CODE ###

a, b, k = map(int, input().split())
da = []
db = []
dc = []
for i in range(1,a+1):
    if a%i == 0:
    	da.append(i)

for j in range(1, b+1):
    if b%j == 0:
    	db.append(j)

for l in da:
    if l in db:
    	dc.append(l)

dc.sort(reverse = True)
print(dc[k-1])
P, Q, R = map(int, input().split())
abc = P+Q
acb = P+R
cab = R+Q

ans = 10000
ans = min(ans, abc)
ans = min(ans, acb)
ans = min(ans, dca)
print(ans)


### FIXED CODE ###

P, Q, R = map(int, input().split())
abc = P+Q
acb = P+R
cab = R+Q

ans = 10000
ans = min(ans, abc)
ans = min(ans, acb)
ans = min(ans, cab)
print(ans)
D, N = input().split()
if D == 0:
    out = N
else:
    out = 100 * D * N
print(out)

### FIXED CODE ###

D, N = map(int, input().split())
if D == 0:
    out = N
    if N == 100:
        out = 101
else:
    out = 100 ** D * N
    if N == 100:
        out = 100 ** (D + 1) + 100 ** D
print(out)
Matches = {num: c for num, c in zip([1, 2, 3, 4, 5, 6, 7, 8, 9], [2, 5, 5, 4, 5, 6, 3, 7, 6])}

def psolve(N, digit, Ms):
    if N == 0:
        return digit
    if N < min([m for m in Ms.values()]):
        return -1
    ans = 0
    for (dc, dnum) in [(c, num) for (num, c) in Ms.items()]:
        if digit + str(dnum) > str(dnum) + digit:
            p = psolve(N - dc, digit + str(dnum), Ms)
            if p != -1:
                ans = max(ans, int(p))
        else:
            p = psolve(N - dc, str(dnum) + digit,  Ms)
            if p != -1:
                ans = max(ans, int(p))
    return ans

def solve(N, M, As):
    Ms = {num: c for num, c in Matches.items() if num in As}
    return psolve(N, "", Ms)


if __name__ == "__main__":
    N, M = tuple(map(int, input().split(" ")))
    As = list(map(int, input().split(" ")))
    print(solve(N, M, As))


### FIXED CODE ###

Matches = {num: c for num, c in zip([1, 2, 3, 4, 5, 6, 7, 8, 9], [2, 5, 5, 4, 5, 6, 3, 7, 6])}


def solve(N, M, As):
    dp = [-1 for _ in range(N + 1)]
    dp[0] = 0
    for a in sorted(As, reverse=True):
        c = Matches[a]
        for i in range(N - c + 1):
            if dp[i] == -1:
                continue
            dp[i + c] = max(dp[i+c],
                            dp[i] * 10 + a)
    return dp[N]

if __name__ == "__main__":
    N, M = tuple(map(int, input().split(" ")))
    As = list(map(int, input().split(" ")))
    print(solve(N, M, As))
import math
import sys
from functools import reduce

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline


def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def main():
    N = int(readline())
    T = list(map(int, read().split()))
    print(lcm(*T))


main()


### FIXED CODE ###

import fractions
import sys
from functools import reduce

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def main():
    N = int(readline())
    T = list(map(int, read().split()))
    print(lcm(*T))


main()
if (A <= 8) and (B <= 8):print "Yay!"
else : print ":("

### FIXED CODE ###


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

if (A <= 8) and (B <= 8):print "Yay!"
else : print ":("
S = input()
h = S // 3600
ms = S % 3600
m = ms // 60
s = ms % 60
print(h + ":" + m + ":" + s)

### FIXED CODE ###

S = int(input())
s = str(S % 60)
HM = S // 60
m = str(HM % 60)
h = str(HM // 60)
print(h + ":" + m + ":" + s)
from math import gcd
a,b,c,d = map(int,input().split())
g = c*d//gcd(c, d)
print(b-a+1 - b//c-b//d+b//g + (a-1)//c+(a-1)//d-(a-1)//g)


### FIXED CODE ###

from fractions import gcd
a,b,c,d = map(int,input().split())
g = c*d//gcd(c, d)
print(b-a+1 - b//c-b//d+b//g + (a-1)//c+(a-1)//d-(a-1)//g)
import copy
from collections import defaultdict

n, k = map(int, input().split())
sushi = [list(map(int, input().split())) for _ in range(n)]
sushi.sort(key=lambda x: x[1])
t = {}
x = []
z = [0]
for i in range(n - 1, n - k - 1, -1):
    if sushi[i][0] in t.keys():
        x.append(i)
        t[sushi[i][0]] += 1
    else:
        t[sushi[i][0]] = 1
    z[0] += sushi[i][1]
y = []
yd = []
for i in range(n - k - 1, -1, -1):
    if sushi[i][0] not in t.keys() and sushi[i][0] not in yd:
        y.append(i)
        yd.append(sushi[i][0])

for k in range(1, len(x) + 1):
    xi = x[-k]
    z.append(z[-1] - sushi[xi][1] + sushi[y[k - 1]][1])

ans = 0
p = len(t.keys())
for i in range(len(z)):
    ans = max(ans, z[i] + (p + i) ** 2)
print(ans)


### FIXED CODE ###

import heapq

n, k = map(int, input().split())
sushi = [list(map(int, input().split())) for _ in range(n)]
sushi.sort(key=lambda x: x[1])
t = {}
x = []
z = 0
for i in range(n - 1, n - k - 1, -1):
    ti, di = sushi[i]
    if ti in t.keys():
        heapq.heappush(x, di)
        t[ti] += 1
    else:
        t[ti] = 1
    z += di

p = len(t.keys())
ans = z + p ** 2
for i in range(n - k - 1, -1, -1):
    if len(x) == 0:
        break
    ti, di = sushi[i]
    if ti not in t.keys():
        t[ti] = 1
        z += di - heapq.heappop(x)
        p += 1
        ans = max(ans, z + p ** 2)

print(ans)
x = input()
y = x**3
print(y)

### FIXED CODE ###

x = int(input())
print (x**3)
N, M = map(int,input().split())
array = sorted(list(map(int,input().split())))
convert = [list(map(int,input().split())) for _ in range(M)]
convert.sort(key=lambda x: x[1])
convert.reverse()
i = 0
for j in range(M):
  start = 0
  while (array[i] < convert[j][1]) & (start < convert[j][0]):
    array[i] = convert[j][1]
    i += 1
    start += 1
    if i == N:
      break
print(sum(array))



### FIXED CODE ###

N, M = map(int,input().split())
array = sorted(list(map(int,input().split())))
convert = [list(map(int,input().split())) for _ in range(M)]
convert.sort(key=lambda x: x[1])
convert.reverse()
i = 0
for j in range(M):
  #array.sort()
  start = 0
  while (array[i] < convert[j][1]) & (start < convert[j][0]):
    array[i] = convert[j][1]
    #print(array)
    i += 1
    start += 1
    if i == N:
      break
  if i == N:
    break

print(sum(array))
N, M, K = map(int, input().split())
MOD = 998244353

CONV = 1
KAIJ = (M - 1) ** (N - 1)
ans = 0

for k in range(K + 1):
  # M x (N-1)Ck x (M-1) ^ (N - 1 - k)
  ans += (M * CONV * KAIJ) % MOD
  CONV = CONV * (N - 1 - k) // (k + 1)
  KAIJ = KAIJ // (M - 1)
  
print(ans % MOD)

### FIXED CODE ###

N, M, K = map(int, input().split())
MOD = 998244353

ans = 0

class combination():
    def __init__(self, n):
        self.fact = [1] * (n+1)
        self.ifact = [1] * (n+1)
        for i in range(1, n+1):
            self.fact[i] = self.fact[i-1]*i % MOD
        self.ifact[n] = pow(self.fact[n], MOD-2, MOD)
        for i in range(n, 0, -1):
            self.ifact[i-1] = self.ifact[i]*i % MOD
    def comb(self, n, k):
        if k < 0 or k > n: return 0
        comb = self.fact[n]*self.ifact[k]*self.ifact[n-k] %MOD
        return comb
comb = combination(N)

  
for k in range(K+1):
  # M x (N-1)Ck x (M-1) ^ (N - 1 - k)
  ans += (comb.comb(N-1, k) * pow(M-1, N-1-k, MOD)) % MOD
  
print(ans * M % MOD)
x = int(input())
max = 10**9+1
flag = False
for i in range(1,max):
    if x%i == 0:
        for j in range(-i-1,i+1):
            tmp = (i-j)**5 - j**5
            if tmp == x:
                print(str(i-j)+" "+str(j))
                flag = True
                break
    if flag:
        break

### FIXED CODE ###

s = input()

if s == "ABC":
    print("ARC")
else:
    print("ABC")
a,b,c = [int(x) for x in input().split( )]
div = []
for x in range(1,c+1):
    if c % x == 0:
        div.append(x)
r = []
for x in range(a,b+1):
    r.append(x)
answer = 0
for x in div:
    for y in r:
        if x == y:
            answer += 1
print(answer)



### FIXED CODE ###

a,b,c = [int(x) for x in input().split( )]
count = 0
for number in range(a,b+1):
    if c % number == 0:
        count += 1
print(count)