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

Solution in C# (judge verdict: Wrong Answer)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AthleteProgramming2
{

    class Point
    {
        double x, y;
        public Point(double x, double y)
        {
            this.x = x;
            this.y = y;
        }

        public Point()
        {

        }

        //??????-?????? p1=?????? p2=??????
        public static Point SubVector(Point p1,Point p2)
        {
            Point vector = new Point();
            vector.x = p1.x - p2.x;
            vector.y = p1.y - p2.y;
            return vector;
        }

        public static bool IsMinus(Point p1,Point p2)
        {
            if (p1.x * p2.y - p1.y * p2.x<0)
            {
                return true;
            }else
            {
                return false;
            }
        }

    }

    class Triangle
    {
        Point p1, p2, p3;
        
        public Triangle(Point p1,Point p2,Point p3)
        {
            this.p1 = p1;
            this.p2 = p2;
            this.p3 = p3;
        }

        public static bool IsPointInTriange(Triangle triangle,Point p)
        {
            Point vector1 = Point.SubVector(triangle.p2, triangle.p1);
            Point vector2 = Point.SubVector(triangle.p3, triangle.p2);
            Point vector3 = Point.SubVector(triangle.p1, triangle.p3);
            Point pVector1 = Point.SubVector(p,triangle.p1);
            Point pVector2 = Point.SubVector(p,triangle.p2);
            Point pVector3 = Point.SubVector(p,triangle.p3);

            if (Point.IsMinus(pVector1,vector1) && Point.IsMinus(pVector2,vector2) && Point.IsMinus(pVector3,vector3))
            {
                return true;
            }else
            {
                return false;
            }


        }

    }

    class Program
    {
        static void Main()
        {
            string str;
            double[] array;
            bool isPointCenter = false;
            while ((str = Console.ReadLine()) != null)
            {
                array = str.Split(' ').Select(double.Parse).ToArray();
                Triangle triangle = new Triangle(new Point(array[0], array[1]), new Point(array[2], array[3]), new Point(array[4], array[5]));
                Point p = new Point(array[6], array[7]);
                isPointCenter = Triangle.IsPointInTriange(triangle, p);
                if (isPointCenter)
                {
                    Console.WriteLine("YES");
                }else
                {
                    Console.WriteLine("NO");
                }
            }
        }
    }
}