Problem p02879 (python)

Fixed submission:
import sys

for line in sys.stdin:
    A, B = list(map(int, line.split(' ')))


    if 1 <= A <= 9 and 1 <= B <= 9:
        out = A*B
        print(out)
    else:
        print(-1)

Buggy submission (verdict: Runtime Error):
import math
# Calculate amount of water that won't oveflow
def calc(a,b,deg): 
    
    rad = math.radians(deg)
    # deg90_in_rad = math.radians(90)
    # a_sect = a*math.sin(rad) - b*math.sin(deg90_in_rad - rad)
    # b_sect = b*math.sin(deg90_in_rad - rad) - a*math.sin(rad) # 縦と水の切片

    # if b_sect >= 0:
    #     sqr_a = a * b_sect 
    #     tri_a = (b-b_sect)*a*1/2  

    # else:
    #     sqr_a = 0
    #     tri_a = (a - a_sect) * b *1/2
    # total_area = (sqr_a + tri_a) 

    if b*math.tan(math.pi/2-rad) <= a:
        total_area = (b*math.tan(math.pi/2-rad)*b*1/2)
    if b*math.tan(math.pi/2-rad)>a:
        total_area = (a*b - a*math.tan(rad)*a*1/2)       

    return total_area * a

import bisect
def main():
    a, b, x = list(map(int, input().split()))

    left = 0
    right = 90
    deg = 45
    while True:
        y = calc(a, b, deg)
        if y - x >= -10 ** -7 and y - x <= 0:
            break
        if y > x:
            deg, left = (right+deg)/2, deg
        elif y < x:
            deg, right = (left+deg)/2, deg
    print(deg)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):

import math
# Calculate amount of water that won't oveflow
def calc(a,b,deg): 
    
    rad = math.radians(deg)
    deg90_in_rad = math.radians(90)
    a_sect = a*math.sin(rad) - b*math.sin(deg90_in_rad - rad)
    b_sect = b*math.sin(deg90_in_rad - rad) - a*math.sin(rad) # 縦と水の切片

    if b_sect >= 0:
        sqr_a = a * b_sect 
        tri_a = (b-b_sect)*a*1/2  

    else:
        sqr_a = 0
        tri_a = (a - a_sect) * b *1/2

    # if b*math.tan(math.pi/2-rad)>a:
    #     return (a*b - a*math.tan(rad)*a*1/2) *a
    # else:
    #     return (b*math.tan(rad/2-rad)*b*1/2)*a
    # print(a_sect, b_sect)
    return (sqr_a + tri_a) * a

import bisect
def main():
    a, b, x = list(map(int, input().split()))

    left = 0
    right = 90
    deg = 45
    while True:
        y = calc(a, b, deg)
        if y - x <= 0 and y - x >= -10 ** -7 :
            break
        if y > x:
            deg, left = (right+deg)/2, deg
        elif y < x:
            deg, right = (left+deg)/2, deg
        
    print(deg)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
################################################
# Start Below

# imports
    
def factors(n):
    gaps = [1,2,2,4,2,4,2,4,6,2,6]
    length, cycle = 11, 3
    f, fs, nxt = 2, [], 0
    while f * f <= n:
        while n % f == 0:
            fs.append(f)
            n /= f
        f += gaps[nxt]
        nxt += 1
        if nxt == length:
            nxt = cycle
    if n > 1: fs.append(n)
    return fs

import itertools
from itertools import combinations, chain
import copy 

# def powerset(L):
#   pset = set()
#   for n in range(len(L) + 1):
#     for sset in itertools.combinations(L, n):
#       pset.add(sset)
#   return pset
def powerset(iterable):
    "powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)"
    s = list(iterable)
    return chain.from_iterable(combinations(s, r) for r in range(len(s)+1))
    
def list_diff(first, second):
        first = copy.copy(first)
        for s in second:
            first.remove(s)
        return first

def prod(lst):
    ret = 1
    for a in lst:
        ret *= a
    return ret

def sup(x):
    return [sorted(x[:i]+x[i+s:]) for i in range(len(x)) for s in range(len(x))]

def main():
    N = int(input())
    facs = factors(N) 
    # st = powerset(facs)
    st=sup(facs)
    # print(facs, st)

    mn_ij = 10**12
    for i in st+[[]]:
        i = prod(i)
        # j = list_diff(facs, i)
        # i, j = prod(i), prod(j)
        j = N / i
        # print(i,j)
        mn_ij = min(mn_ij, i+j)

    # print(list(map(len,[ st, facs]) ))
    print(int(mn_ij-2))

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
import math

for line in sys.stdin:
    a, b, x = list(map(int, line.split(' ')))

    water_height = x / (a*a)

    r = math.atan(water_height/b*2)

    print(math.degrees(r))

Buggy submission (verdict: Runtime Error):
import sys

for line in sys.stdin:
    N = int(line)
    found=False
    for i in range(1, 10, 1): 
        if N % i == 0 and N // i <= 9:
            found = True
            break
    if found:
        print('Yes')
    else:
        print('No')