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

# 幅優先探索（行きがけ）
import collections
import sys
import math
import copy


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N = I()
    AArry = LI()
    AArry.sort()
    AArry = collections.deque(AArry)
    count = 0
    while AArry:
        a = AArry.popleft()
        AArry2 = copy.copy(AArry)
        flag = 0
        for v in AArry2:
            if v % a == 0:
                if v == a:
                    flag = 1
                AArry.remove(v)
                count += 1
        if flag == 1:
            count += 1

    print(N-count)


if __name__ == '__main__':
    main()


### FIXED CODE ###

# 幅優先探索（行きがけ）
import collections
import sys
import math
import copy
import collections


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N = I()
    AArry = LI()
    AArry.sort()
    count = 0
    li = [0 for _ in range(10**6+2)]

    for i, v in enumerate(AArry):
        a = v
        if li[a] == 1:
            count += 1
        if li[a] == 0:
            if i != N-1 and AArry[i+1] == a:
                count += 1

            for j in range(a, 10**6+2, a):
                li[j] = 1

    print(N-count)


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

n, q = (int(i) for i in input().split())
ab = [[int(i) for i in input().split()] for _ in range(n-1)]
child_dict = {}
for i in range(n-2,-1,-1):
    cur = child_dict.get(ab[i][0],set({}))
    cur.add(ab[i][1])
    child_dict[ab[i][0]] = cur
px = [[int(i) for i in input().split()] for _ in range(q)]

p = [0] * n

for j in range(q):
    rootidx = px[j][0]
    p[rootidx - 1] += px[j][1]
    if rootidx in child_dict.keys():
        for k in child_dict[rootidx]:
            p[k-1] += px[j][1]
            while k in child_dict.keys():
                for l in child_dict[k]:
                    p[l-1] += px[j][1]
                k = l
print(*p)

### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.buffer.readline
    from collections import deque
    N, Q = (int(i) for i in input().split())
    G = [[] for _ in range(N)]
    cost = [0]*N
    for _ in range(N-1):
        a, b = (int(i) for i in input().split())
        G[a-1].append(b-1)
        G[b-1].append(a-1)
    for _ in range(Q):
        p, x = (int(i) for i in input().split())
        cost[p-1] += x

    def bfs(s):
        G_color = ['WHITE' for _ in range(len(G))]
        G_color[s] = 'GRAY'
        Q = deque()
        Q.append(s)
        while Q:
            u = Q.popleft()
            for v in G[u]:
                if G_color[v] == 'WHITE':
                    G_color[v] = 'GRAY'
                    cost[v] += cost[u]
                    Q.append(v)
            G_color[u] = 'BLACK'

    bfs(0)
    print(*cost)


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

def modpow(a,n,p):
    if n==0:
        return 1
    x=modpow(a,n//2,p)
    x=(x*x)%p
    if (n%2)==1:
        x=(x*a)%p
    return x%p
def modinv(a,p):
    return modpow(a,p-2,p)
from fractions import gcd
N=int(input())
A=list(map(int,input().split()))
new=[0]*N
A.sort()
insuu=[0]*(A[N-1]+1)
pf={}
l=[]
ans=1
cnt=0
p=(10**9)+7

for i in range(N):
    m = A[i]
    for j in range(2,int(m**0.5)+1):
        while m%j==0:
            pf[j]=pf.get(j,0)+1
            m//=j
    if m>1:pf[m]=1
    #print(pf)
    keys=list(pf.keys())
    values=list(pf.values())
    pf={}
    for j in range(len(keys)):
        if insuu[keys[j]]<values[j]:
            insuu[keys[j]]=values[j]
        #print(insuu)
    #print(l)
for i in range(1,A[N-1]+1,1):
    if insuu[i]>0:
        ans=ans*pow(i,insuu[i])
#print(ans)
for i in range(N):
    #print((ans*modinv(A[i],p))%p)
    cnt=(cnt+(ans*modinv(A[i],p))%p)%p
print(cnt%p)



### FIXED CODE ###

def modpow(a,n,p):
    if n==0:
        return 1
    x=modpow(a,n//2,p)
    x=(x*x)%p
    if (n%2)==1:
        x=(x*a)%p
    return x%p
def modinv(a,p):
    return modpow(a,p-2,p)
from fractions import gcd
N=int(input())
A=list(map(int,input().split()))
new=[0]*N
A.sort()
insuu=[0]*(A[N-1]+1)
pf={}
l=[]
ans=1
cnt=0
p=(10**9)+7

for i in range(N):
    m = A[i]
    for j in range(2,int(m**0.5)+1):
        while m%j==0:
            pf[j]=pf.get(j,0)+1
            m//=j
    if m>1:pf[m]=1
    #print(pf)
    keys=list(pf.keys())
    values=list(pf.values())
    pf={}
    for j in range(len(keys)):
        if insuu[keys[j]]<values[j]:
            insuu[keys[j]]=values[j]
        #print(insuu)
    #print(l)
for i in range(1,A[N-1]+1,1):
    if insuu[i]>0:
        ans=ans*pow(i,insuu[i])
#print(ans)
for i in range(N):
    #print((ans*modinv(A[i],p))%p)
    cnt=(cnt+(ans*modinv(A[i],p))%p)%p
print(cnt%p)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 0
double = set(a)
for i in double:
    if not a.count(i) == 1:
        ans -= a.count(i)
a = sorted(a)
# a.sort()
if n == 1:
    print(1)
    exit()
if a[0] == 1:
    if a[1] == 1:
        print(0)
        exit()
    else:
        print(1)
        exit()

check = True
for i in range(n):
    for j in range(0, i):
        if not a[j] == 1:
            if a[j]*2 > a[i]:
                break
        if i == j:
            continue
        if a[i]%a[j] == 0:
            check = False
            break

    if check:
        ans += 1
        # print(i)
    check = True
# print(a)
# print(ans)
# print(double)

# ans -= len(set(double))
# ans -= len(double)
print(ans)

### FIXED CODE ###

from collections import Counter
n = int(input())
a = list(map(int, input().split()))
a.sort()
c = Counter(a)
m = max(a) + 1
dp = [False]*m
ans = 0
for ai in a:
    if dp[ai]:
        continue
    if c[ai] == 1:
        ans += 1
    for i in range(ai, m, ai):
        dp[i] = True
print(ans)
### BUGGY CODE ###

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

def get_root(x):
  while pare_inds[x] != x:
    x = pare_inds[x]
  return x

for i in range(m):
  x, y = map(int,input().split())
  x, y = x - 1, y - 1
  p_x, p_y  = get_root(x), get_root(y)
  if p_x < p_y:
    pare_inds[y] = p_x
    pare_inds[p_y] = p_x
  elif p_x > p_y:
    pare_inds[x] = p_y
    pare_inds[p_x] = p_y
#  print(x,y,p_x,p_y,pare_inds)

for i in range(n):
  belongs[get_root(i)].append(i)

ans = 0
for lst in belongs:
  for i in lst:
    if plst[i] - 1 in lst:
      ans += 1

print(ans)
#print(belongs)
#print(pare_inds)

### FIXED CODE ###

def solve():
  n, m = map(int,input().split())
  plst = list(map(int,input().split()))
  pare_inds = [i for i in range(n)]
  belongs = [[] for i in range(n)]
  
  def get_root(x):
    p = pare_inds[x]
    if p == x:
      return x
    a = get_root(p)
    pare_inds[x] = a
    return a
  
  for i in range(m):
    x, y = map(int,input().split())
    x, y = x - 1, y - 1
    r_x, r_y  = get_root(x), get_root(y)
    if r_x < r_y:
      pare_inds[y] = r_x
      pare_inds[r_y] = r_x
    else:
      pare_inds[x] = r_y
      pare_inds[r_x] = r_y
  
  for i in range(n):
    belongs[get_root(i)].append(i)
  #print(belongs)
  #print(plst)
  ans = 0
  for lst in belongs:
    lst2 = [plst[i] - 1 for i in lst]
    lst.sort()
    lst2.sort()
    ind1 = 0
    ind2 = 0
    end = len(lst)
    while ind1 < end and ind2 < end:
      if lst[ind1] == lst2[ind2]:
        ans += 1
        ind1 += 1
        ind2 += 1
      elif lst[ind1] < lst2[ind2]:
        ind1 += 1
      else:
        ind2 += 1
  
  print(ans)
solve()
### BUGGY CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
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()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, D, A = MAP()
XH = [LIST() for _ in range(N)]

XH.sort(key = lambda x: x[0])

X, H = zip(*XH)

right = [0]*N
for i, x in enumerate(X):
	right[i] = bisect(X, x+2*D)

damage = [0]*(N+1)
ans = 0

for i in range(N):
	for i, (X, H) in enumerate(XH):
		if i != 0:
			damage[i] += damage[i-1]
		H -= damage[i]
		if 0 < H:
			n = -(-H//A)
			ans += n
			d = A*n
			damage[i] += d
			damage[right[i]] -= d
print(ans)


### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
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()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, D, A = MAP()
XH = [LIST() for _ in range(N)]

XH.sort(key = lambda x: x[0])

X = [XH[i][0] for i in range(N)]
H = [XH[i][1] for i in range(N)]

ans = 0
imos = [0]*(N+1)
tmp = 0
for i in range(N):
	x, h = XH[i]
	tmp += imos[i]
	left = h-tmp
	if 0 < left:
		cnt = -(-left//A)
		damage = A*cnt
		idx = bisect(X, x+2*D)
		tmp += damage
		imos[idx] -= damage
		ans += cnt

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

N=int(input())
A=list(map(int,input().split()))
new=[0]*N
A.sort()
insuu=[0]*(A[N-1]+1)
pf={}
l=[]
ans=1
cnt=0
p=(10**9)+7

for i in range(N):
    m = A[i]
    for j in range(2,int(m**0.5)+1):
        while m%j==0:
            pf[j]=pf.get(j,0)+1
            m//=j
    if m>1:pf[m]=1
    #print(pf)
    keys=list(pf.keys())
    values=list(pf.values())
    pf={}
    for j in range(len(keys)):
        if insuu[keys[j]]<values[j]:
            insuu[keys[j]]=values[j]
        #print(insuu)
    #print(l)
for i in range(1,A[N-1]+1,1):
    if insuu[i]>0:
        ans=ans*pow(i,insuu[i])
for i in range(N):
    new[i]=ans//A[i]
#print(ans,new)
for i in range(N):
    cnt=(cnt+new[i])%p
print(cnt)

#print(l)	#これでlistになった

### FIXED CODE ###

def modpow(a,n,p):
    if n==0:
        return 1
    x=modpow(a,n//2,p)
    x=(x*x)%p
    if (n%2)==1:
        x=(x*a)%p
    return x%p
def modinv(a,p):
    return modpow(a,p-2,p)
from fractions import gcd
N=int(input())
A=list(map(int,input().split()))
new=[0]*N
A.sort()
insuu=[0]*(A[N-1]+1)
pf={}
l=[]
ans=1
cnt=0
p=(10**9)+7

for i in range(N):
    m = A[i]
    for j in range(2,int(m**0.5)+1):
        while m%j==0:
            pf[j]=pf.get(j,0)+1
            m//=j
    if m>1:pf[m]=1
    #print(pf)
    keys=list(pf.keys())
    values=list(pf.values())
    pf={}
    for j in range(len(keys)):
        if insuu[keys[j]]<values[j]:
            insuu[keys[j]]=values[j]
        #print(insuu)
    #print(l)
for i in range(1,A[N-1]+1,1):
    if insuu[i]>0:
        ans=ans*pow(i,insuu[i])
#print(ans)
for i in range(N):
    #print((ans*modinv(A[i],p))%p)
    cnt=(cnt+(ans*modinv(A[i],p))%p)%p
print(cnt%p)
### BUGGY CODE ###

def bipartite():
    color = {v: None for v in V}
    stack = [(V[0], 0)]
    parts = {0: set([]), 1: set([])}
    while stack:
        v, c = stack.pop()
        color[v] = c
        parts[c].add(v)
        for u in E[v]:
            if color[u] is None: # not visited yet
                stack.append((u, c^1)) # paint u with different color from v's one
            elif color[u] != c: # consistent
                continue
            else: # inconsistent
                return (None, None)
    return (parts[0], parts[1])
            
N, M = map(int, input().split())
V = range(1, N+1)
E = {v: [] for v in V}
for _ in range(M):
    a, b = map(int, input().split())
    E[a].append(b)
    E[b].append(a)
p1, p2 = bipartite()
if p1 is None:
    print(N * (N-1) // 2 - M)
else:
    print(len(p1) * len(p2) - M)

### FIXED CODE ###

def bipartite():
    color = {v: None for v in V}
    stack = [(V[0], 0)]
    parts = {0: [], 1:[]}
    while stack:
        v, c = stack.pop()
        if color[v] is not None: # consistent
            continue
        color[v] = c
        parts[c].append(v)
        for u in E[v]:
            if color[u] is None: # not visited yet
                stack.append((u, c^1)) # paint u with different color from v's one
            elif color[u] != c: # consistent
                continue
            else: # inconsistent
                return (None, None)
    return (parts[0], parts[1])
            
N, M = map(int, input().split())
V = range(1, N+1)
E = {v: [] for v in V}
for _ in range(M):
    a, b = map(int, input().split())
    E[a].append(b)
    E[b].append(a)
p1, p2 = bipartite()
if p1 is None:
    print(N * (N-1) // 2 - M)
else:
    print(len(p1) * len(p2) - M)
### BUGGY CODE ###

#b
n = int(input())
a = [int(i) for i in input().split()]
sum_a = sum(a)

#s = int((n*(n-1))/2)
s = n*(n+1)//2
if sum_a%s!=0:
    print("NO")
else:
    times = sum_a//s
    stock = times
    ind = 0
    for _ in range(n):
        next_ind= (ind+1)%n
        now = a[ind]
        tsugi = a[next_ind]
        now += times
        while(tsugi!=now):
            now -= n
            stock -= 1
            if stock<0:
                print("NO")
                exit()      
        ind = next_ind
    if stock==0:
        print("YES")

### FIXED CODE ###

#b

N, *A = map(int, open(0).read().split())
M = (N+1)*N//2
S = sum(A)
if S%M!=0:
  print('NO')
  exit()
cnt = S//M
for i in range(N):
  df = A[(i+1)%N]-A[i]
  if (cnt-df)%N!=0 or cnt<df:
    print('NO')
    break
else:
  print('YES')
### BUGGY CODE ###

n,m=map(int,input().split())
a=[]
for i in range(m):
    a.append(int(input()))
dp=[0]*(n+1)
dp[0]=1
dp[1]=1
for i in range(2,n+1):
    if i-1 not in a and i-2 not in a:
        dp[i]=dp[i-1]+dp[i-2]
    elif i-1 in a and i-2 not in a:
        dp[i]=dp[i-2]
    elif i-1 not in a and i-2 in a:
        dp[i]=dp[i-1]
    elif i-1 in a and i-2 in a:
        dp[i]=0
print(dp[n]%1000000007)

### FIXED CODE ###

import sys
input=sys.stdin.readline
n,m=map(int,input().split())
b=[]
for i in range(m):
    b.append(int(input()))
a=set(b)
dp=[0]*(n+1)
dp[0]=1
if 1 in a:
    dp[1]=0
else:
    dp[1]=1
for i in range(2,n+1):
    if i in a:
        dp[i]=0
    else:
        dp[i]=dp[i-1]+dp[i-2]
print(dp[n]%1000000007)
### BUGGY CODE ###

# import sys
# import bisect

# sys.setrecursionlimit(4100000)


# def inputs(num_of_input):
#     ins = [input() for i in range(num_of_input)]
#     return ins


def bis_insert(L, target, top=None, bottom=None):
    if top is None:
        top = len(L)
    if bottom is None:
        bottom = 0

    while bottom < top:
        half = (top + bottom) // 2
        if target > L[half]:
            bottom = half + 1
        else:
            top = half
    return bottom


def solve(inputs):
    L = string_to_int(inputs)
    L.sort()
    total_count = 0
    for i in range(len(L) - 2):
        for j in range(i + 1, len(L)-1):
            a = L[i]
            b = L[j]
            target = a + b
            r = bis_insert(L, target)
            # r = bisect.bisect_left(L, target)
            total_count += r - j - 1
    return total_count


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    input()
    ret = solve(input())
    print(ret)


### FIXED CODE ###

import sys
import bisect

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def bis_insert(L, target, top=None, bottom=None):
    if top is None:
        top = len(L)
    if bottom is None:
        bottom = 0

    while bottom < top:
        half = (top + bottom) // 2
        if target > L[half]:
            bottom = half + 1
        else:
            top = half
    return bottom


def solve(inputs):
    L = string_to_int(inputs[0])
    L.sort()
    total_count = 0
    for i in range(len(L) - 2):
        for j in range(i + 1, len(L)-1):
            a = L[i]
            b = L[j]
            target = a + b
            # r = bis_insert(L, target)
            r = bisect.bisect_left(L, target)
            total_count += r - j - 1
    return total_count


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)
### BUGGY CODE ###

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

C = N // (A + B) + (0 if N % (A + B) == 0 else 1)

blue = 0
total = 0

while total < N:
    addition = min(N - total, A + B)
    total += addition
    blue += min(addition, A)

print(blue)

### FIXED CODE ###

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

C = N // (A + B)
D = N % (A + B)

R = C * A + min(A, D)
print(R)
### BUGGY CODE ###

h,w = map(int, input().split())
a = [list(map(int, input().split()))+[0] for i in range(h)] + [[0]*(w+1)]
b = [list(map(int, input().split()))+[0] for i in range(h)] + [[0]*(w+1)]
diff = [[x-y for x,y in zip(i,j)] for i,j in zip(a,b)]
diff_set = [[set() for j in range(w+1)] for i in range(h+1)]
diff_set[0][0].add(diff[0][0])
for i in range(h):
  for j in range(w):
    for x in diff_set[i][j]:
      diff_set[i][j+1].add(abs(x+diff[i][j+1]))
      diff_set[i][j+1].add(abs(x-diff[i][j+1]))
      diff_set[i+1][j].add(abs(x+diff[i+1][j]))
      diff_set[i+1][j].add(abs(x-diff[i+1][j]))
ans = min(diff_set[h-1][w-1])
print(ans)

### FIXED CODE ###

h,w = map(int, input().split())
a = [list(map(int, input().split()))+[0] for i in range(h)] + [[0]*(w+1)]
b = [list(map(int, input().split()))+[0] for i in range(h)] + [[0]*(w+1)]
diff = [[abs(x-y) for x,y in zip(i,j)] for i,j in zip(a,b)]
dp = [[0 for j in range(w+1)] for i in range(h+1)]
dp[0][0] = (1 << diff[0][0])


def reverse(d, x):
  res = 0
  for i in range(x+1):
    res <<= 1
    if (1<<i) & d:
      res |= 1
  return res


for i in range(h):
  for j in range(w):
    dp[i][j+1] |= (dp[i][j] << diff[i][j+1])
    dp[i][j+1] |= (dp[i][j] >> diff[i][j+1])
    dp[i][j+1] |= reverse(dp[i][j], diff[i][j+1])
    dp[i+1][j] |= (dp[i][j] << diff[i+1][j])
    dp[i+1][j] |= (dp[i][j] >> diff[i+1][j])
    dp[i+1][j] |= reverse(dp[i][j], diff[i+1][j])
last = dp[h-1][w-1]
for i in range(6401):
  if (last >> i) & 1:
    ans = i
    break
print(ans)
### BUGGY CODE ###

X = int(input())
A = int(X/2)
while True:
    diff = X - A**5
    if diff < 0:
        minus_flg = False
        diff = abs(diff)
    else:
        minus_flg = True
    B = pow(diff, 0.2)
    if (isinstance(B, float)) and B.is_integer():
        break
        A += 1
if minus_flg:
    B = int(B)*-1
print(A, int(B))


### FIXED CODE ###

X = int(input())

for a in range(-118, 121):
    for b in range(-118, 121):
        if (a**5 - b**5) == X:
            break
    else:
        continue
    break
print(a, b)
### BUGGY CODE ###

N,W = map(int,input().split())
goods = [list(map(int,input().split())) for _ in range(N)]

dp = [[0 for _ in range(W)] for _ in range(N)]

for i,[w,v] in enumerate(goods):
  for j in range(W):
    if i == 0:
      if j >= goods[0][0]-1:
        dp[0][j] = goods[0][1]
    else:
      if w <= j:
        dp[i][j] = max(v+dp[i-1][j-w],dp[i][j-1],dp[i-1][j])
      else:
        dp[i][j] = max(dp[i-1][j],dp[i][j-1])

print(dp[N-1][W-1])

### FIXED CODE ###

N,W = map(int,input().split())
goods = [list(map(int,input().split())) for _ in range(N)]

dp = [[0 for _ in range(W)] for _ in range(N)]

for i,[w,v] in enumerate(goods):
  for j in range(W):
    if i == 0:
      if j >= goods[0][0]-1:
        dp[0][j] = goods[0][1]
    else:
      if w <= j:
        dp[i][j] = max(v+dp[i-1][j-w],dp[i][j-1],dp[i-1][j])
      else:
        dp[i][j] = max(dp[i-1][j],dp[i][j-1])

print(dp[N-1][W-1])
### BUGGY CODE ###

N = int(input())
sum=0
while N:
    sum+=N%10
    N//=10
if sum%9==0:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

N=list(str(input()))
sum=0
for i in range(len(N)):
    sum=(sum+int(N[i]))%9
if sum%9==0:
    print("Yes")
else:
    print("No")
### BUGGY CODE ###

import itertools
import heapq
import sys
import functools
import operator
import numpy as np
input = sys.stdin.readline
#-------------
n,k = map(int,input().split())
a = list(map(int,input().split()))
#-------------
b = np.abs(a)
b = sorted(a,reverse = True)
b_k = b[k-1] 
a_new = [a[_] for _ in range(len(a)) if np.abs(a)[_] >= b_k]
a_new.sort()
C=[]
D=[]
for i in range(len(a)):
  for j in range(k):
    C.append(a_new[i+j-k])
  D.append(C)
  C=[]    
A = (functools.reduce(operator.mul,D[_]) for _ in range(len(D)))
l_max = max(A)
waru = 10**9 + 7
print(l_max % waru)

### FIXED CODE ###

import sys
 
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
mod = pow(10, 9)+7
zero = 0
plus = []
minus = []
for i in range(n):
  if a[i] == 0:
    zero += 1
  elif a[i] > 0:
    plus.append(a[i])
  else:
    minus.append(a[i])
 
P, M = len(plus), len(minus)
plus.sort(reverse=True)
minus.sort()
ans = 1
if n == k:
  for i in range(n):
    ans *= a[i]
    ans %= mod
elif P+M < k:
  ans = 0
elif P == 0:
  if zero and k%2:
    ans = 0
  else:
    if k%2:
      minus.reverse()
    for i in range(k):
      ans *= minus[i]
      ans %= mod
else:
  q = 0
  if k%2:
    ans *= plus[0]
    ans %= mod
    q = 1
  judge = []
  for i in range((len(plus)-q)//2):
    judge.append(plus[2*i+q]*plus[2*i+q+1])
  for i in range(len(minus)//2):
    judge.append(minus[2*i]*minus[2*i+1])
  judge.sort(reverse=True)
  for i in range(k//2):
    ans *= (judge[i]%mod)
    ans %= mod
 
print(ans)
### BUGGY CODE ###

import heapq
from collections import defaultdict

def main():
    N, M = map(int, input().split())
    ans = 0
    d = defaultdict(list)
    for _ in range(N):
        A, B = map(int, input().split())
        d[A].append(-B)
    cand = []
    heapq.heapify(cand)
    for day in range(M-1,-1,-1):
        diff = M - day
        if d[diff]:
            cand += d[diff]
        heapq.heapify(cand)
        if cand:
            ans -= heapq.heappop(cand)

    print(ans)



if __name__ == "__main__":
    main()

### FIXED CODE ###

from heapq import heappush, heappop

def main():
    N, M = map(int, input().split())

    # 日数別に仕事を管理
    works = [[] for _ in range(M)]

    for i in range(N):
        A, B = map(int, input().split())
        
        if A > M:
            continue
        
        deadline = M - A
        # heapqは最小値を返す仕組みしかないので、最大値を返すため-する
        works[deadline].append(-B)
    
    ans = 0
    heapque = []

    # i日目に始めることができる仕事で報酬の高いものを選ぶ
    for i in range(M - 1, -1, -1):
        for work in works[i]:
            # heapqに候補を追加
            heappush(heapque, work)
        
        if heapque:
            ans += heappop(heapque)
    
    print(-ans)


main()