def compute_cost(milliseconds, sat_per_second): if any(type(x) is not int or not 0 <= x <= 10**9 for x in (milliseconds, sat_per_second)): raise ValueError("invalid measurement") return (milliseconds * sat_per_second + 999) // 1000 assert compute_cost(1501, 2) == 4 assert compute_cost(0, 2) == 0 assert compute_cost(1000, 2) == 2