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


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

l = sorted(dic.items())

for a, b in l:
    if k <= b:
        ans = a
        break
    k -= b
print(ans)

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

cnt = 0
i = 0
while cnt < k:
    a, b = query[i]
    cnt += b
    i += 1
print(a)

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

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


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

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

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

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

print(ab[index][0])

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

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

Solution (Python):

"""
Created on Mon Sep 28 01:21:16 2020

@author: liang
"""


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

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

Solution (Python):

"""
Created on Mon Sep 28 01:14:47 2020

@author: liang
"""

N, K = map(int,input().split())
A = list()
for i in range(N):
    a, b = map(int,input().split())
    A.append((a,b))
A.sort(key= lambda x:x[0])

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

Solution (Python):
from collections import defaultdict
def main():
  N, K = map(int,input().split())
  D = defaultdict(int)
  for _ in range(N):
    a, b = map(int,input().split())
    D[a]+=b
  D = sorted(D.items())
  ans, total = D[0]
  for i in range(1,len(D)):
    if K <= total:
      print(ans)
      return
    else:
      c, d = D[i]
      ans = c
      total+=d
  print(ans)
  return

main()

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

Solution (Python):
N,K=map(int,input().split())
count=[0]*(100001)
for i in range(1,N+1) :
  a,b=map(int,input().split())
  count[a]+=b
for i in range(1,100001) :
  if K<=count[i] :
    print(i)
    break
  K-=count[i]

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

def slv():
    cnt = 0
    for i in range(n):
        cnt += ab[i][1]
        if cnt >= k:
            return print(ab[i][0])

slv()

Solution (Python):
from collections import defaultdict
n,k = map(int, input().split())
ans = 0
al = []
d = defaultdict(int)
for i in range(n):
  a,b = map(int, input().split())
  al.append(a)
  d[a] += b
al = list(set(al))  
al.sort()
for i in al:
  if k > d[i]:
    k -= d[i]
  else:
    print(i)
    break

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

ab = [0]*n

for i in range(n):
  ab[i] = input().split()
a = []
b = []
for i in range(n):
  tmp1 = int(ab[i][0])
  tmp2 = int(ab[i][1])
  a.append(tmp1)
  b.append(tmp2)
ab = zip(a,b)
ab = sorted(ab)
a,b = zip(*ab)

s = 0
for i in range(n):
  s += int(b[i])
  if s >= k:
    print(int(ab[i][0]))
    exit()

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

nums = [0]*(10**5+1)

for i in range(n):
    a, b = map(int,input().split())
    nums[a] += b
    
now = 0
for i,n in enumerate(nums):
    now += n
    if now >= k:
        print(i)
        break

Solution (Python):
n, k = map(int, input().split(" "))
a = sorted([list(map(int, input().split(" "))) for i in range(n)])
count = 0
for x, y in a:
  count += y
  if k <= count:
    print(x)
    break
else:
  print("None")

Solution (Python):

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

lis = sorted(lis,reverse = False)

cnt = 0
num = 0
for a,b in lis:
    cnt += b
    num = a
    if cnt >= K:
        break
print(num)

Solution (Python):
N, K = map(int, input().split())
a = []
b = []
Sum = 0
for i in range(N):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)
s = [*range(len(a))]
sort_s = sorted(s, key = lambda i: a[i])
sort_a = [a[i] for i in sort_s]
sort_b = [b[i] for i in sort_s]
for i in range(N):
    Sum += sort_b[i]
    if Sum >= K:
        print(sort_a[i])
        break

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

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

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

ab.sort()

num_sum = 0

for a, b in ab:
    num_sum += b
    if num_sum >= 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()

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

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

Solution (Python):
from xml.dom import minidom


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

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

now = -1
idx = 0
while k > 0:
    if idx >= n:
        break
    a, b = AB[idx]
    k -= b
    now = a
    idx += 1
print(now)

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

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

Solution (Python):
from collections import Counter

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

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

x = sorted(d.items(), key=lambda x: x[0])
cnt = 0
for a, b in x:
    cnt += b
    if cnt >= k:
        print(a)
        exit()

Solution (Python):
from collections import defaultdict

def main():
    N, K = map(int, input().split())
    d = defaultdict(int)
    for _ in range(N):
        a, b = map(int, input().split())
        d[a] += b
    total = 0
    for v, freq in sorted(d.items()):
        total += freq
        if total >= K:
            print(v)
            exit()


if __name__ == '__main__':
    main()

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

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

Solution (Python):
n, k = map(int, input().split())
sum_b = 0
ab_list = []

for i in range(n):
    ab_list.append(list(map(int, input().split())))

ab_list.sort()
for i in range(n):
    a, b = ab_list[i]
    sum_b += b
    if sum_b >= k:
        print(a)
        break

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

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

command.sort()

ind = 0
for i in range(N):
    if ind + command[i][1]>=K:
        print(command[i][0])
        exit()
    else:
        ind += command[i][1]

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

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

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

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

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

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

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

Solution (Python):
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n, k = LI()
    lst = []

    for _ in range(n):
        a, b = LI()
        lst.append((a,b))
    
    lst.sort(key=lambda x: x[0])
    taken = 0
    ans = 0

    for i in range(n):
        ans = lst[i][0]
        taken += lst[i][1]

        if taken >= k:
            break

    print(ans)
main()

Solution (Python):

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

    i = 0

    while k > 0:
        k -= ab[i][1]
        i += 1
    else:
        print(ab[i-1][0])

if __name__ ==  "__main__":
    main()

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

lst = [list(map(int, input().split())) for _ in range(N)]
lst.sort(key=lambda x: x[0])
s = 0
for i in range(N):
	s += lst[i][1]
	if s >= K: break
print(lst[i][0])

Solution (Python):
N,K=map(int,input().split())
ab=list(list(map(int,input().split())) for _ in range(N))
ab.sort()

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

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

Solution (Python):
N, K = map(int, input().split())
d = {}
key = set([])
for _ in range(N):
  a, b = map(int, input().split())
  if a in key:
    d[str(a)] += b
  else:
    key.add(a)
    d[str(a)] = b
key = sorted(list(key))
for k in key:
  if d[str(k)] < K:
    K -= d[str(k)]
  else:
    print(k)
    break

Solution (Python):
N, K = map(int, input().split())
A = [0 for i in range(100001)]
for i in range(N):
  a, b = map(int, input().split())
  A[a] += b
for i in range(100001):
  if A[i] < K:
    K -= A[i]
  else:
    print(i)
    break

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

Solution (Python):
n, k = map(int, input().split())
S = set()
D = dict()
for _ in range(n):
    a, b = map(int, input().split())
    if a in S:
        D[a] += b
    else:
        S.add(a)
        D[a] = b
L = sorted(S)
cnt = 0
for l in L:
    cnt += D[l]
    if cnt >= k:
        print(l)
        break

Solution (Python):
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right 
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]

N,K = mint()
C = counter()
for _ in range(N):
    a,b = mint()
    C.add(a,b)
L = []
for k in C:
    L.append([k,C[k]])
L.sort(key=lambda x:x[0])
tmp = 0
for l in L:
    tmp += l[1]
    if tmp>=K:
        print(l[0])
        exit()

Solution (Python):
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

import string

def main():
    n,k = i_map()

    cnt = 0
    l = []
    for _ in range(n):
        a,b = i_map()
        l.append([a,b])

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

if __name__=="__main__":
    main()

Solution (Python):

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

cnt = [0] * (100000 + 1)

for i in range(N):
    cnt[a[i]] += b[i]

for j in range(100000 + 1):
    if K <= cnt[j]:
        print(j)
        break
    K -= cnt[j]

Solution (Python):
n,k=map(int,input().split())
ab=[]
for i in range(n):
    a,b=map(int,input().split())
    ab.append([a,b])
abc=sorted(ab,key=lambda x:x[0])
temp=0
for j in abc:
    temp+=j[1]
    if temp>=k:
        print(j[0])
        exit()

Solution (Python):
from collections import defaultdict as dd
from itertools import count
N, K = map(int, input().split())
Cnt = dd(lambda:0)
for _ in range(N):
    a, b = map(int, input().split())
    Cnt[a] += b

num = 0
for i in count(1,1):
    num += Cnt[i]
    if num >= K:
        print(i)
        break

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

li.sort()

total=0
for i in range(n):
    if i==n-1:
        
        print(li[i][0])
        break
    total+=li[i][1]
    if total<k:
        continue
    else:
        print(li[i][0])
        break

Solution (Python):


def main():
    n, k = map(int, input().split())
    arr = sorted([list(map(int, input().split())) for i in range(n)])
    for ab in arr:
        k -= ab[1]
        if k <= 0:
            ans = ab[0]
            break

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
n,k=map(int,input().split())
import sys
mod=10**9+7 ; inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict 
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal  
  
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright






A=[0]*(10**5+1)
for i in range(n):
    a,b=map(int,input().split())
    A[a]+=b 
R=[0]*(10**5+1)
for i  in range(10**5):
    R[i+1]=R[i]+A[i+1]
print(bileft(R,k))

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

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

class Number:
    def __init__(self,number,times):
        self.number=number
        self.times=times

    def __eq__(self, other):
        if self.number==other.number:
            return True
        return False
    def __le__(self, other):
        if self.number<=other.number:
            return True
        return False
    def __lt__(self, other):
        if self.number<other.number:
            return True
        return False
    def __ge__(self, other):
        if self.number>=other.number:
            return True
        return False
    def __gt__(self, other):
        if self.number>other.number:
            return True
        return False

number_list=[]
for i in range(n):
    number,times=[int(i) for i in input().split()]
    number_list.append(Number(number,times))

number_list.sort()


def get(number_list,k):
    i=0
    while True:
        taishou=number_list[i]
        k=k-taishou.times
        if k<=0:
            return taishou.number
        else:
            i+=1
print(get(number_list,k))

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

Solution (Python):
N, K = list(map(int, input().split()))
C = [0]*(10**5+1)
S=set()
for _ in range(N):
    a, b = list(map(int, input().split()))
    C[a] += b
    S.add(a)

L = list(S)
L.sort()
i = 0
ct = C[L[0]]
while ct < K:
    i += 1
    ct += C[L[i]]
print(L[i])

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

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

ans.sort()

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

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

Solution (Python):
def is_ok(arg):
    global K
    return r[arg] >= K
def meguru_bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok
N, K = map(int, input().split())
A = [0] * 10**5
for _ in range(N):
    a, b = map(int, input().split())
    A[a-1] += b
r = [A[0]]
for i in range(10**5-1):
    r.append(r[i] + A[i+1])
print(meguru_bisect(-1, 10**5)+1)

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

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


judge = 0
dic = {}


for i in range(n):
    if a[i] in dic:
        dic[a[i]] += b[i]
    else:
        dic[a[i]] = b[i]

dic = list(dic.items())
dic.sort()



for i in range(10**9):
    if judge >= k:
        print(dic[i-1][0])
        break
    else:
        judge += int(dic[i][1])

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

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

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

q = sorted(q, key=lambda x:x[0])
cnt = 0
i = 0
while cnt < k:
    a, b = q[i]
    cnt += b
    i += 1
print(a)

Solution (Python):
import heapq

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

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

heapq.heapify(q)

cnt = 0
while cnt < k:
    a, b = heapq.heappop(q)
    cnt += b
    
print(a)

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

cnt=0
for i in range(N):
    a,b=A[i]
    A[i][1]+=cnt
    cnt=A[i][1]

for i in range(N):
    a,b=A[i]
    if K<=b:break
print(a)

Solution (Python):



import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 4
1 1
2 2
3 3"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """10 500000
1 100000
1 100000
1 100000
1 100000
1 100000
100000 100000
100000 100000
100000 100000
100000 100000
100000 100000"""
        output = """1"""
        self.assertIO(input, output)


def resolve():
    N, K = map(int, input().split())
    D = [list(map(int, input().split())) for _ in range(N)]

    D.sort()
    t = 0
    for d in D:
        t += d[1]
        if t >= K:
            print(d[0])
            break


if __name__ == "__main__":
    
    resolve()

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

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

Solution (Python):
n,k=map(int,input().split())
a=[]
for i in range(n):
    A=list(map(int,input().split()))
    a.append(A)
a = sorted(a, key=lambda x: x[0])
b=0
for i in range(n):
    b+=a[i][1]
    if b>=k:
        print(a[i][0])
        exit()

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

def main():
    n,k = map( int , input().split() )
    A = [ 0 for i in range( 10 ** 5 + 1 ) ]
    for i in range(n):
        a,b = map( int , input().split() )
        A[ a ] += b
    
    i = 0
    sum = 0
    while( sum < k ):
        i += 1
        sum += A[i]
    print(i)



main()

Solution (Python):
N,K=map(int,input().split())
d={}
for i in range(N):
  a,b=map(int,input().split())
  if a not in d:
    d[a]=b
  else:
    d[a]+=b
d=sorted(d.items())
for i in d:
  K-=i[1]
  if K<=0:
    print(i[0])
    break

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

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

l = [0] * (10**5 + 1)

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

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

Solution (Python):
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array





sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, K = il()
    counter = collections.Counter()
    for _ in range(N):
        a, b = il()
        counter[a] += b
    counter = sorted(counter.items(), key=lambda x: x[0])

    k = 0
    for key, value in counter:
        k += value
        if k >= K:
            print(key)
            exit()


if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter
n, k = map(int, input().split())
d = Counter([])
for i in range(n):
    a, b = map(int, input().split())
    d[a] += b
ans = 1
cnt = 0
while cnt < k:
    cnt += d[ans]
    ans += 1

print(ans - 1)

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

Solution (Python):

from collections import defaultdict

n, k = [int(i) for i in input().split()]
d = defaultdict(int)

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

array = sorted(d.items(), key=lambda x: x[0])
for num, count in array:
    if k > count:
        k -= count
    else:
        print(num)
        quit()

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

Solution (Python):



N, K = map(int, input().split())
A = [0] * (100005)
for _ in range(N):
    ai, bi = map(int, input().split())
    A[ai] += bi

for index in range(100005):
    if K <= A[index]:
        print(index)
        exit()
    else:
        K -= A[index]

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

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

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

cnt = 0
for i, c in enumerate(bucket):
    if c == 0:
        continue
    cnt += c
    if cnt >= K:
        print(i)
        exit()

Solution (Python):
n, k = map(int, (input().split()))
arr = [0] * 100100
for i in range(n):
    a, b = map(int, input().split())
    arr[a] += b

cur = 0
for i in range(100100):
    cur += arr[i]
    if cur >= k:
        print(i)
        break

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


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

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

Solution (Python):
def main2():
    N, K = map(int, input().split())
    limit = 10**5

    ins = [0 for _ in range(limit + 1)]

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

    c = 0
    for i in range(1, limit + 1):
        c += ins[i]

        if c >= K:
            print(i)
            exit()

if __name__ == "__main__":
    main2()

Solution (Python):
N,K=map(int,input().split())
l=[list(map(int,input().split()))for i in range(N)]
l.sort(key=lambda x: x[0])
ans=0
for i in l:
    if K==0:
        break
    K-=min(K,i[1])
    ans=i[0]
print(ans)

Solution (Python):
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
    
for i in range(len(ans)):
    k-=ans[i]
    if k<=0:
        print(i)
        break

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

Solution (Python):












import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n, k = nm()
    A = [0] * (10 ** 5 + 1)
    for i in range(n):
        a, b = nm()
        A[a] += b

    sum_num = 0
    for i, a in enumerate(A):
        sum_num += a
        if sum_num >= k:
            print(i)
            return


if __name__ == '__main__':
    main()

Solution (Python):


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

d = {}
for i in range(n):
    if a[i] not in d:
        d[a[i]] = b[i]
    else:
        d[a[i]] += b[i]

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

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

Solution (Python):
N, K = map(int, input().split())
now = 0
ab = [list(map(int, input().split())) for _ in range(N)]
ab = sorted(ab)
for a, b in ab:
  if now < K <= now+b:
    print(a)
    exit()
  now += b

Solution (Python):
N,K=map(int,input().split())
l=[list(map(int,input().split()))for i in range(N)]
l.sort(key=lambda x: x[0])
ans=0
for i in l:
    if K==0:
        break
    K-=min(K,i[1])
    ans=i[0]
print(ans)

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

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

Solution (Python):
from sys import stdin
input = stdin.readline
 
from itertools import accumulate
from bisect import bisect_left
 
N, K = map(int, input().split())
 
memo = [0] * 100010
for _ in range(N):
    a, b = map(int, input().split())
    memo[a] += b
 
print(bisect_left(list(accumulate(memo)), K))

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate, product 

from collections import deque,defaultdict,Counter
import decimal
import re
import math












import sys
sys.setrecursionlimit(10000000)


mod = 998244353
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())



from fractions import gcd
from itertools import combinations,permutations,accumulate, product 

from collections import deque,defaultdict,Counter
import decimal
import re
import math












import sys
sys.setrecursionlimit(10000000)


mod = 998244353
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,k = readInts()
dic = defaultdict(int)
d = set()
for i in range(n):
    a,b = readInts()
    d.add(a)
    dic[a] += b
d = sorted(list(d))
ans = 0
for v in d:
    if ans + dic[v] >= k:
        print(v)
        exit()
    ans += dic[v]