Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
x, l = [0]*n, [0]*n
for i in range(n):
    x[i], l[i] = map(int, input().split())
hoge = []
for i in range(n):
    hoge.append(x+l)
t = 0
for i in range(n):
    if t < hoge[i]:
        ans += 1
        t = hoge[i]
print(ans)

Fixed submission:
import numpy as np
import functools
import math
import scipy
import fractions
import itertools

def solve():
    n = int(input())
    x, l = [0]*n, [0]*n
    for i in range(n):
        x[i], l[i] = map(int, input().split())
    hoge = []
    for i in range(n):
        hoge.append([x[i]+l[i], x[i]-l[i]])
    hoge.sort()
    t = -1000000000000000000000
    ans = 0
    for i in range(n):
        if t <= hoge[i][1]:
            ans += 1
            t = hoge[i][0]
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

Buggy python submission (verdict: Runtime Error):
import numpy as np
import functools
import math
import scipy
import fractions
import itertools

def solve():
    n = int(input())
    x, l = [0]*n, [0]*n
    for i in range(n):
        x[i], l[i] = map(int, input().split())
    hoge = []
    for i in range(n):
        hoge.append(x+l)
    t = 0
    for i in range(n):
        if t < hoge[i]:
            ans += 1
            t = hoge[i]
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

Fixed submission:
import numpy as np
import functools
import math
import scipy
import fractions
import itertools

def solve():
    n = int(input())
    x, l = [0]*n, [0]*n
    for i in range(n):
        x[i], l[i] = map(int, input().split())
    hoge = []
    for i in range(n):
        hoge.append([x[i]+l[i], x[i]-l[i]])
    hoge.sort()
    t = -1000000000000000000000
    ans = 0
    for i in range(n):
        if t <= hoge[i][1]:
            ans += 1
            t = hoge[i][0]
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

Buggy python submission (verdict: Runtime Error):
import numpy as np
import functools
import math
import scipy
import fractions
import itertools

def solve():
    n = int(input())
    x, l = [0]*n, [0]*n
    for i in range(n):
        x[i], l[i] = map(int, input().split())
    hoge = []
    for i in range(n):
        hoge.append(x+l)
    t = 0
    for i in range(n):
        if t < hoge[i]:
            ans += 1
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

Fixed submission:
import numpy as np
import functools
import math
import scipy
import fractions
import itertools

def solve():
    n = int(input())
    x, l = [0]*n, [0]*n
    for i in range(n):
        x[i], l[i] = map(int, input().split())
    hoge = []
    for i in range(n):
        hoge.append([x[i]+l[i], x[i]-l[i]])
    hoge.sort()
    t = -1000000000000000000000
    ans = 0
    for i in range(n):
        if t <= hoge[i][1]:
            ans += 1
            t = hoge[i][0]
    print(ans)
    return 0

if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Time Limit Exceeded):
import math
import collections
import fractions
import itertools
import functools
import operator

def solve():
    n = int(input())
    s = list(map(int, input()))
    allper = [(s[a], s[b], s[c]) for a, b, c in itertools.combinations(range(n), 3)]
    print(len(set(allper)))
    return 0

if __name__ == "__main__":
    solve()

Fixed submission:
n = [int(i) for i in input().split()]
s = input()
a = set([""])
ans = set()
for i in s:
    b = a.copy()
    for j in a:
        if len(j) == 2:
            ans.add(j + i)
        else:
            b.add(j + i)
    a = b
print(len(ans))
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
import itertools
import numpy as np

def solve():
    n = int(input())
    num = list(range(1,10))
    bit = 0
    for i in num:
        for j in num:
            if i * j == n:
                print("Yes")
                bit = 1
                break
    i bit == 0:
        print("No")
    return 0

if __name__ == "__main__":
    solve()


Fixed submission:
import math
from functools import reduce
import itertools
import numpy as np

def solve():
    n = int(input())
    num = list(range(1,10))
    bit = 0
    for i in num:
        for j in num:
            if i * j == n:
                print("Yes")
                bit = 1
                break
        if bit == 1:
            break
    if bit == 0:
        print("No")
    return 0

if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Runtime Error):
import numpy as np
import functools
import math
import scipy
import fractions
import itertools

def trial_division(n):
    factor = []
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    if not factor:
        return n
    else:
        factor.append(n)
        return factor

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

def solve():
    a, b = map(int, input().split())
    ans = 0
    for i in trial_division(fractions.gcd(a, b)):
        if is_prime(i):
            ans += 1
    print(ans+1)
    return 0

if __name__ == "__main__":
    solve()

Fixed submission:
import sys
from fractions import gcd
from collections import Counter


def prime_factorization(n):
    """nを素因数分解する

    Return d(dict):
        素因数をキー、素因数の指数部を値とするディクショナリを返す

    Example:
        n=140 -> d = {2: 2, 5: 1, 7: 1}
    """
    d = Counter()
    m = 2
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
        m = m + 1 if m == 2 else m + 2  # m=3からは、m+=2する（偶数は明らかに素数ではないので）

    if n > 1:
        d[n] += 1
    return d


def solve():
    A, B = list(map(int, sys.stdin.readline().split()))
    cd = gcd(A, B)

    if cd == 1:  # コーナーケース
        print(1)
        return

    # (素因数分解の素因数の個数)+1が答え
    prime_d = prime_factorization(cd)
    print(len(prime_d)+1)


if __name__ == "__main__":
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import functools
import math
import scipy
import fractions
import itertools

def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

def solve():
    a, b = map(int, input().split())
    ans = 0
    for i in cf(a, b):
        if is_prime(i):
            ans += 1
    print(ans+1)
    return 0

if __name__ == "__main__":
    solve()

Fixed submission:
import sys
from fractions import gcd
from collections import Counter


def prime_factorization(n):
    """nを素因数分解する

    Return d(dict):
        素因数をキー、素因数の指数部を値とするディクショナリを返す

    Example:
        n=140 -> d = {2: 2, 5: 1, 7: 1}
    """
    d = Counter()
    m = 2
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
        m = m + 1 if m == 2 else m + 2  # m=3からは、m+=2する（偶数は明らかに素数ではないので）

    if n > 1:
        d[n] += 1
    return d


def solve():
    A, B = list(map(int, sys.stdin.readline().split()))
    cd = gcd(A, B)

    if cd == 1:  # コーナーケース
        print(1)
        return

    # (素因数分解の素因数の個数)+1が答え
    prime_d = prime_factorization(cd)
    print(len(prime_d)+1)


if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    n = int(input())
    s = [sorted(input()) for _ in range(n)]
    cnt = 0
    for i in range(n-1):
        for j in range(i+1, n):
            if s[i] == s[j]:
                cnt += 1
    print(cnt)
    return 0

if __name__ == "__main__":
    solve()


Fixed submission:
import math
import collections
import fractions
import itertools
import functools
import  operator

def solve():
    n = int(input())
    s = ["".join(sorted(input())) for _ in range(n)]
    cnt = 0
    past = {}
    for i in range(n):
        si = s[i]
        if si in past:
            past[si] += 1
        else:
            past[si] = 1
    for i in past.values():
        cnt += i*(i-1)//2
    print(cnt)
    return 0

if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Runtime Error):
import math
def solve():
  a, b, c, d = map(int, input().split())
  a -= 1
  lc = (c*d)//math.gcd(c,d)
  ans = (b-a)-(b//c-a//c)-(b//d-a//d)+(b//lc-a//lc)
  print(ans)
  return 0
 
if __name__ == "__main__":
  solve()

Fixed submission:
import numpy as np
import functools
import math
import collections
import scipy
import fractions
import itertools
 
def solve():
  a, b, c, d = map(int, input().split())
  a -= 1
  lc = (c*d)//fractions.gcd(c,d)
  ans = (b-a)-(b//c-a//c)-(b//d-a//d)+(b//lc-a//lc)
  print(ans)
  return 0
 
if __name__ == "__main__":
  solve()

Buggy python submission (verdict: Runtime Error):
import numpy as np
import functools
import math
import collections
import scipy
import fractions
import itertools

def solve():
  a, b, c, d = map(int, input().split())
  a -= 1
  lc = (c*d)//math.gcd(c,d)
  ans = (b-a)-(b//c-a//c)-(b//d-a//d)+(b//lc-a//lc)
  print(ans)
  return 0
 
if __name__ == "__main__":
  solve()


Fixed submission:
import numpy as np
import functools
import math
import collections
import scipy
import fractions
import itertools
 
def solve():
  a, b, c, d = map(int, input().split())
  a -= 1
  lc = (c*d)//fractions.gcd(c,d)
  ans = (b-a)-(b//c-a//c)-(b//d-a//d)+(b//lc-a//lc)
  print(ans)
  return 0
 
if __name__ == "__main__":
  solve()

Buggy python submission (verdict: Runtime Error):
import numpy as np
import functools
import math
import collections
import scipy
import fractions
import itertools

def solve():
  a, b, c, d = map(int, input().split())
  a -= 1
  lc = (c*d)//math.gcd(c,d)
  ans = (b-a)-(b//c-a//c)-(b//d-a//d)+(b//lc-a//lc)
  print(ans)
  return 0
 
if __name__ == "__main__":
  solve()


Fixed submission:
import numpy as np
import functools
import math
import collections
import scipy
import fractions
import itertools
 
def solve():
  a, b, c, d = map(int, input().split())
  a -= 1
  lc = (c*d)//fractions.gcd(c,d)
  ans = (b-a)-(b//c-a//c)-(b//d-a//d)+(b//lc-a//lc)
  print(ans)
  return 0
 
if __name__ == "__main__":
  solve()
Buggy python submission (verdict: Runtime Error):
import numpy as np
import functools
import math
import collections
import scipy
import fractions
import itertools

def solve():
  a, b, c, d = map(int, input().split())
  a -= 1
  lc = (c*d)//fractions.gcd(c,d)
  ans = (b-a)-(b//c-a//c)-(b//d-a//d)+(b//lc-a//lc)
  print(ans)
  return 0
 
if __name__ == "__main__":
  solve()


Fixed submission:
def solve():
  n = int(input())
  works = [list(map(int, input().split())) for i in range(n)]
  works = sorted(works, key=lambda x:x[1])
  if works[0][0] > works[0][1]:
    print("No")
    exit()
  sum = 0
  for i in works:
    sum += i[0]
    if sum > i[1]:
      print("No")
      exit()
  print("Yes")
  return 0
 
if __name__ == "__main__":
  solve()
Buggy python submission (verdict: Runtime Error):
import math
import collections
import fractions
import itertools
import functools
import  operator

def solve():
    n, a, b, c, d = map(int, input().split())
    s = input()
    for i in range(a, max(c,d)):
        if s[i-1:i+1] = "##":
            print("No")
            exit()
    if c > d:
        print("Yes")
        break
    for i in range(b-1, d):
        if s[i-1:i+2] == "...":
            print("Yes")
            exit()
    print("No")
    return 0

if __name__ == "__main__":
    solve()

Fixed submission:
import math
import collections
import fractions
import itertools
import functools
import  operator

def solve():
    n, a, b, c, d = map(int, input().split())
    s = input()
    for i in range(a, max(c,d)):
        if s[i-1:i+1] == "##":
            print("No")
            exit()
    if c < d:
        print("Yes")
        exit()
    for i in range(b-1, d):
        if s[i-1:i+2] == "...":
            print("Yes")
            exit()
    print("No")
    return 0

if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Runtime Error):
def solve():
    s = list(input())
    if s.count("o") >= 8:
        print("YES")
    else:
        print("NO")
    return 0

if __name__ == "__main__":
    solve()
,

Fixed submission:
def solve():
    s = input()
    k = len(s)
    if s.count("o")+(15-k) >= 8:
        print("YES")
    else:
        print("NO")
    return 0

if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Runtime Error):
import numpy as np
import functools
import math
import scipy
import fractions
import itertools

def solve():
    n = int(input())
    a = list(map(int, input().split()))
    hoge = 0
    ans = 0
    for i in range(n):
        if a[i] < 0:
            hoge += 1
    if 0 in a or hoge % 2 == 0:
        for i in range(n):
            ans += abs(a[i])
    else:
        huga = []
        for i in range(n):
            ans += abs(a[i])
            if a[i] > 0:
                huga.append(a[i])
        ans -= min(huga)*2
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

Fixed submission:
import numpy as np
import functools
import math
import scipy
import fractions
import itertools

def solve():
    n = int(input())
    a = list(map(int, input().split()))
    hoge = 0
    ans = 0
    for i in range(n):
        if a[i] < 0:
            hoge += 1
    if 0 in a or hoge % 2 == 0:
        for i in range(n):
            ans += abs(a[i])
    else:
        huga = []
        for i in range(n):
            a[i] = abs(a[i])
            ans += abs(a[i])
            if a[i] > 0:
                huga.append(a[i])
        ans -= min(huga)*2
    print(ans)
    return 0

if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Runtime Error):
import numpy as np
import math
import collections
import fractions
import itertools

def solve():
    n = int(input())
    h = list(map(int, input().split()))
    m = h[0]
    ans = 0
    for i in range(1,h-1):
        if h[i] >= m:
            ans += 1
            m = h[i]
    print(ans)
    return 0

if __name__ == '__main__':
    solve()

Fixed submission:
import numpy as np
import math
import collections
import fractions
import itertools

def solve():
    n = int(input())
    h = list(map(int, input().split()))
    m = h[0]
    ans = 0
    for i in range(1,n):
        if h[i] >= m:
            ans += 1
            m = h[i]
    print(ans+1)
    return 0

if __name__ == '__main__':
    solve()

Buggy python submission (verdict: Runtime Error):
import numpy as np
import math
import collections
import fractions
import itertools

def solve():
    n = int(input)
    h = list(map(int, input().split()))
    m = h[0]
    ans = 0
    for i in range(1,h-1):
        if h[i] >= m:
            ans += 1
            m = h[i]
    print(ans)
    return 0

if __name__ == '__main__':
    solve()

Fixed submission:
import numpy as np
import math
import collections
import fractions
import itertools

def solve():
    n = int(input())
    h = list(map(int, input().split()))
    m = h[0]
    ans = 0
    for i in range(1,n):
        if h[i] >= m:
            ans += 1
            m = h[i]
    print(ans+1)
    return 0

if __name__ == '__main__':
    solve()
Buggy python submission (verdict: Runtime Error):
import math
import collections
import fractions
import itertools

def solve():
    n, m = map(int, input().split())
    x = list(map(int, input().split()))
    x.sort()
    if n >= m:
        print(0)
    else:
        diff = [abs(x[i] - x[i+1]) for i in range(m-1)]
        diff.sort(reverse=True)
        ans = sum(diff)
        for i in range(n-1):
            ans -= diff[i]
    print(ans)
    return 0

if __name__ == "__main__":
    solve()


Fixed submission:
import math
import collections
import fractions
import itertools

def solve():
    n, m = map(int, input().split())
    x = list(map(int, input().split()))
    x.sort()
    if n >= m:
        print(0)
    else:
        diff = [abs(x[i] - x[i+1]) for i in range(m-1)]
        diff.sort(reverse=True)
        ans = sum(diff)
        for i in range(n-1):
            ans -= diff[i]
        print(ans)
    return 0

if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Runtime Error):
import numpy as np
import math

def solve():
    n,w = map(int,input().split())
    w_list,v_list = [0]*n,[0]*n
    for i in range(n):
        w_list[i],v_list[i] = map(int,input().split())
    dp = [[0]*(w+5) for i in range(n+5)]
    for i in range(n):
        for j in range(w+1):
            if j >= w_list[i]:
                dp[i][j] = max(
                    dp[i-1][j],
                    dp[i-1][j-w_list[i]]+v_list[i])
            else:
                dp[i][j] = dp[i-1][j]
    print(dp)
    print(dp[n-1][w])
    return 0

if __name__ == "__main__":
    solve()


Fixed submission:
def hoge():
  dp = [0] * (n + 5)
  dp[1] = abs(h_list[1] - h_list[0])
  for i in range(2, n):
    dp[i] = min(
      dp[i - 2] + abs(h_list[i] - h_list[i - 2]),
      dp[i - 1] + abs(h_list[i] - h_list[i - 1])
      )
  return dp[n - 1]

def solve():
  global n, h_list
  n = int(input())
  h_list = list(map(int, input().split()))
  ans = hoge()
  print(ans)
  return 0

if __name__ == "__main__":
  solve()

Buggy python submission (verdict: Runtime Error):
def hoge():
  dp = [0] * (n + 5)
  for i in range(1, n):
    p = [dp[j] + abs(h_list[i] - h_list[j]) for j in range(max(0, i - k), i)]
    dp[i] = min(p)
  return dp[n - 1]

def solve():
  global n, k, h_list
  n, k = map(int, input().split())
  h_list = list(map(int, input().split()))
  ans = hoge()
  print(ans)
  return 0

if __name__ == "__main__":
  solve()

Fixed submission:
def hoge():
  dp = [0] * (n + 5)
  dp[1] = abs(h_list[1] - h_list[0])
  for i in range(2, n):
    dp[i] = min(
      dp[i - 2] + abs(h_list[i] - h_list[i - 2]),
      dp[i - 1] + abs(h_list[i] - h_list[i - 1])
      )
  return dp[n - 1]

def solve():
  global n, h_list
  n = int(input())
  h_list = list(map(int, input().split()))
  ans = hoge()
  print(ans)
  return 0

if __name__ == "__main__":
  solve()

Buggy python submission (verdict: Runtime Error):
def hoge():
  begin = 0
  end = 10 ** 9 + 1
  while abs(end - begin) > 1:
    mid = (begin + end) // 2
    cost = a * mid + b * len(str(mid))
    if cost <= x:
      begin = mid
    else:
      end = mid
  return begin

def solve():
  global a, b, x
  a, b, x = map(int, input().split())
  ans = hoge()
  print(ans)
  return 0

if __name__ == "__main__":
  solve()

Fixed submission:
def hoge():
  dp = [0] * (n + 5)
  dp[1] = abs(h_list[1] - h_list[0])
  for i in range(2, n):
    dp[i] = min(
      dp[i - 2] + abs(h_list[i] - h_list[i - 2]),
      dp[i - 1] + abs(h_list[i] - h_list[i - 1])
      )
  return dp[n - 1]

def solve():
  global n, h_list
  n = int(input())
  h_list = list(map(int, input().split()))
  ans = hoge()
  print(ans)
  return 0

if __name__ == "__main__":
  solve()
Buggy python submission (verdict: Runtime Error):
def solve():
    n = int(input())
    a = list(map(int, input().split()))
    ruiseki = [0,a[0]]
    ans = 0
    for i in range(n-1):
        ruiseki.append(ruiseki[i]+a[i+1])
        if ruiseki[i]+a[i+1] == 0:
            ans += 1
    c = collections.Counter(ruiseki).values()
    for i in c:
        ans += i*(i-1)//2
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

Fixed submission:
import numpy as np
import math
import collections
import fractions
import itertools

def solve():
    n = int(input())
    a = list(map(int, input().split()))
    ruiseki = [0]
    ans = 0
    for i in range(n):
        ruiseki.append(ruiseki[i]+a[i])
    c = collections.Counter(ruiseki).values()
    for i in c:
        ans += i*(i-1)//2
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    n = int(input())
    a = list(map(int, input().split()))
    ruiseki = [a[0]]
    for i in range(n-1):
        ruiseki.append(ruiseki[i]+a[i+1])
    ans = 0
    for i in range(n-1):
        if ruiseki[i] == 0:
            ans += 1
        for j in range(i+1, n):
            if ruiseki[j]-ruiseki[i] == 0:
                ans += 1
    if ruiseki[-1] == 0:
        ans += 1
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

Fixed submission:
import numpy as np
import math
import collections
import fractions
import itertools

def solve():
    n = int(input())
    a = list(map(int, input().split()))
    ruiseki = [0]
    ans = 0
    for i in range(n):
        ruiseki.append(ruiseki[i]+a[i])
    c = collections.Counter(ruiseki).values()
    for i in c:
        ans += i*(i-1)//2
    print(ans)
    return 0

if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Runtime Error):
import numpy as np
import functools
import math
import scipy
import fractions
import itertools
 
def solve():
    n, h = map(int, input().split())
    a, b = [0]*n, [0]*n
    for i in range(n):
        a[i],b[i] = map(int, input().split())
    a.sort(reverse = True)
    ans = 0
    m = max(a)
    for i in range(n):
        if b[i] > m:
            h -= b[i]
            ans += 1
        if h <= 0:
            print(ans)
            exit()
    ans += math.ceil(h/m)
    print(ans)
    return 0
 
if __name__ == "__main__":
    solve()
import numpy as np
import functools
import math
import scipy
import fractions
import itertools

def solve():
    n, h = map(int, input().split())
    a, b = [0]*n, [0]*n
    for i in range(n):
        a[i],b[i] = map(int, input().split())
    a.sort(reverse = True)
    print(a)
    ans = 0
    m = max(a)
    for i in range(n):
        if b[i] >= m:
            h -= b[i]
            ans += 1
        if h <= 0:
            print(ans)
            exit()
    ans += math.ceil(h/m)
    print(ans)
    return 0

if __name__ == "__main__":
    solve()


Fixed submission:
import numpy as np
import functools
import math
import scipy
import fractions
import itertools

def solve():
    n, h = map(int, input().split())
    a, b = [0]*n, [0]*n
    for i in range(n):
        a[i],b[i] = map(int, input().split())
    a.sort(reverse = True)
    b.sort(reverse = True)
    ans = 0
    m = max(a)
    bit = 0
    for i in range(n):
        if b[i] > m:
            h -= b[i]
            ans += 1
        if h <= 0:
            print(ans)
            bit = 1
            break
    if bit == 0:
        ans += math.ceil(h/m)
        print(ans)
    return 0
 
if __name__ == "__main__":
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import functools
import math
import scipy
import fractions
import itertools

def solve():
    n, h = map(int, input().split())
    a, b = [0]*n, [0]*n
    for i in range(n):
        a[i],b[i] = map(int, input().split())
    a.sort(reverse = True)
    ans = 0
    for i in range(n):
        if b[i] >= max(a):
            h -= b[i]
            ans += 1
        if h <= 0:
            print(ans)
            exit()
    while True:
        h -= max(a)
        ans += 1
        if h <= 0:
            print(ans)
            exit()
    return 0

if __name__ == "__main__":
    solve()


Fixed submission:
import numpy as np
import functools
import math
import scipy
import fractions
import itertools

def solve():
    n, h = map(int, input().split())
    a, b = [0]*n, [0]*n
    for i in range(n):
        a[i],b[i] = map(int, input().split())
    a.sort(reverse = True)
    b.sort(reverse = True)
    ans = 0
    m = max(a)
    bit = 0
    for i in range(n):
        if b[i] > m:
            h -= b[i]
            ans += 1
        if h <= 0:
            print(ans)
            bit = 1
            break
    if bit == 0:
        ans += math.ceil(h/m)
        print(ans)
    return 0
 
if __name__ == "__main__":
    solve()