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, raw_input().split())
a = [0]*N
b = [0]*N
c = [0]*N
for i in range(N):
  a[i], b[i] = map(int, raw_input().split())
  c[i] = i
c.sort(key=lambda i:a[i])
s = 0
for j in range(N):
  s += b[c[j]]
  if s>=K:
    print a[c[j]]
    break

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

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

Solution (Python):
import itertools

res = [0]*10**5

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

sum = list(itertools.accumulate(res))
for i,j in enumerate(sum):
    if j>=k:
        print(i+1)
        break

Solution (Python):
from collections import defaultdict
import sys
sdin = sys.stdin.readline

N, K = map(int, sdin().split())
AB = []
for _ in range(N):
    AB.append(tuple(map(int, sdin().split())))
    
    
dic = defaultdict(int)


for a,b in AB:
    dic[a] += b
    

key_list = list(dic.keys())
key_list.sort()


res = K
i = 0
while res > 0:
    res -= dic[key_list[i]]
    ans = key_list[i]
    i += 1
    
print(ans)

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

Solution (Python):
n, k = [int(_) for _ in input().split()]
dict = {}
for i in range(0, n):
    ai, bi = [int(_) for _ in input().split()]
    if ai in dict:
        dict[ai] += bi
    else:
        dict[ai] = bi

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

total = 0
for i in range(0, len(sorted_list)):
    total += sorted_list[i][1]
    if total >= k:
        print(sorted_list[i][0])
        break

Solution (Python):
n, k = list(map(int, input().split()))
n_map = {}
for _ in range(n):
    a, b = list(map(int, input().split()))
    if not a in n_map.keys():
        n_map[a] = b
    else:
        n_map[a] += b

num = 0
for n in sorted(n_map.keys()):
    num += n_map[n]
    if num >= k:
        print(n)
        break

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

ab.sort()

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

Solution (Python):
N, K = map(int, input().split())
ab = sorted(tuple(map(int, input().split())) for _ in range(N))
x = K
for a, b in ab:
    if b >= x:
        print(a)
        exit()
    else:
        x -= b

Solution (Python):


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

    cnt = 0

    for ab in ab_list:
        cnt += ab[1]
        if cnt >= k:
            print(ab[0])
            break
    
if __name__ == '__main__':
    main()

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

count = 0
for ab_num, ab_count in sorted(ab):
	count += ab_count
	if k <= count:
		print(ab_num)
		exit()

Solution (Python):
a,b=map(int,input().split())
l=sorted(tuple(map(int,input().split())) for _ in range(a))
s=0
for i in l:
  s+=i[1]
  if s>=b:
    print(i[0])
    break

Solution (Python):
def inpl(): return input().split()
n, k = map(int, inpl())
M = list(list(map(int, inpl())) for _ in range(n))
M = sorted(M, key=lambda x:x[0])
for i in range(n):
    a, b = M[i]
    if k <= b:
        print(a)
        exit()
    else:
        k -= b

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

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

sum=0
ans=0
for i in a:
    if sum <K:
        ans = i[0]
        sum+=i[1]
    else:
        break
print(ans)

Solution (Python):
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

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

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

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

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

m_list = []

for i in range(n):
  m_tuple = tuple(map(int, input().split()))
  m_list.append(m_tuple)

num = m_list[0][0]

m_list.sort(key=lambda tup:tup[0])

for a, b in m_list:
  if b >= k:
    num = a
    break
  else:
    k -= b

print(num)

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

Solution (Python):


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

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


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

cnt = K
for n in N_sorted:
    cnt -= n[1]
    if cnt <= 0:
        print(n[0])
        exit()

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

arr_num, arr_times = [], []

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

s_num, s_times = [], []
s_idx = sorted(range(N), key = lambda k : arr_num[k])


for i in s_idx :
    s_num.append(arr_num[i])
    s_times.append(arr_times[i])

cur_idx = 0

for i in range(N) :
    if cur_idx <= K :
        cur_idx += s_times[i]
        
    if cur_idx >= K :
        print(s_num[i])
        break

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

ans=[]

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

ans.sort()

s=0
i=0

while s<k:
    s+=ans[i][1]
    i+=1

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

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

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

Solution (Python):
N,K=map(int,input().split())
grid = []
for i in range(N):
    array = list(map(int, input().strip().split(' ')))
    grid.append(array)
dic = {}
for lis in grid:
  if lis[0] in dic:
    dic[lis[0]] += lis[1]
  else:
    dic[lis[0]] = lis[1]
dic = sorted(dic.items())
num = 0
for li in dic:
  num += li[1]
  if num >= K:
    print(li[0])
    break

Solution (Python):
from collections import defaultdict
N,K = list(map(int,input().split()))
ab= [list(map(int, input().split())) for i in range(N)]
count=defaultdict(int)
for a,b in ab:
    count[a]+=b
lst=sorted(count.items(), key=lambda x:x[0])
idx=0
for val,cnt in lst:
    idx+=cnt
    if idx >=K:
        break
print(val)

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

Solution (Python):

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

A = sorted(A)

count = 0

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

Solution (Python):
N, K = map(int, input().split(' '))
tmp = [list(map(int, input().split(' '))) for _ in range(N)]
tmp.sort()
cumB = []
for i in range(N):
    if i == 0:
        cumB.append(tmp[0][1])
    else:
        cumB.append(cumB[i-1]+tmp[i][1])

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

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

Solution (Python):
from collections import Counter

N, K = map(int, input().split())
input_list = [[int(i) for i in input().split()] for j in range(N)]
input_list.sort()

for element in input_list:
    K -= element[1]
    if K <= 0:
        print(element[0])
        break

Solution (Python):
from collections import Counter

N, K = map(int, input().split())
input_list = [[int(i) for i in input().split()] for j in range(N)]
input_list.sort()

input_counter = Counter()

for element in input_list:
    input_counter[element[0]] += element[1]

for element in input_list:
    K -= element[1]
    if K <= 0:
        print(element[0])
        break

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

arr = [0 for i in range(100001)]

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

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

print i

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

AB.sort()

result = 0
for a,b in AB:
    K -= b
    result = a
    if K <= 0:
        break

print(result)

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

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

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

Solution (Python):
from bisect import bisect_left,bisect_right
N,K=map(int,input().split())
table=[]
for i in range(N):
    a,b=map(int,input().split())
    table.append([a,b])
table.sort()
cou=[0]*N
cou[0]=table[0][1]
for i in range(1,N):
    cou[i]=cou[i-1]+table[i][1]
s = bisect_left(cou,K)
print(table[s][0])

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

tmp = 0
for k,v in sorted(ctr.items()):
    tmp += v
    if tmp >= K:
        print(k)
        exit()

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

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

b=[]
c=0
for i,j in a:
    k-=j
    c=i
    if k<=0: break
print(c)

Solution (Python):
def m():
    n, k = map(int, input().split())
    d = dict()
    for i in range(n):
        a, b = map(int, input().split())
        if d.get(a, 0) == 0:
            d[a] = b
        else:
            d[a] +=b
    keys = list(d.keys())
    keys.sort()
    for key in keys:
        k -= d[key]
        if k <= 0:
            return key
print(m())

Solution (Python):
from collections import defaultdict
n, k = map(int, input().split())
dic = defaultdict(int)
for i in range(n):
    a, b = map(int, input().split())
    dic[a] += b

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

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

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 x:x[0])

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

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

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

bucket = [0]*(10**5+1)
for i in range(n):
    a, b = map(int,input().split())
    bucket[a] += b
lst = list(itertools.accumulate(bucket))
print(bisect.bisect_left(lst, k))

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

Solution (Python):

from itertools import accumulate
from bisect import bisect, bisect_left
def inpl(): return map(int, input().split())
N, K  = inpl()

bucket = [0]*(10**5 + 1)
for _ in range(N):
    a, b = inpl()
    bucket[a] += b

S = list(accumulate(bucket))
print(bisect_left(S, K))

Solution (Python):
n,k=map(int,input().split());i=0;a=sorted(list(map(int,input().split()))for _ in[0]*n)
while k>0:k-=a[i][1];i+=1
print(a[~-i][0])

Solution (Python):
n,k=map(int,input().split());i=0
a=sorted(list(map(int,input().split()))for _ in[0]*n)
while k>0:k-=a[i][1];i+=1
print(a[~-i][0])

Solution (Python):
a=[];n,k=map(int,input().split())
for _ in[0]*n:a+=[list(map(int,input().split()))]
a.sort();i=0
while k>0:k-=a[i][1];i+=1
print(a[~-i][0])

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

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

for _ in range(n):
	ab = list(map(int, input().split()))
	if ab[0] not in d:
		d[ab[0]] = ab[1]
	else:
		d[ab[0]] += ab[1]

di = sorted(d)
s = 0

for key in di:
	s += d[key]
	if s >= k:
		break

print(key)

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

print(ans)

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

for i in range(n):
    ab_lst.append(tuple((map(int, input().split()))))

ab_lst.sort(key=lambda tup: tup[0])

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

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

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

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

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

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

for i in range(len(nums)):
  total += nums[i]
  if total >= k:
    print(i+1)
    break

Solution (Python):
n,k = map(int,input().split())
t = [[0,0] for i in range(n)]
for i in range(n):
    a,b = map(int,input().split())
    t[i] = (a,b)
kk = 0
t = sorted(t, key=lambda t: t[0])

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

Solution (Python):
n,k=map(int,input().split())
t=[tuple(map(int,input().split()))for i in range(n)]
t=sorted(t,key=lambda t:t[0])
total=0
for i in range(n):
    total+=t[i][1]
    if k<=total:
        print(t[i][0])
        exit()

Solution (Python):





if __name__ == '__main__':
    n_max = 10 ** 5
    n, k = list(map(int, input().split()))
    a = [0 for _ in range(n_max + 1)]

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

    for j in range(n_max + 1):
        if a[j] >= k:
            print(j)
            exit()
        else:
            k -= a[j]

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

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

k = 1        
for a,b in sorted(array.items(),key=lambda x:x[0]):
    if k+b>K:
        print(a)
        break
    else:
        k += b

Solution (Python):
def judge(lst, k):
	sum = 0
	for i in range(0, len(lst)):
		sum = sum + lst[i][1]
		if sum >= k: return lst[i][0]
	return -1

N, K = map(int, raw_input().split())
inpt = []
for i in range(0, N):
	inpt.append(map(int, raw_input().split()))
inpt.sort(key = lambda x: x[0])
print judge(inpt, K)

Solution (Python):

line = input().split(" ")
n = int(line[0])
k = int(line[1])

l = []
for _ in range(n):
    line = input().split(" ")
    a = int(line[0])
    b = int(line[1])
    l.append([a,b])

l.sort()

while k>0:
    x = l.pop(0)
    k = k-x[1]

print(x[0])

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

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

Solution (Python):
n, k = map(int,input().split())
dcic = {}
aa = set([])
for i in range(n):
    a,b = map(int,input().split())
    aa.add(a)
    if a in dcic:
        dcic[a] = dcic[a] + b
    else:
        dcic.update({a:b})
        
bb = list(sorted(list(aa)))
cc = 0
s = 0
for i in range(len(bb)):
    if s < k:
        s = s + dcic[bb[i]]
        cc = bb[i]
    else:
        ccc = bb[i]
print(cc)

Solution (Python):
import math
import sys

def getinputdata():

    
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result

arr_data = getinputdata()


n = int(arr_data[0][0])


k = int(arr_data[0][1])

arr=[]

for i in range(1, 1 + n):
    
    arr.append(list(map(int, arr_data[i])))

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





mysum=0

for i in range(0,n):
 
    cnt = arr[i][1]
    j = arr[i][0]
 

    if k<=mysum+cnt:
        
        print(j)
        
        break
        
    else:
        
        
        mysum+=cnt

Solution (Python):
n,m=map(int,input().split())
t=sorted([list(map(int,input().split())) for i in range(n)])
s=0
for j in t:
    if s<m<=s+j[1]:
        print(j[0])
        break
    s=s+j[1]

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

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

for _ in range(n):
    a,b=map(int,input().split())
    if a in d:
        d[a]+=b
    else:
        d[a]=b
d=sorted(d.items() ,key=lambda x:x[0])

for kk,v in d:
    k-=v
    if k<=0:
        print(kk)
        exit()

Solution (Python):
d = dict()
for i in range(100000):
	d[i+1] = 0

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

sum = 0
i = 1
while sum < k:
	sum += d[i]
	i += 1
print(i-1)

Solution (Python):
def kth_smallest(a, k):
    accum = 0
    for elem in a:
        accum += elem[1]
        if accum >= k:
            return elem[0]


if __name__ == '__main__':
    n, k = map(int, input().split())
    a = [list(map(int, input().split())) for _ in range(n)]
    a.sort()
    print(kth_smallest(a, k))

Solution (Python):
def kth_smallest(a, k):
    accum = 0
    i = 0
    while accum < k:
        current = a[i][0]
        accum += a[i][1]
        i += 1
    return current


if __name__ == '__main__':
    n, k = map(int, input().split())
    a = [list(map(int, input().split())) for _ in range(n)]
    a.sort()
    print(kth_smallest(a, k))

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

Solution (Python):
n,k = map(int,input().split())
t = [[0,0] for i in range(n)]
for i in range(n):
    a,b = map(int,input().split())
    t[i] = (a,b)
kk = 0
t = sorted(t, key=lambda t: t[0])

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

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

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

Solution (Python):
import pprint
from collections import defaultdict

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

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

R = 0
for n in range(1, 10 ** 5 + 1):
    if K <= bucket[n]:
        print(n)
        break
    K -= bucket[n]

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

Solution (Python):
import collections

n, k = map(int, input().split())
dict_ = dict()
for i in range(1, 100001):
    dict_[i] = 0
for j in range(n):
    a, b = map(int, input().split())
    dict_[a] += b

tmp = 0
for m, l in dict_.items():
    tmp += l
    if tmp >= k:
        print(m)
        break

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

Solution (Python):
from collections import defaultdict
n, k = map(int, input().split())
s = defaultdict(int)
for j in range(n):
    i, v = map(int, input().split())
    s[i] += v
f = sorted(s.items())
tmp = 0
for g in f:
    tmp += g[1]
    if tmp >= k:
        print(g[0])
        exit()

Solution (Python):
import numpy as np
N, K = map(int, input().split())
a = [0 for i in range(N)]
b = [0 for i in range(N)]
for i in range(N):
    a[i], b[i] = map(int, input().split())
S = 0
s = list(np.argsort(np.array(a)))
for i in range(N):
    if S<K<=S+b[s[i]]:
        print(a[s[i]])
        break
    S += b[s[i]]

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

Solution (Python):
N, K = map(int, input().split())
t = [[0,0] for i in range(N)]
for i in range(N):
    a,b = map(int, input().split())
    t[i] = (a, b)
_k = 0
t = sorted(t, key=lambda t: t[0])

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

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

dic = {}

for i in range(n):
    a,b = map(int,input().split())
    if a in dic.keys():
        dic[a] += b 
    else:
        dic[a] = b 
        
keys = list(dic.keys())
keys.sort()
for i in keys:
    k -= dic[i]
    if k <= 0:
        ans = i
        break

print(ans)

Solution (Python):
n,k=[int(i) for i in input().split()] 
a = [[int(j) for j in input().split()] for _ in range(n)]
a.sort()
x=0
i=0
while 1:
  if k <=0:
    break
  else:
  	k-=a[i][1]
  	i+=1
print(a[i-1][0])

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

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

Solution (Python):
n, k = map(int, input().split())
num = []
for i in range(n):
    num.append(list(map(int, input().split())))
num.sort()
summ = 0
for i in range(len(num)):
    if k <= summ + num[i][1]:
        print(num[i][0])
        exit()
    else:
        summ += num[i][1]

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

Solution (Python):

N,K = map(int,input().split(" "))
num = []

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

if num[0][1] >= K:
	print(num[0][0])
	exit(0)
for i in range(1,N):
	num[i][1] += num[i-1][1]
	if num[i][1] >= K:
		print(num[i][0])
		exit(0)

Solution (Python):
def c_BigArray(N, K, I):
    from collections import defaultdict
    from operator import itemgetter
    d = defaultdict(int)
    for a, b in I:
        d[a] += b
    d = sorted(d.items(), key=itemgetter(0))
    
    tmp = 0
    for k, v in d:
        tmp += v
        if tmp >= K:
            return k
    return None

N,K = [int(i) for i in input().split()]
I = [[int(i) for i in input().split()] for j in range(N)]
print(c_BigArray(N, K, I))

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

a, b = zip(
        *sorted(
            (tuple(map(int, input().split())) for i in range(n)), key=lambda x:x[0]))

rank = itertools.accumulate(b)

for i, r in enumerate(rank):
    if  k <= r:
        print(a[i])
        break

Solution (Python):
line_one = raw_input().split()
n = int(line_one[0])
k = int(line_one[1])

l = []

for i in range(n):
    line_one2 = raw_input().split()
    a1 = int(line_one2[0])
    b1 = int(line_one2[1])
    l.append( ( a1, b1 ))
    
    
    
    
    
    


l = sorted(l, key=lambda x: x[0])
count = 0
for item in l:
    count += item[1]
    if k <= count:
        print item[0]
        break

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

Solution (Python):
n, k = map(int, input().split())
nums = {}
temp = 0
for i in range(n):
  a, b = map(int, input().split())

  if a in nums:
    nums[a] += b
  else:
    nums[a] = b



for key, val in sorted(nums.items()):
  temp += val
  if k <= temp:
    print(key)
    break

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

Solution (Python):
import numpy as np

n, k = map(int, input().split())
z = np.zeros(10**5 + 1)
for i in range(n):
  a, b = map(int, input().split())
  z[a] += b

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

print(int(a))

Solution (Python):
import numpy as np

n, k = map(int, input().split())
z = np.zeros(10**5 + 1, dtype = np.int64)
for i in range(n):
  a, b = map(int, input().split())
  z[a] += b

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

print(a)

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

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

print(a)

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

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

AB.sort()
for ab in AB:
    K -= ab[1]
    if K <= 0:
        print(ab[0])
        exit()

Solution (Python):
def solve():
    n, k = list(map(int, input().split(" ")))
    A, B = [], []
    for _ in range(n):
        tmp_a, tmp_b = list(map(int, input().split(" ")))
        A.append(tmp_a)
        B.append(tmp_b)

    num = [0 for _ in range(10 ** 5 + 1)]
    for a, b in zip(A, B):
        num[a] += b

    summation = 0
    for i, ele in enumerate(num):
        summation += ele
        if summation >= k:
            print(i)
            break


solve()

Solution (Python):
inp = input().split(" ")
N = int(inp[0])
K = int(inp[1])

keys = list(range(1, 100001))
arr = {i:0 for i in keys}

for i in range(N):
	inp = input().split(" ")
	a = int(inp[0])
	b = int(inp[1])
	arr[a] += b

for i in keys:
	K -= arr[i]
	if K <= 0:
		print(i)
		break

Solution (Python):
nk = input().split(' ')
n = int(nk[0])
k = int(nk[1])

arr = []

for i in range(0, n):
	ab = input().split(' ')
	arr.append((int(ab[0]), int(ab[1])))

arr = sorted(arr)

pos = 0
while True:
	if k > arr[pos][1]:
		k -= arr[pos][1]
	else:
		print(arr[pos][0])
		break
	pos += 1

Solution (Python):
line_one = raw_input().split()
n = int(line_one[0])
k = int(line_one[1])

tuples = []
arr = []
for i in range(n):
    line = raw_input().split()
    tuples.append( (int(line[0]), int(line[1]))  )

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

total = 0
for tup in tuples:
    total += tup[1]
    if total >= k:
        print tup[0]
        break

Solution (Python):
x = raw_input().split(" ")
num_operations = int(x[0])
kth_integer = int(x[1])
field = {}
for p in range(0, num_operations):
 line = raw_input().split(" ")
 a = int(line[0])
 b = int(line[1])
 if a in field:
  field[a] += b
 else:
  field[a] = b
ks = field.keys()
ks.sort()
out = field.keys()[-1]
for k in ks:
 kth_integer -= field[k]
 if (kth_integer <= 0):
  out = k
  break
print (out)

Solution (Python):
def main():
    n, k = [int(x) for x in input().split(' ')]
    arr = [0] * 100001
    for _ in range(n):
        a, b = [int(x) for x in input().split(' ')]
        arr[a] += b
    foo = 0
    for i, e in enumerate(arr):
        foo += e
        if (foo >= k):
            print(i)
            break

main()

Solution (Python):
import heapq
N,K=map(int,raw_input().split())
c=[]
for i in range(N):
	heapq.heappush(c, tuple( map(int,raw_input().split()) ) )

cnt=0
for i in range(len(c)):
	val=heapq.heappop(c)
	cnt+=val[1]
	if K<=cnt:
		print val[0]
		break

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

for i in range(1, 10 ** 5 + 2):
    if K <= nums[i]:
        print(i)
        break
    K -= nums[i]

Solution (Python):

"""
http://abc061.contest.atcoder.jp/tasks/abc061_c

"""
import sys
from sys import stdin
from itertools import accumulate
from bisect import bisect_left
input = stdin.readline


def main(args):
    N, K = map(int, input().split())

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

    acc = list(accumulate(freq))
    i = bisect_left(acc, K)
    print(i)


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):

N, K = map(int, raw_input().split())    
ab = [map(int, raw_input().split()) for i in xrange(N)]
ab.sort()
for a, b in ab:
    if K <= b:
        print a
        break
    else:
        K -= b