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())
a = [list(map(int,input().split())) for _ in range(n)]
a.sort()
cnt = 0
for x,y in a:
    cnt += y
    if cnt >= k:
        print(x)
        exit()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
n_list = []
for _ in range(n):
    tmp = list(map(int, input().split()))
    n_list.append(tmp)
n_list.sort()
cnt = 0
for arr in n_list:
    cnt += arr[1]
    if k <= cnt:
        print(arr[0])
        break

Submission status: Accepted

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

ab.sort()

index = 0

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

Submission status: Accepted

Solution code:
#C問題
N,K=map(int,input().split())
ans=[0 for i in range(10**5)]
for i in range(N):
    a,b=map(int,input().split())
    ans[a-1]+=b
count=0
for i in range(10**5):
    count+=ans[i]
    if count >= K:
        print(i+1)
        break

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
from collections import defaultdict
data=[]
for n in range(N):
    data.append(tuple(map(int,input().split())))
data.sort(key=lambda x:x[0])
now=0
for i in range(len(data)):
    now+=data[i][1]
    if now>=K:
        print(data[i][0])
        break

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
ab = []
for i in range(n):
    ab.append([int(j) for j in input().split()])
ab.sort()
cnt = 0
for x in ab:
    if x[1]+cnt < k:
        cnt += x[1]
    elif x[1]+cnt >= k:
        print(x[0])
        break

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
list=[0]*(10**5+1)
for i in range(n):
    a,b=map(int,input().split())
    list[a]+=b
sum=0
for l in range(1,len(list)):
    sum+=list[l]
    if sum>=k:
        print(l)
        exit()

Submission status: Accepted

Solution code:
from operator import itemgetter


def main():
    N, K = map(int, input().split())
    arr = [None] * N
    for i in range(N):
        a, b = map(int, input().split())
        arr[i] = (a, b)
    arr.sort(key=itemgetter(0))
    for i in range(N):
        a, b = arr[i]
        K -= b
        if K <= 0:
            print(a)
            break


if __name__ == "__main__":
    main()

Submission status: Accepted

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

x = 0

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# abc061_c
"""
Big Array
"""

def answer():
    """
    答えを出力する関数
    """
    l = []
    N, K = map(int, input().split())
    counter = 0

    for _ in range(N):
        l.append(list(map(int, input().split())))

    l.sort()
    for v in l:
        counter += v[1]
        if counter >= K:
            print(v[0])
            break

def main():
    """
    処理を実行する関数
    """
    answer()


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#ABC061C
N,K=map(int,input().split())
A={}
for n in range(N):
	a,b=map(int,input().split())
	A[a]=A.get(a,0)+b
for key in sorted(list(A.keys())):
	K-=A[key]
	if K<=0:
		print(key)
		break

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n,k = map(int,input().split())
s = [list(map(int,input().split())) for _ in range(n)]
s.sort()
for i in range(n):
    k -= s[i][1]
    if k <= 0:
        print(s[i][0])
        exit()

Submission status: Accepted

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

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

a.sort()

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

Submission status: Accepted

Solution code:
from collections import defaultdict
n, k = map(int, input().split())
dic = defaultdict(int)
for _ in range(n):
  a, b = map(int, input().split())
  dic[a] += b
cnt = 0
for key in sorted(dic):
  if cnt + dic[key] < k:
    cnt += dic[key]
  else:
    print(key)
    break

Submission status: Accepted

Solution code:
N, K = list(map(int, input().split()))
thelist = [tuple(map(int, input().split())) for i in range(N)]
thelist.sort()
i = x = 0

while x < K:
    x += thelist[i][1]
    i += 1
print(thelist[i-1][0])

Submission status: Accepted

Solution code:
from collections import defaultdict

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

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

def solve(k, s):
    rank = 0

    for i in sorted(s.keys()):
        j = s[i]
        if rank < k <= rank + j:
            return i
        rank += j

main()

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
l=[]
for i in range(n):
    x,y=map(int,input().split())
    l.append([x,y])
l.sort()
sum=l[0][1]
i=0
while sum<k:
    i+=1
    sum+=l[i][1]
print(l[i][0])

Submission status: Accepted

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

d = dict()

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

d = sorted(d.items())

for a, b in d:
    k -= b
    if k <= 0:
        print(a)
        exit()

Submission status: Accepted

Solution code:
import heapq

N, K = map(int, raw_input().split())
pq = []
for a, b in [map(int, raw_input().split()) for _ in range(N)]:
  heapq.heappush(pq, (a, (a, b)))
res = -1
while K > 0:
  res, (_, num) = heapq.heappop(pq)
  K -= num
print res

Submission status: Accepted

Solution code:
int_n, int_k = map(int, input().split())

li_wk = list()

for i in range(int_n):
    li_wk.append(list(map(int, input().split())))

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

counter = 1
for l in li_wk:
    if counter <= int_k <= (counter + l[1] - 1):
        print(l[0])
    counter += l[1]

Submission status: Accepted

Solution code:
N, K = map(int,input().split())
L = []
for _ in range(N):
    L.append(list(map(int,input().split())))
L.sort()
for i in range(1,len(L)):
    L[i][1] = L[i][1] + L[i-1][1]
for x in L:
    if K <= x[1]:
        print(x[0])
        break

Submission status: Accepted

Solution code:
a = list(map(int,input().split()))
N = a[0]
K = a[1]
bucket = [0 for i in range(100001)]
for i in range(N):
    temp = list(map(int,input().split()))
    bucket[temp[0]] += temp[1]
sum = 0
for i in range(100001):
    sum += bucket[i]
    if K <= sum:
        print(str(i))
        break

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
L=[]
for s in range(n):
  a,b=map(int,input().split())
  L.append((a,b))
#print(L)
L=sorted(L,key=lambda x:x[0])
#print(L)
sun=0
for s in L:
  sun+=s[1]
  if sun+1>k:
    print(s[0])
    exit()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

info =sorted(info)

for i in range(n):
  if info[i][1]>=k:
    print(info[i][0])
    exit()
  else:
    k = k - info[i][1]

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from operator import itemgetter

N, K = list(map(int, input().split()))
ab = []
for i in range(N):
    ab.append(list(map(int, input().split())))
ab = sorted(ab, key=itemgetter(0,1))

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

Submission status: Accepted

Solution code:
N, K = map(int,input().split())
AB = sorted([list(map(int,input().split())) for _ in range(N)])
cnt = 0
for a, b in AB:
  if(cnt < K - b):
    cnt += b
  else:
    print(a)
    break

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a_b=[[0,0,0]]
for i in range(n):
    a,b=map(int,input().split())
    a_b.append([a,b,b])
a_b.sort(key=lambda x: x[0])
for i in range(n):
    a_b[i+1][2]+=a_b[i][2]
for i in range(len(a_b)):
    if a_b[i][2]<k<=a_b[i+1][2]:
        print(a_b[i+1][0])
        exit()

Submission status: Accepted

Solution code:
import numpy as np
N,K = map(int, input().split())
ab = [tuple(map(int, input().split())) for i in range(N)]
ab.sort()
num = 0
for i in range(N):
	num += ab[i][1]
	if num >= K:
		ans = ab[i][0]
		break

print(ans)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
l = [tuple(map(int, input().split())) for i in range(n)]
l.sort()
l.append((0, k))
d = [l[0][1]]
for i in range(1,n+1):
    d.append(d[i-1] + l[i][1])
t = 0
while d[t] < k:
    t += 1
print(l[t][0])

Submission status: Accepted

Solution code:
class struct:
  def __init__(self,a,b):
    self.a=a
    self.b=b
n,k=map(int,input().split())
l=[]
for i in range(n):
  a,b=map(int,input().split())
  l.append(struct(a,b))
l=sorted(l,key=lambda x:x.a)
s=0
for i in l:
  s+=i.b
  if k<=s:
    print(i.a)
    exit()

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
x = [list(map(int,input().split())) for i in range(n)]
x = sorted(x,key=lambda x:x[0])
tem = x[0][1]
i = 0
while k-tem > 0:
    i += 1
    tem += x[i][1]
print(x[i][0])

Submission status: Accepted

Solution code:
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, K] = [int(input_raw[0]), int(input_raw[1])]
    A = []
    for i in range(N):
        input_raw = read_func().strip().split()
        [a, b] = [int(input_raw[0]), int(input_raw[1])]
        A.append((a, b))
    A.sort()

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




if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())|	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import collections
import math

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

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

Submission status: Accepted

Solution code:
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
dic = sorted(dic.items(),reverse=True)

tmp = 0
while tmp < K:
    ans = dic.pop()
    tmp += ans[1]
print(ans[0])

Submission status: Accepted

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

data = [map(int,raw_input().split()) for i in range(N)]

data.sort()

cnt = 0

for i in data:
    cnt += i[1]
    if cnt >= K:
        print i[0]
        break

Submission status: Accepted

Solution code:
N,K = map(int,input().split(" "))
list = []
for i in range(N):
    a,b = map(int,input().split(" "))
    list.append([a,b])
list = sorted(list)
#print(list)

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
ls={}
for i in range(n):
  a,b=map(int,input().split())
  if a not in ls:
    ls[a]=b
  else:
    ls[a]+=b
ls=sorted(ls.items())
tmp=0
for i,j in ls:
  tmp+=j
  if k <= tmp:
    print(i)
    exit()

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
c = [0]*(10**5)
for x in range(N):
    a,b=map(int,input().split())
    c[a-1]+=b

for i in range(10**5):
    if c[i]>=K:
        print(i+1)
        break
    else: # c[i]<K
        K -=c[i]

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
a=[[0,0] for _ in range(N)]
for i in range(N):
    a[i][0],a[i][1]=map(int,input().split())
a.sort()
ans=a[0][0]
Sum=0
i=0
while Sum<K:
    Sum+=a[i][1]
    if Sum>=K:
        ans=a[i][0]
    i+=1
print(ans)

Submission status: Accepted

Solution code:
import sys
N, K = map(int, input().split())
num = []
for _ in range(N):
    a, b = map(int, input().split())
    num.append((a, b))
num = sorted(num, key=lambda x: x[0])
s = 0
for item in num:
    s += item[1]
    if s >= K:
        print(item[0])
        sys.exit()

Submission status: Accepted

Solution code:
n, k=[int(w) for w in input().split()]
lim=100*1000+1
c=[0]*lim
for i in range(n):
    a, b=[int(w) for w in input().split()]
    c[a]+=b
for i in range(lim):
    k-=c[i]
    if k<=0:
        print(i)
        break

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    counts = [0] * 100001

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

    for i in range(1, 100001):
        if k <= counts[i]:
            print(i)
            break
        k -= counts[i]


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from operator import itemgetter

n, k = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
a.sort(key=itemgetter(0))
m = 0

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

Submission status: Accepted

Solution code:
n, k = [int(x) for x in input().split(' ')]
ab = sorted([[int(x) for x in input().split(' ')]  for _ in range(n)])
index = 0

for a in ab:
    index += int(a[1])
    if index >= k:
        print(a[0])
        break

Submission status: Accepted

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

    count = dict()
    for i in range(N):
        [a, b] = [int(x) for x in input().split()]
        count[a] = count.get(a, 0) + b

    idx = 0
    # print(count)

    keys = sorted(count.keys())

    K = K - 1
    for k in keys:
        n = count[k]
        if idx <= K < idx + n:
            return k
        idx += n

    return 0


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

Submission status: Accepted

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

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

for i, num in sorted(int_num.items(), key=lambda x:x[0]):
    K -= num
    if K <= 0:
        print(i)
        break

Submission status: Accepted

Solution code:
import heapq
n, k = list(map(int, input().split()))
li = []
for _ in range(n):
    li.append(tuple(map(int, input().split())))

li.sort()
cnt = 0
for a, b in li:
    cnt += b
    if cnt >= k:
        ans = a
        break

print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append((a, b))
A.sort(key=lambda x:x[0])
b_sum = 0
for a, b in A:
    b_sum += b
    if b_sum >= K:
        print(a)
        break

Submission status: Accepted

Solution code:
def solve():
    N, K = map(int, input().split()) 
    ab = []
    for i in range(N):
        ab.append( list(map(int, input().split())) )

    ab.sort()

    for (a, b) in ab:
        K -= b
        if K <= 0:
            print(a)
            return

solve()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
A = sorted([[int(i) for i in input().split()] for i in range(n)])
cnt = 0
for i in range(n):
    cnt += A[i][1]
    if cnt >= k:
        print(A[i][0])
        break

Submission status: Accepted

Solution code:
n, K = map(int, input().split())
rec = [0] * (10 ** 5 + 5)
for i in range(n):
    a, b = map(int, input().split())
    rec[a] += b

for i in range(10 ** 5 + 1):
    if rec[i] > 0:
        K -= rec[i]
        if K <= 0:
            print(i)
            exit()

Submission status: Accepted

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

def main():
    n, k = map(int, input().split())
    cnt = {}
    for i in range(n):
        a, b = map(int, input().split())
        if a not in cnt:
            cnt[a] = 0
        cnt[a] += b
    print(kth_smallest(cnt, k))

def kth_smallest(cnt, k):
    keys = sorted(cnt.keys())
    for key in keys:
        k -= cnt[key]
        if k <= 0:
            return key
    raise Exception

main()

Submission status: Accepted

Solution code:
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))
cnt = 0
i = 0
while cnt < K:
    cnt += AB[i][1]
    i += 1
print(AB[i-1][0])

Submission status: Accepted

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

nums = []
for _ in range(N):
    nums.append(list(map(int, input().split())))

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

acc = [0]*N
acc[0] = nums[0][1]
for i in range(1, N):
    acc[i] += acc[i-1]+nums[i][1]


for i in range(N):
    if acc[i] >= K:
        print(nums[i][0])
        exit()

Submission status: Accepted

Solution code:
import collections
import math
import re
import numpy
from operator import itemgetter
def ai():return input()#s
def a():return int(input())#a,n or k
def ma():return map(int, input().split())#a,b,c,d or n,k
def ms():return map(str, input().split())#,a,b,c,d
def lma():return list(map(int, input().split()))#x or y
def lms():return list(map(str, input().split()))#x or y
def say(i):return print("Yes" if i == 0 else "No")
def Say(i):return print("YES" if i == 0 else "NO")
kind=[]
l = []
f = 0
s=0
c=0
e =1
n,k=ma()
for i in range(n):
    a,b = ma()
    l.append([a,b])
l.sort()
for i in range(n):
    s+=l[i][1]
    if s >=k:
        c = l[i][0]
        break
print(c)

Submission status: Accepted

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

Submission status: Accepted

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

d = {}

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

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

idx = 0
sum = 0
while sum + d[keys[idx]] < K:
    sum += d[keys[idx]]
    idx += 1
    # print("idx:{}, sum:{}".format(idx, sum))

print(keys[idx])

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
D = {}
for i in range(N) :
    a,b = map(int,input().split())
    if a not in D :
        D[a] = b
    else :
        D[a] += b
D = sorted(D.items(),key=lambda x: x[0])        

ctr = 0
for i in range(len(D)) :
    ctr += D[i][1]
    if ctr >= K :
        ans = D[i][0]
        break
print(ans)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()
def LIR(n): return [LI() for i in range(n)]

#A
"""
s = S()
if s[0] != "A":
    print("WA")
else:
    count = []
    for i in range(2,len(s)-1):
        if s[i] == "C": count.append(i)
    if len(count) != 1:
        print("WA")
    else:
        for i in range(1,len(s)):
            if i not in count:
                if s[i] == s[i].upper():
                    print("WA")
                    quit()
        print("AC")
"""

#B
"""
n,m,k = LI()
for i in range((n+1)//2):
    if (k - m*i) % (n - 2*i) == 0 and (k-m*i)//(n-2*i) >= 0 and (k-m*i)//(n-2*i) <= m:
        print("Yes")
        quit()
print("No")
"""

#C
from collections import defaultdict
n,k = LI()
d = defaultdict(int)
for i in range(n):
    a,b = LI()
    d[a] += b
s = list(d.items())
s.sort(key = lambda x:x[0])
su = 0
for i in range(len(s)):
    su += s[i][1]
    if su >= k:
        print(s[i][0])
        break
#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = [0 for _ in range(10 ** 5)]
for i in range(N):
    a, b = map(int, input().split())
    A[a - 1] += b
for i in range(10 ** 5):
    if K - A[i] > 0:
        K = K - A[i]
    else:
        print(i + 1)
        break

Submission status: Accepted

Solution code:
import bisect
N,K=map(int,input().split())
l=[]
for i in range(N):
    a,b=map(int,input().split())
    l.append((a,b))
l.sort()
count=0
for a,b in l:
    count+=b
    if K<=count:
        print(a)
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect
n,k= (int(i) for i in input().split())
array = []
for i in range(n):
 a,b= (int(j) for j in input().split())
 array.append((a,b))
array = sorted(array)
cnt = 0
for ab in array:
    a,b = ab
    cnt += b
    if cnt >= k:
        print(a)
        break

Submission status: Accepted

Solution code:
import collections

N, K = map(int, input().split(" "))
inputLines = [input() for i in range(N)]
arrayInfo = collections.Counter()
for inputLine in inputLines:
    a, b = map(int, inputLine.split(" "))
    arrayInfo[a] += b
now = 0
for key, value in sorted(arrayInfo.items()):
    now += value
    if K <= now:
        print(key)
        break

Submission status: Accepted

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

AB.sort()

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(n)]
AB.sort()
count = 0

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

Submission status: Accepted

Solution code:
#ABC061
N,K = (int(i) for i in input().split())
a = {}
for i in range(N):
    tmp = list(int(i) for i in input().split())
    if not tmp[0] in a.keys():
        a[tmp[0]] = tmp[1]
    else:
        a[tmp[0]] += tmp[1]


ans_array = []
for k,v in a.items():
    ans_array.append((k,v))
ans_array = sorted(ans_array)

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
nums = {}

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

nums_list = list(nums.items())
nums_list.sort()

while True:
    K -= nums_list[0][1]
    if K <= 0:
        print(nums_list[0][0])
        break
    else:
        del nums_list[0]

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

for k, v in sorted(array.items()):
    K -= v
    if K <= 0:
        print(k)
        break

Submission status: Accepted

Solution code:
from sys import stderr, setrecursionlimit, exit
from collections import defaultdict as dd
setrecursionlimit(2147483647)
def getInt():
    return int(input())
def getInts():
    return [int(i) for i in input().split()]
def getIntLines(n=1):
    res = []
    for _ in range(n):
        res.append(getInt())
    return res
def getIntsLines(n=1):
    res = []
    for _ in range(n):
        res.append(getInts())
    return res
def debug(*args, sep=" ", end="\n"):
    for item in args:
        stderr.write(str(item))
        stderr.write(sep)
    stderr.write(end)

n, k = getInts()
arr = dd(int)
for _ in range(n):
    a, b = getInts()
    arr[a] += b
arr_sorted = sorted(list(arr.items()),key=lambda x:x[0])
i = 0
for key, val in arr_sorted:
    i += val
    if i >= k:
        print(key)
        exit()

Submission status: Accepted

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

ans = 0
for a in sorted(A):
    ans += A[a]
    if ans >= k:
        print(a)
        break

Submission status: Accepted

Solution code:
n ,k = map(int, input().split())
A = [tuple(map(int, input().split())) for i in range(n)]
A.sort(key=lambda x: x[0])
m = 0
i = -1
while m < k:
    i += 1
    m += A[i][1]
print(A[i][0])

Submission status: Accepted

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

    ab.sort()
    count = 0
    for v in ab:
        count += v[1]
        if count >= k:
            print(v[0])
            break


abc061_c()

Submission status: Accepted

Solution code:
import numpy as np
N, K = [int(x) for x in input().split()]
#print(N,K)

list = []
for i in range(N):
    a,b = [int(x) for x in input().split()]
    list.append([a, b])
list.sort()
#print(list)
nth = 0
for i in range(N):
    a,b = list[i]
    nth += b 
    if K<=nth:
        break
#    elif nth==K:
#        a,b = list[i-1]
#        break
#print(a,b)
print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict
n, k = list(map(int, input().split()))
d = defaultdict(int)
for i in range(n):
    a, b = list(map(int, input().split()))
    d[a] += b
cnt = 0
for i, j in sorted(list(d.items())):
    if cnt < k <= cnt+j:
        print(i)
        exit()
    cnt += j

Submission status: Accepted

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

a_b.sort(key=lambda x: x[0])
tmp = 0
for a, b in a_b:
    tmp += b
    if tmp >= K:
        print(a)
        break

Submission status: Accepted

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

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

print(a)

Submission status: Accepted

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

Submission status: Accepted

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

l = [0 for _ in range(1000000)]

rui = 0

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


for i in range(len(l)):
    rui += l[i]

    if rui >= k:
        print(i)
        break

#print()

Submission status: Accepted

Solution code:
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)

dic = {}
for i in range(n):
    a = a_list[i]
    b = b_list[i]
    if a in dic.keys():
        tmp = dic[a]
        dic[a] = tmp + b
    else:
        dic[a] = b
count = 0
sorted_dic = sorted(dic.items())
for a, b in sorted_dic:
    count += b
    if count >= k:
        print(a)
        exit()

Submission status: Accepted

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

cnt = 0
for a in A:
  if(cnt < K-a[1]):
    cnt += a[1]
  else:
    print(a[0])
    break
"""
unk buriburi
"""