Go: package main

import "fmt"

func main() {
	var x1, x2, x3, y1, y2, y3, xp, yp float64
	for {
		v, _ := fmt.Scanf("%f %f %f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp)
		// println(x1, x2, x3, y1, y2, y3, xp, yp)
		if v != 8 {
			break
		}
		ok1 := true
		ok2 := true
		if (x2-x1)*(yp-y1)-(xp-x1)*(y2-y1)<0 {
			ok1 = false
		} else {
			ok2 = false
		}
		if (x3-x2)*(yp-y2)-(xp-x2)*(y3-y2)<0 {
			ok1 = false
		} else {
			ok2 = false
		}
		if (x1-x3)*(yp-y3)-(xp-x3)*(y1-y3)<0 {
			ok1 = false
		} else {
			ok2 = false
		}
		if ok1 || ok2 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

C++: #include <iostream>
#include <complex>
#include <vector>
#include <cmath>
using namespace std;

int sign(double n){
	if(n < 0)return -1;
	else if(n > 0)return 1;
	return 0;
}

double angle(double ax, double ay, double bx, double by, double cx, double cy){
    //angle between ab and ac
    double ab = atan2(by-ay,bx-ax);
    double ac = atan2(cy-ay,cx-ax);
    if(ab < 0)ab += 2*M_PI;
    if(ac < 0)ac += 2*M_PI;
    double ang = ac - ab;
    return (fabs(ang) < M_PI ? ang : -sign(ang) * 2 * M_PI + ang) * 180 / M_PI;
}

bool isPointInPolygon(complex< double > a, vector< complex< double > > p){
	int n = p.size();
	double sum = 0;
	
	for(int i = 0; i < n; ++i){
		sum += angle(a.real(), a.imag(), p[i].real(), p[i].imag(), p[(i+1)%n].real(), p[(i+1)%n].imag());
	}
	
	if(abs(sum) >= 300){ //if sum is 360
		return true;
	}
	return false; //if sum is 0
}

int main(){
	double x1, y1, x2, y2, x3, y3 , xp, yp;
	vector< complex< double > > triangle;
	complex< double > point;
	
	while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp){
		point = complex< double >(xp, yp);
		triangle.push_back(complex< double >(x1, y1));
		triangle.push_back(complex< double >(x2, y2));
		triangle.push_back(complex< double >(x3, y3));
		
		if(isPointInPolygon(point, triangle))
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
}

C++: #include <iostream>
using namespace std;

int main(){
	double x1,y1,x2,y2,x3,y3,xp,yp;
	cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp;

	while(!cin.eof()){
		int sign1=(((x2-x1)*(yp-y1)-(xp-x1)*(y2-y1))>0)?1:0;
		int sign2=(((x3-x2)*(yp-y2)-(xp-x2)*(y3-y2))>0)?1:0;
		int sign3=(((x1-x3)*(yp-y3)-(xp-x3)*(y1-y3))>0)?1:0;
		//cout << sign1 << sign2 << sign3;
		if(sign1==sign2 && sign2==sign3)
			cout << "YES\n";
		else
			cout << "NO\n";

		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp;

	}
}

C++: #include <iostream>
#include <cmath>

using namespace std;

double distance(double x1, double y1, double x2, double y2)
{
	return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
}

double helon(double a, double b, double c)
{
	double s = (a + b + c) / 2;

	return sqrt(s * (s - a) * (s - b) * (s - c));
}

double helon(double x1, double y1, double x2, double y2, double x3, double y3)
{
	double a = distance(x1, y1, x2, y2);
	double b = distance(x2, y2, x3, y3);
	double c = distance(x3, y3, x1, y1);

	return helon(a, b, c);
}

int main()
{
	double x1, y1, x2, y2, x3, y3, xp, yp;

	while ( cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
		if (round(helon(x1, y1, x2, y2, x3, y3)*100) == round((helon(x1, y1, x2, y2, xp, yp) + helon(x2, y2, x3, y3, xp, yp) + helon(x3, y3, x1, y1, xp, yp)) *100)) {
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

double dot(P a, P b) {
    return (a.X * b.X + a.Y * b.Y);
}
double cross(P a, P b) {
    return (a.X * b.Y - a.Y * b.X);
}

int ccw(P a, P b, P c) {
    b -= a; c -= a;
    if( cross(b,c) > EPS ) return +1;
    if( cross(b,c) < -EPS ) return -1;
    if( dot(b,c) < 0 ) return +2;
    if( norm(b) < norm(c) ) return -2;
    return 0;
}

int main() {
    P a,b,c,d;
    while(cin >> a.X >> a.Y >> b.X >> b.Y >> c.X >> c.Y >> d.X >> d.Y) {
        int x = ccw(a,b,d);
        int y = ccw(b,c,d);
        int z = ccw(c,a,d);
        printf("%d %d %d\n", x, y, z);
        if(x == 1 && y == 1 && z == 1) cout << "YES" << endl;
        else if(x == -1 && y == -1 && z == -1) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <complex>
#include <cmath>
using namespace std;
typedef complex<double> xy_t;

double cross_product(xy_t a, xy_t b) {
  return (conj(a) * b).imag();
}

double x[4], y[4];
int main() {
  while (1) {
    for (int i = 0; i < 4; i++) cin >> x[i] >> y[i];
    if (!cin) break;
    xy_t a(x[0], y[0]), b(x[1], y[1]), c(x[2], y[2]), p(x[3], y[3]);
    double pab = cross_product(a-p, b-p);
    double pbc = cross_product(b-p, c-p);
    double pca = cross_product(c-p, a-p);
    bool ok = (pab * pbc >= 0 && pab * pca >= 0);
    cout << (ok ? "YES" : "NO") << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <complex>
#include <cmath>
using namespace std;
typedef complex<double> xy_t;
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }
 
double x[4], y[4];
int main() {
  while (true) {
    for (int i=0; i<4; ++i) cin >> x[i] >> y[i];
    if (!cin) break;
 
    xy_t a(x[0],y[0]), b(x[1],y[1]), c(x[2],y[2]), p(x[3],y[3]);
    bool tri1 = cross_product(a-p,b-p) > 0;
    bool tri2 = cross_product(b-p,c-p) > 0;
    bool tri3 = cross_product(c-p,a-p) > 0;
 
    bool tri4 = cross_product(a-p,b-p) < 0;
    bool tri5 = cross_product(b-p,c-p) < 0;
    bool tri6 = cross_product(c-p,a-p) < 0;
 
    bool ok = tri1*tri2*tri3;
    if (ok != 1) ok = tri4*tri5*tri6;
 
    cout << (ok ? "YES" : "NO") << endl;
  }
}

C++: #include <iostream>
#include <cmath>
using namespace std;
//#define debug

class Triangle{
	float m_x[3],m_y[3],m_xp,m_yp;
	float m_vx[3],m_vy[3];//点Pからの相対座標
	float m_nv1,m_nv2, m_rot,m_rot_sum,m_cos_sita;
	int m_p1,m_p2;
	bool m_pointIsSetted;
public:
	Triangle(){m_pointIsSetted=false;m_rot_sum=0;}
	void setPoint(float x1, float y1, float x2, float y2, float x3, float y3){
		m_x[0]=x1; m_y[0]=y1;
		m_x[1]=x2; m_y[1]=y2;
		m_x[2]=x3; m_y[2]=y3;
		m_pointIsSetted=true;
	}
	bool isPointIn(float xp,float yp){
		m_xp=xp;m_yp=yp;

		//点Pからの相対座標の計算
		for(int i=0;i<3;++i){
			m_vx[i]=m_x[i]-xp;
			m_vy[i]=m_y[i]-yp;
		}

		m_rot_sum = 0;
		for(int i=0;i<3;++i){
			m_p1=i;
			if(i==2)m_p2=0; else m_p2=i+1;
			m_nv1=sqrt(pow(m_vx[m_p1],2.0)+pow(m_vy[m_p1],2.0));
			m_nv2=sqrt(pow(m_vx[m_p2],2.0)+pow(m_vy[m_p2],2.0));

			m_cos_sita = (m_vx[m_p1]*m_vx[m_p2]+m_vy[m_p1]*m_vy[m_p2]) / (m_nv1*m_nv2);
			m_rot = acos( m_cos_sita );
			if(m_cos_sita<0){m_rot=-m_rot;}
			m_rot_sum += m_rot;
#ifdef debug
			cout<<m_p1<<"  "<<m_p2<<endl;
			cout<<"cos_sita: "<<m_cos_sita<<endl;
			cout<<"sita: "<<m_rot<<endl;
			cout<<"sum of rot: "<<m_rot_sum<<endl;
#endif
		}

		if(abs(m_rot_sum)>6.0){return true;}else{return false;}

	}
};

int main(){

	float x1,y1,x2,y2,x3,y3,xp,yp;
	Triangle oTri;

	while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>xp>>yp){
		oTri.setPoint(x1,y1,x2,y2,x3,y3);
		if(oTri.isPointIn(xp,yp)){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}


	}
	return 0;
}