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

Solution code:
n, k = map(int, input().split())
d = {}
for _ in range(n):
    a, b = map(int, input().split())
    if a in d:
        d[a] += b
    else:
        d[a] = b
d = dict(sorted(d.items()))
cnt = 0
for key, v in d.items():
    cnt += v
    if cnt >= k:
        print(key)
        break

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

AB.sort()

cnt=0
for i in range(N):
    cnt+=AB[i][1]

    if cnt>=K:
        ans=AB[i][0]
        break

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

for k, v in sorted(num.items()):
    cnt += v
    if K <= cnt:
        print(k)
        exit()

Submission status: Accepted

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

c=0
for ab in AB:
  c+=ab[1]
  if c>=K:
    exit(print(ab[0]))

Submission status: Accepted

Solution code:
#!/usr/bin.env python3

N,K = map(int,input().split())
queries = [list(map(int,input().split())) for _ in range(N)]

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

arrayLength = 0
for i in range(N):
  arrayLength += queries[i][1]
  if arrayLength >= K:
    print(queries[i][0])
    exit()
print(-1)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)]
ab.sort()
c=0
#print(ab)
for i in range(n):
    c+=ab[i][1]
    if c>=k:
        print(ab[i][0])
        exit()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
offset = 10**6

def main():
    N, K = map(int, input().split())
    pair = []
    for _ in range(N):
        a, b = map(int, input().split())
        pair.append((a * offset + b))
    pair.sort()
    num = 0
    for val in pair:
        a, b = val // offset, val % offset
        if num + b < K:
            num += b
            continue
        print(a)
        return


    for p in path: print(p)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Solution code:
n, k = map(int, input().split())
ab = []
for _ in range(n):
    a, b = map(int, input().split())
    ab.append([a, b])
ab.sort(key=lambda x: x[0])

for a, b in ab:
    k -= b
    if k <= 0:
        ans = a
        break
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

ab = sorted(ab)
cum = 0
for i in range(N):
  cum += ab[i][1]
  if cum >= K:
    print(ab[i][0])
    exit()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
ab = []
for _ in range(n):
    a, b = map(int, input().split())
    ab.append([a, b])
ab.sort(key=lambda x: x[0])

for a, b in ab:
    k -= b
    if k <= 0:
        ans = a
        break
print(ans)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
d={}
for _ in range(n):
    a,b=map(int,input().split())
    if a in d:
        d[a]+=b
    else:
        d[a]=b
s=0
for i in sorted(d):
    s+=d[i]
    if s>=k:
        print(i)
        exit()

Submission status: Accepted

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

Submission status: Accepted

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

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

c = 0
for a, b in x:
    c += b
    if K <= c:
        print(a)
        exit()

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
l=[[*map(int,input().split())] for i in range(n)]
l.sort(key=lambda x:x[0])
for i,j in l:
    k-=j
    if k<=0:
        print(i)
        break

Submission status: Accepted

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

sum=0
for i in range(100001):
  sum+=list[i]
  if(sum>=K):
    print(i)
    break

Submission status: Accepted

Solution code:
from collections import Counter
N, K = map(int, input().split())

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

x = list(cnt.items())
x.sort()

now = 0
for k, v in x:
    now += v
    if K <= now:
        print(k)
        break

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

# 取得される値とその出現回数を保存
d = {}
for _ in range(n):
  a,b = map(int, input().split())
  if a not in d: d[a] = b
  else: d[a] += b

# 値の小さい順にカウントしていき、kを超えた時点の値をk番目の値とする
t = 0
for i in sorted(d.items(), key=lambda x:x[0]):
  t += i[1]
  if t >= k:
    print(i[0])
    exit()

Submission status: Accepted

Solution code:
import math

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

abL = []
for i in range(n):
    abL.append(list(map(int, input().split(" "))))

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

cnt = 0
for a, b in abL:
    cnt += b
    if cnt >= k:
        print(a)
        exit()

Submission status: Accepted

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

for a in U:
    if T[a]>=K:
        print(a)
        break
    else:
        K-=T[a]

Submission status: Accepted

Solution code:
import sys

N,K=map(int,input().split())
D=dict()
for i in range(N):
  a,b=map(int,input().split())
  try:
    D[a]+=b
  except:
    D[a]=b

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


for k,v in D:
  K-=v
  if K<=0:
    print(k)
    break

Submission status: Accepted

Solution code:
def solve():
  ans = 0
  cnt = 0
  N, K = map(int, input().split())
  A = [list(map(int, input().split())) for _ in range(N)]
  A.sort()
  for a,b in A:
    cnt += b
    if cnt>=K:
      ans = a
      break
  return ans
print(solve())

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import collections
import bisect


def main():
    n, k = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in range(n)]
    ab.sort(key=lambda x: x[0])
    cnt = 0
    for i in range(len(ab)):
        cnt += ab[i][1]
        if cnt >= k:
            print(ab[i][0])
            return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(N)]
a.sort()
cnt = 0
for i in range(N):
    cnt += a[i][1]
    if cnt >= K:
        print(a[i][0])
        exit()

Submission status: Accepted

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

  if sm>=k:
    print(i)
    break

Submission status: Accepted

Solution code:
N,K = (int(T) for T in input().split())
Ins = [[] for T in range(0,N)]
for TN in range(0,N):
    Ins[TN] = [int(T) for T in input().split()]
InsSort = sorted(Ins)
Total = 0
for TN in range(0,N):
    if Total<K<=Total+InsSort[TN][1]:
        print(InsSort[TN][0])
        break
    else:
        Total += InsSort[TN][1]

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
(n, k), *q = [[*map(int, i.split())] for i in open(0)]
bucket = [0] * (10**5 + 1)
for a, b in q:
    bucket[a] += b
for n, i in enumerate(bucket):
    k -= i
    if k <= 0:
        print(n)
        break

Submission status: Accepted

Solution code:
import sys

n, k = map(int, input().split())
element = [None]*n

for i in range(n):
  element[i] = [int(x) for x in input().split()]

element.sort()

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
(n, k), *q = [[*map(int, i.split())] for i in open(0)]
q.sort()
for a, b in q:
    k -= b
    if k <= 0:
        print(a)
        break

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[19]:


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


# In[20]:


mydict_s = sorted(mydict.items(), key=lambda x:x[0])
cnt = 0
for i,items in enumerate(mydict_s):
    cnt += items[1]
    if cnt >= K:
        ans = items[0]
        break
print(ans)


# In[ ]:

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
L=list()
s=0
for i in range(a):
  x,y=map(int,input().split())
  L.append([x,y])
L=sorted(L)
for i in range(a):
  s+=L[i][1]
  if s>=b:
    print(L[i][0])
    break

Submission status: Accepted

Solution code:
from collections import deque
N, K = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(N)]
L.sort(key = lambda x: x[0])
L = deque(L)
while K>L[0][1]:
  K -= L[0][1]
  L.popleft()
print(L[0][0])

Submission status: Accepted

Solution code:
import sys
N, K = list(map(int, input().split()))
V = [list(map(int, input().split())) for _ in range(N)]
V.sort()
cnt = 0
res = 0
for v in V:
    cnt += v[1]
    if cnt >= K:
        print(v[0])
        sys.exit()

Submission status: Accepted

Solution code:
n,m = map(int,input().split()); sus = {}
for _ in range(n):
  a,b = map(int,input().split())
  sus[a] = sus[a]+b if a in sus else b
fef = sorted(sus.items()); snaas = 0
for cuc in fef:
  snaas += cuc[1]
  if snaas >= m: print(cuc[0]); exit()

Submission status: Accepted

Solution code:
n , k = map(int , input().split())
arr = []
for i in range(0 , n):
	arr.append(list(map(int , input().split())))
# sort according the element of the array first value
arr.sort()
cur =0
# continue to add the frequency of every element in increasing order upto k
for i in range(0 , n):
	if cur + arr[i][1]<k:
		cur = cur+arr[i][1]
	else:
		print(arr[i][0])
		exit()

Submission status: Accepted

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

Submission status: Accepted

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

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

cnt = 0

for ab in A:
    a = ab[0]
    b = ab[1]

    cnt += b
    if cnt >= K:
        print(a)
        exit()

Submission status: Accepted

Solution code:
n,k=map(int, input().split())
l=[tuple(map(int, input().split())) for _ in range(n)]
l.sort()
a,b=0,0
for t in l:
    b=a+t[1]
    if a<k<=b:
        print(t[0])
        exit()
    a=b
print(l)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = [int(x) for x in input().split()]
temp_list = sorted([[int(x) for x in input().split()] for _ in range(n)])
ans = 0
for a, b in temp_list:
    k -= b
    if k <= 0:
        ans = a
        break
print(a)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc061/tasks/abc061_c

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

arr = []
for _ in range(n):
    a, b = map(int, input().split())
    arr.append((a, b))
arr.sort(key=lambda x: x[0])

for a, b in arr:
    k -= b
    if k <= 0:
        print(a)
        break

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, *AB = map(int, read().split())
    vec = [0] * (10 ** 5 + 1)
    for a, b in zip(*[iter(AB)] * 2):
        vec[a] += b

    total = 0
    for i, n in enumerate(vec):
        total += n
        if total >= K:
            ans = i
            break

    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, *AB = map(int, read().split())
    c = Counter()
    for a, b in zip(*[iter(AB)] * 2):
        c[a] += b

    num = 0
    for k, n in sorted(c.items()):
        num += n
        if num >= K:
            ans = k
            break

    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc061/tasks/abc061_c
import sys

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

    cnt = 0
    for i in range(10**5+1):
        cnt += ans[i]
        if cnt >= k:
            print(i)
            exit()

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict
n,k=map(int,input().split())
dd=defaultdict(lambda: 0)
for i in range(n):
  a,b=map(int,input().split())
  dd[a]+=b
cur_k=k
for k in sorted(dd.keys()):
  v=dd[k]
  cur_k-=v
  if cur_k <= 0:
    print(k)
    exit()

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(n)]
a.sort(key=lambda x:x[0])
ans,i = 0,0
t = 0
while(ans < k):
	ans += a[i][1]
	t = a[i][0]
	i += 1
print(t)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
A = []
for _ in range(n):
    a,b = map(int,input().split())
    A.append([a,b])
A.sort()
for a,b in A:
    if k >b:
        k -=b
    else:
        print(a);exit()

Submission status: Accepted

Solution code:
import collections
[n,k] = [int(i) for i in input().split()]
dic = collections.defaultdict(int)
for i in range(n):
  [a,b] = [int(j) for j in input().split()]
  dic[a] += b
keys = sorted(list(dic.keys()))
tmp = 0
for key in keys:
  tmp += dic[key]
  if k <= tmp:
    print(key)
    break

Submission status: Accepted

Solution code:
from collections import defaultdict
def main():
    n, k = map(int, input().split())
    D = defaultdict(int)
    for _ in range(n):
        a, b = map(int, input().split())
        D[a] += b
    for d in sorted(D.items(), key = lambda x: x[0]):
        k -= d[1]
        if k <= 0:
            print(d[0])
            break

if __name__ == '__main__':
    main()

Submission status: Accepted

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

ab.sort()
c = 0
for i in range(N):
    c += ab[i][1]
    if c >= K:
        print(ab[i][0])
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    '''
    code here
    '''

    N, K = [int(item) for item in input().split()]
    queries = [[int(item) for item in input().split()] for _ in range(N)]

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

    temp_que = []
    for num, val in queries:
        temp_que = num
        K -= val
        if K <= 0:
            break

    print(temp_que)

if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
import 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: Accepted

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

L = []
for i in range(10**5+1):
    L.append(0)

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

a = 0
while K > 0:
    a += 1
    K -= L[a]
    
print(a)

Submission status: Accepted

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

cnt = 0
for a, b in num:
    cnt += b
    if cnt >= k:
        print(a)
        break

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
d = {}
for _ in range(n):
    a,b = map(int,input().split())
    if not a in d:
        d[a] = b
    else:
        d[a] += b

c = 0
for v in sorted(d.items()):
    c += v[1]
    if k <= c:
        print (v[0])
        exit ()

Submission status: Accepted

Solution code:
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

N,K = MI()

from collections import defaultdict

d = defaultdict(int)
for i in range(N):
    a,b = MI()
    d[a] += b

A = list(d.keys())
A.sort()

a = 0
for b in A:
    if K <= a+d[b]:
        print(b)
        break
    else:
        a += d[b]

Submission status: Accepted

Solution code:
import heapq
n, k = map(int, input().split())
hq = []
total = 0
for i in range(n):
    a, b = map(int, input().split())
    heapq.heappush(hq, (-a, b))
    total += b

while total >= k:
    a, b = heapq.heappop(hq)
    total -= b

print(abs(a))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def INT():
    return int(input())

def MI():
    return map(int, input().split())

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

from collections import Counter
N, K = MI()
add = Counter([])

for _ in range(N):
    a, b = MI()
    tmp = add[a]
    add[a] = b
    add[a] += tmp

num = sorted(list(add.keys()))
cnt = 0

for n in num:
    cnt += add[n]
    if cnt >= K:
        print(n)
        break

Submission status: Accepted

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

for a, b in ab:
    k -= b
    if k <= 0:
        print(a)
        break

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase
from bisect import bisect_left
MOD = int(1e9)+7
INF = float('inf')


def solve():
    # n, m = [int(x) for x in input().split()]
    n, k = [int(x) for x in input().split()]
    d = defaultdict(int)
    for _ in range(n):
        a, b = [int(x) for x in input().split()]
        d[a] += b
    a = [(x, d[x]) for x in d]
    a.sort()
    i = 0
    while k > a[i][1]:
        k -= a[i][1]
        i += 1

    print(a[i][0])

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

azyxwvutsrqponmlkjihgfedcb

"""

Submission status: Accepted

Solution code:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from bisect import bisect_left

n,k=nii()

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

Solution code:
from collections import defaultdict

n, k = map(int, input().split())
ab = sorted(list(map(int, input().split())) for _ in range(n))

for a, b in ab:
    k -= b
    if k <= 0:
        print(a)
        break

Submission status: Accepted

Solution code:
from collections import defaultdict

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

nums, numd = set(), defaultdict(int)
for a, b in ab:
    nums.add(a)
    numd[a] += b
for i in sorted(nums):
    k -= numd[i]
    if k <= 0:
        print(i)
        break

Submission status: Accepted

Solution code:
s = input().split()
n = int(s[0])
k = int(s[1])

arrays = []
answer = 0
count = 0

for i in range(100001):
    arrays.append(0)

for i in range(n):
    v = input().split()
    p = int(v[0])
    q = int(v[1])
    arrays[p] += q

for i in range(len(arrays)):
    if not arrays[i] == 0:
        count += arrays[i]
        if k <= count:
            answer = i
            break

print(answer)

Submission status: Accepted

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

for n in range(N):
  c+=A[n][1]
  if K<=c:
    print(A[n][0])
    break

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect

sys.setrecursionlimit(10**6)


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


N, K = zz()
A, B = [0]*N, [0]*N
# 力技はだめ
for i in range(N):
    A[i], B[i] = zz()
A, B = zip(*sorted(zip(A, B)))
all_num = 0
for i, b in enumerate(B):
    all_num += b
    if (all_num >= K):
        print(A[i])
        exit()

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
d= {}
for i in range(n):
    a,b=map(int, input().split())
    if d.get(a):
        d[a] +=b
    else:
        d[a] = b
res = 0
for key in sorted(d.keys()):
    if d[key]+res>=k:
        print(key)
        exit()
    res += d[key]

Submission status: Accepted

Solution code:
import numpy as np


def main():
    n, k = map(int, input().split())
    Counts = [0] * (10**5 + 1)
    for _ in range(n):
        a, b = map(int, input().split())
        Counts[a] += b
    cumsum = np.cumsum(Counts)
    for i in range(10**5+1):
        if cumsum[i] >= k:
            ans = i
            break
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n,k,*ab = map(int,open(0).read().split())
ab = [(ab[i*2],ab[i*2+1]) for i in range(n)]
ab.sort(key = lambda x:x[0])
c = 0
for i,j in ab:
  c += j
  if c >= k:
    break
print(i)

Submission status: Accepted

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

for i in range(N):
    K -= AB[i][1]
    if K <= 0:
        print(AB[i][0])
        break

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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.sort()
cnt = 0
ans = 0
i = 0
while cnt < K:
  ans = l[i][0]
  cnt += l[i][1]
  i += 1
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict

N, K = map(int, input().split())
d = defaultdict(int)
for i in range(N):
    a, b = map(int, input().split())
    d[a] += b
for k in sorted(d.keys()):
    K -= d[k]
    if K <= 0:
        print(k)
        exit()

Submission status: Accepted

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

ans = 0
lis = [0] *(10**5 +1)

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

tmp = 0
for j in range(len(lis)):
    tmp += lis[j]
    if tmp >= k:
        print(j)
        break

Submission status: Accepted

Solution code:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n,k = lr()
dic = {}
for i in range(n):
    a,b = lr()
    if a in dic:
        dic[a]+=b
    else:
        dic[a]=b
dic = sorted(dic.items())
for K,v in dic:
    if k > v:
        k -= v
    else:
        print(K)
        sys.exit()

Submission status: Accepted

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