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):
def main():
    from itertools import accumulate

    n, k, *ab = map(int, open(0).read().split())
    c = list(zip(ab[::2], ab[1::2]))
    c.sort(key=lambda x: x[0])
    count = 0
    for i, j in c:
        count += j
        if k <= count:
            print(i)
            break


if __name__ == '__main__':
    main()

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 a in sorted(counter.keys()):
    b = counter[a]
    if K <= b:
        print(a)
        break
    K -= b

Solution (Python):
def main():
    n, k = map(int, input().split())
    a, b = [0 for i in range(n)], [0 for i in range(n)]
    for i in range(n):
        a[i], b[i] = [int(x) for x in input().split()]
    ans = solve(n, k, a, b)
    print(ans)


def solve(n, k, a, b):
    ab = [[a[i], b[i]] for i in range(n)]
    ab.sort(key = lambda x:x[0])
    back = 0
    for i in range(n):
        back += ab[i][1]
        if back >= k:
            return ab[i][0]
    return 


if __name__ == '__main__':
    main()

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

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

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

print(ans)

Solution (Python):
n, k, *AB = map(int, open(0).read().split())
*AB, = zip(AB[::2], AB[1::2])
AB.sort()

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

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

ab = sorted(ab)
cnt = 0
for a, b in ab:
    cnt += b
    if cnt >= k:
        print(a)
        exit()

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

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

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

Solution (Python):
n, k = list(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 k <= cnt:
        print(ab[i][0])
        break

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
ab = [LIST() 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):
N,K=map(int,input().split())
S={}
for i in range(N):
  a,b=map(int,input().split())
  if a in S:
    S[a]+=b
  else:
    S[a]=b
T=sorted(S.items())
count=0
for i in range(len(T)):
  count+=T[i][1]
  if count>=K:
    print(T[i][0])
    break

Solution (Python):
N,K=map(int,input().split())
S={}
for i in range(N):
  a,b=map(int,input().split())
  if a in S:
    S[a]+=b
  else:
    S[a]=b
T=sorted(S.items())
count=0
for i in range(len(T)):
  count+=T[i][1]
  if count>=K:
    print(T[i][0])
    break

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

lst = [0 for i in range(10**5+1)]
for i in range(n):
    ai, bi = map(int, input().split())
    lst[ai] += bi

for i in range(1, 10**5+1):
    k -= lst[i]
    if k <= 0: break

print(i)

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

Solution (Python):
from operator import itemgetter
n,k = map(int,input().split())
lists = []
cnt = 0
a_b = sorted([list(map(int,input().split())) for i in range(n)],key = itemgetter(0))
for a,b in a_b:
    cnt += b
    if cnt >= k:
        print(a)
        exit()

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

Solution (Python):
N, K = map(int,input().split())
L = sorted([list(map(int,input().split())) for _ in range(N)])
for e in L:
    K -= e[1]
    if K <= 0:
        print(e[0])
        exit(0)

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()
cnt = 0
for i in range(n):
    a, b = X[i]
    cnt += b
    if cnt >= k:
        print(a)
        exit()

Solution (Python):
import bisect
n,k=map(int,input().split())
s=[0 for _ in range((10**5)+1)]
maxa=0
for i in range(n):
    a,b=map(int,input().split())
    s[a]+=b
    maxa=max(maxa,a)
s=s[:maxa]

for i in range(1,len(s)):
    s[i]+=s[i-1]

print(bisect.bisect_left(s, k))

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

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

Solution (Python):
import sys, heapq, bisect, math, fractions
from collections import deque
from collections import Counter
from collections import OrderedDict

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

for i in range(N):
    a, b = map(int, input().split())
    if a not in od:
        od[a] = b
    else:
        od[a] += b
od = OrderedDict(sorted(od.items(), key=lambda x: x[0]))

for i in od.items():
    K -= i[1]

    if K <= 0:
        print(i[0])
        exit()

Solution (Python):
n, k = map(int, input().split())
d = {}
for _ in range(n):
    a, b = map(int, input().split())
    if a in d:
        d[a] += b
    else:
        d[a] = b
dd = [(k, v) for k, v in d.items()]
dd = sorted(dd, key=lambda x: x[0])
cur = 0
tmp = -1
for a, b in dd:
    if cur >= k:
        break
    cur += b
    tmp = a
print(tmp)

Solution (Python):
import sys, heapq, bisect, math, fractions
from collections import deque
from collections import Counter
from collections import OrderedDict

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

for i in range(N):
    a, b = map(int, input().split())
    if a not in od:
        od[a] = b
    else:
        od[a] += b
od = OrderedDict(sorted(od.items(), key=lambda x: x[0]))

for i in od.items():
    K -= i[1]

    if K <= 0:
        print(i[0])
        exit()

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

ans = 0
m = 0
ab = []
for i in range(N):
    ab.append(list(map(int,input().split())))

ab.sort()

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

Solution (Python):
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right


from functools import reduce
from pprint import pprint

INF = float("inf")

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

n,k = myinput()
ab = mylistinput(n)

ab = mysort(ab,0,False)


count = 0
for i in range(n):
    a = ab[i][0]
    b = ab[i][1]
    count += b
    if count >= k:
        print(a)
        exit()
print("E")

Solution (Python):
from statistics import median


from fractions import gcd
from itertools import combinations 
from collections import deque
from collections import defaultdict
import bisect










import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

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

def main():
    n,k = readInts()
    sum_ = 0
    l = []
    for i in range(n):
        a,b = readInts()
        l.append([a,b])
    l = sorted(l,key = lambda x:x[0])
    for a,b in l:
        sum_ += b
        if sum_ >= k:
            print(a)
            exit()


if __name__ == '__main__':
  main()

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    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])
    
    
    cnt=0
    for i in range(n):
        temp=cnt
        cnt+=L[i][1]
        if cnt==k:
            print(L[i][0])
            break
        elif cnt>k and temp<k:
            print(L[i][0])
            break
        elif cnt>k and temp>=k:
            print(L[i-1][0])
            break

    
resolve()

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7


n,k=MI()
lis=[0 for i in range(10**5)]
for i in range(n):
    a,b=MI()
    lis[a-1]+=b

sm=0
for i in range(10**5):
    sm+=lis[i]
    
    if sm>=k:
        print(i+1)
        sys.exit()

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

d = {}
for i in range(n):
  a,b = tuple(map(int,input().split()))
  d.setdefault(a,0)
  d[a]+=b
  
l = sorted(d.items())

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

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

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

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

N, K = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(N)]
ab.sort(key=lambda t: t[0])
cnt = 0

for a, b in ab:
    cnt += b
    
    if cnt>=K:
        print(a)
        exit()

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

L=[]

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

L=sorted(L)

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

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


if __name__ == '__main__':
    main()

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

Solution (Python):
N, K = map(int, input().split())
T = sorted((tuple(map(int, input().split())) for _ in range(N)), key=lambda t: t[0])
k = 0
for t in T:
    k += t[1]
    if k >= K:
        print(t[0])
        break

Solution (Python):
[n,k]=list(map(int,input().split()))
ablist=[]
for i in range(n):
    ablist.append(list(map(int,input().split())))
ablist=sorted(ablist,key=lambda x:x[0])
bwa=[0]
for i in range(n):
    bwa.append(bwa[-1]+ablist[i][1])
ind=1
while True:
    if bwa[ind-1]<k<=bwa[ind]:
        break
    ind+=1
print(ablist[ind-1][0])

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
inc=0
for i in range(10**5+1):
    inc+=l[i]
    if inc>=k:
        print(i)
        break

Solution (Python):
import sys

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

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

count = 0

for elem in elements:
    count += elem[1]
    if count >= k:
        print(elem[0])
        sys.exit()

Solution (Python):
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
from operator import itemgetter
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor



dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

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

abab = sorted(ab)

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

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


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

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

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


if __name__ == "__main__":
    main()

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


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

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


if __name__ == "__main__":
    main()

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

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

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

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

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

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

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

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, k = map(int, readline().split())
ab = [tuple(map(int, readline().split())) for _ in range(n)]
ab.sort()
for a, b in ab:
    k -= b
    if k <= 0:
        print(a)
        break

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, k = map(int, readline().split())
ab = [list(map(int, readline().split())) for _ in range(n)]
ab.sort()
for a, b in ab:
    if b >= k:
        print(a)
        exit()
    k -= b

Solution (Python):
from itertools import chain
N,K = map(int,input().split())
num_bool = [0]*(10**5)
numarray_ind = list()

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

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

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

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

L=sorted(L)
count=0

for i in range(N):
    t=L[i]
    a,b=t
    count+=b
    if count>=K:
        print(a)
        break

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

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,k = inpl()
ab = [inpl() for _ in range(n)]
ab.sort()
cnt = 0
for a,b in ab:
    cnt += b
    if cnt >= k:
        print(a)
        break

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

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

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

Solution (Python):
def main():
    from heapq import heappush, heappop

    import sys
    input = sys.stdin.readline

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

    h = []
    for _ in range(N):
        a, b = map(int, input().split())
        heappush(h, (a, b))

    while h:
        a, b = heappop(h)
        K -= b
        if K <= 0:
            print(a)
            return


if __name__ == '__main__':
    main()

Solution (Python):
N,K = map(int,input().split())
d = {}
for i in range(N):
    a,b = map(int,input().split())
    d[a]= d[a]+b if a in d else b
dd = sorted(d)    
_sum = 0
for i in dd:
    _sum += d[i]
    if _sum >= K:
        print(i)
        exit()

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

dic = {}
for ab in ab_inputs:
    a,b = map(int,ab)
    dic[a]=dic.get(a,0)+b

for s in sorted(dic.items(),key=lambda x:x[0]):
    k-=s[1]
    if k<=0:
        ans=s[0]
        break
print(ans)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
n,k=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
l.sort(key=lambda x:x[0])
c=0
i=0
while True:
    if c<k and c+l[i][1]>=k:
        print(l[i][0])
        exit()
    else:
        c+=l[i][1]
        i+=1

Solution (Python):
from collections import defaultdict


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

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

d = sorted(d.items())

for i, j in d:
    cnt += j
    if cnt >= k:
        print(i)
        break

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):
    k -= ab[i][1]
    if k <= 0:
        print(ab[i][0])
        break

Solution (Python):
N, K = map(int, input().split())
from itertools import accumulate
from bisect import bisect_left

lis = []
lis = [tuple(map(int, input().split())) for i in range(N)]
lis.sort()
Bs = [y for x, y in lis]
cB = list(accumulate(Bs))

print(lis[bisect_left(cB, K)][0])

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

Solution (Python):
import sys
import re
import math
import collections









INF = sys.maxsize


ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))





def main():
    n, k = ns()
    d=[]
    for _ in range(n):
        d.append(list(ns()))
    d.sort()

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

if __name__ == '__main__':
    main()

Solution (Python):
n,k=map(int,input().split())
m=[]
for i in range(n):
  m.append(list(map(int,input().split())))
m=sorted(m, key=lambda thing: thing[0])
total=0
for i in range(n):
  total+=m[i][1]
  if total>=k:
    ans=m[i][0]
    break
print(ans)

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

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

d_keys=sorted(d.keys())
cnt=0
for i in d_keys:
  cnt+=d[i]
  if cnt>=k:
    print(i)
    exit()

Solution (Python):
import itertools
n,k=map(int,input().split())
bl=[0]*(10**5+1)
for i in range(n):
  a,b=map(int,input().split())
  bl[a]+=b
ans=list(itertools.accumulate(bl))
for i in range(len(ans)+1):
  if k<=ans[i]:
    print(i)
    break

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

Solution (Python):
N,K = map(int,input().split())
A = sorted([list(map(int,input().split())) for _ in range(N)],key=lambda x:x[0])
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 i in range(N):
  l.append( list(map(int,input().split())) )
l.sort()
  
a = [0]
b = [0]
for i in range(N):
  [x,y] = l[i]
  a.append(x)
  b.append(y)

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

Solution (Python):
import sys
input = sys.stdin.readline
n,k = map(int,input().split())
inf = 10**10
parent = [inf]*n
q = {}
for i in range(n):
    a,b = map(int,input().split())
    if a not in q.keys():
        parent[i] = a
        q[a] = 0
    q[a] += b
parent.sort()
cnt = 0
for p in parent:
    cnt += q[p]
    if cnt >= k:
        print(p)
        break

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

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

nums.sort()

for i in range(N):
    n = min(K, nums[i][1])
    K -= n
    if K == 0:
        print(nums[i][0])
        break

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

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

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

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


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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(n)]
    AB = sorted(AB, key=lambda x: x[0])

    for i in range(n):
        a, b = AB[i]
        if b < k:
            k -= b
        else:
            print(a)
            break


if __name__ == '__main__':
    resolve()

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

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

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

Solution (Python):
import heapq


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

q = []
for a, b in info:
    heapq.heappush(q, (a, b))

while q:
    a, b = heapq.heappop(q)
    if k <= b:
        print(a)
        exit()
    else:
        k -= b

Solution (Python):
def main():
    n, k = map(int, input().split())
    seq = {}
    for _ in range(n):
        a, b = map(int, input().split())
        if a in seq:
            seq[a] += b
        else:
            seq[a] = b
    seq = sorted(seq.items(), key=lambda x: x[0])
    answer = 0
    for n, c in seq:
        k -= min(c, k)
        if k <= 0:
            answer = n
            break
    print(answer)


if __name__ == '__main__':
    main()

Solution (Python):
N,K = map(int,input().split())
AB = [tuple(map(int,input().split())) for i in range(N)]
from collections import Counter
ctr = Counter()
for a,b in AB:
    ctr[a] += b

for k,v in sorted(ctr.items()):
    if K <= v:
        print(k)
        exit()
    K -= v

Solution (Python):
import sys

N, K = map(int, sys.stdin.readline().rstrip().split())

opes = []
for _ in range(N):
    a, b = map(int, sys.stdin.readline().rstrip().split())
    opes.append((a, b))
opes.sort()

count = 0
for (a, b) in opes:
    if count + b >= K:
        print(a)
        sys.exit()
    count += b

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

ablist=[]
for _ in range(N):
  a,b=map(int,input().split())
  ablist.append((a,b))
ablist.sort()
  
s=0
for a,b in ablist:
  s+=b
  if s>=K:
    print(a)
    break

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

ablist=[]
for _ in range(N):
  a,b=map(int,input().split())
  ablist.append((a,b))
ablist.sort()
  
aslist=[]
s=0
for a,b in ablist:
  s+=b
  aslist.append((a,s))


for a,s in aslist:
  if s>=K:
    print(a)
    break

Solution (Python):
v = [0] * 100001
n, k = map(int, input().split())
for i in range(n):
  a, b = map(int, input().split())
  v[a] += b
s = 0
for i in range(100001):
  s += v[i]
  if s >= k:
    print(i)
    break

Solution (Python):
n,k,*l=map(int,open(0).read().split())
for a,b in sorted(zip(l[::2],l[1::2])):
 k-=b
 if k<1:print(a);exit()

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

Solution (Python):
L=lambda:list(map(int,input().split()))
n,k=L()
ab=sorted([L()for _ in range(n)])
for a,b in ab:
  k-=b
  if k<=0:
    print(a)
    exit()

Solution (Python):
L=lambda:list(map(int,input().split()))
n,k=L()
for a,b in sorted([L() for _ in range(n)]):
  k-=b
  if k<=0:print(a);exit()

Solution (Python):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

array = []
n,k = map(int,input().split())
for i in range(n):
    a,b = map(int,input().split())
    array.append([a,b])
array.sort()
sumli = 0
for i in range(len(array)):
    sumli += array[i][1]
    if sumli>=k:
        break
print(array[i][0])

Solution (Python):
def nyu():
    N,K = map(int,input().split())
    A = [list(map(int,input().split())) for _ in range(N)]
    A.sort()
    return N,K,A

def kansu(N,K,A):
    
    sum = 0
    ans = -1


    for a in range(len(A)):
        sum += A[a][1]

        if (K <= sum):
            ans = A[a][0]
            break
    print(ans)




N,K,A = nyu()
kansu(N,K,A)

Solution (Python):
n,k=map(int,input().split())
d={}
l=[]
num=0
for i in range(n):
    a,b=map(int,input().split())
    try:
        d[a]+=b
    except:
        d[a]=b
        l.append(a)
l.sort()

for i in range(len(l)):
    num+=d[l[i]]
    if num>=k:
        print(l[i])
        break

Solution (Python):

import sys

def main():
    N, K = map(int, input().split())
    a = [tuple(map(int, input().split())) for _ in range(N)]
    a.sort()
    i = 0
    while 1:
        K -= a[i][1]
        if K > 0:
            i += 1
        else:
            print(a[i][0])
            exit()

if __name__ == '__main__':
    main()