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

ab = [[int(i) for i in input().split()] for j in range(n)]

ab.sort()

tmp = 0

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

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

c = 0
ans = 0
ab_list = list()

for n in range(N):
    a,b =list(map(int,input().split()))
    ab_list.append([a,b])

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

for a,b in ab_list:
    c += b
    if c >= K:
        ans = a    
        break

print(ans)

Solution (Python):



N, K = list(map(int, input().split()))
ab_list = []

for _ in range(N):
    a, b = list(map(int, input().split()))
    ab_list.append((a, b))

ab_list = sorted(ab_list, key=lambda x: x[0])
c = 0
for a, b in ab_list:
    c += b
    if c >= K:
        ans = a
        break

print(ans)

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

b_dict = {}

for i in range(N):
    a, b = map(int,input().split())
    if a in b_dict:
        b_dict[a] += b
    else:
        b_dict[a] = b
        
a_list = list(b_dict.keys())
a_list.sort()


for a in a_list:
    K -= b_dict[a]
    if K <= 0:
        break

print(a)

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

Solution (Python):
N, K = map(int, input().split())
c = [0] * 100010
for _ in range(N):
    a, b = map(int, input().split())
    c[a] += b
s = 0
for i, v in enumerate(c):
    s += v
    if s >= K:
        print(i)
        exit()

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

Solution (Python):
import sys
import bisect
input = sys.stdin.readline
 
def main():
    n, k = map(int, input().split())
    x = sorted([list(map(int, input().split())) for _ in range(n)])
    cnt = 0
    for a, b in x:
        cnt += b
        if cnt >= k:
            print(a)
            exit()
    
main()

Solution (Python):
N,K=map(int,input().split())
A=[]
total=0
for i in range(N):
    C, B = map(int, input().split())
    A.append([C,B])

A.sort()

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

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

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

    i = 0
    while i < N and K > 0:
        a, b = A[i]
        K -= b
        i += 1
    return a

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

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

cnt = 0
idx = -1
while cnt < k:
    idx += 1
    cnt += info[idx][1]

print(info[idx][0])

Solution (Python):

import sys
input = sys.stdin.readline

from itertools import accumulate
from bisect import bisect_left as bs


def main():
    N, K = tuple(map(int, input().split()))
    A = tuple(tuple(map(int, input().split())) for _ in range(N))
    memo = [0] * (10 ** 5 + 1)  
    for a, b in A:
        memo[a] += b
    ans = bs(list(accumulate(memo)), K)
    print(ans)


if __name__ == "__main__":
    main()

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

Solution (Python):
"""
データの特徴と定義域に注目
- 全体のデータ数は10^10で計算時間がありえない
- データ特徴としては同じ値が連続（圧縮可能）
- データを圧縮した場合のデータ数は10^5になり、空間的に許容範囲、線形探査も時間的に許容範囲
- 「空間的にも」→全要素分の配列を準備してハッシュでソート(=インデックスの場所に格納すればソートされる)
"""
(n, k) = map(int, input().split())

num = [0 for _ in range(100000 + 1)]

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

count = 0
for i, j in enumerate(num):
    if count + j >= k:
        print(i)
        break
    else:
        count += j

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

def main():
    N,K = map(int, input().split())
    A = {}
    for _ in range(N):
        a,b = map(int, input().split())
        if a in A:
            A[a] += b
        else:
            A[a] = b
    A = sorted(A.items(), key=lambda x:x[0])

    for a,b in A:
        K -= b
        if K <= 0:
            print(a)
            break

if __name__ == '__main__':
    main()

Solution (Python):

import bisect
import collections
import itertools

def getint(): return int(input())
def getints(): return list(map(int, input().split()))
def getint2d(rows): return [getints() for _ in range(rows)]
def getgrid(rows): return [input() for _ in range(rows)]
def array1d(n, value): return [value for _ in range(n)]
def array2d(n, m, value): return [array1d(m, value) for _ in range(n)]

n,k=getints()
values=getint2d(n)

k -= 1

values = list(sorted(values))
now = -1

for a,b in values:
    now_s = now + 1
    now_e = now + b
    if now_s <= k <= now_e:
        print(a)
        break
    now += b

Solution (Python):
d=dict()
n, k=map(int,input().split())
for _ in range(n):
    a,b=map(int,input().split())
    if a in d:
        d[a]+=b
    else:
        d.setdefault(a,b)
c=list(d.items())
c.sort()
cum=0

for key,v in c:
    cum+=v
    if cum>=k:
        ans=key
        break

print(ans)

Solution (Python):

import math

if __name__ == '__main__':
    N, K = map(int, input().split())
    A, B = [], []
    for i in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)

    z = zip(A, B)
    z = sorted(z)

    A, B = zip(*z)

    val = 0
    for i in range(len(A)):
        val += B[i]
        if val >= K:
            print(A[i])
            exit()

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

for a, b in ab_list:
  if b >= K:
    print(a)
    exit()
  else:
    K -= b

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

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

cnt = 0
for idx,num in enumerate(numbers):
    cnt += num[1]
    if cnt >= K:
        print(numbers[idx][0])
        exit()

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

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

cnt = 0
for idx,num in enumerate(numbers):
    cnt += num[1]
    if cnt >= K:
        print(numbers[idx][0])
        exit()

Solution (Python):
l1=[]
ret=0
c=0
n,k=map(int,input().split())
for i in range(n):
  l1.append(input().split())
num=[0]*(10**5)

for j in range(n):
  num[int(l1[j][0])-1]+=int(l1[j][1])

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

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

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

keys = list(nums.keys())
keys.sort()

ans = 0
for key in keys:
    if K <= nums[key]:
        ans = key
        break
    else:
        K -= nums[key]

print(ans)

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

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

Solution (Python):

import sys
INF = float("inf")
from collections import Counter
import heapq


class MinHeap(object):
    def __init__(self, x):
        self.heap = [e for e in x]
        heapq.heapify(self.heap)

    def push(self, value):
        heapq.heappush(self.heap, value)

    def pop(self):
        return heapq.heappop(self.heap)


def solve(N: int, K: int, a: "List[int]", b: "List[int]"):
    mh = MinHeap([])
    counter = Counter()
    for aa, bb in zip(a, b):
        if aa not in counter:
            mh.push(aa)
        counter[aa] += bb
    
    

    while True:
        m = mh.pop()
        if counter[m] >= K:
            break
        else:
            K -= counter[m]
    print(m)
    return


def main():

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


if __name__ == '__main__':
    main()

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

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

Solution (Python):
from heapq import heappop,heappush
N,K = map(int,input().split())
A = []
for i in range(N):
    a = list(map(int,input().split()))
    heappush(A,a)
count = 0
while count < K:
    x,y = heappop(A)
    count += y
print(x)

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

ab = [[0, 0] for _ in range(n)]

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

ab.sort()
s = 0
i = 0
while s< k:
  s += ab[i][1]
  ans = ab[i][0]
  i += 1
print(ans)

Solution (Python):
N, K = map(int, input().split())
lis = []
for i in range(N):
    a, b = map(int, input().split())
    lis.append([a,b])
lis = sorted(lis)
cnt = 0
for x, y in lis:
    if cnt <= K <= cnt + y: 
        print(x)
        break
    else:
        cnt += y

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:
        print(a)
        exit()

Solution (Python):
N, K = map(int, input().split())
indexes = [0]*100001
for i in range(N):
    a, b = map(int, input().split())
    indexes[a] += b
i = 0
c = 0
while K > c:
    c += indexes[i]
    i += 1
print(i-1)

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

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

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

now = 0
ans = 0
for i, c in enumerate(count):
    now += c
    if now >= K:
        ans = i
        break

print(ans)

Solution (Python):

import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
import itertools
import random
 




 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N,K = inputMap()
    ab = []
    
    for _ in range(N):
        a,b = inputMap()
        ab.append((a,b))
        
    ab.sort()
    tmp = K
    
    for i, val in enumerate(ab):
        a,b = val
        tmp -= b
        if tmp <= 0:
            print(a)
            sys.exit()
    
if __name__ == "__main__":
	main()

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

ab.sort(key=lambda x:x[0])
i = 0
count = 0
while count < k:
    p = ab[i][0]
    count += ab[i][1]
    i += 1
print(p)

Solution (Python):
N, K = [int(v) for v in input().split()]
bins = [0] * (10 ** 5 + 1)
for _ in range(N):
    a, b = [int(v) for v in input().split()]
    bins[a] += b
cnt = 0
for i in range(1, len(bins)):
    cnt += bins[i]
    if cnt >= K:
        print(i)
        exit()


print(-1)

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

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

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

ab.sort()
for i in range(N) :
    a, b = ab[i]
    if K > b :
        K -= b
    else :
        print(a)
        break

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

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

B=0

for a,b in AB:
  
  B+=b
  if B>=K :
    print(a)
    quit()

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])
cnt = 0

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

print(ans)

Solution (Python):
M=lambda:map(int,input().split())
n,k=M();r=[]
for _ in[0]*n:
  r.append(list(M()))
for x,y in sorted(r):
  k-=y
  if k<1:
    print(x)
    exit()

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

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

l.sort()
count = 0
tmp = 0

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

print(ans)

Solution (Python):


import sys
input = sys.stdin.readline


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

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

    l.sort()

    count = 0
    for index in range(n):
        count += l[index][1]

        if count >= k:
            break

    print(l[index][0])


if __name__ == '__main__':
    main()

Solution (Python):
N, K = [int(x) for x in input().split()]
AB = [None]*N
for i in range(N):
    a, b = [int(x) for x in input().split()]
    AB[i] = (a, b) 
AB.sort()

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

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

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

Solution (Python):
N, K = [int(x) for x in input().split()]

A = [[0]*2 for i in range(N)]



for i in range(N):
	A[i] = [int(x) for x in input().split()]

A.sort()

counter = 0
for i in range(N):
	counter += A[i][1]
	if counter >= K:
		break

print(A[i][0])

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

li = []

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

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

Solution (Python):

import sys
N, K = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
now = 0
ab.sort()
for a, b in ab:
    now += b
    if now >= K:
            print(a)
            sys.exit()

Solution (Python):
import sys
n, k = map(int, input().split())
li = [list(map(int, input().split())) for _ in range(n)]
tmp = {}
for l in li:
    if l[0] in tmp:
        tmp[l[0]] += l[1]
    else:
        tmp[l[0]] = l[1]
sorted_tmp = sorted(tmp.items())
for s in sorted_tmp:
    if k > s[1]:
        k = k -s[1]
    else:
        print(s[0])
        sys.exit()

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

b = 0

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

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

Solution (Python):
N, K = map(int, input().split())
opes = []
for _ in range(N):
  opes.append(tuple(map(int, input().split())))
opes.sort(key=lambda x:x[0])
sum_ope = 0
for ope in opes:
  sum_ope += ope[1]
  if sum_ope >= K:
    print(ope[0])
    break

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

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

while tmp<k:
  tmp+=ab[i][1]
  hoge=ab[i][0]
  i+=1

print(hoge)

Solution (Python):
from operator import itemgetter

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

AB.sort(key=itemgetter(0))

re = K
for a, b in AB:
    if re <= b:
        print(a)
        break
    re -= b

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

Solution (Python):
import sys

n, k = (int(x) for x in sys.stdin.readline().split())
a_b_list = [[int(x) for x in sys.stdin.readline().split()] for y in range(n)]
a_b_list.sort(key=lambda x: x[0])
total_index = 0
for i in a_b_list:
    total_index += i[1]
for i in reversed(a_b_list):
    start = total_index
    end = total_index - i[1] + 1
    if start >= k >= end:
        print(i[0])
        sys.exit(0)
    total_index -= i[1]

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


counter = 0

while(k > 0):
    k -= ans[counter]
    counter += 1

print(counter)

Solution (Python):
a, b = map(int, input().split())
c = []
for i in range(a):
    d, e = map(int, input().split())
    c.append([d, e])
c.sort()
d = 0
for i in range(len(c)):
    d += c[i][1]
    if d >= b:
        print(c[i][0])
        exit()

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

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

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

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

s=0
i=0
while s<k:
    s += m[i][1]
    i += 1
print(m[i-1][0])

Solution (Python):
N, K = map(int, input().split())
ab = [() for i in range(N)]
for i in range(N):
    ab[i] = tuple(map(int, input().split()))
    
ab.sort()
prev_ind = 0
cur_ind = 0
for (a, b) in ab:
    cur_ind = cur_ind + b
    if prev_ind < K and K <= cur_ind:
        print(a)
        break
    prev_ind = cur_ind

Solution (Python):
n, k = map(int, input().split())
ab = {}
for i in range(n):
    a, b = map(int, input().split())
    try:
        ab[a] += b
    except:
        ab[a] = b
count = 0
ans = 0
for key in sorted(ab.keys()):
    count += ab[key]
    if count >= k:
        ans = key
        break
print(ans)

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

for i in range(n):
    a,b=map(int,input().split())
    S.append((a,b))
    
S.sort()

for tup in S:
    k-=tup[1]
    if k<=0:
        print(tup[0])
        break

Solution (Python):
from heapq import heappop,heappush

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

que=[]
for key,val in res.items():
    heappush(que,(key,val))

while k:
    key,val=heappop(que)
    if val>=k:
        print(key)
        exit()
    k-=val

Solution (Python):


import math


tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

n=hoge[0]
k=hoge[1]

a=[]
b=[]
total=0
for i in range(0,n):
	tmp = input().split()
	hoge = list(map(lambda a: int(a), tmp))
	a.append(hoge[0])
	b.append(hoge[1])
	total+=hoge[1]

c=[]
for i in range(0,n):
	c.append((a[i],b[i]))
c.sort()




thr=0
for i in range(0,n):
	thr+=c[i][1]
	if(thr>=k):
		print(c[i][0])
		break

Solution (Python):
def main():
    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(10 ** 5 + 1):
        if K <= ans[i]:
            print(i)
            exit()
        else:
            K -= ans[i]
    
main()

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

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

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    a, b, c = LI()
    if a <= c <= b:
        print("Yes")
        return
    print("No")
    return


def B():
    n, m = LI()
    e = defaultdict(int)
    for i in range(1, n + 1): e[i] = 0
    for i in range(m):
        a, b = LI()
        e[a] += 1
        e[b] += 1
    for i in e.values():
        print(i)
    return


def C():
    n, k = LI()
    d = defaultdict(int)
    for i in range(1, 10**5+1): d[i] = 0
    for i in range(n):
        a, b = LI()
        d[a] += b
    for key, valus in d.items():
        k -= valus
        if k <= 0:
            print(key)
            return
    return


def D():
    return


if __name__ == '__main__':
    C()

Solution (Python):
def main():
    N, K = map(int, input().split())
    C = [0] * 100001
    for _ in range(N):
        a, b = map(int, input().split())
        C[a] += b
    for i, c in enumerate(C):
        K -= c
        if 0 >= K:
            print(i)
            break


main()

Solution (Python):
import sys

def solve(N, K, ab):
    ab.sort(key=lambda x: x[0])

    s = 0
    for x in ab:
        s += x[1]
        if s >= K:
            print(x[0])
            return


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

if __name__ == "__main__":
    main()

Solution (Python):
import math
import itertools

INF = 10**9+7

n,k = map(int,input().split())
ab = {}
for i in range(1,int(10e5+1)):
	ab[i] = 0
for i in range(n):
	a,b = map(int,input().split())
	ab[a] += b

def solve():
	global n,k,ab
	for ky,v in ab.items():
		if(v<k): k -= v
		else: return ky

def sgn(n):
	if(n>0): return 1
	if(n<0): return -1
	return 0

print(solve())

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

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

Solution (Python):
from subprocess import*
with open('Main.java','w')as f:f.write(r"""
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		long k = Long.parseLong(sc.next());
		Map<Integer, Long> m = new TreeMap<>();
		for (int i = 0; i < n; i++) {
			int a = Integer.parseInt(sc.next());
			long b = Integer.parseInt(sc.next());
			if (m.get(a) != null) {
				b += m.get(a);
			}
			m.put(a, b);
		}
		long c = 0;
		for (Integer i:m.keySet()) {
			c += m.get(i);
			if (c >= k) {
				System.out.println(i);
				return;
			}
		}
	}
}
""")
call(('javac','Main.java'))
call(('java','Main'))

Solution (Python):
from subprocess import*
with open('Main.java','w')as f:f.write(r"""
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		long k = Long.parseLong(sc.next());
		Map<Integer, Long> m = new TreeMap<>();
		for (int i = 0; i < n; i++) {
			int a = Integer.parseInt(sc.next());
			long b = Integer.parseInt(sc.next());
			if (m.get(a) != null) {
				b += m.get(a);
			}
			m.put(a, b);
		}
		long c = 0;
		for (Integer i:m.keySet()) {
			c += m.get(i);
			if (c >= k) {
				System.out.println(i);
				return;
			}
		}
	}
}
""")
call(('javac','Main.java'))
call(('java','Main'))

Solution (Python):
N, M = map(int, input().split(' '))
A = []
for i in range(N):
    a, b = map(int, input().split(' '))
    A.append([a, b])
A.sort()
i = -1
count=0
while(True):
    i += 1
    count += A[i][1]
    if count >= M:
        print(A[i][0])
        break

Solution (Python):



from operator import itemgetter

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

x = sorted(ab,key = itemgetter(0))
s = 0
for i,j in x:
    if s < k <= s+j:
        print(i)
        break
    s += j

Solution (Python):

from operator import itemgetter

n, k = map(int, input().split())
temp_array = []
addlist = temp_array.append
for i in range(n):
    addlist(list(map(int, input().split())))
temp_array.sort(key=itemgetter(0))
o = 0
for i in temp_array:
    o += i[1]
    if o >= k:
        print(i[0])
        exit()

Solution (Python):
from collections import defaultdict

def main():
    num, k = map(int, input().split())
    data = defaultdict(int)
    for i in range(num):
        a, b = map(int, input().split())
        data[a] += b

    data = sorted(data.items(), key=lambda x: x[0])
    for aaa, count in data:
        k -= count
        if k <= 0:
            print(aaa)
            break

if __name__ == '__main__':
    main()

Solution (Python):
N, K = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(N)]
ab.sort()
b_sum = 0
for i in range(N):
    b_sum += ab[i][1]
    if K <= b_sum:
        print(ab[i][0])
        break

Solution (Python):
N,M=map(int,input().split())
inp=sorted([list(map(int,input().split())) for _ in range(N)],key=lambda x:x[0])
for i,j in inp:
    if M>j:
        M-=j
    else:
        print(i)
        break

Solution (Python):


def main(N,K,A):
    A = sorted(A, key=lambda x:x[0])
    tmp = A[0][0]
    for a, b in A:
        tmp = a
        if(0<K-b):
            K -= b
        else:
            print(tmp)
            break
    
if __name__ == '__main__':
    N, K = map(int, input().split())
    A = [[int(i) for i in input().split()] for i in range(N)]
    main(N,K,A)

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

Solution (Python):

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

now = 0
dic = {}
lis = []

for i in range(N):

    a,b = map(int,input().split())

    if a in dic:
        dic[a] += b
    else:
        dic[a] = b
        lis.append(a)

lis.sort()

for i in lis:

    now += dic[i]

    if now >= K:
        print (i)
        break

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

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

count=[0]*(10**5+1)
for i in range(n):
    count[ab[i][0]]+=ab[i][1]

tmp=0
for i in range(len(count)):
    tmp+=count[i]
    if tmp>=k:
        print(i)
        quit()

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

Solution (Python):




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

abl.sort()

cnt = 0
idx = 0

while cnt < k:
    cnt += abl[idx][1]
    idx += 1

ans = abl[idx - 1][0]


print(ans)

Solution (Python):
N,K = map(int,input().split())
d = {}
for _ in range(N):
    a,b = map(int,input().split())
    d[a] = d.get(a,0) + b
f = 0
for c in sorted(d.keys()):
    f += d[c]
    if f >= K:
        print(c)
        break

Solution (Python):

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

list_ab = []

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

list_ab.sort()

sum_b = 0

for a, b in list_ab:
    
    sum_b += b
    
    if sum_b >= K:
        
        print(a)
        break