Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

N, M = map(int, input().split())

AB = {}
for _ in range(N):
    a, b = map(int, input().split())
    if a in AB:
        AB[a].append(b)
    else:
        AB[a] = [b]

count = 0
current = []

for day in range(1, M + 1):
    if day in AB:
        current.extend(AB[day])
        current.sort(reverse=True)

    #print("day{}:{}".format(day, current))
    if len(current) != 0:
        count += current.pop(0)

print(count)




### FIXED CODE ###

import heapq
N, M = map(int, input().split())

AB = {}
for _ in range(N):
    a, b = map(int, input().split())
    if a in AB:
        AB[a].append(b)
    else:
        AB[a] = [b]

count = 0
current = []

for day in range(1, M + 1):
    if day in AB:
    	for work in AB[day]:
            heapq.heappush(current, -work)

    #print("day{}:{}".format(day, current))
    if len(current) > 0:
        count += -heapq.heappop(current)

print(count)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
from decimal import Decimal
from itertools import permutations

# 整数の入力
N = int(input())

# スペース区切りの整数の入力
V = list(map(Decimal, input().split()))

result = 0

for values in permutations(V, N):
    new_result = values[0]

    for value in values[1:]:
        new_result = (new_result + value) / 2

    if result < new_result:
        result = new_result

# 出力
print(result)


### FIXED CODE ###

# -*- coding: utf-8 -*-
from decimal import Decimal
from itertools import permutations

# 整数の入力
N = int(input())

# スペース区切りの整数の入力
V = list(map(Decimal, input().split()))

result = 0

V = sorted(V)
result = V[0]

for value in V[1:]:
    result = (result + value) / 2


# 出力
print(result)
### BUGGY CODE ###

import sys
input=sys.stdin.readline
n,k=map(int,input().split())
l=[0]*n
c=0
for i in range(n):
    l[i]=int(input())
    if l.count(l[i])>=k:
        print(0)
        c=1
if c==0:
    l.sort()
    print(l[k-1]-l[0])

### FIXED CODE ###

# coding: utf-8
# Your code here!
n,k=map(int,input().split())
h=[]
for i in range(n):
    h.append(int(input()))
ans=10**10
c=0
h.sort()
for i in range(n-k+1):
    c=h[i+k-1]-h[i]
    if c<ans:
        ans=c
print(ans)
### BUGGY CODE ###

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
S = str(input())

cnt = 0
cnt_str = {
    "R" :0,
    "G" : 0,
    "B" : 0
}
for i in range(N):
    cnt_str[S[i]] += 1

cnt += cnt_str["R"] * cnt_str["G"] * cnt_str["B"]
# print(cnt)
for i in range(1, N + 1):
    for j in range(i + 1, N + 1):
        k = 2 * j - i
        if k > N:
            continue
        if S[i - 1] == S[j - 1] or S[j-1] == S[k-1] or S[i -1] == S[k-1]:
            pass
        else: # 数えられているもので条件2に反するものを引く
            cnt -= 1

print(cnt)



### FIXED CODE ###

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
S = str(input())

cnt = 0
cnt += S.count("R") * S.count("G") * S.count("B")

# for i in range(1, N - 1):
#     for j in range(i + 1, N):
#         k = 2 * j - i
#         if k > N :
#             continue
#         if S[i - 1] != S[j - 1] and S[j-1] != S[k-1] and S[i -1] != S[k-1]:
#             cnt -= 1

for k in range(N):
    for j in range(k):
        i = 2 * j - k
        if i < 0:
            continue
        if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
            cnt -= 1 

print(cnt)
### BUGGY CODE ###

N,M=[int(i) for i in input().split()]
a=[]
b=[]
c=[]
flag=0
for i in range(M):
    x,y=map(int,input().split())
    a.append(x)
    b.append(y)
    if x==1:
        c.append(y)
for i in range(M):
    if b[i]==N:
        if a[i] in c:
            flag=1
if flag==0:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")


### FIXED CODE ###

N,M=[int(i) for i in input().split()]
a=[]
b=[]
c=[]
for i in range(M):
    x,y=[int(i) for i in input().split()]
    if x==1 :
        c.append(y)
    if y==N:
        c.append(x)
if len(c)==len(set(c)):
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")
### BUGGY CODE ###

import math
import itertools
import bisect
import sys
input = sys.stdin.readline


# 素数判定
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []
    time = 0

    while True:
        prime = min(A)

        if prime > math.sqrt(limit):
            break

        P.append(prime)

        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
    for a in A:
        P.append(a)

    return P

q=int(input())
s= [list(map(int, input().split())) for i in range(q)]
v=eratosthenes(pow(10,5))
ans=[]
for i in range(len(v)):
    x=(v[i]+1)//2
    index = bisect.bisect_left(v, x)
    if v[index]==x:
        ans.append(v[i])

for i,j in s:
    r = bisect.bisect_left(ans, j+1)
    l = bisect.bisect_left(ans, i-1)
    print(r-l)


### FIXED CODE ###

import itertools
from itertools import accumulate

q=int(input())
x=[list(map(int, input().split())) for i in range(q)]
s=[0]*(1+10**5)
#素数のリスト
n = 10**5
primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes=list(primes)

primes.sort()
for i in range(len(primes)):
    if primes[i]>5*10**4:
        break
    primes.append(2*primes[i])

primes.sort()
count=0
for i in range(len(primes)-1):
    if primes[i+1]-primes[i]==1 and primes[i+1]%2==0:
        s[primes[i]]=1
s=itertools.accumulate(s)
s=list(s)
a=0
b=0
for i in range(q):
    print(s[x[i][1]]-s[x[i][0]-1])
### BUGGY CODE ###

s=input()[::-1]
if s[0]=="?":
    p=[1]*10+[0]*3
else:
    p=[0]*13
    p[int(s[0])]=1
q=10
for i in s[1:]:
    if i!="?":
        i=int(i)
        s=q*i%13
        p=p[-s:]+p[:-s]
    else:
        d=[0]*13
        for j in range(10):
            s=q*j%13
            r=p[-s:]+p[:-s]
            d=[r[i]+d[i]for i in range(13)]
        p=d
    q=(q*10)%13
print(p[5]%(10**9+7))

### FIXED CODE ###

s=input()[::-1]
p=[1]+[0]*12
q=1
t=[[(i*k)%13 for i in range(10)]for k in range(13)]
for i in s:
    if i!="?":
        i=int(i)
        g=t[q][i]
        p=p[-g:]+p[:-g]
    else:
        d=[0]*13
        for j in t[q]:
            r=p[-j:]+p[:-j]
            d=[(r[i]+d[i])%(10**9+7)for i in range(13)]
        p=d
    q=(q*10)%13
print(p[5]%(10**9+7))
### BUGGY CODE ###

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

n = len(s)

d = set()
for i in range(n):
    for j in range(i+1, n+1):
        tmp = s[i:j]
        if len(tmp) > k:
            continue
        d.add(tmp)
a = sorted(list(d))
print(a[k-1])



### FIXED CODE ###

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

n = len(s)

d = set()
for i in range(n):
    for j in range(i+1, min(i+k+1,n+1)):
        tmp = s[i:j]
        d.add(tmp)
a = sorted(list(d))
print(a[k-1])
### BUGGY CODE ###

from sys import stdin
from collections import deque

N, Q = [int(x) for x in stdin.readline().rstrip().split()]
S = stdin.readline().rstrip()
lr_list = [list(map(int, stdin.readline().rstrip().split())) for _ in range(Q)]


for l, r in lr_list:
    stack = deque([])
    S2 = S[l-1:r]
    count = 0
    #print(S2)
    flg = False
    for s in S2:
        if s == "A":
            flg = True
        elif s == "C" and flg:
            count += 1
            flg = False
        else:
            flg = False
    print(count)
        

### FIXED CODE ###

from sys import stdin
from collections import deque

N, Q = [int(x) for x in stdin.readline().rstrip().split()]
S = stdin.readline().rstrip()
lr_list = [list(map(int, stdin.readline().rstrip().split())) for _ in range(Q)]

#result_list = []
count = 0

result_list = deque([])

for i in range(N):
    result_list.append(count)
    if S[i] != "A":
        continue
    try:
        if S[i+1] == "C":
            count += 1
    except:
       pass

for l, r in lr_list:
    print(result_list[r-1] - result_list[l-1])
### BUGGY CODE ###

import collections
N = int(input())
L = [int(input()) for i in range(N)]
a = []
for i in L:
    if i in a:
        a.remove(i)
    else:
        a.append(i)
print(len(a))

### FIXED CODE ###

N = int(input())
L = [int(input()) for i in range(N)]
L.sort()
res = 0
i = 0
while i < len(L)-1:
    if L[i] == L[i+1]:
        res += 2
        i += 1
    i += 1
    
print(len(L)-res)
### BUGGY CODE ###

import itertools

N = int(input())
L = list(map(int, input().split()))

result = 0
for i in list(itertools.combinations(range(N),3)) :
  if L[i[0]] < L[i[1]] + L[i[2]] and L[i[1]] < L[i[0]] + L[i[2]] and L[i[2]] < L[i[1]] + L[i[0]] :
    result += 1

print(result)

### FIXED CODE ###

from bisect import bisect_left

N = int(input())
L = list(map(int, input().split()))
L.sort()

result = 0
for i in range(N) :
  for j in range(i+1,N) :
    result += bisect_left(L,L[i]+L[j]) - (j+1)

print(result)
### BUGGY CODE ###

#x,y,z = list(map(int,input().split()))
# k = int(input())

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

k = int(input())
ans = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        for kk in range(1,k+1):
            ans += gcd(i,j,kk)


print(ans)


### FIXED CODE ###

#x,y,z = list(map(int,input().split()))
# k = int(input())

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

k = int(input())
ans = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        for kk in range(1,k+1):
            ans += gcd(i,j,kk)


print(ans)
### BUGGY CODE ###

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

potentials = [i for i in a if i[1] == n]

for p in potentials:
    if [1, p[0]] in a:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")


### FIXED CODE ###

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

# n, m = 3, 2
# a = [[1, 2], [2, 3]]

pot_starts = []
pot_ends = []

for i in a:
    if i[0] == 1:
        pot_starts.append(i[1])
    elif i[1] == n:
        pot_ends.append(i[0])

if set(pot_starts).intersection(pot_ends):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
### BUGGY CODE ###

#!/usr/bin/env python3
# BFS
from collections import deque

x = int(input())
q = deque()
q.append((0, 0))
visited = []

while q:
    u = q.popleft()
    if u[0] == x:
        print(u[1])
        break
    visited.append(u)
    if ((u[0]-1, u[1]+1)) not in visited:
        q.append((u[0]-(u[1]+1), u[1]+1))
    if ((u[0], u[1]+1)) not in visited:
        q.append((u[0], u[1]+1))
    if ((u[0]+1, u[1]+1)) not in visited:
        q.append((u[0]+(u[1]+1), u[1]+1))

### FIXED CODE ###

#!/usr/bin/env python3

x = int(input())
t = 0
while True:
    if t*(t+1)/2 >= x:
        print(t)
        break
    t += 1
### BUGGY CODE ###

mod = int(1e9 + 7)
N = int(input())
A = list(map(int, input().split()))
S = 0
j = 1
while A != [0 for i in range(N)]:
  m = 0
  n = 0
  for i in range(N):
    if A[i] % 2 == 1:
      m += 1
    else:
      n += 1
    A[i] //= 2
  S += (m * n) * j
  S %= mod
  j *= 2
S %= mod
print(S)


### FIXED CODE ###

mod = int(1e9 + 7)
N = int(input())
A = [format(i, '060b') for i in map(int, input().split())]
S = 0
for k in range(60):
  s = [b[59-k] for b in A]
  v = s.count('0')*s.count('1')
  S += (v<<k)
S %= mod
print(S)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sun Apr 26 20:57:47 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

x = 2019
S = input()
l = len(S)
S = int(S)

a, b = [],[0]
s = 0
xx = [0 for _ in range(2019)]
xx[0] += 1
for i in range(l):
    s = (S%10**(i+1))
#    b.append(s % x)
    xx[s%x] += 1

ans = 0
#for i in range(len(b)):
#    xx[b[i]] += 1
def a(n):
    return n*(n+1)//2 

for i in range(len(xx)):
    if xx[i] > 1:
        ans += a(xx[i] - 1)

print(ans)


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sun Apr 26 20:57:47 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 2019

S = input()
l = len(S)
#S = int(S)

a, b = [],[0]
s = 0
xx = [0 for _ in range(2019)]
xx[0] += 1
for i in range(l):
    s += int(S[-i-1])*pow(10,i,mod)
    s %= mod
#    b.append(s % x)
    xx[s] += 1

ans = 0
#for i in range(len(b)):
#    xx[b[i]] += 1
def a(n):
    return n*(n+1)//2 

for i in range(len(xx)):
    if xx[i] > 1:
        ans += a(xx[i] - 1)

print(ans)
### BUGGY CODE ###

S = input()
N = int(input())
flg=False
for i in range(N):
	Q = input().split()
	if Q[0] == "1":
		if not flg:
			flg = True
		else:
			flg = False
	elif Q[0] == "2":
		if Q[1] == "1":
			if not flg:
				S = Q[2]+S
			else:
				S = S+Q[2]
		if Q[1] == "2":
			if flg:
				S = Q[2]+S
			else:
				S = S+Q[2]
if flg:
	S =S[::-1]
print(S)

### FIXED CODE ###

S = input()
N = int(input())
rev_flg=False
head = []
tail = []
for i in range(N):
	Q = input().split()
	if Q[0] == "1":
		if not rev_flg:
			rev_flg = True
		else:
			rev_flg = False
	elif Q[0] == "2":
		if Q[1] == "1":
			if not rev_flg:
				head.append(Q[2])
			else:
				tail.append(Q[2])
		if Q[1] == "2":
			if not rev_flg:
				tail.append(Q[2])
			else:
				head.append(Q[2])
S = "".join(head[::-1])+S+"".join(tail)
#print(head,tail)
#print(S)
if rev_flg:
	S =S[::-1]
print(S)
### BUGGY CODE ###

n = int(input())
list = [list(map(int,input().split())) for i in range(n)]

p = []

for i in list:
  p.append([i[0] - i[1],i[0] + i[1]])
  
p = sorted(p,key = lambda x: x[1])

ex = []
ex.append(p.pop(0))



for i in range(len(p)):
  if(ex[-1][1] <= p[0][0]):
    ex.append(p.pop(0))
  else:
    p.pop(0)

print(len(ex))

### FIXED CODE ###

from collections import deque

n = int(input())
list = [list(map(int,input().split())) for i in range(n)]

p = deque()

for i in list:
  p.append([i[0] - i[1],i[0] + i[1]])
  
p = sorted(p,key = lambda x: x[1])

ex = []
ex.append(p.pop(0))




for i in range(len(p)):
  if(ex[-1][1] <= p[0][0]):
    ex.append(p.pop(0))
  else:
    p.pop(0)

print(len(ex))
### BUGGY CODE ###

N=int(input())
P=list(map(int,input().split()))
count=1
for i in range(1,N):
    if(P[i]<min(P[0:i])):
        count+=1
    else:
        pass
print(count)

### FIXED CODE ###

N=int(input())
P=list(map(int,input().split()))
count=0
mini=P[0]
for i in range(N):
    if(P[i]<=mini):
        mini=P[i]
        count+=1
    else:
        pass
print(count)
### BUGGY CODE ###

from collections import defaultdict
S = input()
S = S[::-1]
d = 1
mods = [0]
counter = defaultdict(int)
counter[mods[-1]] += 1
for s in S:
  s = int(s)
  mods.append((mods[-1]+s*d)%2019)
  counter[mods[-1]] += 1
  d *= 10

print(sum([i*(i-1)//2 for i in counter.values()]))


### FIXED CODE ###

S = input()
S = S[::-1]
d = 1
mods = [0]
counter = [0]*2019
counter[0] += 1
result = 0
for s in S:
  s = int(s)
  mods.append((mods[-1]+s*d)%2019)
  counter[mods[-1]] += 1
  result += counter[mods[-1]] - 1
  d *= 10
  d %= 2019

print(result)
### BUGGY CODE ###


import sys
# import collections
# import math
# import string
# import bisect

def main():
    n, *parts = (int(x) for x in sys.stdin.read().split())
    uppers, middles, lowers = (sorted(parts[n*i:n*(i+1)], reverse=1) for i in range(3))

    count = 0
    for a in uppers:
        for b in middles:
            if a >= b: break
            else:
                for c in lowers:
                    if b >= c: break
                    else: count += 1
    print(count)

if __name__ == "__main__":
    main()


### FIXED CODE ###


import sys
# import collections
# import math
# import string
import bisect

def main():
    n, *parts = (int(x) for x in sys.stdin.read().split())
    uppers, middles, lowers = (parts[n*i:n*(i+1)] for i in range(3))
    uppers.sort()
    lowers.sort()

    count = 0
    for j in middles:
        i = bisect.bisect_left(uppers, j)
        k = len(lowers) - bisect.bisect_right(lowers, j)
        count += i * k
        
    print(count)

if __name__ == "__main__":
    main()
### BUGGY CODE ###

import copy
from collections import deque
from itertools import combinations

H, W = map(int, input().split())
field_s = []

# フィールドを作る
for h in range(H + 2):
    field_s.append(["#"] * (W + 2))
    if 1 <= h <= (H):
        field_s[h][1:-1] = list(map(str, input().rstrip()))

#　動き方のセットを準備
moves = [[1, 0], [-1, 0], [0, 1], [0, -1]]

# スタートとゴールの座標の組み合わせを作成
sg = []
for y in range(H + 2):
    for x in range(W + 2):
        if field_s[y][x] == ".":
            sg.append([y, x])

# 答え
ans = 0

# スタートとゴールの座標を組み合わせてぐるぐる
for s, g in list(combinations(sg, 2)):

    # startとgoalの座標が同じならスキップ
    if s == g:
        continue

    # fieldの初期化
    field = copy.deepcopy(field_s)

    # startをキューに追加
    que = deque([s])

    # startの距離は0に
    field[s[0]][s[1]] = 0

    # キューに何かがある限り探索を続ける
    while que:
        c = que.popleft()

        # 今の距離
        dist = field[c[0]][c[1]]

        # 動いた先が「.」なら、距離を記録してキューに追加
        for m in moves:
            my = c[0] + m[0]
            mx = c[1] + m[1]

            if field[my][mx] == ".":
                field[my][mx] = dist + 1
                que.append([my, mx])
            else:
                continue

            # もしゴールに到達していたらansを差し替えてbreak
            if [my, mx] == g:
                ans = max(ans, field[my][mx])
                break

print(ans)

### FIXED CODE ###

import copy
from collections import deque

H, W = map(int, input().split())
field_s = []

# フィールドを作る
for h in range(H + 2):
    field_s.append(["#"] * (W + 2))
    if 1 <= h <= (H):
        field_s[h][1:-1] = list(map(str, input().rstrip()))

#　動き方のセットを準備
moves = [[1, 0], [-1, 0], [0, 1], [0, -1]]

# スタート座標を取得
start = []
for y in range(1, H + 1):
    for x in range(1, W + 1):
        if field_s[y][x] == ".":
            start.append([y, x])

# 答え
ans = 0

for s in start:

    # fieldの初期化
    field = copy.deepcopy(field_s)

    # startをキューに追加
    que = deque([s])

    # startの距離は0に
    field[s[0]][s[1]] = 0

    # キューに何かがある限り探索を続ける
    while que:
        c = que.popleft()

        # 今の距離
        dist = field[c[0]][c[1]]

        # 動いた先が「.」なら、距離を記録してキューに追加
        for m in moves:
            my = c[0] + m[0]
            mx = c[1] + m[1]

            if field[my][mx] == ".":
                field[my][mx] = dist + 1
                que.append([my, mx])
            else:
                continue
    
    # キューを消化したら最大値を取り出す
    field = sum(field, [])
    ans = max(ans, max([x for x in field if type(x)==int]))

print(ans)
### BUGGY CODE ###

import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
n=int(input())
a=list(map(int,input().split()))
b=0
l=lcm_list(a)
for i in range(n):
    b+=l//a[i]
print(b%(10**9+7))

### FIXED CODE ###

import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
n=int(input())
a=list(map(int,input().split()))
b=0
l=lcm_list(a)
for i in range(n):
    b+=l//a[i]
print(b%(10**9+7))
### BUGGY CODE ###

from collections import Counter

def main():
    N, *A = map(int, open(0).read().split())

    ctr = Counter(A)
    memo = set()
    ans = 0

    for a in sorted(A):
        if a == 1:
            if ctr[a] == 1:
                ans = 1
            break

        if ctr[a] == 1:
            for i in range(1, int(a ** 0.5) + 1):
                if a % i == 0 and ((i in memo) or (a // i in memo)):
                    break
            else:
                ans += 1

        memo.add(a)

    print(ans)

    
if __name__ == "__main__":
    main()
    

### FIXED CODE ###

from collections import Counter

N, *A = map(int, open(0).read().split())

m = max(A) + 1
ok = [True] * m
ctr = Counter(A)
ans = 0
for a in sorted(A):
    if ok[a] and ctr[a] == 1:
        ans += 1
        
    for j in range(2 * a, m, a):
        ok[j] = False
            
print(ans)
### BUGGY CODE ###

N = int(input())

import math

def num_pair(n):
  res = 2 # 1 x n, n x 1
  for i in range(2, int(math.sqrt(n)) + 1):
    if n % i == 0:
      res += 2
  if int(math.sqrt(n)) ** 2 == n:
    res -= 1
  return res

# a x b + c == n
# n - c == a x b

res = 0
for i in range(1, N):
  res += num_pair(i)

print(res)

### FIXED CODE ###

N = int(input())

def num_divisors_table(n):
  table = [0] * (n + 1)
  for i in range(1, n + 1):
    for j in range(i, n + 1, i):
      table[j] += 1
  return table

table = num_divisors_table(1000000)

# a x b + c == n
# n - c == a x b

res = 0
for i in range(1, N):
  res += table[i]

print(res)
### BUGGY CODE ###

n = int(input())
L = list(map(int,input().split()))
L = sorted(L,reverse=True)
total = 0
for i in range(0,n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if L[j] + L[k] > L[i]:
                total += 1
            else:
                continue
print(total)


### FIXED CODE ###

import bisect

n = int(input())
L = list(map(int,input().split()))
L = sorted(L)
ans = 0

for i in range(n-1):
    for j in range(i+1,n):
        limit = L[i]+L[j]
        ans += bisect.bisect_left(L,limit) - (j+1)

print(ans)
### BUGGY CODE ###

N,K = map(int,input().split())
S = list(map(int,input()))
blobs = []
if S[0] == 0:
    blobs.append(0)
cnt = 0
past_i = 0
for i in range(len(S)):
    if i == 0:
        past_i = S[i]
    if past_i == S[i]:
        cnt += 1
        past_i = S[i]
        
    else:
        blobs.append(cnt)
        cnt = 1
        past_i = S[i]
    if i == len(S)-1:
        blobs.append(cnt)

if S[-1] == 0:
    blobs.append(0)
sums = []
len_blobs = len(blobs)

# 
for i in range(len(blobs)//2-min(K,len_blobs//2)+1):
    temp_sum = sum(blobs[2*i:2*(i+K)+1])
    sums.append(temp_sum)
    if temp_sum == N:
        break
print(max(sums))

### FIXED CODE ###

N,K = map(int,input().split())
S = input()
one = [0]
zero = [0]
if S[0] == '0':
    one.append(0)
cnt = 1
for i in range(1,len(S)):
    if S[i] != S[i-1]:
        if S[i-1] == '1':
            one.append(cnt+one[-1])                
        else:
            zero.append(cnt+zero[-1])                
        cnt = 1
    else:
        cnt += 1
else:
    if S[-1] == '1':
        one.append(cnt+one[-1])                
    else:
        zero.append(cnt+zero[-1])                
        one.append(one[-1])                
window_size = min(len(zero)-1,K)
MAX = 0
for i in range(len(zero)-window_size):
    if MAX < (zero[i+window_size] - zero[i]) + (one[i+window_size+1] - one[i]):
        MAX = (zero[i+window_size] - zero[i]) + (one[i+window_size+1] - one[i])

print(MAX)
### BUGGY CODE ###

n,m=map(int,input().split())
a=[int(i) for i in input().split()]

for i in range(m):
 a.sort()
 b,c=map(int, input().split())
 for i in range(b):
  if a[i] < c:
   a[i] = c
  else:
   break
print(sum(a))

### FIXED CODE ###

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

s = sorted(l, key=lambda x:x[0], reverse=True)

c=n
t=0
i=0
while c>0:
  n = s[i][1] if c>=s[i][1] else c
  t += s[i][0] * n
  c -= n
  i += 1

print(t)