Harryxun/stf_run huggingface dataset:
n = int(input())
a_list = list(map(int,input().split()))
ans_list = []
for i in range(len(a_list)):
    ans_list.append(a_list[i] - i - 1)
import numpy as np
if len(ans_list)% 2 == 0:
    cary = np.delete(ans_list, min(ans_list))
    
else:
    cary = ans_list
number = int(np.median(cary))
ans = 0
for i in ans_list:
    ans += abs(i - number)
print(ans)


### FIXED CODE ###

n = int(input())
a_list = list(map(int,input().split()))
ans_list = []
for i in range(len(a_list)):
    ans_list.append(a_list[i] - i - 1)
import numpy as np
if len(ans_list)% 2 == 0:
    ans_list1 = sorted(ans_list)
    number1 = ans_list1[n//2]
    number2 = ans_list1[n//2 + 1]
    
    ans1 = 0
    ans2 = 0
    for i in ans_list:
        ans1 += abs(i - number1)
        ans2 += abs(i - number2)
    print(min(ans1 , ans2))
else:
    cary = ans_list
    number = int(np.median(cary))
    ans = 0
    for i in ans_list:
        ans += abs(i - number)
    print(ans)
import math
while True:
    n = int(input())
    score = [ int(i) for i in input().split(" ") ] 
    average = sum(score) / n
    if n == 0:
        break
    a2 = 0
    for s in score:
        a2 += (s - average) ** 2

    print("{:.8f}".format(math.sqrt(a2) / n ) )

### FIXED CODE ###

import math
while True:
    n = int(input())
    if n == 0:
        break
    s = [int(i) for i in input().split(" ")]
    m = sum(s) / n
    print("{:.8f}".format(math.sqrt(sum([(x-m) ** 2 for x in s]) / n)))
import bisect
    
    n = int(input())
    length = list(map(lambda x:int(x), input().split()))
    length.sort()
    ans = 0
    for i in range(n):
        a = length[i]
        for j in range(n):
            b = length[j]
            if i >= j:
                continue
            else:
                c_candidates = length[j+1:]
                min_bar = bisect.bisect_right(c_candidates,max(a-b, b-a))
                max_bar = bisect.bisect_left(c_candidates,a+b)
                ans += max_bar - min_bar
                
    print(ans)

### FIXED CODE ###

import bisect

n = int(input())
#length = list(map(lambda x:int(x), input().split()))
length = list(map(int, input().split()))
length.sort()
ans = 0
for i in range(n-2):  
    a = length[i]
    for j in range(i+1,n-1):
        b = length[j]
        if i >= j:
            continue
        else:
            max_bar = bisect.bisect_left(length,a+b)
            ans += max_bar - j - 1
            
print(ans)
N = map(int,input().split())
S = str(input().split())
i = 0
count = 0
for i in range(N-1):
  if S[i] == "A" and S[i+1] == "B" and S[i+2] == "C":
    count += 1
print(count)

### FIXED CODE ###

N = int(input())
S = str(input())
i = 0
count = 0
for i in range(N-2):
  if S[i] == "A" and S[i+1] == "B" and S[i+2] == "C":
    count += 1
print(count)
import itertools

n,y = map(int,input().split())
a = [1000,5000,10000]
l = list(itertools.product(a,repeat = n))
print(l)

for i in range(len(l)):
    if sum(l[i]) == y:
        o = l[i].count(10000)
        p = l[i].count(5000)
        q = l[i].count(1000)
        print(o + ' ' + p + ' ' + q)
        exit(0)

print('-1 -1 -1')

### FIXED CODE ###

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

for i in range(0,n+1):
    for j in range(0,n+1-i):
        k = max(0,n-i-j)
        if 10000*i + 5000*j + 1000*k == y:
            print(i,j,k)
            exit(0)

print(-1,-1,-1)
a = input()
b = input()
c = input()
A, B, C = len(a), len(b), len(c)
ab, bc, ac = [1] * 12000, [1] * 12000, [1] * 120000

for i in range(A):
    if a[i] == '?':
        continue
    for j in range(B):
        if b[j] == '?':
            continue
        if a[i] != b[j]:
            ab[i-j+6000]= 0
for i in range(B):
    if b[i] == '?':
        continue
    for j in range(C):
        if c[j] == '?':
            continue
        if b[i] != c[j]:
            bc[i-j+6000]= 0
for i in range(A):
    if a[i] == '?':
        continue
    for j in range(C):
        if c[j] == '?':
            continue
        if a[i] != c[j]:
            ac[i-j+6000]= 0
ans = 6000

for i in range(-4000, 4000):
    for j in range(-4000, 4000):
        if ab[i+6000] and bc[j-i+6000] and ac[j+6000]:
            L = min(0, min(i, j))
            R = max(A, max(B+i, C+j))
            ans = min(ans, R-L)
print(ans)    

### FIXED CODE ###

a = input()
b = input()
c = input()
A, B, C = len(a), len(b), len(c)
ab, bc, ac = [1] * 16000, [1] * 16000, [1] * 16000

for i in range(A):
    if a[i] == '?':
        continue
    for j in range(B):
        if b[j] != '?' and a[i] != b[j]:
            ab[i-j+8000]= 0
for i in range(B):
    if b[i] == '?':
        continue
    for j in range(C):
        if c[j] != '?' and b[i] != c[j]:
            bc[i-j+8000]= 0
for i in range(A):
    if a[i] == '?':
        continue
    for j in range(C):
        if c[j] != '?' and a[i] != c[j]:
            ac[i-j+8000]= 0
ans = 6000

for i in range(-4000, 4000):
    for j in range(-4000, 4000):
        if ab[i+8000] and bc[j-i+8000] and ac[j+8000]:
            L = min(0, min(i, j))
            R = max(A, max(B+i, C+j))
            ans = min(ans, R-L)
print(ans)
# coding: utf-8
minutes = [int(input()) for _ in range(5)]
time=0
l=[]
 
for i in minutes:
    time = time + i
    if(i%10==0):
        l.append(0)
    else:
        l.append(10-i%10)
 
l.sort()
time += sum(l[:-1])
print(time)


### FIXED CODE ###

# coding: utf-8
n = int(input())

high = list(map(int, input().split()))
max_high = []
count =1

for i in range(1,n):
    x = high[:i]
    if(max(x) <= high[i]):
        count = count +1
        
print(count)
x = int(input())
h = x / 3600
m = (x % 3600) / 60
s = x - h*3600 - m*60
print(':'.join('h', 'm', 's')

### FIXED CODE ###

x = int(input())
a = x // 3600
b = x // 60 %60
c = x % 60

a = str(a)
b = str(b)
c = str(c)
print(":".join([a,b,c]))
a,b,c,d=map(int,input().split())

print(max(a*c,a*d,b*c

### FIXED CODE ###

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

print(max(a*c,a*d,b*c,b*d))
S = str(input())

amari = []
for i in range(len(S)+1):
    for j in range(i+4, len(S)+1):
        amari_tmp = int(S[i:j]) % 2019
        amari.append(amari_tmp)
        kosu = amari.count(0)

print(kosu)


### FIXED CODE ###

s=list(input())[::-1] # 10進数で位を上げていくために反転させる
n=len(s)
amari_lis=[0]*2019 # 
amari_lis[0]=1 # 2019で割り切れる場合、組合せ総数は (n+1)C2 となるため（その他はnC2でOK）

num=0
kurai=1
for keta in s:
    num+=int(keta)*kurai
    num%=2019
    amari_lis[num]+=1
    kurai*=10
    kurai%=2019 # amari_lisが 0~2019 のため、位の数も 2019 で割った余りで考える

ans=0
for i in amari_lis:
    ans+=i*(i-1)/2 # nC2の計算, 余りが同じものを引けば 0⇒2019で割れると言える（組合せ数を逐次追加することで総数算出）

print(int(ans))
x,n = map(int,input().split(' '))
p = [int(x) for x in input().split(' ')]

if n == 0:
    print(x)
else:
    s = set([x for x in range(102)])
    s -= set(p)
    for i in range(1,51):
        if x-i in s:
            print(x-i)
            break
        if x+i in s:
            print(x+i)
            break

### FIXED CODE ###

x,n = map(int,input().split(' '))

if n == 0:
    p = input()
    print(x)
else:
    p = [int(x) for x in input().split(' ')]
    s = set([x for x in range(102)])
    s -= set(p)
    for i in range(0,51):
        if x-i in s:
            print(x-i)
            break
        if x+i in s:
            print(x+i)
            break
if a == 22:
    print("Christmas Eve Eve Eve")
elif a == 23:
    print("Christmas Eve Eve")
elif a == 24:
    print("Christmas Eve")
elif a == 25:
    print("Christmas")

### FIXED CODE ###

D = int(input())
if D == 22:
    print("Christmas Eve Eve Eve")
elif D == 23:
    print("Christmas Eve Eve")
elif D == 24:
    print("Christmas Eve")
elif D == 25:
    print("Christmas")
import sys
sys.setrecursionlimit(100000)
input=sys.stdin.readline

n,q=map(int,input().split())
A=[[] for i in range(n)]
node=[0]*n

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

for i in range(q):
    p,x=map(int,input().split())
    node[p-1] +=x


def calculate(num,pre=-1):
    for i in A[num]:
        if i==pre:continue
        node[i] +=node[num]
        calculate(i,num)


calculate(0)
print(*node)

### FIXED CODE ###

# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

#n = int(input())
n,q = [int(i) for i in readline().split()]

g = [[] for _ in range(n)]
for i in range(n-1):
    a,b = [int(i) for i in readline().split()]
    g[a-1].append(b-1)
    g[b-1].append(a-1)

add = [0]*n
for _ in range(q):
    p,x = [int(i) for i in readline().split()]
    add[p-1] += x

ans = [0]*n
#ans[0] = add[0]

def dfs(v,p,value): #p: parent of v
    value += add[v]
    ans[v] = value
    for c in g[v]:
        if c == p: continue
        dfs(c,v,value)

dfs(0,-1,0)

#print(add)

print(*ans)
from collections import deque
H, W = map(int, input().split())
route = []
n_black = 0
for _ in range(H):
  tmp_ls = input()
  n_black += tmp_ls.count("#")
  route.append(tmp_ls)
visited = [[False]*W for _ in range(H)]
dist = [[-1]*W for _ in range(H)]
dist[0][0] = 0
tmp = [0,0]
goal = [H-1, W-1]
kouho = deque()
def rinsetsu(ls):
  x, y = ls[0], ls[1]
  ans = []
  if x-1 >= 0:
    ans.append([x-1, y])
  if x+1 <= H-1:
    ans.append([x+1, y])
  if y-1 >= 0:
    ans.append([x, y-1])
  if y+1 <= W-1:
    ans.append([x, y+1])
  return ans
for ls in rinsetsu([0,0]):
  if route[ls[0]][ls[1]] == ".":
    kouho.append([ls[0], ls[1], 0, 0])
def bfs():
  while True:
    while True:
      tmp = kouho.popleft()
      if not visited[tmp[0]][tmp[1]]:
        break
      if len(kouho) == 0:
        return
    x, y = tmp[0], tmp[1]
    visited[x][y] = True
    dist[x][y] = dist[tmp[2]][tmp[3]] + 1
    if [x, y] == goal:
      return
    for ls in rinsetsu([x,y]):
      if not visited[ls[0]][ls[1]] and route[ls[0]][ls[1]] == ".":
        kouho.append(ls + [x, y])
bfs()
if dist[H-1][W-1] == -1:
  print(-1)
else:
  white = dist[H-1][W-1] + 1
  print(H*W - white - n_black)



### FIXED CODE ###

from collections import deque
H, W = map(int, input().split())
route = []
n_black = 0
for _ in range(H):
  tmp_ls = input()
  n_black += tmp_ls.count("#")
  route.append(tmp_ls)
visited = [[False]*W for _ in range(H)]
dist = [[-1]*W for _ in range(H)]
dist[0][0] = 0
tmp = [0,0]
goal = [H-1, W-1]
kouho = deque()
def rinsetsu(ls):
  x, y = ls[0], ls[1]
  ans = []
  if x-1 >= 0:
    ans.append([x-1, y])
  if x+1 <= H-1:
    ans.append([x+1, y])
  if y-1 >= 0:
    ans.append([x, y-1])
  if y+1 <= W-1:
    ans.append([x, y+1])
  return ans
for ls in rinsetsu([0,0]):
  if route[ls[0]][ls[1]] == ".":
    kouho.append([ls[0], ls[1], 0, 0])
def bfs():
  while True:
    while True:
      if len(kouho) == 0:
        return
      tmp = kouho.popleft()
      if not visited[tmp[0]][tmp[1]]:
        break
    x, y = tmp[0], tmp[1]
    visited[x][y] = True
    dist[x][y] = dist[tmp[2]][tmp[3]] + 1
    if [x, y] == goal:
      return
    for ls in rinsetsu([x,y]):
      if not visited[ls[0]][ls[1]] and route[ls[0]][ls[1]] == ".":
        kouho.append(ls + [x, y])
bfs()
if dist[H-1][W-1] == -1:
  print(-1)
else:
  white = dist[H-1][W-1] + 1
  print(H*W - white - n_black)
import sys
input = sys.stdin.readline
import numpy as np
from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix

N, M, K  = (int(i) for i in input().split())
graph = np.zeros((N+1, N+1))
graph2 = [[0] * (N+1) for i in range(N+1)]

#ABC = [[int(i) for i in input().split()] for i in range(N)]
for i in range(M):
    A, B =  (int(i) for i in input().split())
    graph[A][B] = 1
    graph[B][A] = 1
    graph2[A][B] = 1
    graph2[B][A] = 1

for j in range(K):
    A, B =  (int(i) for i in input().split())
    graph2[A][B] = -1
    graph2[B][A] = -1

#graph = np.array(graph)
#print(graph)
#print(graph2)
n, labels = connected_components(graph)
size = [0]*n
for i in range(1, n):
    size[i] = np.count_nonzero(labels == i)
#print(n)
# 2
#print(labels)
#print(size)
for i in range(1, N+1):
    count = 0
    for j in range(1, N+1):
        if labels[j] == labels[i] and graph2[i][j] != 0:
            count += 1
    print(size[labels[i]]-count-1)


### FIXED CODE ###

import sys
input = sys.stdin.readline

class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * (n+1)

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

N, M, K  = (int(i) for i in input().split())

#graph = np.zeros((N+1, N+1))
#graph2 = [[0] * (N+1) for i in range(N+1)]
uf = UnionFind(N)
fblist = [0] * (N+1)

for i in range(M):
    A, B =  (int(i) for i in input().split())
    uf.union(A, B)
    fblist[A] += 1
    fblist[B] += 1
 
for j in range(K):
    A, B =  (int(i) for i in input().split())
    if uf.same(A, B):
        fblist[A] += 1
        fblist[B] += 1

for i in range(1, N+1):
    print(uf.size(i) - fblist[i] - 1, end=" ")

print()
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right
from heapq import heappush, heappop

import re
# import numpy as np
# from scipy.misc import comb

# 再帰がやばいとき
import sys
sys.setrecursionlimit(10**9)

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e30)
MOD = int(1e9)+7 # 10^9 + 7

# field[H][W]
def create_grid(H, W, value = 0):
    return [[ value for _ in range(W)] for _ in range(H)]

########

def main():
    N = i_inpl()
    a = list(range(1, N+1))
    P = a[1:] + [a[0]]
    ans = 0
    for ai, Pi in zip(a, P):
        ans += ai % Pi
    print(ans)
if __name__ == "__main__":
    main()


### FIXED CODE ###

import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right
from heapq import heappush, heappop

import re
# import numpy as np
# from scipy.misc import comb

# 再帰がやばいとき
import sys
sys.setrecursionlimit(10**9)

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e30)
MOD = int(1e9)+7 # 10^9 + 7

# field[H][W]
def create_grid(H, W, value = 0):
    return [[ value for _ in range(W)] for _ in range(H)]

########

def main():
    N = i_inpl()
    if N == 1:
        print(0)
        return
    print(((1+(N-1))*(N-1))//2)
if __name__ == "__main__":
    main()
from copy import *
from collections import*
n=int(input())
p=[list(map(int,input().split()))for i in range(n)]
l=[]
for i in range(n):
    q=deepcopy(p)
    a,b=q.pop(i)
#    print(a,q)
    l.extend([(s-a,t-b)for s,t in q])
print(n-(Counter(l).most_common()[0][1]+1)+1)

### FIXED CODE ###

from copy import *
from collections import*
n=int(input())
if n==1:
    print(1)
    exit()
p=[list(map(int,input().split()))for i in range(n)]
l=[]
for i in range(n):
    q=deepcopy(p)
    a,b=q.pop(i)
#    print(a,q)
    l.extend([(s-a,t-b)for s,t in q])
print(n-(Counter(l).most_common()[0][1]+1)+1)
s=str(input())
words=["dream", "dreamer", "erase", "eraser"]
N=max(len(words[0]),len(words[1]),len(words[2]),len(words[3]))
flag=0
while len(s)>=0:
  pos0=s[-N:].rfind(words[0])
  pos1=s[-N:].rfind(words[1])
  pos2=s[-N:].rfind(words[2])
  pos3=s[-N:].rfind(words[3])
  m=max(pos0,pos1,pos2,pos3)
  if m==-1:
    flag=1
    break
  else:
    pos=N-m
    s=s[:-pos]

if flag=1:
  print("NO")
else:
  print("YES")

### FIXED CODE ###

S=input()
Word = ['eraser','erase','dreamer','dream']
for i in Word:
  S=S.replace(i,'')
if len(S) == 0 :
  print('YES')
else :
  print('NO')
n = int(input())
alist=list(map(int,input().split()))
core = 0
for i in range(n-2):
  core +=min(alist[i],alist[i+1],alist[i+2])
print(core +min(alist[-2],alist[-1]) +alist[-1]) +min(alist[0],alist[1])

### FIXED CODE ###

n = int(input())
alist=list(map(int,input().split()))
alist.insert(0,1e7)
alist.append(1e7)
core = 0
for i in range(n):
  core +=min(alist[i],alist[i+1])
print(core)
n = int(input())
v = [int(_) for _ in input().split()]
cnt = 0
for i in range(2, n):
  if v[i-2] != v[i]:
    cnt += 1
print(cnt)

### FIXED CODE ###

N = int(input())
print(1110-N)
X, N = [int(x) for x in input().split()]


def main(X,N):
    if N == 0:
        return X
    arrp = [int(x) for x in input().split()]
    b = sorted(arrp)
    lists = []
    for x in range(b[0],b[-1]):
        if x not in arrp:
            a = abs(X-x)
            lists.append([a,x])
    return sorted(lists)[0][1]

print(main(X,N))



### FIXED CODE ###

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

def main(X, N):
    if N == 0:
        return X
    arrp = [int(x) for x in input().split()]
    minus = X
    plus = X
    while True:
        if minus not in arrp:
            print(minus)
            exit()
        if plus not in arrp:
            print(plus)
            exit()
        minus -= 1
        plus += 1

print(main(X, N))
def resolve():
    X, N = map(int, input().split())
    P = [int(input()) for _ in range(N)]
    if X in P:
        for j in range(N):
            if X+j in P:
                continue
            else:
                print(X+j)
                exit()
            if X-j in P:
                continue
            else:
                print(X-j)
                exit()
    else:
        print(X)
resolve()

### FIXED CODE ###

def resolve():
    X, N = map(int, input().split())
    if N != 0:
        P = list(map(int, input().split()))
        S = []
        for _ in range(0, 102):
            if _ in P:
                continue
            else:
                S.append(_)
        if X in S:
            print(X)
        else:
            for i in range(1, 102):
                if X-i in S:
                    print(X-i)
                    exit()
                elif X+i in S:
                    print(X+i)
                    exit()
    else:
        print(X)
resolve()
def f(a):
	s=0;q=[]
	for i in range(n):s+=a[i];heappush(q,a[i])
	r=[s]
	for i in range(n,2*n):s+=a[i];s-=heappushpop(q,a[i]);r+=[s]
	return r
import sys;from heapq import*;n,*a=list(map(int,sys.stdin.read().split()));print(max(x+y for x,y in zip(f(a),f(list(reversed(-e for e in a))))))

### FIXED CODE ###

import sys,heapq
n=int(sys.stdin.readline())
a=list(map(int,sys.stdin.readline().split()))
sa=sb=0
la=[]
lb=[]
for i in range(n):
	sa+=a[i]
	heapq.heappush(la,a[i])
ra=[sa]
for i in range(n,2*n):
	sa+=a[i]
	heapq.heappush(la,a[i])
	sa-=heapq.heappop(la)
	ra.append(sa)
for i in range(3*n-1,2*n-1,-1):
	sb+=a[i]
	heapq.heappush(lb,-a[i])
rb=[sb]
for i in range(2*n-1,n-1,-1):
	sb+=a[i]
	heapq.heappush(lb,-a[i])
	sb+=heapq.heappop(lb)
	rb.append(sb)
print(max(x-y for x,y in zip(ra,reversed(rb))))
a, b, k = input().split()
a = int(a)
b = int(b)
k = int(k)
for i in range(k):
  if a >= 1:
    a -= 1
  elif b >= 1:
    b -= 1
  else:
    continue
    
print("{} {}".format(a, b))

### FIXED CODE ###

s, t = input().split()

print("{}{}".format(t, s))
import sys
x=int(input())
div=[]
for i in range(1,int(x**0.5)+1):
  if x%i==0:
    div.append(i)
    if i != n // i:
      div.append(n//i)
div.sort()
div.reverse()
for i in div:
  for j in range(100000):
    a=i+j
    b=j
    other=(a**4)+(a**3)*b+(a**2)*(b**2)+a*(b**3)+(b**4)
    if i*other>x:
      break
    if i*other==x:
      print(a," ",b)
      sys.exit()


### FIXED CODE ###

import sys
x=int(input())
div=[]
for i in range(1,int(x**0.5)+1):
  if x%i==0:
    div.append(i)
    if i != x // i:
      div.append(x//i)
div.sort()
div.reverse()
for i in div:
  for j in range(-10,1000):
    a=i-i+j
    b=-i+j
    other=(a**4)+(a**3)*b+(a**2)*(b**2)+a*(b**3)+(b**4)
    if i*other==x:
      print(a,b)
      sys.exit()
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

for i in range(N):
  if AB[i][0] > M:
    AB.pop(i)

AB.sort(reverse = True, key = lambda x:x[1])
ans = 0
for i in range(1, M + 1):
  for j in range(len(AB)):
    if AB[j][0] <= i:
      ans += AB.pop(j)[1]
      break

print(ans)

### FIXED CODE ###

from heapq import heappush, heappop

N, M = map(int, input().split())
jobs = [[] for _ in range(M)]

for i in range(N):
  ab = list(map(int, input().split()))
  #Ai > M の仕事はいらない
  if ab[0] <= M:
    jobs[ab[0] - 1].append(ab[1])

#最終日はAi=1の仕事のみ選べる。その前の日はAi<=2, ...
#終わりから考えればよさそう
hq = []
ans = 0
for i in range(M):
  for b in jobs[i]:
    heappush(hq, -1 * b)
  if len(hq) > 0:
    m = -1 * heappop(hq)
    ans += m

print(ans)
from collections import deque

k = int(input())
q = deque(range(1, 10))
 
for i in range(k):
    x = q.popleft()
    if x % 10 != 0:
        q.append(10 * x + x % 10 - 1) #左端

    q.append(10 * x + x % 10) #真ん中

    if x % 10 != 9:
        q.append(10 * x + x % 10 + 1) #右端
 
print(x)

### FIXED CODE ###

x,y,z = map(int,input().split())
print('{0} {1} {2}'.format(z,x,y))
a, b = map(int,input().split()) #複数の入力はmap関数

#判別＆出力
if A <= 9 and B <= 10:
  print(A * B)
else:
  print(-1)

### FIXED CODE ###

a,b=map(int,input().split())
if a<10 and b<10:
  print(a*b)
else:
  print(-1)