Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def main():
    x, n = map(int, input().split())
    p = list(map(int, input().split()))
    _near = 0
    for i in range(101):
        if i in p:
            continue
        if abs(_near - x) > abs(i - x):
            if _near > i:
                _near = i
    print(_near)


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    a = list(map(int, input().split()))
    for i, x in enumerate(a):
        if x == 0:
            print(i + 1)



if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
 main():
    K = int(input())
    A, B = map(int, input().split())
    x = list(range(K, 1001, K))
    print('OK') if any([A <= i <= B for i in x]) else print('NG')

    return


if __name__=="__main__":
    main()


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

    for i in range(A, B+1):
        if i % K == 0:
            print('OK')
            return
    print('NG')


if __name__=="__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    a = list(map(int, input().split()))

    for i in range(n):
        print(a.count(i+1))

if __name__=="__main__":
    main()


Fixed submission:
import math


def main():
    R = int(input())
    p = math.pi
    print(R*p*2)


if __name__=="__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

def main():
    n = int(input())
    a = np.array(list(map(int, input().split())), dtype='uint')

    _ = [print(np.count_nonzero(a == i+1)) for i in range(n)]


if __name__=="__main__":
    main()


Fixed submission:
def main():
    n = int(input())
    a = list(map(int, input().split()))

    mem = [0] * n
    for i in range(n-1):
        mem[a[i]-1] += 1

    for i in mem:
        print(i)

if __name__=="__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

def main():
    n = int(input())
    a = np.array(list(map(int, input().split())), dtype='uint')

    for i in range(n):
        print(np.count_nonzero(a == i+1))


if __name__=="__main__":
    main()


Fixed submission:
def main():
    n = int(input())
    a = list(map(int, input().split()))

    mem = [0] * n
    for i in range(n-1):
        mem[a[i]-1] += 1

    for i in mem:
        print(i)

if __name__=="__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    A = list(map(int, input().split()))

    for i in range(n):
        print(A.count(i+1))


if __name__=="__main__":
    main()


Fixed submission:
def main():
    n = int(input())
    a = list(map(int, input().split()))

    mem = [0] * n
    for i in range(n-1):
        mem[a[i]-1] += 1

    for i in mem:
        print(i)

if __name__=="__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce


def gcd(*numbers):
    return reduce(math.gcd, numbers)


def main():
    K = int(input())
    s = sum([gcd(i+1, j+1, k+1) for i in range(K) for j in range(K) for k in range(K)])

    print(s)


if __name__=="__main__":
    main()


Fixed submission:
import math
from functools import reduce


def gcd(*numbers):
    return reduce(math.gcd, numbers)


def main():
    K = int(input())
    s = sum([gcd(i+1, j+1, k+1) for i in range(K) for j in range(K) for k in range(K)])

    print(s)


if __name__=="__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    n, a, b = map(int, input().split())
    q, mod = divmod(n, (a+b))
    x = mod if mod < n else x = n
    print(q*a+x)

if __name__ == "__main__":
    main()


Fixed submission:
def main():
    n, a, b = map(int, input().split())
    q, mod = divmod(n, (a+b))
    x = mod if mod < a else a
    print(q*a+x)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    a, b = map(int, input().split())
    print('Odd') if a*B % 2 != 0 else print('Even')


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    a, b = map(int, input().split())
    print('Odd') if a*b % 2 != 0 else print('Even')


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    a, b = map(int, input().split())
    print('Odd') if a*B % != 0 else print('Even')


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    a, b = map(int, input().split())
    print('Odd') if a*b % 2 != 0 else print('Even')


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
print(round(h * w / 2))

Fixed submission:
lists = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
i = int(input())

print(lists[i - 1])
Buggy python submission (verdict: Runtime Error):
input()

if S[0] == S[1] and S[1] == S[2]:
    print('No')
else:
    print('Yes')

Fixed submission:
S = input()

if S[0] == S[1] and S[1] == S[2]:
    print('No')
else:
    print('Yes')
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n%1000 == 0:
    print(0)
else:
print(1000-n%1000)

Fixed submission:
n = int(input())
if n%1000 == 0:
    print(0)
else:
    print(1000-n%1000)
Buggy python submission (verdict: Runtime Error):
n, m = map(int(input().split()))
h = list(map(int, input().split()))
p = [1]*n
max = 0
for i in range(m):
    a, b = map(int(input().split()))
    if h[a-1] <= h[b-1]:
        p[a-1] = 0
    if h[a-1] >= h[b-1]:
        p[b-1] = 0
print(sum(p))

Fixed submission:
n, m = map(int, (input().split()))
h = list(map(int, input().split()))
p = [1]*n
max = 0
for i in range(m):
    a, b = map(int, (input().split()))
    if h[a-1] <= h[b-1]:
        p[a-1] = 0
    if h[a-1] >= h[b-1]:
        p[b-1] = 0
print(sum(p))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
for i in range(n-k+1):
    a = 0
    for j in range(i, i+k):
        a += (p[j]*(1+p[j]))/2/p[j]
    ans = max(ans, a)
print(ans)

Fixed submission:
n, k = map(int, input().split())
p = list(map(int, input().split()))

ans = 0
kitai = []
for i in range(n):
    kitai.append((1+p[i])/2)
wa = []
a = 0
for i in range(n):
    a += kitai[i]
    wa.append(a)
if n == k:
    print(wa[n-1])
    exit()
ans = 0
for i in range(n-k):
    ans = max(ans, wa[i+k] - wa[i])

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
count = int(input())
num = list(map(int, input().split()))
ans = 1
for i in range(len(num)):
  ans = ans*num[i]
  if ans > 1000000000000000000:
    ans = -1
if ans < 0:
  print(-1)
else:
  print(ans)

Fixed submission:
count = int(input())
A = list(map(int, input().split()))
ans = 1
for i in A:
  if i==0:
    print(0)
    exit()
    
for i in range(len(A)):
  ans = ans*A[i]
  if ans > 1000000000000000000:
    print(-1)
    exit()
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
count = int(input())
num = list(map(int, input().split()))
ans = 1
breakFlag = False
for i in range(len(num)):
  ans = ans*num[i]
if ans > 1000000000000000000:
  ans = -1
print(ans)

Fixed submission:
count = int(input())
A = list(map(int, input().split()))
ans = 1
for i in A:
  if i==0:
    print(0)
    exit()
    
for i in range(len(A)):
  ans = ans*A[i]
  if ans > 1000000000000000000:
    print(-1)
    exit()
    
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
N, M = list(map(int, input().split()))
print(math.factorial(N) // (2*math.factorial(N-2)) + math.factorial(M) // (2*math.factorial(M-2)))

Fixed submission:
import math
N, M = list(map(int, input().split()))
n_pairs = math.factorial(N) // (2*math.factorial(N-2)) if N > 1 else 0
m_pairs = math.factorial(M) // (2*math.factorial(M-2)) if M > 1 else 0
print(n_pairs + m_pairs)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input.split())
print('Yes') if N == M else print('No')

Fixed submission:
N, M = map(int, input().split())
print('Yes') if N == M else print('No')

Buggy python submission (verdict: Runtime Error):
print('Yes') if N == M else print('No')

Fixed submission:
N, M = map(int, input().split())
print('Yes') if N == M else print('No')
Buggy python submission (verdict: Runtime Error):
import sys

n = int(input())
 
num = n%10
 
if num==3:
  print('bon')
elif (num==0 or num==1 or num==6 or num==8:
  print('pon')
else:
  print('hon')

Fixed submission:
import sys

n = int(input())
 
num = n % 10
 
if num == 3:
  print('bon')
elif num==0 or num==1 or num==6 or num==8:
  print('pon')
else:
  print('hon')

Buggy python submission (verdict: Runtime Error):
n = input()
 
if n[-1]=='3':
  print('bon')
elif (num[-1]=='0' or num[-1]=='1' or num[-1]=='6' or num[-1]=='8'):
  print('pon')
else:
  print('hon')


Fixed submission:
import sys

n = int(input())
 
num = n % 10
 
if num == 3:
  print('bon')
elif num==0 or num==1 or num==6 or num==8:
  print('pon')
else:
  print('hon')

Buggy python submission (verdict: Runtime Error):
n = int(input())
 
num = n%10
 
if num==3:
  print('bon')
elif (num==0 or num==1 or num==6 or num==8:
  print('pon')
else:
  print('hon')

Fixed submission:
import sys

n = int(input())
 
num = n % 10
 
if num == 3:
  print('bon')
elif num==0 or num==1 or num==6 or num==8:
  print('pon')
else:
  print('hon')

Buggy python submission (verdict: Runtime Error):
n = int(input())

num = n%10

if num==3:
  print('bon')
elsif num==0 or num==1 or num==6 or num==8:
  print('pon')
else:
  print('hon')
  

Fixed submission:
import sys

n = int(input())
 
num = n % 10
 
if num == 3:
  print('bon')
elif num==0 or num==1 or num==6 or num==8:
  print('pon')
else:
  print('hon')
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()

if len(s)<=n:
    print(s)
else:
    i=0
    for i in range(7):
        print(s[i], end='')
    print('...')

Fixed submission:
n = int(input())
s = input()

if len(s)<=n:
    print(s)
else:
    i=0
    for i in range(n):
        print(s[i], end='')
    print('...')
Buggy python submission (verdict: Time Limit Exceeded):
A, B, C, K = map(int,input().split())

L = []
for x in range(0,A):
	L.append(1)
for y in range(0,B):
	L.append(0)
for z in range(0,C):
	L.append(-1)
print(sum(L[0:K]))


Fixed submission:
A, B, C, K = map(int,input().split())
# 1 2 3 4
card = K#4
# 取れるカードの数
result = 0
# 得点は0
if card < A: # 4 < 1 false
	print(card)
	# Aのカードを取るだけで済むパターン
else:
	card -= A # 4 - 1
	# print("カード残り",card)
	# Aのカードを取り切ってもまだとれるカードの数
	if card < B:
		print(A)
	else:
		card -= B # 3 - 2
		#print("カード残り", card)
		x = card * -1
		#print("X",x)
		print(A+x)
Buggy python submission (verdict: Time Limit Exceeded):
i = int(input())
c = i
l = []
while c != 1:
	if i % c == 0:
		l.append(c)
	c -= 1
ll = []
for x in l:
	ll.append(i//x)
lll = []
for a,b in zip(l,ll):
	cc = a + b - 2
	lll.append(cc)
print(min(lll))

Fixed submission:
i = int(input())
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)
	return divisors

l = []
for x, y in zip(sorted(make_divisors(i)), sorted(make_divisors(i),reverse=True)):
	l.append(x + y - 2)
print(min(l))
Buggy python submission (verdict: Runtime Error):
l = ["Sunny","Cloudy", "Rainy" ]
s = input()
i = l.index(s)
printf(l[(i+1)%3])

Fixed submission:
l,s=["Sunny","Cloudy","Rainy"],input()
i=l.index(s)
print(l[(i+1)%3])
Buggy python submission (verdict: Runtime Error):
a = list(map(int,input().split())
a.sort()
print(a[0]+a[1])

Fixed submission:
a = list(map(int,input().split()))
a.sort()
print(a[0]+a[1])
Buggy python submission (verdict: Runtime Error):
x = 0
y= 0
n = input()
v = list(map(int, input().split()))
c = list(map(int, input().split()))
for vv,cc in v,c:
    if cc < vv:
        x+=vv
        y+=cc
print(x-y)

Fixed submission:
x = 0
y= 0
n = input()
v = list(map(int, input().split()))
c = list(map(int, input().split()))
for (vv,cc) in zip(v,c):
    if cc < vv:
        x+=vv
        y+=cc
print(x-y)
Buggy python submission (verdict: Runtime Error):
s = input()
d = {"A":"T","T":"A","G":"C","C":"G"}
print(s["{}".format(s)])

Fixed submission:
i = input()
L1=["A","C","G","T"]
L2=["T","G","C","A"]
print(L2[L1.index(i)])
Buggy python submission (verdict: Runtime Error):
import sys
import math
import fractions
import time
import random
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

start = time.perf_counter()

D = int(input())
c = list(map(int, input().split()))
s = []
last = [0] * 26
for _ in range(D):
    line = list(map(int, input().split()))
    s.append(line)


def calc_one_score(t, d, sat):
    t -= 1
    sat += s[d][t]
    last[t] = d + 1
    for i in range(26):
        sat -= c[i] * (d + 1 - last[i])
    return sat


def calc_score(ts):
    sat = 0
    for d in range(D):
        sat = calc_one_score(ts[d], d, sat)
    return sat


max_score = 0

ts = [1, 17, 13, 14, 13]
while time.perf_counter() - start < 1.70:
    last = [0] * 26
    score = calc_score(ts)
    if max_score < score:
        max_score = score
        # print(ts, score)
    else:
        ts[d] = old
    d = random.randrange(D)
    i = random.randrange(1, 27)
    old = ts[d]
    ts[d] = i

for t in ts:
    print(t)
# print(max_score)


Fixed submission:
import sys
import math
import fractions
import time
import random
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

start = time.perf_counter()

D = int(input())
c = list(map(int, input().split()))
s = []
last = [0] * 26
for _ in range(D):
    line = list(map(int, input().split()))
    s.append(line)


def calc_one_score(t, d, sat):
    t -= 1
    sat += s[d][t]
    last[t] = d + 1
    for i in range(26):
        sat -= c[i] * (d + 1 - last[i])
    return sat


def calc_score(ts):
    sat = 0
    for d in range(D):
        sat = calc_one_score(ts[d], d, sat)
    return sat


max_score = -1000000000000

ts = [1] * D
while time.perf_counter() - start < 1.70:
    last = [0] * 26
    score = calc_score(ts)
    d = random.randrange(D)
    i = random.randrange(1, 27)
    old = ts[d]
    ts[d] = i
    if max_score < score:
        # print(ts, score)
        max_score = score
    else:
        ts[d] = old

for t in ts:
    print(t)
# print(max_score)
Buggy python submission (verdict: Runtime Error):
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

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

for i in range(N):
    A[i] -= 1

visited = set()
visited.add(0)
trace = []
cur = 0
while True:
    trace.append(cur)
    if A[cur] in visited:
        cur = A[cur]
        break
    visited.add(A[cur])
    cur = A[cur]

pre = 0
for i, a in enumerate(trace):
    if a == cur:
        pre = i

loop = N - pre - 1

if K < pre:
    ans = trace[K - 1] + 1
else:
    r = (K - pre) % loop
    ans = trace[pre::][r] + 1

print(ans)


Fixed submission:
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

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

for i in range(N):
    A[i] -= 1

visited = set()
visited.add(0)
trace = []
cur = 0
while True:
    trace.append(cur)
    if A[cur] in visited:
        cur = A[cur]
        break
    visited.add(A[cur])
    cur = A[cur]

pre = 0
for i, a in enumerate(trace):
    if a == cur:
        pre = i

loop = len(trace) - pre

if K <= pre:
    ans = trace[K]
else:
    if loop == 0:
        ans = trace[pre::][0]
    else:
        r = (K - pre) % loop
        ans = trace[pre::][r]

print(ans + 1)
Buggy python submission (verdict: Runtime Error):
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

l = []
for i in range(0, 1000):
    l.append(i ** 5)

for i in range(len(l)):
    for j in range(len(l)):
        if l[i] - l[j] == X:
            print(i, j)
            sys.exit()
        if l[i] + l[j] == X:
            print(i, -j)
            sys.exit()


Fixed submission:
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

X = int(input())

l = []
for i in range(0, 1000):
    l.append(i ** 5)

for i in range(len(l)):
    for j in range(len(l)):
        if l[i] - l[j] == X:
            print(i, j)
            sys.exit()
        if l[i] + l[j] == X:
            print(i, -j)
            sys.exit()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

A, B, N = map(int, input().split())

m = -1

for x in range(1, N+1):
    res = math.floor(A * x / B) - A * math.floor(x / B)
    if res >= m:
        m = res
    elif res == 0:
        break
    else:
        break

print(m)


Fixed submission:
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

A, B, N = map(int, input().split())

# m = -1

# for x in range(1, N+1):
#     res = math.floor(A * x / B) - A * math.floor(x / B)
#     print(res)

if B > N:
    x = N
    res = math.floor(A * x / B) - A * math.floor(x / B)
    print(res)
else:
    x = B - 1
    res = math.floor(A * x / B) - A * math.floor(x / B)
    print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

A, B, N = map(int, input().split())

m = -1

for x in range(1, N+1):
    res = math.floor(A * x / B) - A * math.floor(x / B)
    if res >= m:
        m = res
    else:
        break

print(m)


Fixed submission:
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

A, B, N = map(int, input().split())

# m = -1

# for x in range(1, N+1):
#     res = math.floor(A * x / B) - A * math.floor(x / B)
#     print(res)

if B > N:
    x = N
    res = math.floor(A * x / B) - A * math.floor(x / B)
    print(res)
else:
    x = B - 1
    res = math.floor(A * x / B) - A * math.floor(x / B)
    print(res)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

S = input()
S = S[::-1]

dp = [[0] * 13 for _ in range(len(S))]
mod = 10 ** 9 + 7

if S[0] == '?':
    for i in range(10):
        dp[0][i] = 1
else:
    dp[0][int(S[0])] = 1

for i in range(1, len(S)):
    if S[i] == '?':
        for j in range(13):
            for k in range(10):
                dp[i][(j + 10 ** i * k) % 13] += dp[i-1][j]
                dp[i][(j + 10 ** i * k) % 13] %= mod
    else:
        for j in range(13):
            dp[i][(j + 10 ** i * int(S[i])) % 13] += dp[i-1][j]
            dp[i][(j + 10 ** i * int(S[i])) % 13] %= mod
print(dp[len(S) - 1][5])


Fixed submission:
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

S = input()

dp = [[0] * 13 for _ in range(len(S))]
mod = 10 ** 9 + 7

if S[0] == '?':
    for i in range(10):
        dp[0][i] = 1
else:
    dp[0][int(S[0])] = 1

for i in range(1, len(S)):
    if S[i] == '?':
        for j in range(13):
            for k in range(10):
                dp[i][(j * 10 + k) % 13] += dp[i-1][j]
                dp[i][(j + 10 + k) % 13] %= mod
    else:
        for j in range(13):
            dp[i][(j * 10 + int(S[i])) % 13] += dp[i-1][j]
            dp[i][(j * 10 + int(S[i])) % 13] %= mod
print(dp[len(S) - 1][5])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(4100000)
N, M = map(int, input().split())
graph = [[] * N for _ in range(N)]
for _ in range(M):
    L, R, D = map(int, input().split())
    L -= 1
    R -= 1
    graph[L].append((R, D))
    graph[R].append((L, -D))


def dfs(node, dist):
    global visited
    global dists
    dists[node] = dist
    for next, d in graph[node]:
        if next in visited:
            if d + dist != dists[next]:
                print('No')
                sys.exit()
        else:
            visited.add(next)
            dfs(next, dist + d)


visited = set()
dists = [0] * N
for i in range(N):
    if i in visited:
        continue
    visited.add(i)
    dfs(i, 0)

print('Yes')


Fixed submission:
import sys
sys.setrecursionlimit(4100000)
N, M = map(int, input().split())
graph = [[] * N for _ in range(N)]
for _ in range(M):
    L, R, D = map(int, input().split())
    L -= 1
    R -= 1
    graph[L].append((R, D))
    graph[R].append((L, -D))


def dfs(node, dist):
    global visited
    global dists
    dists[node] = dist
    for next, d in graph[node]:
        if next in visited:
            if d + dist != dists[next]:
                print('No')
                sys.exit()
        else:
            visited.add(next)
            dfs(next, dist + d)


visited = set()
dists = [0] * N
for i in range(N):
    if i in visited:
        continue
    visited.add(i)
    dfs(i, 0)

print('Yes')

Buggy python submission (verdict: Runtime Error):
import sys
N, M = map(int, input().split())
graph = [[] * N for _ in range(N)]
for _ in range(M):
    L, R, D = map(int, input().split())
    L -= 1
    R -= 1
    graph[L].append((R, D))
    graph[R].append((L, -D))


def dfs(node, dist):
    global visited
    global dists
    dists[node] = dist
    for next, d in graph[node]:
        if next in visited:
            if d + dist != dists[next]:
                print('No')
                sys.exit()
        else:
            visited.add(next)
            dfs(next, dist + d)


visited = set()
dists = [0] * N
for i in range(N):
    if i in visited:
        continue
    visited.add(i)
    dfs(i, 0)

print('Yes')


Fixed submission:
import sys
sys.setrecursionlimit(4100000)
N, M = map(int, input().split())
graph = [[] * N for _ in range(N)]
for _ in range(M):
    L, R, D = map(int, input().split())
    L -= 1
    R -= 1
    graph[L].append((R, D))
    graph[R].append((L, -D))


def dfs(node, dist):
    global visited
    global dists
    dists[node] = dist
    for next, d in graph[node]:
        if next in visited:
            if d + dist != dists[next]:
                print('No')
                sys.exit()
        else:
            visited.add(next)
            dfs(next, dist + d)


visited = set()
dists = [0] * N
for i in range(N):
    if i in visited:
        continue
    visited.add(i)
    dfs(i, 0)

print('Yes')
Buggy python submission (verdict: Runtime Error):
import math
n, h = map(int, input().split())
max_swing = 0
throw = []
for _ in range(n):
    a, b = map(int, input().split())
    max_swing = max(max_swing, a)
    throw.append(b)

throw.sort(reverse=true)

min_cnt = int(math.ceil(h / max_swing))
throw_cnt = 0
for t in throw:
    h -= t
    throw_cnt += 1
    if h <= 0:
        min_cnt = min(throw_cnt, min_cnt)
        break
    cnt = throw_cnt + int(math.ceil(h / max_swing))
    min_cnt = min(cnt, min_cnt)

print(min_cnt)


Fixed submission:
import math
n, h = map(int, input().split())
max_swing = 0
throw = []
for _ in range(n):
    a, b = map(int, input().split())
    max_swing = max(max_swing, a)
    throw.append(b)

throw.sort(reverse=True)

min_cnt = int(math.ceil(h / max_swing))
throw_cnt = 0
for t in throw:
    h -= t
    throw_cnt += 1
    if h <= 0:
        min_cnt = min(throw_cnt, min_cnt)
        break
    cnt = throw_cnt + int(math.ceil(h / max_swing))
    min_cnt = min(cnt, min_cnt)

print(min_cnt)