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

Submission status: Runtime Error

Solution code:

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

Submission status: Runtime Error

Solution code:
from collections import defaultdict

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

keys = nval.keys()
sorted(keys)

cnt = 0
for val in keys:
    # cnt += nval[val]
    if K <= nval[val]:
        print(val)
        break
    k -= nval[val]

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)].sort()
cou=0
for r in l:
  a,b=r[0],r[1]
  cou+=b
  if cou>=k:
    print(a)
    break

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)].sort()
cou=0
for [a,b] in l:
  cou+=b
  if cou>=k:
    print(a)
    break

Submission status: Runtime Error

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

for a, b in ab_list:
  if b >= K:
    print(a)
    exit()
  else:
    K -= b

Submission status: Runtime Error

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

for i in range(n):
    a,b = map(int,input().split())
    count += b
    if count >= k:
        print(a)
        break()

Submission status: Runtime Error

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

AB =sorted([tuple(map(int,input().split())) for i in range(N)],key=lambda x:-x[0])

B=1

for a,b in AB:
  a,b=tuple(map(int,
  if B>=K :
    print(a)
    quit()
  B+=b

Submission status: Runtime Error

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

cnt = 0
ans = ""
for a, b in ab:
    ans += str(a) * b
    cnt += b
    if cnt >= K:
        print(ans[-1])
        break

Submission status: Runtime Error

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

ans = ""

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

print(ans[k])

Submission status: Runtime Error

Solution code:
N, K = int(input())
opes = []
for _ in range(N):
  opes.append(tuple(map(int, input().split())))
opes.sort(key=lambda x:x[0])
sum_ope = 0
for ope in opes:
  sum_ope += ope[1]
  if sum_ope >= K:
    print(ope[0])
    break

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, k = [int(i) for i in input().split()]
m = sorted([[int(i) for i in input().split()] for _ in range(n)]

s=0
i=0
while s<k:
    s += m[i][1]
    i += 1
print(m[i-1][0])

Submission status: Runtime Error

Solution code:
from heapq import heappop,heappush

input=open(0).readline
n,k=map(int,input().split())
res={}
for i in range(n):
    a,b=map(int,input().split())
    res[a]=res.get(a,0)+b

que=[]
for key,val in res.items():
    heappush(que,(key,val))

while k:
    key,val=heappop(que)
    if val<=k:
        print(key)
        exit()
    k-=val

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

int main(){
  int N, K, a, b, S, ans;
  cin >> N >> K;
  
  vector<int> C(100000);
  
  for (int i = 0; i < N; i++){
    cin >> a >> b;
    C.at(a-1) += b;
  }
  
  for (int i = 0; i < N; i++){
    S += C.at(i);
    if (S >= K){
      cout << i+1 << endl;
      break;
    }
  }
}

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c = LI()
    if a <= c <= b:
        print("Yes")
        return
    print("No")
    return

#B
def B():
    n, m = LI()
    e = defaultdict(int)
    for i in range(1, n + 1): e[i] = 0
    for i in range(m):
        a, b = LI()
        e[a] += 1
        e[b] += 1
    for i in e.values():
        print(i)
    return

#C
def C():
    n, k = LI()
    d = [0] * (n+1)
    for i in range(n):
        a, b = LI()
        d[a] += b
    for i in range(n+1):
        k -= d[i]
        if k <= 0:
            print(i)
            return
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c = LI()
    if a <= c <= b:
        print("Yes")
        return
    print("No")
    return

#B
def B():
    n, m = LI()
    e = defaultdict(int)
    for i in range(1, n + 1): e[i] = 0
    for i in range(m):
        a, b = LI()
        e[a] += 1
        e[b] += 1
    for i in e.values():
        print(i)
    return

#C
def C():
    n, k = LI()
    d = [0] * (n+1)
    for i in range(1, n + 1): d[i] = 0
    for i in range(n):
        a, b = LI()
        d[a] += b
    for i in range(n+1):
        k -= d[i]
        if k <= 0:
            print(i)
            return
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()

Submission status: Runtime Error

Solution code:
[[print(ab[[index for index in [SumI if NK[1]<=sum([ab[1][I] for I in range(SumI)]) else -1 for SumI in range(NK[0])] if index!=-1][0]][0]) for ab in [sorted([list(map(int,(input().split()))) for i in range(NK[0])],key=lambda x:x[0])]] for NK in [list(map(int,(input().split())))]]

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())
D,L={},[]
for _ in range(N):
    a,b=map(int,input().split())
    L.append(a)
    if a in D:D[a]=D[a]+b
    else:D[a]=b
l=list(set(L)).sort()
for i in l:
    K-=D[i]
    if K<=0:
        print(i)
        exit()

Submission status: Runtime Error

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 = a.sort()

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

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

Submission status: Runtime Error

Solution code:
N, K = list(map(int, input().split()))
__max = 10**5+1
buff = [0 for i in range(__max)]
a = []
ans = 0
b = 0
for i in range(N):
    _a, _b = list(map(int, input().split()))
    buff[_a] = _b


for i in range(1,__max+1):

    if K <= buff[i]:
        print(i)
        exit()

    K -= buff[i]

Submission status: Runtime Error

Solution code:
N, K = list(map(int, input().split()))
__max = 10**5+1
buff = [0 for i in range(__max)]
a = []
ans = 0
b = 0
for i in range(N):
    _a, _b = list(map(int, input().split()))
    buff[_a] = _b


for i in range(1,__max+1):

    if K <= buff[i]:
        print(i)
        exit()

    K -= buff[i]

Submission status: Runtime Error

Solution code:

def list_pos(cnt,a,b,ans):
    if ans  >= b :
        return cnt-1
    else :

        ans += a[cnt][1]
        cnt += 1
        return list_pos(cnt,a,b,ans)
import sys
sys.setrecursionlimit(10000)
N,K = map(int,input().split())
para = {}
for i in range(N):
    a,b  = map(int,input().split())
    if not a in para.keys():
        para[a] = b
    else : para[a] += b

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

p = list_pos(0,para,K,0)
print("{}".format(para[p][0]))

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10000)
def list_pos(cnt,a,b,ans):
    if ans  >= b :
        return cnt-1
    else :

        ans += a[cnt][1]
        cnt += 1
   　return list_pos(cnt,a,b,ans)

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

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

p = list_pos(0,para,K,0)
print("{}".format(para[p][0]))

Submission status: Runtime Error

Solution code:
def list_pos(cnt,a,b,ans):
    if ans  >= b :
        return cnt-1
    else :

        ans += a[cnt][1]
        cnt += 1
        return list_pos(cnt,a,b,ans)

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

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

p = list_pos(0,para,K,0)
print("{}".format(para[p][0]))

Submission status: Runtime Error

Solution code:
def list_pos(cnt,a,b,ans):
    if ans  >= b :
        return cnt-1
    else :

        ans += a[cnt][1]
        cnt += 1
    return list_pos(cnt,a,b,ans)

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

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

p = list_pos(0,para,K,0)
print("{}".format(para[p][0]))

Submission status: Runtime Error

Solution code:
def list_pos(cnt,a,b,ans):
    if ans  >= b :
        return cnt-1
    else :

        ans += a[cnt][1]
        cnt += 1
    return list_pos(cnt,a,b,ans)

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


p = list_pos(0,para,K,0)
print("{}".format(para[p][0]))

Submission status: Runtime Error

Solution code:
def list_pos(cnt,a,b,ans):
    if ans  >= b :
        return cnt
    else :
        cnt += 1
        ans += a[cnt][1]
    return list_pos(cnt,a,b,ans)

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


p = list_pos(-1,para,K,0)
print("{}".format(para[p][0]))

Submission status: Runtime Error

Solution code:
def list_pos(cnt,a,b,ans):
    if ans  >= b :
        return cnt-1
    else :
        cnt += 1
        ans += a[cnt][1]
    return list_pos(cnt,a,b,ans)

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


p = list_pos(0,para,K,0)
print("{}".format(para[p][0]))

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
para = [[i for i in map(int,input().split())] for j in range(N)]
ans= []
size = 0
for i in range(N) :
    if size > K :
        break
    else: 
        ans += para[i]
        size = len(ans)
print("{}".format(ans[K]))

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
para = [[i for i in map(int,input().split())] for j in range(N)]
ans= []
size = 0
for i in range(N) :
    if N > K :
        break
    else: 
        ans += para[i]
        size = len(ans)
print("{}".format(ans[K]))

Submission status: Runtime Error

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

new=0

for i in a:
    now+=i[1]
    if now>=k:
        print(i[0])
        break

Submission status: Runtime Error

Solution code:
go

Submission status: Runtime Error

Solution code:

import bisect
n, k =  [ int(v) for v in input().split() ]
num_list = sorted([ tuple(map(int, input().split())) for i in range(n) ])
order_list, value_list = [ 0 for i in range(n) ], [ 0 for i in range(n) ]
for i in range(n):
	order_list[i] = num_list[i][1] + order_list[i-1]
	value_list[i] = num_list[i][0]


print(value_list[bisect.bisect(order_list,k)])

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
lis = [10**5]*K
for _ in range(N):
    a, b = map(int, input().split())
    if a < lis[K-1]:
        for index, num in enumerate(lis):
            if num > a:
                if index + b < K:
                    lis = lis[:index] + [a for _ in range(b)] + lis[index:K-b]
                else:
                    lis = lis[:index] + [a for _ in range(K-index)]
                break
print(lis[K-1])

Submission status: Runtime Error

Solution code:
N, K = map(int,input().split())
count = 0
while True:
    a,b = map(int,input().split())
    count += b
    if count > K:
        print(a)
        exit()

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
ab = sorted([map(int,input().split()) for _ in [0]*N])
for a,b in ab:
    K -= b
    if K <= 0:
        print(a)
        break

Submission status: Runtime Error

Solution code:
import sys

def main():
n, k = map(int, input().split())
num = 0
for i in range(n):
    a, b = map(int, input().split())
    num += b
    if (num >= k):
        print(a)
        sys.exit()

Submission status: Runtime Error

Solution code:
N, K = map(int,input().split())
ans = ""
for i in range(N):
    a, b = map(int,input().split())
    ans += str(a)*b

print(ans[K-1])

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
number = [0 for i in range(N+1)]
for i in range(N):
  a, b = map(int, input().split())
  number[a] += b
for i in range(N):
  if K - number[i+1] <= 0:
    print(i+1)
    break
  else:
    K -= number[i+1]

Submission status: Runtime Error

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

Submission status: Runtime Error

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

count = 0
for x in ab:
    count += x[1]
    if k <= count:
        print(x[0])
        break

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
list=[0]*11
for i in range(n):
    a,b=map(int,input().split())
    list[a]+=b
sum=0
for l in range(1,len(list)):
    sum+=list[l]
    if sum>=k:
        print(l)
        exit()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
from collections import defaultdict
n, k = map(int, input().split())
dic = defaultdict(int)
for _ in range(n):
  a, b = map(int, input().split())
  dic[a] += b
dic = sorted(dic, key = lambda x: x[0])
cnt = 0
for key in dic:
  if cnt + dic[key] < k:
    cnt += dic[key]
  else:
    print(key)
    break

Submission status: Runtime Error

Solution code:
N, K = map(int,input().split())
AB = sorted([[list(map(int,input().split())) for _ in range(N)]])
cnt = 0
for a, b in AB:
  if(cnt < K - b):
    cnt += b
  else:
    print(a)
    break

Submission status: Runtime Error

Solution code:
N, K = map(int,input().split())
AB = sorted([[list(map(int,input().split())) for _ in range(N)]])
cnt = 0
for a, b in AB:
  if(cnt < K - b)
    cnt += b
  else:
    print(a)
    break

Submission status: Runtime Error

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

c = 0
d = 0
for i in b:
    c += i
    if c >= K:
        break
    d += 1
    
A = []
for i in range(d):
    A += [a[i]]*b[i]
A.sort()
print(A[K])

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
ls={}
for i in range(n):
  a,b=map(int,input().split())
  if a not in ls:
    ls[a]=b
  else:
    ls[a]+=b
ls=sorted(ls.keys())
tmp=0
for i,j in ls.items():
  tmp+=j
  if k <= tmp:
    print(i)
    exit()

Submission status: Runtime Error

Solution code:
n, k = [int(x) for x in input().split(' ')]
ab = [(input().split(' ')) for _ in range(n)]
index = 0

for a, b  in ab:
    index += int(b)
    if index >= k:
        print(a)
        breaka

Submission status: Runtime Error

Solution code:
import sys


def input(): return sys.stdin.readline().strip()


N, M = (list)(map(int, input().split()))
edge = []

for _ in range(M):
    edge.append((list)(map(int, input().split())))


inf = 10**15

d = [inf]*(N+1)
d[1] = 0
ans = inf
for i in range(N):
    update = False
    for a, b, c in edge:
        c = -c
        new_d = d[a]+c
        if d[a] != inf and d[b] > new_d:
            d[b] = new_d
            update = True

    if not update:
        break

neg = [False]*(N+1)
for i in range(N):
    for a, b, c in edge:
        c = -c
        new_d = d[a]+c
        if d[a] != inf and d[b] > new_d:
            d[b] = new_d
            neg[b] = True
        if neg[a]:
            neg[b] = True

if neg[-1]:
    print('inf')
else:
    print(-d[-1])

Submission status: Runtime Error

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

kc = 0
for a, b in sorted(ab, key=lambda x: x[0]):
  if kc + b >= K:
    break
  kc += b

print(a)

Submission status: Runtime Error

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

result = [a for j in range(b) for a, b in A]
print(result[K+1])

"""
result = []
for a, b in A:
  for j in range(b):
    result.append(a)
print(result[K-1])
"""

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

count = 0
i = 0
while count < k:
  count = count + b[i]
  i = i + 1

  
print(a[i])

Submission status: Runtime Error

Solution code:
N, K = list(map(int, input().strip().split()))
grid = []
k = 0
j = 0
for i in range(N):
	array = list(map(int, input().strip().split()))
	grid.append(array)
for i in range(N):
	if k < K:
		k += grid[i-1][1]
		j += 1
print(str(grid[j][0])[K-k])

Submission status: Runtime Error

Solution code:
from collections import defaultdict

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

a = []
b = []

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

d = defaultdict(int)

for i in range(N):
    if a[i] in d:
        d[a[i]] += b[i]
    else:
        d[a[i]] = b[i]

d_sorted = sorted(d.items())

l = 0
for a_i,b_i in d_sorted.items():
	l += b_i
	if l >= K:
		print(a_i)
		break

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(b)
	print(l)
	if sum(l) > K-1:
		print(a)
		break

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def main():
    len_s = 0
    ans = -1
    dic = {}
    N, K = map(int, input().split())
    for _ in range(N):
        a, b = map(int, input().split())
        if a not in dic:
            dic[a] = b
        else:
            dic[a] = b + dic[a].values
    dic = sorted(dic.items())
    for key, value in dic:
        len_s += value
        if len_s >= K and ans == -1:
            ans = key
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N)]
hikaku = 0
for i in range(N):
    hikaku += ab[i][1]
    if K <= ans:
        print(ab[i][0])
        break

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 += [a]*b
    A = A.sort()[:K]
print(A[K-1])

Submission status: Runtime Error

Solution code:
n,k = map(int,input()split())
d = []
for _ in range(n):
    d.append(list(map(int,input().split())))
d.sort(key=lambda x: x[0])
count = 0
for x,y in d:
    count += y
    if count >= k:
        break
print(x)

Submission status: Runtime Error

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

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

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

#print(numbers)

kugiri = numbers[0][1]
i = 0
while K >= kugiri:
    i += 1
    kugiri += numbers[i][1]

print(numbers[i][0])

Submission status: Runtime Error

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

d = dict()
for ab_i in ab:
	a, b = ab_i
	if a not in d:
		d[a] = 0
	d[a] += b

print(sum([[d_a] * d_b for d_a, d_b in sorted(d.items())], [])[k-1])

Submission status: Runtime Error

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

count = 0

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

Submission status: Runtime Error

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

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

v.sort()
i=int(0)
while k-w[i] >= 0 :
    k-=w[i]
    i+=1

print(v[i])

Submission status: Runtime Error

Solution code:
n, k = map(int,input().split())
dcic = {}
aa = ()
for i in range(n):
    a,b = map(int,input().split())
    aa.add(a)
    if a in dcic:
        dcic[a] = dcic + b
    else:
        dcic.update({a:b})

bb = list(sorted(list(aa)))
cc = 0
for i in range(len(bb)):
    if k - dcic[bb[i]] > -1:
        k = k - dcic[bb[i]]
    else:
        cc = dcic[bb[i]]
        
print(cc)

Submission status: Runtime Error

Solution code:
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result

arr_data = getinputdata()

#回数
n = int(arr_data[0][0])

#番目
k = int(arr_data[0][1])

s=""

for i in range(1, 1 + n):

    cnt = int(arr_data[i][1])
    j = arr_data[i][0]

    s+=str(cnt * j)

print(s[k-1])

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import sys
n,k=map(int,input().split())
ab=[[0,0]for i in range(n)]
for i in range(n):
  ab[i][0],ab[i][1]=map(int,input.split())
ab.sort()
x=0
for i in range(n):
  x+=ab[i][1]
  if(x>=k):
    print(ab[i][0])
    sys.exit()
print(ab[-1][0])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;

long long int N, K;
long long int a, b;


int main(){
    cin >> N >> K;
    vector<pair<long long int, long long int> > pairs(N);

    for(int i = 0; i < N; i++){
        cin >> a >> b;
        pairs[i] = make_pair(a, b);
    }
    sort(pairs.begin(), pairs.end());

    for(int i = 0; i < N; i++){
        K -= pairs[i].second;
        if(K <= 0){
            cout << (pairs[i].first);
            return 0;
        }
    }
    return 0;
}

Submission status: Runtime Error

Solution code:
n = int(input())
k = int(input())
x = 0
y =0
sum = 0
for i in range(n):
    x=int(input())
    y = int(input())
    sum+=y
    if(k <= sum):
        print(x)
        break

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <queue>
#include <cstring>
#include <iterator>
#include <list>
#include <set>
#include <map>
#include <bitset>
using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;

    map<int, int> freq;
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        if(!freq.count(a))
            freq[a] = 0;
        freq[a] += b;
    }

    map<int, int>::iterator it;
    int k = 1;
    for (it = freq.begin(); k <= K && it != freq.end(); it++) {
        k += it->second;
    }
    it--;
    cout << it->first << endl;
}

Submission status: Runtime Error

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
	else:
		for i in indicies:
			if a > arr[i-1] and a < arr[i]:
				arr = arr[0:i] + ([a] * b) + arr[i:]
	print(arr)

print(arr[K])

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <queue>
#include <cstring>
#include <iterator>
#include <list>
#include <set>
#include <map>
#include <bitset>
using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;

    map<int, int> freq;
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        freq[a] = b;
    }

    map<int, int>::iterator it;
    int k = 1;
    for (it = freq.begin(); k <= K && it != freq.end(); it++) {
        k += it->second;
    }
    it--;
    cout << it->first << endl;
}

Submission status: Runtime Error

Solution code:
10 500000
1 100000
1 100000
1 100000
1 100000
1 100000
100000 100000
100000 100000
100000 100000
100000 100000
100000 100000

Submission status: Runtime Error

Solution code:
from collections import deque
N, K = map(int, input().split())
a = [0] * N
b = [0] * N
x = deque()
y = deque()

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

for i in range(N):
    if len(y) <= K:
        x = [1 * a[i]] * b[i]
        y.extend(x)
        print(y)
    else:
        break

print(y[K-1])

Submission status: Runtime Error

Solution code:
from collections import deque
N, K = map(int, input().split())
a = [0] * N
b = [0] * N
x = deque()
y = deque()

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

for i in range(N):
    if len(y) < K:
        x = [1 * a[i]] * b[i]
        y.extend(x)
        print(y)
    else:
        break

print(y[K-1])

Submission status: Runtime Error

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

c_n=[int(i) for k in range(N) for i in input().split()]

a_n=[]
b_n=[]
for i in range(N):
    a_n.append(c_n[2*i])
    b_n.append(c_n[2*i+1])

for i in range(N):
    for j in range(b_n[i]):
        em.append(a_n[i])

print(c_n[K-1])