Problem:
 Score : 300 points    Problem Statement There is an empty array.
The following N operations will be performed to insert integers into the array.
In the i -th operation (1≤i≤N) , b_i copies of an integer a_i are inserted into the array.
Find the K -th smallest integer in the array after the N operations.
For example, the 4 -th smallest integer in the array \{1,2,2,3,3,3\} is 3 .      Constraints  1≤N≤10^5   1≤a_i,b_i≤10^5   1≤K≤b_1…+…b_n  All input values are integers.         Input Input is given from Standard Input in the following format:  N  K  a_1  b_1  :  a_N  b_N       Output Print the K -th smallest integer in the array after the N operations.        Sample Input 1 3 4
1 1
2 2
3 3      Sample Output 1 3  The resulting array is the same as the one in the problem statement.       Sample Input 2 10 500000
1 100000
1 100000
1 100000
1 100000
1 100000
100000 100000
100000 100000
100000 100000
100000 100000
100000 100000      Sample Output 2 1

Solution (Python):
N, K = 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)

Solution (Python):
n,k=map(int,input().split())
X=[0]*10**5
for _ in range(n):
    a,b=map(int,input().split())
    X[a-1]+=b
cnt=0
for i in range(10**5):
    cnt+=X[i]
    if cnt>=k:
        print(i+1)
        break

Solution (Python):
N, K = map(int, input().split())
AB = []
for i in range(N):
    a, b = map(int, input().split())
    AB.append((a,b))
    
B = []
for i in sorted(AB):
    B.append(i[1])

import numpy
B_res = numpy.cumsum(B)


from bisect import bisect_left,bisect_right

print(sorted(AB)[bisect_left(B_res, K)][0])

Solution (Python):
def two_dim_merge_sort(arr):
    if len(arr) <= 1:
        return arr

    mid = len(arr) // 2
    
    left = arr[:mid]
    right = arr[mid:]

    
    left = two_dim_merge_sort(left)
    right = two_dim_merge_sort(right)

    
    return two_dim_merge(left, right)


def two_dim_merge(left, right):
    merged = []
    l_i, r_i = 0, 0

    
    while l_i < len(left) and r_i < len(right):
        
        if left[l_i][0] <= right[r_i][0]:
            merged.append(left[l_i])
            l_i += 1
        else:
            merged.append(right[r_i])
            r_i += 1

    
    if l_i < len(left):
        merged.extend(left[l_i:])
    if r_i < len(right):
        merged.extend(right[r_i:])
    return merged



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

a = [0] * n
b = [0] * n

for i in range(0,n):
    a[i], b[i] = map(int,input().split())

l = [0] * n

for i in range(0,n):
    l[i] = [a[i],b[i]]

ll = two_dim_merge_sort(l)

s = 0

for i in range(0,n):
    s = s + ll[i][1]
    if s >= k:
        ans = ll[i][0]
        break

print(ans)

Solution (Python):
N,K=map(int,input().split(' '))
nums=[0]*(10**5)
for i in range(N):
  a,b=map(int,input().split(' '))
  nums[a-1]+=b
s=0
for i in range(len(nums)):
  s+=nums[i]
  if s>=K:
    print(i+1)
    break
  else:
    continue

Solution (Python):
n,k=map(int,input().split())
ans=[0]*1000001

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

for j in range(len(ans)):
    if k<=ans[j]:
        print(j)
        break
    k-=ans[j]

Solution (Python):
n,k=map(int,input().split())
cnt=0
dic={}
for i in range(n):
  a,b=map(int,input().split())
  if a in dic:
    dic[a]+=b
  else:
    dic[a]=b

dic=sorted(dic.items())
for i,j in dic:
  cnt+=j
  if k<=cnt:
    print(i)
    exit()

Solution (Python):
N, K = map(int, input().split())
ab = [[int(_) for _ in input().split()] for _ in range(N)]
ab = sorted(ab, key=lambda x: x[0])
tmp = 0

for i in ab:
    tmp += i[1]
    if tmp >= K:
        ans = i[0]
        break
print(ans)

Solution (Python):
N, K = map(int, input().split())
li = [0] * (10 ** 5 +1)
for i in range(N):
    a, b = map(int, input().split())
    li[a] += b

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

Solution (Python):
n,k = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(n)]
a.sort()
cnt = 0
for x,y in a:
    cnt += y
    if cnt >= k:
        print(x)
        exit()

Solution (Python):
n, k = map(int, input().split())
n_list = []
for _ in range(n):
    tmp = list(map(int, input().split()))
    n_list.append(tmp)
n_list.sort()
cnt = 0
for arr in n_list:
    cnt += arr[1]
    if k <= cnt:
        print(arr[0])
        break

Solution (Python):
N,K = map(int,input().split())
ab = []
for i in range(N):
    ab.append(list(map(int,input().split())))

ab.sort()

index = 0

for a,b in ab:
    index += b
    if index >= K:
        print(a)
        break

Solution (Python):

N,K=map(int,input().split())
ans=[0 for i in range(10**5)]
for i in range(N):
    a,b=map(int,input().split())
    ans[a-1]+=b
count=0
for i in range(10**5):
    count+=ans[i]
    if count >= K:
        print(i+1)
        break

Solution (Python):
N,K = map(int,input().split())
ab = []



ab = sorted(list(map(int,input().split())) for i in range(N))

s = 0
for l in ab:
    s += l[1]
    if s >= K:
        print(l[0])
        break

Solution (Python):
N,K=map(int,input().split())
from collections import defaultdict
data=[]
for n in range(N):
    data.append(tuple(map(int,input().split())))
data.sort(key=lambda x:x[0])
now=0
for i in range(len(data)):
    now+=data[i][1]
    if now>=K:
        print(data[i][0])
        break

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

count = 0
for x in ab:
    count += x[1]
    if k <= count:
        print(x[0])
        break

Solution (Python):
n,k= (int(i) for i in input().split())
ab = sorted([[int(i) for i in input().split()] for i in range(n)])

count = 0
for x in ab:
    count += x[1]
    if k <= count:
        print(x[0])
        break

Solution (Python):
n,k = map(int,input().split())
ab = []
for i in range(n):
    ab.append([int(j) for j in input().split()])
ab.sort()
cnt = 0
for x in ab:
    if x[1]+cnt < k:
        cnt += x[1]
    elif x[1]+cnt >= k:
        print(x[0])
        break

Solution (Python):
n,k=map(int,input().split())
list=[0]*(10**5+1)
for i in range(n):
    a,b=map(int,input().split())
    list[a]+=b
sum=0
for l in range(1,len(list)):
    sum+=list[l]
    if sum>=k:
        print(l)
        exit()

Solution (Python):
from operator import itemgetter


def main():
    N, K = map(int, input().split())
    arr = [None] * N
    for i in range(N):
        a, b = map(int, input().split())
        arr[i] = (a, b)
    arr.sort(key=itemgetter(0))
    for i in range(N):
        a, b = arr[i]
        K -= b
        if K <= 0:
            print(a)
            break


if __name__ == "__main__":
    main()

Solution (Python):
n,k = map(int,input().split())
s = [list(map(int,input().split())) for i in range(n)]
s.sort()

x = 0

for i in range(len(s)):
    x = x + s[i][1]
    if x >= k:
        print(s[i][0])
        break

Solution (Python):
N, K = map(int,input().split())
AB = sorted([list(map(int,input().split())) for _ in range(N)])

tmp = 0
for a, b in AB:
  if(tmp < K-b):
    tmp += b
  else:
    print(a)
    break

Solution (Python):


"""
Big Array
"""

def answer():
    """
    答えを出力する関数
    """
    l = []
    N, K = map(int, input().split())
    counter = 0

    for _ in range(N):
        l.append(list(map(int, input().split())))

    l.sort()
    for v in l:
        counter += v[1]
        if counter >= K:
            print(v[0])
            break

def main():
    """
    処理を実行する関数
    """
    answer()


if __name__ == '__main__':
    main()

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

beg = 0
for i in range(N):
    beg += ab[i][1]
    if beg >= K:
        print(ab[i][0])
        exit()

Solution (Python):

N,K=map(int,input().split())
A={}
for n in range(N):
	a,b=map(int,input().split())
	A[a]=A.get(a,0)+b
for key in sorted(list(A.keys())):
	K-=A[key]
	if K<=0:
		print(key)
		break

Solution (Python):
import sys
input = sys.stdin.readline
n,k = map(int,input().split())
s = [list(map(int,input().split())) for _ in range(n)]
s.sort()
for i in range(n):
    k -= s[i][1]
    if k <= 0:
        print(s[i][0])
        exit()

Solution (Python):
n,k = map(int,input().split())

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

a.sort()

for i in range(n):
    co += a[i][1]
    if co >= k:
        print(a[i][0])
        break

Solution (Python):
from collections import defaultdict
n, k = map(int, input().split())
dic = defaultdict(int)
for _ in range(n):
  a, b = map(int, input().split())
  dic[a] += b
cnt = 0
for key in sorted(dic):
  if cnt + dic[key] < k:
    cnt += dic[key]
  else:
    print(key)
    break

Solution (Python):
N, K = list(map(int, input().split()))
thelist = [tuple(map(int, input().split())) for i in range(N)]
thelist.sort()
i = x = 0

while x < K:
    x += thelist[i][1]
    i += 1
print(thelist[i-1][0])

Solution (Python):
from collections import defaultdict

def main():
    n, k = map(int, input().split())
    s = defaultdict(int)

    for _ in range(n):
        a, b = map(int, input().split())
        s[a] += b
    
    print(solve(k, s))

def solve(k, s):
    rank = 0

    for i in sorted(s.keys()):
        j = s[i]
        if rank < k <= rank + j:
            return i
        rank += j

main()

Solution (Python):
n,k=map(int,input().split())
l=[]
for i in range(n):
    x,y=map(int,input().split())
    l.append([x,y])
l.sort()
sum=l[0][1]
i=0
while sum<k:
    i+=1
    sum+=l[i][1]
print(l[i][0])

Solution (Python):
n, k = map(int, input().split())

d = dict()

for _ in range(n):
    a, b = map(int, input().split())
    if a in d.keys():
        d[a] += b
    else:
        d[a] = b

d = sorted(d.items())

for a, b in d:
    k -= b
    if k <= 0:
        print(a)
        exit()

Solution (Python):
import heapq

N, K = map(int, raw_input().split())
pq = []
for a, b in [map(int, raw_input().split()) for _ in range(N)]:
  heapq.heappush(pq, (a, (a, b)))
res = -1
while K > 0:
  res, (_, num) = heapq.heappop(pq)
  K -= num
print res

Solution (Python):
int_n, int_k = map(int, input().split())

li_wk = list()

for i in range(int_n):
    li_wk.append(list(map(int, input().split())))

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

counter = 1
for l in li_wk:
    if counter <= int_k <= (counter + l[1] - 1):
        print(l[0])
    counter += l[1]

Solution (Python):
N, K = map(int,input().split())
L = []
for _ in range(N):
    L.append(list(map(int,input().split())))
L.sort()
for i in range(1,len(L)):
    L[i][1] = L[i][1] + L[i-1][1]
for x in L:
    if K <= x[1]:
        print(x[0])
        break

Solution (Python):
a = list(map(int,input().split()))
N = a[0]
K = a[1]
bucket = [0 for i in range(100001)]
for i in range(N):
    temp = list(map(int,input().split()))
    bucket[temp[0]] += temp[1]
sum = 0
for i in range(100001):
    sum += bucket[i]
    if K <= sum:
        print(str(i))
        break

Solution (Python):
N, K = 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

Solution (Python):
n,k=map(int,input().split())
L=[]
for s in range(n):
  a,b=map(int,input().split())
  L.append((a,b))

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

sun=0
for s in L:
  sun+=s[1]
  if sun+1>k:
    print(s[0])
    exit()

Solution (Python):
n,k=map(int,input().split())
L=[]
for s in range(n):
  a,b=map(int,input().split())
  L.append((a,b))

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

sun=0
for s in L:
  sun+=s[1]
  if sun+1>k:
    print(s[0])
    exit()

Solution (Python):
N,K = map(int, input().split())
ab = [ [int(j) for j in input().split()] for _ in range(N)]
ab = sorted(ab)

i = 0
ans = 0
while K > 0:
    p = ab[i]
    ans = p[0]
    K -= p[1]
    i+=1
print(ans)

Solution (Python):
N,K=map(int,input().split())
arr=[]
for i in range(N):
    a,b=map(int,input().split())
    arr.append([a,b])
arr.sort()
x=0
for i in range(N):
    x+=arr[i][1]
    if x>=K:
        print(arr[i][0])
        break

Solution (Python):
n,k = map(int,input().split())
info =[list(map(int,input().split())) for i in range(n)]

info =sorted(info)

for i in range(n):
  if info[i][1]>=k:
    print(info[i][0])
    exit()
  else:
    k = k - info[i][1]

Solution (Python):
n, k = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort(key = lambda x:x[0])
total = 0
for a, b in ab:
    total += b
    if total >= k:
        print(a)
        exit()

Solution (Python):
from operator import itemgetter

N, K = list(map(int, input().split()))
ab = []
for i in range(N):
    ab.append(list(map(int, input().split())))
ab = sorted(ab, key=itemgetter(0,1))

for a, b in ab:
    K -= b
    if K <= 0:
        print(a)
        break

Solution (Python):
N, K = 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

Solution (Python):
n,k=map(int,input().split())
a_b=[[0,0,0]]
for i in range(n):
    a,b=map(int,input().split())
    a_b.append([a,b,b])
a_b.sort(key=lambda x: x[0])
for i in range(n):
    a_b[i+1][2]+=a_b[i][2]
for i in range(len(a_b)):
    if a_b[i][2]<k<=a_b[i+1][2]:
        print(a_b[i+1][0])
        exit()

Solution (Python):
import numpy as np
N,K = map(int, input().split())
ab = [tuple(map(int, input().split())) for i in range(N)]
ab.sort()
num = 0
for i in range(N):
	num += ab[i][1]
	if num >= K:
		ans = ab[i][0]
		break

print(ans)

Solution (Python):
n, k = map(int, input().split())
l = [tuple(map(int, input().split())) for i in range(n)]
l.sort()
l.append((0, k))
d = [l[0][1]]
for i in range(1,n+1):
    d.append(d[i-1] + l[i][1])
t = 0
while d[t] < k:
    t += 1
print(l[t][0])

Solution (Python):
class struct:
  def __init__(self,a,b):
    self.a=a
    self.b=b
n,k=map(int,input().split())
l=[]
for i in range(n):
  a,b=map(int,input().split())
  l.append(struct(a,b))
l=sorted(l,key=lambda x:x.a)
s=0
for i in l:
  s+=i.b
  if k<=s:
    print(i.a)
    exit()

Solution (Python):
n,k = map(int,input().split())
x = [list(map(int,input().split())) for i in range(n)]
x = sorted(x,key=lambda x:x[0])
tem = x[0][1]
i = 0
while k-tem > 0:
    i += 1
    tem += x[i][1]
print(x[i][0])

Solution (Python):
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, K] = [int(input_raw[0]), int(input_raw[1])]
    A = []
    for i in range(N):
        input_raw = read_func().strip().split()
        [a, b] = [int(input_raw[0]), int(input_raw[1])]
        A.append((a, b))
    A.sort()

    count = 0L
    for i in range(N):
        count += A[i][1]
        if count >= K:
            print A[i][0]
            return




if __name__ == '__main__':
    main()

Solution (Python):
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, K] = [int(input_raw[0]), int(input_raw[1])]
    A = []
    for i in range(N):
        input_raw = read_func().strip().split()
        [a, b] = [int(input_raw[0]), int(input_raw[1])]
        A.append((a, b))
    A.sort()

    count = 0L
    for i in range(N):
        count += A[i][1]
        if count >= K:
            print A[i][0]
            return




if __name__ == '__main__':
    main()

Solution (Python):
n,k=map(int,input().split())
A=[]
for _ in range(n):
    A.append(list(map(int,input().split())))
A.sort()
cnt=A[0][1]
i=0
while cnt<k:
    i+=1
    cnt+=A[i][1]
print(A[i][0])

Solution (Python):
N,K = map(int,input().split())
L = []
S = 0
for i in range(N):
  L.append(list(map(int,input().split())))
L.sort()
for i in range(N):
  S += L[i][1]
  if S >= K:
    print(L[i][0])
    break

Solution (Python):


















import collections
import math


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

AA = sorted(AA)
s = 0
for a, b in AA:
  s += b
  if K<=s:
    print(a)
    break

Solution (Python):
from collections import defaultdict
N,K = map(int, input().split())
dic = defaultdict(int)
for i in range(N):
    a,b = map(int, input().split())
    dic[a] += b
dic = sorted(dic.items(),reverse=True)

tmp = 0
while tmp < K:
    ans = dic.pop()
    tmp += ans[1]
print(ans[0])

Solution (Python):
N,K = map(int,raw_input().split())

data = [map(int,raw_input().split()) for i in range(N)]

data.sort()

cnt = 0

for i in data:
    cnt += i[1]
    if cnt >= K:
        print i[0]
        break

Solution (Python):
N,K = map(int,input().split(" "))
list = []
for i in range(N):
    a,b = map(int,input().split(" "))
    list.append([a,b])
list = sorted(list)


for i in range(N):
    a,b = list[i][0],list[i][1]
    K -= b
    if K <= 0:
        print(a)
        break

Solution (Python):
n,k=map(int,input().split())
ls={}
for i in range(n):
  a,b=map(int,input().split())
  if a not in ls:
    ls[a]=b
  else:
    ls[a]+=b
ls=sorted(ls.items())
tmp=0
for i,j in ls:
  tmp+=j
  if k <= tmp:
    print(i)
    exit()

Solution (Python):
N,K=map(int,input().split())
c = [0]*(10**5)
for x in range(N):
    a,b=map(int,input().split())
    c[a-1]+=b

for i in range(10**5):
    if c[i]>=K:
        print(i+1)
        break
    else: 
        K -=c[i]

Solution (Python):
N,K=map(int,input().split())
a=[[0,0] for _ in range(N)]
for i in range(N):
    a[i][0],a[i][1]=map(int,input().split())
a.sort()
ans=a[0][0]
Sum=0
i=0
while Sum<K:
    Sum+=a[i][1]
    if Sum>=K:
        ans=a[i][0]
    i+=1
print(ans)

Solution (Python):
import sys
N, K = map(int, input().split())
num = []
for _ in range(N):
    a, b = map(int, input().split())
    num.append((a, b))
num = sorted(num, key=lambda x: x[0])
s = 0
for item in num:
    s += item[1]
    if s >= K:
        print(item[0])
        sys.exit()

Solution (Python):
n, k=[int(w) for w in input().split()]
lim=100*1000+1
c=[0]*lim
for i in range(n):
    a, b=[int(w) for w in input().split()]
    c[a]+=b
for i in range(lim):
    k-=c[i]
    if k<=0:
        print(i)
        break

Solution (Python):
def main():
    n, k = map(int, input().split())
    counts = [0] * 100001

    for _ in range(n):
        a, b = map(int, input().split())
        counts[a] += b

    for i in range(1, 100001):
        if k <= counts[i]:
            print(i)
            break
        k -= counts[i]


if __name__ == '__main__':
    main()

Solution (Python):
from operator import itemgetter

n, k = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
a.sort(key=itemgetter(0))
m = 0

for i in range(n):
    m += a[i][1]
    if k <= m:
        print(a[i][0])
        break

Solution (Python):
n, k = [int(x) for x in input().split(' ')]
ab = sorted([[int(x) for x in input().split(' ')]  for _ in range(n)])
index = 0

for a in ab:
    index += int(a[1])
    if index >= k:
        print(a[0])
        break

Solution (Python):
def solve():
    [N, K] = [int(x) for x in input().split()]

    count = dict()
    for i in range(N):
        [a, b] = [int(x) for x in input().split()]
        count[a] = count.get(a, 0) + b

    idx = 0
    

    keys = sorted(count.keys())

    K = K - 1
    for k in keys:
        n = count[k]
        if idx <= K < idx + n:
            return k
        idx += n

    return 0


if __name__ == '__main__':
    print(solve())

Solution (Python):
N, K = map(int, input().split())

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

for i, num in sorted(int_num.items(), key=lambda x:x[0]):
    K -= num
    if K <= 0:
        print(i)
        break

Solution (Python):
import heapq
n, k = list(map(int, input().split()))
li = []
for _ in range(n):
    li.append(tuple(map(int, input().split())))

li.sort()
cnt = 0
for a, b in li:
    cnt += b
    if cnt >= k:
        ans = a
        break

print(ans)

Solution (Python):
N, K = map(int, input().split())
A = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append((a, b))
A.sort(key=lambda x:x[0])
b_sum = 0
for a, b in A:
    b_sum += b
    if b_sum >= K:
        print(a)
        break

Solution (Python):
def solve():
    N, K = map(int, input().split()) 
    ab = []
    for i in range(N):
        ab.append( list(map(int, input().split())) )

    ab.sort()

    for (a, b) in ab:
        K -= b
        if K <= 0:
            print(a)
            return

solve()

Solution (Python):
n, k = 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

Solution (Python):
n, K = map(int, input().split())
rec = [0] * (10 ** 5 + 5)
for i in range(n):
    a, b = map(int, input().split())
    rec[a] += b

for i in range(10 ** 5 + 1):
    if rec[i] > 0:
        K -= rec[i]
        if K <= 0:
            print(i)
            exit()

Solution (Python):


def main():
    n, k = map(int, input().split())
    cnt = {}
    for i in range(n):
        a, b = map(int, input().split())
        if a not in cnt:
            cnt[a] = 0
        cnt[a] += b
    print(kth_smallest(cnt, k))

def kth_smallest(cnt, k):
    keys = sorted(cnt.keys())
    for key in keys:
        k -= cnt[key]
        if k <= 0:
            return key
    raise Exception

main()

Solution (Python):
from operator import itemgetter
N, K = map(int, input().split())

AB = [list(map(int, input().split())) for _ in range(N)]
AB.sort(key=itemgetter(0))
cnt = 0
i = 0
while cnt < K:
    cnt += AB[i][1]
    i += 1
print(AB[i-1][0])

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

nums = []
for _ in range(N):
    nums.append(list(map(int, input().split())))

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

acc = [0]*N
acc[0] = nums[0][1]
for i in range(1, N):
    acc[i] += acc[i-1]+nums[i][1]


for i in range(N):
    if acc[i] >= K:
        print(nums[i][0])
        exit()

Solution (Python):
import collections
import math
import re
import numpy
from operator import itemgetter
def ai():return input()
def a():return int(input())
def ma():return map(int, input().split())
def ms():return map(str, input().split())
def lma():return list(map(int, input().split()))
def lms():return list(map(str, input().split()))
def say(i):return print("Yes" if i == 0 else "No")
def Say(i):return print("YES" if i == 0 else "NO")
kind=[]
l = []
f = 0
s=0
c=0
e =1
n,k=ma()
for i in range(n):
    a,b = ma()
    l.append([a,b])
l.sort()
for i in range(n):
    s+=l[i][1]
    if s >=k:
        c = l[i][0]
        break
print(c)

Solution (Python):
n,k=map(int,input().split())
a=[list(map(int,input().split()))for i in range(n)]
a.sort()
for i in range(n):
    k-=a[i][1]
    if k<=0:
        print(a[i][0])
        break

Solution (Python):
N, K = [int(x) for x in input().split()]

d = {}

for i in range(N):
    a, b = [int(x) for x in input().split()]
    cnt = d.get(a, 0)
    d[a] = cnt + b

keys = list(d.keys())
keys.sort()

idx = 0
sum = 0
while sum + d[keys[idx]] < K:
    sum += d[keys[idx]]
    idx += 1
    

print(keys[idx])

Solution (Python):
N,K = map(int,input().split())
D = {}
for i in range(N) :
    a,b = map(int,input().split())
    if a not in D :
        D[a] = b
    else :
        D[a] += b
D = sorted(D.items(),key=lambda x: x[0])        

ctr = 0
for i in range(len(D)) :
    ctr += D[i][1]
    if ctr >= K :
        ans = D[i][0]
        break
print(ans)

Solution (Python):

def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()
def LIR(n): return [LI() for i in range(n)]


"""
s = S()
if s[0] != "A":
    print("WA")
else:
    count = []
    for i in range(2,len(s)-1):
        if s[i] == "C": count.append(i)
    if len(count) != 1:
        print("WA")
    else:
        for i in range(1,len(s)):
            if i not in count:
                if s[i] == s[i].upper():
                    print("WA")
                    quit()
        print("AC")
"""


"""
n,m,k = LI()
for i in range((n+1)//2):
    if (k - m*i) % (n - 2*i) == 0 and (k-m*i)//(n-2*i) >= 0 and (k-m*i)//(n-2*i) <= m:
        print("Yes")
        quit()
print("No")
"""


from collections import defaultdict
n,k = LI()
d = defaultdict(int)
for i in range(n):
    a,b = LI()
    d[a] += b
s = list(d.items())
s.sort(key = lambda x:x[0])
su = 0
for i in range(len(s)):
    su += s[i][1]
    if su >= k:
        print(s[i][0])
        break

Solution (Python):
N, K = map(int, input().split())
A = [0 for _ in range(10 ** 5)]
for i in range(N):
    a, b = 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

Solution (Python):
import bisect
N,K=map(int,input().split())
l=[]
for i in range(N):
    a,b=map(int,input().split())
    l.append((a,b))
l.sort()
count=0
for a,b in l:
    count+=b
    if K<=count:
        print(a)
        break

Solution (Python):
N, K = 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)

Solution (Python):
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

Solution (Python):
import collections

N, K = map(int, input().split(" "))
inputLines = [input() for i in range(N)]
arrayInfo = collections.Counter()
for inputLine in inputLines:
    a, b = map(int, inputLine.split(" "))
    arrayInfo[a] += b
now = 0
for key, value in sorted(arrayInfo.items()):
    now += value
    if K <= now:
        print(key)
        break

Solution (Python):
N,K = map(int,input().split())
AB = []
for i in range(N):
    a,b = 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

Solution (Python):
n,k = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(n)]
AB.sort()
count = 0

for i in range(n):
    count += AB[i][1]
    if count >= k:
        print(AB[i][0])
        break

Solution (Python):

N,K = (int(i) for i in input().split())
a = {}
for i in range(N):
    tmp = list(int(i) for i in input().split())
    if not tmp[0] in a.keys():
        a[tmp[0]] = tmp[1]
    else:
        a[tmp[0]] += tmp[1]


ans_array = []
for k,v in a.items():
    ans_array.append((k,v))
ans_array = sorted(ans_array)

count = 0
for i in range(N):
    count += ans_array[i][1]
    if count>=K:
        print(ans_array[i][0])
        break

Solution (Python):
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
nums = {}

for _ in range(N):
    a, b = map(int, input().split())
    if a in nums:
        nums[a] += b
    else:
        nums[a] = b

nums_list = list(nums.items())
nums_list.sort()

while True:
    K -= nums_list[0][1]
    if K <= 0:
        print(nums_list[0][0])
        break
    else:
        del nums_list[0]

Solution (Python):
n,k=map(int,input().split())

l=[]
for i in range(n):
    p=[int(i) for i in input().split()]
    l.append(p)

from operator import itemgetter
l.sort(key=itemgetter(0)) 

s=0
ans=0
for i in range(n):
    s+=l[i][1]
    if s>=k:
        ans=l[i][0]
        break
print(ans)

Solution (Python):
N, K = map(int, input().split())
array = {}
for i in range(N):
    a, b = map(int, input().split())
    if not a in array:
        array[a] = 0
    array[a] += b

for k, v in sorted(array.items()):
    K -= v
    if K <= 0:
        print(k)
        break

Solution (Python):
from sys import stderr, setrecursionlimit, exit
from collections import defaultdict as dd
setrecursionlimit(2147483647)
def getInt():
    return int(input())
def getInts():
    return [int(i) for i in input().split()]
def getIntLines(n=1):
    res = []
    for _ in range(n):
        res.append(getInt())
    return res
def getIntsLines(n=1):
    res = []
    for _ in range(n):
        res.append(getInts())
    return res
def debug(*args, sep=" ", end="\n"):
    for item in args:
        stderr.write(str(item))
        stderr.write(sep)
    stderr.write(end)

n, k = getInts()
arr = dd(int)
for _ in range(n):
    a, b = getInts()
    arr[a] += b
arr_sorted = sorted(list(arr.items()),key=lambda x:x[0])
i = 0
for key, val in arr_sorted:
    i += val
    if i >= k:
        print(key)
        exit()

Solution (Python):
n, k = map(int, input().split())
A = {}
for _ in range(n):
    a, b = map(int, input().split())
    A[a] = A.get(a, 0) + b

ans = 0
for a in sorted(A):
    ans += A[a]
    if ans >= k:
        print(a)
        break

Solution (Python):
n ,k = map(int, input().split())
A = [tuple(map(int, input().split())) for i in range(n)]
A.sort(key=lambda x: x[0])
m = 0
i = -1
while m < k:
    i += 1
    m += A[i][1]
print(A[i][0])

Solution (Python):
def abc061_c():
    n, k = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in range(n)]

    ab.sort()
    count = 0
    for v in ab:
        count += v[1]
        if count >= k:
            print(v[0])
            break


abc061_c()

Solution (Python):
import numpy as np
N, K = [int(x) for x in input().split()]


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

nth = 0
for i in range(N):
    a,b = list[i]
    nth += b 
    if K<=nth:
        break




print(a)

Solution (Python):
N, K = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N)]
ab.sort()
check = 0
for i in range(N):
    check += ab[i][1]
    if K <= check:
        print(ab[i][0])
        break

Solution (Python):
from collections import defaultdict
n, k = list(map(int, input().split()))
d = defaultdict(int)
for i in range(n):
    a, b = list(map(int, input().split()))
    d[a] += b
cnt = 0
for i, j in sorted(list(d.items())):
    if cnt < k <= cnt+j:
        print(i)
        exit()
    cnt += j

Solution (Python):
N, K = map(int, input().split())
a_b = []
for i in range(N):
    a, b = map(int, input().split())
    a_b.append((a, b))

a_b.sort(key=lambda x: x[0])
tmp = 0
for a, b in a_b:
    tmp += b
    if tmp >= K:
        print(a)
        break

Solution (Python):
N, K = map(int, input().strip().split())
ab = []
for _ in range(N):
  ab.append(tuple(map(int, input().strip().split())))

kc = 0
for a, b in sorted(ab, key=lambda x: x[0]):
  if kc + b >= K:
    break
  kc += b

print(a)

Solution (Python):
n,k=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
l.sort()
ct=0
for i in range(n):
  ct+=l[i][1]
  if ct>=k:
    print(l[i][0])
    break

Solution (Python):
n, k = map(int, input().split())

l = [0 for _ in range(1000000)]

rui = 0

for i in range(n):
    a, b = map(int, input().split())
    l[a] += b


for i in range(len(l)):
    rui += l[i]

    if rui >= k:
        print(i)
        break