Problem:
 Score : 300 points    Problem Statement There is an empty array.
The following N operations will be performed to insert integers into the array.
In the i -th operation (1≤i≤N) , b_i copies of an integer a_i are inserted into the array.
Find the K -th smallest integer in the array after the N operations.
For example, the 4 -th smallest integer in the array \{1,2,2,3,3,3\} is 3 .      Constraints  1≤N≤10^5   1≤a_i,b_i≤10^5   1≤K≤b_1…+…b_n  All input values are integers.         Input Input is given from Standard Input in the following format:  N  K  a_1  b_1  :  a_N  b_N       Output Print the K -th smallest integer in the array after the N operations.        Sample Input 1 3 4
1 1
2 2
3 3      Sample Output 1 3  The resulting array is the same as the one in the problem statement.       Sample Input 2 10 500000
1 100000
1 100000
1 100000
1 100000
1 100000
100000 100000
100000 100000
100000 100000
100000 100000
100000 100000      Sample Output 2 1

Solution (Python):
from sys import stdin


def main():
    lines = stdin.readlines()
    N, K = map(int, lines[0].split())
    abn = [[int(abi) for abi in line.split()] for line in lines[1:]]
    abn.sort()
    cnt = 0
    for ai, bi in abn:
        cnt += bi
        if K <= cnt:
            print(ai)
            break
    return


main()

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

Solution (Python):
N,K = map(int,input().split())
C = {}
A = []
for _ in range(N):
    a,b = map(int,input().split())
    if a not in C:
        C[a] = 0
    C[a] += b
    A.append(a)
A = sorted(list(set(A)))
cnt = 0
for i in range(len(A)):
    cnt += C[A[i]]
    if cnt>=K:
        print(A[i])
        break

Solution (Python):
n,k=map(int,input().split())
l=[]
for i in range(n):
    a,b=map(int,input().split())
    l.append([a,b])
l.sort()
sm=0 
for i in range(n):
    if sm+l[i][1]<k:
        sm+=l[i][1]
    else: 
        print(l[i][0])
        exit()

Solution (Python):
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

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

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

dic = {}
for _ in range(n):
    a,b = map(int, input().split())
    if a not in dic:
        dic[a] = 0
    dic[a] += b

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

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

dic = {}
for _ in range(n):
    a,b = map(int, input().split())
    if a not in dic:
        dic[a] = 0
    dic[a] += b

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

Solution (Python):
res = 0
flag = False
n,k = map(int,input().split())
ab = []
for i in range(n):
	aa,bb = map(int,input().split())
	ab.append([aa,bb])

ab.sort()

for j in range(0,n):
	res = res + ab[j][1]
	if res >= k:
		print(ab[j][0])
		flag = True
	if flag == True:
		break

Solution (Python):
N,K=map(int,input().split())
ans={}
for n in range(N):
  a,b=map(int,input().split())
  if a in ans.keys():
    ans[a]+=b
  else:
    ans[a]=b
answer=sorted(ans.items(), key=lambda x:x[0])
count=0
for k in range(len(answer)):
  count+=answer[k][1]
  if count>=K:
    print(answer[k][0])
    break

Solution (Python):



n,k = map(int,input().split())
li = []

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

li.sort()

cnt = 0

for i in range(n):
    cnt += li[i][1]

    if cnt >= k:
        print(li[i][0])
        break

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

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

Solution (Python):
import sys
input = sys.stdin.buffer.readline
N, K = map(int, input().split())
d = [0] * (10 ** 5 + 1)
for i in range(N):
  a, b = map(int, input().split())
  d[a] += b
for i in range(10 ** 5 + 1):
  if d[i] >= K:
    print(i)
    exit(0)
  else:
    K -= d[i]

Solution (Python):
n,k=map(int,input().split())
lists=[0]*n
for i in range(n):
    lists[i]=tuple(map(int,input().split()))
lists=sorted(lists,key=lambda x: x[0])

count=0
num=0
for j in range(n):
    if count<k:
        count=count+lists[j][1]
        num=lists[j][0]

    else:
        break
print(num)

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

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

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

Solution (Python):
import numpy as np
from bisect import bisect_left, bisect_right
N, K = map(int, input().split())
count = 0
lis = np.array([0] * (10 ** 5))
for n in range(N):
    a, b = map(int, input().split())
    lis[a - 1] += b
for n in range(100000):
    K -= lis[n]
    if K <= 0:
        print(n + 1)
        break

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

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

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

Solution (Python):

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

for i in range(len(a_num)):
    K -= a_num[i]
    if K <= 0: 
        print(i)
        exit()

Solution (Python):


import numpy as np
import bisect

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

ab = sorted(ab, key = lambda x : x[0])
a, b = zip(*ab)
b = np.array(b)
b = b.cumsum()

ans_idx = bisect.bisect_left(b, K)
print(a[ans_idx])

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

array = []

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

array.sort()
index = 0
for a_b in array:
  index += a_b[1]
  if index >= k:
    print(a_b[0])
    break

Solution (Python):
from collections import defaultdict

n,k=map(int,input().split())
d=defaultdict(int)
for i in range(n):
    a,b=map(int,input().split())
    d[a]+=b
l=sorted(d.keys())
cnt=0
for i in l:
    cnt+=d[i]
    if cnt>=k:
        print(i)
        exit()

Solution (Python):
n,k=map(int,input().split())
d={}
for i in range(n):
    a,b=map(int,input().split())
    if a in d.keys():
        d[a]+=b
    else:
        d[a]=b
l=sorted(d.keys())
cnt=0
for i in l:
    cnt+=d[i]
    if cnt>=k:
        print(i)
        exit()

Solution (Python):

from operator import itemgetter
N,K = map(int,input().split())
A = []
B = []
AB = [[] for _ in range(N)]

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

AB.sort(key=itemgetter(0, 1))

ans = 0
if len(AB) == 1:
    ans = AB[0][0]
    print(ans)
    exit()

for i in range(N):
    if i == 0:
        AB[0].append(AB[0][1])
        continue
    AB[i].append(AB[i-1][2]+AB[i][1])

for i in range(N):
    if i == 0:
       f = 0
       t = AB[0][2]
       if f < K <= t:
           ans = AB[0][0]
           break
       continue
    f = AB[i-1][2]
    t = AB[i][2]
    if f < K <= t:
        ans = AB[i][0]
        break
print(ans)

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

while c<k:
    c+=a[i][1]
    i+=1

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

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

Solution (Python):
def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools

    n, k = map(int, input().split())
    a_b = [tuple(map(int, input().split())) for _ in range(n)]
    a_b.sort()

    sum_add_value = 0
    for v in a_b:
        sum_add_value += v[1]
        if sum_add_value >= k:
            print(v[0])
            break

if __name__ == '__main__':
    main()

Solution (Python):
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))

def main():
  n, k = na()
  ab = [na() for _ in range(n)]
  ab.sort(key = lambda x: x[0])
  cnt = 0
  for a, b in ab:
    cnt += b
    if cnt >= k:
      print(a)
      return

main()

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

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

ab = sorted(ab)

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

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

sort_dict_num = sorted(dict_num.items(), key=lambda x:x[0])
checked = 0
for key, v in sort_dict_num:
  if checked < k <= checked + v:
    print(key)
    exit()
  else:
    checked += v

Solution (Python):
if __name__ == "__main__":
    N, K = map(int, input().split())
    ab = list()
    for i in range(N):
        ab.append(list(map(int, input().split())))
    
    ab = sorted(ab)

    res = K
    for i in range(N):
        res -= ab[i][1]
        if res <= 0:
            print(ab[i][0])
            exit()

Solution (Python):

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

for i in range(len(a_num)):
    k -= a_num[i]
    if k <= 0:
        print(i)
        exit()

Solution (Python):
import heapq
n,k = map(int,input().split())
a = []
for i in range(n):
  heapq.heappush(a,tuple(map(int,input().split())))
while k:
  cur = heapq.heappop(a)
  if k <= cur[1]:
    print(cur[0])
    k = 0
  else:
    k -= cur[1]

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

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    ab = [list(map(int, input().rstrip('\n').split())) for _ in range(n)]
    ab.sort()
    cnt = 0
    for a, b in ab:
        cnt += b
        if cnt >= k:
            print(a)
            exit()


if __name__ == '__main__':
    slove()

Solution (Python):
n,k=map(int,input().split())
l=[list(map(int, input().split())) for i in range(n)]
r=[0]*(10**5+1)
for i in range(n):
    r[l[i][0]]+=l[i][1]

c=0
for i in range(1,10**5+1):
    c+=r[i]
    if k<=c:
        print(i)
        break

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

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

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

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

st_sorted = sorted(st.items(), key=lambda x:x[0])

num = 0
for i in range(len(st_sorted)):
    num += st_sorted[i][1]
    if num >= K:
        print(st_sorted[i][0])
        exit()

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

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

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

Solution (Python):
import sys
from collections import defaultdict

N, K = map(int, input().split())
ans = [0] * ((10 ** 5) + 1)

for i in range(N):
    a, b = map(int, input().split())
    ans[a] += b
cnt = 0
for i in range(10 ** 5 + 1):
    cnt += ans[i]
    if K <= cnt:
        print(i)
        sys.exit()

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

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

li = sorted(li.items())
ans = 0
for i in range(len(li)):
    ans += li[i][1]
    if ans >= k:
        print(li[i][0])
        exit()

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

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

li = sorted(li.items())
ans = 0
for i in range(len(li)):
    ans += li[i][1]
    if ans >= k:
        print(li[i][0])
        exit()

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

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

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

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

N, K = map(int, input().split())
a = [0] * N
b = [0] * N

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

a, b = zip(*sorted(zip(a, b)))

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

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

N, K = map(int, input().split())
a = [0] * N
b = [0] * N

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

a, b = zip(*sorted(zip(a, b)))

for i in range(N):
    K -= b[i]
    if K <= 0:
        print(a[i])
        exit()
    else:
        continue

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

N, K = map(int, input().split())
a = [0] * N
b = [0] * N

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

a, b = zip(*sorted(zip(a, b)))

count = 0
while K > 0:
    K -= b[count]
    count += 1

print(a[count - 1])

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

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

a, b = zip(*sorted(zip(a, b)))

count = 0
while K > 0:
    K -= b[count]
    count += 1

print(a[count - 1])

Solution (Python):
from collections import defaultdict
n,k=map(int,input().split())
d=defaultdict(int)
for _ in range(n):
  a,b=map(int,input().split())
  d[a]+=b
s=sorted(d.items(), key=lambda x:x[0])
l=0
for i,v in s:
  l+=v
  if l>=k:
    print(i)
    break

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    ab = [list(map(int, input().rstrip('\n').split())) for _ in range(n)]
    ab.sort()
    cnt = 0
    for a, b in ab:
        cnt += b
        if cnt >= k:
            print(a)
            exit()


if __name__ == '__main__':
    slove()

Solution (Python):
from itertools import accumulate
n, k = map(int, input().split())
memo = [0] * (10 ** 5 + 1)
for _ in range(n):
    i, j = map(int, input().split())
    memo[i] += j
cnt = 0
for i, j in enumerate(memo):
    cnt += j
    if cnt >= k:
        print(i)
        exit()

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

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

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

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    ab = sorted([list(map(int, input().rstrip('\n').split())) for _ in range(n)])
    t = 0
    for a, b in ab:
        t += b
        if t >= k:
            print(a)
            exit()


if __name__ == '__main__':
    slove()

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

array={}
for _ in range(n):
    a,b=map(int, input().split())
    if a not in array:
        array.setdefault(a, b)
    else:
        array[a]+=b
    
array=sorted(array.items())

count=0
for array_ele in array:
    count+=array_ele[1]
    if count>=k:
        print(array_ele[0])
        break

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

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

Solution (Python):


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

ab.sort()

for a, b in ab:
    k -= b
    if k <= 0:
        break

print(a)

Solution (Python):


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

ab.sort()

for a, b in ab:
    k = k - b
    if k <= 0:
        break

print(a)

Solution (Python):
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
data = []
for _ in range(N):
    data.append([int(x) for x in stdin.readline().rstrip().split()])

ans = 0
for i in sorted(data):
    if K <= 0:
        break
    ans = i[0]
    K -= i[1]
    
    
print(ans)

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

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


S=[M[0][1]]
for i in range(1,N):
  S.append(S[i-1]+M[i][1])


ans=0
for i,s in enumerate(S):
  if s>=K:
    ans=M[i][0]
    break
    
print(ans)

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, k = LI()
L = []
for a, b in LIR(n):
    L += [(a, b)]


L.sort()
ret = 0
i = 0
for a, b in L:
    ret += b
    ans = a
    if ret >= k:
        break


print(ans)

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    ab = [list(map(int, input().rstrip('\n').split())) for _ in range(n)]
    ab.sort()
    t = 0
    mt = 0
    for a, b in ab:
        t += b
        mt = max(mt, a)
        if t >= k:
            print(mt)
            exit()


if __name__ == '__main__':
    slove()

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

AB = [list(map(int,input().split())) for i in range(N)]
AB = sorted(AB,key=lambda a:a[0])
tmp = 0
for i in range(N):
    if K <= tmp:
        break
    tmp += AB[i][1]
    ans = AB[i][0]
print(ans)

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

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

ans = 1
while K > 0:
    K -= num[ans]
    ans += 1
print(ans-1)

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


if __name__ == "__main__":
    resolve()

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

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

i=0
ans=0
while k>0:
    k=k-l[i][1]
    ans=l[i][0]
    i=i+1
print(ans)

Solution (Python):
import heapq as hq
def main():
    n,k=map(int,input().split(' '))
    a_b=[[i for i in list(map(int,input().split(' ')))] for i in range(n)]
    hq.heapify(a_b)
    cnt = 0
    while cnt < k:
        ans,c = hq.heappop(a_b)
        cnt += c
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    l, k = list(map(int, input().rstrip('\n').split()))
    ab = [list(map(int, input().rstrip('\n').split())) for _ in range(l)]
    ab.sort()
    cnt = 0
    for a, b in ab:
        cnt += b
        if cnt >= k:
            print(a)
            exit()


if __name__ == '__main__':
    slove()

Solution (Python):
n, k = map(int,input().split())
ab_list = [list(map(int,input().split())) for _ in range(n)]
ab_dic= {}
ab_list.sort()
for i in range(n):
  if i<n-1 and ab_list[i][0] == ab_list[i+1][0]:
    ab_list[i+1][1] += ab_list[i][1]
  else:
    ab_dic[ab_list[i][0]]=ab_list[i][1]

ab_dic = sorted(ab_dic.items(),key=lambda x:x[0])
cnt = 0
for i in range(len(ab_dic)):
  cnt += ab_dic[i][1]
  if cnt >= k:
    print(ab_dic[i][0])
    break

Solution (Python):

from operator import itemgetter
N, K = map(int,input().split())
A = [list(map(int, input().split())) for i in range(N)]
S = 0
A.sort(key=itemgetter(0))

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

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

while K>0:
    K-=s[t][1]
    t+=1

print(s[t-1][0])

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

if N==1:
    a,b=map(int,input().split())
    print(a)
    exit()

for i in range(N):
    x.append(list(map(int,input().split())))

x.sort()
sum=0
for i in range(N):
    sum+=x[i][1]
    if sum>=K:
        print(x[i][0])
        exit()

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

Solution (Python):
N,K,*A=map(int,open(0).read().split())
A=sorted(zip(A[::2],A[1::2]),key=lambda x:x[0])
for a,b in A:
 if K<=b:print(a);break
 K-=b

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

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

Solution (Python):
N,K = map(int,input().split())
ins = [list(map(int,input().split())) for _ in range(N)]
ins.sort()
num = 0
i = 0
while num < K:
    num += ins[i][1]
    i += 1
print(ins[i-1][0])

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

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

print(ans)

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

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

def main():
    N, K = map(int, input().split())
    ab = sorted([list(map(int, input().split())) for i in range(N)])

    tmp = 0
    for i in range(N):
        a, b = ab[i]
        tmp += b
        if tmp >= K:
            print(a)
            return


if __name__ == "__main__":
    main()

Solution (Python):
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue,fractions
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))
def inpl_str(): return list(sys.stdin.readline().split())
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

n,k = inpl()
ab = []
for i in range(n):
    a,b = inpl()
    ab.append([a,b])
ab.sort()
cnt = 0
for i in range(n):
    if cnt + ab[i][1] >= k:
        print(ab[i][0])
        break
    else:
        cnt += ab[i][1]

Solution (Python):
n,k=map(int,input().split())
A=[]
for i in range(n):
    a=list(map(int,input().split()))
    A.append(a)
S=sorted(A,key=lambda x:x[0])
i=0

while i<n:
    a=S[i][1]
    if k<=a:
        print(S[i][0])
        exit()
    else:
        k-=S[i][1]
        i+=1

Solution (Python):
n, k = list(map(int, input().split()))
dic = {}
for _ in range(n):
    a, b = list(map(int, input().split()))
    if a not in dic:
        dic[a] = b
    else:
        dic[a] += b
total = 0
for key, val in sorted(dic.items(), key=lambda x: x[0]):
    total += val
    if k<= total:
        print(key)
        break

Solution (Python):

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

C = [0] * (10**5 + 5)

for i in range(n):
    C[A[i][0]] += A[i][1]

for i in range(len(C)):
    if k <= C[i]:
        print(i)
        break
    else:
        k -= C[i]

Solution (Python):
N, K = [int(x) for x in input().split()]
AB = [0] * N
for n in range(N):
  AB[n] = tuple([int(x) for x in input().split()])

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

Solution (Python):
from collections import defaultdict
ans = defaultdict(int)
n,k = list(map(int, input().split()))

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

ord = 0
for key in sorted(ans.keys()):
  ord += ans[key]
  if(ord >= k):
    print(key)
    exit()

Solution (Python):
N,K = map(int,input().split())
k = []
s = []
sum = 0
ans = 0
for i in range(10**5):
    k.append(0)
for i in range(N):
    s.append(list(map(int,input().split())))
for i in range(N):
    k[(s[i][0]-1)] += s[i][1]
for i in range(10**5):
    sum += k[i]
    ans += 1
    if sum >= K:
        print(ans)
        break
    else:
        continue

Solution (Python):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


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

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

remain = K
for i in range(10**5+1):
    if ans[i] == 0:
        continue

    remain -= ans[i]
    if remain <= 0:
        print(i)
        exit()

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

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

AB.sort(key=lambda x: (x[0], -x[1]))

idx = 0
rignt = 0
for a, b in AB:
    idx += b
    rignt = a
    if idx >= K:
        break

print(rignt)

Solution (Python):
n,k=map(int,input().split())
ab=[[int(i) for i in input().split()]for j in range(n)]
dic={}
for a,b in ab:
    if a in dic:
        dic[a]+=b
    else:
        dic[a]=b
dic=sorted(dic.items() , key=lambda x:x[0])
check=0
for i,j in dic:
    check+=j
    if check>=k:
        print(i)
        break

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

s = {}

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

s_key = list(s.keys())
s_key_int = [int(i) for i in s_key]
s_key_int.sort()

cnt = 0
num = 0

for j in s_key_int:
    cnt += s[str(j)]
    if cnt >= K:
        num=j
        break
print(j)

Solution (Python):
import bisect

N, K = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x: x[0])
sumB = [0]
for a, b in AB:
    sumB.append(sumB[-1] + b)
print(AB[bisect.bisect_left(sumB, K) - 1][0])

Solution (Python):
N,K=map(int,input().split())
ab=[[0]*2 for i in range(N)]
for i in range(N):
  ab[i]=list(map(int,input().split()))
  
ab=sorted(ab,key=lambda x:x[0])
i=-1
while(K > 0):
  i+=1
  K -= ab[i][1]

print(ab[i][0])

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

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

Solution (Python):
import sys
import copy
import  math
from _bisect import *
from collections import *
from operator import itemgetter
from math import factorial
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n, k = na()
li = []
for i in range(n):
    a, b = na()
    li.append((a, b))
ct = 0
for a, b in sorted(li, key=itemgetter(0)):
    ct += b
    if ct >= k:
        ans = a
        break
print(ans)

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

Solution (Python):
from collections import defaultdict

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

s = set()
d = defaultdict(int)
for _ in range(n):
    a, b = map(int, input().split())
    d[a] += b
    s.add(a)

s = sorted(list(s))


s += [0]
cnt = 0
ret = None
for i in s:
    cnt += d[i]
    if cnt >= k:
        
        ret = i
        break
print(ret)

Solution (Python):
N, K = map(int, input().split())
AB = []
for i in range(N):
  AB.append(list(map(int, input().split())))
AB = sorted(AB)
o = 0
for i in range(N):
  o += AB[i][1]
  if o >= K:
    print(AB[i][0])
    break

Solution (Python):
N,K=map(int, input().split())
s=[list(map(int, input().split())) for i in range(N)]
s.sort()
t=0
while K>0:
    K-=s[t][1]
    t+=1
print(s[t-1][0])

Solution (Python):
n,k=map(int,input().split())
l=sorted([list(map(int,input().split())) for _ in range(n)])
cou=0
for r in l:
  a,b=r[0],r[1]
  cou+=b
  if cou>=k:
    print(a)
    break

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

acc = 0

for i in range(100000):
    acc += arr[i]
    
    if acc >= k:
        print(i+1)
        break

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


cnt = 0
for i in sorted(list(c.keys())):
    cnt += c[i]
    if cnt >= k:
        print(i)
        exit()

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

ab = sorted(ab)


tmp = 0

for i in ab:
    tmp += i[1]
    if tmp >= K:
        ans = i[0]
        break

print(ans)

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