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())  
ans = []
for _ in range(N):
    ans.append(list(map(int, input().split())))
ans = sorted(ans, key=lambda x: x[0])
for value, amount in ans:
    if amount >= k:
        print(value)
        exit()
    else:
        k -= amount

Solution (Python):
import sys

n, k, *ab = map(int, sys.stdin.read().split())
ab = zip(*[iter(ab)] * 2)

def main():
    s = 0
    for a, b in sorted(ab):
        s += b
        if s >= k:
            return a

if __name__ == '__main__':
    ans = main()
    print(ans)

Solution (Python):
import sys
from collections import defaultdict

n, k, *ab = map(int, sys.stdin.read().split())
ab = zip(*[iter(ab)] * 2)

def main():
    cnt = defaultdict(int)
    for a, b in ab:
        cnt[a] += b
    
    s = 0
    for v, c in sorted(cnt.items()):
        s += c
        if s >= k:
            return v

if __name__ == '__main__':
    ans = main()
    print(ans)

Solution (Python):
import sys
bbn=1000000007
	

		
def main():
	n, k= map(int, input().split())
	vv=[]
	for i in range(n):
		ai, bi = map(int, input().split())
		vv.append([ai,bi])
	vv.sort()
	for ai,bi in vv:
		k-= bi
		if k <= 0:
			return ai
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

Solution (Python):
n, k = map(int, input().split())
array = [tuple(map(int, input().split())) for _ in range(n)]
array.sort()
cnt = 0
for a, b in array:
    cnt += b
    if cnt >= k:
        print(a)
        break

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

dicts = sorted(dicta.items(), key = lambda x:x[0])
for i,v in dicts:
    num += v
    if num >= K:
        print(i)
        break

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

dicts = sorted(dicta.items(), key = lambda x:x[0])
for i,v in dicts:
    num += v
    if num >= K:
        print(i)
        break

Solution (Python):
d = {}
n,k = map(int, input().split())
for _ in range(n):
    a,b = map(int, input().split())
    if d.setdefault(a):
        d[a] = d[a] + b
    else:
        d[a] = b
for key in sorted(d):
    k -= d[key]
    if k<=0:
        print(key)
        break

Solution (Python):
D = {}
N, K = map(int, input().split())
for i in range(N):
  A, B = map(int, input().split())
  if A in D:
    D[A] += B
  else:
    D[A] = B
C = sorted(D)
i, S = 0, 0
while S < K:
  S += D[C[i]]
  i += 1
print(C[i-1])

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

Solution (Python):
n,k=map(int,input().split())
L=[]
for i in range(n):
      a,b=map(int,input().split())
      L+=[[a,b]]
L.sort(key=lambda x:x[0])

sm=0
for i in range(n):
      sm+=L[i][1]
      if sm>=k:
            print(L[i][0])
            exit()

Solution (Python):
N,K = map(int,input().split())
AB = [tuple(map(int,input().split())) for _ in range(N)]
AB.sort(key=lambda x:(x[0],x[1]))


for a,b in AB:
  if K <= b:
    print(a)
    exit()
  else:
    K -= b

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

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

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

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

Solution (Python):
import bisect
N, K = map(int, input().split())
a = []
b = []
for i in range(N):
    ta, tb = map(int, input().split())
    a.append(ta)
    b.append(tb)
dict = {}
for i in range(N):
    if a[i] in dict:
        dict[a[i]] += b[i]
    else:
        dict[a[i]] = b[i]
array = sorted(list(dict.items()))
ruiseki = [0]*len(array)
ruiseki[0] = array[0][1]
for i in range(1, len(array)):
    ruiseki[i] = ruiseki[i-1] + array[i][1]
print(array[bisect.bisect_left(ruiseki, K)][0])

Solution (Python):
N , K = map(int,input().split())
lst = []
for _ in range(N):
    a , b = map(int,input().split())
    lst.append([a , b])
lst.sort()
for i in range(N):
    if K <= lst[i][1]:
        print(lst[i][0])
        exit()
    else:
        K -= lst[i][1]

Solution (Python):
import sys
input = sys.stdin.readline
n, k = map(int,input().split())
lst = [[int(i) for i in input().split()] for _ in range(n)]
lst.sort(key = lambda x: x[0])

for [i, j] in lst:
    if j >= k:
        print(i)
        quit()
    else:
        k -= j

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

lst = [[int(i) for i in input().split()] for _ in range(n)]

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

for [i, j] in lst:
    if j >= k:
        print(i)
        quit()
    else:
        k -= j

Solution (Python):
n , k = map(int, input().split())
data = []
for i in range(n):
    data.append(list(map(int, input().split())))
data.sort()
total = 0
for i in data:
    if total < k <= total + i[1]:
        print(i[0])
        exit()
    else:
        total += i[1]

Solution (Python):
n,k=[int(i) for i in input().split()]
count=0
lst=[]
for i in range(n):
    lst.append([int(i) for i in input().split()])
lst.sort()
for i in range(n):
    a,b=lst[i]
    count+=b
    if(count>=k):
        print(a)
        exit()

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

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

c = 0
cur = 0
while True:
    if ab[cur][1] + c < k:
        c += ab[cur][1]
        cur += 1
    else:
        break
print(ab[cur][0])

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,K=MI()
    AB=LLIN(N)
    AB.sort()
    for a,b in AB:
        K-=b
        if K<=0:
            print(a)
            exit()
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()
for i in range(n):
    a,b = ab[i]
    k -= b
    if k <= 0:
        print(a)
        break

Solution (Python):
lists=list(map(int,input().split()))
n=lists[0]
k=lists[1]
beforeSort = [[0]*2]*n
for i in range(n):
  getNum=list(map(int,input().split()))
  beforeSort[i]=getNum
afterSort=sorted(beforeSort)
for i in range(n):
  k=k-afterSort[i][1]
  if k<=0:
  	print(afterSort[i][0])
  	break

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


input_dict = {}

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

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

for i in range(len(input_dict)):
    K -= input_dict[i][1]
    if K <= 0:
        print(input_dict[i][0])
        break

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

A.sort()
cnts=0
vals=0
for i in range(len(A)):
    cnts+=A[i][1]
    vals=A[i][0]
    if cnts>=K:
        print(vals)
        exit(0)

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

Solution (Python):
N,K=map(int,input().split())
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(),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

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

for i in range(1,len(s)):
  if s[i]>=K:
    print(i)
    exit()
  K-=s[i]

Solution (Python):
import bisect
n, k = map(int, input().split())
M = sorted([ list(map(int, input().split())) for _ in range(n) ])
L = []
S = [0]
for a, b in M:
  L.append(a)
  S.append(S[-1]+b)
S = S[1:]
t = bisect.bisect_left(S, k)
print(L[t])

Solution (Python):
from sys import stdin
from itertools import accumulate
import bisect

n,k = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]

lin = [0]*(10**5)

for i in li:
    lin[i[0]-1] += i[1]

lis = list(accumulate(lin))

print(bisect.bisect_left(lis,k)+1)

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

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

L.sort()
cnt = 0
for i in range(N):
    cnt += L[i][1]
    if K <= cnt:
        ans = L[i][0]
        break
        
print(ans)

Solution (Python):
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, k = list(map(int, readline().split()))
    ab = [list(map(int, readline().split())) for _ in range(n)]
    ab.sort()
    t = 0
    for a, b in ab:
        t += b
        if t >= k:
            print(a)
            exit()


if __name__ == '__main__':
    solve()

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

li = sorted(li,key = lambda x:x[0])
cnt = 0
for i in range(n):
  cnt += li[i][1]
  if k <= cnt:
    print(li[i][0])
    exit()

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,k=map(int,input().split())
    AB=[tuple(map(int,input().split())) for _ in range(n)]
    AB.sort()
    for a,b in AB:
        k-=b
        if(k<=0):
            print(a)
            return
resolve()

Solution (Python):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
mod = 10**9+7


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

Cnt = [0]*(10**5+1)
for a,b in AB:
    Cnt[a] += b

i = 1
for ci in range(len(Cnt)):
    if i <= K < i+Cnt[ci]:
        print(ci)
        sys.exit()
    else:
        i += Cnt[ci]

Solution (Python):
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
arr = []
for _ in range(N):
    arr.append(list(map(int, input().split())))
arr.sort()

count = 0
for i in arr:
    count += i[1]
    if K <= count:
        print(i[0])
        exit()

Solution (Python):
n, k = map(int, input().split(" "))
l = []
a_l = []
for i in range(n):
  a, b = map(int, input().split(" "))
  l.append((a, b))
  
l = sorted(l)
for n in l:
  if k > n[1]:
    k = k - n[1]
    continue
  else:
    ans = n[0]
    break
    
print(ans)

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

counter = [0 for i in range(110000)]
for a,b in ablist:
    counter[a]+=b

for i in range(110000):
    K-=counter[i]
    if K<=0:
        print(i)
        break

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

Solution (Python):
N, K = [int(i) for i in input().split()]
L = []
for i in range(N):
  a, b = [int(j) for j in input().split()]
  L.append([a, b])
L.sort(key=lambda x: x[0])


cnt = 0
for x, y in L:
  cnt += y
  if cnt >= K:
    ans = x
    break
print(ans)

Solution (Python):
import itertools
n, k = map(int, input().split())
l = [0] * 100010
for i in range(n):
    a, b = map(int, input().split())
    l[a] += b
d = 0
for i in range(1, 100001):
    d += l[i]
    if d >= k:
        print(i)
        break

Solution (Python):
N, K = map(int, input().split())
X = sorted([[int(a) for a in input().split()] for _ in range(N)])
i = 0
K -= X[0][1]
while K > 0:
    i += 1
    K -= X[i][1]

print(X[i][0])

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

LIST=[[0,0] for i in range(N)]

for i in range(N):
    LIST[i][0],LIST[i][1]=map(int,input().split())

LIST=sorted(LIST)

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

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

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

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

arr = []
k_sum = 0
for i in range(n):
  a, b = map(int, input().split())
  d = {}
  d['num'] = a
  d['count'] = b
  arr.append(d)
  
arr = sorted(arr, key=itemgetter('num'))

for i in range(n):
  k_sum += arr[i]['count']
  if k <= k_sum:
    print(arr[i]['num'])
    exit(0)

Solution (Python):
n,k=map(int,input().split())
hoge=[0]*100001
for i in range(n):
  a,b=map(int,input().split())
  hoge[a]+=b
for i in range(100001):
  k-=hoge[i]
  if(k<=0):
    print(i)
    exit()

Solution (Python):
n, k = map(int, input().split())
data = [tuple(map(int, input().split())) for _ in range(n)]
data.sort()

tmp = 0
for a, b in data:
    tmp += b
    if tmp >= k:
        print(a)
        break

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

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

array = []
for n, t in 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

Solution (Python):
import sys
N,K=map(int,input().split())
nums = {}
for _ in range(N):
  a,b = map(int,sys.stdin.readline().split())
  if a in nums:
    nums[a] += b
  else:
    nums[a] = b

cnt = 0
for key in sorted(nums.keys()):
  cnt += nums[key]
  if cnt >= K:
    print(key)
    exit()

Solution (Python):
def examC():
    N, K = LI()
    d = defaultdict(int)
    element = set()
    for _ in range(N):
        a, b = LI()
        d[a] += b
        element.add(a)
    element = list(element)
    element.sort()
    for i in element:
        K -= d[i]
        if K<=0:
            ans = i
            break
    print(ans)


import sys
import copy
import bisect
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()

Solution (Python):
from collections import Counter
N, K = map(int, input().split())
c = Counter()
for _ in range(N):
    a, b = map(int, input().split())
    c[a] += b
for item in sorted(c.items(), key=lambda x: x[0]):
    if item[1] >= K:
        print(item[0])
        break
    else:
        K -= item[1]

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

Solution (Python):
N,K=map(int,input().split())
ab=sorted([list(map(int,input().split())) for i in range(N)])
s=0
for a,b in ab:
    s+=b
    if s>=K:
        print(a)
        break

Solution (Python):
import sys
input = sys.stdin.readline

def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

from collections import defaultdict


N,K = two_int()


query = []
for i in range(N):
    query.append(two_int() )

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

ans=0
sums=0
for q in query:
    if sums < K <= sums+q[1]:
        ans=q[0]
        break
    
    sums += q[1]

print(ans)

Solution (Python):
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


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


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


def solve(N, K, inputs):
    values = list(map(string_to_int, inputs))
    values.sort(key=lambda x: x[0])
    count = 0
    for v in values:
        count += v[1]
        if count >= K:
            return v[0]


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


if __name__ == "__main__":
    [N, K] = string_to_int(input())
    ret = solve(N, K, inputs(N))
    print(ret)

Solution (Python):
num = list(map(int, input().split(' ')))
insert = num[0]
minimum = num[1]
mylist = [0 for i in range(insert)]

for i in range(insert):
    mylist[i] = (list(map(int, input().split(' '))))
    
sort_list = sorted(mylist)
sum_num = 0
for i in range(insert):
    sum_num += sort_list[i][1]
    if sum_num >= minimum:
        print(sort_list[i][0])
        break

Solution (Python):
n, k = map(int, input().split())
from collections import defaultdict as dd
dic = dd(lambda: 0)
for i in range(n):
  a, b = map(int, input().split())
  dic[a] += b

for key in sorted(dic.keys()):
  if k <= dic[key]:
    print(key)
    break
  else:
    k -= dic[key]

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()
if k<=ab[0][1]:
  print(ab[0][0])
for i in range(n):
  k-=ab[i][1]
  if k<=0:
    print(ab[i][0])
    exit()

Solution (Python):
def main():
    N, K = map(int, input().split())
    AB = []
    for i in range(N):
        a, b = map(int, input().split())
        AB.append([a, b])
    AB.sort(key=lambda x: x[0])

    c = 0
    for a, b in AB:
        if K <= c + b:
            ans = a
            break
        c += b
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
def main():
    N, K = map(int, input().split())
    AB = []
    for i in range(N):
        a, b = map(int, input().split())
        AB.append([a, b])
    AB.sort(key=lambda x: x[0])

    c = 0
    for a, b in AB:
        if c <= K <= c + b:
            ans = a
            break
        c += b
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import heapq
n, k = map(int,input().split())
hq = []
for i in range(n):
  heapq.heappush(hq, tuple(map(int, input().split())))
length = 0
while(length < k):
  a, b = heapq.heappop(hq)
  length += b
print(a)

Solution (Python):
def main():
    N, K = (int(i) for i in input().split())
    S = []
    for i in range(N):
        a, b = (int(i) for i in input().split())
        S.append((b, a))
    S.sort(key=lambda s: s[1])
    SS = [(0, 0)]
    for i in range(N):
        SS.append((S[i][0] + SS[i][0], S[i][1]))
    for b, a in SS:
        if K <= b:
            print(a)
            break


if __name__ == '__main__':
    main()

Solution (Python):
n,k=map(int,input().split())
l=[0 for i in range(10**5+1)]
for i in range(n):
  a,b=map(int,input().split())
  l[a]+=b
count=0
index=0
while count<k:
  index+=1
  count+=l[index]
print(index)

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

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

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

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

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

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

Solution (Python):

N, K = 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] = 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)

Solution (Python):
n,k = map(int, input().split())
p = [[0,0]]
for i in range(n):
    a,b = map(int, input().split())
    p.append([a,b])
p.sort()
ans = 0
p.pop(0)
for i in range(n):
    ans+=p[i][1]
    if ans>=k:
        print(p[i][0])
        exit()
    else:
        continue

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

Solution (Python):
import sys
input=sys.stdin.readline
n,k=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(n)]

AB.sort()
cnt=0
for a,b in AB:
  cnt+=b
  if cnt>=k:
    print(a)
    exit()

Solution (Python):
import sys
input=sys.stdin.readline
n,k=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(n)]

AB.sort()
cnt=0
for a,b in AB:
  cnt+=b
  if cnt>=k:
    print(a)
    exit()

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

    ls = []
    ans = 0

    for i in range(n):
        ab = list(map(int, input().split()))
        ls.append(ab)
    
    ls.sort()

    index = 0

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

    
if __name__ == "__main__":
    main()

Solution (Python):
N,K = map(int,input().split())
a = []
M = 0
for i in range(N):
  a.append(tuple(map(int,input().split())))
a.sort()
for i in range(N):
    K = K-a[i][1]
    if K <= 0:
        print(a[i][0])
        break

Solution (Python):
n,k=map(int,input().split())
AB=sorted([list(map(int,input().split())) for i in range(n)])
dic={}
C=[0]
for i in range(n):
    C.append(C[-1]+AB[i][1])
for i in range(n):
    if C[i]<k<=C[i+1]:
        print(AB[i][0])
        exit()

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

i = 0
count = 0
while count < K:
    if ab[i][1] >= K:
        ans = ab[i][0]
        break

    else:
        count += ab[i][1]
        ans = ab[i][0]
        i += 1

print(ans)

Solution (Python):
from sys import stdin
input = stdin.readline

N, K = [int(x) for x in input().split()]
arr = [0] * (10**5+1)
for _ in range(N):
    a, b = [int(x) for x in input().split()]
    arr[a] += b

remain = K
for i in range(1, 10**5+1):
    if arr[i] != 0:
        remain -= arr[i]
    if remain <= 0:
        print(i)
        exit()

Solution (Python):
import sys
sys.stdin.readline

N, K = [int(x) for x in input().split()]
arr = [0] * (10**5+1)
for _ in range(N):
    a, b = [int(x) for x in input().split()]
    arr[a] += b

remain = K
for i in range(1, 10**5+1):
    if arr[i] != 0:
        remain -= arr[i]
    if remain <= 0:
        print(i)
        exit()

Solution (Python):
import sys
sys.stdin

N, K = [int(x) for x in input().split()]
arr = [0] * (10**5+1)
for _ in range(N):
    a, b = [int(x) for x in input().split()]
    arr[a] += b

remain = K
for i in range(1, 10**5+1):
    if arr[i] != 0:
        remain -= arr[i]
    if remain <= 0:
        print(i)
        exit()

Solution (Python):
import sys
input = sys.stdin.readline

N, K = [int(x) for x in input().split()]
arr = [0] * (10**5+1)
for _ in range(N):
    a, b = [int(x) for x in input().split()]
    arr[a] += b

remain = K
for i in range(1, 10**5+1):
    if arr[i] != 0:
        remain -= arr[i]
    if remain <= 0:
        print(i)
        exit()

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

remain = K
for i in range(1, 10**5+1):
    if arr[i] != 0:
        remain -= arr[i]
    if remain <= 0:
        print(i)
        exit()

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

th = 0
for i in range(1, 10**5+1):
    if arr[i] != 0:
        th += arr[i]
    if th >= K:
        print(i)
        exit()

Solution (Python):
n,k=map(int,input().split())
AB=sorted([list(map(int,input().split())) for i in range(n)])
dic={}
C=[0]
for i in range(n):
    C.append(C[-1]+AB[i][1])
for i in range(n):
    if C[i]<k<=C[i+1]:
        print(AB[i][0])
        exit()

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

Solution (Python):
N,K = map(int,input().split())
list = [list(map(int,input().split())) for i in range(N)]
a = {}
for l in list:
  if l[0] not in a:
    a[l[0]] = l[1]
  else:
    a[l[0]] += l[1]
a = sorted(a.items(), key=lambda x:x[0])
c = 0
for b in a:
  c += b[1]
  ans = b[0]
  if c >= K: break
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

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

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

ab.sort()
t = 0
for a, b in ab:
    t += b
    if t >= K:
        print(a)
        break

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])
cnt = 0
for i in range(N):
    cnt += ab[i][1]
    if cnt >= K:
        print(ab[i][0])
        break

Solution (Python):

import sys
import itertools

def solve(N: int, K: int, a: "List[int]", b: "List[int]"):
    ab = list(zip(a,b))
    ab.sort(key=lambda x: x[0])
    sumb =0
    123334
    for i in range(N):
        sumb+=ab[i][1]
        if sumb>=K:
            print(ab[i][0])
            return 
        
    

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    K = int(next(tokens))  
    a = [int()] * (N)  
    b = [int()] * (N)  
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, K, a, b)

if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict

N,K=map(int,input().split())
dd=defaultdict(int)
for i in range(N):
    a,b=map(int,input().split())
    dd[a]+=b
l=sorted(dd.keys())
i=0
for ai in l:
    i+=dd[ai]
    if i>=K:
        print(ai)
        break

Solution (Python):
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, k = list(map(int, input().rstrip('\n').split()))
    ab = [list(map(int, input().rstrip('\n').split())) for _ in range(n)]
    ab.sort()
    cnt = 0
    for a, b in ab:
        cnt += b
        if cnt >= k:
            print(a)
            exit()


if __name__ == '__main__':
    solve()

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

Solution (Python):
from collections import Counter

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

for key in sorted(counter.keys()):
    k -= counter[key]
    if k <= 0:
        break
print(key)

Solution (Python):



N,K=map(int,input().split())
l=[0]*(10**5+1)

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

all=0
for index,item in enumerate(l):
    all+=item
    if all>=K:
        print(index)
        exit()

Solution (Python):
from sys import stdin


def main():
    lines = stdin.readlines()
    N, K = map(int, lines[0].split())
    bn = [0] * (int(1e5) + 1)
    for line in lines[1:]:
        ai, bi = map(int, line.split())
        bn[ai] += bi
    cnt = 0
    for ai, bi in enumerate(bn):
        cnt += bi
        if K <= cnt:
            print(ai)
            break
    return


main()

Solution (Python):
from sys import stdin
from operator import itemgetter


def main():
    lines = stdin.readlines()
    N, K = map(int, lines[0].split())
    abn = [[int(abi) for abi in line.split()] for line in lines[1:]]
    abn.sort(key=itemgetter(0))
    cnt = 0
    for ai, bi in abn:
        cnt += bi
        if K <= cnt:
            print(ai)
            break
    return


main()