Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03633 (python)

Fixed submission:
import fractions
N = int(input())
T = list(int(input()) for _ in range(N))
ans = T[0]
for i in range(1, N):
    ans = ans * T[i] // fractions.gcd(ans, T[i])
print(ans)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
T = list(int(input()) for _ in range(N))
ans = T[0]
for i in range(1, N):
    ans = ans * T[i] // math.gcd(ans, T[i])
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
l = list(int(input()) for _ in range(n))
ans = l[0]
for i in range(1, n):
    ans = ans * l[i] // math.gcd(ans, l[i])

print(ans)
Problem p03636 (python)

Fixed submission:
s = input()
print(s[0] + str(len(s) -2) + s[-1])

Buggy submission (verdict: Runtime Error):
str = input()
s_head = str[0]
s_tail = str[-1]
s_middle = len(str) -2
ans = s_head + str(s_middle) + s_tail
print(ans)

Buggy submission (verdict: Runtime Error):
str = input()
s_head = str[0]
s_tail = str[1]
s_middle = len(str) -2
ans = s_head + str(s_middle) + s_tail
Problem p03645 (python)

Fixed submission:
n, m = map(int, input().split())
sa = set()
sb = set()
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        sb.add(b)
    if b == n:
        sa.add(a)
print('IMPOSSIBLE' if len(sa & sb) == 0 else 'POSSIBLE')

Buggy submission (verdict: Runtime Error):
n, m = map(int, input())
sa = set()
sb = set()
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        sb.add(b)
    if b == n:
        sa.add(a)
print('IMPOSSIBLE' if len(sa & sb) == 0 else 'POSSIBLE')

Buggy submission (verdict: Runtime Error):
n, m = map(int, input())
sa = set()
sb = set()
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        sb.add(b)
    if b == n:
        sa.add(a)
print('IMPOSSIBLE', if len(sa & sb) == 0 else 'POSSIBLE')
Problem p04043 (python)

Fixed submission:
str = input()
if str.count('5') == 2 and str.count('7') == 1:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
str = input().gsub(" ", "")
if str.count('5') == 2 and str.count('7') == 1:
  print("YES")
else:
  print("NO")
Problem p02630 (python)

Fixed submission:
from collections import Counter
n=int(input())
arr=list(map(int,input().split()))
ans=Counter(arr)
sm=sum(arr)
q=int(input())
for i in range(q):
    x,y=(map(int,input().split()))
    sm=sm-(x*ans[x])
    sm=sm+(y*ans[x])
    ans[y]+=ans[x]
    ans[x]=0
    print(sm)

Buggy submission (verdict: Runtime Error):
n=int(input())
arr=list(map(int,input().split()))
ans=[0]*100000
for i in range(n):
    ans[arr[i]]+=1
sm=sum(arr)
q=int(input())
for i in range(q):
    x,y=(map(int,input().split()))
    sm=sm-(x*ans[x])
    sm=sm+(y*ans[x])
    ans[y]+=ans[x]
    ans[x]=0
    print(sm)

Buggy submission (verdict: Runtime Error):
n=int(input())
arr=list(map(int,input().split()))
ans=[0]*100000
for i in range(n):
    ans[arr[i]]+=1
sm=sum(arr)
q=int(input())
for i in range(q):
    x,y=(map(int,input().split()))
    ans[y]+=ans[x]
    sm=sm-(x*ans[x])
    sm=sm+(y*ans[x])
    ans[x]=0
    print(sm)
Problem p02639 (python)

Fixed submission:
rt=list(map(int,input().split()))
for i in range(5):
        if(rt[i]==0):
        	print(i+1)
        	break

Buggy submission (verdict: Runtime Error):
rt=list(map(in(t,input().split()))
for i in range(0,4):
        if(rt[i]==0):
        	print(i+1)
        	break
Problem p02658 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
anser = 1
if 0 in A:
    print("0")
    exit()
for i in A:
    anser *= i
    if anser > 10 ** 18:
        print("-1")
        exit()
print(anser)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
for i in A:
    anser *= i
if 0 in A:
    print(0)
if anser > 10 ** 18:
    print("-1")
else:
    print(anser)
Problem p02681 (python)

Fixed submission:
S = input()
T = input()

if S == T[0:len(T) - 1]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a,b,c,k = map(int,input().split())

if a + b >= k:
    print(a)
else:
    sumcheck = a + b - k
    print(a - sumcheck)
Problem p02921 (python)

Fixed submission:
S = list(input())

T = list(input())

count_value = 0

if len(S) <= 3 and len(T) <= 3:
    for s, t in zip(S, T):
        if s == t:
            count_value += 1
            continue
print(count_value)

Buggy submission (verdict: Runtime Error):
import sys

a, b = map(int, input().split())
add_value = 0

if a >= 20 and a <= 2:
    if b >= 20 and b <= 1:
        sys.exit()
else:
    while True:
            add_value += 1
            a *= add_value
            if a >= b:
                break


print(add_value)
Problem p02922 (python)

Fixed submission:
import sys

a, b = map(int, input().split())
add_value = 0
outlet = 1
while outlet < b:
    outlet -= 1
    outlet += a
    add_value += 1

print(add_value)

Buggy submission (verdict: Runtime Error):
import sys
 
a, b = map(int, input().split())
add_value = 0
 
if a >= 20 and a <= 2:
	print("0")
    sys.exit()
if b >= 20 and b <= 1:
  	print("0")
    sys.exit()
 
while True:
        add_value += 1
        a *= add_value
        if a >= b:
            break
Problem p03369 (python)

Fixed submission:
print(700+100*input().count('o'))

Buggy submission (verdict: Runtime Error):
print(700+100*input().count( o ))

Buggy submission (verdict: Runtime Error):
a = 700
b = input("").count('o').count('x')
     
if b == 3:
  c = a + 300
  print(c)
      
if b == 2:
  d = a + 200
  print(d)
      
if b == 1:
  e = a + 100
  print(e)
  
if b == "x":
  print(a)
Problem p02687 (python)

Fixed submission:
t=input()
if(t=="ABC"):
  print("ARC")
else:
  print("ABC")

Buggy submission (verdict: Runtime Error):
t=input()
if(t=="ABC"){
	print("ARC")}
else{
	print("ABC")}
Problem p02641 (python)

Fixed submission:
import sys

X, N = map(int, input().split())
list_p = list(map(int, input().split()))

if N == 0:
    print(X)
    sys.exit()

all_list = [int(x) for x in range(0, 102)]
target_list = sorted(list(set(list_p) ^ set(all_list)))

ans = [abs(num - X) for num in target_list]
# print(all_list)
# print(target_list)
# print(min(ans))
# print(ans.index(min(ans)))
print(target_list[ans.index(min(ans))])

Buggy submission (verdict: Runtime Error):
import sys

X, N = map(int, input().split())
list_p = list(map(int, input().split()))

if N == 0:
    print(X)
    sys.exit()

all_list = [int(x) for x in range(min(list_p), max(list_p) + 1)]
target_list = sorted(list(set(list_p) ^ set(all_list)))

ans = [abs(num - X) for num in target_list]
# print(ans)
# print(min(ans))
# print(ans.index(min(ans)))
print(target_list[ans.index(min(ans))])
Problem p02657 (python)

Fixed submission:
int_list = list(map(int, input().split()))
print(int_list[0] * int_list[1])

Buggy submission (verdict: Runtime Error):
input_number = int(input())
int_list = list(map(int, input().split()))

check = 10 ** 18
ans = int_list[0]
for i in int_list[1:]:
    ans = ans * i

    if ans > check:
        ans = -1
        break

for i in int_list:
    if i == 0:
        ans = 0
        break

print(ans)
Problem p02675 (python)

Fixed submission:
s = int(input())

if s % 10 == 2 or s % 10 == 4 or s % 10 == 5 or s % 10 == 7 or s % 10 == 9:
    print("hon")
elif s % 10 == 0 or s % 10 == 1 or s % 10 == 6 or s % 10 == 8:
    print("pon")
else:
    print("bon")

Buggy submission (verdict: Runtime Error):
s = input()

if s%10 == 2 or s%10 == 4 or s%10 == 5 or s%10 == 7 or s%10 == 9:
    print("hon")
elif s%10 == 0 or s%10 == 1 or s%10 == 6 or s%10 == 8:
    print("pon")
else :
    print("bon")
Problem p02612 (python)

Fixed submission:
N = int(input())


A = N%1000

if 1000-A!=1000:
    print(1000-A)

else:
    print(0)

Buggy submission (verdict: Runtime Error):
N = int(input())


n = str(N)
a = n[-1]
b = n[-2]
c = n[-3]

A = int(a)+10*int(b)+100*int(c)

if 1000-A!=1000:
    print(1000-A)

else:
    print(0)
Problem p02614 (python)

Fixed submission:
import numpy as np
from copy import copy

def red(l, r, prefix):
    for index, i in enumerate(r):
        i = int(i)
        if i:
            if prefix == 0:
                l[index] = 'r'
            else:
                l[:, index] = 'r'

    return l

def main():
    h, w, k = map(int, input().split())
    cnt = 0
    list_ = []
    box = []
    for _ in range(h):
        l = list(input())
        list_.append(l)
    list_ = np.array(list_)
    x = copy(list_)
    for i in range(2**h):
        x1 = copy(x)

        r = format(i, f'0{h}b')
        x1 = red(x1, r, 0)
        for j in range(2**w):
            x2 = copy(x1)
            r = format(j, f'0{w}b')
            x2 = red(x2, r, 1)
            if np.count_nonzero(x2 == '#') == k:
                cnt += 1

    print(cnt)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import numpy as np
from copy import copy

def red(l, r, prefix):
    for index, i in enumerate(r):
        i = int(i)
        if i:
            if prefix == 0:
                l[index] = 'r'
            else:
                l[:, index] = 'r'

    return l

def main():
    h, w, k = map(int, input().split())
    cnt = 0
    list_ = []
    box = []
    for _ in range(h):
        l = list(input())
        list_.append(l)
    list_ = np.array(list_)
    x = copy(list_)
    for i in range(2**h):
        x1 = copy(x)

        r = format(i, f'0{h}b')
        x1 = red(x1, r, 0)
        for j in range(2**w):
            x2 = copy(x1)
            r = format(j, f'0{w}b')
            x2 = red(x2, r, 1)
            if np.count_nonzero(x2 == '#') == k:
                cnt += 1

    print(cnt)

if __name__ == "__main__":
    main()
Problem p02621 (python)

Fixed submission:
def main():
    a = int(input())
    ans = a + a**2 + a**3
    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    a.append(10**9+1)
    b.append(10**9+1)
    a, b = a[::-1], b[::-1]
    sum = 0
    for _ in range(400001):
        x = a.pop() if a[-1] < b[-1] else b.pop()
        if x > 10**9:
            break
        k -= x
        if k < 0:
            break
        sum += 1
    print(sum)

if __name__ == "__main__":
    main()
Problem p02630 (python)

Fixed submission:
from collections import Counter


def main():
    n = int(input())
    a = list(map(int, input().split()))
    cnt = Counter(a)
    q = int(input())
    s = sum(a)
    for _ in range(q):
        b, c = map(int, input().split())
        s -= cnt[b]*b

        s += cnt[b]*c
        cnt[c] += cnt[b]
        cnt[b] = 0
        print(s)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from collections import Counter


def main():
    n = int(input())
    a = list(map(int, input().split()))
    c = Counter(A)
    q = int(input())
    s = sum(a)
    for _ in range(q):
        b, c = map(int, input().split())
        s -= C[b]*b
        s += C[b]*c
        C[c] += c[b]
        c[b] = 0
        print(s)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from collections import Counter


def main():
    n = int(input())
    a = list(map(int, input().split()))
    c = Counter(A)
    q = int(input())
    s = sum(a)
    for _ in range(q):
        b, c = map(int, input().split())
        s -= C[b]*b
        s += C[b]*c
        C[c] += c[b]
        c[b] = 0
        print(s)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
rom collections import Counter


def main():
    n = int(input())
    a = list(map(int, input().split()))
    c = Counter
    q = int(input())
    s = sum(a)
    for _ in range(q):
        b, c = map(int, input().split())
        s -= C[b]*b
        s += C[b]*c
        C[c] += c[b]
        c[b] = 0
        print(s)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
rom collections import Counter


def main():
    n = int(input())
    a = list(map(int, input().split()))
    c = Counter
    q = int(input())
    s = sum(a)
    for _ in range(q):
        b, c = map(int, input().split())
        s -= C[b]*b
        s += C[b]*c
        C[c] += c[b]
        c[b] = 0
        print(s)

if __name__ == "__main__":
    main()
Problem p02639 (python)

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 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()
Problem p02705 (python)

Fixed submission:
import math


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


if __name__=="__main__":
    main()

Buggy 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()
Problem p03455 (python)

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

Buggy 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()
Problem p02741 (python)

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 submission (verdict: Runtime Error):
h, w = map(int, input().split())
print(round(h * w / 2))
Problem p02612 (python)

Fixed submission:
n = int(input())
if n%1000 == 0:
    print(0)
else:
    print(1000-n%1000)

Buggy submission (verdict: Runtime Error):
n = int(input())
if n%1000 == 0:
    print(0)
else:
print(1000-n%1000)
Problem p02789 (python)

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

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

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

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

Buggy 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')

Buggy 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')

Buggy 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')
Problem p02909 (python)

Fixed submission:
l,s=["Sunny","Cloudy","Rainy"],input()
i=l.index(s)
print(l[(i+1)%3])

Buggy submission (verdict: Runtime Error):
l = ["Sunny","Cloudy", "Rainy" ]
s = input()
i = l.index(s)
printf(l[(i+1)%3])
Problem p03060 (python)

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 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)
Problem p03085 (python)

Fixed submission:
i = input()
L1=["A","C","G","T"]
L2=["T","G","C","A"]
print(L2[L1.index(i)])

Buggy submission (verdict: Runtime Error):
s = input()
d = {"A":"T","T":"A","G":"C","C":"G"}
print(s["{}".format(s)])
Problem p02618 (python)

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 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)
Problem p02684 (python)

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 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)
Problem p02690 (python)

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 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()
Problem p03450 (python)

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 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')
Problem p03472 (python)

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)

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