Harryxun/stf_run huggingface dataset:
n, k = map(int, input().split())
hlis = list(map(int, input().split()))
hlis.sort(reverse=True)
for i in range(0, k):
  del hlis[0]
print(sum(hlis))

### FIXED CODE ###

n, k = map(int, input().split())
hlis = list(map(int, input().split()))
hlis.sort(reverse=True)

del hlis[0:k]
print(sum(hlis))
n = int(input())

A =        list( map(int, input().split()) )	# 1 2 3 4 5 ...
B =        list( map(int, input().split()) )	# 1 2 3 4 5 ...
C =        list( map(int, input().split()) )	# 1 2 3 4 5 ...

ans=0

x=-1
for a in A:
	
	if a==x+1:
		ans+=C[a]
	else:
		ans+=B[a]
	x=a

print(ans)


### FIXED CODE ###

n = int(input())

A =        list( map(int, input().split()) )	# 1 2 3 4 5 ...
B =        list( map(int, input().split()) )	# 1 2 3 4 5 ...
C =        list( map(int, input().split()) )	# 1 2 3 4 5 ...

ans=0

x=-2
for a in A:
	a-=1
	ans+=B[a]
	if a==x+1:
		ans+=C[a-1]
	x=a

print(ans)
N = int(input())
A = list(map(int,input().split()))
B = set(sorted(A))
k = 1
a = 0
b = []
for i in B:
    if i != k:
        break
    j = A.index(i)
    a += j+1
    b.append(a)
    A = A[j+1:]
    if a == N:
        break
    k += 1
    
if b == []:
    print(-1)
else:
    print(N-len(b))

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
c = 0
for a in A:
    if a == c + 1:
        c = a
    
if c == 0:
    print(-1)
else:
    print(N-c)
import sys

st = list(input())
ls = list(set(st))
ls.sort()
abc = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
for i in range(0,len(abc)):
    if abc[i] != ls[i]:
        print(abc[i])
        sys.exit()
print("None")


### FIXED CODE ###

st = list(input())
ls = list(set(st))
abc = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
set_ab = set(abc) - set(ls)
ans = list(set_ab)
ans.sort()
if ans:
    print(ans[0])
else:
    print("None")
S=input()
b=["A","T","G","C"]
cntl=[]
cnt=0
for i in S:
    if i in b:
        cnt+=1
    else:
        cntl.append(cnt)
        cnt=0
print(max(cntl))

### FIXED CODE ###

S=input()
b=["A","T","G","C"]
cntl=[]
cnt=0
for i in S:
    if i in b:
        cnt+=1
    else:
        cntl.append(cnt)
        cnt=0
else:
    cntl.append(cnt)
print(max(cntl))
from collections import deque
s=deque(list(input()))
q=int(input())
r = False
for i in range(q):
    tmp = list(input().split(' '))
    if tmp[0]=='1':
        r = not r
    elif (not r and tmp[1]=='1') or (r and tmp[1] =='2'):
        s.appendleft(tmp[2])
    else:
        s.append(tmp[2])
if not r:
    for i in s:
        print(i,end='')
else:
    for i in s[::-1]:
        print(i,end='')

### FIXED CODE ###

from collections import deque
s=deque(list(input()))
q=int(input())
r = False
for i in range(q):
    tmp = list(input().split(' '))
    if tmp[0]=='1':
        r = not r
    elif (not r and tmp[1]=='1') or (r and tmp[1] =='2'):
        s.appendleft(tmp[2])
    else:
        s.append(tmp[2])
if not r:
    for i in s:
        print(i,end='')
else:
    for i in reversed(s):
        print(i,end='')
k, x = map(int, input().split())
ans = []
for i in range(N):
  ans.append(k-i)
for j in range(1, N, 1):
  ans.append(k+i)
  
ans = sorted(ans)

for k in ans:
  print(ans[k])

### FIXED CODE ###

k, x = map(int, input().split())
l = []
for i in range(k):
    l.append(x+i)
    if i > 0:
        l.append(x-i)
l = sorted(l)
for j in range(2*k-1):
    print(l[j], end=" ")
S = input().strip()
K = int(input().strip())

ans: int = 1
for i in range(min(K, len(S))):
    if(S[i] != "1"):
        ans = S[i]
        break
print(ans)

### FIXED CODE ###

s=input()
k=int(input())

cnt=0 #1の個数
i=0
while True:
    if s[i]!='1': break
    else:
        cnt+=1
        i+=1
        if i>len(s)-1: break
        
print(1 if k<=cnt else s[cnt])
from sys import stdin
n,k=list(map(int,input().split()))
c=0
while n > 0:
    c += 1
    n//=k
print(c)


### FIXED CODE ###

from sys import stdin

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

if n < 10:
    print(r + 100 * (10-n))
else:
    print(r)
# A,Double Helix
# AtCoder 星には四種類の塩基 A, C, G, T が存在し、A と T、C と G がそれぞれ対になります。
# 文字 bが入力されます。これは A, C, G, T のいずれかです。塩基bと対になる塩基を表す文字を出力するプログラムを書いてください。

# bは文字 A, C, G, T のいずれかである。

b = input()

# 塩基bと対になる塩基を表す文字を出力せよ。

if b == "A":
    answer = "T"
elif b == "T":
    anawer = "A"
elif b == "C":
    answer = "G"
elif b == "G":
    answer = "C"

print(answer)

### FIXED CODE ###

# A,Double Helix
# AtCoder 星には四種類の塩基 A, C, G, T が存在し、A と T、C と G がそれぞれ対になります。
# 文字 bが入力されます。これは A, C, G, T のいずれかです。塩基bと対になる塩基を表す文字を出力するプログラムを書いてください。

# bは文字 A, C, G, T のいずれかである。

b = input()

# 塩基bと対になる塩基を表す文字を出力せよ。

if b == "A":
    print("T")
elif b == "T":
    print("A")
elif b == "C":
    print("G")
elif b == "G":
    print("C")
N, K, L = map(int, input().split())

par = [i for i in range(N)]
size = [1] * N


def find(x, P):
    if P[x] == x:
        return x
    else:
        return find(P[x], P)

def unite(x, y):
    x = find(x, par)
    y = find(y, par)

    if x != y:
        # xとyの属している集合が異なる時
        pass
        par[x] = y

par2 = [i for i in range(N)]
def unite2(x, y):

    x = find(x, par2)
    y = find(y, par2)

    if x != y:
        # xとyの属している集合が異なる時
        par2[x] = y
        s = size[x] + size[y]
        size[y] = s

for _ in range(K):
    p, q = map(int, input().split())
    find(q-1, par)

    unite(p-1, q-1)

### FIXED CODE ###

from collections import Counter

n,k,l=map(int,input().split())
city1=[i for i in range(n)]
city2=[i for i in range(n)]

def root(c,x):
  if x==c[x]:
    return x
  else:
    c[x]=root(c,c[x])
    return c[x]

def union(c,x,y):
  rx=root(c,x)
  ry=root(c,y)
  if rx>ry:
    c[rx]=ry
  else:
    c[ry]=rx

for i in range(k):
  a,b=map(int,input().split())
  union(city1,a-1,b-1)
for i in range(l):
  a,b=map(int,input().split())
  union(city2,a-1,b-1)
r=[]
for i in range(n):
  r.append((root(city1,i),root(city2,i)))
c=Counter(r)
for i in range(n):
  ans=c[r[i]]
  if i==n-1:
    print(ans)
  else:
    print(ans,end=' ')
s = input()

if s == "ABC":
    print("ARC")
elif s = "ARC":
    print("ABC")

### FIXED CODE ###

s = input()

if s == "ABC":
    print("ARC")
elif s == "ARC":
    print("ABC")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
    ll N;
    cin >> N;
    int res = 30;
    for(ll i = 1; i*i <= N; ++i) {
        if(N%i) continue;
        ll j = N/i;
        int cnt = 0;
        while(j > 0) ++cnt, j /= 10;
        res = min(res, cnt);
    }
    cout << res << endl;
    return 0;
}

### FIXED CODE ###

import sys
input = sys.stdin.readline

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

def main():
    N = int(input())
    a = make_divisors(N)
    a.sort()
    ans = 10
    for i in a:
        ans = min(ans, len(str(max(i, N/i))))
    
    print(ans)

if __name__ == '__main__':
    main()
count = {} #a~zの出現回数を記録

while True:
    try:
        text = raw_input()
    except:
        break
    for i in range(26):
        count[(i)] = 0
    
    for i in range(len(text)):
        if(ord(text[i]) >= ord('a') and ord(text[i]) <= ord('z')):
            count[(ord(text[i]))-ord('a')] += 1
        if(ord(text[i]) >= ord('A') and ord(text[i]) <= ord('Z')):
            count[(ord(text[i]))-ord('A')] += 1

    #出現回数の表示
    for i in range(26):
        print '%s : %d' %(unichr(i+ord('a')), count[(i)])

### FIXED CODE ###

count = {}
for i in range(26):
    count[(i)] = 0

while True:
    try:
        x = raw_input()
    except:
        break
    for i in range(len(x)):
        if(ord('a') <= ord(x[i]) and ord(x[i]) <= ord('z')):
            count[(ord(x[i])-ord('a'))] += 1
        elif(ord('A') <= ord(x[i]) and ord(x[i]) <= ord('Z')):
            count[(ord(x[i])-ord('A'))] += 1

for i in range(26):
    print '%s : %d' %(chr(i+ord('a')), count[(i)])
exit(0)
import sys
from math import factorial
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
import scipy.misc
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n, k = MAP()
a = LIST()


a.sort(reverse = True)
res = 0
for i in range(n-k+1):
    res += a[i] * scipy.misc.comb(n-i-1, k-1, exact = True)

a.reverse()
for i in range(n-k+1):
    res -= a[i] * scipy.misc.comb(n-i-1, k-1, exact = True)

print(res%MOD)


### FIXED CODE ###

import sys
from math import factorial
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n, k = MAP()
a = LIST()

def mpow(a, n):
    if n == 0:return 1
    if n == 1:return a%MOD
    if n%2 == 1:return (a%MOD * mpow(a, n-1)%MOD)%MOD
    t = mpow(a, n//2)
    return (t*t)%MOD

fac = [1]*(n+1)
inv_fac = [1]*(n+1)
for i in range(n):
    fac[i+1] = (fac[i]*(i+1))%MOD
inv_fac[n] = mpow(fac[n], MOD-2)
for i in range(n, 0, -1):
    inv_fac[i-1] = (inv_fac[i]*i)%MOD

def cmb(n, r):
    if n == 0 and r == 0:return 1
    if n<r or n<0:return 0
    return (fac[n]*(inv_fac[r]*inv_fac[n-r])%MOD)%MOD
 
a.sort(reverse = True)
res = 0
for i in range(n-k+1):
    res += (a[i]*cmb(n-i-1, k-1))%MOD
    res = res%MOD
 
a.reverse()
for i in range(n-k+1):
    res -= (a[i]*cmb(n-i-1, k-1))%MOD
    res = res%MOD
 
print(res)
a,b,c = map(int,input().split())

if (a==b && a!=c) || (a==c&&a!=b) ||(b==c&&b!=a):
    print('yes')
else:
    print('no')

### FIXED CODE ###

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

if (a==b and a!=c) or (a==c and a!=b) or (b==c and b!=a):
    print('Yes')
else:
    print('No')
s=input()
for i in range(1,4):
  if s[i]==s[i-1]:
    print("Bad")
    return
print("Good")

### FIXED CODE ###

a=input()
if a[0]==a[1] or a[1]==a[2] or a[2]==a[3]:
  print("Bad")
else:
  print("Good")
n,k = map(int ,raw_input().split(' '))
prices = map(int, raw_input().split(' ')
print sum(prices[:k])

### FIXED CODE ###

n,k = map(int ,raw_input().split(' '))
prices = map(int, raw_input().split(' '))
prices.sort()
print sum(prices[:k])
N = int(input())
a = list(N)
if N[0]==N[1]==N[2]==N[3] or N[0]==N[1]==N[2] or N[1]==N[2]==N[3]:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

N = input()
a = list(N)
if N[0]==N[1]==N[2]==N[3] or N[0]==N[1]==N[2] or N[1]==N[2]==N[3]:
    print('Yes')
else:
    print('No')
n,m=map(int,input().split())
b=[]
for i in range(n):
  b.append(input())
ans=[[0]*m for i in range(n)]
d=[-1,0,1]
for i in range(n):
  for j in range(m):
    if b[i][j]=='#':
      for x in d:
        for y in d:
          X=i+x
          Y=j+y
          if 0 <= X < n and 0 <= Y < m:
            ans[X][Y]+=1
import sys
for i in range(n):
  for j in range(m):
    if b[i][j]=='#':
      sys.stdout.write('#')
    else:
      sys.stdout.write(ans[i][j])
  sys.stdout.write('\n')

### FIXED CODE ###

n,m=map(int,input().split())
b=[]
for i in range(n):
  b.append(input())
ans=[[0]*m for i in range(n)]
d=[-1,0,1]
for i in range(n):
  for j in range(m):
    if b[i][j]=='#':
      for x in d:
        for y in d:
          X=i+x
          Y=j+y
          if 0 <= X < n and 0 <= Y < m:
            ans[X][Y]+=1
import sys
for i in range(n):
  for j in range(m):
    if b[i][j]=='#':
      sys.stdout.write('#')
    else:
      sys.stdout.write(str(ans[i][j]))
  sys.stdout.write('\n')
import io
import sys


def IN_S():
  return input()


def IN_I():
  return int(input())


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


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


test_str = '''
2000 3
'''


def MAIN():
  # T_IN()
  init()
  A()


def A():
  n, k = IN_L_I()

  for i in range(1, k + 1):
    blue = f(k, i)

    red = 0
    red += f(n - k, i - 1)
    red += f(n - k, i)
    red += f(n - k, i)
    red += f(n - k, i + 1)

    res = int((blue * red) % (10 ** 9 + 7))
    print(res)
  return None


def f(x: int, y: int):
  if x < y:
    return 0
  if x == y == 0:
    return 1
  if y < 1:
    return 0
  return f2(x - y, y)


def f2(x: int, y: int):
  return c(x + y - 1, y - 1)


def c(a: int, b: int):
  global hoge
  return hoge[a][b]


hoge = [[0 for i in range(4004)] for j in range(4004)]


def init():
  global hoge
  hoge[0][0] = 1
  for i in range(0, 4000):
    for j in range(0, i + 1):
      hoge[i + 1][j] += (hoge[i + 1][j] + hoge[i][j]) % (10 ** 9 + 7)
      hoge[i + 1][j + 1] += (hoge[i + 1][j + 1] + hoge[i][j]) % (10 ** 9 + 7)


MAIN()


### FIXED CODE ###

import io
import sys


def IN_S():
  return input()


def IN_I():
  return int(input())


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


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


test_str = '''
ABBA
'''

def MAIN():
  # T_IN()
  if A():
    print("Yes")
  else:
    print("No")
  quit()

def A():
  s = IN_S()
  l = list(STR_SPLIT(s, 1))
  l.sort()
  if len(l) == 4 and l[0] == l[1] and l[2] == l[3] and l[1] != l[2]:
    return True
  return False


MAIN()
L = readline()
m = {"1":"9","9","1"}:
res = [m.get(i,i) for i in L]
print "".join(L)

### FIXED CODE ###

n = list(raw_input())
for i in range(3):
    if n[i] == '1':
        n[i] = '9'
    else:
        n[i] = '1'
print(int(n[0]+n[1]+n[2]))
N = input()

for i in range(len(N) - 1, -1, -1):
    t = int(N[i])
    a, b = min(a + t, b + (t + 1)), min(a + (10 - t), b + (10 - (t + 1)))
print(min(a, b + 1))


### FIXED CODE ###

N = input()

N = '0' + N
result = 0
carry = 0
for i in range(len(N) - 1, 0, -1):
    c = int(N[i]) + carry
    n = int(N[i - 1])
    if c < 5 or (c == 5 and n < 5):
        result += c
        carry = 0
    else:
        result += 10 - c
        carry = 1
result += carry
print(result)
import sys
A,B,C,D = map(int, input().split())
if A+B+C+D==7:
    print("A+B+C+D=7")
    sys.exit()
if A-B+C+D==7:
    print("A-B+C+D=7")
    sys.exit()
if A+B-C+D==7:
    print("A+B-C+D=7")
    sys.exit()
if A+B+C-D==7:
    print("A+B+C-D=7")
    sys.exit()
if A-B-C+D==7:
    print("A-B-C+D=7")
    sys.exit()
if A-B+C-D==7:
    print("A-B+C-D=7")
    sys.exit()
if A-B-C+D==7:
    print("A-B-C+D=7")
    sys.exit()
if A-B-C-D==7:
    print("A-B-C-D=7")
    sys.exit()


### FIXED CODE ###

import sys
A,B,C,D = map(int, list(input()))
if A+B+C+D==7:
    print("{}+{}+{}+{}=7".format(A,B,C,D))
    sys.exit()
if A+B-C+D==7:
    print("{}+{}-{}+{}=7".format(A,B,C,D))
    sys.exit()
if A+B+C-D==7:
    print("{}+{}+{}-{}=7".format(A,B,C,D))
    sys.exit()
if A+B-C-D==7:
    print("{}+{}-{}-{}=7".format(A,B,C,D))
    sys.exit()
if A-B+C+D==7:
    print("{}-{}+{}+{}=7".format(A,B,C,D))
    sys.exit()
if A-B-C+D==7:
    print("{}-{}-{}+{}=7".format(A,B,C,D))
    sys.exit()
if A-B+C-D==7:
    print("{}-{}+{}-{}=7".format(A,B,C,D))
    sys.exit()
if A-B-C-D==7:
    print("{}-{}-{}-{}=7".format(A,B,C,D))
    sys.exit()
import sys
n=int(input())
s=input()
t=input()
if s == t:
  print len(s)
  sys.exit()
for i in range(1,n):
  tmp=s+t[-1*i:]
  if tmp[-n:] == t:
    print n+i
    sys.exit()


### FIXED CODE ###

import sys
n=int(input())
s=input()
t=input()
if s == t:
  print(n)
  sys.exit()
for i in range(1,n+1):
  tmp=s+t[-1*i:]
  if tmp[-n:] == t:
    print(n+i)
    sys.exit()
n = int(input())
a = list(map(int, input().split()))
x = 0
y = 0
z = 0
ans = 1 
for i in range(n): #1文字目
  if a[i] == x:
    x = x + 1
    if x-1 == y:
      if x-1 == z:
        ans = ans * 3
      else:
        ans = ans * 2
  elif a[i] == y:
    y = y + 1
    if y-1 == z:
      ans = ans * 2
  else:
  	z = z + 1
print(ans % 1000000007)

### FIXED CODE ###

# -*- coding: utf-8 -*-
m_1, d_1 = map(int, input().split())
m_2, d_2 = map(int, input().split())

if m_1 == m_2:
  print(0)
else:
  print(1)
a,b,k=list(map(int ,input().split()))
l=[]
count=0
for i in range(1,max(a,b)):
	if(a%i==0 and b%i==0):
		l.append(i)
		
		
	
	else:
		count+=1

l.sort()
l.reverse()
if(a==b==k):
	print(a)
else:
	print(l[k-1])


### FIXED CODE ###

A,B,K=map(int,input().split())
ans=0
n=100
while True:
    if A%n==0 and B%n==0:
        ans+=1
        if ans==K:
            print(n)
            exit()
    n-=1
n = int(input())
    sols = []
    for i in range(n):
        sols.append([int(i) for i in input().split()])
    if len(sols) == 1:
        print(*sols[0])
        return
 
    for cx in range(0, 101):
        for cy in range(0, 101):
            lastH = None
            for x, y, h in sols:
                H = h + abs(x - cx) + abs(y - cy)
                if H < 1:
                    continue
                if lastH:
                    if H != lastH:
                        break
                lastH = H
            else:
                print(cx, cy, H)
                break

### FIXED CODE ###

n = int(input())
s_list = []
ans = 0
zero_list = []
for _ in range(n):
    x, y, s = map(int, input().split())
    if s > 0:
        s_list.append([x, y, s])
    else:
        zero_list.append([x, y, s])
for x in range(101):
    for y in range(101):
        t = []
        for i in range(len(s_list)):
            x_, y_, h = s_list[i]
            if h > 0:
                t.append(h + abs(x_ - x) + abs(y_ - y))
        if (len(set(t)) == 1):
            if len(zero_list) > 0:
                zero_p = max([list(t)[0] - abs(x - x_zero) - abs(y - y_zero) for (x_zero, y_zero, s_zero) in zero_list])
                if zero_p <= 0:
                    ttt = h + abs(x_ - x) + abs(y_ - y)
                    ans = str(x) + " " + str(y) + " " + str(ttt)
                    break
            else:
                ttt = h + abs(x_ - x) + abs(y_ - y)
                ans = str(x) + " " + str(y) + " " + str(ttt)
                break
                
print(ans)
n = input()
n.sort()
print(int(n[2])-int(n[0]))

### FIXED CODE ###

n = list(map(int,input().split()))
n.sort()
print(n[2]-n[0])
a,b,c,d,e,f=map(int,input().split())
able_water=[]
for na in range(1+f//(a*100)):
  for nb in range(1+(f-na*a*100)//(b*100)):
    water=na*a*100+nb*b*100
    if water<=f:
      able_water.append(water)
able_water.sort()
import bisect
ans=[0,0,0]
max_s=f//100*e
for nd in range(1+max_s//d):
  for nc in range(1+(max_s-nd*d)//c):
    sugger=nc*c+nd*d
    min_water=sugger*100/e
    if min_water>f-sugger:continue
    idx=bisect.bisect_left(able_water,min_water)
    if idx and able_water[idx]+sugger<=f:
      if ans[0]<(100*sugger/(able_water[idx]+sugger)):
        ans=[100*sugger/(able_water[idx]+sugger),able_water[idx]+sugger,sugger]
print(ans[1],ans[2])

### FIXED CODE ###

a,b,c,d,e,f=map(int,input().split())
able_water=[]
for na in range(1+f//(a*100)):
  for nb in range(1+(f-na*a*100)//(b*100)):
    water=na*a*100+nb*b*100
    if water and water<=f:
      able_water.append(water)
able_water.sort()
import bisect
ans=[0,0,0]
max_s=(f*e+100-1)//100
for nd in range(1+max_s//d):
  for nc in range(1+(max_s-nd*d)//c):
    sugger=nc*c+nd*d
    min_water=(sugger*100+e-1)//e
    if min_water+sugger>f:continue
    idx=bisect.bisect_left(able_water,min_water)
    if idx <len(able_water) and able_water[idx]+sugger<=f:
      if ans[0]<=(100*sugger/(able_water[idx]+sugger)):
        ans=[100*sugger/(able_water[idx]+sugger),able_water[idx]+sugger,sugger]
print(ans[1],ans[2])
import sys
import fractions
input = sys.stdin.readline

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

n = fractions.gcd(A, B)
if n == 1:
    print(1)
    sys.exit()


def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = {2}
    limit = int(n**0.5)
    data = {i + 1 for i in range(2, n, 2)}
    while True:
        p = data[0]
        if limit <= p:
            return prime | data
        prime.add(p)
        data = {e for e in data if e % p != 0}


p = set(get_sieve_of_eratosthenes(n))
count = sum([1 for i in p if not n % i])

print(count + 1)


### FIXED CODE ###

import sys
import fractions
input = sys.stdin.readline

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

n = fractions.gcd(A, B)
if n == 1:
    print(1)
    sys.exit()


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


a = {x[0] for x in factorization(A)}
b = {x[0] for x in factorization(B)}

print(len(a & b) + 1)
import sys

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

for a in A:
  if a in dict.keys():
    dict[a] = dict[a] + 1
  else:
    dict[a] = 1

if len(list(dict.keys())) > 3:
  print('No')
  sys.exit()

keys=list(dict.keys())
vals=set(dict.values())

if len(vals)> 1:
  print('No')
  sys.exit()
  
a0=keys[0]
a1=keys[1]
a2=''
b0=bin(a0)[2:]
b1=bin(a1)[2:]
if len(b0)<len(b1):
  b0,b1=b1,b0
b1=b1.zfill(len(b0))
for s0,s1 in zip(b0,b1):
  a2 = a2 + str( int(s0)^int(s1) )
a2=int(a2,2)

if a2!=keys[2]:
  print('No')
  sys.exit()

print('Yes')

### FIXED CODE ###

import sys

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

for a in A:
  if a in dict.keys():
    dict[a] = dict[a] + 1
  else:
    dict[a] = 1

if len(list(dict.keys())) > 3:
  print('No')
  sys.exit()
elif len(list(dict.keys()))==1:
  keys=list(dict.keys())
  if keys[0]==0:
    print('Yes')
    sys.exit()
  else:
    print('No')
    sys.exit()
elif len(list(dict.keys()))==2:
  keys=list(dict.keys())
  a0=keys[0]
  a1=keys[1]
  a2=''
  b0=bin(a0)[2:]
  b1=bin(a1)[2:]
  if len(b0)<len(b1):
    b0,b1=b1,b0
  b1=b1.zfill(len(b0))
  for s0,s1 in zip(b0,b1):
    a2 = a2 + str( int(s0)^int(s1) )
  a2=int(a2,2)
  #print(a0,a1,a2)
  if a2==a0 or a2==a1:
    vals=list(dict.values())
    if vals[0]/2==vals[1] or vals[0]==vals[1]/2:
      print('Yes')
      sys.exit()
    else:
      print('No')
      sys.exit()
  
keys=list(dict.keys())
vals=set(dict.values())

if len(vals)> 1:
  print('No')
  sys.exit()
  
a0=keys[0]
a1=keys[1]
a2=''
b0=bin(a0)[2:]
b1=bin(a1)[2:]
if len(b0)<len(b1):
  b0,b1=b1,b0
b1=b1.zfill(len(b0))
for s0,s1 in zip(b0,b1):
  a2 = a2 + str( int(s0)^int(s1) )
a2=int(a2,2)

if a2!=keys[2]:
  print('No')
  sys.exit()

print('Yes')
N = input()
remainder = N % 1000
if remainder == 0:
  print(0)
else:
  print(1000 - remainder)

### FIXED CODE ###

N = int(input())
remainder = N % 1000
if remainder == 0:
  print(0)
else:
  print(1000 - remainder)
# D - Integer Cards

from operator import itemgetter

N, M = map(int, input().split())
A = sorted([int(a) for a in input().split()])

B = [0] * M
C = [0] * M
for i in range(M):
    B[i], C[i] = map(int, input().split())

D = []
for _ in range(M):
    i = C.index(min(C))
    c = C.pop(i)
    b = B.pop(i)
    for j in range(b):
        D.append(c)

for i in range(N):
    if A[i] <= D[-1]:
        A[i] = D.pop()

print(sum(A))


### FIXED CODE ###

# D - Integer Cards

from operator import itemgetter

N, M = map(int, input().split())
A = sorted([int(a) for a in input().split()])

BC = []
for i in range(M):
    b, c = map(int, input().split())
    BC.append([b, c])

BC = sorted(BC, key=itemgetter(1), reverse=True)

ans = 0
for i in range(N):
    if len(BC) != 0 and A[i] <= BC[0][1]:
        ans += BC[0][1]
        BC[0][0] -= 1
        if BC[0][0] == 0:
            BC.pop(0)
    else:
        ans += A[i]

print(ans)