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())
A = [list(map(int,input().split())) for _ in range(N)]
A = sorted(A,key=lambda x:x[0])
cnt = 0
i = 0
while K>cnt:
    cnt += A[i][1]
    i += 1
print(A[i-1][0])

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

result = {}
for _ in range(N):
    a, b = [int(x) for x in input().split()]
    if a in result:
        result[a] += b
    else:
        result[a] = b

result = sorted(result.items())

now = 0
for key, value in result:
    now += value

    if now >= K:
        print(key)
        exit()

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

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

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

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

Solution (Python):
N, K = map(int,input().split())
L = []
for k in range(N):
    L.append(list(map(int,input().split())))
L = sorted(L)
for e in L:
    K -= e[1]
    if K <= 0:
        print(e[0])
        exit(0)

Solution (Python):
N, K, *AB = map(int, open(0).read().split())
li = [(a, b) for a, b in zip(*[iter(AB)] * 2)]
li.sort()
for a, b in li:
    if K > b:
        K -= b
    else:
        print(a)
        break

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

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

q=[]
for _ in range(n):
    a,b=map(int,input().split())
    heapq.heappush(q,(a,b))

while k>0:
    a,b=heapq.heappop(q)
    k-=b

print(a)

Solution (Python):
def main():
    n, k = map(int, input().split())
    inlis = list()

    for _ in range(n):
        alis = list(map(int, input().split()))
        inlis.append(alis)
    inlis.sort()
    tmp = k
    i = 0

    while tmp > 0:
        tmp -= inlis[i][1]

        if tmp > 0:
            i += 1    
        else:
            print(inlis[i][0])
            exit()



if __name__ == "__main__":
    main()

Solution (Python):
n, k = list(map(int, input().split()))
c = {}
cnts = []

for i in range(n):
    a, b = list(map(int, input().split()))
    if a in c:
        cnts[c[a]][1] += b
    else:
        c[a] = len(cnts)
        cnts.append([a, b])

cnts = sorted(cnts, reverse=True)

s = 0
while True:
    si = cnts.pop()
    s += si[1]

    if s >= k:
        print(si[0])
        break

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

for d in a:
  if (ans+d[1])>=k:
    ans1=d[0]
    break
    
  else:
    ans+=d[1]
    
print(ans1)

Solution (Python):
import itertools

n, k = list(map(int, input().split()))
ab = [[] for _ in range(n)]
for i in range(n):
    ab[i] = list(map(int, input().split()))
ab.sort(key=lambda x: x[0])
az, bz = list(zip(*ab))

accb = list(itertools.accumulate(bz))
idx = 0
for j, v in enumerate(accb):
    if k <= v:
        idx = j
        break
print(az[idx])

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

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

for i in x:
  k-=i[1]
  if k<=0:
    print(i[0])
    exit()

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

Solution (Python):
import sys












stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    
    n,k = map(int, stdin.readline().rstrip().split())
    
    
    
    
    
    a = [0]*(10**5+1)
    m = 0
    for i in range(n):
        A,B = map(int, stdin.readline().rstrip().split())
        a[A] += B
        m = max(m,A)
    j = 0
    for i in range(10**5):
        j += a[i]
        if j >= k:
            print(i)
            exit()
    print(m)



if __name__ == '__main__':
    solve()

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

Solution (Python):
N, K = [int(x) for x in input().split(" ")]
 
placed = 0
elm = []
for i in range(N):
  a, b = input().split(" ")
  elm.append({
    "order": i + 1,
    "element": int(a),
    "count": int(b)
  })

elm.sort(key=lambda e: (e["element"], e["order"]))
for i in range(len(elm)):
  e = elm[i]
  placed += e["count"]
  if placed >= K:
    print(e["element"])
    break

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

d = {}
for _ in range(n):
  a,b = map(int, input().split())
  if a in d: d[a] += b
  else: d[a] = b
    
for x,y in sorted(d.items(), key=lambda x: x[0]):
  k -= y
  if k <= 0:
    print(x)
    exit()

Solution (Python):
def resolve():
    n, k = map(int, input().split())
    input_list = []
    for _ in range(n):
        ai, bi = map(int, input().split())
        input_list.append([ai, bi])

    input_list.sort()
    count_dic = {}
    prev_max = 0
    for key, value in input_list:
        if key in count_dic.keys():
            count_dic[key] += value
        else:
            count_dic[key] = value + prev_max
        prev_max = count_dic[key]

        if count_dic[key] >= k:
            print(key)
            return
          
resolve()

Solution (Python):
n, k = map(int, input().split())
d = {}
for _ in range(n):
    a, b = map(int, input().split())
    if a in d:
        d[a] += b
    else:
        d[a] = b
d = dict(sorted(d.items()))
cnt = 0
for key, v in d.items():
    cnt += v
    if cnt >= k:
        print(key)
        break

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])
        break

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

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

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

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

AB.sort()

cnt=0
for i in range(N):
    cnt+=AB[i][1]

    if cnt>=K:
        ans=AB[i][0]
        break

print(ans)

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

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

Solution (Python):


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

for k, v in sorted(num.items()):
    cnt += v
    if K <= cnt:
        print(k)
        exit()

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

c=0
for ab in AB:
  c+=ab[1]
  if c>=K:
    exit(print(ab[0]))

Solution (Python):


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

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

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

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

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
offset = 10**6

def main():
    N, K = map(int, input().split())
    pair = []
    for _ in range(N):
        a, b = map(int, input().split())
        pair.append((a * offset + b))
    pair.sort()
    num = 0
    for val in pair:
        a, b = val // offset, val % offset
        if num + b < K:
            num += b
            continue
        print(a)
        return


    for p in path: print(p)


if __name__ == "__main__":
    main()

Solution (Python):
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
    
v=0
for i in range(k):
    v+=ans[i]
    if ans[i]==0:
        i-=1
    if v>=k:
        a=i
        break
    
print(a)

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(key=lambda x: x[0])

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

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

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

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

ab = sorted(ab)
cum = 0
for i in range(N):
  cum += ab[i][1]
  if cum >= K:
    print(ab[i][0])
    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(key=lambda x: x[0])

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

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

Solution (Python):
N, K = list(map(int,input().split()))
A = [list(map(int,input().split())) for _ in range(N)]
cnt = 0
A = sorted(A, key = lambda x: x[0])
for i in range(N):
    cnt += A[i][1]
    if cnt >= K:  
        print(A[i][0])
        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(key=lambda x: x[0])

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

Solution (Python):
n,k=map(int,input().split())
l=[[*map(int,input().split())] for i in range(n)]
l.sort(key=lambda x:x[0])
for i,j in l:
    k-=j
    if k<=0:
        print(i)
        break

Solution (Python):
N,K=map(int,input().split())
list=[0 for i in range(100001)]
for i in range(N):
  a,b=map(int,input().split())
  list[a]+=b

sum=0
for i in range(100001):
  sum+=list[i]
  if(sum>=K):
    print(i)
    break

Solution (Python):
from collections import Counter
N, K = map(int, input().split())

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

x = list(cnt.items())
x.sort()

now = 0
for k, v in x:
    now += v
    if K <= now:
        print(k)
        break

Solution (Python):
n,k = map(int,input().split())
array = [0]*(10**5+1)
for i in range(n):
    a,b = map(int,input().split())
    array[a] += b
for i in range(1,10**5+1):
    k -= array[i]
    if k <= 0:
        print(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 = sorted(l)
c = 0
i = 0
while c < k:
  c += l[i][1]
  i += 1

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

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


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


t = 0
for i in sorted(d.items(), key=lambda x:x[0]):
  t += i[1]
  if t >= k:
    print(i[0])
    exit()

Solution (Python):
import math

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

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

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

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

Solution (Python):
N,K=map(int,input().split())
T={}
for _ in range(N):
    a,b=map(int,input().split())
    if a in T:
        T[a]+=b
    else:
        T[a]=b
U=sorted(T)

for a in U:
    if T[a]>=K:
        print(a)
        break
    else:
        K-=T[a]

Solution (Python):
import sys

N,K=map(int,input().split())
D=dict()
for i in range(N):
  a,b=map(int,input().split())
  try:
    D[a]+=b
  except:
    D[a]=b

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


for k,v in D:
  K-=v
  if K<=0:
    print(k)
    break

Solution (Python):
def solve():
  ans = 0
  cnt = 0
  N, K = map(int, input().split())
  A = [list(map(int, input().split())) for _ in range(N)]
  A.sort()
  for a,b in A:
    cnt += b
    if cnt>=K:
      ans = a
      break
  return ans
print(solve())

Solution (Python):
n,k=map(int,input().split())
B=[0]*100001

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

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

Solution (Python):
import sys
import collections
import bisect


def main():
    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(len(ab)):
        cnt += ab[i][1]
        if cnt >= k:
            print(ab[i][0])
            return


if __name__ == '__main__':
    main()

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

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
sm=0
for i in range(1,10**5+1):
  sm+=l[i]

  if sm>=k:
    print(i)
    break

Solution (Python):
N,K = (int(T) for T in input().split())
Ins = [[] for T in range(0,N)]
for TN in range(0,N):
    Ins[TN] = [int(T) for T in input().split()]
InsSort = sorted(Ins)
Total = 0
for TN in range(0,N):
    if Total<K<=Total+InsSort[TN][1]:
        print(InsSort[TN][0])
        break
    else:
        Total += InsSort[TN][1]

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

Solution (Python):

(n, k), *q = [[*map(int, i.split())] for i in open(0)]
bucket = [0] * (10**5 + 1)
for a, b in q:
    bucket[a] += b
for n, i in enumerate(bucket):
    k -= i
    if k <= 0:
        print(n)
        break

Solution (Python):
import sys

n, k = map(int, input().split())
element = [None]*n

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

element.sort()

c = 0
for i in range(n):
  c += element[i][1]
  if c >= k:
    print(element[i][0])
    sys.exit()

Solution (Python):

(n, k), *q = [[*map(int, i.split())] for i in open(0)]
q.sort()
for a, b in q:
    k -= b
    if k <= 0:
        print(a)
        break

Solution (Python):






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





mydict_s = sorted(mydict.items(), key=lambda x:x[0])
cnt = 0
for i,items in enumerate(mydict_s):
    cnt += items[1]
    if cnt >= K:
        ans = items[0]
        break
print(ans)

Solution (Python):
a,b=map(int,input().split())
L=list()
s=0
for i in range(a):
  x,y=map(int,input().split())
  L.append([x,y])
L=sorted(L)
for i in range(a):
  s+=L[i][1]
  if s>=b:
    print(L[i][0])
    break

Solution (Python):
from collections import deque
N, K = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(N)]
L.sort(key = lambda x: x[0])
L = deque(L)
while K>L[0][1]:
  K -= L[0][1]
  L.popleft()
print(L[0][0])

Solution (Python):
import sys
N, K = list(map(int, input().split()))
V = [list(map(int, input().split())) for _ in range(N)]
V.sort()
cnt = 0
res = 0
for v in V:
    cnt += v[1]
    if cnt >= K:
        print(v[0])
        sys.exit()

Solution (Python):
n,m = map(int,input().split()); sus = {}
for _ in range(n):
  a,b = map(int,input().split())
  sus[a] = sus[a]+b if a in sus else b
fef = sorted(sus.items()); snaas = 0
for cuc in fef:
  snaas += cuc[1]
  if snaas >= m: print(cuc[0]); exit()

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

arr.sort()
cur =0

for i in range(0 , n):
	if cur + arr[i][1]<k:
		cur = cur+arr[i][1]
	else:
		print(arr[i][0])
		exit()

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

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

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

cnt = 0

for ab in A:
    a = ab[0]
    b = ab[1]

    cnt += b
    if cnt >= K:
        print(a)
        exit()

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

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

Solution (Python):
n, k = [int(x) for x in input().split()]
temp_list = sorted([[int(x) for x in input().split()] for _ in range(n)])
ans = 0
for a, b in temp_list:
    k -= b
    if k <= 0:
        ans = a
        break
print(a)

Solution (Python):


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

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

for a, b in arr:
    k -= b
    if k <= 0:
        print(a)
        break

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, *AB = map(int, read().split())
    vec = [0] * (10 ** 5 + 1)
    for a, b in zip(*[iter(AB)] * 2):
        vec[a] += b

    total = 0
    for i, n in enumerate(vec):
        total += n
        if total >= K:
            ans = i
            break

    print(ans)
    return


if __name__ == '__main__':
    main()

Solution (Python):
import sys
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, *AB = map(int, read().split())
    c = Counter()
    for a, b in zip(*[iter(AB)] * 2):
        c[a] += b

    num = 0
    for k, n in sorted(c.items()):
        num += n
        if num >= K:
            ans = k
            break

    print(ans)
    return


if __name__ == '__main__':
    main()

Solution (Python):

import sys

def main():
    n, k = map(int, input().split())
    ans = [0 for _ in range(10**5+1)]
    for x in sys.stdin.readlines():
        a, b = map(int, x.split())
        ans[a] += b

    cnt = 0
    for i in range(10**5+1):
        cnt += ans[i]
        if cnt >= k:
            print(i)
            exit()

if __name__ == "__main__":
    main()

Solution (Python):
from collections import defaultdict
n,k=map(int,input().split())
dd=defaultdict(lambda: 0)
for i in range(n):
  a,b=map(int,input().split())
  dd[a]+=b
cur_k=k
for k in sorted(dd.keys()):
  v=dd[k]
  cur_k-=v
  if cur_k <= 0:
    print(k)
    exit()

Solution (Python):
n,k = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(n)]
a.sort(key=lambda x:x[0])
ans,i = 0,0
t = 0
while(ans < k):
	ans += a[i][1]
	t = a[i][0]
	i += 1
print(t)

Solution (Python):
n,k = map(int,input().split())
A = []
for _ in range(n):
    a,b = map(int,input().split())
    A.append([a,b])
A.sort()
for a,b in A:
    if k >b:
        k -=b
    else:
        print(a);exit()

Solution (Python):
import collections
[n,k] = [int(i) for i in input().split()]
dic = collections.defaultdict(int)
for i in range(n):
  [a,b] = [int(j) for j in input().split()]
  dic[a] += b
keys = sorted(list(dic.keys()))
tmp = 0
for key in keys:
  tmp += dic[key]
  if k <= tmp:
    print(key)
    break

Solution (Python):
from collections import defaultdict
def main():
    n, k = map(int, input().split())
    D = defaultdict(int)
    for _ in range(n):
        a, b = map(int, input().split())
        D[a] += b
    for d in sorted(D.items(), key = lambda x: x[0]):
        k -= d[1]
        if k <= 0:
            print(d[0])
            break

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.sort()
c = 0
for i in range(N):
    c += ab[i][1]
    if c >= K:
        print(ab[i][0])
        break

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

Solution (Python):
def resolve():
    '''
    code here
    '''

    N, K = [int(item) for item in input().split()]
    queries = [[int(item) for item in input().split()] for _ in range(N)]

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

    temp_que = []
    for num, val in queries:
        temp_que = num
        K -= val
        if K <= 0:
            break

    print(temp_que)

if __name__ == "__main__":
    resolve()

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

def main():
    n,k=map(int,rl().strip().split())
    ints=[list(map(int,rl().strip().split())) for _ in range(n)]
    ints.sort(key=lambda e:e[0])
    s=0
    for e in ints:
        s+=e[1]
        if s>=k:
            print(e[0])
            break

if __name__=='__main__':
    main()

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

L = []
for i in range(10**5+1):
    L.append(0)

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

a = 0
while K > 0:
    a += 1
    K -= L[a]
    
print(a)

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

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

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

c = 0
for v in sorted(d.items()):
    c += v[1]
    if k <= c:
        print (v[0])
        exit ()

Solution (Python):
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

N,K = MI()

from collections import defaultdict

d = defaultdict(int)
for i in range(N):
    a,b = MI()
    d[a] += b

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

a = 0
for b in A:
    if K <= a+d[b]:
        print(b)
        break
    else:
        a += d[b]

Solution (Python):
import heapq
n, k = map(int, input().split())
hq = []
total = 0
for i in range(n):
    a, b = map(int, input().split())
    heapq.heappush(hq, (-a, b))
    total += b

while total >= k:
    a, b = heapq.heappop(hq)
    total -= b

print(abs(a))

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

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

Solution (Python):
def INT():
    return int(input())

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

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

from collections import Counter
N, K = MI()
add = Counter([])

for _ in range(N):
    a, b = MI()
    tmp = add[a]
    add[a] = b
    add[a] += tmp

num = sorted(list(add.keys()))
cnt = 0

for n in num:
    cnt += add[n]
    if cnt >= K:
        print(n)
        break

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

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

Solution (Python):

import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil



import string

from bisect import bisect_left
MOD = int(1e9)+7
INF = float('inf')


def solve():
    
    n, k = [int(x) for x in input().split()]
    d = defaultdict(int)
    for _ in range(n):
        a, b = [int(x) for x in input().split()]
        d[a] += b
    a = [(x, d[x]) for x in d]
    a.sort()
    i = 0
    while k > a[i][1]:
        k -= a[i][1]
        i += 1

    print(a[i][0])

t = 1

for case in range(1,t+1):
    ans = solve()


"""

azyxwvutsrqponmlkjihgfedcb

"""

Solution (Python):
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from bisect import bisect_left

n,k=nii()

l=[]
for i in range(n):
  a,b=nii()
  l.append([a,b])

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

a_l=[]
b_l=[]
for a,b in l:
  a_l.append(a)
  b_l.append(b)

b_rui=[0]
for i in range(1,n+1):
  b_rui.append(b_rui[i-1]+b_l[i-1])
b_rui=b_rui[1:]

inx=bisect_left(b_rui,k)
print(a_l[inx])

Solution (Python):
from collections import defaultdict

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

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

Solution (Python):
from collections import defaultdict

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

nums, numd = set(), defaultdict(int)
for a, b in ab:
    nums.add(a)
    numd[a] += b
for i in sorted(nums):
    k -= numd[i]
    if k <= 0:
        print(i)
        break

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

arrays = []
answer = 0
count = 0

for i in range(100001):
    arrays.append(0)

for i in range(n):
    v = input().split()
    p = int(v[0])
    q = int(v[1])
    arrays[p] += q

for i in range(len(arrays)):
    if not arrays[i] == 0:
        count += arrays[i]
        if k <= count:
            answer = i
            break

print(answer)

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

for n in range(N):
  c+=A[n][1]
  if K<=c:
    print(A[n][0])
    break

Solution (Python):

import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect

sys.setrecursionlimit(10**6)


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


N, K = zz()
A, B = [0]*N, [0]*N

for i in range(N):
    A[i], B[i] = zz()
A, B = zip(*sorted(zip(A, B)))
all_num = 0
for i, b in enumerate(B):
    all_num += b
    if (all_num >= K):
        print(A[i])
        exit()

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

Solution (Python):
import numpy as np


def main():
    n, k = map(int, input().split())
    Counts = [0] * (10**5 + 1)
    for _ in range(n):
        a, b = map(int, input().split())
        Counts[a] += b
    cumsum = np.cumsum(Counts)
    for i in range(10**5+1):
        if cumsum[i] >= k:
            ans = i
            break
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
n,k,*ab = map(int,open(0).read().split())
ab = [(ab[i*2],ab[i*2+1]) for i in range(n)]
ab.sort(key = lambda x:x[0])
c = 0
for i,j in ab:
  c += j
  if c >= k:
    break
print(i)

Solution (Python):

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

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

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

a = sorted(a,key=lambda x:x[0])
ans = 0
for i in range(n):
    ans += a[i][1]
    if ans >= k:
        print(a[i][0])
        exit()

Solution (Python):
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):
  a,b  = ab[i][0],ab[i][1]
  count += b
  if count >= K:
    print(a)
    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()
cnt = 0
ans = 0
i = 0
while cnt < K:
  ans = l[i][0]
  cnt += l[i][1]
  i += 1
print(ans)

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
for k in sorted(d.keys()):
    K -= d[k]
    if K <= 0:
        print(k)
        exit()

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

ans = 0
lis = [0] *(10**5 +1)

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

tmp = 0
for j in range(len(lis)):
    tmp += lis[j]
    if tmp >= k:
        print(j)
        break

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

ans = 0
lis = [0] *(10**5 +1)

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

tmp = 0
for j in range(len(lis)):
    tmp += lis[j]
    if tmp >= k:
        print(j)
        break