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: Runtime Error

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

ab = [[0, 0]] * N
for i in range(N):
    _a, _b = map(int, input().split())
    ab[i] = [_a, _b]
ab.sort(key=lambda x:x[0])

j = 0
index = 0
while j < K:
    j += ab[index][1]
    if j < K:
        index += 1

print ab[index][0]

Submission status: Runtime Error

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

total = [[0, 0]] * k
for i in range(n):
    number, copies = map(lambda x: int(x), input().split())
    total[i] = [number, copies]

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


count = i = 0
while count < K:
    count += total[i][1]
    if count < K:
        i += 1

print(total[i][0])

Submission status: Runtime Error

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

total = [[0, 0]] * k
for i in range(n):
    number, copies = map(lambda x: int(x), input().split())
    total[i] = [number, copies]

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

add = 0
for pair in total:
    add += pair[1]
    if add >= k:
        print(pair[0])
        break

Submission status: Runtime Error

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

ab = [0]*n

for i in range(n):
  ab[i] = input().split()
  
ans = []

for i in range(n):
  tmp = [int(ab[i][0])]*int(ab[i][1])
  ans.append(tmp)

ans = list(itertools.chain.from_iterable(ans))
ans.sort()
print(ans[k-1])

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())
cnt=0
P=[]
for i in range(N):
    a,b=map(int,input().split())
    P.append((a,b))

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
s[0]*10**5
for i in range(n):
  a,b=map(int,input().split())
  s[a-1]+=b
i=0
while k>0:
  k-=s[i]
  i+=1
print(i)

Submission status: Runtime Error

Solution code:
# ABC 061: C – Big Array
N, K = [int(i) for i in input().split()]
a, b = [], []
for _ in range(N):
    tmp = input().split()
    a.append(int(tmp[0]))
    b.append(int(tmp[1]))

cnt = [0] * 100000

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

for j in range(100000):
    if K <= cnt[j]:
        print(j)
        break
    K -= cnt[j]

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
B = {}
cnt = 0
i = 0
while K>cnt:
    cnt += A[i][1]
    B[A[i][0]] = A[i][1]
    i += 1
B[A[i-1][0]] = K-(cnt-A[i-1][1])
B = B.items()
B = sorted(B,key=lambda x:x[0])
cnt = 0
i = 0
while K>cnt:
    cnt += B[i][1]
    i += 1
print(B[i-1][0])

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
l = []
for i in range(n):
  a,b=map(int,input().split())
  l.append((a,b))
l = sorted(l)
c = 0
i = 0
while c < k:
  c += l[i][1]
  i += 1

print(l[i][1])

Submission status: Runtime Error

Solution code:
import sys

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

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

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
from sys
rl=sys.stdin.readline

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

if __name__=='__main__':
    main()

Submission status: Runtime Error

Solution code:
from collections import deque
n,k=map(int,input().split())
ints=[list(map(int,input().split())) for _ in range(n)]
d=deque()
for x in ints:
  d.extend([x[0]]*x[1])
ans=list(d).sort()
print(ans[k-1])

Submission status: Runtime Error

Solution code:
import sys

def main():
    n, k = map(int, input().split())
    cnt = 0
    for x in sys.stdin.readlines:
        a, b = map(int, x.split())
        if cnt + b < k:
            cnt += b
        else:
            print(a)
            exit()

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
from bisect import bisect_left

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

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

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

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

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

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

Submission status: Runtime Error

Solution code:
import numpy as np
N,K = (int(x) for x in input().split())
A = []
B = []
for i in range (N):
  a,b = (int(x) for x in input().split())
  A.append (a)
  B.append (b)
for i in range (N):
  x = np.argmin(A)
  if B[x] >= K:
    print (A[x])
    break
  else:
    K -= B[x]
    A.pop (A[x])

Submission status: Runtime Error

Solution code:
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N,K = I()
L = [l() for _ in range(N)]
L.sort()
for i in range(N):
    K -= L[i][1]
    if K <= 0:
        print(L[i][0])
        exit()

Submission status: Runtime Error

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

INF = 10 ** 5 + 1
arr = [INF] * 4
for i in range(n):
    a, b = map(int, input().split())
    new = [a] * min(b, 4)

    arr += new
    arr.sort()
    arr = arr[:k]

print(arr[k-1])

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
dic = {}
for _ in range(N):
  a, b = map(int,input().split())
  if a in dic:
    dic[a] += b
  else:
    dic[a] = b
List = sorted(dic)
ans = 0
i = 0
while M >= 0:
  M -= dic[List[i]]
  ans = List[i]
  i += 1
print(ans)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
dic = {}
for _ in range(N):
  a, b = map(int,input().split())
  if a in dic:
    dic[a] += b
  else:
    dic[a] = b
List = sorted(dic)[::-1]
ans = 0
i = 1
while M > 0:
  M -= dic[i]
  ans = i
  i += 1
print(ans)

Submission status: Runtime Error

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

a=[]
b=[]
d={}
for _ in range(n):
    a_i,b_i=map(int,input().split())
    d[a_i]=b_i

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


prev=0
for key,value in d:
    a.append(key)
    b.append(prev+value)

    prev+=value


for j in range(n):
    if k<=b[j]:
        break

print(a[j])

Submission status: Runtime Error

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

for n in range(N):
  a,b = input().split()
  ans+= a*int(b)

print(ans[K-1])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
a,b=map(int,input().split())
s=[]
s+=[a]*b
for i in range(n-1):
  a,b=map(int,input().split())
  if a>s[-1]:
    continue
  s+=[a]*b
  p=sorted(s)[:k]
print(p[k-1])

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
a,b=map(int,input().split())
s=[]
s+=[a]*b
for i in range(n-1):
  a,b=map(int,input().split())
  if a>max(s) and len(s)>k:
    continue
  s+=[a]*b
print(p[k-1])

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
s=[]
for i in range(n):
  a,b=map(int,input().split())
  if a>max(s) and len(s)>k:
    continue
  s+=[a]*b
p=sorted(s)
print(p[k-1])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
n,k=map(int, input().split()) #a1 a2 a3

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

i=0

while k>0:
  k-=com[i][1]
  i+=1

print(com[~i][0]) #~i -i-1

Submission status: Runtime Error

Solution code:
import sys
n,k=map(int, input().split()) #a1 a2 a3

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

i=0

while k>0:
  k-=com[i][0]
  i+=1

print(com[~i][0]) #~i -i-1

Submission status: Runtime Error

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

abb = ab.sort()

temp =0

for i in range(n):
    if temp < k:
        temp += abb[i][1]
    else:
        print(abb[i-1][0])
        exit()

Submission status: Runtime Error

Solution code:
N,K = map(int, input().split())
A = []
ruiseki = [0]
for i in range(N):
    a,b = map(int, input().split())
    A.append(a)
    ruiseki.append(ruiseki[i]+b)
K = ruiseki[-1]-K+1
for i in range(1,N+1):
    if K >= ruiseki[i]:
        n = i
        break
print(A[n+1])

Submission status: Runtime Error

Solution code:
import numpy as np
n,k = map(int,input().split())
c = [0] * (10**5+1)
for _ in range(n):
  a,b = map(int,input().split())
  c[a] += b

A = np.array(c,dtype=np.int32)
A = A.cumsum()
answer = (A >= k).nonzero()[0].min()
print(answer)

Submission status: Runtime Error

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

for i in range(N):
    index += a_b[i][1]
    if index >= K:
        print(a_b[i][0])
        exit()

Submission status: Runtime Error

Solution code:
def main():
    n, k = map(int, input().split())
    a, b = [0 for i in range(n)], [0 for i in range(n)]
    for i in range(n):
        x, y = input().split()
        a[i], b[i] = x, int(y)
    ans = solve(n, k, a, b)
    print(ans)


def solve(n, k, a, b):
    s = ''
    for i in range(n):
        s += a[i] * b[i]
    return s[k - 1]


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
from operator import itemgetter
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

n, k = map(int, input().split())
ab = [readints() for _ in range(n)]
# print(ab)
abab = sorted(ab)
# print(abab)
tmp = 0
for i in range(n):
    tmp += ab[i][1]
    if tmp >= k:
        print(ab[tmp-k][0])
        break

Submission status: Runtime Error

Solution code:
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
from operator import itemgetter
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

n, k = map(int, input().split())
ab = [readints() for _ in range(n)]
# print(ab)
abab = sorted(ab)
# print(abab)
tmp = 0
for i in range(n):
    tmp += ab[i][1]
    if tmp >= k:
        print(ab[tmp-k][0])
        exit()

Submission status: Runtime Error

Solution code:
from itertools import chain
N,K = map(int,input().split())
numarray = list()
num_bool = [0]*(10**5)
numarray_ind = list()

for i in range(N):
    a,b = map(int,input().split())
    num_bool[a-1]+=1
    if(num_bool[a-1]>=2):
        numarray[numarray_ind.index(a)][1]+=b
        # print(numarray)    
        
    else:
        numarray.append([a,b])
        numarray_ind.append(a)

        # print(numarray)    
numarray.sort()
sum_c = 0
i= 0
while all:
    sum_c+=numarray[i][1]
    i+=1
    if(sum_c <=K):
        break
    # print(sum_c,i)
# print(numarray)
print(numarray[i-1][0])

Submission status: Runtime Error

Solution code:
from itertools import chain
N,K = map(int,input().split())
numarray = list()
num_bool = [0]*(10**5)


for i in range(N):
    a,b = map(int,input().split())
    num_bool[a-1]+=1
    if(num_bool[a-1]>=2):
        pos = divmod(    list(chain(*numarray)).index(a), len(numarray[0])
        )
        numarray[pos[0]][1]+=b
        # print(numarray)    
        
    else:
        numarray.append([a,b])
        # print(numarray)    
numarray.sort()
sum_c = 0
i= 0
while all:
    sum_c+=numarray[i][1]
    i+=1
    if(sum_c <=K):
        break
    # print(sum_c,i)
# print(numarray)
print(numarray[i-1][0])

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

for _ in range(N):
    a, b= map(int, input().split())
    for i in range(b):
        c.append(a)
    if d <= K:
        break
        
print(sorted(c)[K-1])

Submission status: Runtime Error

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

for _ in range(N):
    a, b= map(int, input().split())
    for i in range(b):
        c.append(a)
    if d <= len(c):
        break
        
print(sorted(c)[K-1])

Submission status: Runtime Error

Solution code:
## N, K = map(int, input().split())
c = []
d = 0
for _ in range(N):
    a, b= map(int, input().split())
    for i in range(b):
        c.append(a)
    d += b
    if d <= K-1:
        break
print(sorted(c)[K-1])

Submission status: Runtime Error

Solution code:
import numpy as np
N, K = map(int, input().split())
d = []
for _ in range(N):
    a, b= map(int, input().split())
    c = [a] * b
    d.append(c)
print(sorted(c)[K-1])

Submission status: Runtime Error

Solution code:
ma = lambda:map(int,input().split())
n,k = ma()
ab = []
for i in range(n):
    ab.append((list(ma)))
ab.sort()
c  = 0
for a,b in ab:
    c+=b
    if c>=k:print(a)

Submission status: Runtime Error

Solution code:
N,K=(int(x) for x in input().split())
a_list=[]
b_list=[]
for i in range(N):
  a,b=(int(x) for x in input().split())
  a_list.append(a)
  b_list.append(b)
none_list=[]  
for i in range(N):
  _append=a_list[i]*b_list[i]
  none_list.append(a_list[i])
none_list.sort()
print(none_list[K-1])

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A, B = [0]*N, [0]*N
s = ""
for i in range(N):
  A[i], B[i] = input().split()
  s += A[i] * int(B[i])
print(s[K-1])

Submission status: Runtime Error

Solution code:
def cnct(lint,lim):
    global list753
    global list357
    global list333
    lint1=str(lint)+"3"
    lint1int=int(lint1)
    if lint1int<=lim and not lint1int in list357:
        list357.add(lint1int)
        cnct(lint1int,lim)
    lint2=str(lint)+"5"
    lint2int=int(lint2)
    if lint2int<=lim and not lint2int in list357:
        list357.add(lint2int)
        cnct(lint2int,lim)
    lint3=str(lint)+"7"
    lint3int=int(lint3)
    if lint3int<=lim and not lint3int in list357:
        list357.add(lint3int)
        cnct(lint3int,lim) 
    lint4="3"+str(lint)
    lint4int=int(lint4)
    if lint4int<=lim and not lint4int in list357:
        list357.add(lint4int)
        cnct(lint4int,lim)
    lint5="5"+str(lint)
    lint5int=int(lint5)
    if lint5int<=lim and not lint5int in list357:
        list357.add(lint5int)
        cnct(lint5int,lim)
    lint6="7"+str(lint)
    lint6int=int(lint6)
    if lint6int<=lim and not lint6int in list357:
        list357.add(lint6int)
        cnct(lint6int,lim)
def D(lint):
    lista=list(str(lint))
    if lista.count("3") and lista.count("5") and lista.count("7"):
        return True
    else:
        return False

list753=[3,5,7]
list357=set()
k=int(input())
count=0
for b in list753:
    cnct(b,k)
list333=list(list357)
list333.sort()
for c in [x for x in list333]:
    if not D(c):
        list333.remove(c)
print(len(list333))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:

n,k = map(int,input().split())
count = [0]* (10**5+1)
s = set()

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

x = 0
for s in sorted(S):
    x += count[s-1]
    if x >= k:
        print(s)
        break

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np

num, rank = map(int,input().split())
grid = []
for i in range(num):
    array = list(map(int, input().strip().split()))
    grid.append(array)


list = np.ravel(grid)
list.sort()

print(list[rank-1])

Submission status: Runtime Error

Solution code:
import numpy as np

num = int(input().strip())
grid = []
for i in range(num):
    array = list(map(int, input().strip().split()))
    grid.append(array)


list = np.ravel(grid)
list.sort()

print(list[num-1])

Submission status: Runtime Error

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

Submission status: Runtime Error

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
import collections

while K>0:
    c=min(a)
    array=[]
    for i,x in enumerate(a):
        if a[i]==c:
            K-=b[i]
            array.append(i)
    for i in array:
        a.pop(array[i])
        b.pop(array[i])
print(c)

Submission status: Runtime Error

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

print(P[a][0])

Submission status: Runtime Error

Solution code:
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

n = int(input())
t = [0]*n
for i in range(n):
    t[i] = int(input())
    
ans = t[0]
    
for i in range(1,n):
    ans = ans * t[i] // gcd(ans , t[i])
    
print(ans)

Submission status: Runtime Error

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

ab.sort()
i = 0
c = ab[0][1]
while c < k:
    i +=1
    c += ab[i][1]
print(ab[i][0])

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
n, k = [int(i) for i in input().split()]
d = {}
for i in range(n):
    a, b = [int(i) for i in input().split()]
    if a in d:
        d[a] += b
    else:
        d[a] = b
c = []
for k, v in sorted(d.items(), key=lambda x: x[0]):
    c += [k] * v
print(c[k])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

ab= []
ans = 0
for i in range(n):
    ab = list(map(int,input().split()))
    ab.append(count)
ab.sort()

while ans < k:
    ans +=ab[i][1]
    i +=1
print(ab[i-1][0])

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,k=mii()
arr= llint(n)
arr.sort(key=lambda x: x[1])

i=-1
num=0
val=0
while k>num:
    i+=1
    num+=arr[i][0]
    val=arr[i][1]
print(val)

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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())
c=[0]*(10**6)
for i in range(0,N):
    c[a[i]]=c[a[i]]+b[i]
s=0
i=1
while s<K:
    s=s+c[i]
    x=a[i-1]
    i=i+1
print(x)

Submission status: Runtime Error

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: Runtime Error

Solution code:
	n, k = map(int, input().split())
a = [0] * n
b = [0] * n
sum = 0
arr = []
for i in range(n):
    a[i], b[i] = map(int, input().split())
arr_list = list(zip(a, b))
arr_list = sorted(arr_list)
# print(arr_list)
for i in range(n):
    sum += arr_list[i][1]
    # print(sum, arr_list[i])
    if sum >= k:
        answer = arr_list[i]
        break

print(answer)

Submission status: Runtime Error

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 = index(min(a))
  point += b[Index]
  if K <=point:
    break
  else:
    a.pop(Index)
    b.pop(Index)
    
print(a[Index])

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
ls = []
len = 0
for i in range(N):
    a,b = map(int,input().split())
    ls.append(str(a)*b)
    len += b
    if len >= K:
        break
ls = "".join(ls)
print(ls[K-1])

Submission status: Runtime Error

Solution code:
a,b=map(int,input())
s=[]
for i in(range(a)):
  
  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: Runtime Error

Solution code:
n = int(input())
array = []
for i in range(1,n+1):
    for j in range(1,n//i+1):
        array.append(abs(i-j) + n - i*j)
print(min(array))

Submission status: Runtime Error

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

lst = [[int(i) for i in input().split()] for _ in range(n)]

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

for [i, j] in lst:
    if j >= k:
        print(i)
        quit()
    else:
        k -= j

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())
li=sorted([list(map(int,input().split())) for _ in range(N)])
for l in li:
    K-=l[1]
    if K<=0:
        print(l[0])
        break()

Submission status: Runtime Error

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

s = []
for i in range(n):
  s.extend([a[i]] * b[i])
for i in range(3):
  s.remove(min(s)
           
print(s)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np
n,m = [int(i) for i in input().split()]
l = [[int(i) for i in input().split()] for _ in range(n)]
ans = np.zeros(10**10+100,dtype = np.int64)
start = 0
end = 0
for i,j in l:
    end += j
    ans[start:end] = i
    start = end
    
print(ans[m-1])

Submission status: Runtime Error

Solution code:
import numpy as np

n,m = [int(i) for i in input().split()]
l = [[int(i) for i in input().split()] for _ in range(n)]
ans = np.zeros(10**5+1,dtype = np.int64)
start = 0
end = 0
for i,j in l:
    end += j
    ans[start:end] = i
    start = end
    
print(ans[m-1])

Submission status: Runtime Error

Solution code:
n,m = [int(i) for i in input().split()]
l = [[int(i) for i in input().split()] for _ in range(n)]
ans = np.zeros(10**5+1,dtype = np.int64)
start = 0
end = 0
for i,j in l:
    end += j
    ans[start:end] = i
    start = end
    
print(ans[m-1])

Submission status: Runtime Error

Solution code:
n, k = map(int,input().split())
result = float("Inf")
length = 0
for i in range(N):
  a, b = map(int,input().split())
  if(length < k):
    length += b
    result = max(result, a)
  else:
    if(a < result):
      length += b
      if(length > k):
        result = a
print(result)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,k = map(int, input().split())
p = [[0,0]]
for i in range(n):
    a,b = map(int, input().split())
    p.append([a,b])
p.sort()
ans = 0
i = 0
while ans<=k:
    ans+=p[i+1][1]
    i+=1
print(p[i][0])

Submission status: Runtime Error

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

N, K = [int(x) for x in input().split()]
arr = [0] * (10**5+1)
for _ in range(N):
    a, b = [int(x) for x in input().split()]
    arr[a] += b

remain = K
for i in range(1, 10**5+1):
    if arr[i] != 0:
        remain -= arr[i]
    if remain <= 0:
        print(i)
        exit()

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())
ans=[0]*10**13
for i in range(N):
    a,b=map(int,input().split())
    ans[a]+=b
for i in range(len(ans)):
    cnt+=ans[i]
    if cnt<K:
        continue
    else:
        print(ans[i])
        exit()

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
C = {}
A = []
for _ in range(N):
    a,b = map(int,input().split())
    if a not in C:
        C[a] = 0
    C[a] += b
    A.append(a)
A = sorted(list(set(A)))
cnt = 0
for i in range(len(A)):
    cnt += C[i]
    if cnt>=K:
        print(i)
        break

Submission status: Runtime Error

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    ab = sorted([ist(map(int, input().rstrip('\n').split())) for _ in range(n)])
    t = 0
    for a, b in ab:
        t += b
        if t >= k:
            print(a)
            exit()


if __name__ == '__main__':
    slove()

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
num = [0] * 100000
for i in range(n):
  a, b = map(int, input().split())
  num[a - 1] += b
for i in range(100000 - 1):
  if num[i] > 0:
    k -= num[i]
    if k <= 0:
      ans = i + 1
      break
print(ans)

Submission status: Runtime Error

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    ab = [ist(map(int, input().rstrip('\n').split()))]
    ab.sort()
    t = 0
    mt = 0
    for a, b in ab:
        t += b
        if t >= k:
            print(a)
            exit()


if __name__ == '__main__':
    slove()

Submission status: Runtime Error

Solution code:
N,K = list(map(int,input().split()))
l = [0]*(10**5+1)
for i in range(N):
  a, b = list(map(int,input().split()))
  l[a] += b 
  
for j in range(1,int(len(l))+1):
  if K >= l[j]:
    K -= l[j]
  else:
    print(j)
    break

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
A=[]
for i in range(n):
    a=list(map(int,input().split()))
    A.append(a)
S=sorted(A,key=lambda,x:x[0])
i=0
while k>0:
    k-=A[i][1]
    i+=1
print(A[i][0])