Problem p02677 (python)

Fixed submission:
import sys
import math

a,b,h,m = (float(x) for x in input().split())

zi = 0.5 * 60 * h + 0.5 * m
hun = 6 * h * 60 + 6 * m

if hun >= 360:
    for i in range(11):

        if hun >= 360:
            hun = hun - 360 
        elif hun < 360:
            break



if hun > zi:
    if hun - zi > 180:
        degree = 360 - hun + zi
    elif hun - zi < 180:
        degree = hun - zi
    elif hun - zi == 180:
        print(a + b)
        sys.exit(0)

elif zi > hun: 
    if zi - hun > 180:
        degree = 360 - zi + hun
    elif zi - hun < 180:
        degree = zi - hun
    elif zi - hun == 180:
        print(a + b)
        sys.exit(0)
elif hun == zi:
    if b >= a:
        print(b - a)
        sys.exit(0)
    else:
        print(a-b)
        sys.exit(0)

cosain = math.cos(math.radians(degree))

print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * cosain))

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

a,b,h,m = (float(x) for x in input().split())

zi = 0.5 * 60 * h + 0.5 * m
hun = 6 * h * 60 + 6 * m

if hun >= 360:
    for i in range(11):

        if hun >= 360:
            hun = hun - 360 
        elif hun < 360:
            break

#print(zi)

if hun > zi:
    if hun - zi > 180:
        degree = 360 - hun + zi
    elif hun - zi < 180:
        degree = hun - zi
    elif hun - zi == 180:
        print(a + b)
        sys.exit()

elif zi > hun: 
    if zi - hun > 180:
        degree = 360 - zi + hun
    elif zi - hun < 180:
        degree = zi - hun
    elif hun - zi == 180:
        print(a + b)
        sys.exit()
elif hun == zi:
    if b >= a:
        print(b - a)
        sys.exit()
    else:
        print(a-b)
        sys.exit()

cosain = math.cos(math.radians(degree))

print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * cosain))

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

a,b,h,m = (float(x) for x in input().split())

zi = 0.5 * 60 * h + 0.5 * m
hun = 6 * h * 60 + 6 * m

if hun >= 360:
    for i in range(12):

        if hun >= 360:
            hun = hun - 360 
        elif hun < 360:
            break

#print(zi)

if hun > zi:
    if hun - zi > 180:
        degree = 360 - hun + zi
    elif hun - zi < 180:
        degree = hun - zi
    elif hun - zi == 180:
        print(a + b)
        sys.exit()

elif zi > hun: 
    if zi - hun > 180:
        degree = 360 - zi + hun
    elif zi - hun < 180:
        degree = zi - hun
    elif hun - zi == 180:
        print(a + b)
        sys.exit()
elif hun == zi:
    if b >= a:
        print(b - a)
        sys.exit()
    else:
        print(a-b)
        sys.exit()

cosain = math.cos(math.radians(degree))

print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * cosain))

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

a,b,h,m = (int(x) for x in input().split())

zi = 0.5 * 60 * h + 0.5 * m
hun = 6 * h * 60 + 6 * m

if hun >= 360:
    for i in range(12):

        if hun >= 360:
            hun = hun - 360 
        elif hun < 360:
            break

if hun > zi:
    if hun - zi > 180:
        degree = 360 - hun + zi
    elif hun - zi < 180:
        degree = hun - zi
    elif hun - zi == 180:
        print(a + b)
        sys.exit()
elif hun == zi:
    print(b - a)
    sys.exit()
else:
    if zi - hun > 180:
        degree = 360 - zi + hun
    elif zi - hun < 180:
        degree = zi - hun
    elif hun - zi == 180:
        print(a + b)
        sys.exit()

cosain = math.cos(math.radians(degree))

print(math.sqrt(a ** 2 + b**2 -2 * a * b *cosain))