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



Sample input:
3 4
1 1
2 2
3 3


Sample output:
3

Submission status: Accepted

Solution code:
N,K = map(int, input().split())
ab_list = []
for i in range(N):
    a = list(map(int, input().split()))
    ab_list.append(a)
    
ab_list.sort()
    
count =0
for i in ab_list:
    count+=i[1]
    if (count >= K):
        print(i[0])
        break

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
ls = []

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

ls.sort()
for a,b in ls:
    if b >= k:
        print(a)
        break
    else:
        k -= b

Submission status: Accepted

Solution code:
import sys
import numpy as np
import collections
n,k = [int(x) for x in sys.stdin.readline().split()]
r = collections.defaultdict(int)
for i in range(n):
	a, b = [int(x) for x in sys.stdin.readline().split()]
	r[a] += b
d = sorted(r.items())
c = 0
for i,j in enumerate(d):
	c += j[1]
	if c >= k:
		print(int(j[0]))
		break

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
import sys
N, K = map(int, input().split())
ans = []
for tmp in range(N):
    a, b = map(int, input().split())
    ans.append((a,b))
ans.sort()
s = 0
for tmp in range(len(ans)):
    s += (ans[tmp])[1]
    if s >= K:
        print((ans[tmp])[0])
        sys.exit()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = []
count = 0

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

Submission status: Accepted

Solution code:
import numpy as np

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

a = []
for i in range(N):
    a.append(list(map(int,input().split())))
a = sorted(a,key = lambda i:i[0])
sum = 0
b = 0
#print (a)
for i in range(N):
    sum += a[i][1]
    b = a[i][0]
    if sum >= K:
        break

print (b)

Submission status: Accepted

Solution code:
N,K=[int(i) for i in input().split()]
data=list()
for i in range(0,N):
    data.append([int(i) for i in input().split()])
newdata=sorted(data,key=lambda d:d[0])
count=0
for d in newdata:
    count+=d[1]
    if count>=K:
        print(d[0])
        break

Submission status: Accepted

Solution code:
nums = [int(x) for x in input().split()]
N = nums[0]
K = nums[1]
arr = []
for i in range(N):
	nums = [int(x) for x in input().split()]
	arr.append(tuple(nums))

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

vol = 0
for i in range(len(arr)):
	vol = vol + arr[i][1]
	if vol >= K:
		print(arr[i][0])
		break

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
import sys
N, K = map(int, input().split())
a, b, ans = ( [], [], [] )
for tmp in range(N):
    a, b = map(int, input().split())
    ans.append((a,b))
ans.sort()
s = 0
for tmp in range(len(ans)):
    s += (ans[tmp])[1]
    if s >= K:
        print((ans[tmp])[0])
        sys.exit()

Submission status: Accepted

Solution code:
# coding: utf-8
x={}
n,k=map(int,input().split())
for i in range(n):
    a,b=map(int,input().split())
    if a in x:
        x[a]+=b
    else:
        x[a]=b
x=sorted(x.items(),key=lambda x:x[0])
a=0
for i in x:
    a+=i[1]
    if(a>=k):
        print(i[0])
        break;

Submission status: Accepted

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

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

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

for i in range(1, 100001):
    a_b[i] += a_b[i-1]
    if a_b[i] >= k:
        print(i)
        break

Submission status: Accepted

Solution code:

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

a = [ [0]*2 ] * N
count = 0

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


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


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

Submission status: Accepted

Solution code:
from operator import itemgetter
N, K = [int(i) for i in input().split()]
ab = [[int(i) for i in input().split()] for j in range(N)]
ab = sorted(ab, key=itemgetter(0))
for row in ab:
    K -= row[1]
    if K <= 0:
        print(row[0])
        break

Submission status: Accepted

Solution code:
def C(_mid):
    tmp_sum = 0
    if len(ab) <= _mid:
        return False
    for i in range(0, _mid):
        tmp_sum += ab[i][1]
    if tmp_sum < K:
        return True
    else:
        return False


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

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

lb = 0
ub = 100000
while ub - lb > 1:
    # print(str(lb) + " " + str(ub))
    mid = int((lb + ub) / 2)
    if C(mid):
        lb = mid
    else:
        ub = mid

print(ab[lb][0])

Submission status: Accepted

Solution code:
N, K = map(int, raw_input().split())
array=[]
for i in range(N):
 l=map(int, raw_input().split())
 array.append(l)
array.sort()
num=0
for j in range(N):
 num=num+array[j][1]
 if K<=num:
  print array[j][0]
  break;

Submission status: Accepted

Solution code:
#coding:utf-8

from collections import defaultdict

if __name__ == "__main__":
    N, K = map(int, input().split(" "))

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

    count = 0
    for key in sorted(num.keys()):
        count += num[key]

        if count >= K:
            print (key)
            break

Submission status: Accepted

Solution code:
#!/usr/bin/env python

N,K=map(int,raw_input().split())
arr=[[0,0]]*N
for i in range(N):
    arr[i]=map(int,raw_input().split())
#print "Not sorted arr",
#print arr
arr=sorted(arr)
#print "sorted",
#print arr
sum=0
for i in range(N):
#    print "i: "+str(i)
    sum=sum+arr[i][1]
#    print "sum = "+str(sum)
    if sum>=K:
#        print "sum: "+str(sum)
        print arr[i][0]
        break

Submission status: Accepted

Solution code:
from operator import itemgetter

N, K = [int(x) for x in input().split()]
Array = list()
A = list()
count = 0
ans = 0
for i in range(N):
	A.append([int(x) for x in input().split()])

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

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    ab = []
    i = 0
    while i < N:
        a, b = map(int, input().split())
        ab.append([a, b])
        i += 1

    ary = sorted(ab)
    j = 0
    for i in ary:
        j += i[1]
        if j >= K:
            print(i[0])
            break

main()

Submission status: Accepted

Solution code:
def rren(): return list(map(int, input().split()))


a = set()
b = dict()
N, K = rren()

for i in range(N):
    a_t, b_t = rren()
    if(a_t not in a):
        a.add(a_t)
        b[a_t] = b_t
    else:
        b[a_t] += b_t

li_a = list(a)
li_a.sort()
count = K
for i in range(K):
    count -= b[li_a[i]]
    if(count <= 0):
        print(li_a[i])
        break

Submission status: Accepted

Solution code:

d={}
N,K=map(int,raw_input().split())

for i in xrange(N):
    a,b=map(int,raw_input().split())
#    print a,b
    if a in d:
        d[a] = d[a] + b
    else:
        d[a]=b
#    td={}
#    cnt=0
#    print d
#    for key in sorted(d):
#        print key
#        if cnt<=K:
#            td[key]=d[key]
#        else:
#            break
#    d=td

aa=None
cnt=0
#print d
for k in sorted(d):
    aa=k
    cnt+=d[k]
#    print cnt
    if cnt>=K:
        break
print aa

Submission status: Accepted

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

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

cur_pos = 0
for key in keys:
    b = dic[key]
    cur_pos += b
    if cur_pos >= K:
        print(key)
        break

Submission status: Accepted

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

    l = []

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

    l.sort()

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
freq = [0] * (10**5 + 1)
for n in range(N):
    a, b = map(int, input().split())
    freq[a] += b
    
for i, f in enumerate(freq):
    K -= f
    if K <= 0:
        print(i)
        break

Submission status: Accepted

Solution code:
if __name__ == '__main__':
	N, K = map(int, input().split())

	n=[]
	num=0
	for j in range(100000):
		n.append(0)

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

	for j in range(100000):
		num+=n[j]
		if(num>=K):
			break

	print(j+1)

Submission status: Accepted

Solution code:
read = lambda: map(int, input().split())
n, k = read()
N = 10 ** 5 + 10
c = [0] * N
for i in range(n):
    a, b = read()
    c[a] += b
for i in range(N):
    k -= c[i]
    if k <= 0:
        ans = i
        break
print(ans)

Submission status: Accepted

Solution code:
import sys

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

for i in range(N):
    box.append([int(i) for i in input().split()])
    
box.sort()
cnt = 0
for i in range(N):
    cnt += box[i][1]
    if cnt >= K:
        print(box[i][0])
        sys.exit()

Submission status: Accepted

Solution code:
#coding=UTF-8

mozir=input()
hyo=mozir.split(' ')
N=int(hyo[0])
ans_nth=int(hyo[1])

hai=[]
for idx in range(0,N,1):
    mozir=input()
    hyo=mozir.split(' ')
    entr=tuple([int(mono) for mono in hyo])
    hai.append(entr)

#print(hai)
kirei_hai=sorted(hai,key=lambda po:po[0])
#print(kirei_hai)

ans_ent_ichi=-1
tmp_nth=0
#初期値はめり込んでいる

while tmp_nth < ans_nth:
    ans_ent_ichi+=1
    tmp_nth=tmp_nth+kirei_hai[ans_ent_ichi][1]

print(kirei_hai[ans_ent_ichi][0])

Submission status: Accepted

Solution code:
n, k = map(int,input().split(" "))
num_count = dict()
for i in range(n):
    a, b = map(int, input().split(" "))
    if a not in num_count:
        num_count[a] = 0

    num_count[a] += b

temp = 0
for key in sorted(num_count.keys()):
    temp += num_count[key]
    if temp >= k:
        print(key)
        break

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
A=[]
C=[]
for i in range(N):
    a,b=map(int,input().split())
    T=[a,b]
    A.append(T)
A.sort()
counter=0
for i in range(N):
     counter+=A[i][1]
     if counter>=K:
         counter=i
         break   
print(A[counter][0])

Submission status: Accepted

Solution code:
from operator import itemgetter, attrgetter
NK = list(map(int,input().split()))
AB = sorted([tuple(map(int, input().split())) for _ in range(NK[0])],key = itemgetter(0))
for i,j in AB:
    NK[1] = NK[1] - j
    if NK[1]<=0:
        print(i)
        break

Submission status: Accepted

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

from collections import defaultdict
d = defaultdict(int)

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

d = sorted(d.items())

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
tmp=[]
for i in range(N):
    a_i,b_i=map(int,input().split())
    tmp.append([a_i,b_i])

tmp.sort(key=lambda x:x[0])
for t in tmp:
    K -= t[1]
    if K<=0:
        print(t[0])
        break

Submission status: Accepted

Solution code:
N,K = list(map(int,input().split()))
data = []
def insert(num,N,K):
    x = 0
    for i in range(N):
        x += num[i][1]
        if x >= K:
            print(num[i][0])
            break
num = [list(map(int,input().split())) for i in range(N)]
num.sort(key=lambda x:x[0])
insert(num,N,K)

Submission status: Accepted

Solution code:
from collections import defaultdict
N, K = map(int, input().split())
seq = defaultdict(lambda: 0) 
for i in range(N):
    a, b = map(int, input().split())
    seq[a] += b

values = list(seq.keys())

values.sort()
ans = 0
for i in range(len(values)):
    K -= seq[values[i]]
    if(K<=0):
        print(values[i])
        break

Submission status: Accepted

Solution code:
N,K=map(int,raw_input().split())
c=[0]*N
for i in range(N):
	a,b=map(int,raw_input().split())
	c[i]=(a,b)
c.sort()
i,j=0,0
while i<=K-1:
	i+=c[j][1]
	if i>=K:break
	j+=1
print c[j][0]

Submission status: Accepted

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

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

ab2 = sorted(ab)

cum=0
for i in range(n):
    cum += ab2[i][1]
    if cum >= k: break

print(ab2[i][0])

Submission status: Accepted

Solution code:
N, K = map(int, raw_input().split())
a = []
b = []
for i in range(N):
    temp0, temp1 = map(int, raw_input().split())
    a.append(temp0)
    b.append(temp1)

index = sorted(range(N), key=a.__getitem__)

for i in range(N):
    K -= b[index[i]]
    if K <= 0:
        print(a[index[i]])
        break

Submission status: Accepted

Solution code:
def int_input():
    line = input()
    return [int(x) for x in line.split()]

n, k = int_input()
nums = {}

for i in range(n):
    a, b = int_input()
    nums[i] = (a, b)

s = 0
for i, x in sorted(nums.values()):
    s += x
    if k <= s:
        print(i)
        break

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N, K = map(int, raw_input().split())

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

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

print ab[index][0]

Submission status: Accepted

Solution code:
import sys
N,K=map(int, input().split())
p=[]
for i in range (0,N):
  r=list(map(int, input().split() )) 
  p.append(r)
p.sort()
k=0
for i in range(0,N):
  k+=p[i][1]
  if k>=K:
    print(p[i][0])
    sys.exit()

Submission status: Accepted

Solution code:
class Data:
    def __init__(self):
        self.datanum = 0
        self.datalen = 0


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

data_list = []
for i in range(n):
    a, b = map(int, input().split(' '))
    data = Data()
    data.datanum = a
    data.datalen = b
    data_list.append(data)
sorted_list = sorted(data_list, key=lambda u: u.datanum)
output = 0
for data in sorted_list:
    output = data.datanum
    k -= data.datalen
    if k <= 0:
        break
print(output)

Submission status: Accepted

Solution code:
from operator import itemgetter
N, K = map(int, input().split())
l = []
for i in range(N):
    a, b = map(int, input().split())
    l.append([a, b])
l.sort(key = itemgetter(0))
c = 0
for e in l:
    add = e[1]
    c += add
    if c >= K:
        print(e[0])
        break

Submission status: Accepted

Solution code:
from collections import defaultdict as dd
def main():
    N, K = map(int, input().split())

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

    count = 0
    A = sorted(d.keys())
    for k in A:
        # print(k,v)
        count += d[k]
        if count >= K:
            print(k)
            break

if __name__ == "__main__":
    # global stime
    # stime = time.clock()
    main()

Submission status: Accepted

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

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

ends = [0 for x in range(10**5 + 1)]
for a, b in ab:
    ends[a] += b

for i, e in enumerate(ends):
    k -= e
    if k <= 0:
        print(i)
        break

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

array = [0]*(10**5+1)
num = 0        
index = 0
for i in range(n):
    a,b = map(int, raw_input().split())
    array[a] += b
for i in range(10**5+1):
    num += array[i]
    if(num>=k):
        index = i
        break
    

print(index)

Submission status: Accepted

Solution code:
n, k = map(int, raw_input().split())
ary = []
for i in xrange(n):
    a, b = map(int, raw_input().split())
    ary.append([a, b]) 
ary.sort(key=lambda x:x[0])
for i in xrange(n):
    k -= ary[i][1]
    if k <= 0:
        result = ary[i][0]
        break
print result

Submission status: Accepted

Solution code:
n, k = [int(x) for x in input().split(' ')]
exist = []
storage = [0 for x in range(10 ** 5+1)]
for i in range(n):
    a, b = [int(x) for x in input().split(' ')]
    storage[a] += b
sum = 0
for i in range(1, 10**5+1):
    sum += storage[i]
    if sum >= k:
        print(i)
        break
    else:
        continue

Submission status: Accepted

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

array = [None for i in range(n)]

for i in range(n):
    array[i] = [int(i) for i in input().split()]

# print(array)
#
# print(sorted(array))

sa = sorted(array)

# print(sa)

cnt = 0

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
ps = []
for i in range(N):
    a, b = map(int, input().split())
    ps.append([a, b])
ps = sorted(ps)
k = 0
for i in range(N):
    k += ps[i][1]
    if k >= K:
        print(ps[i][0])
        break

Submission status: Accepted

Solution code:
N,K = map(int,raw_input().split())

ab_list=[]

count = 0
for i in range(N):
    a,b = map(int,raw_input().split())
    ab_list.append([a,b])
    
ab_list = sorted(ab_list,key=lambda ab:ab[0])

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

array = [tuple(map(int, input().split(' '))) for i in range(N)]
array = sorted(array, key=lambda x: x[0])

count = 0
i = 0
while True:
    count = count + array[i][1]
    if count >= K:
        break
    i = i + 1

print(array[i][0])

Submission status: Accepted

Solution code:
a = list(map(int,input().split(" ")))
b = list()

for i in range(a[0]):
    b.append(list(map(int,input().split(" "))))

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

ans = c[0][0]
tmp = 0


for i in range(a[0]):
    tmp = tmp + c[i][1]
    if tmp >= a[1]:
        ans = c[i][0]
        break

print(ans)

Submission status: Accepted

Solution code:
n, k = map(int, raw_input().split(' '))
d = {}

for i in range(n):
	a, b = map(int, raw_input().split(' '))
	if d.has_key(a):
		d[a] += b
	else:
		d[a] = b

l = d.keys()
l.sort()

s = 0
for i in l:
	s += d[i]
	if s >= k:
		print i
		break

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
l = []

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

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

count = 0
for j in l:
    count += j[1]
    if k <= count:
        print(j[0])
        break

Submission status: Accepted

Solution code:
n, k = map(int, raw_input().split())
ab = {}
for i in range(n):
    l = map(int, raw_input().split())
    if l[0] not in ab:
        ab[l[0]] = [l[1]]
    else:
        ab[l[0]].append(l[1])
key = sorted(ab.keys())
x = 0
for i in key:
    sum = 0
    for j in ab[i]:
        sum += j
    x += sum
    if k <= x:
        print i
        break

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n,k = LI()
    r = []
    for _ in range(n):
        r.append(LI())

    r = sorted(r)
    c = 0
    for a,b in r:
        c += b
        if k <= c:
            return a

print(main())

Submission status: Accepted

Solution code:
N,K = [int(x) for x in input().split()]
arr=[]
for i in range(N):
    arr.append([int(x) for x in input().split()])
    
arr.sort(key=lambda tup: tup[0])

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

Submission status: Accepted

Solution code:
import sys
import math
import collections
sys.setrecursionlimit(10000)

mod = 10**9 + 7

n, k = map(int, input().split())
dic = collections.defaultdict(int)
for i in range(n):
    a, b = map(int, input().split())
    dic[a] += b
ls = []
for key in dic.keys():
    ls.append(key)
ls.sort()
for i in range(len(ls)):
    val = dic[ls[i]]
    if val >= k:
        print(ls[i])
        exit(0)
    else:
        k -= val

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict

def main():
    line = sys.stdin.readline()
    lst = line.split()
    n = int(lst[0])
    k = int(lst[1])

    cnt_dic = defaultdict(int)
    for line in sys.stdin:
        lst = line.split()
        a = int(lst[0])
        b = int(lst[1])

        cnt_dic[a] += b

    cnt = 0
    for key in sorted(cnt_dic.keys()):
        val = cnt_dic[key]
        cnt += val

        # sys.stderr.write("%d" % cnt)
        if cnt >= k:
            print("%d" % key)
            break

    return 0

if __name__ == '__main__':
    sys.exit(main())

Submission status: Accepted

Solution code:
n,K = list(map(int, input().split()))
seq = []
d = {}
for _ in range(n):
    a,b = list(map(int, input().split()))
    if a in d.keys():
        d[a] += b
    else:
        d[a] = b
c = 0
for k in sorted(d.keys()):
    ans = k
    # print(ans,k,c)
    c += d[k]
    if c >= K:
        ans = k
        break
print(ans)

Submission status: Accepted

Solution code:
import numpy as np

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

al = []
bl = []

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

al = np.array(al)
bl = np.array(bl)

s = al.argsort()

bl = bl[s]
al = al[s]

c = 0

for a,b in zip(al,bl):
	c += b
	if c >= K:
		print(a)
		break

Submission status: Accepted

Solution code:
N, K = list(map(int, input().split()))
val_dict = dict()

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

val_keys = sorted(val_dict.keys())

K_rest = K
for key in val_keys:
    K_rest -= val_dict[key]
    if K_rest <= 0:
        print(key)
        break

Submission status: Accepted

Solution code:
def linput():
    return list(map(int,input().split(" ")))


N,K=linput()
ab=[]
for i in range(N):
    ab.append(linput())

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

k=0
for i,r in enumerate(ab):
    k+=r[1]
    if k>=K:
        print(ab[i][0])
        break

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
t = []
for i in range(n):
	ti = tuple(map(int, input().split()))
	t.append(ti)

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

res = 0
x = 0
for i in range(n):
	res = t[i][0]
	inc = t[i][1]
	x += inc
	if x >= k:
		break

print(res)

Submission status: Accepted

Solution code:
import sys
import math
sys.setrecursionlimit(10000)

mod = 10**9 + 7

n, k = map(int, input().split())
dic = {}
for i in range(n):
    a, b = map(int, input().split())
    if a in dic:
        dic[a] += b
    else:
        dic[a] = b
ls = []
for key in dic.keys():
    ls.append(key)
ls.sort()
for i in range(len(ls)):
    val = dic[ls[i]]
    if val >= k:
        print(ls[i])
        exit(0)
    else:
        k -= val

Submission status: Accepted

Solution code:
N, K = map(int, raw_input().split())
D = [map(int, raw_input().split()) for _ in range(N)]

pos = 0
for a, b in sorted(D):
    if pos + b < K:
        pos += b
    else:
        print a
        exit()

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
d = {}
for n in range(N):
	a,b = map(int,input().split())
	if a in d:
		d[a] += b
	else:
		d[a] = b 
d2 = list(d)
d2.sort()
cnt = 0
for i in d2:
	cnt += d[i]
	if cnt >= K:
		print(i)
		break

Submission status: Accepted

Solution code:
import sys
import random

def rd():
        return sys.stdin.readline().rstrip()

def rdi():
        return [ int(x) for x in rd().split() ]

N, K = rdi()
a = []
b = []

for i in range(N):
        ai, bi = rdi()
        a.append(ai)
        b.append(bi)

c = {}
for i in range(N):
        ai = a[i]
        bi = b[i]
        if ai not in c:
                c[ai] = bi
        else:
                c[ai] += bi
r = K
for x in sorted(c.keys()):
        y = c[x]
        r -= y
        if r <= 0:
                print x
                break

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
arr = []
for _ in range(n):
    a, b = map(int, input().split())
    arr.append((a, b))
arr = list(sorted(arr))
cnt = 0
i = 0
ans = arr[-1][0]
while cnt < k:
    ans = arr[i][0]
    cnt += arr[i][1]
    i += 1
print(ans)

Submission status: Accepted

Solution code:
n,k = map(int, raw_input().split())
ab = []
for i in range(n):
  a,b = map(int, raw_input().split())
  ab.append((a,b))

ab.sort()
k -= 1
for a,b in ab:
  if k >= b:
    k -= b
  else:
    print a
    exit()

Submission status: Accepted

Solution code:
import collections

if __name__ == '__main__':
    n, k = map(int, input().split())
    counter = collections.defaultdict(int)

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

    x = 0
    for i in sorted(counter):
        if x <= k <= x + counter[i]:
            print(i)
            break
        x += counter[i]

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = {}
for _ in range(N):
    a, b = map(int, input().split())
    if not a in A:
        A[a] = 0
    A[a] += b

c = 0
for a in sorted(A.keys()):
    c += A[a]
    if c >= K:
        print(a)
        break

Submission status: Accepted

Solution code:
# C
import numpy as np
N, K = map(int, input().split())
a_list = []
b_list = []
for i in range(N):
    a, b = map(int, input().split())
    a_list.append(a)
    b_list.append(b)

a_order = np.argsort(a_list)
kc = 0
for i in range(N):
    kc += b_list[a_order[i]]
    if kc >= K:
        print(a_list[a_order[i]])
        break

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

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

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

A.sort()

i = 0
cnt = 0
for a in A:
    v = a[0]
    num = a[1]
    cnt += num

    if cnt >= K:
        print(v)
        break

Submission status: Accepted

Solution code:
temp=input().split()
N=int(temp[0])
K=int(temp[1])
ab=[[int(j) for j in input().split()] for i in range(N)]

ab.sort()
while ab[0][1]<K:
	K-=ab[0][1]
	del ab[0]
	#print(ab)
print(ab[0][0])

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

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

c = 0
for p in d:
    c += p[1]
    if c >= K:
        print(p[0])
        break

Submission status: Accepted

Solution code:
# coding: utf-8
n,m=map(int,input().split())
dic={}
for i in range(n):
    x,y=map(int,input().split())
    if x not in dic:
        dic[x]=y
    else:
        dic[x]+=y
for i in sorted(dic.items()):
    m-=i[1]
    if m<=0:
        print(i[0])
        break;

Submission status: Accepted

Solution code:
N,K = map(int, raw_input().split())
ab = sorted(map(int, raw_input().split()) for _ in range(N))
c = 0
for a,b in ab:
  if c+b >= K:
    print a
    break
  c += b

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, raw_input().split())
d = {}
for i in xrange(n):
    a, b = map(int, raw_input().split())
    d[a] = d.get(a, 0) + b
i = 1
ks = sorted(d)
for e in ks:
    if i <= k < i+d[e]:
        print e
        break
    i += d[e]

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
d = {}
for n in range(N):
    a, b = map(int, input().split())
    d[a] = d.get(a, 0) + b

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

cnt = 0
for k in keys:
    cnt += d[k]
    if cnt >= K:
        print(k)
        exit()
print(keys[-1])

Submission status: Accepted

Solution code:
#!/usr/bin/env pypy3
# -*- coding: UTF-8 -*-

n,k=map(int,input().split())
d={}
l=[]
for i in range(n):
    u,v=map(int,input().split())
    if u in d:
        d[u]+=v
    else:
        d[u]=v
        l.append(u)
l.sort()
for i in l:
    k-=d[i]
    if k<=0:
        print(i)
        break

Submission status: Accepted

Solution code:
n,k=map(int,raw_input().split())
cnt=[0]*(10**5+1)
for i in xrange(n):
    a,b=map(int,raw_input().split())
    cnt[a]+=b
for i in xrange(10**5+1):
    if k-cnt[i]<=0:
        print i
        break
    k-=cnt[i]

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin


def na(): return map(int, stdin.readline().split())


def ns(): return stdin.readline().strip()


stack = []
n,k = na()
for i in range(n):
    stack.append(list(na()))
stack.sort(key=lambda x: x[0])

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

Submission status: Accepted

Solution code:
A = [0 for _ in xrange(10**5+10)]
N, K = map(int, raw_input().split())
for i in xrange(N):
    a, b = map(int, raw_input().split())
    A[a] += b

k = 0
for i in xrange(10**5+10):
    k += A[i]
    if k >= K:
        print i
        break

Submission status: Accepted

Solution code:
import sys
from collections import Counter

def solve():
    N, K = map(int, input().split())
    cntr = Counter()

    for i in range(N):
        ai, bi = map(int, sys.stdin.readline().split())
        cntr[ai] += bi

    cntr = sorted(cntr.items())
    # print(cntr)

    cnt = 0

    for a, b in cntr:
        cnt += b

        if cnt >= K:
            print(a)
            return


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
a = []
for i in range(n):
    x,y = map(int, input().split())
    a.append((x,y))
a.sort()
for x,y in a:
    if y >= k:
        print(x)
        exit()
    else:
        k -= y