CodeEff/ECCO huggingface dataset:
# Original solution
N, K = list(map(int,input().split()))
P = []
for i in range(N):
    a, b = list(map(int,input().split()))
    p = [a] * b
    P += p
P.sort()
print((P[K-1]))

# Optimized solution
N, K = list(map(int,input().split()))
P = [list(map(int,input().split())) for _ in range(N)]
p = 0
P.sort()
for i in range(N):
    p += P[i][1]
    if p >= K:
        ans = P[i][0]
        break
print(ans)
# Original solution
n,k=list(map(int,input().split()))
l=[0]
for _ in range(n):
    a,b=list(map(int,input().split()))
    l+=[a]*b
l.sort()
print((l[k]))

# Optimized solution
n,k=list(map(int,input().split()))
l=[0]*(10**5+1)
for _ in range(n):
    a,b=list(map(int,input().split()))
    l[a]+=b
s=0    
for i in range(len(l)):
    s+=l[i]
    if s>=k:
        print(i)
        break
# Original solution
n, k = list(map(int, input().split()))
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = list(map(int ,input().split()))

#愚直な実装だけどいけるかなって感じ
lis = []

for i in range(n):
    for j in range(b[i]):
        lis.append(a[i])

lis.sort()
print((lis[k-1]))

# Optimized solution
n, k = list(map(int, input().split()))
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = list(map(int ,input().split()))


judge = 0
dic = {}


for i in range(n):
    if a[i] in dic:
        dic[a[i]] += b[i]
    else:
        dic[a[i]] = b[i]
#print(dic)
dic = list(dic.items())
dic.sort()
#print(dic)


for i in range(10**9):
    if judge >= k:
        print((dic[i-1][0]))
        break
    else:
        judge += int(dic[i][1])
    #print(judge)
# Original solution
# ABC 061: C – Big Array
N, K = [int(i) for i in input().split()]
a, b = [], []
for _ in range(N):
    tmp = input().split()
    a.append(int(tmp[0]))
    b.append(int(tmp[1]))

sequence = []

for i in range(N):
    sequence += [a[i]] * b[i]

sequence.sort()
print((sequence[K - 1]))

# Optimized solution
# ABC 061: C – Big Array
N, K = [int(i) for i in input().split()]
a, b = [], []
for _ in range(N):
    tmp = input().split()
    a.append(int(tmp[0]))
    b.append(int(tmp[1]))

cnt = [0] * (100000 + 1)

for i in range(N):
    cnt[a[i]] += b[i]

for j in range(100000 + 1):
    if K <= cnt[j]:
        print(j)
        break
    K -= cnt[j]
# Original solution
n, k = list(map(int, input().split()))
a = []

for i in range(n):
    x, y = list(map(int, input().split()))
    for j in range(y):
        a.append(x)

a.sort()
print((a[k-1]))


# Optimized solution
n, k = list(map(int, input().split()))
a = []
count = 0

for i in range(n):
    a.append(list(map(int, input().split())))
a = sorted(a, key = lambda x: x[0])
i = 0
while count < k:
    count += a[i][1]
    ans = a[i][0]
    i += 1
print (ans)
# Original solution
import collections

d={}
N,K=list(map(int,input().split()))

for i in range(N):
    a,b=list(map(int,input().split()))
#    print a,b
    if a in d:
        d[a] = d[a] + b
    else:
        d[a]=b
    td={}
    cnt=0
#    print d
    for key in sorted(d):
#        print key
        if cnt<=K:
            td[key]=d[key]
        else:
            break
    d=td

aa=None
cnt=0
#print d
for k in sorted(d):
    aa=k
    cnt+=d[k]
#    print cnt
    if cnt>=K:
        break
print(aa)


# Optimized solution

d={}
N,K=list(map(int,input().split()))

for i in range(N):
    a,b=list(map(int,input().split()))
#    print a,b
    if a in d:
        d[a] = d[a] + b
    else:
        d[a]=b
#    td={}
#    cnt=0
#    print d
#    for key in sorted(d):
#        print key
#        if cnt<=K:
#            td[key]=d[key]
#        else:
#            break
#    d=td

aa=None
cnt=0
#print d
for k in sorted(d):
    aa=k
    cnt+=d[k]
#    print cnt
    if cnt>=K:
        break
print(aa)
# Original solution
N,K = list(map(int,input().split()))
Z = []
for i in range(N):
    a,b = list(map(int,input().split()))
    Z.append((a,b))
Z = sorted(Z)
for a,b in Z:
    K -= b
    if K <= 0:
        print(a)
        break

# Optimized solution
N,K = list(map(int,input().split()))
AB = []
for i in range(N):
    a,b = list(map(int,input().split()))
    AB.append((a,b))

AB.sort()

cnt = 0
for ab in AB:
    a,b = ab
    cnt += b
    if cnt >= K:
        print(a)
        break
# Original solution
n, k = list(map(int, input().split()))
l = []
for i in range(n):
    a, b = list(map(int, input().split()))
    l += [a] * b
l.sort()
print((l[k-1]))


# Optimized solution
n, k = list(map(int, input().split()))
l = [0] * (10**5 + 1)
for i in range(n):
    a, b = list(map(int, input().split()))
    l[a] += b
s = 0
for i, v in enumerate(l):
    s += v
    if s >= k:
        print(i)
        break
# Original solution
N, K = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(N)]
ab.sort()

counter = 0
array1 = []

for i in range(N):
  for j in range(ab[i][1]):
    array1.append(ab[i][0])
    if len(array1) >= K:
      break
    
print((array1[K-1]))

# Optimized solution
N, K = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(N)]
ab.sort()

counter = 0
array1 = []

for i in range(N):
  counter += ab[i][1]
  if K <= counter:
    ans = ab[i][0]
    break

print(ans)
# Original solution
import sys

N, K = (int(i) for i in input().split())
ab_list = [[int(i) for i in input().split()] for i in range(N)]

a = [0]*N
b = [0]*N
for i, ab in zip(list(range(N)), ab_list):
    _a, _b = ab
    a[i] = _a
    b[i] = _b

idx = 0
cnt = 0
while N > cnt:
    min = 1e6
    for i in range(cnt, N):
        if min > a[i]:
            min = a[i]
            idx = i
    a_tmp = a[cnt]
    b_tmp = b[cnt]
    a[cnt] = a[idx]
    b[cnt] = b[idx]
    a[idx] = a_tmp
    b[idx] = b_tmp
    cnt += 1

#print a, b                                                                                                                                                                                                                                   

num = 0
for i in range(N):
    num += b[i]
    if num >= K:
        print(a[i])
        break


# Optimized solution
import sys

N, K = (int(i) for i in input().split())
ab_list = [[int(i) for i in input().split()] for i in range(N)]
ab_list = sorted(ab_list, key=lambda ab: ab[0])

num = 0
for i in range(N):
    num += ab_list[i][1]
    if num >= K:
        print(ab_list[i][0])
        break
# Original solution
n, k = list(map(int, input().split()))

a = []
b = []
for i in range(n):
    tmp1, tmp2 = list(map(int, input().split()))
    a.append(tmp1)
    b.append(tmp2)

p_list = []
t = list(zip(a, b))
ts = sorted(t)
a, b = list(zip(*ts))
for ai, bi in zip(a, b):
    for i in range(bi):
        p_list.append(ai)

print((p_list[k-1]))




# Optimized solution
n, k = list(map(int, input().split()))

a = []
b = []
for i in range(n):
    tmp1, tmp2 = list(map(int, input().split()))
    a.append(tmp1)
    b.append(tmp2)

p_list = []
t = list(zip(a, b))
ts = sorted(t)
a, b = list(zip(*ts))
ans = 0
count = 0
for ai, bi in zip(a, b):
    count += bi
    if count >= k:
        ans = ai
        break

print(ans)
# Original solution
def main():
    MAX = 100010
    n,k = list(map(int,input().split()))
    m = {}
    for x in range(100010):
        m[x] = 0
    for x in range(n):
        a,b = list(map(int,input().split()))
        m[a] += b
    if k == 0:
        print((list(m.keys())[0]))
        return
    for key,value in list(m.items()):
        k-=value
        if k <= 0:
            print(key)
            return

if __name__ == '__main__':
    main()


# Optimized solution
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [eval(input()) for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(eval(input())) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


sys.setrecursionlimit(1000000)
MOD = int(1e09) + 7
INF = int(1e30)


def main():
    # sys.stdin = open("Sample.txt")
    N, K = Scanner.map_int()
    S = defaultdict(int)
    for i in range(N):
        a, b = Scanner.map_int()
        S[a] += b
    n = 0
    for i in range(100001):
        n += S[i]
        if n >= K:
            print(i)
            return
    return


if __name__ == "__main__":
    main()
# Original solution
xx = []
n, k = list(map(int, input().split()))
for i in range(n):
  a, b = list(map(int, input().split()))
  for j in range(b):
    xx.append(a)

yy = sorted(xx)
print((yy[k-1]))


# Optimized solution
xx = []
n, k = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(n)]
xx = sorted(ab, key= lambda x:x[0])

ans = 0
for i in range(n):
  ans += xx[i][1]
  if ans >=  k:
    print((xx[i][0]))
    break
# Original solution
N,K = list(map(int,input().split()))
data = []
def insert(num,N,K):
    x = 0
    for i in range(N):
        x += num[i][1]
        if x >= K:
            print((num[i][0]))
            break
num = [list(map(int,input().split())) for i in range(N)]
num.sort(key=lambda x:x[0])
insert(num,N,K)


# Optimized solution
N,K = list(map(int,input().split()))
data = []
def insert(num,N,K):
    for i in range(N):
        if num[i][1] >= K:
            print((num[i][0]))
            break
        else:
            K -= num[i][1]
num = [list(map(int,input().split())) for i in range(N)]
num.sort(key=lambda x:x[0])
insert(num,N,K)
# Original solution
N, K = list(map(int,input().split()))
hairetu = []
for _ in range(N):
  a, b = list(map(int,input().split()))
  hairetu.extend([a]*b)
print((sorted(hairetu)[K-1]))

# Optimized solution
import sys
N, K = list(map(int,input().split()))
hairetu = []
for _ in range(N): hairetu.append(list(map(int,input().split())))
hairetu.sort()
cnt = 0
for i in range(N):
  cnt += hairetu[i][1]
  if K <= cnt:
    print((hairetu[i][0]))
    sys.exit()
# Original solution
def main():
    N, K = (int(i) for i in input().split())
    A = []
    B = []
    from bisect import bisect_left
    AB = [[int(i) for i in input().split()] for j in range(N)]
    AB.sort()
    A = [a[0] for a in AB]
    B = [a[1] for a in AB]
    from itertools import accumulate
    B = list(accumulate(B))
    idx = bisect_left(B, K)
    # print(A, B, idx)
    print((A[idx]))


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, K = (int(i) for i in input().split())
    AB = [[int(i) for i in input().split()] for j in range(N)]
    AB.sort()
    cur = 0
    for a, b in AB:
        if cur+b < K:
            cur += b
            continue
        else:
            return print(a)


if __name__ == '__main__':
    main()
# Original solution
n, k = list(map(int, input().split()))
data = [10 ** 9]
for i in range(n):
    a, b = list(map(int, input().split()))
    temp = [a] * b
    data.extend(temp)

rev = sorted(data)
#rev = data.reverse() > 大きい順
ans = rev[k - 1]
print(ans)


# Optimized solution
n, k = list(map(int, input().split()))
'''
data = [10 ** 9]
for i in range(n):
    a, b = map(int, input().split())
    temp = [a] * b
    data.extend(temp)

rev = sorted(data)
#rev = data.reverse() > 大きい順
ans = rev[k - 1]
print(ans)

>最大で（１０*＊１０）サイズリストになる。

バケツソートが必要。
（出現回数を格納したリストから、答えを出す。）
'''

data = [0] * (10 ** 5 + 1)
for i in range(n):
    a, b = list(map(int, input().split()))
    data[a] += b

count = 0
for i in range(1, 10 ** 5 + 1):
    count += data[i]
    if (count >= k):
        ans = i
        break

print(ans)
# Original solution
#61c
N,K = list(map(int, input().split()))

array = []

for i in range(N):
    a,b = list(map(int, input().split()))
    array += [a for i in range(b)]
    
array.sort(reverse=False) #O( n・log(n) )
print((array[K-1]))

# Optimized solution
#61c
#import random #テスト用

N,K = list(map(int, input().split()))#N,K<=10**5　#Nのループで考えないとTLEしそう
#N = 100000 #test

a_b_dict = dict()

#b_sum = 0 #test

for i in range(N):
    a,b = list(map(int, input().split()))
    #a = random.randint(1, 100000) #test
    #b = random.randint(1, 100000) #test
    
    if a not in a_b_dict:
        a_b_dict[a] = 0
    
    a_b_dict[a] += b
    
    #b_sum += b #test
    
a_b_dict_sorted = sorted(list(a_b_dict.items()), key=lambda x:x[0])

#K = random.randint(1, b_sum)

position = 0
for ab in a_b_dict_sorted:
    b = ab[1]
    position += b
    
    if position >= K:
        print((ab[0]))
        break
# Original solution
N, K = list(map(int, input().split()))
a = [0]*N
b = [0]*N
c = [0]*N
for i in range(N):
  a[i], b[i] = list(map(int, input().split()))
  c[i] = i
c.sort(key=lambda i:a[i])
s = 0
for j in range(N):
  s += b[c[j]]
  if s>=K:
    print(a[c[j]])
    break

# Optimized solution
N, K = list(map(int, input().split()))
a = [0]*N
b = [0]*N
for i in range(N):
  a[i], b[i] = list(map(int, input().split()))
sa = list(range(N))
sa.sort(key=lambda i:a[i])
c = 0
for i in range(N):
  c += b[sa[i]]
  if c >= K:
    print(a[sa[i]])
    break
# Original solution
n, k = list(map(int, input().split()))

ans = []
for i in range(n):
    a, b = list(map(int, input().split()))
    ans.append([a]*b)

ans = sorted(sum(ans, []))
print((ans[k-1]))


# Optimized solution
n, k = list(map(int, input().split()))

dict_num = {}
for i in range(n):
    a, b = list(map(int, input().split()))
    if a in dict_num:
        dict_num[a] += b
    else:
        dict_num[a] = b

array = []
for n, t in list(dict_num.items()):
    array.append([n, t])

array.sort()

cnt = 0
for a in array:
    cnt += a[1]
    if cnt >= k:
        print((a[0]))
        break
# Original solution
import sys
from collections import Counter

def solve():
    N, K = list(map(int, input().split()))
    cntr = Counter()

    for i in range(N):
        ai, bi = list(map(int, sys.stdin.readline().split()))
        cntr[ai] += bi

    cntr = sorted(cntr.items())
    # print(cntr)

    cnt = 0

    for a, b in cntr:
        cnt += b

        if cnt >= K:
            print(a)
            return


if __name__ == '__main__':
    solve()

# Optimized solution
import sys

def solve():
    N, K = list(map(int, input().split()))

    cnt = [0]*(10**5 + 1)

    for i in range(N):
        ai, bi = list(map(int, sys.stdin.readline().split()))
        cnt[ai] += bi

    tot = 0

    for i, cnti in enumerate(cnt):
        tot += cnti

        if tot >= K:
            print(i)
            return

if __name__ == '__main__':
    solve()
# Original solution
import bisect

N, K = list(map(int, input().split()))
AB = [tuple(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x: x[0])
sumB = [0]
for a, b in AB:
    sumB.append(sumB[-1] + b)
print((AB[bisect.bisect_left(sumB, K) - 1][0]))


# Optimized solution
N, K = list(map(int, input().split()))
AB = [tuple(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x: x[0])
sumB = 0
for a, b in AB:
    sumB += b
    if sumB >= K:
        print(a)
        break
# Original solution
N, K = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(N)]

AB.sort()


result = []

count = 0
for a,b in AB:
    min_k = min(b,K)
    result += [a]*min_k
    count += min_k
    if count >= K:
        break

print((result[K-1]))

# Optimized solution
N, K = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(N)]

AB.sort()

result = 0
for a,b in AB:
    K -= b
    result = a
    if K <= 0:
        break

print(result)
# Original solution
n,k=list(map(int,input().split()))
ans=[0]*(10**5+1)
for i in range(n):
    a,b=list(map(int,input().split()))
    ans[a]+=b
    
v=0
for i in range(k):
    v+=ans[i]
    if ans[i]==0:
        i-=1
    if v>=k:
        a=i
        break
    
print(a)

# Optimized solution
n,k=list(map(int,input().split()))
count=0
ba=[0]*(10**5+1)
for i in range(n):
    a,b=list(map(int,input().split()))
    ba[a]+=b
 
for i in range(len(ba)):
    k-=ba[i]
    if k<=0:
        print(i)
        break
# Original solution
n,k=list(map(int,input().split()))
ll=[list(map(int,input().split())) for i in range(n)]

l=[]
for i in ll:
    for j in range(i[1]):
        l.append(i[0])
l.sort()
print((l[k-1]))


# Optimized solution
n, k = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(n)]
l = [0] * (10 ** 5 + 1)
for i in ab:
    l[i[0]] += i[1]
s = 0
for i in range(10 ** 5 + 1):
    s += l[i]
    if s >= k:
        print(i)
        break
# Original solution
n,k=list(map(int,input().split()))
ab=[]
for i in  range(n):
    a,b=list(map(int,input().split()))
    ab.append([a,b])
ab.sort()
x=[]
for i in range(n):
    x.extend([ab[i][0]]*ab[i][1])
    if len(x)>k:
        break
print((x[k-1]))


# Optimized solution
n,k=list(map(int,input().split()))
ab=[]
for i in  range(n):
    a,b=list(map(int,input().split()))
    ab.append([a,b])
ab.sort()
c=0
for i in range(n):
    c+=ab[i][1]
    if c>=k:
        print((ab[i][0]))
        exit()
# Original solution
n,k=list(map(int,input().split()))
L=[]
for s in range(n):
  a,b=list(map(int,input().split()))
  L.append((a,b))
#print(L)
L=sorted(L,key=lambda x:x[0])
#print(L)
sun=0
for s in L:
  sun+=s[1]
  if sun+1>k:
    print((s[0]))
    exit()

# Optimized solution
n,k=list(map(int,input().split()))
for s,t in sorted([list(map(int,input().split()))for i in range(n)],key=lambda x:x[0]):
    if k>t:
        k-=t
    else:
        print(s)
        exit()
# Original solution
n,k=list(map(int,input().split()))
for s,t in sorted([list(map(int,input().split()))for i in range(n)],key=lambda x:x[0]):
    if k>t:
        k-=t
    else:
        print(s)
        exit()
    

# Optimized solution
n,k=list(map(int,input().split()))
for a,b in sorted([list(map(int,input().split()))for i in range(n)],key=lambda x:x[0]):
    if k>b:
        k-=b
    else:
        print(a)
        break
# Original solution
l1=[]
l2=[]
n,k=list(map(int,input().split()))
for i in range(n):
  l1.append(input().split())
for j in range(n):
  for l in range(int(l1[j][1])):
    l2.append(int(l1[j][0]))
l2.sort()
print((l2[k-1]))

# Optimized solution
l1=[]
ret=0
c=0
n,k=list(map(int,input().split()))
for i in range(n):
  l1.append(input().split())
num=[0]*(10**5)

for j in range(n):
  num[int(l1[j][0])-1]+=int(l1[j][1])
#print(num)
for l in range(10**5):
  if num[l]>=k:
    print((l+1))
    break
  k-=num[l]
# Original solution
N,K = list(map(int,input().split()))
list1 = []
for i in range(N):
    a,b = list(map(int,input().split())) 
    list2 = [a]*b
    list1 += list2
list1.sort()
print((list1[K-1]))

# Optimized solution
N,K = list(map(int,input().split()))
list1 = []
for i in range(N):
    list1.append(list(map(int,input().split())))
list1.sort()
list2 = []
for j in range(N):
    list2 += [list1[j][0]]*list1[j][1]
    if len(list2) >= K:
        break
print((list2[K-1]))
# Original solution
N,K = list(map(int,input().split()))
list1 = []
for i in range(N):
    list1.append(list(map(int,input().split())))
list1.sort()
list2 = []
for j in range(N):
    list2 += [list1[j][0]]*list1[j][1]
    if len(list2) >= K:
        break
print((list2[K-1]))

# Optimized solution
N,K = list(map(int,input().split()))
list1 = []
for i in range(N):
    list1.append(list(map(int,input().split())))
num = [0]*(10**5+1)
for j in range(N):
    num[list1[j][0]] += list1[j][1]
c = 0
d = 0
for k in range(10**5+1):
    c += num[k]
    if c >= K:
        d = k
        break
print(d)
# Original solution
N, K = list(map(int, input().split()))
A = []
for i in range(N):
    a, b = list(map(int, input().split()))
    for k in range(b):
        A.append(a)
A.sort()
print((A[K-1]))

# Optimized solution
N, K = list(map(int, input().split()))
A = [0 for _ in range(10 ** 5)]
for i in range(N):
    a, b = list(map(int, input().split()))
    A[a - 1] += b
for i in range(10 ** 5):
    if K - A[i] > 0:
        K = K - A[i]
    else:
        print((i + 1))
        break
# Original solution
def resolve():
	n, k = list(map(int, input().split()))
	arr = [0]*(10**5+1)
	for i in range(n):
		a, b = list(map(int, input().split()))
		arr[a] += b
	for i in range(len(arr)):
		if arr[i] >= k:
			print(i)
			break
		k -= arr[i]
resolve()

# Optimized solution
def resolve():
	n, k = list(map(int, input().split()))
	B = [0]*10**5
	for _ in range(n):
		a, b = list(map(int, input().split()))
		B[a-1] += b
	cnt = 0
	for i in range(len(B)):
		cnt += B[i]
		if cnt >= k:
			print((i+1))
			break
resolve()
# Original solution
N, K = list(map(int, input().split()))
a = []
b = []
hairetu = []
for i in range(N):
    A, B = list(map(int, input().split()))
    h = [A for i in range(B)]
    hairetu.extend(h)

hairetu.sort()
print((hairetu[K-1]))


# Optimized solution
N, K = list(map(int, input().split()))
a = []
b = []
hairetu = []
for i in range(N):
    A, B = list(map(int, input().split()))
    hairetu.append([A, B])

hairetu.sort()
for i in range(N):
    K -= hairetu[i][1]
    if K <= 0:
        print((hairetu[i][0]))
        break
# Original solution
N, K = list(map(int, input().split()))
li = [list(map(int, input().split())) for n in range(N)]

a = []

for i in li:
  b = [i[0]] * i[1]
  a.extend(b)

a.sort()

print((a[K-1]))

# Optimized solution
from collections import defaultdict
d = defaultdict(int)

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

for i in li:
  d[i[0]] += i[1]
  
count = 0
new = sorted(d)

for i in new:
  count += d[i]
  
  if count >= K:
    print(i)
    break
# Original solution
# -*- coding: utf-8 -*-

import sys
import os
import math

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

A = []
for i in range(N):
    a, b = list(map(int, input().split()))
    A += [a] * b

A.sort()
print((A[K-1]))

# Optimized solution
# -*- coding: utf-8 -*-

import sys
import os
import math

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

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

A.sort()

i = 0
cnt = 0
for a in A:
    v = a[0]
    num = a[1]
    cnt += num

    if cnt >= K:
        print(v)
        break
# Original solution
import sys
input = sys.stdin.readline
n,k=list(map(int,input().split()))
ab=[list(map(int,input().split())) for _ in range(n)]
ab.sort()
l=[]
m=0
for i in range(len(ab)):
    for j in range(ab[i][1]):
        l.append(ab[i][0])
        m+=1
    if m>k:break
print((l[k-1]))

# Optimized solution
import sys
input = sys.stdin.readline
n,k=list(map(int,input().split()))
l=[0]*10**5
for i in range(n):
    a,b=list(map(int,input().split()))
    l[a-1]+=b
m=0
for i in range(10**5):
    if m+l[i]>=k:print((i+1));break
    else: m+=l[i]