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 <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){

    double x[4],y[4];
    while(true){
	REP(i,4) {
	    cin >> x[i] >> y[i];
	    if(cin.eof()) break;
	    //cin >> y[i];
	}
	double s,t;
	bool flg = false;
	REP(i,1e6){
	    s = ((double)i/1e6);
	    t = (double)1 - s;
	    double x1 = s * (x[2] - x[0]) + t * ( x[1] - x[0]);
	    double y1 = s * (y[2] - y[0]) + t * ( y[1] - y[0]);
	    double x2 = x[3] - x[0];
	    double y2 = y[3] - y[0];
	    double dotpro = (  (  (x1 * x2 + y1 * y2 )*(x1 * x2 + y1 * y2 ) )  /( (x1*x1 + y1*y1)*(x2*x2 + y2*y2))); 
	    //cout << dotpro << endl;
	    if(  1 - dotpro  <= 1e-3  ){
		    flg = true;
		    break;
	    }
	}
	if(flg) cout << "YES" << endl;
	else cout << "NO" << endl;

    }

    return 0;
}

C++: #include <iostream>
using namespace std;
double x[4],y[4],px,py,ax,ay,bx,by;
int main()
{
	while(true)
	{
		for(int i = 1;i<=3;i++){cin >> x[i];cin >> y[i];}
		if(cin.eof()){break;}
		cin >> px;
		cin >> py;
		double m,n;
		ax = x[2]-x[1];
		ay = y[2]-y[1];
		bx = x[3]-x[1];
		by = y[3]-y[1];
		double det = ax*by-ay*bx;
		m = (by*px-bx*py)/det;
		n = (-ay*px+ax*py)/det;
		if(m>0 && m < 1 && n > 0 && n < 1 && m+n < 1 ) {cout << "YES" ;}
		else {cout << "NO" ;}
		cout << endl;
	}
	return 0;
}

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

#define double long double

double T(double a[3]) {
	double res, sum;
	res = a[0] + a[1] + a[2];
	sum = res;
	for(int i = 0; i < 3; i++) {
		res *= sum - 2.0 * a[i];
	}
	return sqrt(res);
}

double dist(double ax, double ay, double bx, double by) {
	return sqrt((ax - bx) * (ax - bx) + (ay - by) * (ay - by));
}

int main() {
	while(1) {
		bool exit = false;
		double x[4], y[4];
		double d0[3], d1[3];
		for(int i = 0; i < 4; i++) {
			if(!(cin >> x[i] >> y[i]))
				exit = true;
		}
		if(exit)
			break;
		for(int i = 0; i < 3; i++) {
			d0[i] = dist(x[i], y[i], x[(i+1)%3], y[(i+1)%3]);
			d1[i] = dist(x[i], y[i], x[3], y[3]);
		}
		bool flg = true;
		double S0, S1;
		S0 = T(d0); S1 = 0;
		for(int i = 0; i < 3; i++) {
			double res;
			double tmp[3] = {d0[i], d1[i], d1[(i+1)%3]};
			/*
			   for(int i = 0; i < 3; i++)
			   cout << tmp[i] << " ";
			   cout << endl;
			   */
			res = T(tmp);
			if(res < 1e-16)
				flg = false;
			S1 += res;
		}
		//cout << S1 - S0 << endl;
		if(flg && fabs(S1 - S0) < 1e-16)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

double cross(double x1,double y1,double x2,double y2)
{
	return x1*y2-x2*y1;
}

int ccw(double x1,double y1,double x2,double y2,double x3,double y3)
{
	return cross(x2-x1,y2-y1,x3-x1,y3-y1)>0;
}

int main()
{
	//float x,y,a,b,n,m,p,q;
	//int i;
	//for(;~scanf("%f%f%f%f%f%f%f%f",&x,&y,&a,&b,&n,&m,&p,&q);puts(i>2^!i?"YES":"NO"))
	//	i=((p-x)*(b-y)>(q-y)*(a-x))+((p-a)*(m-b)>(q-b)*(n-a))+((p-n)*(y-m)>(q-m)*(x-n));
	
	for(double x,y,a,b,n,m,p,q;scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x,&y,&a,&b,&n,&m,&p,&q)==8;){
		int counter=0;
		//counter+=(p-x)*(b-y)-(q-y)*(a-x)>0;
		//counter+=(p-a)*(m-b)-(q-b)*(n-a)>0;
		//counter+=(p-n)*(y-m)-(q-m)*(x-n)>0;
		counter+=cross(a-x,b-y,p-x,q-y)>0;
		counter+=cross(n-a,m-b,p-a,q-b)>0;
		counter+=cross(x-n,y-m,p-n,q-m)>0;
		
		cout<<(counter%3==0?"YES":"NO")<<endl;
	}
	
	return 0;
}

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

using namespace std;

struct Vector{
  double x,y;
  Vector operator-(const Vector &v)const{
    return Vector(x-v.x,y-v.y);
  }
  Vector():x(0),y(0){}
  Vector(const Vector &v):x(v.x),y(v.y){}
  Vector(double xx,double yy):x(xx),y(yy){}
  Vector& operator=(const Vector& v){
    x=v.x;
    y=v.y;
    return (*this);
  }
};

struct Triangle{
  Vector v[3];
};

double outerprod(const Vector &v1,const Vector &v2);
bool is_in(const Triangle&,const Vector&);
int main(){
  Vector v;
  Triangle t;
  while(std::cin>>t.v[0].x>>t.v[0].y>>t.v[1].x>>t.v[1].y>>t.v[2].x>>t.v[2].y>>v.x>>v.y){
     if(is_in(t,v)){
       std::cout<<"YES"<<std::endl;
     }else{
       std::cout<<"NO"<<std::endl;
     }
  }
  return 0;
}

double outerprod(const Vector &v1,const Vector &v2){
  return v1.x*v2.y-v2.x*v1.y;
}

bool is_in(const Triangle& t,const Vector& v){
  double prod1 = outerprod(t.v[1]-t.v[0],v-t.v[1]);
  double prod2 = outerprod(t.v[2]-t.v[1],v-t.v[2]);
  double prod3 = outerprod(t.v[0]-t.v[2],v-t.v[0]);
  return (prod1<0&&prod2<0&&prod3<0)||(prod1>0&&prod2>0&&prod3>0);
}

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

int check( double x0, double y0, double x1, double y1, double x2, double y2 ){
	return (x1-x0)*(y2-y0)-(y1-y0)*(x2-x0) > 0 ? 1 : -1; 
}

int main(){
	double x[3], y[3], xp, yp;
	while( scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x[0],&y[0],&x[1],&y[1],&x[2],&y[2],&xp,&yp) != EOF ){
		int ch = check( x[0], y[0], x[1], y[1], xp, yp );
		ch += check( x[1], y[1], x[2], y[2], xp, yp );
		ch += check( x[2], y[2], x[0], y[0], xp, yp );
		if( ch==3 || ch==-3 ){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){

    double x[4],y[4];
    while(true){
	REP(i,4) {
	    cin >> x[i];
	    if(cin.eof()) return 0;
	    cin >> y[i];
	}
	double s,t;
	double m = 0;
	bool flg = false;
	REP(i,1e6){
	    s = ((double)i/1e6);
	    t = (double)1 - s;
	    double x1 = s * (x[2] - x[0]) + t * ( x[1] - x[0]);
	    double y1 = s * (y[2] - y[0]) + t * ( y[1] - y[0]);
	    double x2 = x[3] - x[0];
	    double y2 = y[3] - y[0];
	    double dotpro =  (  (x1 * x2 + y1 * y2 )*(x1 * x2 + y1 * y2 ) )  /( (x1*x1 + y1*y1)*(x2*x2 + y2*y2)) ;

        if( (x2 * x2 + y2 * y2) >= (x1*x1 + y1 * y1)) continue;
	    if(  abs(1 - sqrt(dotpro))  <= 1e-3  ){
	
		    flg = true;
		    break;
	    }
	}
	if(flg) cout << "YES" << endl;
	else cout << "NO" << endl;

    }

    return 0;
}