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

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

Solution (Python):
n,k=map(int,input().split())
a=[]
for i in range(n):
    a_i,b_i=map(int,input().split())
    a.append([a_i,b_i])
a.sort()
num=0
for i in range(n):
    num+=a[i][1]
    if num>=k:
        print(a[i][0])
        break

Solution (Python):
n,k = map(int,input().split())
l = [list(map(int,input().split())) for i in range(n)]
l.sort()
count = 0
for i,j in l:
  if j < k:
    k -= j
  else:
    print(i)
    exit()

Solution (Python):
from collections import defaultdict
d = defaultdict(int)

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

Solution (Python):
if __name__ == '__main__':
    N,K=list(map(int,input().split()))
    AB=[tuple(map(int,input().split())) for i in range(N)]
    AB.sort(key=lambda x:x[0])
    for a,b in AB:
        K-=b
        if K<=0:
            print(a)
            break

Solution (Python):

N,K=map(int,input().split())
cnt=0
L=[]

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

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


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

Solution (Python):
n, k = map(int, input().split())
amax = 100000
cnt = [0 for _ in range(amax+1)]


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

for i in range(1, amax+1):
    if k <= cnt[i]:
        print(i)
        break
    k -= cnt[i]

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

ab.sort()

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

Solution (Python):
n, k = (int(x) for x in input().split())
ab = []
for _ in range(n):
    a, b = (int(x) for x in input().split())
    ab.append([a, b])

ab = sorted(ab)

count = 0

for a, b in ab:
    count += b
    if k <= count:
        print(a)
        exit()

Solution (Python):
N, K = map(int, input().split())
numberdict = {}
for j in range(N):
    a, b = map(int, input().split())
    if a in numberdict:
        numberdict[a] += b
    else:
        numberdict[a] = b
numberdict = sorted(numberdict.items())

index = 0
for i in range(len(numberdict)):
    index += numberdict[i][1]
    if index >= K:
        print(numberdict[i][0])
        break

Solution (Python):
N,K = map(int,input().split())
dic = {str(i):0 for i in range(10**5 + 5)}
for _ in range(N):
    a,b = map(int,input().split())
    dic[str(a)] += b
z = 0
for i in range(10**5 + 5):
    z += dic[str(i)]
    if z >= K:
        ans = i
        break
print(ans)

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

a.sort()
count = 0
for x,y in a:
    count += y
    if count>=K:
        print(x)
        exit()

Solution (Python):
N,K=map(int,input().split())
a=[]
for i in range(N):
    c,d=map(int,input().split())
    a.append((c,d))
a.sort()
count = 0
for x,y in a:
    if y>=K:
        print(x)
        exit()
    else:
        K -= y

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()
for a, b in ab:
  k -= b
  if k <= 0:
    break
print(a)

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

ab = []
for i in range(n):
  ta,tb = map(int,input().split())
  ab.append([ta,tb])

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

count = k
for i in range(n):
  count -= ab[i][1]
  if count <= 0:
    print(ab[i][0])
    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
count = 0
for k, v in sorted(dic.items()):
    count += v
    if count >= K:
        print(k)
        break

Solution (Python):
N, M = map(int, input().split())
A = []
B = []
for _ in range(N):
    a, b = list(map(int, input().split()))
    A.append(a)
    B.append(b)

d = {}
for i in range(N):
    if A[i] in d:
        d[A[i]] = d[A[i]] + B[i]
    else:
        d[A[i]] = B[i]

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

for a, b in list:
    if M - b <= 0:
        print(a)
        break
    M -= b

Solution (Python):
def smallk(n , k , ab):
    count = 0
    for i in range(n):
        if count + int(ab[i][1]) >= k:
            return int(ab[i][0])
        else:
            count += int(ab[i][1])

def main():
    n , k = map(int , input().split())
    ab = [list(map(int,input().split())) for i in range(n)]
    ab.sort()
    print(smallk(n , k , ab))

if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
N,K = [int(i) for i in input().split()]
ab = [0] * N
for i in range(N) :
    ab[i] = [int(i) for i in input().split()]
ab.sort()
sum = 0
for i in range(N) :
    sum += ab[i][1]
    if sum >= K:
        print(ab[i][0])
        break

Solution (Python):
import heapq

def solve():
    N,K = map(int, input().split())
    nums = []
    num_dict = {}
    for _ in range(N):
        a,b = map(int, input().split())
        if a not in num_dict:
            heapq.heappush(nums, a)
            num_dict[a] = b
        else:
            num_dict[a] += b
            
    ret = 0
    while K>0:
        ret = heapq.heappop(nums)
        
        K -= num_dict[ret]
        
    print(ret)
    
solve()

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

count = 0
for a, b in sorted(AB):
    count += b
    if count >= K:
        print(a)
        break

Solution (Python):
def solve(n, k, AB):
    AB.sort(key=lambda ab: ab[0])
    count = 0
    ret = -1
    for a, b in AB:
        count += b
        if k <= count:
            ret = a
            break
    return ret

_n, _k = map(int, input().split())
_AB = [list(map(int, input().split())) for _ in range(_n)]
print(solve(_n, _k, _AB))

Solution (Python):
from operator import itemgetter
import sys

def read():
    return sys.stdin.readline().rstrip()

n, k = map(int, input().split())
ab = sorted([[int(i) for i in read().split()] for _ in range(n)], key=itemgetter(0))
c = 0
for a, b in ab:
    c += b
    if c >= k:
        print(a)
        break

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

A_list = [[0, j] for j in range(N)]
B_list = [0] * N

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

A_list.sort()
sort_key = [j[1] for j in A_list]
B_list_sort = [B_list[j] for j in sort_key]

for i in range(10 ** 5):
    K -= B_list_sort[i]
    if K <= 0:
        print(A_list[i][0])
        break

Solution (Python):
n, k = map(int, input().split())
ab = []
for i in range(n):
    ai, bi = map(int, input().split())
    ab.append((ai, bi))
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])
        exit()

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

Solution (Python):
N, K = map(int, input().split())
lst = [list(map(int, input().split())) for i in range(N)]
sorted_lst = sorted(lst, key=lambda x: x[0])
cnt = 0
for i in sorted_lst:
  cnt += i[1]
  if (cnt >= K):
    print(i[0])
    break

Solution (Python):
n, k = map(int, input().split())
L = [0]*(pow(10,5)+1)

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

s = 0
for i in range(pow(10,5)+1):
  s += L[i]
  if s >= k:
    print(i)
    break

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

Solution (Python):
n, k = map(int, input().split())
x = []
for i in range(n):
	a,b = map(int, input().split())
	x.append([a,b])
x.sort()
c = 0
for i,j in x:
	c += j
	if k <= c:
		print (i)
		exit()
print (j)

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

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

Solution (Python):

n,m = map(int,input().split())
a = [0]*n
b = [0]*n
for i in range(n):
	a[i],b[i] = map(int,input().split())
a,b = zip(*sorted(zip(a,b)))
cur_sum = 0
for i in range(n):
	cur_sum += b[i]
	if cur_sum >= m:
		print(a[i])
		exit(0)

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

D = sorted(list(D.items()))
k = 0
for a, b in D:
  k += b
  if k>=K:
    print(a)
    exit()

Solution (Python):
import sys

if sys.platform =='ios':
	sys.stdin=open('input_file.txt')
	

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

sa = sorted(aa.keys())
for a in sa:
	if k > aa[a]:
		k -= aa[a]
	else:
		print(a)
		break

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

ls.sort()

ln = 0

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

Solution (Python):
from heapq import heappop, heappush
N, K = map(int, input().split())
AB = []

cnt = 0
for i in range(N):
  a, b = map(int, input().split())
  heappush(AB, (a, b))


while AB:
  a, b = heappop(AB)
  cnt += b
  
  if K <= cnt:
    print(a)
    exit()

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

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

sA.sort()

compK = 0
for i in sA:
  compK += i[1]
  if compK >= k:
    print(i[0])
    break

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

Solution (Python):
if __name__ == '__main__':

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

	lst.sort()
	indx = 0

	for i in range(0,N):
		indx += lst[i][1]
		if indx >= K:
			ans = lst[i][0]
			break

	print(ans)

Solution (Python):
N, K = map(int, input().split())
AB = sorted(tuple(map(int, input().split())) for _ in range(N))
for a, b in AB:
    if K <= b:
        print(a)
        break
    else:
        K -= b

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

res = [0]*10**5

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

count = 0
for i,r in enumerate(res):
    count+=r
    if count >= M:
        print(i+1)
        break

Solution (Python):
import sys
import numpy as np


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


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


s.sort()

number = 0
for s_item in s:
    
    number += s_item[1]
    if number >= k:
        number_k = s_item[0]
        break

print(number_k)

Solution (Python):
from collections import defaultdict
N, K = map(int, input().strip().split())
ab = [list(map(int, input().strip().split())) for _ in range(N)]

dic = defaultdict(int)
for a, b in ab:
  dic[a] += b

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

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

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

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    ab = []
    for _ in range(N):
        ab.append([int(x) for x in input().split()])

    count = 0
    i = -1
    ab.sort()
    while count < K:
        i += 1
        count += ab[i][1]

    print(ab[i][0])






if __name__ == '__main__':
    main()

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

for n in sorted(ab, key=lambda x: x[0]):
    cnt += n[1]
    if cnt >= K:
        ans = n[0]
        break

print(ans)

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

List.sort()
cnt = 0

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

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])
tmp=0
for a,b in ab:
  tmp+=b
  if tmp>=k:
    print(a) 
    exit()

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

if __name__ == '__main__':
    main()

Solution (Python):
n, k = map(int,input().split())
s = 0
ans = 0
x = []
for _ in range(n):
    a,b = map(int,input().split())
    x.append([a,b])
x.sort()
for i in range(n):
    s += x[i][1]
    if s >= k:
        ans = x[i][0]
        break
print(ans)

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

ab.sort()

cnt = 0
for a, b in ab:
    cnt += b
    if k <= cnt:
        print(a)
        break

Solution (Python):
from collections import defaultdict as DD
N, K = map(int,input().split())
D = DD(int)
for i in range(N):
  a, b = map(int,input().split())
  D[a] += b

L = sorted(D.items(), key = lambda x: x[0])
i = 0
while True:
  if L[i][1] >= K:
    print (L[i][0])
    break
  else:
    K -= L[i][1]
    i += 1

Solution (Python):
n,k=[int(i) for i in input().split()]
array=[]
for i in range(n):
    a,b=[int(_) for _ in input().split()]
    array.append(tuple([a,b]))
array.sort(key=lambda x:x[0])
count=0
for a,b in array:
    count+=b
    if count>=k:
        print(a)
        break

Solution (Python):

 
import math
import itertools
import sys
import copy
 






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

s = 0
for i in range(len(d)) :
  s += d[i]
  if s >= K :
    print (i)
    exit()

Solution (Python):
N, K = map(int, input().split())
count = 0
arr = [list(map(int, input().split())) for _ in range(N)]
arr.sort()
for i in arr:
    count += i[1]
    if count >= K:
        print(i[0])
        exit()
print(arr[-1][0])

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

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

cnt = 0
prev = None
for a, b in sorted(num_cnt.items()):
    if cnt >= K:
        break
    cnt += b
    prev = a
print(prev)

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

ABn = sorted(ABn, key=lambda x: x[0])
crr = K
ans = 0
for i in range(N):
    crr -= ABn[i][1]
    if crr <= 0:
        ans = ABn[i][0]
        break

print(ans)

Solution (Python):
tmp0 = input().split()
n = int(tmp0[0])
k = int(tmp0[1])
a = []
b = []
for i in range(n):
    tmp = input().split()
    a.append(int(tmp[0]))
    b.append(int(tmp[1]))

arr = [0]*(10**5 + 1)
for i in range(n):
    arr[a[i]] += b[i]

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

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

x = [0 for _ in range(0, 100001)]

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

l = 0
for i in range(1, 100001):
   if (l < k and (l + x[i]) >= k ):
      print(i)
      exit()

   l += x[i]

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, K = LI()
    ops = []
    for _ in range(N):
        a, b = LI()
        ops.append((a, b))
    ops = sorted(ops, key=lambda x: x[0])
    for op in ops:
        a, b = op
        if K - b <= 0:
            ans = a
            break
        K -= b
    print(ans)
main()

Solution (Python):
n,k=map(int,input().split())
cnt=0
lst=[]
for i in range(n):
  a,b=map(int,input().split())
  lst.append([a,b])
lst.sort(key=lambda x:x[0])
for j in range(n):
  cnt+=lst[j][1]
  if cnt>k-1:
    print(lst[j][0])
    break

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

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


for k,v in score_sorted:
  Z += v
  if K <= Z:
    print(k)
    break

Solution (Python):
N,K=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(N)]
B=[0]*(10**5+1)
for i in range(N):
  B[A[i][0]]+=A[i][1]

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

Solution (Python):
n, k = map(int, input().split())
a = [0] * n
b = [0] * n
sum = 0
arr = []
for i in range(n):
    a[i], b[i] = map(int, input().split())
arr_list = list(zip(a, b))
arr_list = sorted(arr_list)

for i in range(n):
    sum += arr_list[i][1]
    
    if sum >= k:
        answer = arr_list[i][0]
        break

print(answer)

Solution (Python):
import sys
input = sys.stdin.readline
n,k=map(int,input().split())
g=[]
for i in range(n):
    a,b=map(int,input().split())
    g.append([a,b])
g.sort()
i=0
while k>0:
    if k>g[i][1]:
        k-=g[i][1]
        i+=1
    else:
        ans=g[i][0]
        break
print(ans)

Solution (Python):
import sys
from itertools import accumulate
import bisect
n, k = [int(i) for i in sys.stdin.readline().split()]
ls = []
for i in range(n):
    a, b = [int(i) for i in sys.stdin.readline().split()]
    ls.append([a, b])
ls.sort(key=lambda x:x[0])
a_ls, b_ls = zip(*ls)
res = [i for i in accumulate(b_ls)]
print(a_ls[bisect.bisect_left(res, k)])

Solution (Python):

n, k = map(int, input().split())
l = []
ll = []
for i in range(n):
    a, b = map(int, input().split())
    l.append(b)
    ll.append([a, b])
ll.sort(key=lambda x: x[0])
for i in range(n):
    if k <= ll[i][1]:
        print(ll[i][0])
        break
    k -= ll[i][1]

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

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

Solution (Python):
n,k=map(int,input().split())
a=sorted([list(map(int,input().split())) for i in range(n)])
i=0
while True:
  if k-a[i][1]>0:
    k-=a[i][1]
  else:
    print(a[i][0])
    exit()
  i+=1

Solution (Python):
from operator import itemgetter
N,K = map(int,input().split())
ls = [list(map(int,input().split())) for _ in range(N)]
ls = sorted(ls,key=itemgetter(0))
len = 0
ans = 0
i = 0
while True:
    if len >= K:
        break
    ans = ls[i][0]
    len += ls[i][1]
    i += 1
print(ans)

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

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

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

Solution (Python):
N,K = map(int,input().split())
AB = []
for i in range(N):
    AB.append(list(map(int,input().split())))
AB.sort(key=lambda x:x[0])
c = 0
for a,b in AB:
    c += b
    if c >= K:
        print(a)
        exit()

Solution (Python):
import sys
from heapq import *

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n,k=MI()
    hp=[]
    for _ in range(n):
        a,b=MI()
        heappush(hp,[a,b])
    s=0
    while 1:
        a,b=heappop(hp)
        s+=b
        if s>=k:
            print(a)
            break
main()

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

ab.sort()

cnt=0
for i,j in ab:
  cnt+=j
  if cnt>=k:
    ans=i
    print(ans)
    exit()

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

Solution (Python):
import numpy as np

N, K = map(int, input().split())
a = []
b = []
for i in range(N):
    a1, b1 = map(int, input().split())
    a.append(a1)
    b.append(b1)
    
c = np.argsort(a)
ans = 0
for i in range(N):
    ans += b[c[i]]
    if ans >= K:
        print(a[c[i]])
        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])
i = 0
j = 0
while i < k:
  i += ab[j][1]
  j += 1
  
print(ab[j-1][0])

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

ans = dict()
for i in range(N):
    a, b = map(int, input().split())
    if a in ans:
        ans[a] += b
    else:
        ans[a] = b
    
ans = sorted(ans.items(), key=lambda x:x[0])    
count = 0
for k, v in ans:
    count += v
    if count >= K:
        print(k)
        exit()

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

Solution (Python):
n,k = map(int,input().split())
lst = [[int(i) for i in input().split()] for i in range(n)]
nlst = sorted(lst,key= lambda x:x[0])
cnt = 0

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

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

def main():
    N,K = map(int,input().split())
    L = []
    for i in range(N):
        a,b = map(int,input().split())
        L.append((a,b))
    
    L.sort()
    for i in range(N):
        K -= L[i][1]
        if K <= 0:
            print(L[i][0])
            exit()
    
if __name__ == "__main__":
    main()

Solution (Python):
def main():
    n,k=map(int,input().split())
    L=sorted([list(map(int,input().split())) for _ in range(n)])
    s=0
    for l in L:
        s += l[1]
        if k<=s:
            print(l[0])
            break
main()

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

total = 0
for a, b in AB:
  total += b
  if total >= K:
    print(a)
    exit()

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])
counter=0
i=0
counter+=ab[i][1]
while counter<K:
  i+=1
  counter+=ab[i][1]
print(ab[i][0])

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

Solution (Python):
from collections import deque
n, k = map(int, input().split())
d = deque()
for _ in range(n):
    a, b = map(int, input().split())
    d.append([a, b])
x = sorted(list(d))
for i in range(n):
    k -= x[i][1]
    if k < 1:
        print(x[i][0])
        break

Solution (Python):



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


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

a_b_list = sorted(a_b_list)

ans = 0
sum_elements = 0

for i in range(N):

    sum_elements += a_b_list[i][1]
    ans = a_b_list[i][0]
    
    if sum_elements >= K:
        print(ans)
        exit()

Solution (Python):
N,K = [int(i) for i in input().split()]
s = [[int(i) for i in input().split()] for N in range(N)]
s = sorted(s)
ans_bool = True

for i in s:
  K = K - i[1]
  if (K <= 0) and (ans_bool):
    ans_bool = False
    print(i[0])

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())
AB = [[i for i in map(int,input().split())] for j in range(N)]
sum = 0
AB.sort()

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

Solution (Python):
N , K = map(int,(input().split()))
 
sums = 0
nums = [0] * (10 ** 5 + 1) 
con = 0
ans = 0
 
for i in range(N):
  a,b = map(int,(input().split()))
  nums[a] += b
  
for i in range(len(nums)):
  con += nums[i]
  if K > con:
    continue
  elif K <= con:
    ans = i
    break

    
print(ans)

Solution (Python):
n, k = map(int, input().split())
c = 0
AB = []
ABC = []
for _ in range(n):
    a, b = map(int, input().split())
    AB.append((a,b))

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

for i in range(n):
    c += AB[i][1]
    ABC.append((AB[i][0], AB[i][1], c))

for i in range(n):
    if k <= ABC[i][2]:
        ind = i
        break

print(ABC[ind][0])

Solution (Python):
import sys
input = sys.stdin.readline
N, K = [int(x) for x in input().split()]
A = []
for _ in range(N):
    A.append([int(x) for x in input().split()])
A = sorted(A)
cnt = 0
for i in A:
    cnt += i[1]
    if cnt >= K:
        print(i[0])
        sys.exit()

Solution (Python):
a,b = [int(i) for i in input().split()]

temp = 0
l = sorted([[int(i) for i in input().split()] for _ in range(a)],key = lambda x: x[0])
for i in l:
    temp += i[1]
    if temp >= b:
        ans = i[0]
        break
print(ans)

Solution (Python):
n,k = map(int,input().split())
a = []
b = []
for i in range(n):
    tmp1,tmp2 = map(int,input().split())
    a.append(tmp1)
    b.append(tmp2)
ab =zip(a,b)
ab =sorted(ab)
a,b = zip(*ab)
counter = k
for i in range(n):
    counter -=b[i]
    if counter <= 0:
        print(a[i])
        break

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

lis = []
max_num = 0
for i in range(n):
    array = list(map(int, input().split()))
    if array[0] > max_num:
        max_num = array[0]
    lis.append(array)

num_list = [0] * max_num

for i, j in lis:
    num_list[i-1] += j

count = 0
for i in range(len(num_list)):
    count += num_list[i]
    if count >= k:
        print(i+1)
        exit()

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

abl = sorted(abl)
for a,b in abl:
    k -= b
    if k <= 0:
        print(a)
        import sys
        sys.exit()

Solution (Python):

import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
ans = 0 ;count = 0 ;pro = 1

data=[]
n,k=map(int,input().split())
for i in range(n):
    a,b=map(int,input().split())
    data.append((a,b))
data.sort()
for di in data:
    if di[1]>=k:
        print(di[0])
        exit()
    else:
        k-=di[1]