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:
N,K=map(int,input().split())
a=[0]*N
b=[0]*N
for i in range(N):
    a[i],b[i]=map(int,input().split())
c=0
while K>0:
    c=min(a)
    array=[]
    count=0
    for i in range(len(a)):
        if a[i-count]==c:
            K-=b[i-count]
            a.pop(i-count)
            b.pop(i-count)
            count+=1
print(c)

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
a=[0]*N
b=[0]*N
for i in range(N):
    a[i],b[i]=map(int,input().split())
c=0
while K>0:
    c=min(a)
    array=[]
    for i in range(len(a)):
        if a[i]==c:
            K-=b[i]
            array.append(i)
    count=0
    for j in array:
        a.pop(j-count)
        b.pop(j-count)
        count+=1
print(c)

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
a=[0]*N
b=[0]*N
for i in range(N):
    a[i],b[i]=map(int,input().split())
c=0
while K>0:
    c=min(a)
    array=[]
    for i,x in enumerate(a):
        if a[i]==c:
            K-=b[i]
            array.append(i)
    count=0
    for j in array:
        a.pop(j-count)
        b.pop(j-count)
        count+=1
print(c)

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
a=[0]*N
b=[0]*N
for i in range(N):
    a[i],b[i]=map(int,input().split())
count=0
while K>0:
    c=a.index(min(a))
    K-=b[c]
    count=a.pop(c)
    b.pop(c)
print(count)

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
a=[0]*N
b=[0]*N
for i in range(N):
    a[i],b[i]=map(int,input().split())
def bubble_sort_kai(arr,b):
    change = True
    while change:
        change = False
        for i in range(len(arr) - 1):
            if arr[i] > arr[i + 1]:
                arr[i], arr[i + 1] = arr[i + 1], arr[i]
                b[i],b[i+1]=b[i+1],b[i]
                change = True
    return arr,b
bubble_sort_kai(a,b)
count=0
wa=K
while wa>0:
    wa-=b[count]
    count+=1
print(a[count-1])

Submission status: Time Limit Exceeded

Solution code:
#ABC061

n,k = map(int,input().split())
l = []
for i in range(n):
    a,b = list(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())
Array=[]
for n in range(0,N):
    a,b=input().split()
    Array+=((a+" ")*int(b)).split()
    Array.sort()
print(int(Array[K-1]))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
listA=[]
listB=[]
for z in range(N):
    a,b=map(int,input().split())
    if a in listA:
        n=listA.index(a)
        listB[n]+=b
    else:
        listA.append(a)
        listB.append(b)
while True:
    kotae=min(listA)
    basho=listA.index(kotae)
    if listB[basho]<K:
        K-=listB[basho]
    else:
        print(kotae)
        break
    listA.pop(basho)
    listB.pop(basho)

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
list=[]
for z in range(N):
    a,b=map(int,input().split())
    list.append([a,b])
numbers=[]
for y in range(N):
    numbers+=[list[y][0]]*list[y][1]
newnumbers=sorted(numbers)
print(newnumbers[K-1])

Submission status: Time Limit Exceeded

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

nums = []
for _ in range(n):
  a, b = map(int, input().split())
  nums.extend([a]*b)
  
sn = sorted(nums)
print(sn[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
l.sort()
print(l[k-1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

ans.sort()
print(ans[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())
    B = [a] * b
    A.extend(B)
A = sorted(A)
print(A[k-1])

Submission status: Time Limit Exceeded

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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    N, K = map(int,input().split())
    AB = [list(map(int,input().split())) for _ in range(N)]
    S = []
    for ab in AB:
        S += [ab[0]]*ab[1]
    S.sort()
    print(S[K-1])
    
            

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    N, K = map(int,input().split())
    AB = [list(map(int,input().split())) for _ in range(N)]
    S = []
    for ab in AB:
        S += [ab[0]]*ab[1]
        S.sort()
    print(S[K-1])
    
            

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

a = []

for i in li:
  b = [i[0]] * i[1]
  a.extend(b)

a.sort()

print(a[K-1])

Submission status: Time Limit Exceeded

Solution code:
if __name__ == '__main__':
    N,K=list(map(int,input().split()))
    L=[]
    for i in range(N):
        a,b=list(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())
l=[]
for i in range(n):
    a,b=map(int,input().split())
    l+=[a]*b
l.sort()
print(l[k-1])

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
dic = {}
for i in range(N):
    a, b = map(int, input().split())
    if a not in dic.keys():
        dic[a] = 0
    dic[a] += b
count = 0
for k, v in sorted(dic.items()):
    count += v
    if count >= K:
        print(k)
        break

Submission status: Time Limit Exceeded

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

ab = []
l = []
for _ in range(N):
    A, B = [int(i) for i in input().split()]
    n = [A] * B
    l.extend(n)
    
l = sorted(l)
print(l[K-1])

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
a =[0]*N
b =[0]*N
for i in range(0,N):
    a[i],b[i] =map(int,input().split())
s=0
t=0
A=0
while s<K:
    A=min(a)
    t=A
    s=s+b[a.index(A)]
    a[a.index(A)]=max(a)+A
print(t)

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
a =[0]*N
b =[0]*N
for i in range(0,N):
    a[i],b[i] =map(int,input().split())
a.sort()
c =[]
for i in range(0,N):
    for j in range(0,b[i]):
        c.append(a[i])
print(c[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()
print(array[k - 1])

Submission status: Time Limit Exceeded

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

for n in range(N):
  a, b = input().split()
  a = int(a)
  b = int(b)
  for times in range(b):
    proList.append(int(a))

sortList = sorted(proList)

print(sortList[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())
    cache = [a] * b
    array += cache
array.sort()
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())
    for m in range(b):
        array.append(a)
array.sort()
print(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())
  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())

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

Submission status: Time Limit Exceeded

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

l=[]
for i in ll:
    for j in range(i[1]):
        l.append(i[0])
l.sort()
print(l[k-1])

Submission status: Time Limit Exceeded

Solution code:
if __name__ == '__main__':

	#入力
	N, K  = map(int,input().split())
	lst = []
	for i in range(0,N):
		a, b = map(int,input().split())
		lst.append([a,b])

	ans_lst = []
	for i in range(0,N):
		a = lst[i][0]
		b = lst[i][1]
		for j in range(0,b):
			ans_lst.append(a)

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import numpy as np

# N K 操作回数、K番目の値
n, k = map(int, input().split())

# ai, bi  追加する整数 ai, 追加する数 bi
s = []
for i in range(n):
    s.append(list(map(int, input().split())))

num = []
for pr in s:
    for i in range(pr[1]):
        num.append(pr[0])

num.sort()

print(num[k-1])

Submission status: Time Limit Exceeded

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

tmp_dic = {}
for i in range(n):
  a_tmp, b_tmp = map(int, input().split())
  if a_tmp in list(tmp_dic.keys()):
    tmp_dic[a_tmp]+=b_tmp
  else:
  	tmp_dic[a_tmp] = b_tmp

a_list = list(tmp_dic.keys())
a_list.sort()

acum=0
for key in a_list:
  acum+=tmp_dic[key]
  #print(acum)
  if m<=acum:
    print(key)
    break

Submission status: Time Limit Exceeded

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

ls = []
for i in range(n):
  a_tmp, b_tmp = map(int, input().split())
  for j in range(b_tmp):
    ls.append(a_tmp)

ls.sort()

print(ls[m-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.extend([a for _ in range(b)])

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

Submission status: Time Limit Exceeded

Solution code:
N,K = [int(i) for i in input().split(" ")]
a = []
b = []
for n in range(N):
  temp = [int(i) for i in input().split(" ")]
  a.append(temp[0])
  b.append(temp[1])
point = 0
while 1:
  Index = a.index(min(a))
  point += b[Index]
  if K <=point:
    break
  else:
    a.pop(Index)
    b.pop(Index)

print(a[Index])

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:
a,b=map(int,input().split())
s=[]
for i in(range(a)):
    x,y=map(int, input().split())
    s.append([x]*y)
one_s=[ flatten for inner in s for flatten in inner]
print(sorted(one_s)[b-1])

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import deque

if sys.platform in ['ios','win32','darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N, K = MAP()
A = [MAP() for _ in range(N)]

A.sort()
B = deque()
for a in A:
	ai, bi = a
	B.extend([ai]*bi)
# print(B)
print(B[K-1])

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(n)]
c = []
for i in range(n):
    for _ in range(l[i][1]):
        #print(l[i][0])
        c.append(l[i][0])
    
c.sort()
print(c[k-1])

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(j) for j in input().split()]
  l = [a]*b
  L.extend(l)
L.sort()
print(L[K-1])

Submission status: Time Limit Exceeded

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

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

ans = sorted(sum(ans, []))
print(ans[k-1])

Submission status: Time Limit Exceeded

Solution code:
import sys
N,K=map(int,input().split())
nums = []
for _ in range(N):
  a,b = map(int,sys.stdin.readline().split())
  nums += [a for _ in range(b)]
nums.sort()
print(nums[K-1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

def one_int():
    return int(input())

def one_str():
    return input()

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

from collections import defaultdict


N,K = two_int()

query = []
for i in range(N):
    query.append(two_int() )

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

dicts = defaultdict(int)
count = 0
sums = 0

for [a,b] in query:
    temp = 0
    
    for k,v in dicts.items():
        if k>a:
            dicts[k] += b
        if temp <= k <= a:
            temp = k
            
    dicts[a] = b+dicts[temp]
    sums += b
    if sums > K:
        break

output = [ [k,v] for k,v in dicts.items()]

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

ans=0
for i in range(len(temp)-1):
    if temp[i][1] < K <= temp[i+1][1]:
        ans=temp[i+1][0]
        break

print(ans)

Submission status: Time Limit Exceeded

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

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

def one_int():
    return int(input())

def one_str():
    return input()

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

from collections import defaultdict


N,K = two_int()

dicts = defaultdict(int)
count = 0
for i in range(N):
    a,b = two_int()
    temp = 0
    
    for k,v in dicts.items():
        if k>a:
            dicts[k] += b
        if temp <= k <= a:
            temp = k
            
    dicts[a] = b+dicts[temp]

output = [ [k,v] for k,v in dicts.items()]

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

ans=0
for i in range(len(temp)-1):
    if temp[i][1] < K <= temp[i+1][1]:
        ans=temp[i+1][0]

print(ans)

Submission status: Time Limit Exceeded

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

def one_int():
    return int(input())

def one_str():
    return input()

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

from collections import defaultdict


N,K = two_int()

dicts = defaultdict(int)
count = 0
for i in range(N):
    a,b = two_int()
    temp = 0
    
    for k,v in dicts.items():
        if k>a:
            dicts[k] += b
        if temp <= k <= a:
            temp = k
            
    dicts[a] = b+dicts[temp]

output = [ [k,v] for k,v in dicts.items()]

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

ans=0
for i in range(len(temp)-1):
    if temp[i][1] < K <= temp[i+1][1]:
        ans=temp[i+1][0]

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N,K =map(int,input().split())
result = []
for i in range(N):
  a,b = map(int,input().split())
  result +=[a]*b
result.sort()
print(result[K-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.sort() 




print(p[k-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())
  for j in range(b):
    p.append(a)
p.sort() 
 

print(p[k-1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

arr.sort()

print(arr[k-1])

Submission status: Time Limit Exceeded

Solution code:
List = []
N, K = map(int, input().split())
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())
ans=[]
for i in range(N):
    a,b=map(int,input().split())
    tmp_ = [a]*b
    ans.extend(tmp_)
ans = sorted(ans)
print(ans[K-1])

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys
import itertools

def solve(N: int, K: int, a: "List[int]", b: "List[int]"):
    big_array = []
    for i in range(N):
        big_array += [a[i]]*b[i]
    big_array.sort()
    print(big_array[K-1])
    return


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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
from bisect import insort
n, k = map(int, input().split())
array = []

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

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

print(a)

Submission status: Time Limit Exceeded

Solution code:
import heapq
N, K = map(int,input().split())
Q = []
for i in range(N):
    a, b = map(int,input().split())
    for j in range(b):
        heapq.heappush(Q,a)
for i in range(K-1):
    heapq.heappop(Q)
print(heapq.heappop(Q))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import heapq as q

n, k = map(int, input().split())
l = []
q.heapify(l)

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

for i in range(k):
    ans = q.heappop(l)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import heapq as q

n, k = map(int, input().split())
l = []
for i in range(n):
    a, b = map(int, input().split())
    l += [a]*b
q.heapify(l)
for i in range(k):
    ans = q.heappop(l)
print(ans)

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
l.sort()
print(l[k-1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

s = list()
for i in range(n):
    for j in range(b[i]):
        s.append(a[i])

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n, k = [int(num) for num in input().split()]
dic = {}
list = []
for i in range(n):
  a, b = [int(num) for num in input().split()]
  if a in dic.keys():
    dic[a] += b
  else:
    dic[a] = b
    list.append(a)

list.sort()
    
for num in list:
  if k - dic[num] <= 0:
    print(num)
    break
  else:
    k -= dic[num]

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
A = []
for i in range(N):
    x,y = list(map(int,input().split()))
    a = [x] * y
    A += a
A.sort()
print(A[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)]
l = []
for i in range(n):
  l+=[ab[i][0]]*(ab[i][1])
l.sort()
print(l[k-1])

Submission status: Time Limit Exceeded

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

ans.sort()

print(ans[k - 1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# 2019/07/23

input=open(0).readline
n,k=map(int,input().split())
res=[]
for i in range(n):
    a,b=map(int,input().split())
    res+=[a]*b
res.sort()
print(res[k-1])

Submission status: Time Limit Exceeded

Solution code:
def main():
    N, K = map(int, input().split())
    ans = []
    for i in range(N):
        a, b = map(int, input().split())
        for i in range(b):
            ans.append(a)
    sort_ans = sorted(ans)
    print(sort_ans[K-1])
    
main()

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())
    l1 = [a]*b
    l = l + l1
l.sort()
print(l[k-1])

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(' '))
    A.append([a]*b)
A.sort()
A = [i for v in A for i in v]
print(A[M-1])

Submission status: Time Limit Exceeded

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

def main(N,K,A,B):
    while(0<K):
        tmp = min(A)
        idx = A.index(min(A))
        K -= B[idx]
        A.pop(idx)
        B.pop(idx)
    print(tmp)
    
if __name__ == '__main__':
    N, K = map(int, input().split())
    A, B = [], []
    for i in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
    main(N,K,A,B)

Submission status: Time Limit Exceeded

Solution code:

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

now = 0
lis = []

for i in range(N):

    a,b = map(int,input().split())
    lis += [a]*b



lis.sort()
print (lis[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])
ab.sort()
x=[]
for i in range(n):
    x.extend([ab[i][0]]*ab[i][1])
    if len(x)>k:
        break
print(x[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())
    x=[a]*b
    ab.extend(x)
ab.sort()
print(ab[k-1])

Submission status: Time Limit Exceeded

Solution code:
# 操作回数（N）および数を求めたい順位（K）を入力する
N, K = map(int, input().split())
# 整数を格納するリスト（list_num）を定義する
list_num = []
# 各操作において、、
for _ in range(N):
    # 挿入する整数（a）とその個数（b）を入力する
    a, b = map(int, input().split())
    # list_numにaをb個だけ挿入する
    list_num.extend([a] * b)
# list_numを昇順にソートする
list_num.sort()
# K番目に小さい数を返す
print(list_num[K - 1])

Submission status: Time Limit Exceeded

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

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

p_list = []
t = zip(a, b)
ts = sorted(t)
a, b = zip(*ts)
for ai, bi in zip(a, b):
    for i in range(bi):
        p_list.append(ai)

print(p_list[k-1])

Submission status: Time Limit Exceeded

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

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

p_list = []
t = zip(a, b)
ts = sorted(t)
a, b = zip(*ts)
for ai, bi in zip(a, b):
    for i in range(bi):
        p_list.append(ai)

p_list.sort()

print(p_list[k-1])

Submission status: Time Limit Exceeded

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

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

p_list = []
for ai, bi in zip(a, b):
    for i in range(bi):
        p_list.append(ai)

p_list.sort()

print(p_list[k-1])

Submission status: Time Limit Exceeded

Solution code:
n,k=(int(i) for i in input().split())
a=[[int(i) for i in input().split()] for i in range(n)]
#print(a)

ans=0
while ans < k:
    mina=min(a)
#    print(a)
    a.remove(mina)
    ans+=mina[1]
    
print(mina[0])

Submission status: Time Limit Exceeded

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

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

print(t[K-1])

Submission status: Time Limit Exceeded

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

buff = []
_a = []
ans = 0
b = 0


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

_a.sort()
for i in range(N):
    buff += [_a[i][0]] * _a[i][1]

print(buff[K-1])

Submission status: Time Limit Exceeded

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

buff = []
a = []
ans = 0
b = 0
for i in range(N):
    _a, _b = list(map(int, input().split()))
    b += _b
    a.append((_a, _b))
    # if b >= K and ans == 0:
    #     ans = _a
    # buff += [_a]*_b


a = sorted(a)

for i in range(N):
    buff += [a[i][0]] * a[i][1]

# buff = sorted(buff)
print(buff[K-1])


# print(ans)

Submission status: Time Limit Exceeded

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

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


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

Submission status: Time Limit Exceeded

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

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


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

Submission status: Time Limit Exceeded

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

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


buff = sorted(buff)
print(buff[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())
  for j in range(b):
    arr.append(a)
arr.sort()
print(arr[k-1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from sys import exit, stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
AB = []
for i in range(N):
    a, b = stdin.readline().rstrip().split()
    for j in range(int(b)):
        AB.append(int(a))
AB.sort()
print(AB[K-1])

Submission status: Time Limit Exceeded

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

L = []
for i in range(N):
    
    L += [ab[i][0]] * ab[i][1]
    
L.sort()
print(L[K-1])

Submission status: Time Limit Exceeded

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

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

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