Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
student=[list(map(int,input().split())) for i in range(n)]
point=[list(map(int,input().split())) for i in range(n)]
for a,b in student:
  length=10**10
  pn=0
  for j in range(m):
    c,d=point[j]
    if abs(a-c)+abs(b-d)<length:
      length=abs(a-c)+abs(b-d)
      pn=1+j
  print(pn)

Fixed submission:
n,m=map(int,input().split())
student=[list(map(int,input().split())) for i in range(n)]
point=[list(map(int,input().split())) for i in range(m)]

for a,b in student:
  length=10**10
  pn=0
  for j in range(m):
    c,d=point[j]
    if abs(a-c)+abs(b-d)<length:
      length=abs(a-c)+abs(b-d)
      pn=1+j
  print(pn)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
student=[list(map(int,input().split())) for i in range(n)]
point=[list(map(int,input().split())) for i in range(n)]
for a,b in student:
  length=10**10
  pn=0
  for j in range(m):
    c,d=point[j]
    if abs(a-c)+abs(b-d)<length:
      length=abs(a-c)+abs(b-d)
      pn+=1
  print(pn)

Fixed submission:
n,m=map(int,input().split())
student=[list(map(int,input().split())) for i in range(n)]
point=[list(map(int,input().split())) for i in range(m)]

for a,b in student:
  length=10**10
  pn=0
  for j in range(m):
    c,d=point[j]
    if abs(a-c)+abs(b-d)<length:
      length=abs(a-c)+abs(b-d)
      pn=1+j
  print(pn)

Buggy python submission (verdict: Runtime Error):
yandy
n, m = map(int, input().split())

student = []

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

point = []

for j in range(m):
    c, d = map(int, input().split())
    point.append((c, d))

for a, b in student:
    length = 10 ** 10
    pn = 0
    for j in range(m):
        c, d = point[j]
        if abs(a-c) + abs(b-d) < length:
            length = abs(a-c) + abs(b-d)
            pn = j + 1
    print(pn)


Fixed submission:
n,m=map(int,input().split())
student=[list(map(int,input().split())) for i in range(n)]
point=[list(map(int,input().split())) for i in range(m)]

for a,b in student:
  length=10**10
  pn=0
  for j in range(m):
    c,d=point[j]
    if abs(a-c)+abs(b-d)<length:
      length=abs(a-c)+abs(b-d)
      pn=1+j
  print(pn)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
mod=10**9+7
power=1
for i in range(1,n+1):
  power=power*i
print(power%mod)

Fixed submission:
n=int(input())
mod=10**9+7
power=1
for i in range(1,n+1):
  power=power*i%mod
print(power)
Buggy python submission (verdict: Runtime Error):
yandy
N, M = map(int, input().split())
A = [''] * N
B = [''] * M

for i in range(N):
    A[i] = input()
for j in range(M):
    B[j] = input()

for i in range(N-M+1):
    for j in range(N-M+1):
        NO = False
        for x in range(M):
            a = A[i+x][j:j+M]
            if a != B[x]:
                NO = True
                break
        if not NO:
            print('Yes')
            exit()

print('No')


Fixed submission:
n, m = map(int, input().split())
a = [input() for i in range(n)]
b = [input() for i in range(m)]
for k in range(n-m+1):
  for j in range(n-m+1):
    h="true"
    for i in range(m):
      if a[k+i][j:j+m]!=b[i]:
        h="false"    
    if h=="true":
      print("Yes")
      exit()
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
yandy
K, S = map(int, input().split())

ans = 0
for z in range(K+1):
    for y in range(K+1):
        if 0 <= S - z - y <= K:
            ans += 1

print(ans)


Fixed submission:
k,s=map(int,input().split())
count=0
for a in range(k+1):
  for b in range(k+1):
    if 0<=s-a-b<=k:
      count+=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
k,s=map(int,input().split())

count=0
for x in range (k+1):
  for y in range (k+1):
    for z in range(k+1):
      if x+y+z==s:
        count+=1
print(count)

Fixed submission:
k,s=map(int,input().split())
count=0
for a in range(k+1):
  for b in range(k+1):
    if 0<=s-a-b<=k:
      count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
yandy
n = int(input())
t = [int(i) for i in input().split()]
m = int(input())

ans = sum(t)
for i in range(m):
    p, x = map(int, input().split())
    print(ans - t[p-1] + x)


Fixed submission:
n=int(input())
t=[0]+[int(i) for i in input().split()]
m=int(input())
p=[[int(j) for j in input().split()] for i in range(m)]

total=sum(t)
for i in range(m):
  print(total-t[p[i][0]]+p[i][1])
Buggy python submission (verdict: Runtime Error):
satoooh
a, b, x = map(int, input().split())
print(b // x - (a - 1) // x)

Fixed submission:
a,b,x=map(int,input().split())

print(b//x-(a-1)//x)
Buggy python submission (verdict: Runtime Error):
s=input()
if "F" in s[s.index("C"):]:
  print("Yes")
else:
  print("No")

Fixed submission:
s=input()
try: 
  if "F" in s[s.index("C"):]:
    print("Yes")
  else:
    print("No")
 
except:
  print("No")
Buggy python submission (verdict: Runtime Error):
w = input()
print(set(w))
"""for i in set(w):
  print(w)
  if w.count(i)%2 != 0:
    print("No")
    exit()
print("Yes")"""
セットで出てくる文字列を絞って数える

Fixed submission:
s=list(input())
s.sort()
if len(s)%2==1 and s[0]==s[-1]:
  print("No")
  
else:
  ans=0
  for i in range(len(s)-1):
    if s[i]==s[i+1]:
      ans+=1
    else:
      if ans%2==0:
        print("No")
        break
      else:
        ans=0
        pass
  else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
countlist = [0 for i in range(n)]
for j in range(n):
    countlist[a[j]-1]+=1
for i in range(n):
    print(countlist[i])

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
countlist = [0 for i in range(n)]
for j in range(n-1):
    countlist[a[j]-1]+=1
for i in range(n):
    print(countlist[i])
Buggy python submission (verdict: Runtime Error):
N, M=map(int,input().split())
alist = list(map(int,input().split()))
alist.sort(reverse = True)
su = 0
correct = True
for i in alist:
    su += i
for i in range[M-1]:
    if alist[i] < 1/(4*M) :
        print("No")
        correct = False
if correct:
    print("Yes")


Fixed submission:
N, M=map(int,input().split())
alist = list(map(int,input().split()))
alist.sort(reverse = True)
abc = sum(alist)
if alist[M-1] >= abc/(4*M):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
N, M=map(int,input().split())
alist = list(map(int,input().split()))
alist.sort(reverse = True)
sum = 0
correct = True
for i in alist:
    sum += i
for i in range[M-1]:
    if alist[i] < 1/(4*M) :
        print("No")
        correct = False
if correct:
    print("Yes")

Fixed submission:
N, M=map(int,input().split())
alist = list(map(int,input().split()))
alist.sort(reverse = True)
abc = sum(alist)
if alist[M-1] >= abc/(4*M):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)
N=input()
n=list()
m=list()
for i in range(N-1):
    if(i%3==0 or i%5==0):
        n.append(i)
    else:
        m.append(i)
print(sum(m))

Fixed submission:
N=int(input())
P=0
for i in range(N+1):
    if i%3!=0 and i%5!=0:
        P+=i
print(P)
Buggy python submission (verdict: Runtime Error):
c=input()
print("vowel"if c=='a','i','u','e','o' else "constant")

Fixed submission:
c=input()
print("vowel"if c in "aiueo" else "consonant")

Buggy python submission (verdict: Runtime Error):
N=input()
print("vowel"if N=='a','i','u','e','o' else "constant")

Fixed submission:
c=input()
print("vowel"if c in "aiueo" else "consonant")
Buggy python submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())

while True:
  C -= B

  if (C <= 0):
    print('Yes')
    return
  
  A -= D
  if (A <= 0):
    print('No')
    return


Fixed submission:
A, B, C, D = map(int, input().split())

result = ''
while True:
  C -= B

  if (C <= 0):
    result = 'Yes'
    break
  
  A -= D
  if (A <= 0):
    result = 'No'
    break

print(result)
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
K = int(input())

result = 0
for k in range(1, K + 1):
  for l in range(1, K + 1):
    for m in range(1, K + 1):
      gcd_res = gcd(gcd(k, l), m)
      result += gcd_res

print(result)


Fixed submission:
def euclid(a, b):
  division = a if (a > b) else b
  divider = b if (a > b) else a
  reminder = 0
  while divider != 0:
    reminder = division % divider
    division = divider
    divider = reminder
  
  return division

K = int(input())

result = 0
for k in range(1, K + 1):
  for l in range(1, K + 1):
    for m in range(1, K + 1):
      gcd = euclid(euclid(k, l), m)
      result += gcd

print(result)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
K = int(input())

result = 0
for k in range(1, K + 1):
  for l in range(1, K + 1):
    for m in range(1, K + 1):
      gcd_kl = fractions.gcd(k, l)
      gcd_klm = fractions.gcd(gcd_kl, m)
      result += gcd_klm

print(result)


Fixed submission:
def euclid(a, b):
  division = a if (a > b) else b
  divider = b if (a > b) else a
  reminder = 0
  while divider != 0:
    reminder = division % divider
    division = divider
    divider = reminder
  
  return division

K = int(input())

result = 0
for k in range(1, K + 1):
  for l in range(1, K + 1):
    for m in range(1, K + 1):
      gcd = euclid(euclid(k, l), m)
      result += gcd

print(result)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

guess = []
for _ in range(M):
  s, c = map(int, input().split())
  guess.append([s, c])

for n in range(pow(10, N)):
  if (len(str(n)) != N):
    continue
  
  valid = True
  for s_c in guess:
    keta = s_c[0]
    index = keta - 1
    if (str(n)[index] != str(s_c[1])):
      valid = False
      break
  
  if (valid == False):
    continue
  else:
    print(n)
    return

print(-1)

Fixed submission:
N, M = map(int, input().split())

guess = []
for _ in range(M):
  s, c = map(int, input().split())
  guess.append([s, c])

result = -1
for n in range(pow(10, N)):
  if (len(str(n)) != N):
    continue
  
  valid = True
  for s_c in guess:
    keta = s_c[0]
    index = keta - 1
    if (str(n)[index] != str(s_c[1])):
      valid = False
      break
  
  if (valid == False):
    continue
  else:
    result = n
    break

print(result)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int, input().split()))
result = 0

# for i, p in enumerate(P):
#     subary = P[:i+1]
#     if (min(subary) >= p):
#         result += 1

for i in range(len(P)):
    subary = P[:i+1]
    if (min(subary) >= P[i]):
        result += 1

print(result)


Fixed submission:
N = int(input())
P = list(map(int, input().split()))
result = 0

minValue = P[0]

for i, p in enumerate(P):
  if (minValue >= p):
    result += 1
    minValue = p

print(result)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int, input().split()))
result = 0

for i in range(len(P)):
    subary = P[:i+1]
    if (min(subary) >= P[i]):
        result += 1

print(result)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))
result = 0

minValue = P[0]

for i, p in enumerate(P):
  if (minValue >= p):
    result += 1
    minValue = p

print(result)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int, input().split()))
result = 0

for i, p in enumerate(P):
    subary = P[:i+1]
    if (min(subary) >= p):
        result += 1

print(result)


Fixed submission:
N = int(input())
P = list(map(int, input().split()))
result = 0

minValue = P[0]

for i, p in enumerate(P):
  if (minValue >= p):
    result += 1
    minValue = p

print(result)
Buggy python submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())

print(A*B//math.gcd(A, B))

Fixed submission:
import fractions
A, B = map(int, input().split())

print(A*B//fractions.gcd(A, B))

Buggy python submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())

print(A*B//math.gcd(A, B))


Fixed submission:
import fractions
A, B = map(int, input().split())

print(A*B//fractions.gcd(A, B))
Buggy python submission (verdict: Runtime Error):
N = int(input())

M = []
for _ in range(N):
  t, x, y = map(int, input().split())
  M.append([t, x, y])

current = [0, 0, 0]
can = True
for m in M:
  dt = m[0] - current[0]
  dist = abs(m[1] - current[1]) + abs(m[2] - current[2])
  if (dist > dt):
    can = False
    break
  else:
    if (dist % 2 != dt % 2):
      can = False
      break
  current = m

result = "Yes" if (can == True) else "No"
print(result)


Fixed submission:
a, b = map(int, input().split())
result = "Even" if (a*b % 2 == 0) else "Odd"
print(result)
Buggy python submission (verdict: Runtime Error):
jN = int(input())

M = []
for _ in range(N):
  t, x, y = map(int, input().split())
  M.append([t, x, y])

current = [0, 0, 0]
can = True
for m in M:
  dt = m[0] - current[0]
  dist = abs(m[1] - current[1]) + abs(m[2] - current[2])
  if (dist > dt):
    can = False
    break
  else:
    if (dist % 2 != dt % 2):
      can = False
      break
  current = m

result = "Yes" if (can == True) else "No"
print(result)

Fixed submission:
N = int(input())

M = []
for _ in range(N):
  t, x, y = map(int, input().split())
  M.append([t, x, y])

current = [0, 0, 0]
can = True
for m in M:
  dt = m[0] - current[0]
  dist = abs(m[1] - current[1]) + abs(m[2] - current[2])
  if (dist > dt):
    can = False
    break
  else:
    if (dist % 2 != dt % 2):
      can = False
      break
  current = m

result = "Yes" if (can == True) else "No"
print(result)
Buggy python submission (verdict: Runtime Error):
  s = input()
  print(s.count("1"))

Fixed submission:
s = input()
print(s.count("1"))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
AB = []
for _ in range(N):
  a, b = map(int, input().split())
  AB.append((a, b))

CD = []
for _ in range(M):
  c, d = map(int, input().split())
  CD.append((c, d))

check_index = []
for i, ab in enumerate(AB):
  min_index = 0
  for j, cd in enumerate(CD):
    check_dis = distance(ab, cd)
    min_dis = distance(ab, CD[min_index])
    if(min_dis > check_dis):
      min_index = j
  
  check_index.append(min_index)

for ci in check_index:
  print(ci + 1)


Fixed submission:
def distance(ab, cd):
  return abs(ab[0] - cd[0]) + abs(ab[1] - cd[1])

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

CD = []
for _ in range(M):
  c, d = map(int, input().split())
  CD.append((c, d))

check_index = []
for i, ab in enumerate(AB):
  min_index = 0
  for j, cd in enumerate(CD):
    check_dis = distance(ab, cd)
    min_dis = distance(ab, CD[min_index])
    if(min_dis > check_dis):
      min_index = j
  
  check_index.append(min_index)

for ci in check_index:
  print(ci + 1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

power = 1
for n in range(1, N+ 1):
  power *= n
result = power % (pow(10, 9) + 7)
print(result)


Fixed submission:
import math
N = int(input())

power = math.factorial(N)
result = power % (pow(10, 9) + 7)
print(result)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

A = []
for _ in range(N):
  a = input()
  A.append(a)

B = []
for _ in range(M):
  b = input()
  B.append(b)

existed = False
for i in range(N - M + 1):
  for j in range(N - M + 1):
    match = True
    for mi in range(M):
      for mj in range(M):
        x = i + mi
        y = j + mj

        if (A[y][x] != B[mj][mi]):
          match = False
          break
      
      if (match == False):
        break

    if (match):
      existed = True
      break
  
  if (existed):
    break

result = 'Yes' if (existed) else 'No'
print(result)


Fixed submission:
A, B = map(int, input().split())

result = ''
if (A == 1 and B != 1):
  result = 'Alice'
elif (B == 1 and A != 1):
  result = 'Bob'
elif (A > B):
  result = 'Alice'
elif (B > A):
  result = 'Bob'
elif (B == A):
  result = 'Draw'

print(result)
Buggy python submission (verdict: Runtime Error):
  A, B, C, D = map(int, input().split())
  areaA = A*B
  areaB = C*D
  result = areaA if (areaA > areaB) else areaB
  print(result)

Fixed submission:
A, B, C, D = map(int, input().split())
areaA = A*B
areaB = C*D
result = areaA if (areaA > areaB) else areaB
print(result)
Buggy python submission (verdict: Runtime Error):
Sa = input()
Sb = input()
Sc = input()

dic = {'a':Sa, 'b':Sb, 'c':Sc}

doCont = True
person = 'a'
result = ''
while doCont:
  if (len(dic[person]) == 0):
    doCont = False
    result = person.upper()

  drop_card = dic[person][0]
  dic[person] = dic[person][1:]
  person = drop_card

print(result)

Fixed submission:
Sa = input()
Sb = input()
Sc = input()

dic = {'a':Sa, 'b':Sb, 'c':Sc}

doCont = True
person = 'a'
result = ''
while doCont:
  if (len(dic[person]) == 0):
    doCont = False
    result = person.upper()
    break

  drop_card = dic[person][0]
  dic[person] = dic[person][1:]
  person = drop_card

print(result)
Buggy python submission (verdict: Runtime Error):
ins = list(map(int, input().split()))
N = ins[0]
L = ins[1]
Ss = []

for i in range(N):
  Ss.append(input())

for i, a in enumerate(Ss):
  key = a
  j = i - 1

  while j >= 0 and Ss[j] > a:
    Ss[j + 1] = Ss[j]
    j = j - 1

  Ss[j + 1] = key

print(' '.join(Ss))

Fixed submission:
arr = list(input().split())

result = "YES" if ((arr.count('5')) == 2 and (arr.count('7')) == 1) else "NO"

print(result)
Buggy python submission (verdict: Runtime Error):
N = int(input().splice()[0])
L = int(input().splice()[1])
Ss = []

for i in range(N):
  Ss[i] = input()

for i, a in enumerate(Ss):
  key = a
  j = i - 1

  while j >= 0 and Ss[j] > a:
    Ss[j + 1] = Ss[j]
    j = j - 1

  Ss[j + 1] = key

print(' '.join(Ss))

Fixed submission:
N, L = map(int, input().split())
S = []
for i in range(N):
    line = input()
    S.append(line)
S.sort()
print("".join(S))
Buggy python submission (verdict: Runtime Error):
def most_frequent(List):
    counter = 0
    num = List[0]

    for i in List:
        curr_frequency = List.count(i)
        if(curr_frequency> counter):
            counter = curr_frequency
            num = i

    return num

n = int(input())
c = []
for i in range(n):
    x,y = map(int,input().split())
    c.append([x,y])
c = sorted(c)
l = []
for i in range(len(c)-1):
    for j in range(i+1,len(c)):
        l.append([c[j][0]-c[i][0],c[j][1]-c[i][1]])

z = most_frequent(l)
l = 1
for i in range(1,len(c)):
    if([c[i][0]-z[0],c[i][1]-z[1]] not in c):
        l+=1
print(l)


Fixed submission:
def most_frequent(List):
    counter = 0
    num = List[0]

    for i in List:
        curr_frequency = List.count(i)
        if(curr_frequency> counter):
            counter = curr_frequency
            num = i

    return num

n = int(input())
c = []
for i in range(n):
    x,y = map(int,input().split())
    c.append([x,y])
c = sorted(c)
l = []
for i in range(len(c)-1):
    for j in range(i+1,len(c)):
        l.append([c[j][0]-c[i][0],c[j][1]-c[i][1]])
if(n==1):
    z = most_frequent(c)
else:
    z = most_frequent(l)
l = 1
for i in range(1,len(c)):
    if([c[i][0]-z[0],c[i][1]-z[1]] not in c):
        l+=1
print(l)

Buggy python submission (verdict: Runtime Error):
def most_frequent(List):
    counter = 0
    num = List[0]

    for i in List:
        curr_frequency = List.count(i)
        if(curr_frequency> counter):
            counter = curr_frequency
            num = i

    return num

n = int(input())
c = []
for i in range(n):
    x,y = map(int,input().split())
    c.append([x,y])
c = sorted(c)
l = []
for i in range(len(c)-1):
    l.append([c[i+1][0]-c[i][0],c[i+1][1]-c[i][1]])
z = most_frequent(l)
l = 1
for i in range(1,len(c)):
    if(c[i][0]-c[i-1][0]!=z[0] or c[i][1]-c[i-1][1]!=z[1]):
        l+=1
print(l)


Fixed submission:
def most_frequent(List):
    counter = 0
    num = List[0]

    for i in List:
        curr_frequency = List.count(i)
        if(curr_frequency> counter):
            counter = curr_frequency
            num = i

    return num

n = int(input())
c = []
for i in range(n):
    x,y = map(int,input().split())
    c.append([x,y])
c = sorted(c)
l = []
for i in range(len(c)-1):
    for j in range(i+1,len(c)):
        l.append([c[j][0]-c[i][0],c[j][1]-c[i][1]])
if(n==1):
    z = most_frequent(c)
else:
    z = most_frequent(l)
l = 1
for i in range(1,len(c)):
    if([c[i][0]-z[0],c[i][1]-z[1]] not in c):
        l+=1
print(l)
Buggy python submission (verdict: Runtime Error):
def gcd(x, y): 
  
   while(y): 
       x, y = y, x % y 
  
   return x 
n = int(input())
a = list(map(int,input().split()))
g = 0
for i in range(len(a)):
    g = gcd(g,a[i])
print(g)


Fixed submission:
def gcd(x, y): 
  
   while(y): 
       x, y = y, x % y 
  
   return x 
n = int(input())
a = list(map(int,input().split()))
g = 0
for i in range(len(a)):
    g = gcd(g,a[i])
print(g)

Buggy python submission (verdict: Runtime Error):
import math
n = int(raw_input())
a = list(map(int,raw_input().split()))
g = 0
for i in range(len(a)):
    g = math.gcd(g,a[i])
print(g)


Fixed submission:
def gcd(x, y): 
  
   while(y): 
       x, y = y, x % y 
  
   return x 
n = int(input())
a = list(map(int,input().split()))
g = 0
for i in range(len(a)):
    g = gcd(g,a[i])
print(g)

Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
a = list(map(int,input().split()))
g = 0
for i in range(len(a)):
    g = math.gcd(g,a[i])
print(g)


Fixed submission:
def gcd(x, y): 
  
   while(y): 
       x, y = y, x % y 
  
   return x 
n = int(input())
a = list(map(int,input().split()))
g = 0
for i in range(len(a)):
    g = gcd(g,a[i])
print(g)

Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
a = list(map(int,input().split()))
g = 0
for _ in range(len(a)):
    g = math.gcd(g,a[_])
print(g)


Fixed submission:
def gcd(x, y): 
  
   while(y): 
       x, y = y, x % y 
  
   return x 
n = int(input())
a = list(map(int,input().split()))
g = 0
for i in range(len(a)):
    g = gcd(g,a[i])
print(g)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
n,k = map(int,input().split())
c = []
heapq.heapify(c)
for i in range(n):
    a,b = map(int,input().split())
    c+=([a]*b)
    heapq.heapify(c)
l = heapq.nsmallest(k,c)
print(l[-1])


Fixed submission:
import heapq
n,k = map(int,input().split())
d = {}
z = []
for i in range(n):
    a,b = map(int,input().split())
    z.append([a,b])
    d[a] = 0
for i in range(len(z)):
    d[z[i][0]]+=z[i][1]
c = sorted(d.keys())
l=0
for i in range(len(c)):
    if(k<=0):
        print(c[i-1])
        l+=1
        break
    k-=d[c[i]]
if(l!=1):
    print(c[-1])

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
n,k = map(int,input().split())
c = []
heapq.heapify(c)
for i in range(n):
    a,b = map(int,input().split())
    c+=([a]*b)
l = heapq.nsmallest(k,c)
print(l[-1])


Fixed submission:
import heapq
n,k = map(int,input().split())
d = {}
z = []
for i in range(n):
    a,b = map(int,input().split())
    z.append([a,b])
    d[a] = 0
for i in range(len(z)):
    d[z[i][0]]+=z[i][1]
c = sorted(d.keys())
l=0
for i in range(len(c)):
    if(k<=0):
        print(c[i-1])
        l+=1
        break
    k-=d[c[i]]
if(l!=1):
    print(c[-1])