Problem:


Score : 300 points

Problem Statement

There is an empty array.
The following N operations will be performed to insert integers into the array.
In the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array.
Find the K-th smallest integer in the array after the N operations.
For example, the 4-th smallest integer in the array \{1,2,2,3,3,3\} is 3.

Constraints

1≤N≤10^5 

1≤a_i,b_i≤10^5 

1≤K≤b_1…+…b_n

All input values are integers.

Input

Input is given from Standard Input in the following format:  

N K
a_1 b_1
:  
a_N b_N

Output

Print the K-th smallest integer in the array after the N operations.  

Sample Input 1

3 4
1 1
2 2
3 3

Sample Output 1

3

The resulting array is the same as the one in the problem statement.

Sample Input 2

10 500000
1 100000
1 100000
1 100000
1 100000
1 100000
100000 100000
100000 100000
100000 100000
100000 100000
100000 100000

Sample Output 2

1



Sample input:
3 4
1 1
2 2
3 3


Sample output:
3

Submission status: Time Limit Exceeded

Solution code:
#ABC061C
N, K = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
ans = []
for i in range(N):
    for _ in range(ab[i][1]):
        ans.append(ab[i][0])
ans.sort()
print(ans[K-1])

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
m = {}
ml = list()

for i in range(n):
    a, b = map(int, input().split())
    if a not in ml:
        ml.append(a)
        
    if m.get(a):
        m[a] += b
    else:
        m[a] = b

ml.sort()
for v in ml:
    if k > m[v]:
        k -= m[v]
    else:
        print(v)
        break

Submission status: Time Limit Exceeded

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

for n in range(1,n+1):
    a,b=map(int,input().split())
    for x in range(1,b+1):
        ans.append(a)

ans=sorted(ans)

print(ans[k-1])

Submission status: Time Limit Exceeded

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

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

ret = []
tb = 0
i = 0
for i in range(n):
    ret.extend([a[i]] * b[i])

ret = sorted(ret)
print(ret[k-1])

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
big_array = []
for i in range(N):
    a,b = map(int,input().split())
    for j in range(b):
        big_array.append(a)
big_array.sort()
print(big_array[K-1])

Submission status: Time Limit Exceeded

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

l=[]
for i in range(n):
  a,b=map(int, input().split())
  l.append([a]*b)
ll=[]
for i in l:
  for j in i:  
    ll.append(j)
 
ll=sorted(ll)
print(ll[k-1])

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
l=[]
for i in range(n):
  a,b=map(int,input().split())
  for j in range(b):
    l.append(a)
l=sorted(l)
print(l[k-1])

Submission status: Time Limit Exceeded

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N,K=LI()
#AB=[LI() for i in range(N)]

counts={}
l=[]
for i in range(N):
	ab=LI()

	if not counts.get(ab[0]):
		counts[ab[0]]=ab[1]
	else:
		counts[ab[0]]+=ab[1]
	if ab[0] not in l:
		l.append(ab[0])

l.sort()
c=0
for item in l:
	c+=counts.get(item)
	if c>=K:
		print(item)
		exit()

Submission status: Time Limit Exceeded

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N,K=LI()
AB=[LI() for i in range(N)]

counts={}
l=[]
for ab in AB:
	if not counts.get(ab[0]):
		counts[ab[0]]=ab[1]
	else:
		counts[ab[0]]+=ab[1]
	if ab[0] not in l:
		l.append(ab[0])

l.sort()
c=0
for item in l:
	c+=counts.get(item)
	if c>=K:
		print(item)
		exit()

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
A = []
for _ in range(N):
    a, b = map(int, input().split())
    A += [a] * b

A.sort()
print(A[K-1])

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
c=[]
for i in range(n):
  a,b=map(int,input().split())
  c+=[a]*b
c.sort()
print(c[k-1])

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
c = []
for _ in range(n):
    a, b = map(int, input().split())
    c.extend([a]*b)
c.sort()
print(c[k-1])

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
n,k, = map(int,input().split())
list = []
for i in range(n):
    a,b = map(int,input().split())
    for i in range(b):
        list.append(a)

list.sort()
print(list[k-1])

Submission status: Time Limit Exceeded

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

counter = 0
array1 = []

for i in range(N):
  for j in range(ab[i][1]):
    array1.append(ab[i][0])
    if len(array1) >= K:
      break
    
print(array1[K-1])

Submission status: Time Limit Exceeded

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

for i in range(N):
  for j in range(ab[i][1]):
    array1.append(ab[i][0])
    
array1.sort()

print(array1[K-1])

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
from collections import defaultdict
data=defaultdict(int)
for n in range(N):
    a,b=map(int,input().split())
    data[a]+=b
now=0
for i in range(len(data)):
    idx=min(data.keys())
    now+=data[idx]
    if now>=K:
        print(idx)
        break
    data.pop(idx)

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
a=[]
dic={}
for i in range(n):
    A,B=map(int,input().split())
    if A in a:
        dic[A]+=B
    else:
        a.append(A)
        dic[A]=B
a=sorted(a)
sum=0
for i in range(len(a)):
    sum+=dic[a[i]]
    if sum>=k:
        print(a[i])
        exit()

Submission status: Time Limit Exceeded

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

test = False

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

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


    l_1.sort()
    if test:
        print(l_1)

    for v in l_1:
        l_2.extend([v[0]] * v[1])

    # 小さい順にソートして、K-1番目の要素を出力
    if test:
        print(l_2)
    print(l_2[K-1])


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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

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

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

    # 小さい順にソートして、K-1番目の要素を出力
    l.sort()
    print(l[K-1])


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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
#数列の値を重複無く昇順に並べたものとその個数を別々に保存する
#配列のどこに挿入等の操作をするかは二分探索で調べる

def bs(A, key, B, keynum):
    sizeA = len(A)
    # 0なら挿入確定
    if sizeA == 0:
        A.append(key)
        B.append(keynum)
        return

    l = 0
    r = sizeA - 1
    mid = (l+r) // 2

    while r - l >= 1:
        if A[mid] == key:
            break
        elif key < A[mid]:
            r = mid
        else:
            l = mid + 1
        mid = (l+r) // 2
    #この時点で,A[mid]はkeyと等しいかkeyより大きい最小の値である(ただしkeyがAのどの要素よりも大きい時を除く)
    if A[mid] == key:
        B[mid] += keynum
    elif A[mid] < key:
        A.append(key)
        B.append(keynum)
    else:
        A.insert(mid, key)
        B.insert(mid, keynum)

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

syurui = []
kousuu = []
for i in range(N):
    temp = list(map(int,input().split()))
    bs(syurui, temp[0], kousuu, temp[1])

size = len(kousuu)
sum = [0 for i in range(size)]
sum[0] = kousuu[0]
for i in range(size):
    if i > 0:
        sum[i] = sum[i-1] + kousuu[i]
    if K <= sum[i]:
        print(str(syurui[i]))
        break

Submission status: Time Limit Exceeded

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

for i in range(n):
    a = A.index(min(A))
    m -= B[a]
    if(m<=0):
        print(A[a])
        break
    A[a] = 1000000

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
A = []
for i in range(n):
    a,b = map(int, input().split())
    for j in range(b):
        A.append(a)
    
A.sort()
print(A[m-1])

Submission status: Time Limit Exceeded

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

for i in range(n):
    Table.extend([a[i][0]]*a[i][1])

print(sorted(Table)[k-1])

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
A = []
for i in range(N):
    a, b = map(int, input().split())
    for k in range(b):
        A.append(a)
A.sort()
print(A[K-1])

Submission status: Time Limit Exceeded

Solution code:
import bisect
n,k= (int(i) for i in input().split())
array = []
for i in range(n):
 a,b= (int(i) for i in input().split())
 for j in range(b):
  bisect.insort(array, a, lo=0, hi=len(array))
print(array[k-1])

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int,input().split())
array = []
for i in range(N):
    a,b = map(int,input().split())
    array += [a] * b
array.sort()
ans = array[K-1]
print(ans)

Submission status: Time Limit Exceeded

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

ar_int = list()

for i in range(int_n):
    int_a, int_b = map(int, input().split())
    for x in range(int_b):
        ar_int.append(int_a)

print(sorted(ar_int)[int_k - 1])

Submission status: Time Limit Exceeded

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

l = []

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

    
l.sort()

print(l[k-1])

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int,input().split())
list =[]
for i in range(n):
    a, b = map(int,input().split())
    x = [a]
    for j in range(b):
        list = list + x
        
list.sort()

print(list[k])

Submission status: Time Limit Exceeded

Solution code:
N, K = (int(i) for i in input().split())

L = []
for i in range(N):
    a, b = (int(i) for i in input().split())
    L = L + [a]*b
    if len(L) > K:
        L.sort()
        L = L[:K]
        if L[-1] == 1:
            print(1)
            break
else:
    print(L[-1])

Submission status: Time Limit Exceeded

Solution code:
def main():
    l = []
    N, K = map(int, input().split())
    for i in range(N):
        a, b = map(int, input().split())
        l.extend([a for j in range(b)])

    l = sorted(l)
    print(l[K-1])

main()

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
l = []
for _ in range(N):
    an, bn = map(int, input().split())
    for _ in range(bn):
        l.append(an)
l.sort()
print(l[K-1])

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
array=[]
for i in range(n):
    a,b=map(int,input().split())
    for j in range(b):
        array.append(a)
ans=sorted(array)
print(ans[k-1])

Submission status: Time Limit Exceeded

Solution code:
n,k = list(map(int,input().split()))
array = []

b = [input() for _ in range(n)]

for i in range(n):
  c = list(map(int,b[i].split()))
  while c[1] != 0:
    array.append(c[0])
    c[1] -= 1

array = sorted(array)
print(array[k-1])

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
d = {}
array = []
for _ in range(N):
    a, b = map(int, input().split())
    if a in array:
        d[a] += b
    else:
        d[a] = b
        array.append(a)

array.sort()
counter = 0
for i in array:
    counter += d[i]
    if counter >= K:
        print(i)
        break

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
a = []
b = []
hairetu = []
for i in range(N):
    A, B = map(int, input().split())
    h = [A for i in range(B)]
    hairetu.extend(h)

hairetu.sort()
print(hairetu[K-1])

Submission status: Time Limit Exceeded

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

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

risuto = []
for i in range(N):
    A = ab[i][0]
    B = ab[i][1]
    for j in range(B):
        risuto.append(A)

print(sorted(risuto)[K-1])

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
a=[]
for i in range(N):
    b,c=list(map(int,input().split()))
    for j in range(c):
        a.append(b)
a.sort()
print(a[K-1])

Submission status: Time Limit Exceeded

Solution code:
N, K = map( int, input().split())
A = []
for i in range(N):
    a, b = map( int, input().split())
    A += [a]*b
    A.sort()
    A = A[:K]
print(A[K-1])

Submission status: Time Limit Exceeded

Solution code:
N, K = map( int, input().split())
A = []
for i in range(N):
    a, b = map( int, input().split())
    A += [a]*b
A.sort()
print(A[K-1])

Submission status: Time Limit Exceeded

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

ret = []

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

ret.sort()

print(ret[k-1])

Submission status: Time Limit Exceeded

Solution code:
f = lambda: list(map(int,input().split()))
f_ = lambda: [int(x)-1 for x in input().split()]

n,k = f()
l = []
for _ in range(n):
    a,b = f()
    l += [a]*b
print(sorted(l)[k-1])

Submission status: Time Limit Exceeded

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

numList = []

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

    for _ in range(b):
        numList.append(a)

numList.sort()

print(numList[K-1])

Submission status: Time Limit Exceeded

Solution code:
N,K = (int(i) for i in input().split())

numbers = []
for i in range(N):
    a,b = (int(j) for j in input().split())
    for k in range(b):
        numbers.append(a)

numbers.sort()
print(numbers[K-1])

Submission status: Time Limit Exceeded

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

import bisect
A = []
for _ in range(N):
    bisect.insort_left(A, tuple(int(x) for x in input().split()))

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

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
ans = [a[i][0] for i in range(n) for _ in range(a[i][1])]
print(sorted(ans)[k-1])

Submission status: Time Limit Exceeded

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

v = []
for i in range(n) :
    s, t = map(int, input().split())
    for j in range(t) :
        v.append(s)

v.sort()
print(v[k-1])

Submission status: Time Limit Exceeded

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

AB.sort()


result = []

count = 0
for a,b in AB:
    min_k = min(b,K)
    result += [a]*min_k
    count += min_k
    if count >= K:
        break

print(result[K-1])

Submission status: Time Limit Exceeded

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

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

result = []
for a,b in AB:
    result += [a]*min(b,K)

print(sorted(result)[K-1])

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int,input().split())
arr = []
for i in range(n):
    a,b = map(int,input().split())
    arr += [a] * b

arr.sort()
print(arr[k - 1])

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int, input().split())
a=[list(map(int, input().split())) for i in range(n)]
a.sort()
#print(a)
b=[]
for i,j in a:
    b=b+[i]*j
    if len(b)>k:break
print(b[k-1])

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
c = []
for i in range(n):
    a, b = map(int, input().split())
    c.extend([a]*b)
print(sorted(c)[k-1])

Submission status: Time Limit Exceeded

Solution code:
a=[];n,k=map(int,input().split())
for _ in[0]*n:
    b,c=map(int,input().split())
    a+=[b]*c
print(sorted(a)[~-k])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
tmp = list(map(int,input().split()))
n, k = tmp[0],tmp[1]
an = []
for i in range(n):
  tmp = list(map(int,input().split()))
  an += [tmp[0]] * tmp[1]
an.sort()
print(an[k-1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
key = []
value = []
a, b = map(int, input().split())
key.append(a)
value.append(b)
s = 0
for i in range(n-1):
    last = True    
    a, b = map(int, input().split())
    for j in range(len(key)):
        if a <= key[j]:
            key.insert(j,a)
            value.insert(j,b)
            last = False
            break
    if last:
        key.append(a)
        value.append(b)
for i in range(n):
    s += value[i]
    if k <= s:
        print(key[i])
        break

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
array = []
for i in range(n):
    a, b = map(int, input().split())
    for j in range(b):
        array.append(a)
array.sort()
print(array[k-1])

Submission status: Time Limit Exceeded

Solution code:
line_one = raw_input().split()
n = int(line_one[0])
k = int(line_one[1])

l = []
#d = {}
for i in range(n):
    line_one2 = raw_input().split()
    a1 = int(line_one2[0])
    b1 = int(line_one2[1])
    if a1 in l:
        #d[a1] += b1
        l[a1][1] += b1
    else:
        l.append( ( a1, b1 ))
        #//d[a1] = b1

l.sort()
count = 0
for item in l:
    count += item[1]
    if k <= count:
        print item[0]
        break

Submission status: Time Limit Exceeded

Solution code:
line_one = raw_input().split()
n = int(line_one[0])
k = int(line_one[1])

l = []
d = {}
for i in range(n):
    line_one2 = raw_input().split()
    a1 = int(line_one2[0])
    b1 = int(line_one2[1])
    if a1 in l:
        d[a1] += b1
    else:
        l.append(a1)
        d[a1] = b1

l.sort()
count = 0
for item in l:
    count += d[item]
    if k <= count:
        print item
        break

Submission status: Time Limit Exceeded

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

l = []
d = {}
for i in range(n):
    a1, b1 = map(int, raw_input().split(" "))
    if a1 in l:
        d[a1] += b1
    else:
        l.append(a1)
        d[a1] = b1

l.sort()
count = 0
for item in l:
    count += d[item]
    if k <= count:
        print item
        break

Submission status: Time Limit Exceeded

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

d = {}
for i in range(n):
    a1, b1 = map(int, raw_input().split(" "))
    if a1 in d.keys():
        d[a1] += b1
    else:
        d[a1] = b1


count = 0
for item in sorted(d.items(), key=lambda x: x[0]) :
    count += item[1]
    if k <= count:
        print item[0]
        break
    #count += item[1]

Submission status: Time Limit Exceeded

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

d = {}
for i in range(n):
    a1, b1 = map(int, raw_input().split(" "))
    if a1 in d.keys():
        d[a1] += b1
    else:
        d[a1] = b1


count = 0
for item in sorted(d.items(), key=lambda x: x[0]) :
    if k <= count + item[1]:
        print item[0]
        break
    count += item[1]

Submission status: Time Limit Exceeded

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

d = {}
for i in range(n):
    a1, b1 = map(int, raw_input().split(" "))
    if a1 in d.keys():
        d[a1] += b1
    else:
        d[a1] = b1


l = sorted(d.items(), key=lambda x: x[0])
#print (l)
count = 0
for e, item in enumerate(l):
    if k <= count + item[1]:
        print item[0]
        break
    else:
        count += item[1]

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int,input().split())
P = []
for i in range(N):
    a, b = map(int,input().split())
    p = [a] * b
    P += p
P.sort()
print(P[K-1])

Submission status: Time Limit Exceeded

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

arr = {}
keys = []

def bin_insert(arr, n, lo, hi):
	if lo == hi:
		return arr[:lo] + [n] + arr[lo:]
	mid = (hi+lo) // 2
	if n > arr[mid]:
		return bin_insert(arr, n, mid+1, hi)
	else:
		return bin_insert(arr, n, lo, mid)
	

for i in range(N):
	inp = input().split(" ")
	a = int(inp[0])
	b = int(inp[1])
	try:
		arr[a] += b
	except KeyError:
		arr[a] = b
		keys = bin_insert(keys, a, 0, len(keys))

for i in keys:
	K -= arr[i]
	if K <= 0:
		print(i)
		break

Submission status: Time Limit Exceeded

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

arr = {}
keys = []

def bin_insert(arr, n, lo, hi):
	if lo == hi:
		return arr[:lo] + [n] + arr[lo:]
	mid = (hi+lo) // 2
	if n > arr[mid]:
		return bin_insert(arr, n, mid+1, hi)
	else:
		return bin_insert(arr, n, lo, mid)
	

for i in range(N):
	inp = input().split(" ")
	a = int(inp[0])
	b = int(inp[1])
	if a in arr:
		arr[a] += b
	else:
		arr[a] = b
		keys = bin_insert(keys, a, 0, len(keys))

for i in keys:
	K -= arr[i]
	if K <= 0:
		print(i)
		break

Submission status: Time Limit Exceeded

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

arr = {}
keys = []

for i in range(N):
	inp = input().split(" ")
	a = int(inp[0])
	b = int(inp[1])
	if a in arr:
		arr[a] += b
	else:
		arr[a] = b
		keys.append(a)
		keys.sort()

for i in keys:
	K -= arr[i]
	if K <= 0:
		print(i)
		break

Submission status: Time Limit Exceeded

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

arr = []
indicies = [0]

for i in range(N):
	inp = input().split(" ")
	a = int(inp[0])
	b = int(inp[1])
	if len(arr) == 0 or a >= arr[-1]:
		arr += [a] * b
		indicies.append(len(arr))
	elif a <= arr[0]:
		arr = ([a] * b) + arr
		for i in range(len(indicies)):
			indicies[i] += b
		indicies.append(0)
	else:
		index = 0
		for i in range(len(indicies)):
			i = indicies[i]
			if a >= arr[i-1] and a <= arr[i]:
				index = i
				
				arr = arr[0:i] + ([a] * b) + arr[i:]
				break
		for i in range(len(indicies)):
			if indicies[i] > index:
				indicies[i] += b
		indicies.append(index+b)

print(arr[K-1])

Submission status: Time Limit Exceeded

Solution code:
line_one = raw_input().split()
n = int(line_one[0])
k = int(line_one[1])

arr = []
for i in range(n):
    line = raw_input().split()
    a = int(line[0])
    b = int(line[1])
    arr += [a] * b

arr = sorted(arr)
print arr[k-1]

Submission status: Time Limit Exceeded

Solution code:
import heapq
N,K=map(int,raw_input().split())
c=[]
for i in range(N):
	a,b=map(int,raw_input().split())
	for j in range(b):
		heapq.heappush(c,a)

for i in range(len(c)):
	val=heapq.heappop(c)
	if i==K-1:
		print val
		break

Submission status: Time Limit Exceeded

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

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

list.sort()
print(list[K-1])

Submission status: Time Limit Exceeded

Solution code:
N, K = [int(i) for i in input().split()]
ans = []
for i in range(N):
    A,B = [int(i) for i in input().split()]
    for b in range(B):
        ans.append(A)
ans.sort()
print(ans[K-1])

Submission status: Time Limit Exceeded

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

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

print(d[K-1])

Submission status: Time Limit Exceeded

Solution code:

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

l = []

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

print(sorted(l)[K-1])

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
lst = []
for i in range(n):
    a, b = map(int, input().split())
    for j in range(b):
        lst.extend([a])
lst.sort()
print(lst[k-1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
arr = []
temp = []
j = 0
for i in range(N):
    temp.append(list(map(int,input().split())))
    temp.sort()
while len(arr)<K:
    [arr.append(temp[j][0]) for _ in range(temp[j][1])]
    j += 1
print(arr[K-1])

Submission status: Time Limit Exceeded

Solution code:
# Big Array
n,k =  list(map(int, input().split()))

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

A2 = []
for s in A1:
    A2.extend(s)
print( sorted(A2)[k-1] )

Submission status: Time Limit Exceeded

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

a = [0]*N
b = [0]*N
for i, ab in zip(range(N), ab_list):
    _a, _b = ab
    a[i] = _a
    b[i] = _b

idx = 0
cnt = 0
while N > cnt:
    min = 1e6
    for i in range(cnt, N):
        if min > a[i]:
            min = a[i]
            idx = i
    a_tmp = a[cnt]
    b_tmp = b[cnt]
    a[cnt] = a[idx]
    b[cnt] = b[idx]
    a[idx] = a_tmp
    b[idx] = b_tmp
    cnt += 1

#print a, b                                                                                                                                                                                                                                   

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

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
N,K = map(int,input().split())
tmp = Counter()
for i in range(N):
    a,b = map(int,input().split())
    tmp.update([a]*b)

print(sorted(tmp.elements())[K-1])

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
lit =  []
for i in range(N):
    a,b = map(int,input().split())
    lit.extend([a for x in range(b)])
lit.sort()
print(lit[K-1])

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
list1 = []
for i in range(N):
    list1.append(list(map(int,input().split())))
list1.sort()
list2 = []
for j in range(N):
    list2 += [list1[j][0]]*list1[j][1]
    if len(list2) >= K:
        break
print(list2[K-1])

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
list1 = []
for i in range(N):
    a,b = map(int,input().split()) 
    list2 = [a]*b
    list1 += list2
list1.sort()
print(list1[K-1])

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
list1 = []
for i in range(N):
    a,b = map(int,input().split()) 
    for j in range(b):
        list1.append(a)
list1.sort()
print(list1[K-1])

Submission status: Time Limit Exceeded

Solution code:
#-*- coding: utf-8 -*-

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]) # 0番目の要素でソート

data = []
for a, b in src:
    for i in range(b):
        data.append(a)

print data[k-1]

Submission status: Time Limit Exceeded

Solution code:
#-*- coding: utf-8 -*-

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

data = []

for i in range(n):
    a, b = map(int, raw_input().split())
    for j in range(b):
        data.append(a)

data.sort()
print data[k-1]

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
stri=list()
for var in range(1,N+1):
    a,b=map(str,input().split())
    b=int(b)
    for v in range(1,b+1):
        stri.append(a)

stri.sort()

print(stri[K-1])

Submission status: Time Limit Exceeded

Solution code:

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

v=[]
for i in a:
    i=list(map(int, i.split()))
    v=v+[i]
a=v

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


diffK=x[1]
for i in a:


    if diffK-i[1]<=0:
        print(i[0])
        quit()
    else:
        diffK -=i[1]

Submission status: Time Limit Exceeded

Solution code:
N, K = list(map(int, input().split()))
control = [list(map(int, input().split())) for i in range(N)]
L = []
for con in control:
    num, times = con
    for i in range(times):
        L.append(num)

L = sorted(L)
print(L[K-1])

Submission status: Time Limit Exceeded

Solution code:
# N,Kの把握
l1 = list(map(int, input().split()))
N = l1[0]
K = l1[1]
 

#空リストを作成。a,bを把握し、リストにaを追加、b回。これをN回くりかえし
l3 = []
for i in range(N):
	l2 = list(map(int, input().split()))
	a = l2[0]
	b = l2[1]
	if len(l3) >= K :
		if max(l3) <= a:
			pass #リストの要素数がKを上回っている場合、要素の最大値よりも大きい数は追加しない。
		else:
			adl=[a] * b
			l3 = l3 + adl
			for j in range(len(l3)-K):
				l3.remove(max(l3))
	else:
		adl=[a] * b
		l3 = l3 + adl
 
# リストをソートし、K番目を出力
l3.sort()
print(str(l3[K-1]))

Submission status: Time Limit Exceeded

Solution code:
# N,Kの把握
l1 = list(map(int, input().split()))
N = l1[0]
K = l1[1]
 

#空リストを作成。a,bを把握し、リストにaを追加、b回。これをN回くりかえし
l3 = []
for i in range(N):
	l2 = list(map(int, input().split()))
	a = l2[0]
	b = l2[1]
	if len(l3) > K and max(l3) < a:
		pass #リストの要素数がKを上回っている場合、要素の最大値よりも大きい数は追加しない。
	else:
		adl=[a] * b
		l3 = l3 + adl
 
# リストをソートし、K番目を出力
l3.sort()
print(str(l3[K-1]))

Submission status: Time Limit Exceeded

Solution code:
# N,Kの把握
l1 = list(map(int, input().split()))
N = l1[0]
K = l1[1]

#タイムアウト問題。リストをソートし、K後を削除する。
#空リストを作成。a,bを把握し、リストにaを追加、b回。これをN回くりかえし
l3 = []
for i in range(N):
	l2 = list(map(int, input().split()))
	a = l2[0]
	b = l2[1]
	if len(l3) > K and max(l3) < a:
		pass
	else:
		for j in range(b):
			l3.append(a)

# リストをソートし、K番目を出力
l3.sort()
print(str(l3[K-1]))

Submission status: Time Limit Exceeded

Solution code:
# N,Kの把握
l1 = list(map(int, input().split()))
N = l1[0]
K = l1[1]

#空リストを作成。a,bを把握し、リストにaを追加、b回。これをN回くりかえし
l3 = []
for i in range(N):
	l2 = list(map(int, input().split()))
	a = l2[0]
	b = l2[1]
	if b <= K:
		for j in range(b):
			l3.append(a)
	else:
		for j in range(K):
			l3.append(a)

# リストをソートし、K番目を出力
l3.sort()
print(str(l3[K-1]))

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
tmp = []
[tmp.extend((lambda x: [x[0] for j in range(0, x[1])])(list(map(int, input().split())))) for i in range(0, n)]
tmp.sort()
print(tmp[k-1])