CodeEff/ECCO huggingface dataset:
# Original solution
N,K = list(map(int,input().split()))
big_array = []
for i in range(N):
    a,b = list(map(int,input().split()))
    for j in range(b):
        big_array.append(a)
big_array.sort()
print((big_array[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()
while K > 0:
    for _ab in ab:
        K -= _ab[1]
        if K <= 0:
            print((_ab[0]))
            break
# Original solution
N,K=list(map(int,input().split()))
ab=[[0]*2 for i in range(N)]
for i in range(N):
  ab[i]=list(map(int,input().split()))
  
ab=sorted(ab,key=lambda x:x[0])
i=-1
while(K > 0):
  i+=1
  K -= ab[i][1]

print((ab[i][0]))

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

ab.sort()

id = 0
for a, b in ab:
    if id + b >= K:
        print(a)
        break
    else:
        id += b
# Original solution
line_one = input().split()
n = int(line_one[0])
k = int(line_one[1])

arr = []
for i in range(n):
    line = input().split()
    a = int(line[0])
    b = int(line[1])
    arr += [a] * b

arr = sorted(arr)
print(arr[k-1])


# Optimized solution
line_one = input().split()
n = int(line_one[0])
k = int(line_one[1])

tuples = []
arr = []
for i in range(n):
    line = input().split()
    tuples.append( (int(line[0]), int(line[1]))  )

tuples = sorted(tuples, key = lambda x: x[0])

total = 0
for tup in tuples:
    total += tup[1]
    if total >= k:
        print(tup[0])
        break
# Original solution

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

now = 0
lis = []

for i in range(N):

    a,b = list(map(int,input().split()))
    lis += [a]*b



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


# Optimized solution

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

now = 0
dic = {}
lis = []

for i in range(N):

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

    if a in dic:
        dic[a] += b
    else:
        dic[a] = b
        lis.append(a)

lis.sort()

for i in lis:

    now += dic[i]

    if now >= K:
        print (i)
        break
# Original solution
n, k = list(map(int, input().split()))
l = [list(map(int, input().split())) for _ in range(n)]
c = []
for i in range(n):
    for _ in range(l[i][1]):
        #print(l[i][0])
        c.append(l[i][0])
    
c.sort()
print((c[k-1]))

# Optimized solution
N,K=list(map(int,input().split()))
li=sorted([list(map(int,input().split())) for _ in range(N)])
for l in li:
    K-=l[1]
    if K<=0:
        print((l[0]))
        break
# Original solution
n, k = list(map(int, input().split()))
count = 0
ab = [list(map(int, input().split())) for _ in range(n)]
ab = sorted(ab)
i = 0
while count < k:
  a, b = ab[i]
  count += b
  i += 1
  if count >= k:
    print(a)
    break


# Optimized solution
N, K = list(map(int, input().split()))
now = 0
ab = [list(map(int, input().split())) for _ in range(N)]
ab = sorted(ab)
for a, b in ab:
  if now < K <= now+b:
    print(a)
    exit()
  now += b
# Original solution
# Big Array
n,k =  list(map(int, input().split()))

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

A2 = []
for s in A1:
    A2.extend(s)
print(( sorted(A2)[k-1] ))

# Optimized solution
# Big Array
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(key=lambda x:x[0])

cnt = 0
for i in range(n):
    cnt += A[i][1]
    if ( cnt >= k ):
        print((A[i][0]))
        break
# Original solution
import sys
from collections import deque

if sys.platform in ['ios','win32','darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(eval(input()))
def MAP(): return [int(s) for s in input().split()]

N, K = MAP()
A = [MAP() for _ in range(N)]

A.sort()
B = deque()
for a in A:
	ai, bi = a
	B.extend([ai]*bi)
# print(B)
print((B[K-1]))

# Optimized solution
import sys
from collections import deque

if sys.platform in ['ios','win32','darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(eval(input()))
def MAP(): return [int(s) for s in input().split()]

N, K = MAP()
A = [MAP() for _ in range(N)]

A.sort()
cur = 0
for a in A:
	cur += a[1]
	if cur >= K:
		print((a[0]))
		break
# Original solution
n,k = list(map(int,input().split()))
a =[]
for i in range(n):
    a.append(list(map(int,input().split())))
a.sort()
b =[]
for i in range(n):
    for j in range(a[i][1]):
        b.append(a[i][0])
print((b[k-1]))

# Optimized solution
n,k = list(map(int,input().split()))
a =[]
for i in range(n):
    a.append(list(map(int,input().split())))
a.sort()
b =[]
c =[]
for i in range(n):
    b.append(a[i][0])
    c.append(a[i][1])
for i in range(n-1):
    c[i+1] = c[i]+c[i+1]
ans = c[-1]
for i in range(1,n):
    if c[i] >= k:
        ans = b[i]
        break

print(ans)
# Original solution
# N,Kの把握
l1 = list(map(int, input().split()))
N = l1[0]
K = l1[1]
 

#空リストを作成。a,bを把握し、リストにaを追加、b回。これをN回くりかえし
l3 = []
for i in range(N):
	l2 = list(map(int, input().split()))
	a = l2[0]
	b = l2[1]
	if len(l3) >= K :
		if max(l3) <= a:
			pass #リストの要素数がKを上回っている場合、要素の最大値よりも大きい数は追加しない。
		else:
			adl=[a] * b
			l3 = l3 + adl
			for j in range(len(l3)-K):
				l3.remove(max(l3))
	else:
		adl=[a] * b
		l3 = l3 + adl
 
# リストをソートし、K番目を出力
l3.sort()
print((str(l3[K-1])))

# Optimized solution
# N,Kの把握
l1 = list(map(int, input().split()))
N = l1[0]
K = l1[1]

#リストをすぐに作成するのが悪手。数値と回数をセット作成
dic = {}
for i in range(N):
	l2 = list(map(int, input().split()))
	a = l2[0]
	b = l2[1]
	if a in dic:
		dic[a] += b #既に存在する数値であればそのまま回数を＋
	else:
		dic.update({a: b}) #新規の数値であれば追加

dic = sorted(list(dic.items()), key=lambda x:x[0])

x = 0
for key, value in dic: #回数値を足していき、総回数＞＝Kとなったときの数値を出力する。
	x += value
	if x >= K:
		print((str(key)))
		break
# Original solution
inp = input().split(" ")
N = int(inp[0])
K = int(inp[1])

arr = []
indicies = [0]

for i in range(N):
	inp = input().split(" ")
	a = int(inp[0])
	b = int(inp[1])
	if len(arr) == 0 or a >= arr[-1]:
		arr += [a] * b
		indicies.append(len(arr))
	elif a <= arr[0]:
		arr = ([a] * b) + arr
		for i in range(len(indicies)):
			indicies[i] += b
		indicies.append(0)
	else:
		index = 0
		for i in range(len(indicies)):
			i = indicies[i]
			if a >= arr[i-1] and a <= arr[i]:
				index = i
				
				arr = arr[0:i] + ([a] * b) + arr[i:]
				break
		for i in range(len(indicies)):
			if indicies[i] > index:
				indicies[i] += b
		indicies.append(index+b)

print((arr[K-1]))


# Optimized solution
x = input().split(" ")
num_operations = int(x[0])
kth_integer = int(x[1])
field = {}
for p in range(0, num_operations):
 line = input().split(" ")
 a = int(line[0])
 b = int(line[1])
 if a in field:
  field[a] += b
 else:
  field[a] = b
ks = list(field.keys())
ks.sort()
out = list(field.keys())[-1]
for k in ks:
 kth_integer -= field[k]
 if (kth_integer <= 0):
  out = k
  break
print (out)
# Original solution
n,k = list(map(int, input().split()))
res = []
for _ in range(n):
    a,b = list(map(int, input().split()))
    res += [a]*b
res.sort()
print((res[k-1]))

# Optimized solution
n,k = list(map(int, input().split()))
res = [0]*(10**5+1)
for _ in range(n):
    a,b = list(map(int, input().split()))
    res[a] += b

for i, x in enumerate(res):
    if k>x:
        k -= x
    else:
        print(i)
        exit()
# Original solution
# ABC061_C
N, K = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(N)]

lst = []

for i in range(N):
    lst += [AB[i][0]]*AB[i][1]

lst = sorted(lst)
print((lst[K-1]))


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

for i in range(N):
    K -= AB[i][1]
    if K <= 0:
        print((AB[i][0]))
        break
# Original solution
import sys
iN,iK = [int(_) for _ in input().split()]
#aData = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]

d = {}
for _ in range(iN):
    a,b = [int(_) for _ in sys.stdin.readline().split()]
    if a in d:
        d[a] += b
    else:
        d[a] = b
iC = 0
for a in sorted(d.keys()):
    iC += d[a]
    if iK <= iC :
        print(a)
        exit()


# Optimized solution
import sys
def 解():
    iN,iK = [int(_) for _ in input().split()]
    #aData = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]

    d = {}
    for a,b in [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]:
        if a in d:
            d[a] += b
        else:
            d[a] = b
    iC = 0
    for a in sorted(d.keys()):
        iC += d[a]
        if iK <= iC :
            print(a)
            exit()
解()
# Original solution
N, K = list(map(int,input().split()))
A = sorted([list(map(int,input().split())) for _ in range(N)])

cnt = 0
for a in A:
  if(cnt < K-a[1]):
    cnt += a[1]
  else:
    print((a[0]))
    break
"""
unk buriburi
"""

# Optimized solution
N, K = list(map(int,input().split()))
AB = sorted([list(map(int,input().split())) for _ in range(N)])
cnt = 0
for a, b in AB:
  if(cnt < K - b):
    cnt += b
  else:
    print(a)
    break
# Original solution
N, K = [int(x) for x in input().split()]

result = []
for _ in range(N):
    a, b = [int(x) for x in input().split()]
    result.extend([a] * b)

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


# Optimized solution
N, K = [int(x) for x in input().split()]

result = {}
for _ in range(N):
    a, b = [int(x) for x in input().split()]
    if a in result:
        result[a] += b
    else:
        result[a] = b

result = sorted(result.items())

now = 0
for key, value in result:
    now += value

    if now >= K:
        print(key)
        exit()
# Original solution
# -*- coding: utf-8 -*-

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

ab.sort()

for a, b in ab:
    k = k - b
    if k <= 0:
        break

print(a)


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

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

ab.sort()

for a, b in ab:
    k -= b
    if k <= 0:
        break

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

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

print((sorted(ans)[K-1]))

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

A = [0] * 10**5

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

c = 0

for i in range(10**5):
    c += A[i]
    if c >= K:
        break

print((i+1))
# Original solution
n,k = list(map(int,input().split()))
l = []
for i in range(n):
    a,b = list(map(int,input().split()))
    l1 = [a]*b
    l = l + l1
l.sort()
print((l[k-1]))

# Optimized solution
n,k = list(map(int,input().split()))
l = []
for i in range(n):
    a = list(map(int,input().split()))
    l.append(a)
l.sort(key=lambda x:x[0])
count = 0
i = 0
while count < k:
    count = count + l[i][1]
    i = i + 1
print((l[i-1][0]))
# Original solution
# 2019/07/23

input=open(0).readline
n,k=list(map(int,input().split()))
res=[]
for i in range(n):
    a,b=list(map(int,input().split()))
    res+=[a]*b
res.sort()
print((res[k-1]))

# Optimized solution
from heapq import heappop,heappush

input=open(0).readline
n,k=list(map(int,input().split()))
res={}
for i in range(n):
    a,b=list(map(int,input().split()))
    res[a]=res.get(a,0)+b

que=[]
for key,val in list(res.items()):
    heappush(que,(key,val))

while k:
    key,val=heappop(que)
    if val>=k:
        print(key)
        exit()
    k-=val
# Original solution
n, k = list(map(int, input().split()))
a_list = []
for i in range(n):
	a, b = list(map(int, input().split()))
	a_list.extend([a] * b)
	if a_list.count(1) >= k:
		break
a_list.sort()
print((a_list[k-1]))

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

# Optimized solution
n,k=list(map(int,input().split()))
array=[]
for i in range(n):
    array.append(list(map(int,input().split())))
array.sort(key=lambda x:x[0])
q=True
count=0
i=0
while q:
    count +=array[i][1]
    if k<=count:
        print((array[i][0]))
        exit()
    else:
        i +=1
# 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.sort() 




print((p[k-1]))

# Optimized solution
N,K = list(map(int,input().split()))
a = []
M = 0
for i in range(N):
  a.append(list(map(int,input().split())))
a.sort()
for i in range(N):
    K = K-a[i][1]
    if K <= 0:
        print((a[i][0]))
        break
# Original solution
# =map(int,input().split())
n,m=list(map(int,input().split()))
a =[list(map(int,input().split())) for i in range(n)]
ans=[]
# print(a)
for i in range(n):
    for k in range(a[i][1]):
        ans.append(a[i][0])
# print(ans)
# ans=[int(i) for i in ans]
# print(ans)
ans.sort()
print((ans[m-1]))

# Optimized solution
# =map(int,input().split())
n,m=list(map(int,input().split()))
a =[list(map(int,input().split())) for i in range(n)]
a.sort()
import sys
# ans=dict(a)
# print(a)
cnt=0
for i in range(n):
    z=cnt+a[i][1]
    if z>=m:
        print((a[i][0]))
        sys.exit()
    else:
        cnt=z

# print(a)
# for i in range(n):
#     for k in range(a[i][1]):
#         ans.append(a[i][0])
# print(ans)
# ans=[int(i) for i in ans]
# print(ans)
# print(ans[m-1])
# Original solution
import sys
from operator import itemgetter
input = sys.stdin.readline  # NOQA


def main():
    N, K = list(map(int, input().split()))
    ab = [None] * N
    for i in range(N):
        ab[i] = tuple(map(int, input().split()))

    ab.sort(key=itemgetter(0))
    
    cnt = 0
    for a, b in ab:
        cnt += b
        if cnt >= K:
            ans = a
            break
    print(ans)


if __name__ == "__main__":
    main()


# Optimized solution
import sys
input = sys.stdin.readline  # NOQA


def main():
    N, K = list(map(int, input().split()))
    cnt = [0] * (1 + 10**5)

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

    total = 0
    for i in range(1, 10**5 + 1):
        total += cnt[i]
        if total >= K:
            ans = i
            break
    print(ans)


if __name__ == "__main__":
    main()
# Original solution
N,K=list(map(int,input().split()))
dic={}
for i in range(N):
  a,b=list(map(int,input().split()))
  if a in dic:
    dic[a]+=b
  else:
    dic[a]=b
    
dic=sorted(list(dic.items()),key=lambda x:x[0])
for d in range(len(dic)):
  amount=dic[d][1]
  if amount>=K:
    print((dic[d][0]))
    exit(0)
  else:
    K-=amount
  

# Optimized solution
import sys
readline = sys.stdin.readline

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

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

AB = sorted(AB, key = lambda x:x[0])
amount = 0
for a,b in AB:
  amount += b
  if amount >= K:
    print(a)
    break
# Original solution
#Big Array
N, K = list(map(int, input().split()))
a = [0]*N
b = [0]*N
R = []
for i in range(N):
    a[i], b[i] = list(map(int, input().split()))
for i in range(N):
    for j in range(b[i]):
        R.append(a[i])
R.sort()
print((R[K-1]))

# Optimized solution
#Big Array
N, K = list(map(int, input().split()))
a = [0]*(N)
b = [0]*(N)
R = [0]*(10**5+1)
ans = 0
for i in range(N):
    a[i], b[i] = list(map(int, input().split()))
for i in range(N):
    R[a[i]] = R[a[i]] + b[i]
j = 0
while K > 0:
    K = K - R[j]
    ans = ans + 1
    j = j + 1
print((ans-1))
# Original solution
from collections import defaultdict
def main():
    n, k = list(map(int, input().split()))
    d = defaultdict(int)
    for _ in range(n):
        a, b = list(map(int, input().split()))
        d[a] += b
    A = sorted(list(d.items()), key = lambda x: x[0])
    count = 0
    for a in A:
        count += a[1]
        if count >= k:
            print((a[0]))
            exit()

if __name__ == '__main__':
    main()


# Optimized solution
from collections import defaultdict
def main():
    n, k = list(map(int, input().split()))
    D = defaultdict(int)
    for _ in range(n):
        a, b = list(map(int, input().split()))
        D[a] += b
    for d in sorted(list(D.items()), key = lambda x: x[0]):
        k -= d[1]
        if k <= 0:
            print((d[0]))
            break

if __name__ == '__main__':
    main()
# 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()))

a, b = list(zip(*sorted(zip(a, b))))

count = 0
while K > 0:
    K -= b[count]
    count += 1

print((a[count - 1]))

# Optimized solution
import sys
input = sys.stdin.readline

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()))

a, b = list(zip(*sorted(zip(a, b))))

count = 0
while K > 0:
    K -= b[count]
    count += 1

print((a[count - 1]))
# Original solution
import bisect
n,k= (int(i) for i in input().split())
array = []
for i in range(n):
 a,b= (int(i) for i in input().split())
 for j in range(b):
  bisect.insort(array, a, lo=0, hi=len(array))
print((array[k-1]))

# Optimized solution
import bisect
n,k= (int(i) for i in input().split())
array = []
for i in range(n):
 a,b= (int(j) for j in input().split())
 array.append((a,b))
array = sorted(array)
cnt = 0
for ab in array:
    a,b = ab
    cnt += b
    if cnt >= k:
        print(a)
        break
# Original solution
N,K=list(map(int,input().split()))
c=[]
for i in range(N):
	a,b=list(map(int,input().split()))
	c+=[a]*b

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

# Optimized solution
N,K=list(map(int,input().split()))
c=[0]*N
for i in range(N):
	a,b=list(map(int,input().split()))
	c[i]=(a,b)
c.sort()
i,j=0,0
while i<=K-1:
	i+=c[j][1]
	if i>=K:break
	j+=1
print(c[j][0])
# Original solution
import sys
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, *AB = list(map(int, read().split()))
    c = Counter()
    for a, b in zip(*[iter(AB)] * 2):
        c[a] += b

    num = 0
    for k, n in sorted(c.items()):
        num += n
        if num >= K:
            ans = k
            break

    print(ans)
    return


if __name__ == '__main__':
    main()


# Optimized solution
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, *AB = list(map(int, read().split()))
    vec = [0] * (10 ** 5 + 1)
    for a, b in zip(*[iter(AB)] * 2):
        vec[a] += b

    total = 0
    for i, n in enumerate(vec):
        total += n
        if total >= K:
            ans = i
            break

    print(ans)
    return


if __name__ == '__main__':
    main()
# Original solution
# ABC061 C - Big Array
from operator import itemgetter
N,K = list(map(int,input().split()))
A = []
B = []
AB = [[] for _ in range(N)]

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

AB.sort(key=itemgetter(0, 1))

ans = 0
if len(AB) == 1:
    ans = AB[0][0]
    print(ans)
    exit()

for i in range(N):
    if i == 0:
        AB[0].append(AB[0][1])
        continue
    AB[i].append(AB[i-1][2]+AB[i][1])

for i in range(N):
    if i == 0:
       f = 0
       t = AB[0][2]
       if f < K <= t:
           ans = AB[0][0]
           break
       continue
    f = AB[i-1][2]
    t = AB[i][2]
    if f < K <= t:
        ans = AB[i][0]
        break
print(ans)

# Optimized solution
n,k=list(map(int,input().split()))
ab=[]
for i in range(n):
  aa,bb=list(map(int,input().split()))
  ab.append([aa,bb])
ab.sort(key=lambda x: x[0])
a,b=[],[]
for aa,bb in ab:
  a.append(aa)
  b.append(bb)
from itertools import accumulate
c=list(accumulate(b))
idx=-1
for i in range(n):
  if i==0:
    if 0<=k<=c[i]:
      idx=i
      break
    continue
  if c[i-1]<k<=c[i]:
    idx=i
    break
print((a[idx]))
# Original solution
n, k = list(map(int,input().split(" ")))
l = []
for i in range(n):
    a, b = list(map(int, input().split(" ")))
    l.extend([a] * b)
l.sort()
print((l[k - 1]))


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

    num_count[a] += b

temp = 0
for key in sorted(num_count.keys()):
    temp += num_count[key]
    if temp >= k:
        print(key)
        break
# Original solution
N,K = list(map(int, input().split()))
li=[]
for i in range(N):
    a,b = list(map(int, input().split()))
    for j in range(b):
        li.append(a)
li.sort()
print((li[K-1]))

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

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

ans=0
i=0
while K>0 and i<N:
    K-=AB[i][1]
    ans=AB[i][0]
    i+=1

print(ans)
# Original solution
n, k = list(map(int, input().split()))
A = sorted([[int(i) for i in input().split()] for i in range(n)])
cnt = 0
for i in range(n):
    cnt += A[i][1]
    if cnt >= k:
        print((A[i][0]))
        break

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

cnt = 0
for i in range(N):
    cnt += A[i][1]
    if cnt >= K:
        print((A[i][0]))
        break
# Original solution
N, K = list(map(int,input().split()))
array = []
for i in range(N):
    a,b = list(map(int,input().split()))
    array += [a] * b
array.sort()
ans = array[K-1]
print(ans)

# Optimized solution
N, K = list(map(int,input().split()))
info = [list(map(int,input().split())) for i in range(N)]
info.sort()
count = 0
for e in info:
    count += e[1]
    if count >= K:
        ans = e[0]
        break
print(ans)
# Original solution
def rren(): return list(map(int, input().split()))


a = set()
b = dict()
N, K = rren()

for i in range(N):
    a_t, b_t = rren()
    if(a_t not in a):
        a.add(a_t)
        b[a_t] = b_t
    else:
        b[a_t] += b_t

count = K
for i in range(K-1):
    mn = min(a)
    nu = b[mn]
    a.discard(mn)
    count -= nu
    if(count <= 0):
        print(mn)
        break


# Optimized solution
def rren(): return list(map(int, input().split()))


a = set()
b = dict()
N, K = rren()

for i in range(N):
    a_t, b_t = rren()
    if(a_t not in a):
        a.add(a_t)
        b[a_t] = b_t
    else:
        b[a_t] += b_t

li_a = list(a)
li_a.sort()
count = K
for i in range(K):
    count -= b[li_a[i]]
    if(count <= 0):
        print((li_a[i]))
        break
# Original solution
# -*- coding: utf-8 -*-

def flatten(nested_list):
    return [e for inner_list in nested_list for e in inner_list]

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

a = [0] * N
b = [0] * N
ab = [[0, 0]] * N
for i in range(N):
    _a, _b = list(map(int, input().split()))
    ab[i] = [_a, _b]
ab.sort(key=lambda x:x[0])

ans = flatten([[a] * b for a, b in ab])
print(ans[K - 1])


# Optimized solution
# -*- coding: utf-8 -*-
N, K = list(map(int, input().split()))

ab = [[0, 0]] * N
for i in range(N):
    _a, _b = list(map(int, input().split()))
    ab[i] = [_a, _b]
ab.sort(key=lambda x:x[0])

j = 0
index = 0
while j < K:
    j += ab[index][1]
    if j < K:
        index += 1

print(ab[index][0])
# Original solution
# a 200
from collections import Counter
from math import factorial

N = int(eval(input()))
a = list(map(int, input().split()))

#累計和
wa = [0]
for ai in a:
    wa.append(wa[-1]+ai)
wa = wa[1:]

def combination(n, r):
    return factorial(n)//(factorial(r)*factorial(n-r))

c = Counter(wa)
ans = 0

for k,v in list(c.items()):
    if v<2: continue
    ans += combination(v, 2)
    
ans += c[0]
print(ans)

# Optimized solution
N = int(eval(input()))
a = list(map(int , input().split()))
s = [0]
d = {0:1}
for i in range(N):
    nex = s[-1]+a[i]
    s.append(nex)
    if nex not in d:
        d[nex] = 0
    d[nex] += 1
    
ans = 0
for v in list(d.values()):
    if v >= 2:
        ans += int(v*(v-1)/2)
print(ans)