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

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

    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)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())



N,M=list(map(int,input().split()))
uf=UnionFind(N)
for _ in range(M):
    a,b=list(map(int,input().split()))
    a-=1
    b-=1
    uf.union(a,b)

L=set(uf.roots())
Ls=uf.all_group_members()
ans=0
for k in L:
    ans=max(ans,len(Ls[k]))
print(ans)

### FIXED CODE ###

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

    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)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]


N,M=list(map(int,input().split()))
uf=UnionFind(N)
for _ in range(M):
    a,b=list(map(int,input().split()))
    a-=1
    b-=1
    uf.union(a,b)

L=set(uf.roots())
ans=0
for k in L:
    ans=max(ans,uf.size(k))
print(ans)
### BUGGY CODE ###

a, b, n = map(int, input().split())
if b > n:
    ans = (a*n)//b
else:
    l = []
    for i in range(n//b +1):
        result = a*(b*(i+1)-1)//b - a*i
        l.append(result)
    ans = max(l)

print(ans)

### FIXED CODE ###

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

print(int(a*min(n,b-1)/b))
### BUGGY CODE ###

def main():
    x,y,z,k = map(int,input().split())
    lia = sorted(list(map(int,input().split())))
    lib = sorted(list(map(int,input().split())))
    lic = sorted(list(map(int,input().split())))

    li2 = sorted(list(a+b for a in lia for b in lib),reverse = True)[:k]
    li3 = sorted(list(ab + c for ab in li2 for c in lic),reverse = True)

    for i in range(k):
        print(li3[i])

main()


### FIXED CODE ###

def main():
    x,y,z,k = map(int,input().split())
    lia = sorted(list(map(int,input().split())))
    lib = sorted(list(map(int,input().split())))
    lic = sorted(list(map(int,input().split())))

    li2 = sorted(list(a+b for a in lia for b in lib),reverse = True)[:k]
    li3 = sorted(list(ab + c for ab in li2 for c in lic),reverse = True)[:k]

    print('\n'.join(map(str,li3)))

main()
### BUGGY CODE ###

#!/usr/bin/env python3
n, m = map(int, input().split())

w, v = [0] * n, [0] * n
for i in range(n):
    w[i], v[i] = map(int, input().split())

dp = [[0] * (m + 1) for _ in range(n)]
for j in range(w[0], m + 1):
    dp[0][j] = v[0]

for i in range(1, n):
    for j in range(m + 1):
        if j < w[i]:
            dp[i][j] = dp[i - 1][j]
        else:
            dp[i][j] = max(v[i] + dp[i - 1][j - w[i]], dp[i - 1][j])

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


### FIXED CODE ###

#!/usr/bin/env python3
import os
import sys
from atexit import register
from io import StringIO

sys.stdin = StringIO(os.read(0, os.fstat(0).st_size).decode())
sys.stdout = StringIO()
register(lambda: os.write(1, sys.stdout.getvalue().encode()))

input = lambda: sys.stdin.readline().rstrip('\r\n')

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

w, v = [0] * n, [0] * n
for i in range(n):
    w[i], v[i] = map(int, input().split())

dp = [[0] * (m + 1) for _ in range(n)]
for j in range(w[0], m + 1):
    dp[0][j] = v[0]

for i in range(1, n):
    for j in range(m + 1):
        if j < w[i]:
            dp[i][j] = dp[i - 1][j]
        else:
            dp[i][j] = max(v[i] + dp[i - 1][j - w[i]], dp[i - 1][j])

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

N, K = map(int, input().split(' '))
h = list(map(int, input().split(' ')))
dp = [0] + [float('inf')]*(len(h)-1)
for i in range(1, len(h)):
    dp[i] = min([dp[j] + abs(h[i] - h[j]) for j in range(max(0, i-K), i)])
print(dp[-1])

### FIXED CODE ###

import numpy as np

N, K = map(int, input().split(' '))
h = np.array(list(map(int, input().split(' '))))
dp = np.zeros(len(h), dtype=int)
for i in range(1, len(h)):
    start = max(0, i-K)
    dp[i] = min(dp[start:i] + np.abs(h[i] - h[start:i]))
print(dp[-1])
### BUGGY CODE ###

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

id = [0]*N
Lock = [-1]*N
ans = 0
flag = [True]*N
min_id = 0
while(min_id < N-1):
    ans += 1
    if ans > (N*(N-1)) // 2:
        break
    tmp = set()
    for i in range(N):
        if id[i] >= N-1:
            continue
        else:
            if Lock[i] >= 0:
                continue
            else:
                if Lock[A[i][id[i]]-1] == i and i not in tmp:
                    Lock[A[i][id[i]]-1] = -1
                    id[A[i][id[i]]-1] += 1
                    tmp.add(A[i][id[i]]-1)
                    id[i] += 1
                else:
                    if i not in tmp:
                        Lock[i] = A[i][id[i]]-1
    min_id = min(id)
if ans > (N*(N-1)) // 2:
    print(-1)
else:
    print(ans)


### FIXED CODE ###

def main():
    import sys
    import time
    input = sys.stdin.buffer.readline
    start = time.time()
    N = int(input())
    A = [tuple(map(int, input().split())) for i in range(N)]

    id = [0]*N
    Lock = [-1]*N
    ans = 0
    min_id = 0
    M = (N*(N-1)) // 2

    while(min_id < N-1):
        now = time.time()
        if now - start > 1.9:
            ans = M
            break
        ans += 1
        if ans > M:
            break
        tmp = set()
        for i in range(N):
            if id[i] >= N-1:
                continue
            else:
                if Lock[i] >= 0:
                    continue
                else:
                    a = A[i][id[i]]
                    if Lock[a-1] == i and i not in tmp:
                        Lock[a-1] = -1
                        id[a-1] += 1
                        tmp.add(a-1)
                        id[i] += 1
                    else:
                        if i not in tmp:
                            Lock[i] = A[i][id[i]]-1
        min_id = min(id)
    if ans > M:
        print(-1)
    else:
        print(ans)


main()
### BUGGY CODE ###

n=int(input())
l=[*map(int,input().split())]
f=lambda p: exit(print(['pairwise','setwise','not'][p]+' coprime'))
from math import *
g=l[0]
for x in l: g=gcd(g,x)
if g>1: f(2)
from collections import *
C=Counter()
b=0
for x in l:
  if x%2<1:
    if C[2]: f(1)
    C[2]=1
  while x%2<1: x//=2
  for i in range(3,int(x**0.5)+1,2):
    if x%i<1:
      if C[i]: f(1)
      C[i]=1
    while x%i<1: x//=i
    if x<2: break
  if x>1:
    if C[x]: f(1)
    C[x]=1
f(0)

### FIXED CODE ###

n=int(input())
l=[*map(int,input().split())]
from math import *
g=l[0]
for x in l:
  g=gcd(g,x)
if g>1: exit(print('not coprime'))
from collections import *
d=Counter()
b=0
for x in l:
  if x%2<1:
    if d[2]:
      b=1
      break
    d[2]=1
  while x%2<1: x//=2
  for i in range(3,int(x**0.5)+1,2):
    if x%i<1:
      if d[i]:
        b=1
        break
      d[i]=1
    while x%i<1: x//=i
    if x<2: break
  if x>1:
    if d[x]:
      b=1
      break
    d[x]=d.get(x,0)+1
print(['pair','set'][b]+'wise coprime')
### BUGGY CODE ###

s = list(input())
c = 0
state = 0
res = 0
while c < len(s):
    #print("c" + str(c))
    #print("cur: " + "".join(s))
    #print("state" + str(state))
    if state == 0:
        if s[c] == "A":
            state = 1
    elif state == 1:
        if s[c] == "B":
            state = 2
        else:
            state = 0
            if s[c] == "A":
                state = 1
    elif state == 2:
        if s[c] == "C":
            #print("hit")
            res += 1
            s[c-2], s[c-1], s[c] = "B", "C", "A"
            c = c - 3
            state = 0
        else:
            state = 0
        if s[c] == "A":
            state = 1
    c = c + 1
print(res)

### FIXED CODE ###

import re
s = input()
s = s.replace("BC", "X")
m = re.search(r"[AX]+", s)
count = 0
res = 0
for m in re.finditer(r"([AX]+)", s):
    t = str(m.groups()[0])
    t = ''.join(list(reversed(t)))
    count = 0
    for i in range(len(t)):
        if t[i] == "A":
            res += (i - count)
            count += 1
print(res)
### BUGGY CODE ###

a,b,k=map(int, input().split())
for i in range(a,b+1):
  if i<=a+k-1 or b-k+1<=i:
    print(i,end=" ")


### FIXED CODE ###

a,b,k=map(int,input().split())
ans=[]
for i in range(a,min(a+k,b+1)):
    ans.append(i)
for j in range(b,max(b-k,a-1),-1):
    if j not in ans:
        ans.append(j)
ans.sort()
for k in range(len(ans)):
  print(ans[k])
### BUGGY CODE ###

import sys
input=sys.stdin.readline
class BinaryIndexedTree():
  def __init__(self,n):self.bit=[0]*n
  def add(self,i,x):
    i+=1
    while i<=len(self.bit):
      self.bit[i-1]+=x
      i+=i&-i
  def sum_1(self,i):
    a=0
    i+=1
    while i:
      a+=self.bit[i-1]
      i-=i&-i
    return a
  def sum(self,i,j):
    a=self.sum_1(j-1)
    if i!=0:a-=self.sum_1(i-1)
    return a
def tentousu(a):
  bit=BinaryIndexedTree(n)
  b=[0]*n
  for i in range(n):
    b[a[i]]=i
  ans=0
  for i in range(n):
    j=b[i]+bit.sum(b[i]+1,n)
    ans+=j-i
    bit.add(b[i],1)
  return ans
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
import itertools
c=set()
for i in range(n):
  if i%2:c.add((b[i],a[i],i))
  else:c.add((a[i],b[i],i))
ans=inf=float('inf')
for i in itertools.combinations(c,(n+1)//2):
  ii=c-set(i)
  ac=[(j[0],j[2])for j in i]
  bc=[(j[1],j[2])for j in ii]
  ac.sort()
  bc.sort()
  x=[]
  for j in range(n):
    if j%2:x.append(bc[j//2])
    else:x.append(ac[j//2])
  f=False
  for j in range(1,n):
    if x[j-1][0]>x[j][0]:f=True
  if f:continue
  m=[]
  for j in range(n):m.append(x[j][1])
  ans=min(ans,tentousu(m))
if ans==inf:ans=-1
print(ans)

### FIXED CODE ###

class BinaryIndexedTree():
  def __init__(self,n):self.bit=[0]*n
  def add(self,i,x):
    i+=1
    while i<=len(self.bit):
      self.bit[i-1]+=x
      i+=i&-i
  def sum_1(self,i):
    a=0
    i+=1
    while i:
      a+=self.bit[i-1]
      i-=i&-i
    return a
  def sum(self,i,j):
    a=self.sum_1(j-1)
    if i!=0:a-=self.sum_1(i-1)
    return a
def tentousu(a):
  bit=BinaryIndexedTree(n)
  b=[0]*n
  for i in range(n):
    b[a[i]]=i
  ans=0
  for i in range(n):
    j=b[i]+bit.sum(b[i]+1,n)
    ans+=j-i
    bit.add(b[i],1)
  return ans
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
for i in range(1,n,2):a[i],b[i]=b[i],a[i]
ans=inf=float('inf')
for i in range(2**n):
  s=bin(i)[2:].zfill(n)
  if s.count("0")!=n//2:continue
  ac=[]
  bc=[]
  for j in range(n):
    if s[j]=="1":ac.append((a[j],j))
    else:bc.append((b[j],j))
  ac.sort()
  bc.sort()
  x=[]
  for j in range(n):
    if j%2:x.append(bc[j//2])
    else:x.append(ac[j//2])
  f=False
  for j in range(1,n):
    if x[j-1][0]>x[j][0]:f=True
  if f:continue
  m=[]
  for j in range(n):m.append(x[j][1])
  ans=min(ans,tentousu(m))
if ans==inf:ans=-1
print(ans)
### BUGGY CODE ###

n = input()
 
S = [int(x) for x in raw_input().split()]
 
q = input()
 
T = [int(x) for x in raw_input().split()]
 
C = 0

left = 0
right = n

for key in T:
 while left<right:
  mid = (right - left)/2
  if key==S[mid]:
   C += 1
   break
  elif key<S[mid]:
   right = mid
  elif key>S[mid]:
   left = mid+1

print C

### FIXED CODE ###

n = input()
  
S = [int(x) for x in raw_input().split()]
  
q = input()
  
T = [int(x) for x in raw_input().split()]
  
C = 0

 
for key in T:
  left = 0
  right = n
  while left<right:
    mid = (right + left)/2
    if key==S[mid]:
      C += 1
      break
    elif key<S[mid]:
      right = mid
    elif key>S[mid]:
      left = mid+1
 

print C
### BUGGY CODE ###

def main():
    N,M = map(int,input().split())
    A = [int(x) for x in input().split()]
    for _ in range(M):
        b,c = map(int, input().split())
        for i in range(b):
            A.append(c)
    A.sort()
    print(sum(A[-N:]))
main()

### FIXED CODE ###

from operator import itemgetter

def main():
    N,M = map(int, input().split())
    A = [[1,int(x)] for x in input().split()]
    for _ in range(M):
        b,c = map(int, input().split())
        A.append([b,c])
    A.sort(key=itemgetter(1))
    A.reverse()
    n=0
    s=0
    for a in A:
        n+=a[0]
        if n<=N:
            s+=a[1]*a[0]
        elif n>N:
            d=a[0]
            e=a[1]
            break
    s+=(N-n+d)*e
    print(s)
    
main()
### BUGGY CODE ###

import numpy as np

n = int(input())
h = np.array(list(map(int, input().split())), dtype='int64')
a = np.array(list(map(int, input().split())), dtype='int64')

dp = np.zeros((n, 2), dtype='int64')
dp[0][0] = a[0]
dp[0][1] = a[0]

for i in range(1, n):
    h_ = h[:i]
    js = np.where(h_ < h[i])[0]
    if len(js) == 0:
        dp[i][1] = a[i]
    else:
        dp[i][1] = np.max(np.array(dp[js, 1])) + a[i]
    dp[i][0] = max(dp[i][1], dp[i-1][0])

print(dp[-1][0])


### FIXED CODE ###

from math import ceil, log

n = int(input())
h = list(map(int, input().split()))
a = list(map(int, input().split()))


class SegmentTree(object):
    __slots__ = ["elem_size", "tree", "default", "op"]

    def __init__(self, a: list, default: int, op):
        real_size = len(a)
        self.elem_size = elem_size = 1 << ceil(log(real_size, 2))
        self.tree = tree = [default] * (elem_size * 2)
        tree[elem_size:elem_size + real_size] = a
        self.default = default
        self.op = op

        for i in range(elem_size - 1, 0, -1):
            tree[i] = op(tree[i << 1], tree[(i << 1) + 1])

    def get(self, x: int, y: int) -> int:  # [x, y)
        l, r = x + self.elem_size, y + self.elem_size
        tree, result, op = self.tree, self.default, self.op
        while l < r:
            if l & 1:
                result = op(tree[l], result)
                l += 1
            if r & 1:
                r -= 1
                result = op(tree[r], result)
            l, r = l >> 1, r >> 1

        return result

    def set(self, i: int, value: int) -> None:
        k = self.elem_size + i
        self.tree[k] = value
        self.update(k)

    def update(self, i: int) -> None:
        op, tree = self.op, self.tree
        while i > 1:
            i >>= 1
            tree[i] = op(tree[i << 1], tree[(i << 1) + 1])


dp = SegmentTree([0] * (n+1), 0, max)

for i in range(n):
    v = dp.get(0, h[i]) + a[i]
    if v > dp.get(h[i], h[i]+1):
        dp.set(h[i], v)

print(dp.get(0, n+1))
### BUGGY CODE ###

N = int(input())
ARR = [int(s) for s in input().split(" ")]
import numpy as np

def calculate(n,arr):

    dict = {}
    for ar in arr:

        if dict.get(ar) == None:
            dict.__setitem__(ar,1)
        else:
            tmp = dict.get(ar)
            tmp = tmp + 1
            dict.__setitem__(ar,tmp)


    for ar in arr:
        tmp = dict.get(ar)
        dict.__setitem__(ar,tmp-1)

        vals = np.array(list(dict.values()))
        print(sum((vals * (vals-1)) // 2))

        dict.__setitem__(ar,tmp)

calculate(N,ARR)

### FIXED CODE ###

N = int(input())
ARR = [int(s) for s in input().split(" ")]
# N = 8
# ARR = [1, 2, 1, 4, 2, 1, 4, 1]

def calculate(n,arr):

    dict = {}
    brr = {}
    for ar in arr:

        if dict.get(ar) == None:
            dict.__setitem__(ar,1)
        else:
            tmp = dict.get(ar)
            tmp = tmp + 1
            brr.__setitem__(ar,(tmp * (tmp - 1)) // 2 )
            dict.__setitem__(ar,tmp)

    sumValue = sum(brr.values())

    for ar in arr:
        tmp = dict.get(ar)

        print(sumValue - (tmp - 1))

calculate(N,ARR)
### BUGGY CODE ###

'''
Created on 2020/08/29

@author: harurun
'''
def main():
  import copy
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  X=list(map(int,pin().split()))
  t=(N+1)//2
  Y=sorted(X)
  for i in range(N):
    T=copy.copy(Y)
    T.remove(X[i])
    print(T[t-1])
  return 

main()

### FIXED CODE ###

'''
Created on 2020/08/29

@author: harurun
'''
def main():
  import copy
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  X=list(map(int,pin().split()))
  t=(N+1)//2
  Y=sorted(X)
  ans1=Y[t-1]
  ans2=Y[t]
  median=ans1+ans2
  for i in range(N):
    s=X[i]
    if s==ans1:
      print(ans2)
    elif s==ans2:
      print(ans1)
    elif  2*s<median:
      print(ans2)
    elif 2*s>median:
      print(ans1)
  return 

main()
### BUGGY CODE ###

s = list(input())
q = int(input())
a = 0
c = ""
for i in range(q):
    b = list(input().split())
    if b[0] == "1":
        if a == 0:
            a = 1
        else:
            a = 0
    else:
        if (a, b[1]) == (0, "1") or (a, b[1]) == (1, "2"):
            s.insert(0, b[2])
        else:
            s.append(b[2])
if a == 0:
    for i in range(len(s)):
        c = c + s[i]
else:
    for i in range(len(s)):
        c = c + s[-i-1]
print(c)

### FIXED CODE ###

from collections import deque
s = deque(input())
q = int(input())
a = 0
c = ""
for i in range(q):
    b = list(input().split())
    if b[0] == "1":
        if a == 0:
            a = 1
        else:
            a = 0
    else:
        if (a, b[1]) == (0, "1") or (a, b[1]) == (1, "2"):
            s.appendleft(b[2])
        else:
            s.append(b[2])
if a == 0:
    for i in range(len(s)):
        c += s.popleft()
else:
    for i in range(len(s)):
        c += s.pop()
print(c)
### BUGGY CODE ###

N,K = map(int, input().split())
P = [int(i) for i in input().split()]
maxP = 0

for i in range(N-K+1):
    a = sum(P[i:i+K])
    if maxP < a:
        maxP, array = a, P[i:i+K]
print(sum([i*(i+1)/2/i for i in array]))

### FIXED CODE ###

N,K = map(int, input().split())
P = [int(i) for i in input().split()]
total, maxS = 0, 0
S = [0]
for p in P:
    total += p*(p+1)/2/p
    S.append(total)

for i in range(N-K+1):
    if maxS < S[i+K]-S[i]:
        maxS = S[i+K]-S[i]
print(maxS)
### BUGGY CODE ###

class UFT():
    def __init__(self):
        self.par = {}
        self.rank = {}

    def find(self, x):
        if self.par.get(x, x) == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

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

        self.rank[x] = self.rank.get(x, 0)
        self.rank[y] = self.rank.get(y, 0)

        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

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

N, K, L = [int(_) for _ in input().split()]

C = UFT()
for _ in range(K):
    p, q = [int(_) for _ in input().split()]
    C.unite(p, q)
for _ in range(L):
    r, s = [int(_) for _ in input().split()]
    C.unite(r + N, s + N)
memo = {}
for i in range(1, N + 1):
    memo[C.find(i) - 1, C.find(i + N) - N - 1] = memo.get((C.find(i) - 1, C.find(i + N) - N - 1), 0) + 1
print(' '.join(str(memo[C.find(i) - 1, C.find(i + N) - N - 1]) for i in range(1, N + 1)))


### FIXED CODE ###

class UFT():
    def __init__(self):
        self.par = {}
        self.rank = {}

    def find(self, x):
        if self.par.get(x, x) == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

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

        self.rank[x] = self.rank.get(x, 0)
        self.rank[y] = self.rank.get(y, 0)

        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

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

N, K, L = [int(_) for _ in input().split()]

Road = UFT()
for _ in range(K):
    p, q = [int(_) for _ in input().split()]
    Road.unite(p, q)
Railway = UFT()
for _ in range(L):
    r, s = [int(_) for _ in input().split()]
    Railway.unite(r, s)
memo = {}
for i in range(1, N + 1):
    memo[Road.find(i), Railway.find(i)] = memo.get((Road.find(i), Railway.find(i)), 0) + 1
print(' '.join(str(memo[Road.find(i), Railway.find(i)]) for i in range(1, N + 1)))
### BUGGY CODE ###

n = int(input())
li = []
count =0
for i in range(n):
    s = input()
    if not s in li:
        li.append(s)
        count +=1
print(count)

### FIXED CODE ###

n = int(input())
li=[input() for i in range(n)]
print(len(set(li)))
### BUGGY CODE ###

from itertools import product

N = int(input())
added = set()
ans = []
a = [[chr(97+i) for i in range(j)] for j in range(1,N+1)]
for x in product(*a):
    appeared = set('a')
    d = ['a']
    temp = [0]
    for y in x[1:]:
        if y not in appeared:
            appeared.add(y)
            d.append(y)
            temp.append(d.index(y))
        else:
            temp.append(d.index(y))
    t = tuple(temp)
    if t not in added:
        print(''.join(x))
        added.add(t)

### FIXED CODE ###

def dfs(s,n):
    if len(s) == n:
        print(s)
    else:
        for i in range(len(set(s))+1):
            dfs(''.join([s,chr(97+i)]),n)

N = int(input())
dfs('a',N)
### BUGGY CODE ###

import heapq
n,m = map(int, input().split())
job = {}
for i in range(n):
    a,b = map(int, input().split())
    if a not in job.keys():
        job[a] = [(-b,a)]
    else:
        job[a].append((-b,a))

hq = []

max_income = 0
for i in range(1,m+1):
    if i in job.keys():
        for j in job[i]:
            heapq.heappush(hq,(j))
    if len(hq) < 1:
        continue
    b_i, a_i = heapq.heappop(hq)
    max_income += -b_i

print(max_income)


### FIXED CODE ###

import heapq
n,m = map(int, input().split())
job_list = []
for i in range(n):
    a,b = map(int, input().split())
    job_list.append((a,b))
job_list.sort(key=lambda x:x[0])
# print(job_list)

hq = []
max_income = 0
j = 0
for i in range(1,m+1):
    while j < n and job_list[j][0] <= i:
        heapq.heappush(hq, (-job_list[j][1],job_list[j][0]))
        j += 1
    if len(hq) < 1:
        continue
    b_i, a_i = heapq.heappop(hq)
    max_income += -b_i

print(max_income)