Problem p03001 (python)

Fixed submission:
w,h,x,y=map(int,input().split())
if (x==w/2) and (y==h/2):
    print((w*h)/2,1)
else:
    print((w*h)/2,0)

Buggy submission (verdict: Runtime Error):
w,h,x,y=map(int,input().split())
area=w*h
if x!=0:
    if (y/x)*w>=h:
        ax=(h/y)*x
        if ((y-h)/x)*w+h>=0:
            ayy=((y-h)/x)*w+h
            axx=((x-w)*w)/y+w
            if y!=h:
                ay=((y-h)/(w-x))*w+h
                lst=[min(area-((w-axx)*h)/2,((w-axx)*h)/2),min(area-((h-ayy)*w)/2,((h-ayy)*w)/2),min(area-h*x,h*x),min(area-w*y,w*y),min(area-(ax*h)/2,(ax*h)/2),min(area-(ay*w)/2,(ay*w)/2)]
                ans=max(lst)
                if lst.count(ans)==1:
                    f=0
                else:
                    f=1
            else:
                lst=[min(area-((w-axx)*h)/2,((w-axx)*h)/2),min(area-h*x,h*x),min(area-(ax*h)/2,(ax*h)/2)]
                ans=max(lst)
                if lst.count(ans)==1:
                    f=0
                else:
                    f=1
        else:
            axx=(h*x)/(h-y)
            ayy=(w*y)/(w-y)
            ay=((y-h)/(w-x))*w+h
            lst=[min(area-(w*ayy)/2,(w*ayy)/2),min(area-(axx*h)/2,(axx*h)/2),min(area-h*x,h*x),min(area-w*y,w*y),min(area-(ax*h)/2,(ax*h)/2),min(area-(ay*w)/2,(ay*w)/2)]
            ans=max(lst)
            if lst.count(ans)==1:
                f=0
            else:
                f=1
    else:
        ay=(w*y)/x
        if ((y-h)/x)*w+h>=0:
            axx=((x-w)*w)/y+w
            ayy=((y-h)/x)*w+h
            if x!=w:
                ax=((w-x)/(y-h))*h+w
                lst=[min(area-((w-axx)*h)/2,((w-axx)*h)/2),min(area-((h-ayy)*w)/2,((h-ayy)*w)/2),min(area-h*x,h*x),min(area-w*y,w*y),min(area-(ay*w)/2,(ay*w)/2),min(area-((w-ax)*h)/2,((w-ax)*h)/2)]
                ans=max(lst)
                if lst.count(ans)==1:
                    f=0
                else:
                    f=1
            else:
                lst=[min(area-((h-ayy)*w)/2,((h-ayy)*w)/2),min(area-w*y,w*y),min(area-(ay*w)/2,(ay*w)/2)]
                ans=max(lst)
                if lst.count(ans)==1:
                    f=0
                else:
                    f=1
        else:
            axx=(h*x)/(h-y)
            ayy=(w*y)/(w-y)
            ax=((w-x)/(y-h))*h+w
            lst=[min(area-(w*ayy)/2,(w*ayy)/2),min(area-(axx*h)/2),min(area-(axx*h)/2,(axx*h)/2),min(area-h*x,h*x),min(area-w*y,w*y),min(area-(ay*w)/2,(ay*w)/2),min(area-((w-ax)*h)/2,((w-ax)*h)/2)]
            ans=max(lst)
            if lst.count(ans)==1:
                f=0
            else:
                f=1
else:
    lst=[min(area-w*y,w*y),min(((h-y)*w)/2,area-((h-y)*w)/2),min(area-(y*w)/2,(y*w)/2)]
    ans=max(lst)
    if lst.count(ans)==1:
        f=0
    else:
        f=1
print(ans,f)

Buggy submission (verdict: Runtime Error):
w,h,x,y=map(int,input().split())
area=w*h
if x!=0:
    if (y/x)*w>=h:
        ax=(h/y)*x
        if ((y-h)/x)*w+h>=0:
            ayy=((y-h)/x)*w+h
            axx=((x-w)*w)/y+w
            if y!=h:
                ay=((y-h)/(w-x))*w+h
                lst=[min(area-((w-axx)*h)/2,((w-axx)*h)/2),min(area-((h-ayy)*w)/2,((h-ayy)*w)/2),min(area-h*x,h*x),min(area-w*y,w*y),min(area-(ax*h)/2,(ax*h)/2),min(area-(ay*w)/2,(ay*w)/2)]
                ans=max(lst)
                if lst.count(ans)==1:
                    f=0
                else:
                    f=1
            else:
                lst=[min(area-((w-axx)*h)/2,((w-axx)*h)/2),min(area-h*x,h*x),min(area-(ax*h)/2,(ax*h)/2)]
                ans=max(lst)
                if lst.count(ans)==1:
                    f=0
                else:
                    f=1
        else:
            axx=(h*x)/(h-y)
            ayy=(w*y)/(w-y)
            ay=((y-h)/(w-x))*w+h
            lst=[min(area-(w*ayy)/2,(w*ayy)/2),min(area-(axx*h)/2,(axx*h)/2),min(area-h*x,h*x),min(area-w*y,w*y),min(area-(ax*h)/2,(ax*h)/2),min(area-(ay*w)/2,(ay*w)/2)]
            ans=max(lst)
            if lst.count(ans)==1:
                f=0
            else:
                f=1
    else:
        ay=(w*y)/x
        if ((y-h)/x)*w+h>=0:
            axx=((x-w)*w)/y+w
            ayy=((y-h)/x)*w+h
            if x!=w:
                ax=((w-x)/(y-h))*h+w
                lst=[min(area-((w-axx)*h)/2,((w-axx)*h)/2),min(area-((h-ayy)*w)/2,((h-ayy)*w)/2),min(area-h*x,h*x),min(area-w*y,w*y),min(area-(ay*w)/2,(ay*w)/2),min(area-((w-ax)*h)/2,((w-ax)*h)/2)]
                ans=max(lst)
                if lst.count(ans)==1:
                    f=0
                else:
                    f=1
            else:
                lst=[min(area-((h-ayy)*w)/2,((h-ayy)*w)/2),min(area-w*y,w*y),min(area-(ay*w)/2,(ay*w)/2)]
                ans=max(lst)
                if lst.count(ans)==1:
                    f=0
                else:
                    f=1
        else:
            axx=(h*x)/(h-y)
            ayy=(w*y)/(w-y)
            ax=((w-x)/(y-h))*h+w
            lst=[min(area-(w*ayy)/2,(w*ayy)/2),min(area-(axx*h)/2),min(area-(axx*h)/2,(axx*h)/2),min(area-h*x,h*x),min(area-w*y,w*y),min(area-(ay*w)/2,(ay*w)/2),min(area-((w-ax)*h)/2,((w-ax)*h)/2)]
            ans=max(lst)
            if lst.count(ans)==1:
                f=0
            else:
                f=1
else:
    lst=[min(area-w*y,w*y),min(((h-y)*w)/2,area-((h-y)*w)/2),min(area-(y*w)/2,(y*w)/2)]
    ans=max(lst)
    if lst.count(ans)==1:
        f=0
    else:
        f=1
print(ans,f)