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

Solution (Python):
N, K = map(int, input().split())
cnt = [0]*100001
S = set()
for i in range(N):
  a, b = map(int, input().split())
  cnt[a-1] += b
  S.add(a)

acc = 0
for s in sorted(S):
  acc += cnt[s-1]
  if acc >= K:
    print(s)
    break

Solution (Python):
n,k = map(int,input().split())
num = [0] * 100000
for i in range(n):
  c,d = map(int,input().split())
  num[c-1] += d
sum = 0
for i in range(100000):
  sum += num[i]
  if sum >= k:
    print(i + 1)
    exit()

Solution (Python):



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

    cnt = 0
    for i in range(10 ** 5 + 1):
        if cnt+L[i] >= K:
            print(i)
            break
        else:
            cnt += L[i]


resolve()

Solution (Python):
import sys
input = sys.stdin.readline
n,k=map(int,input().split())
l=[0]*10**5
for i in range(n):
    a,b=map(int,input().split())
    l[a-1]+=b
s=0
for i in range(10**5):
    if s+l[i]>=k:print(i+1);break
    else: s+=l[i]

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

def readlines(n):
    for _ in range(n):
        a, b = map(int, input().split())
        yield a, b

def main():
    n, k = map(int, input().split())
    ary = []
    heapq.heapify(ary)
    for a, b in readlines(n):
        heapq.heappush(ary, (a, b))

    while True:
        a, b = heapq.heappop(ary)
        k -= b
        if k <= 0:
            print(a)
            return

main()

Solution (Python):
import numpy as np

N,K = [int(i) for i in input().split()]

ab = np.ones([N,2])

for i in range(N):
    ab[i,0], ab[i,1] = [int(i) for i in input().split()]

ab_sort = ab[np.argsort(ab[:,0])]

cout = 0

for i in range(N):
    cout += ab_sort[i,1]
    if cout >= K:
        print(int(ab_sort[i,0]))
        break

Solution (Python):



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


a_b_dict = dict()



for i in range(N):
    a,b = map(int, input().split())
    
    
    
    if a not in a_b_dict:
        a_b_dict[a] = 0
    
    a_b_dict[a] += b
    
    
    
a_b_dict_sorted = sorted(a_b_dict.items(), key=lambda x:x[0])



position = 0
for ab in a_b_dict_sorted:
    b = ab[1]
    position += b
    
    if position >= K:
        print(ab[0])
        break

Solution (Python):

import math
import heapq
import bisect
import numpy as np
from collections import Counter, deque


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

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

Solution (Python):
import math
import collections
from operator import mul
from functools import reduce


n,k=map(int,input().split())
a=[(0,0)]*n
for i in range(n):
  a[i]=tuple(map(int,input().split()))

a=sorted(a)
for ai in a:
    k-=ai[1]
    if k<=0:
        print(ai[0])
        exit()

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

Solution (Python):
N,K =map(int,input().rstrip().split())
ans = [0 for _ in range(10 ** 5 + 1)]
for i in range(N):
  a,b = map(int,input().rstrip().split())
  ans[a] += b
counter = 0
c2 = 0
while counter < K:
  c2  += 1
  counter += ans[c2]
print(c2)

Solution (Python):
n,k=map(int,input().split())
a=[]
b=[]
for _ in range(n):
    x,y=map(int,input().split())
    a.append(x)
    b.append(y)

lo=1
hi=max(a)
while lo<hi:
    md=(lo+hi)//2
    def chk(md):
        cnt=0
        for i in range(n):
            if a[i]<=md:
                cnt+=b[i]
        return cnt
    if chk(md)>=k:
        hi=md
    else:
        lo=md+1
print(lo)

Solution (Python):
n,k,*l=map(int,open(0).read().split())
for a,b in sorted(zip(l[::2],l[1::2])):
  k-=b
  if k<1:print(a);break

Solution (Python):
n,k,*l=map(int,open(0).read().split());c=0
for a,b in sorted(zip(l[::2],l[1::2])):
  c+=b
  if c>=k:print(a);break

Solution (Python):
f=lambda:map(int,input().split());n,k=f();c=0
for a,b in sorted(list(f())for _ in[0]*n):
  c+=b
  if c>=k:print(a);break

Solution (Python):
f=lambda:map(int,input().split());n,k=f();c=0
for a,b in sorted(list(f())for _ in range(n)):
  c+=b
  if c>=k:print(a);break

Solution (Python):
f=lambda:map(int,input().split())
n,k=f()
c=0
for a,b in sorted(list(f()) for _ in range(n)):
  c+=b
  if c>=k: print(a); break

Solution (Python):
f=lambda:map(int,input().split())
n,k=f()
d={}
for i in range(n):
  a,b=f()
  d[a]=d.get(a,0)+b
c=0
for a,b in sorted(d.items()):
  c+=b
  if c>=k: print(a); break

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

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

Solution (Python):
import sys
from operator import itemgetter

rl = sys.stdin.readline


def solve():
    N, K = map(int, rl().split())
    ab = [list(map(int, rl().split())) for _ in range(N)]
    ab.sort(key=itemgetter(0))
    
    cnt = 0
    for a, b in ab:
        cnt += b
        if K <= cnt:
            print(a)
            exit()


if __name__ == '__main__':
    solve()

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

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

Solution (Python):

n, k = map(int, input().split())
pair = []
for _ in range(n):
    a, b = map(int, input().split())
    pair.append((a, b))
pair.sort()

tmp = 0
for a, b  in pair:
    tmp += b
    if k <= tmp:
        print(a)
        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=[]
for u,v in d.items():
  l.append((u,v))
l.sort(key=lambda x:x[0])
i=0
while k-l[i][1]>0:
  k-=l[i][1]
  i+=1
print(l[i][0])

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

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

C = zip(A, B)
C = sorted(C)
A, B = zip(*C)
for i in range(n):
    a = A[i]
    b = B[i]
    k -= b
    if k <= 0:
        print(a)
        break

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

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

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

count = [0] * (10 ** 5 + 2)
for a, b in query:
    count[a] += b

for i, c in enumerate(count):
    k -= c
    if k <= 0:
        print(i)
        exit()

Solution (Python):












mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

def main():
    n,k = map(int,input().split())
    a = []
    for i in range(n):
        a.append(list(map(int,input().split())))
    a.sort()
    cnt = 0
    for i in range(n):
        cnt += a[i][1]
        if cnt>=k:
            print(a[i][0])
            break
    return

if __name__=='__main__':
    main()

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

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

ab.sort(key=lambda x: x[0])
index = 0
for i in range(n):
  index += ab[i][1]
  if index >= k:
    ans = ab[i][0]
    break

print(ans)

Solution (Python):
n,k = [int(x) for x in input().split()]
d = {}
for _ in range(n):
    a = [int(x) for x in input().split()]
    if a[0] in d.keys():
        d[a[0]] += a[1]
    else:
        d[a[0]] = a[1]


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

Solution (Python):
import sys
N, K = map(int, input().split())
arr = [0 for _ in range(10**5 + 1)]
su = 0
ans = 0

for n in range(N):
  a, b = map(int, input().split())
  arr[a] += b
  
for i in range(1, 10**5+1):
  su += arr[i]
  if su >= K:
    ans = i
    break
print(ans)

Solution (Python):
N, K = map(int, input().split())
l = sorted([tuple(map(int, input().split()))for _ in range(N)], key=lambda x:x[0])
c = 0
for i in l:
  c += i[1]
  if c >= K:
    print(i[0])
    break

Solution (Python):
N, K = map(int, input().split())
cnt = [0]*100001
S = set()
for i in range(N):
  a, b = map(int, input().split())
  cnt[a-1] += b
  S.add(a)

acc = 0
for s in sorted(S):
  acc += cnt[s-1]
  if acc >= K:
    print(s)
    break

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

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

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

cnt = 0

for v in ab:
    cnt += v[1]

    if cnt >= K:
        print(v[0])
        exit(0)

Solution (Python):
from operator import itemgetter
N, K = map(int, input().split())
ab = []
for i in range(N):
    a, b = map(int, input().split())
    ab.append((a,b))
ab.sort(key=itemgetter(0))

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

for i in range(1,N+1):
    if R[i-1]<K<=R[i]:
        print(ab[i-1][0])

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

ab.sort()

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

index = bisect.bisect_left(cusum, k) - 1
print(ab[0 if index < 0 else index][0])

Solution (Python):
N,K=map(int,input().split())
a=[0]*N
b=[0]*N
c=[0]*N
for i in range(N):
  a[i],b[i]= map(int,input().split())
  c[i]=(a[i],b[i])
  
c.sort(key=lambda x: x[0])
cnt=0

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

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

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

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

cnt = 0
d = {}
for _ in range(N):
    a, b = map(int, input().split())
    if a in d:
        d[a] += b
    else:
        d[a] = b

sorted_d = sorted(d.items(), key=lambda x: x[0])
cnt = 0
for k, v in sorted_d:
    cnt += v
    if cnt >= K:
        print(k)
        break

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

for i in range(N):
    a, b = l[i]
    if K>b:
        K-=b
    else:
        print(a)
        exit()

Solution (Python):
N, M = map(int,input().split()) 
P = [list(map(int,input().split())) for i in range(N)]
P.sort()
a = 0
for i in range(N):
    if M <= P[i][1]:
        break
    M = M-P[i][1]
    a += 1


print(P[a][0])

Solution (Python):
N,K=map(int,input().split())
Array={}
for n in range(0,N):
    a,b=map(int,input().split())
    if a in Array:
        Array[a]+=b
    else:
        Array[a]=b
numbers=sorted(list(Array.keys()))
n=0
k=0
while True:
    k+=Array[numbers[n]]
    if k>=K:
        break
    n+=1
print(numbers[n])

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

dic = {}
for i in range(n):
    a,b = map(int,input().split())
    try:
        dic[a] += b
    except:
        dic[a] = b


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

for a,b in dic:
    if b-k >=0:
        print(a)
        exit()
    else:
        k -= b

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

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

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

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

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

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

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

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

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

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

Solution (Python):

from collections import defaultdict
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, K: int, a: "List[int]", b: "List[int]"):
    d = defaultdict(int)
    for ai, bi in zip(a, b):
        d[ai] += bi
    for k, v in sorted(d.items()):
        K -= v
        if K <= 0:
            print(k)
            return
    assert False


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


if __name__ == '__main__':
    main()

Solution (Python):
N, K = map(int, input().split())
li = sorted([tuple(map(int, input().split())) for _ in range(N)])
cnt = 0
for a, b in li:
    cnt += b
    if cnt >= K:
        print(a)
        break

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
  
for k,v in sorted(d.items()):
  if v >= K:
    print(k)
    exit()
  K -= v

Solution (Python):
def main():
  n,k=map(int,input().split())
  ab=sorted([list(map(int,input().split())) for _ in [0]*n],key=lambda x:x[0])
  count=0
  for i in range(n):
    count+=ab[i][1]
    if count>=k:
      print(ab[i][0])
      exit()  
if __name__=='__main__':
  main()

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

a.sort()

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

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

Solution (Python):
n,k=map(int,input().split())
d=dict()
for i in range(n):
  a,b=map(int,input().split())
  if a not in d:
    d[a]=b
  else:
    d[a]+=b
d=list(d.items())
d.sort()
cnt=0
for i in range(n):
  if cnt+d[i][1]<k:
    cnt+=d[i][1]
  else:
    print(d[i][0])
    exit()

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

c = [0 for _ in range(10**5+1)]

for i in range(N) :
    c[a[i]] += b[i]

temp = 0
for i in range(10**5+1) :
    temp += c[i]
    if temp >= K :
        print(i)
        break

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

for _ in range(N):
	a, b = map(int, input().split())
	lst.append([a, b])
	
lst.sort(key = lambda x : -x[0])

tot = 0
while True:
	val, num = lst.pop()
	tot += num
	if tot >= K:
		print(val)
		break

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,K=MI()
    ab=[[0,0] for _ in range(N)]
    for i in range(N):
        ab[i][0],ab[i][1]=MI()
        
    ab.sort()
    
    ans=0
    temp=0
    for i in range(N):
        temp+=ab[i][1]
        if  temp>=K:
            ans=ab[i][0]
            break
        
    print(ans)
        

main()

Solution (Python):
N,K=map(int,input().split())
listA=[0]*10**5
for z in range(N):
    a,b=map(int,input().split())
    listA[a-1]+=b
count=0
y=0
while count<=10**5-1:
    y+=listA[count]
    if y>=K:
        print(count+1)
        break
    else:
        count+=1

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

    d[a] += b
for i in range(len(d)):
    k -= d[i]
    if k <= 0:
        print(i)
        break

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

    d[a] += b
for i in range(len(d)):
    k -= d[i]
    if k <= 0:
        print(i)
        break

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

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

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

ab.sort()
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())
c=[0]*(10**5+1)
for i in range(n):
    a,b=map(int,input().split())
    c[a]+=b
tmp=0
for i in range(10**5+1):
    tmp+=c[i]
    if tmp>=k:
        print(i)
        break

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

nums = []
for _ in range(n):
  ab = list(map(int, input().split()))
  nums.append(ab)
sn = sorted(nums)

i = 0
while k > 0:
  if sn[i][1] < k:
    k -= sn[i][1]
  else:
    print(sn[i][0])
    break
  i += 1

Solution (Python):
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7


N, K = MI()
AB = [tuple(MI()) for _ in range(N)]
AB.sort()

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

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

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

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

ab.sort()

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

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

for i, x in enumerate(res):
    if k>x:
        k -= x
    else:
        print(i)
        exit()

Solution (Python):
N,K=map(int,input().split())
X=[]
for i in range (N):
	A=list(map(int,input().split()))
	X.append(A)
Y=sorted(X, key=lambda x:x[0])
tmp=0
for i in range (len(Y)):
	M=Y[i][1]
	tmp+=int(M)
	if tmp>=K:
		print(Y[i][0])
		exit()

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

n = 0
for i in range(N):
  if n + ab[i][1] < K:
    n += ab[i][1]
  else:
    print(ab[i][0])
    break

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

while AB:
    a, b = AB.pop()
    K -= b
    if K <= 0:
        ans = a
        break

print(ans)

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

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

if __name__=="__main__":
    main()

Solution (Python):
def main():
    N, K = (int(i) for i in input().split())
    A = []
    B = []
    from bisect import bisect_left
    AB = [[int(i) for i in input().split()] for j in range(N)]
    AB.sort()
    A = [a[0] for a in AB]
    B = [a[1] for a in AB]
    from itertools import accumulate
    B = list(accumulate(B))
    idx = bisect_left(B, K)
    
    print(A[idx])


if __name__ == '__main__':
    main()

Solution (Python):

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

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

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

from collections import defaultdict
from bisect import insort_left

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

L_sorted = sorted(L.items(), key=lambda x:x[0])

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

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

Solution (Python):
N, K = map(int, input().split())
from collections import defaultdict
D = defaultdict(int)
for _ in range(N):
    a, b = map(int, input().split())
    D[a] += b
for k,v in sorted(D.items(), key=lambda x:x[0]):
    K -= v
    if K <= 0:
        print(k)
        exit()

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

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

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

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

Solution (Python):





import collections
import sys

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n, k = list(map(int,ipti().split()))
    nn = [0] * (10**5 + 1)

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

    cnt = 0
    for i in range(10**5 + 2):
        cnt += nn[i]
        if cnt >= k:
            print(i)
            sys.exit()

if __name__ == '__main__':
    main()

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

    for num in nums:
        if num[1] >= k:
            print(num[0])
            break
        else:
            k -= num[1]

main()

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

Solution (Python):
from collections import defaultdict

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


dd = defaultdict(int)

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

cnt = 0
for key, v in sorted(dd.items()):
    cnt += v
    if k <= cnt:
        print(key)
        break

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

Solution (Python):
n, k = [int(i) for i in input().split()]
cnt = [0] * int(10e5)
for i in range(n):
    a, b = [int(i) for i in input().split()]
    cnt[a] += b

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

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

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

cnt = 0 
for i in range(100001):
    if cnt < k  and cnt + count[i] >=k :
        print(i+1)
        break
    cnt +=count[i]

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

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

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

for i in range(1, 10**5+1):
    sum_d += d[i]
    if(sum_d >= K):
        print(i)
        break

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

Solution (Python):
N, K = [int(i) for i in input().split()]
ab = [[int(i) for i in input().split()] for _ in range(N)]
ab.sort(key=lambda x: x[0])
for a, b in ab:
    K -= b
    if K <= 0:
        print(a)
        break

Solution (Python):
n,k=map(int,input().split())
num=[list(map(int,input().split())) for i in range(n)]
num.sort(key=lambda s:s[0])
for i in range(n):
    a,b=num[i][0],num[i][1]
    if k-b>0:
        k-=b
    else:
        print(a)
        break

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

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

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

while K-AB[i][1]>0:
    K -= AB[i][1]
    i += 1

print(AB[i][0])

Solution (Python):
def main():
    operation, target = map(int, input().split())
    count = [0] * (10 ** 5 + 1)
    for _ in range(operation):
        a, b = map(int, input().split())
        count[a] += b
    for i in range(1, 10 ** 5 + 2):
        if target <= count[i]:
            print(i)
            break
        else:
            target -= count[i]


if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict
d = defaultdict(int)

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

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

d_sorted = sorted(d.items())
cnt = 0
for k,v in d_sorted:
  cnt += v
  if cnt >= K:
    ans = k
    break

print(ans)

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

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

Solution (Python):

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

n, k = map(int, input().split())
nums = [list(map(int, input().split())) for _ in range(n)]
nums.sort()
i = 0
for a, b in nums:
    i += b
    if i >= k:
        print(a)
        exit(0)

Solution (Python):
n, k = map(int, input().split())
ab = []
for _ in range(n):
    a, b = map(int, input().split())
    ab.append([a, b])
ab.sort()
cnt = 0
for i, v in ab:
    cnt += v
    if cnt < k:
        pass
    else:
        print(i)
        break

Solution (Python):
def solve():
    N, K = [int(_) for _ in input().split()]
    AB = [[int(_) for _ in input().split()] for i in range(N)]
    AB.sort()
    k = 0
    for a, b in AB:
        k += b
        if K <= k:
            return a

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

Solution (Python):
N,K=map(int,input().split())
cnt=[0]*100001
for i in range(N):
    a,b=map(int,input().split())
    cnt[a]+=b
ans=0
tmp=0
for i in range(100001):
    tmp+=cnt[i]
    if(tmp>=K):
        ans=i
        break
print(ans)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

b = [] 
a = [] 

lst1 = [list(map(int,readline().split())) for i in range(n)]
lst1.sort()
for i,j in lst1:
    b.append(j)
    a.append(i)

for i in range(1,n):
    b[i] += b[i-1]

for i in range(n):
    if b[i] >= k:
        print(a[i])
        exit()

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

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

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

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


a.sort()

count=0
i=0
while count<k:
    count+=a[i][1]
    i+=1

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

Solution (Python):
import numpy as np
N, K = map(int, input().split())
A = np.array([0] * (10**5 + 1))
for _ in range(N):
    a, b = map(int, input().split())
    A[a] += b
cumsum = A.cumsum()
ans = (cumsum >= K).nonzero()[0].min()
print(ans)

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
d = list(d.items())
d = sorted(d, key=lambda x: x[0])
cnt = 0
for v, count in d:
    cnt += count
    if cnt >= K:
        print(v)
        exit()

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

n = 0
for x in sorted(dic.keys()):
    n += dic[x]
    if K <= n:
        print(x)
        exit()

Solution (Python):
N,K=map(int,input().split())
a =[0]*N
b =[0]*N
for i in range(0,N):
    a[i],b[i] =map(int,input().split())
c=[0]*(10**6)
for i in range(0,N):
    c[a[i]]=c[a[i]]+b[i]
s=0
i=1
while s<K:
    s=s+c[i]
    x=i
    i=i+1
print(x)