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, stdout
from collections import defaultdict
def readLine_int_list():return list(map(int, stdin.readline().split()))
def main():
    n,k = readLine_int_list()
    
    l = defaultdict(lambda: 0)
    for i in range(n):
        a,b =readLine_int_list()
        l[a] += b
    
    cnt = 0
    for key in sorted(l.keys()):
        val = l[key]
        cnt += val
        if cnt >= k:
            print(key)
            break


if __name__ == "__main__":
    main()

Solution (Python):
N , K = map(int,input().split())
cnt =0
get_val = [[0,0]]*N
for i in range(N):
    get_val[i] = list(map(int,input().split()))
get_val.sort()

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

Solution (Python):
cnt_a = [0] * 100001

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

cnt = 0
for n in range(100001):
  cnt += cnt_a[n]
  if cnt >= K:
    print(n)
    import sys
    sys.exit(0)

Solution (Python):
from collections import defaultdict as dd
import sys
input = sys.stdin.readline

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

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

d = sorted(d.items())
for i,j in d:
    K -= j
    if K <= 0:
        print(i)
        break

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

d = sorted(list(d.items()))

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

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

ab.sort()

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

Solution (Python):
N, K = [int(i) for i in input().split()]
ans = []
A = [[]*2]*N
num = 0
for i in range(N):
    A[i] = [int(i) for i in input().split()]
A.sort()
i = 0
while num < K:
    num += A[i][1]
    i += 1

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

Solution (Python):
col = {}
N, K = [int(i) for i in input().split()]
for _ in range(N):
	a_i, b_i = [int(i) for i in input().split()]
	if not a_i in col:
		col[a_i] = b_i
	else:
		col[a_i] += b_i

count = 0
for i in sorted(col.items()):
	count += i[1]
	if count >= K:
		print(i[0])
		break

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()
i = 0
cnt = 0
ans = -1
while True:
    a, b = l[i]
    K -= b
    if K <= 0:
        ans = a
        break

    i += 1

print(ans)

Solution (Python):
import sys
d = [0] * 10**5
N, K = [int(x) for x in sys.stdin.readline().split()]

for i in range(N):
    a, b = [int(x) for x in sys.stdin.readline().split()]
    d[a-1] += b
    
cnt = 0

for i, j in enumerate(d):
    cnt += j
    if cnt >= K:
        print(i+1)
        break

Solution (Python):
import sys
import bisect

N, K = map(int, sys.stdin.readline().split())
d = []


for i in range(N):
    a, b = map(int, sys.stdin.readline().split())
    d.append([a,b])

d.sort()

l = [0] * N
l[0] = d[0][1]

for i in range(1, N):
    l[i] = d[i][1]+ l[i-1]

pos = bisect.bisect_left(l, K)
print(d[pos][0])

Solution (Python):
import bisect

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


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

d.sort()

l = [0] * N
l[0] = d[0][1]

for i in range(1, N):
    l[i] = d[i][1]+ l[i-1]

pos = bisect.bisect_left(l, K)
print(d[pos][0])

Solution (Python):
n,k=[int(x) for x in input().split()]
s=[]
for i in [None]*n:
    a,b=[int(x) for x in input().split()]
    s.append((a,b))
s=sorted(s,key=lambda x : x[0])
for i in s:
    if i[1]>=k:
        print(i[0])
        break
    else:
        k-=i[1]

Solution (Python):
from collections import defaultdict


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

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

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


if __name__ == "__main__":
    main()

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

l = []

for i in range(N):
    a, b = map(int, input().split())
    l.append((a,b))
def c(x):
    return  x[0]
l = sorted(l, key=c)
t = 0
for a,b in l:
    t2 = t
    t += b
    if t2 <= K and t >= K:
        break

print(a)

Solution (Python):
n, k = map(int, input().split())
dic = {}
lst = []
ans = 0
for i in range(n):
    a, b = map(int, input().split())
    if (a in dic)==False:
        dic[a] = b
        lst.append(a)
    else:
        dic[a] += b
lst.sort()

for i in range(len(dic)):
    if k > (dic[lst[i]] + ans):
        ans += dic[lst[i]]
    else:
        ans = lst[i]
        break
print(ans)

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

i = 0
for a, b in sorted(m.items()):
    i += b
    if i >= k:
        print(a)
        break

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

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

d = dict()

for i in range(N):
    a, b = list(map(int, input().split(" ")))
    if a in d:
        d[a] = d[a] + b
    else:
        d[a] = b
    
ans_sum = 0

for key in sorted(d.keys()):
    ans_sum += d[key]
    if (ans_sum) >= K:
        print(key)
        break

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

Solution (Python):
def main():
    N, K = list(map(int, input().strip().split()))
    num_counts = {}
    for _ in range(N):
        a, b = list(map(int, input().strip().split()))
        if a in num_counts:
            num_counts[a] += b
        else:
            num_counts[a] = b

    num_counts = sorted(num_counts.items(),
                        key=lambda x: x[0])
    for n, c in num_counts:
        if K - c <= 0:
            print(n)
            break
        K -= c

if __name__ == '__main__':
    main()

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

    total = 0
    for k, v in sorted(d.items()):
        if total < K <= total + v:
            print(k)
            return
        total += v


if __name__ == '__main__':
    main()

Solution (Python):
n, k = map(int, input().split(" "))
 
nums=[]
for i in range(0, n):
    a, b = map(int, input().split(" "))
    nums.append([a, b])

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

sum = 0
for i in range(0, n):
    sum +=nums[i][1]
    if sum >= k:
        print(nums[i][0])
        break

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

Solution (Python):

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

A = []
for i in range(n):
    a,b = list(map(int, input().split())) 
    A.append([a,b])
    
A.sort(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):

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

A = []
for i in range(n):
    a,b = list(map(int, input().split())) 
    A.append([a,b])
    
A.sort(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):
N, K = list(map(int, input().split(" ")))

nums = {}

for _ in range(N):
    a, b = list(map(int, input().split(" ")))
    
    if a in nums:
        nums[a] += b
    else :
        nums[a] = b
        
acc = 0
for key in sorted(nums.keys()):
    acc += nums[key]
    if acc >= K:
        print(key)
        break

Solution (Python):
import sys

N, K = (int(i) for i in raw_input().split())
ab_list = [[int(i) for i in raw_input().split()] for i in range(N)]
ab_list = sorted(ab_list, key=lambda ab: ab[0])

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

Solution (Python):

import math
import sys
import itertools
import numpy as np

n, k = map(int, input().split())
memo = np.zeros(100010, dtype=np.int)

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

s = 0
for i in range(len(memo)):
    s += memo[i]
    if k <= s:
        print(i)
        exit()

Solution (Python):
n,k=map(int,input().split())
arr=[]
for _ in range(n):
    arr.append(tuple(map(int,input().split())))
arr.sort(key=lambda x:x[0])
cur=0
for pair in arr:
    cur+=pair[1]
    if cur>=k:
        print(pair[0])
        break

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

for i in range(N):
    x,y = (map(int, input().split()))
    l.append((x,y))
l.sort()
cnt = 0
ans = 0
index = 0
while cnt < K:
    ans = l[index][0]
    cnt += l[index][1]
    index += 1

print(ans)

Solution (Python):
N,K = map(int,input().split())
list1 = []
for i in range(N):
    list1.append(list(map(int,input().split())))
num = [0]*(10**5+1)
for j in range(N):
    num[list1[j][0]] += list1[j][1]
c = 0
d = 0
for k in range(10**5+1):
    c += num[k]
    if c >= K:
        d = k
        break
print(d)

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

Solution (Python):


def get_ans():
    n, k = map(int, raw_input().split())
    src = []
    for i in range(n):
        src.append(map(int, raw_input().split()))
    src.sort(key=lambda x:x[0]) 

    cnt = 0
    for a, b in src:
        cnt = cnt + b
        if cnt >= k:
            return a
            break
    return src[n-1][1]

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

Solution (Python):
import sys



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

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

s = 0
for a, b in operations:
    s += b
    if k <= s:
        print(a)
        break

Solution (Python):
N,K = [int(i) for i in input().split(" ")]
num = [0]*((10**5)+1)
for i in range(N):
    a_k,b_k = [int(i) for i in input().split(" ")]
    num[a_k] += b_k
for i, v in enumerate(num): 
    K = K - v
    if K<=0:
        print(i)
        break

Solution (Python):
N,K=map(int,raw_input().split())
K-=1
s={}
for i in range(N):
    a,b=map(int,raw_input().split())
    if a in s:
        s[a] += b
    else:
        s[a] = b

c=sorted(s.items())

index = 0
for i in c:
    index += i[1]
    if K<index:
        print i[0]
        break

Solution (Python):



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


def solve(k,l):
    for i in range(len(l)):
        k -= l[i]
        if (k <= 0):
            return i
    return 0


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

print(str(solve(K,list)))

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

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

for m in m_list:
    count += m[1]
    if count >= K:
        print(m[0])
        break

Solution (Python):


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

A = []
table = []

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

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

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

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

Solution (Python):
import heapq

def solve():
  firstline = raw_input().split(' ')
  N = int(firstline[0])
  K = int(firstline[1])

  heap = []
  for i in range(N) :
    ar = raw_input().split(' ')
    a = int(ar[0])
    b = int(ar[1])
    heapq.heappush(heap, (a, b))

  count = 0
  while len(heap) > 0 :
    t = heapq.heappop(heap)
    count += t[1]
    if (count >= K) : return t[0]
  return -1

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

Solution (Python):
from sys import stdin
n,k = map(int,stdin.readline().split())
a = []
for _ in xrange(n):
    x,y = map(int,stdin.readline().split())
    a.append( (x,y) )
a.sort()
cur = 0
for x,y in a:
    cur += y
    if cur >=k:
        break
print x

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

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

Solution (Python):
import sys

def solve():
    N, K = map(int, sys.stdin.readline().split())
    p = [tuple(map(int, sys.stdin.readline().split())) for i in range(N)]

    p.sort()

    cnt = 0

    for ai, bi in p:
        cnt += bi

        if cnt >= K:
            print(ai)
            return

if __name__ == '__main__':
    solve()

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

p.sort()

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

Solution (Python):
n, k = map(int, input().split())
data = []
for i in range(n):
    data.append( list(map(int, input().split())) )
data.sort( key = lambda x: x[0] )
pos = 0
for val in data:
    pos += val[1]
    if k <= pos:
        print(val[0])
        break

Solution (Python):


l = 10 ** 5
num = [0] * (l + 1)
n, k = map(int, raw_input().split())

for _ in xrange(n):
    a, b = map(int, raw_input().split())
    num[a] += b

for i in xrange(1, l+1):
    k -= num[i]
    if k <= 0:
        print i
        break

Solution (Python):
tmp = input().split(" ")
K = int(tmp[1])
 
num = [0 for i in range(10**5)]
for i in range(int(tmp[0])):
    tmp = input().split(" ")
    num[int(tmp[0])-1] += int(tmp[1])
    
tmp = 0
i = 0
while tmp < K:
    tmp = tmp + num[i]
    if tmp >= K:
        print(i+1)
    i = i + 1

Solution (Python):
tmp1 = list(map(int, input().split(" ")))
num = [0 for i in range(10**5)]
for i in range(tmp1[0]):
    tmp = list(map(int, input().split(" ")))
    num[tmp[0]-1] += tmp[1]
tmp = 0
i = 0
while tmp < tmp1[1]:
    tmp = tmp + num[i]
    if tmp >= tmp1[1]:
        print(i+1)
    i = i + 1

Solution (Python):

l1 = list(map(int, input().split()))
N = l1[0]
K = l1[1]


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

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

x = 0
for key, value in dic: 
	x += value
	if x >= K:
		print(str(key))
		break

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

Solution (Python):
if __name__ == '__main__':
    N, K = map(int, input().split())
    ab = []
    for i in range(N):
        ab.append(list(map(int, input().split())))
    ab.sort(key=lambda x: x[0])
    count = 0
    for i in ab:
        count += i[1]
        if K <= count:
            print(i[0])
            break

Solution (Python):
tmp = input().split(" ")
N = int(tmp[0])
K = int(tmp[1])

num = [0 for i in range(10**5)]
for i in range(N):
    tmp = input().split(" ")
    a = int(tmp[0])
    b = int(tmp[1])
    num[a-1] = num[a-1] + b

tmp = 0
i = 0
while tmp < K:
    tmp = tmp + num[i]
    if tmp >= K:
        print(i+1)
    i = i + 1

Solution (Python):
a,b=map(int,input().split())
alllist=[]
goukei=1
for i in range(a):
    tmplist=list(map(int,input().split()))
    alllist.append(tmplist)

alllist2=sorted(alllist)
for i in range(a):
    goukei=alllist2[i][1]+goukei
    if goukei>b:
        owari=alllist2[i][0]
        break
    else:
        pass

print(owari)

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

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

array.sort()
K -= 1
for tup in array:
    if K < tup[1]:
        print(tup[0])
        break
    else:
        K -= tup[1]

Solution (Python):
from collections import defaultdict
n,k = map(int, raw_input().split())
d = defaultdict(int)
for _ in range(n):
    a,b = map(int, raw_input().split())
    d[a] += b
s = 0
for p in sorted(d.keys()):
    if k <= s + d[p]:
        print p
        break
    s += d[p]

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

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

Solution (Python):


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

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

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

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

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

Solution (Python):
N,K = map(int, input().split())
a = []
d = {}
for i in range(N):
    ls = list(map(int, input().split()))
    if ls[0] in d:
        d[ls[0]] = d[ls[0]] + ls[1]
    else:
        d[ls[0]] = ls[1]
d = sorted(d.items())
cnt = 0
for t in d:
    cnt += t[1]
    if cnt >= K:
        print(t[0])
        break

Solution (Python):
import sys
from collections import defaultdict

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

cnt = 0
for x in sorted(di.keys()):
    cnt += di[x]
    if cnt >= k:
        print(x)
        sys.exit()

Solution (Python):
if __name__ == "__main__":
    N,K = map(int, input().split())
    deg = [0 for x in range(10 ** 5 + 1)]
    for x in range(N):
        a,b = map(int, input().split())
        deg[a] += b
    res = 0
    for i,val in enumerate(deg):
        res += val
        if (res >= K):
            print (i)
            break

Solution (Python):
N, K = map(int, raw_input().split())
V = {}
for i in range(N):
    a, b = map(int, raw_input().split())
    if not a in V:
        V[a] = 0
    V[a] += b
for v, num in sorted(V.items()):
    K -= num
    if K <= 0:
        print v
        break

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

num = 0
for ele in sorted(counter.items()):
    num += ele[1]
    if k <= num:
        print ele[0]
        break

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

L = []
for i in range(100000):
	L.append(0)

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

sm = 0
for i in range(100000):
	sm += L[i]
	if sm >= K:
		print(i + 1)
		break

Solution (Python):
n,k=map(int,input().split())
d=[0]*100001
for i in range(n):
	a,b=map(int,input().split())
	d[a]+=b
cnt=0
for i in range(100001):
	if cnt+d[i]>=k:
		print(i);quit()
	cnt+=d[i]

Solution (Python):
n,k=map(int,input().split())
d={}
for i in range(n):
	a,b=map(int,input().split())
	if a in d:d[a]+=b
	else:d[a]=b
cnt=0
d=sorted(tuple(d.items()),key=lambda a:a[0])
for i in d:
	if cnt+i[1]>=k:
		print(i[0]);quit()
	cnt+=i[1]

Solution (Python):


n,k=map(int,raw_input().split())
l=[]
for i in xrange(n):
 a,b=map(int,raw_input().split())
 l.append((a,b))
l.sort()
s=0
for i in xrange(n):
 s+=l[i][1]
 if s>=k:
  print l[i][0]
  break

Solution (Python):
def c():
    n, k = map(int, input().split())
    U = []
    for i in range(n):
        U.append(tuple(map(int, input().split())))
    U = sorted(U, key=lambda i: i[0])
    
    for i in U:
        k -= i[1]
        if k <= 0:
            print(i[0])
            break

c()

Solution (Python):
def c():
    n, k = map(int, input().split())
    U = []
    for i in range(n):
        U.append(tuple(map(int, input().split())))
    U = sorted(U, key=lambda i: i[0])
    
    for i in U:
        if k <= i[1]:
            print(i[0])
            break
        k -= i[1]
    else:
        print(U[-1][0])
        
        
        
        

c()

Solution (Python):


N, K = map(int, raw_input().split())
R = [0] * (10**5+10) 

for i in xrange(N):
     ia, ib = map(int, raw_input().split())
     R[ia] += ib

k = 0
c = 0
while k < K:
    c += 1
    k += R[c]
print c

Solution (Python):
import sys

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

    cnt = [0]*(10**5 + 1)

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

    tot = 0

    for i, cnti in enumerate(cnt):
        tot += cnti

        if tot >= K:
            print(i)
            return

if __name__ == '__main__':
    solve()

Solution (Python):
import sys
r = [0]*(100000+1)
n,k = [int(x) for x in sys.stdin.readline().split()]
for i in range(n):
	a, b = [int(x) for x in sys.stdin.readline().split()]
	r[a] += b
c = 0
for i,j in enumerate(r):
	c += j
	if c >= k:
		print(i)
		break

Solution (Python):
import sys
r = [0]*100000
n,k = [int(x) for x in sys.stdin.readline().split()]
for i in range(n):
	a, b = [int(x) for x in sys.stdin.readline().split()]
	r[a-1] += b
c = 0
for i,j in enumerate(r):
	c += j
	if c >= k:
		print(i+1)
		break

Solution (Python):
n,k = map(int,raw_input().split())
l = []
s = list()
for i in range(n):
    v,count = map(int,raw_input().split())
    l.append((count,v))

l = sorted(l, key=lambda x: x[1])

countTmp = 0
for count,v in l:
    countTmp = countTmp + count
    if k <= countTmp:
       print v
       break

Solution (Python):

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


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


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


count = 0
for a,b in numList:
	count += b
	if count>=K:
		print(a)
		quit()

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

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

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

Solution (Python):
import numpy as np

L = np.zeros(10**5).astype(int)
N, K = list(map(int, input().split(' ')))
for _ in range(N):
    a, b = list(map(int, input().split(' ')))
    L[a-1] += b
    
tot = 0
for i in range(10**5):
    tot += L[i]
    if tot >= K:
        print(i+1)
        break

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

count=0
for i in range(n):
    count+=list[i][1]
    if count>=k: ans=list[i][0]; break


print(ans)

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

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

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

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

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

Solution (Python):

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

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

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

Solution (Python):
import numpy as np

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

a = []
for i in range(N):
    a.append(list(map(int,input().split())))
a = sorted(a,key = lambda i:i[0])
sum = 0
b = 0

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

print (b)

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

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

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

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

Solution (Python):

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

Solution (Python):

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

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

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

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

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

Solution (Python):

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

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

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


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


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

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

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


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

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

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

print(ab[lb][0])

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

Solution (Python):


from collections import defaultdict

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

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

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

        if count >= K:
            print (key)
            break

Solution (Python):


N,K=map(int,raw_input().split())
arr=[[0,0]]*N
for i in range(N):
    arr[i]=map(int,raw_input().split())


arr=sorted(arr)


sum=0
for i in range(N):

    sum=sum+arr[i][1]

    if sum>=K:

        print arr[i][0]
        break

Solution (Python):
from operator import itemgetter

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

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

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

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

main()

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


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

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

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

Solution (Python):

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

for i in xrange(N):
    a,b=map(int,raw_input().split())

    if a in d:
        d[a] = d[a] + b
    else:
        d[a]=b











aa=None
cnt=0

for k in sorted(d):
    aa=k
    cnt+=d[k]

    if cnt>=K:
        break
print aa

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
keys = list(dic.keys())
keys.sort()

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

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

    l = []

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

    l.sort()

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

if __name__ == '__main__':
    main()