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):
from sys import stdin


def main():
    n, k = map(int, stdin.readline().split())
    ab = [list(map(int, stdin.readline().split())) for _ in range(n)]
    ab.sort(key=lambda x: x[0])
    count = 0
    for a, b in ab:
        if count + b < k:
            count += b
        else:
            print(a)
            exit()


if __name__ == "__main__":
    main()

Solution (Python):
from sys import stdin


def main():
    n, k = map(int, stdin.readline().split())
    ab = [list(map(int, stdin.readline().split())) for _ in range(n)]
    ab.sort(key=lambda x: x[0])
    count = 0
    for a, b in ab:
        if count + b < k:
            count += b
        else:
            print(a)
            exit()


if __name__ == "__main__":
    main()

Solution (Python):
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
for i in range(1, 10**5+1):
    if K <= num[i]:
        print(i)
        exit()
    K -= num[i]

Solution (Python):
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
for i in range(1,10**5+1):
    if K <= num[i]:
        print(i)
        exit()
    K -= num[i]

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

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

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

d = [0 for i in range(10**5)]

for i in range(n):
    d[l[i][0]-1] += l[i][1]

cnt = 0
for i in range(10**5):
    cnt += d[i]
    if cnt >= m:
        print(i+1)
        exit()

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

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

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

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

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


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


s=0
ans=0

for n,i in enumerate(ans_list):
  s+=i
  ans=n
  if s>=k:
    print(ans)
    break

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

N, K = map(int, input().split())
l = np.array([list(map(int, input().split())) for _ in range(N)])
a = l[np.argsort(l[:, 0])]

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

Solution (Python):
n, k = map(int, input().split())
ll = []
for i in range(n):
    a, b = map(int, input().split())
    ll.append([a, b])
lls = sorted(ll)
cnt = 0
for i in range(n):
    cnt += lls[i][1]
    if cnt  >= k:
        print(lls[i][0])
        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())
dic = {}
cnt = [0 for i in range(100001)]
for i in range(n):
    s, t = map(int, input().split())
    cnt[s] += t
for i in range(1, 100002):
    if k <= cnt[i]:
        print(i)
        break
    k -= cnt[i]

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

p = [[0, 0] for i in range(n)]
for i in range(n):
  p[i] = list(map(int, input().split()))
  
p.sort()

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

Solution (Python):

def main2():
    import heapq
    n,k = map(int,input().split(" "))
    q = []
    for i in range(n):
        a,b = map(int,input().split(" "))
        heapq.heappush(q,(a,b))
    
    while k>0:
        a,b = heapq.heappop(q)
        k-=b
    
    print(a)
main2()

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])
k_ = 0
for a_, b_ in ab:
    k_ += b_
    if k_ >= k:
        print(a_)
        exit()

Solution (Python):
import sys

readline = sys.stdin.readline
N, K = map(int, readline().split())
X = [0] * (10**5+1)
for _ in range(N):
    a, b = map(int, readline().split())
    X[a] += b
for i, x in enumerate(X):
    K -= x
    if K <= 0:
        print(i)
        break

Solution (Python):
n,k=map(int,input().split())
l=sorted([list(map(int,input().split())) for i in range(n)])
now=0
for key,v in l:
    if v+now>=k:print(key);exit()
    now+=v

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

for j in list_ab:
    if b_sum < k:
        b_sum += j[1]
        cnt += 1
    else:
        break

print(list_ab[cnt-1][0])

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

for a,b in li:
  k -= b
  if k <= 0:
    print(a)
    break

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

for a,b in li:
  k -= b
  if k <= 0:
    print(a)
    break

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

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

Solution (Python):
N, K = 3, 4
ARR = [
    [1, 1],
    [2, 2],
    [3, 3],
]















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

def calculate(n, k, arr):
    dict = {}
    for ar in arr:
        if dict.get(int(ar[0])) == None:
            dict.__setitem__(int(ar[0]), int(ar[1]))
        else:
            dict.__setitem__(int(ar[0]), dict.__getitem__(ar[0]) + ar[1])

    kkk = 0
    for key in sorted(dict.keys()):
        kkk = kkk + dict.get(key)
        if kkk >= k:
            print(key)
            break


calculate(N, K, ARR)

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

A = []

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

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


f = k
i = 0
while f > 0:
    f -= A[i][1]
    i += 1

print(A[i-1][0])

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

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

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

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

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

Solution (Python):
N,K =  list(map(int,input().split()))
listA = []
for i in range(N):
    listA.append(list(map(int,input().split())))
now = 0
listA.sort()
for i in range(N):
    if now <= K <= now+listA[i][1]:
        print(listA[i][0])
        exit()
    else:
        now += listA[i][1]

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


res=K
for i,l in enumerate(L):
    if l>0:
        res-=l
        if res<=0:
            print(i)
            break

Solution (Python):
import numpy as np
n,k = map(int,input().split())
ls_2dim = [0] * n
for i in range(n):
    a,b = map(int,input().split())
    ls_2dim[i] = [a,b]
ls_2dim.sort(key=lambda x: x[0])
count = 0
i = 0
while True:
    a,b = ls_2dim[i]
    count += b
    if count >= k:
        ans = a
        break
    i += 1
print(ans)

Solution (Python):
import numpy as np
n,k = map(int,input().split())
item_count = {}
for i in range(n):
    a,b = map(int,input().split())
    if a not in item_count:
        item_count[a] = 0
    item_count[a] += b
sorted_ls = sorted(item_count.items(), key = lambda x:x[0])
nums_ls = list(item_count.keys())
nums_ls.sort()
count_ls = [item[1] for item in sorted_ls]
csum_count = list(np.cumsum(count_ls))

def isOK(index, key, l):
    if l[index] >= key:
        return True
    else:
        return False
def meguru_search(l, key):
    left = -1
    right = len(l)
    while (right - left) > 1:
        mid = left + (right - left) // 2
        
            
                
            
        if isOK(mid, key, l):
            right = mid
        else:
            left = mid
    
    return right

ind = meguru_search(csum_count, k)
ans = nums_ls[ind]
print(ans)

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

counter = 0
for i in range(10**10):
    if counter >= K:
        print(i-1)
        break
    counter += data[i]

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

Solution (Python):
def resolve():
    N, K = list(map(int, input().split()))
    AB = sorted([list(map(int, input().split())) for i in range(N)], key=lambda x: x[0])
    length = 0
    idx = 0
    val = None
    while True:
        if length >= K:
            break
        length += AB[idx][1]
        val = AB[idx][0]
        idx += 1
    print(val)
    

if '__main__' == __name__:
    resolve()

Solution (Python):
N, K = map(int, input().split())
li=[0]*100001

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

tmp=0
for i in range(100001):
    tmp += li[i]
    if tmp >= K:
        print(i)
        break

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

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


times=0

index=0

while True:
    hoge = times+S[index][1]
    if hoge < K:
        times += S[index][1]
    else:
        re =S[index][0]
        break
    index += 1

print(re)

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

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


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


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

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

Solution (Python):
class Node():
	def __init__(self, v, w):
		self._v = v
		self._w = w
	def v(self):
		return self._v
	def w(self):
		return self._w
def resolve():
	n, k = map(int, input().split())
	arr = []
	for i in range(n):
		a, b = map(int, input().split())
		arr.append(Node(a, b))
	arr.sort(key=lambda x: x.v())
	for v in arr:
		if v.w() >= k:
			print(v.v())
			break
		k -= v.w()
resolve()

Solution (Python):
from operator import itemgetter
n, k = map(int, input().split())
ab = []
A = 0
B = 1
for i in range(n):
    ab.append(list(map(int, input().split())))

ab.sort(key=itemgetter(0))
cnt = 0
ans = 0

for i in range(n):
    cnt += ab[i][B]
    if k <= cnt:
        ans = ab[i][A]
        break

print(ans)

Solution (Python):

n,k=map(int,input().split())
cnt=[0]*100001

for i in range(n):
    ai,bi=map(int,input().split())
    cnt[ai]+=bi
    
for ans in range(1,len(cnt)):
    if cnt[ans]>=k:
        print(ans)
        break
    k-=cnt[ans]

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

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

total = 0
for i in range(n):
    if total + ab_sorted[i][1] >= k:
        print(ab_sorted[i][0])
        exit()
    else:
        total += ab_sorted[i][1]

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

def main():
    N, K = map(int, readline().rstrip().split())
    d = {}
    for _ in range(N):
        a, b = map(int, readline().rstrip().split())
        d.setdefault(a, 0)
        d[a] += b
    
    keys, vals = d.keys(), d.values()
    z = zip(keys, vals)
    z = sorted(z)
    keys, vals = zip(*z)
    s = 0
    for k, v in zip(keys, vals):
        if s + v < K:
            s += v
        else:
            ans = k
            break
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict

N, K = map(int, input().split())
sum = 0
array = defaultdict(int)
for i in range(N):
    a, b = map(int, input().split())
    array[a]+= b

array = sorted(array.items(), key = lambda x: x[0])
for i in range(10 ** 5 + 1):
    sum += array[i][1]
    if sum >= K:
        print(array[i][0])
        exit()

Solution (Python):

from collections import defaultdict
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(), key=lambda x:x[0])
s = 0
for i in range(len(d)):
  s += d[i][1]
  if K <= s:
    print(d[i][0])
    exit()

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

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

ans.sort()

for l in ans:
    x += l[1]
    if x < k:
        continue
    else:
        print(l[0])
        exit()

Solution (Python):
from collections import defaultdict
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(), key=lambda x:x[0])
s = 0
for i in range(len(d)):
  s += d[i][1]
  if K <= s:
    print(d[i][0])
    exit()

Solution (Python):
from collections import defaultdict
N, K = map(int,input().split())
d = defaultdict(int)
for _ in range(N):
    a, b = map(int,input().split())
    d[a] += b
cnt = 0
for i in range(1,10**5+1):
    cnt += d[i]
    if cnt >= K:
        print(i)
        break

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

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

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

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

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

Solution (Python):
n,k = map(int,input().split())
l = sorted(list(list(map(int,input().split())) for _ in range(n)))
for a,b in l:
  k -= b
  if k<=0:
    print(a)
    break

Solution (Python):
n,k=map(int,input().split())
ab=[]
for _ in range(n):
    ab.append(list(map(int,input().split())))
ab.sort(key=lambda x:x[0])
i=0
j=0
ans=0
while j<k:
    j+=ab[i][1]
    ans=ab[i][0]
    i+=1
print(ans)

Solution (Python):
n, m = map(int, input().split())
l = [0]*(10**5+10)

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

sum = 0
for i in range(len(l)):
    sum += l[i]
    if sum >= m:
        print(i)
        break

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

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

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

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

Solution (Python):
from collections import defaultdict
n,k=map(int,input().split())
ab=[input() for i in range(n)]
d = defaultdict(list)
[d[int(i.split()[0])].append(int(i.split()[1])) for i in ab]
sd=sorted(d.items(), key=lambda x:x[0])
c=0
for i,l in sd:
  c+=sum(l)
  if c>=k:
    print(i)
    exit()

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

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


li.sort()
for i in range(n):
    a,b = li[i]
    
    if k > b:
        k -= b
    else:
        print(a)
        exit()

Solution (Python):
def slove(ab_list, k):
    num_list = []
    count = 0
    for a, b in sorted(ab_list, key=lambda x: x[0]):
        count += b
        if count >= k:
            break

    return a

if __name__ == "__main__":
    n, k = [int(i) for i in input().split()]
    ab_list = [[int(i)for i in input().split()] for i in range(n)]
    print(slove(ab_list, k))

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

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

cnt = [[k, v] for k, v in cnt.items()]
cnt.sort()

s = 0
ans = 0
for k, v in cnt:
    s += v
    if s < K:
        continue
    else:
        ans = k
        break

print(ans)

Solution (Python):
n, k = map(int, input().split())
list_score = [ list(map(int,input().split(" "))) for i in range(n)]
list_score.sort(key=lambda x:x[0])
cnt = 0
ans = -1
for i in range(n):
    cnt += list_score[i][1]
    if cnt >= k:
        ans = list_score[i][0]
        break

print(ans)

Solution (Python):

n,m=map(int,input().split())
a =[list(map(int,input().split())) for i in range(n)]
a.sort()
import sys


cnt=0
for i in range(n):
    z=cnt+a[i][1]
    if z>=m:
        print(a[i][0])
        sys.exit()
    else:
        cnt=z

Solution (Python):
N,K=map(int,input().split())
A=[0]*1000000
for i in range(N):
  a,b=map(int,input().split())
  A[a-1]+=b
s=0
for i in range(100000):
  if A[i]==0: continue
  if s+A[i]<K:
    s+=A[i]
  else:
    print(i+1)
    exit()

Solution (Python):
n,k = map(int,input().split())
a = []
b = []
for i in range(n):
    x,y = map(int,input().split())
    a.append(x)
    b.append(y)
cnt = {}
for i in range(n):
    cnt[a[i]] = 0
for i in range(n):
    cnt[a[i]] += b[i]
res = 0
for i in range(10**6):
    if i not in cnt:continue
    if res +cnt[i] >=k:
        ans = i
        break
    res += cnt[i]
print(ans)

Solution (Python):
"""
解説を読んでから、バケットソートで書き直した。
単純にリストのリストをソートすると、O(NlogN)かかる。
Nの最大値N_max個のバケットを用意してからバケットソートすると、O(N_max+A_max)になる。
A_max<=N_maxだから、要するにO(N_max)になる。
"""
N_max = 10**5+1

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

bucket_list = [0 for i in range(N_max)]
for i in range(N):
    a, b = map(int, input().split())
    bucket_list[a] += b
 
counter = 0
answer = None
for i in range(1, N_max):
    counter += bucket_list[i]
    if counter >= K:
        answer = i
        break
 
print(answer)

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

counter = 0
answer = None
for a_b_list in a_b_list_list:
    counter += a_b_list[1]
    if counter >= K:
        answer = a_b_list[0]
        break

print(answer)

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

nums = {}

for i in range(N):
  num, count = list(map(int, input().split()))
  if num in nums:
    nums[num] += count
  else:
    nums[num] = count

nums = sorted(nums.items(), key=lambda x:x[0])
count = 0
for num in nums:
  count += num[1]
  if K <= count:
    print(num[0])
    break

Solution (Python):
n, k = map(int, input().split())
s = {}
for i in range(n):
    a, b = map(int, input().split())
    s[a] = s.get(a,0)+b
s = sorted(s.items(), key=lambda x:x[0])
for i in range(len(s)):
    k -=s[i][1]
    if k<=0:
        print(s[i][0])
        break

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

Solution (Python):
import sys

n, k, *ab = map(int, sys.stdin.read().split())

def main():
  cnt = 0
  for a, b in sorted(zip(*[iter(ab)] * 2)):
    cnt += b
    if cnt >= k:
      print(a)
      return

if __name__ == '__main__':
  main()

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

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

ans = key_l[-1]
i = 0
for key in key_l:
    i+=d[key]
    if i >= k:
        ans = key
        break
print(ans)

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

ab.sort()

ans = 0
j = k
for i in ab:
    ans = i[0]
    j -= i[1]
    if j<=0:
        break

print(ans)

Solution (Python):
n, k = map(int, input().split())
AB = sorted([list(map(int, input().split())) for _ in range(n)], 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())
input_lines = [[int(j) for j in input().split()]for i in range(n)]

input_dic = {}
for line in input_lines:
    input_dic[line[0]] = input_dic.get(line[0],0)+line[1]

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

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
cnt = 0
d_key = sorted(d)
for i in d_key:
  cnt += d[i]
  if cnt >= k:
    print(i)
    break

Solution (Python):
from collections import Counter
import sys


N, K = map(int, input().split())
C = Counter()
for s in sys.stdin.readlines():
    a, b = map(int, s.split())
    C[a] += b

keys = list(C.keys())
keys.sort()
cnt = 0
for k in keys:
    cnt += C[k]
    if cnt >= K:
        break
print(k)

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

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

Solution (Python):
class Number:
    def __init__(self,number,qty):
        self.qty=qty
        self.number=number

n,k=map(int,input().split())
listn=[]
for a in range(n):
    b,c=map(int,input().split())
    listn.append(Number(b,c))
listn.sort(key=lambda x:x.number)
count=k
for a in listn:
    if a.qty>=count:
        print(a.number)
        break
    else:
        count-=a.qty

Solution (Python):




def main():
    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:
            break

    print(a)


if __name__ == "__main__":
    main()

Solution (Python):
import numpy as np

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

b = a[np.argsort(a[:,0])]
c = np.cumsum(b[:,1])
d = np.min(np.where(k <= c))
ans = b[d, 0]
print(ans)

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

Solution (Python):
import sys
N, K = map(int,input().split())
hairetu = []
for _ in range(N): hairetu.append(list(map(int,input().split())))
hairetu.sort()
cnt = 0
for i in range(N):
  cnt += hairetu[i][1]
  if K <= cnt:
    print(hairetu[i][0])
    sys.exit()

Solution (Python):
N, K = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
from operator import itemgetter
ab.sort(key=itemgetter(0))
s = [0] * (N + 1)
for i in range(N):
    s[i + 1] = s[i] + ab[i][1]
    if s[i + 1] >= K:
        print(ab[i][0])
        break

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

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

ans = -1
temp = 0
i = 0
while True:
    if temp + abn[i][1] >= k:
        ans = abn[i][0]
        break
    temp += abn[i][1]
    i += 1
print(ans)

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

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

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

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

a=[]
for i in range(n):
    ai,bi=map(int,input().split())
    a.append([ai,bi])
    
a.sort()

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

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

Solution (Python):
import sys
input = sys.stdin.readline
n,k=map(int,input().split())
l=[0]*10**5
for i in range(n):
    a,b=map(int,input().split())
    l[a-1]+=b
m=0
for i in range(10**5):
    if m+l[i]>=k:print(i+1);break
    else: m+=l[i]

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

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

Solution (Python):
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, k = na()
ab = nan(n)
ab.sort()

ans = 0
cur = 0
for i in range(n):
    a, b = ab[i]
    cur += b
    if cur >= k:
        print(a)
        break

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

ins.sort(key=lambda x:x[0])
num=0
for i in range(N):
    num=num+ins[i][1]
    if num-ins[i][1]<K<=num:
        print(ins[i][0])
        break

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

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

total = 0
for i, n in enumerate(l):
    total += n
    if total>=K:
        print(i)
        break

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

num=[0]*(10**5+1)
for el in ab:
    num[el[0]]+=el[1]

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

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

accum=[0]
for i in range(len(ab)):
    accum.append(accum[i]+ab[i][1])

for i in range(len(ab)):
    
    if accum[i] < K <= accum[i+1]:
        print(ab[i][0])
        break

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

a.sort()
for i in range(n):
  k -= a[i][1]
  if k <= 0:
    print(a[i][0])
    break

Solution (Python):
n, k = map(int, input().split())
freq = dict()
for i in range(n):
  a, b = map(int, input().split())
  if freq.get(a): freq[a] += b
  else: freq[a] = b
f_asc = sorted(freq.items(), key=lambda x: x[0])
idx = 0
for kv in f_asc:
  idx += kv[1]
  if idx >= k:
    print(kv[0])
    break

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

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

Solution (Python):
n, k = map(int, input().split())
num =  [0] * 10**5
for i in range(n):
  a, b = map(int, input().split())
  num[a-1] += b
wa =  0
wa_b = 0
for i in range(len(num)):
  if num[i] == 0:
    pass
  else:
    wa += num[i]
    if wa_b < k and k <= wa:
      print(i+1)
      wa_b = wa
    else:
      wa_b = wa

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])
ans= 0
ab = sorted(ab, key=lambda x: x[0])

for i,j in ab:
    ans+=j
    if k<=ans:
        print(i)
        break