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: Wrong Answer

Solution code:
n,k=map(int,input().split())
l=[[int(i) for i in input().split()] for i in range(n)]
for i in range(n):
    if l[i][1]<k:
        k-=l[i][1]
    else:
        print(l[i][0])
        break

Submission status: Wrong Answer

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

cnt = 0
for key, value in c.items():
    cnt += value
    if cnt >= k:
        print(key)
        exit()

Submission status: Wrong Answer

Solution code:
n,k=map(int, input().split())
s=[list(map(int, input().split()))  for i in range(n)] 
x=0
for i in range(n):
    x+=s[i][1]
    if k<=x:
        print(s[i][0])
        exit()

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc061/tasks/abc061_c
# C - Big Array

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

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

ab_list = sorted(ab_list, key=lambda x: x[0])
c = 0
for a, b in ab_list:
    c += a ** b
    if c > K:
        ans = a

print(ans)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
num = 0
for i in range(n):
    a,b = map(int,input().split())
    num += a
    if num < k:
        continue
    elif num >= k:
        print(b)
        break

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
num = 0
for i in range(n):
    a,b = map(int,input().split())
    num += b
    if num < k:
        continue
    elif num >= k:
        print(a)
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import bisect
input = sys.stdin.readline
 
def main():
    n,k = map(int,input().split())
    a=[0 for _ in range(n)]
    b=[0 for _ in range(n)]

    for i in range(n):
        a[i],b[i] = map(int,input().split())
    ans=[]
    while(len(ans)<k):
        for i in range(n):
            ans+=[a[i] for _ in range(b[i])]
    answer=[0 for _ in range(k)]
    for i in range(k):
        answer[i]=ans[i]
    answer.sort()
    print(answer[k-1])
    
main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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:
    cnt += a
    if cnt >= k:
        print(b)
        exit()

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
cnt = 0
for i in range(n):
    a, b = map(int, input().split())
    cnt += b
    if cnt >= k:
        print(a)
        exit()

Submission status: Wrong Answer

Solution code:
def main():
    N, K = map(int, input().split())
    while K > 0:
        a, b = map(int, input().split())
        K -= b
    return a
     
if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

Solution code:
# ABC061C - Big Array
import sys
input = sys.stdin.readline

from itertools import accumulate
from bisect import bisect_left as bs


def main():
    N, K = tuple(map(int, input().split()))
    A = tuple(tuple(map(int, input().split())) for _ in range(N))
    a, b = zip(*A)
    idx = bs(list(accumulate(b)), K)
    print(a[idx])


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
"""
データの特徴と定義域に注目
- 全体のデータ数は10^10で計算時間がありえない
- データ特徴としては同じ値が連続（圧縮可能）
- データを圧縮した場合のデータ数は10^5になり、空間的に許容範囲、線形探査も時間的に許容範囲
- 「空間的にも」→全要素分の配列を準備してハッシュでソート(=インデックスの場所に格納すればソートされる)
"""
(n, k) = map(int, input().split())

num = [0 for _ in range(100000 + 1)]

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

count = 0
for i, j in enumerate(num):
    if count + j > k:
        print(i)
        break
    else:
        count += j
print(1)

Submission status: Wrong Answer

Solution code:
import heapq

(n, k) = map(int, input().split())
insertion = []
for _ in range(n):
    insertion.append(list(map(int, input().split())))

result = []
for pair in insertion:
    for _ in range(pair[1]):
        heapq.heappush(result, pair[0])
print(result[k-1])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
l1=[]
c=0
ret=0
n,k=map(int,input().split())
for i in range(n):
  l1.append(input().split())
l1.sort()
#print(l1)
for j in range(n):
  c+=int(l1[j][1])
  if c>=k:
    ret=int(l1[j][0])
    break
print(ret)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")
from collections import Counter
import heapq


class MinHeap(object):
    def __init__(self, x):
        self.heap = [e for e in x]
        heapq.heapify(self.heap)

    def push(self, value):
        heapq.heappush(self.heap, value)

    def pop(self):
        return heapq.heappop(self.heap)


def solve(N: int, K: int, a: "List[int]", b: "List[int]"):
    mh = MinHeap([])
    counter = Counter()
    for aa, bb in zip(a, b):
        mh.push(aa)
        counter[aa] += bb

    while True:
        m = mh.pop()
        if counter[m] >= K:
            break
        else:
            K -= counter[m]
    print(m)
    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: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")
from collections import Counter
import heapq


class MinHeap(object):
    def __init__(self, x):
        self.heap = [e for e in x]
        heapq.heapify(self.heap)

    def push(self, value):
        heapq.heappush(self.heap, value)

    def pop(self):
        return heapq.heappop(self.heap)


def solve(N: int, K: int, a: "List[int]", b: "List[int]"):
    mh = MinHeap([])
    counter = Counter()
    for aa, bb in zip(a, b):
        mh.push(aa)
        counter[aa] += bb

    while len(mh.heap) > 0:
        m = mh.pop()
        if counter[m] >= K:
            break
        else:
            K -= counter[m]
    print(m)
    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: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")
from collections import Counter
import heapq


class MinHeap(object):
    def __init__(self, x):
        self.heap = [e for e in x]
        heapq.heapify(self.heap)

    def push(self, value):
        heapq.heappush(self.heap, value)

    def pop(self):
        return heapq.heappop(self.heap)


def solve(N: int, K: int, a: "List[int]", b: "List[int]"):
    mh = MinHeap([])
    counter = Counter()
    for aa, bb in zip(a, b):
        mh.push(aa)
        counter[aa] += bb

    while len(mh.heap) > 0:
        m = mh.pop()
        if counter[m] > K:
            break
        else:
            K -= counter[m]
    print(m)
    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: Wrong Answer

Solution code:
N,K=map(int,input().split())
ans={}
for i in range(N):
    a,b=map(int,input().split())
    if a in ans:ans[a]+=b
    else :ans[a]=b
ans=sorted(ans.items(),key=lambda x:x[0])
print(ans)
for key,value in ans:
    K-=value
    if K<=0:break
print(key)

Submission status: Wrong Answer

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

ab = [[0, 0] for _ in range(n)]

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

i = 0
while K > indexes[i]:
    i += 1
print(nums[i])

Submission status: Wrong Answer

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

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

B=1

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

Submission status: Wrong Answer

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

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

B=1

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

Submission status: Wrong Answer

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

for i in range(N):
  a,b=tuple(map(int,input().split()))
  if B>=K :
    print(a)
    quit()
  B+=b

Submission status: Wrong Answer

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

for i in range(N):
    if cnt <= K <= cnt + B[i]:
        print(A[i]) 
        break
    cnt += B[i]

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = []
fron = 0
for i in range(n):
    o,p =map(int,input().split())
    a += [o] * p
    coun = p + fron
    if coun >= k:
        break
    fron = coun
print(a[k-1])

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
cnt = 0
for i in range(N):
    a, b = map(int, input().split())
    if cnt <= K <= cnt + b:
        print(a) 
    cnt += b

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
cnt = 1
for i in range(N):
    a, b = map(int, input().split())
    if cnt <= K <= cnt + b:
        print(a) 
    cnt += b

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline


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

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

    count = 0
    for index in range(n):
        count += l[index][1]

        if count >= k:
            break

    print(l[index][0])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n, k = map(int,input().split())
ans = [int(0)]*(10**5+1)

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

for j in range(1, 10^5+1):
  if k<=ans[j]:
    print(j)
    break
  k-= ans[j]

Submission status: Wrong Answer

Solution code:
n, k = map(int,input().split())
ans = [int(0)]*(10**5+1)

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

for j in range(10^5+1):
  if k<=ans[j]:
    print(j)
    break
  k-= ans[j]

Submission status: Wrong Answer

Solution code:
n, k = map(int,input().split())
kk = k
for i in range(n):
  a, b = map(int,input().split())
  if kk-b<=0:
    print(a)
    break
  else:
    kk-=b

Submission status: Wrong Answer

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

A = [[0]*2 for i in range(N)]



for i in range(N):
	A[i] = [int(x) for x in input().split()]

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

print(A[i][0])

Submission status: Wrong Answer

Solution code:
#ABC061C
import sys
N, K = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
now = 0
ans = ""
for a, b in ab:
    for i in range(b):
        now += 1
        if now == K:
            print(a)
            sys.exit()

Submission status: Wrong Answer

Solution code:
#ABC061C
N, K = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
now = 0
ans = ""
for a, b in ab:
    for i in range(b):
        now += 1
        if now == K:
            print(a)
            break

Submission status: Wrong Answer

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

x = 0
for i in ab:
  x += int(i[1])
  if x >= k:
    print(i[0])
    exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

b = 0
for i in ab:
  b += int(i[1])
  if b >= k:
    print(i[0])
    exit()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n,k=map(int,input().split())
l=[0]*10**5
for i in range(n):
    a,b=map(int,input().split())
    l[a-1]+=b
s=0
for i in range(n):
    if s+l[i]>=k:print(i+1);break
    else: s+=l[i]

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
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())
s=0
for i in range(n):
    if s+b[i]>=k:print(a[i]);break
    else:s+=b[i]

Submission status: Wrong Answer

Solution code:
import sys

n, k = (int(x) for x in sys.stdin.readline().split())
a_b_list = [[int(x) for x in sys.stdin.readline().split()] for y in range(n)]
total_index = 0
for i in a_b_list:
    total_index += i[1]
for i in reversed(a_b_list):
    start = total_index
    end = total_index - i[1] + 1
    if start >= k >= end:
        print(i[0])
        sys.exit(0)
    else:
        total_index -= i[1]

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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(l[K-1])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
#ABC061C
import math

#n = int(input())
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

n=hoge[0]
k=hoge[1]

a=[]
b=[]
total=0
for i in range(0,n):
	tmp = input().split()
	hoge = list(map(lambda a: int(a), tmp))
	a.append(hoge[0])
	b.append(hoge[1])
	total+=hoge[1]

c=[]
for i in range(0,n):
	c.append((a[i],b[i]))
c.sort()

thr=0
for i in range(0,n):
	thr+=b[i]
	if(thr>=k):
		print(a[i])
		break

Submission status: Wrong Answer

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 = defaultdict(int)
    for i in range(1, n + 1): d[i] = 0
    for i in range(n):
        a, b = LI()
        d[a] += b
    for key, valus in d.items():
        k -= valus
        if k <= 0:
            print(key)
            return
    return

#D
def D():
    return

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

Submission status: Wrong Answer

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()
i = 0
count=0
while(True):
    count += A[i][1]
    if count > N:
        print(A[i+1][0])
        break
    elif count == N:
        print(A[i][0])
        break
    i += 1

Submission status: Wrong Answer

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()
i = 0
count=0
while(True):
    count += A[i][1]
    if count >= N:
        print(A[i+1][0])
        break
    i += 1

Submission status: Wrong Answer

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()
i = 0
count=0
while(True):
    count += A[i][1]
    if count > N:
        print(A[i][0])
        break
    i += 1

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
acc = 0
while True:
    a, b = map(int, input().split())
    acc += b
    if K <= acc:
        print(a)
        break

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
inp=[list(map(int,input().split())) for _ in range(N)]
for i,j in inp:
    if M>j:
        M-=j
    else:
        print(i)
        break

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
n,k=map(int,input().split())
s=sorted([list(map(int,input().split())) for _ in range(n)])
ans=0
for a,b in s:
    if b<=k:
        print(a)
        exit()

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
s=[]
c=0
for i in range(n):
    a,b=map(int,input().split())
    c+=b
    if k<=c:
        print(a)
        break

Submission status: Wrong Answer

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()
c=0
for i in range(n):
    c+=ab[i][1]
    if c>k:
        print(ab[i][0])
        exit()

Submission status: Wrong Answer

Solution code:
# 操作回数（N）および数を求めたい順位（K）を入力する
N, K = map(int, input().split())
# 挿入する整数（a）とその個数（b）の組を格納するリスト（list_ab）を定義する
list_ab = []
# 各操作において、、
for _ in range(N):
    # aおよびbを入力する
    a, b = map(int, input().split())
    # list_abにaとb個の組を追加する
    list_ab.append((a, b))
# bの合計を計算する変数（sum_b）を定義する
sum_b = 0
# 各a、bの組について、、
for a, b in list_ab:
    # sum_bにbを足す
    sum_b += b
    # sum_bがK以上になった場合、、
    if sum_b >= K:
        # aを出力する
        print(a)
        break

Submission status: Wrong Answer

Solution code:
# 操作回数（N）および数を求めたい順位（K）を入力する
N, K = map(int, input().split())
# 挿入する整数（a）とその個数（b）の組を格納するリスト（list_ab）を定義する
list_ab = []
# 各操作において、、
for _ in range(N):
    # aおよびbを入力する
    a, b = map(int, input().split())
    # list_abにaとb個の組を追加する
    list_ab.append((a, b))
# bの合計を計算する変数（sum_b）を定義する
sum_b = 0
# 各a、bの組について、、
for a, b in list_ab:
    # sum_bにbを足す
    sum_b += b
    # sum_bがK以上になった場合、、
    if sum_b >= K:
        # aを出力する
        print(a)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
for i in range(n):
    a,b=map(int,input().split())
    if k>b:
        k-=b
    else:
        print(a)
        break

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

N, K = map(int, input().split())
li = [list(map(int, input().split())) for i in range(N)]
total = 0

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

N, K = map(int, input().split())
li = [list(map(int, input().split())) for i in range(N)]
arr = [[li[i][0] for j in range(li[i][1])] for i in range(N)]
arr = sum(arr, [])
print(arr[K - 1])

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

N, K = map(int, input().split())
li = [list(map(int, input().split())) for i in range(N)]
crr_arr = []
arr = []
my_extend = arr.extend

for i in range(N):
    crr_arr = [li[i][0] for j in range(li[i][1])]
    my_extend(crr_arr)
print(arr[K - 1])

Submission status: Wrong Answer

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

def main():
    k = K
    ans = 0
    for i in range(N):
        n, i = [int(s) for s in input().split()]
        k -= i
        if not ans and k <= 0:
            ans = n
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(N)]
a = sorted(a, key = lambda x: x[1])
for i in range(N):
	if K > a[i][1]:
		K -= a[i][1]
	else:
		print(a[i][0])
		exit()
print(a[N - 1][0])

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
now = 0
for _ in range(N):
    a, b = map(int, input().split())
    now += b
    if now >= K:
        print(a)
        exit()

Submission status: Wrong Answer

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))
for i in l:
    K-=D[i]
    if K<=0:
        print(i)
        exit()

Submission status: Wrong Answer

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.sort()
for i in L:
    K-=D[i]
    if K<=0:
        print(i)
        exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
n,k=map(int,input().split())
cnt=0
ans=[]
for i in range(n):
    a,b=map(int,input().split())
    cnt+=b
    if k<=cnt:
        ans.append(a)
print(ans[0])

Submission status: Wrong Answer

Solution code:
import sys
n,k=map(int,input().split())
cnt=0
for i in range(n):
    a,b=map(int,input().split())
    cnt+=b
    if k<=cnt:
        print(a)
        sys.exit()

Submission status: Wrong Answer

Solution code:
n,k=[int(i) for i in input().split()]
ab=[[int(j) for j in input().split()] for _ in range(n)]
for a,b in ab:
    k-=b
    if k<=0:
        print(a)
        break

Submission status: Wrong Answer

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


def solve(N: int, K: int, a: "List[int]", b: "List[int]"):
    nt = -1
    for i in range(N):
        nt += b[i]
        if(nt >= K-1):
            print(a[i])
            exit()
        else:
            continue

    print(a[-1])


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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: Wrong Answer

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


def solve(N: int, K: int, a: "List[int]", b: "List[int]"):
    ans = []
    for i in range(N):
        ans += [a[i]] * b[i]

    print(ans[K-1])
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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: Wrong Answer

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

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

array.sort

print(array[K-1])

Submission status: Wrong Answer

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

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

array.sort

print(array[3])

Submission status: Wrong Answer

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

stock = 0

for a,b in AB:
    stock += b
    if stock >= k:
        print(a)
        break

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
ls = [[int(x) for x in input().split()] for _ in range(n)]
from collections import defaultdict
d = defaultdict(int)
for i in range(n):
    d[ls[i][0]] +=ls[i][1]

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

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

Submission status: Wrong Answer

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

d = sorted(d)
s = 0
ans = 0
for a, b in d:
    s += b
    if (s > k):
        break
    ans = a

print(ans)

Submission status: Wrong Answer

Solution code:
n, k = list(map(int, input().split()))
cur = 0
for i in range(n):
  a, b = list(map(int, input().split()))
  cur += b
  if cur>=k:
    print(a)
    break

Submission status: Wrong Answer

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: Wrong Answer

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):

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

    K -= buff[i]

Submission status: Wrong Answer

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(__max):

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

    K -= buff[i]