Problem:


  MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

A Point in a Triangle

There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.

Write a program which prints "YES" if a point $P$ $(x_p, y_p)$ is in the triangle and "NO" if not.

Input

Input consists of several datasets. Each dataset consists of:

$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$

All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.

Constraints

You can assume that:

$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$

1.0 $\leq$ Length of each side of a tringle

0.001 $\leq$ Distance between $P$ and each side of a triangle

Output

For each dataset, print "YES" or "NO" in a line.

Sample Input

0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0

Output for the Sample Input

YES
NO



Sample input:
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0


Sample output:
YES
NO

Submission status: Runtime Error

Solution code:
import math
while True:
    try:
        x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
    except:
        break
    x = [x1, x2, x3, x1]
    y = [y1, y2, y3, y1]
    x = list(map(lambda i: i - xp, x))
    y = list(map(lambda i: i - yp, y))
    s = lambda a1, a2, b1, b2: abs(a1 * b2 - a2 * b1)
    sum = sum(s(x[i], y[i], x[i + 1], y[i + 1]) for i in range(3))
    S = s(x[1] - x[0], y[1] - y[0], x[2] - x[0], y[2] - y[0])
    if sum == S:
        print('YES')
    else:
        print('NO')

Submission status: Runtime Error

Solution code:
import sys
datasets = sys.stdin

def between(xa, xb, xp):
    return xa < xp < xb or xb < xp < xa

for dataset in datasets:

    x1, y1, x2, y2, x3, y3, xp, yp = map(float, dataset.split())

    if between(x1, x2, xp) and beteen(y1, y2, yp) and between(x2, x3, xp) and between(y2, y3, yp) and between(x3, x1, xp) and between(y3, y1, yp):
        print 'YES'
    else:
        print 'NO'

Submission status: Runtime Error

Solution code:
import sys

for line in sys.stdin:
    x1, y1, x2, y2, x3, y3, xp, yp = map(float, raw_input().split())
    AB = [x2-x1, y2-y1]
    BP = [xp-x2, yp-y2]
    BC = [x3-x2, y3-y2]
    CP = [xp-x3, yp-y3]
    CA = [x1-x3, y1-y3]
    BP = [xp-x1, yp-y1]
    c1 = AB[0] * BP[1] - AB[1] * BP[0]
    c2 = BC[0] * CP[1] - BC[1] * CP[0]
    c3 = CA[0] * AP[1] - CA[1] * AP[0]
    if (c1>0 and c2>0 and c3>0) or (c1<0 and c2<0 and c3<0):
        print 'YES'
    else:
        print 'NO'

Submission status: Runtime Error

Solution code:
import sys

for line in sys.stdin:
    x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split())
    AB = [x2-x1, y2-y1]
    BP = [xp-x2, yp-y2]
    BC = [x3-x2, y3-y2]
    CP = [xp-x3, yp-y3]
    CA = [x1-x3, y1-y3]
    BP = [xp-x1, yp-y1]
    c1 = AB[0] * BP[1] - AB[1] * BP[0]
    c2 = BC[0] * CP[1] - BC[1] * CP[0]
    c3 = CA[0] * AP[1] - CA[1] * AP[0]
    if (c1>0 and c2>0 and c3>0) or (c1<0 and c2<0 and c3<0):
        print 'YES'
    else:
        print 'NO'

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

int main(){
    double x1,y1,x2,y2,x3,y3,xp,yp;
    while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)!=EOF){
        if (((x2-x1)*(y2-y3))-((y1-y3)*(x2-x3))>0 && ((x3-x2)*(y3-yp))-((y1-yp)*(x3-xp))>0) {
        //if(((x2-x1)*(y2-yp)-(y2-y1)*(x2-xp)>0)&&((x3-x2)*(y3-yp)-(y3-y2)*(x3-xp)>0)&&((x1-x3)*(y1-yp)-(y1-y3)*(x1-xp)>0)){
            printf("YES\n");
        //}else if(((x2-x1)*(y2-yp)-(y2-y1)*(x2-xp)<0)&&((x3-x2)*(y3-yp)-(y3-y2)*(x3-xp)<0)&&((x1-x3)*(y1-yp)-(y1-y3)*(x1-xp)<0)){
        //    printf("YES\n");
        }else{
            printf("NO\n");
        }

    }
    return 0;
}

Submission status: Runtime Error

Solution code:
import sys

lines = str(sys.stdin.read()).strip().split("\n")
for line in lines:
    data = line.split(" ")
    x1 = float(data[0])
    y1 = float(data[1])
    x2 = float(data[2])
    y2 = float(data[3])
    x3 = float(data[4])
    y3 = float(data[5])
    xp = float(data[6])
    yp = float(data[7])
    if xp > min(x1, x2, x3) and
    xp < max(x1, x2, x3) and
    yp > min(y1, y2, y3) and
    yp < max(y1, y2, y3):
        print("YES")
    else:
        print("NO")

Submission status: Runtime Error

Solution code:
import sys

def isleft(ox, oy, ax, ay, px, py):
    oax, oay = ax - ox, ay - oy
    opx, opy = px - ox, py - oy
    if oax * opy > oay * opx:
        return 1
    else:
        return 0

for line in sys.stdin:
    x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split())
    A, B, C, P = (x1, y1), (x2, y2), (x3, y3), (xp, yp)
    if isleft(*A, *B, *P) == isleft(*B, *C, *P) == isleft(*C, *A, *P):
        print("YES")
    else:
        print("NO")

Submission status: Runtime Error

Solution code:
import sys

def isleft(ox, oy, ax, ay, px, py):
    oax, oay = ax - ox, ay - oy
    opx, opy = px - ox, py - oy
    if oax * opy > oay * opx:
        return 1
    else:
        return 0

for line in sys.stdin:
    x1, y1, x2, y2, x3, y3, xp, yp = list(map(float, line.split()))
    A, B, C, P = (x1, y1), (x2, y2), (x3, y3), (xp, yp)
    if isleft(*A, *B, *P) == isleft(*B, *C, *P) == isleft(*C, *A, *P):
        print("YES")
    else:
        print("NO")

Submission status: Runtime Error

Solution code:
while True:
  x1,y1,x2,y2,x3,y3,xp,yp=map(float,input().split())
  if xp<0 or yp<0:
    print('No')
  else:
    print('Yes')

Submission status: Runtime Error

Solution code:
# coding: utf-8

def linecheck(x1, y1, x2, y2, xp, yp):
	if yp - y1 > (xp - x1) * (y2 - y1) / (x2 - x1):
		return 1
	elif yp - y1 < (xp - x1) * (y2 - y1) / (x2 - x1):
		return -1

while True:
	try:
		x1, y1, x2, y2, x3, y3, xp, yp = map(float, raw_input().split())

		if x1 == x2:
			if (x1 < xp and xp < x3) or (x1 > xp and xp > x3):
				judge = -1
			else:
				judge = 1
			judge *= linecheck(x1, y1, x3, y3, xp, yp) * linecheck(x2, y2, x3, y3, xp, yp)
		elif x2 == x3:
			if (x1 < xp and xp < x3) or (x1 > xp and xp > x3):
				judge = -1
			else:
				judge = 1
			judge *= linecheck(x1, y1, x2, y2, xp, yp) * linecheck(x1, y1, x3, y3, xp, yp)
		elif x3 == x1:
			if (x1 < xp and xp < x2) or (x1 > xp and xp > x2):
				judge = -1
			else:
				judge = 1
			judge *= linecheck(x1, y1, x2, y2, xp, yp) * linecheck(x2, y2, x3, y3, xp, yp)
		else:
			judge = linecheck(x1, y1, x2, y2, xp, yp) * linecheck(x1, y1, x3, y3, xp, yp) * linecheck(x2, y2, x3, y3, xp, yp)

		if judge > 0:
			print("YES")
		elif judge < 0:
			print("NO")

	except EOFError:
		break

Submission status: Runtime Error

Solution code:
# coding: utf-8

def linecheck(x1, y1, x2, y2, xp, yp):
	if yp - y1 > (xp - x1) * (y2 - y1) / (x2 - x1):
		return 1
	elif yp - y1 < (xp - x1) * (y2 - y1) / (x2 - x1):
		return -1

while True:
	try:
		x1, y1, x2, y2, x3, y3, xp, yp = map(float, raw_input().split())
		if x1 == x2:
			if (x1 < xp and xp < x3) or (x1 > xp and xp > x3):
				judge = -1
			else:
				judge = 1
			judge *= linecheck(x1, y1, x3, y3, xp, yp) * linecheck(x2, y2, x3, y3, xp, yp)
		elif x2 == x3:
			if (x1 < xp and xp < x3) or (x1 > xp and xp > x3):
				judge = -1
			else:
				judge = 1
			judge *= linecheck(x1, y1, x2, y2, xp, yp) * linecheck(x1, y1, x3, y3, xp, yp)
		elif x3 == x1:
			if (x1 < xp and xp < x2) or (x1 > xp and xp > x2):
				judge = -1
			else:
				judge = 1
			judge *= linecheck(x1, y1, x2, y2, xp, yp) * linecheck(x2, y2, x3, y3, xp, yp)
		else:
			judge = linecheck(x1, y1, x2, y2, xp, yp) * linecheck(x1, y1, x3, y3, xp, yp) * linecheck(x2, y2, x3, y3, xp, yp)
		if judge > 0:
			print("YES")
		elif judge < 0:
			print("NO")
	except EOFError:
		break

Submission status: Runtime Error

Solution code:
def linecheck(x1, y1, x2, y2, xp, yp):
	if yp - y1 > (xp - x1) * (y2 - y1) / (x2 - x1):
		return 1
	elif yp - y1 < (xp - x1) * (y2 - y1) / (x2 - x1):
		return -1

while True:
	try:
		x1, y1, x2, y2, x3, y3, xp, yp = map(float, raw_input().split())

		if x1 == x2:
			if (x1 < xp and xp < x3) or (x1 > xp and xp > x3):
				judge = -1
			else:
				judge = 1
			judge *= linecheck(x1, y1, x3, y3, xp, yp) * linecheck(x2, y2, x3, y3, xp, yp)
		elif x2 == x3:
			if (x1 < xp and xp < x3) or (x1 > xp and xp > x3):
				judge = -1
			else:
				judge = 1
			judge *= linecheck(x1, y1, x2, y2, xp, yp) * linecheck(x1, y1, x3, y3, xp, yp)
		elif x3 == x1:
			if (x1 < xp and xp < x2) or (x1 > xp and xp > x2):
				judge = -1
			else:
				judge = 1
			judge *= linecheck(x1, y1, x2, y2, xp, yp) * linecheck(x2, y2, x3, y3, xp, yp)
		else:
			judge = linecheck(x1, y1, x2, y2, xp, yp) * linecheck(x1, y1, x3, y3, xp, yp) * linecheck(x2, y2, x3, y3, xp, yp)

		if judge > 0:
			print("YES")
		elif judge < 0:
			print("NO")

	except EOFError:
		break

Submission status: Runtime Error

Solution code:
import numpy
while True:
    try:
        x1,y1,x2,y2,x3,y3,xp,yp=map(float,raw_input().split())
        AB=numpy.array([x2-x1,y2-y1])
        AP=numpy.array([xp-x1,yp-y1])
        BC=numpy.array([x3-x2,y3-y2])
        BP=numpy.array([xp-x2,yp-y2])
        CA=numpy.array([x1-x3,y1-y3])
        CP=numpy.array([xp-x3,yp-y3])

        if (numpy.cross(AB,AP) < 0 and numpy.cross(BC,BP) < 0 and numpy.cross(CA,CP) < 0) or\
        (numpy.cross(AB,AP) > 0 and numpy.cross(BC,BP) > 0 and numpy.cross(CA,CP) > 0):
            print "YES"
        else:
            print "NO"
    except:
        break

Submission status: Runtime Error

Solution code:
import numpy

while True:
    try:
        x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
        s1 = (x2-x1)*(yp-y1) - (y2-y1)*(xp-x1)
        s2 = (x3-x2)*(yp-y2) - (y3-y2)*(xp-x2)
        s3 = (x1-x3)*(yp-y3) - (y1-y3)*(xp-x3)
        if numpy.sign(s1) == numpy.sign(s2) and numpy.sign(s1) == numpy.sign(s3):
            print("YES")
        else:
            print("NO")
    except:
        break

Submission status: Runtime Error

Solution code:
import numpy
while True:
    try:
        x1,y1,x2,y2,x3,y3,xp,yp=map(float,raw_input().split())
        AB=numpy.array([x2-x1,y2-y1])
        AP=numpy.array([xp-x1,yp-y1])
        BC=numpy.array([x3-x2,y3-y2])
        BP=numpy.array([xp-x2,yp-y2])
        CA=numpy.array([x1-x3,y1-y3])
        CP=numpy.array([xp-x3,yp-y3])
        #print numpy.cross(AB,AP)
        if (numpy.cross(AB,AP) < 0 and numpy.cross(BC,BP) < 0 and numpy.cross(CA,CP) < 0) or\
        (numpy.cross(AB,AP) > 0 and numpy.cross(BC,BP) > 0 and numpy.cross(CA,CP) > 0):
            print "YES"
        else:
            print "NO"
    except:
        break

Submission status: Runtime Error

Solution code:
import numpy
while True:
    try:
        x1,y1,x2,y2,x3,y3,xp,yp=map(float,raw_input().split())
        AB=numpy.array([x2-x1,y2-y1])
        AP=numpy.array([xp-x1,yp-y1])
        BC=numpy.array([x3-x2,y3-y2])
        BP=numpy.array([xp-x2,yp-y2])
        CA=numpy.array([x1-x3,y1-y3])
        CP=numpy.array([xp-x3,yp-y3])
        #print numpy.cross(AB,AP)
        if (numpy.cross(AB,AP) < 0 and numpy.cross(BC,BP) < 0 and numpy.cross(CA,CP) < 0) or\
        (numpy.cross(AB,AP) > 0 and numpy.cross(BC,BP) > 0 and numpy.cross(CA,CP) > 0):
            print 'YES'
        else:
            print 'NO'
    except:
        break

Submission status: Runtime Error

Solution code:
import sys
for e in sys.stdin:
 p,q,r,s,t,u,x,y=map(float,e.split())
 a=((x-p)*(u-q)-(y-q)*(t-p))/((r-p)*(u-q)-(s-q)*(t-p))
 b=(x-p-a*(r-p))/(t-p)
 print(['No','Yes'][0<a<1-b and 0<b<1-a])

Submission status: Runtime Error

Solution code:
import sys
for e in sys.stdin:
 p,q,r,s,t,u,x,y=map(float,e.split())
 a=((x-p)*(u-q)-(y-q)*(t-p))/((r-p)*(u-q)-(s-q)*(t-p))
 b=(x-p-a*(r-p))/(t-p)
 print(['NO','YES'][0<a<1-b and 0<b<1-a])

Submission status: Runtime Error

Solution code:
while 1:
    x1,y1,x2,y2,x3,y3,xp,yp=[float(p) for p in input().split()]
    d_max=max((x2-x1)**2+(y2-y1)**2,(x3-x2)**2+(y3-y2)**2,(x3-x1)**2+(y3-y1)**2)
    d1,d2,d3=(x2-x1)**2+(y2-y1)**2,(x3-x2)**2+(y3-y2)**2,(x3-x1)**2+(y3-y1)**2;
    
    if max(d_max,d1,d2,d3) > d_max:
        print("No")
    else:
        print("Yes")

Submission status: Runtime Error

Solution code:

x1,y1,x2,y2,x3,y3,xp,yp=[float(p) for p in input().split()]

x_vector_1to2=x2-x1;
y_vector_1to2=y2-y1;
x_vector_1to3=x3-x1;
y_vector_1to3=y3-y1;
x_vector_p=xp-x1;
y_vector_p=yp-y1;

def renritu(p,q,r,s,t,u):  # renritu(p,q,r,s,t,u) px + qy = r  sx+ty=u
    a=p; b=q; c=r; d=s; e=t; f=u;
    a1=a*d; b1=b*d; c1=c*d; d1=d*a; e1=e*a; f1=f*a;
    res_y=b1-e1;
    if res_y != 0 :
        res_y =(c1-f1)/res_y;
        res_x =(c-b*res_y)/a;
        return(res_x,res_y)
    else:
        return(-1,-1)
    
res=renritu(x_vector_1to2,x_vector_1to3,x_vector_p,y_vector_1to2,y_vector_1to3,y_vector_p)
if res[0]=>0 and res[1]=>0 and res[0]+res[1]<1:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
while(true):

    x1,y1,x2,y2,x3,y3,xp,yp=[float(p) for p in input().split()]

    x_vector_1to2=x2-x1;
    y_vector_1to2=y2-y1;
    x_vector_1to3=x3-x1;
    y_vector_1to3=y3-y1;
    x_vector_p=xp-x1;
    y_vector_p=yp-y1;

    def renritu(p,q,r,s,t,u):  # renritu(p,q,r,s,t,u) px + qy = r  sx+ty=u
        a=p; b=q; c=r; d=s; e=t; f=u;
        a1=a*d; b1=b*d; c1=c*d; d1=d*a; e1=e*a; f1=f*a;
        res_y=b1-e1;
        if res_y != 0 :
            res_y =(c1-f1)/res_y;
            res_x =(c-b*res_y)/a;
            return(res_x,res_y)
        else:
            return(-1,-1)

    res=renritu(x_vector_1to2,x_vector_1to3,x_vector_p,y_vector_1to2,y_vector_1to3,y_vector_p)
    if res[0] >0 and res[1] >0 and (res[0]+res[1])<1:
        print("YES")
    else:
        print("NO")

Submission status: Runtime Error

Solution code:
while(True):

    x1,y1,x2,y2,x3,y3,xp,yp=[float(p) for p in input().split()]

    x_vector_1to2=x2-x1;
    y_vector_1to2=y2-y1;
    x_vector_1to3=x3-x1;
    y_vector_1to3=y3-y1;
    x_vector_p=xp-x1;
    y_vector_p=yp-y1;

    def renritu(p,q,r,s,t,u):  # renritu(p,q,r,s,t,u) px + qy = r  sx+ty=u
        a=p; b=q; c=r; d=s; e=t; f=u;
        a1=a*d; b1=b*d; c1=c*d; d1=d*a; e1=e*a; f1=f*a;
        res_y=b1-e1;
        if res_y != 0 :
            res_y =(c1-f1)/res_y;
            res_x =(c-b*res_y)/a;
            return(res_x,res_y)
        else:
            return(-1,-1)

    res=renritu(x_vector_1to2,x_vector_1to3,x_vector_p,y_vector_1to2,y_vector_1to3,y_vector_p)
    if res[0] >0 and res[1] >0 and (res[0]+res[1])<1:
        print("YES")
    else:
        print("NO")

Submission status: Runtime Error

Solution code:
while(True):

    x1,y1,x2,y2,x3,y3,xp,yp=[float(p) for p in input().split()]

    x_vector_1to2=x2-x1;
    y_vector_1to2=y2-y1;
    x_vector_1to3=x3-x1;
    y_vector_1to3=y3-y1;
    x_vector_p=xp-x1;
    y_vector_p=yp-y1;

    def renritu(p,q,r,s,t,u):  # renritu(p,q,r,s,t,u) px + qy = r  sx+ty=u
        a=p; b=q; c=r; d=s; e=t; f=u;
        a1=a*d; b1=b*d; c1=c*d; d1=d*a; e1=e*a; f1=f*a;
        res_y=b1-e1;
        if res_y != 0 :
            res_y =(c1-f1)/res_y;
            res_x =(c-b*res_y)/a;
            return(res_x,res_y)
        else:
            return(-1,-1)

    res=renritu(x_vector_1to2,x_vector_1to3,x_vector_p,y_vector_1to2,y_vector_1to3,y_vector_p)
    if res[0] >=0 and res[1] >=0 and (res[0]+res[1])<=1:
        print("YES")
    else:
        print("NO")

Submission status: Runtime Error

Solution code:
while(True):

    x1,y1,x2,y2,x3,y3,xp,yp=[float(p) for p in input().split()]

    x_vector_1to2=x2-x1;
    y_vector_1to2=y2-y1;
    x_vector_1to3=x3-x1;
    y_vector_1to3=y3-y1;
    x_vector_p=xp-x1;
    y_vector_p=yp-y1;

    def renritu(p,q,r,s,t,u):  # renritu(p,q,r,s,t,u) px + qy = r  sx+ty=u
        a=p; b=q; c=r; d=s; e=t; f=u;
        a1=a*d; b1=b*d; c1=c*d; d1=d*a; e1=e*a; f1=f*a;
        res_y=b1-e1;
        if res_y != 0 :
            res_y =(c1-f1)/res_y;
            res_x =(c-b*res_y)/a;
            return(res_x,res_y)
        else:
            return(-1,-1)

    res=renritu(x_vector_1to2,x_vector_1to3,x_vector_p,y_vector_1to2,y_vector_1to3,y_vector_p)
    if res[0] >=0 and res[1] >=0 and (res[0]+res[1])<=1:
        print('YES')
    else:
        print('NO')

Submission status: Runtime Error

Solution code:
import math
lm=lambda x,y,xa,ya,xb,yb:abs((yb-ya)/(xb-xa)*xa+xa - y + (yb-ya)/(xb-xa)*x) / math.hypot((yb-ya)/(xb-xa),-1) if (xb-xa)!=0 else abs(x-xb)
while True:
    r=input()
    if r=="":break
    x1,y1,x2,y2,x3,y3,xp,yp=[float(i) for i in r.split()]
    if lm(x1,y1,x2,y2,x3,y3)<lm(xp,yp,x2,y2,x3,y3) or lm(x2,y2,x1,y1,x3,y3)<lm(xp,yp,x1,y1,x3,y3) or lm(x3,y3,x1,y1,x2,y2)<lm(xp,yp,x1,y1,x2,y2):
        print("NO")
    else:
        print("YES")

Submission status: Runtime Error

Solution code:
import math
def lm(x,y,xa,ya,xb,yb):
    if (xb-xa)==0:return abs(x-xb)
    d=(yb-ya)/(xb-xa)
    return abs(d*xa+xa - y + d*x) / math.hypot(d,-1)
while True:
    r=input()
    if r=="":break
    x1,y1,x2,y2,x3,y3,xp,yp=[float(i) for i in r.split()]
    a=bool(lm(x1,y1,x2,y2,x3,y3)<lm(xp,yp,x2,y2,x3,y3))
    b=bool(lm(x2,y2,x1,y1,x3,y3)<lm(xp,yp,x1,y1,x3,y3))
    c=bool(lm(x3,y3,x1,y1,x2,y2)<lm(xp,yp,x1,y1,x2,y2))
    if a or b or c:
        print("NO")
    else:
        print("YES")

Submission status: Runtime Error

Solution code:
g=lambda a,b:abs(a[0]*b[1]-a[1]*b[0])

while True:
    l=[float(i) for i in input().split()]
    if not l:break
    ba=[l[0]-l[2],l[1]-l[3]]
    ab=[-i for i in ba]
    cb=[l[2]-l[4],l[3]-l[5]]
    bc=[-i for i in cb]
    ca=[l[0]-l[4],l[1]-l[5]]
    ac=[-i for i in ca]
    ap=[l[6]-l[0],l[7]-l[1]]
    bp=[l[6]-l[2],l[7]-l[3]]
    cp=[l[6]-l[4],l[7]-l[5]]
    if g(ab,ac)<g(ab,ap) or g(ba,bc)<g(ba,bp) or g(ca,cb)<g(ca,cp):
        print("NO")
    else:
        print("YES")

Submission status: Runtime Error

Solution code:
g=lambda a,b:abs(a[0]*b[1]-a[1]*b[0])

while True:
    t=input()
    if t=="":break
    l=[float(i) for i in t.split()]
    ba=[l[0]-l[2],l[1]-l[3]]
    ab=[-i for i in ba]
    cb=[l[2]-l[4],l[3]-l[5]]
    bc=[-i for i in cb]
    ca=[l[0]-l[4],l[1]-l[5]]
    ac=[-i for i in ca]
    ap=[l[6]-l[0],l[7]-l[1]]
    bp=[l[6]-l[2],l[7]-l[3]]
    cp=[l[6]-l[4],l[7]-l[5]]
    if g(ab,ac)<g(ab,ap) or g(ba,bc)<g(ba,bp) or g(ca,cb)<g(ca,cp):
        print("NO")
    else:
        print("YES")

Submission status: Runtime Error

Solution code:
g=lambda a,b:abs(a[0]*b[1]-a[1]*b[0])

while True:
    t=input()
    if t=="":break
    l=[float(i) for i in t.split()]
    ba=[l[0]-l[2],l[1]-l[3]]
    ab=[-i for i in ba]
    cb=[l[2]-l[4],l[3]-l[5]]
    bc=[-i for i in cb]
    ca=[l[0]-l[4],l[1]-l[5]]
    ac=[-i for i in ca]
    ap=[l[6]-l[0],l[7]-l[1]]
    bp=[l[6]-l[2],l[7]-l[3]]
    cp=[l[6]-l[4],l[7]-l[5]]
    if g(ab,ac)<g(ab,ap) or g(ba,bc)<g(ba,bp):
        print("NO")
    else:
        print("YES")

Submission status: Runtime Error

Solution code:
g=lambda a,b:abs(a[0]*b[1]-a[1]*b[0])

while True:
    t=input()
    if t=="":break
    l=[float(i) for i in t.split()]
    ba=[l[0]-l[2],l[1]-l[3]]
    ab=[-i for i in ba]
    cb=[l[2]-l[4],l[3]-l[5]]
    bc=[-i for i in cb]
    ca=[l[0]-l[4],l[1]-l[5]]
    ac=[-i for i in ca]
    ap=[l[6]-l[0],l[7]-l[1]]
    bp=[l[6]-l[2],l[7]-l[3]]
    cp=[l[6]-l[4],l[7]-l[5]]
    if 0:
        print("NO")
    else:
        print("YES")

Submission status: Runtime Error

Solution code:
g=lambda a,b:abs(a[0]*b[1]-a[1]*b[0])

while True:
    t=input()
    if t=="":
        break
    l=[float(i) for i in t.split()]
    ba=[l[0]-l[2],l[1]-l[3]]
    ab=[-i for i in ba]
    cb=[l[2]-l[4],l[3]-l[5]]
    bc=[-i for i in cb]
    ca=[l[0]-l[4],l[1]-l[5]]
    ac=[-i for i in ca]
    ap=[l[6]-l[0],l[7]-l[1]]
    bp=[l[6]-l[2],l[7]-l[3]]
    cp=[l[6]-l[4],l[7]-l[5]]
    if g(ab,ac)<g(ab,ap) or g(ba,bc)<g(ba,bp) or g(ca,cb)<g(ca,cp):
        print("NO")
    else:
        print("YES")

Submission status: Runtime Error

Solution code:
import sys

def cross(a,b,p):
    return ((b[0]-a[0])*(p[1]-a[1])) - ((p[0]-a[0])*(b[1]-a[1]))

for i in sys.stdin.readlines():
    l = [float(x) for x in i.split()]
    a,b,c,p = [l[:2],l[2:4],l[4:6],l[6:]]

    if cross(a,b,p)<=0 and cross(b,c,p)<=0 and cross(c,a,p)<=0 :
        print "YES"
    elif cross(a,b,p)>=0 and cross(b,c,p)>=0 and cross(c,a,p)>=0 :
        print "YES"
    else:
        print "N0"

Submission status: Runtime Error

Solution code:
import sys

def cross(a,b,p):
    return ((b[0]-a[0])*(p[1]-a[1])) - ((p[0]-a[0])*(b[1]-a[1]))

for i in sys.stdin:
    l = [float(x) for x in i.split()]
    a,b,c,p = [l[:2],l[2:4],l[4:6],l[6:]]

    if cross(a,b,p)<=0 and cross(b,c,p)<=0 and cross(c,a,p)<=0 :
        print "YES"
    elif cross(a,b,p)>=0 and cross(b,c,p)>=0 and cross(c,a,p)>=0 :
        print "YES"
    else:
        print "N0"

Submission status: Runtime Error

Solution code:
import sys

def cross(a, b):
	return (a.conjugate() * b).real
def dot(a, b):
	return (a.conjugate() * b).imag

def ccw(a, b, c):
	x = b - a
	y = c - a;
	if cross(x, y) > 0: return 1
	if cross(x, y) < 0: return -1
	if dot(x, y) < 0: return 2
	if abs(x) < abs(y): return -2
	return 0

def solve(l, p):
	x = ccw(l[0][0], l[0][1], p)
	x = int(x / abs(x))
	for i in l[1:]:
		y = ccw(i[0], i[1], p)
		y = int(y / abs(y))
		if x != y:
			print "NO"
			return
	print 'YES'

for line in sys.stdin:
	ax, ay, bx, by, cx, cy, px, py = map(float, line.split())
	a = complex(ax, ay)
	b = complex(bx, by)
	c = complex(cx, cy)
	p = complex(px, py)
	solve([(a, b), (b, c), (c, a)], p)

Submission status: Runtime Error

Solution code:
import sys

def cross(a, b):
	return (a.conjugate() * b).real
def dot(a, b):
	return (a.conjugate() * b).imag

def ccw(a, b, c):
	x = b - a
	y = c - a;
	if cross(x, y) > 0: return 1
	if cross(x, y) < 0: return -1
	if dot(x, y) < 0: return 2
	if abs(x) < abs(y): return -2
	return 0

def solve(l, p):
	x = ccw(l[0][0], l[0][1], p)
	if x != 0:
		x = int(x / abs(x))
	for i in l[1:]:
		y = ccw(i[0], i[1], p)
		if y != 0:
			y = int(y / abs(y))
		if x != y:
			print "NO"
			return
	print 'YES'

for line in sys.stdin:
	ax, ay, bx, by, cx, cy, px, py = map(float, line.split())
	a = complex(ax, ay)
	b = complex(bx, by)
	c = complex(cx, cy)
	p = complex(px, py)
	solve([(a, b), (b, c), (c, a)], p)

Submission status: Runtime Error

Solution code:
import sys
for line in sys.stdin:
    list=map(float,line.split())
    x=list[0:6:2]
    y=list[1:6:2]
    xp=list[6]
    yp=list[7]
    xv=[x[a%3]-x[(a+1)%3] for a in xrange(4)]
    yv=[y[a%3]-y[(a+1)%3] for a in xrange(4)]
    xpv=[xp-x[a] for a in xrange(3)]
    ypv=[yp-y[a] for a in xrange(3)]
    cross=[xv[i]*ypv[i]-yv[i]*xpv[i] for i in xrange(3)]
    sorted(cross)
    if (cross[2]>0 and cross[0]>0) or (cross[2]<0 and cross[0]<0): 
        print "YES"
    else:
        print "NO"

Submission status: Runtime Error

Solution code:
import sys
for line in sys.stdin.readlines():
    list=map(float,line.split())
    x=list[0:6:2]
    y=list[1:6:2]
    xp=list[6]
    yp=list[7]
    xv=[x[a%3]-x[(a+1)%3] for a in xrange(4)]
    yv=[y[a%3]-y[(a+1)%3] for a in xrange(4)]
    xpv=[xp-x[a] for a in xrange(3)]
    ypv=[yp-y[a] for a in xrange(3)]
    cross=[xv[i]*ypv[i]-yv[i]*xpv[i] for i in xrange(3)]
    sorted(cross)
    if (cross[2]>0 and cross[0]>0) or (cross[2]<0 and cross[0]<0): 
        print "YES"
    else:
        print "NO"

Submission status: Runtime Error

Solution code:
import sys
for line in sys.stdin.readlines():
    list=map(float,line.split(" "))
    x=list[0:6:2]
    y=list[1:6:2]
    xp=list[6]
    yp=list[7]
    xv=[x[a%3]-x[(a+1)%3] for a in xrange(4)]
    yv=[y[a%3]-y[(a+1)%3] for a in xrange(4)]
    xpv=[xp-x[a] for a in xrange(3)]
    ypv=[yp-y[a] for a in xrange(3)]
    cross=[xv[i]*ypv[i]-yv[i]*xpv[i] for i in xrange(3)]
    sorted(cross)
    if (cross[2]>0 and cross[0]>0) or (cross[2]<0 and cross[0]<0): 
        print "YES"
    else:
        print "NO"

Submission status: Runtime Error

Solution code:
#coding: utf-8
def isInOut(p, q, s, c, z):
    if (p*c[0] + q*c[1] - s)*(p*z[0] + q*z[1] - s) > 0:
        return True
    else:
        return False

while 1:
    try:
        x = [0 for i in xrange(3)]
        y = [0 for i in xrange(3)]
        c = [0 for i in xrange(2)]
        z = [0 for i in xrange(2)]
        a,b,t = [[0 for i in xrange(2)] for i in xrange(3)]
        p,q,s = [[0 for i in xrange(3)] for i in xrange(3)]
        x[0],y[0],x[1],y[1],x[2],y[2],z[0],z[1] = map(float, raw_input().split())
        c = [sum(x)/3, sum(y)/3]
            
        for j in xrange(3):
            if x[j] == x[j-1]:
                p[j] = 1.
                q[j] = 0.
                s[j] = x[j]
            else:
                t[j] = (y[j] - y[j-1]) / (x[j] - x[j-1])
                p[j] = t[j]
                q[j] = -1.
                s[j] = t[j]*x[j]-y[j]
            #print p[j], q[j], s[j]
            if isInOut(p[j], q[j], s[j], c, z) is False:
                print "NO"
                break
        else:
            print "YES"
            
    except EOFError:
        break

Submission status: Runtime Error

Solution code:
#coding: utf-8
def isInOut(p, q, s, c, z):
    if (p*c[0] + q*c[1] - s)*(p*z[0] + q*z[1] - s) > 0:
        return True
    else:
        return False

while 1:
    try:
        x = [0 for i in xrange(3)]
        y = [0 for i in xrange(3)]
        c = [0 for i in xrange(2)]
        z = [0 for i in xrange(2)]
        t = [0 for i in xrange(3)]
        p,q,s = [[0 for i in xrange(3)] for i in xrange(3)]
        x[0],y[0],x[1],y[1],x[2],y[2],z[0],z[1] = map(float, raw_input().split())
        c = [sum(x)/3, sum(y)/3]
            
        for j in xrange(3):
            if x[j] == x[j-1]:
                p[j] = 1.
                q[j] = 0.
                s[j] = x[j]
            else:
                t[j] = (y[j] - y[j-1]) / (x[j] - x[j-1])
                p[j] = t[j]
                q[j] = -1.
                s[j] = t[j]*x[j]-y[j]
            #print p[j], q[j], s[j]
            if isInOut(p[j], q[j], s[j], c, z) is False:
                print "NO"
                break
        else:
            print "YES"
            
    except EOFError:
        break

Submission status: Runtime Error

Solution code:
#coding: utf-8
def dot(a, b):
    return (a.real*b.real - a.imag*b.imag)
def cross(a, b):
    return (a.real*b.imag - a.imag*b.real)

EPS = 10**(-7)

def isIntersectedLS(a1, a2, b1, b2):
    return ((cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1)) < EPS and
            (cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1)) < EPS)

while 1:
    try:
        x,y = [[0 for i in xrange(3)] for j in xrange(2)]
        a = []
        z = [0 for i in xrange(2)]
        x[0],y[0],x[1],y[1],x[2],y[2],z[0],z[1] = map(float, raw_input().split())
        for i in xrange(3):
            a.append((x[i]+(y[i])*1j))
        c = (sum(x)/3)+(sum(y)/3)*1j
        p = z[0]+z[1]*1j
            
        for i in xrange(3):
            #print a, c, p
            if isIntersectedLS(a[i-1], a[i], c, p) is True:
                print "NO"
                break
        else:
            print "YES"
            
    except EOFError:
        break

Submission status: Runtime Error

Solution code:
def dot(a, b):
    return (a.real*b.real - a.imag*b.imag)
def cross(a, b):
    return (a.real*b.imag - a.imag*b.real)

EPS = 10**(-7)

def isIntersectedLS(a1, a2, b1, b2):
    return ((cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1)) < EPS and
            (cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1)) < EPS)

while 1:
    try:
        x,y = [[0 for i in xrange(3)] for j in xrange(2)]
        a = []
        z = [0 for i in xrange(2)]
        x[0],y[0],x[1],y[1],x[2],y[2],z[0],z[1] = map(float, raw_input().split())
        for i in xrange(3):
            a.append((x[i]+(y[i])*1j))
        c = (sum(x)/3)+(sum(y)/3)*1j
        p = z[0]+z[1]*1j
            
        for i in xrange(3):
            #print a, c, p
            if isIntersectedLS(a[i-1], a[i], c, p) is True:
                print "NO"
                break
        else:
            print "YES"
            
    except EOFError:
        break

Submission status: Runtime Error

Solution code:
def dot(a, b):
    return (a.real*b.real - a.imag*b.imag)
def cross(a, b):
    return (a.real*b.imag - a.imag*b.real)

EPS = 10**(-7)

def isIntersectedLS(a1, a2, b1, b2):
    return ((cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1)) < EPS and
            (cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1)) < EPS)

while 1:
    try:
        x,y = [[0 for i in range(3)] for j in range(2)]
        a = []
        z = [0 for i in range(2)]
        x[0],y[0],x[1],y[1],x[2],y[2],z[0],z[1] = map(float, raw_input().split())
        for i in xrange(3):
            a.append((x[i]+(y[i])*1j))
        c = (sum(x)/3)+(sum(y)/3)*1j
        p = z[0]+z[1]*1j
            
        for i in xrange(3):
            #print a, c, p
            if isIntersectedLS(a[i-1], a[i], c, p) is True:
                print "NO"
                break
        else:
            print "YES"
            
    except EOFError:
        break

Submission status: Runtime Error

Solution code:
def dot(a, b):
    return (a.real*b.real - a.imag*b.imag)
def cross(a, b):
    return (a.real*b.imag - a.imag*b.real)

EPS = 10**(-7)

def isIntersectedLS(a1, a2, b1, b2):
    return ((cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1)) < EPS and
            (cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1)) < EPS)

def main():
    while 1:
        try:
            x,y = [[0. for i in xrange(3)] for j in xrange(2)]
            a = []
            z = [0. for i in xrange(2)]
            x[0],y[0],x[1],y[1],x[2],y[2],z[0],z[1] = map(float, raw_input().split())
            for i in xrange(3):
                a.append((x[i]+(y[i])*1j))
            c = (sum(x)/3)+(sum(y)/3)*1j
            p = z[0]+z[1]*1j
                
            for i in xrange(3):
                #print a, c, p
                if isIntersectedLS(a[i-1], a[i], c, p) is True:
                    print "NO"
                    break
            else:
                print "YES"
                
        except EOFError:
            break

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def dot(a, b):
    return (a.real*b.real - a.imag*b.imag)
def cross(a, b):
    return (a.real*b.imag - a.imag*b.real)

EPS = 10**(-7)

def isIntersectedLS(a1, a2, b1, b2):
    return ((cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1)) < EPS and
            (cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1)) < EPS)

while 1:
    try:
        x1,y1,x2,y2,x3,y3 = (0,0,0,0,0,0)
        a = []
        xp,yp = (0,0)
        x1,y1,x2,y2,x3,y3,xp,yp = map(float, raw_input().split())
        a.append(x1+(y1)*1j)
        a.append(x2+(y2)*1j)
        a.append(x3+(y3)*1j)
        c = (x1+x2+x3)/3+((y1+y2+y3)/3)*1j
        p = xp+yp*1j
            
        for i in xrange(3):
            #print a, c, p
            if isIntersectedLS(a[i-1], a[i], c, p) is True:
                print "NO"
                break
        else:
            print "YES"
            
    except EOFError:
        break