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 <cmath>
using namespace std;

struct Vec2d{
  double x,y;
};

double cross(Vec2d &A, Vec2d &B){
  return A.x*B.y - A.y*B.x;
}

int main(void){
  double x1,y1,x2,y2,x3,y3,xp,yp;
  while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>xp>>yp){
	  Vec2d AB,AP,BC,BP,CA,CP;
	  AB.x = x2-x1; AB.y = y2-y1;
	  BC.x = x3-x2; BC.y = y3-y2;
	  CA.x = x1-x3; CA.y = y1-y3;
	  AP.x = xp-x1; AP.y = yp-y1;
	  BP.x = xp-x2; BP.y = yp-y2;
	  CP.x = xp-x3; CP.y = yp-y3;
	  if(cross(AB,AP)>0.0 && cross(BC,BP)>0.0 && cross(CA,CP)>0.0)
	  	cout<<"YES"<<endl;
	  else if(cross(AB,AP)<0.0 && cross(BC,BP)<0.0 && cross(CA,CP)<0.0){
	  	cout<<"YES"<<endl;
	  }else
	  	cout<<"NO"<<endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

typedef struct _Point {
	double x;
	double y;
} Point;

typedef struct _Line {
	Point a;
	Point b;
} Line;

typedef struct _Triangle {
	Point a;
	Point b;
	Point c;
} Triangle;

int side(Point p, Line l) {
	int n = p.x * (l.a.y - l.b.y) + l.a.x * (l.b.y - p.y) + l.b.x * (p.y - l.a.y);
	if (n > 0) return 1;
	else if (n < 0) return -1;
	else return 0;
}

bool pointInaTriangle(Point p, Triangle t) {
	Line ab, bc, ca;
	ab.a = t.a; ab.b = t.b;
	bc.a = t.b; bc.b = t.c;
	ca.a = t.c; ca.b = t.a;
	int pab = side(p, ab);
	int pbc = side(p, bc);
	int pca = side(p, ca);
	if (0 < pab && 0 < pbc && 0 < pca)
		return true;
	return false;
}

int main() {
	Triangle t;
	Point p;
	while (cin >> t.a.x >> t.a.y >> t.b.x >> t.b.y >> t.c.x >> t.c.y >> p.x >> p.y) {
		if (pointInaTriangle(p, t) == true)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <complex>
#define rep(i,n) for(int i=0; i<(n); i++)
#define EPS 1e-10
using namespace std;

typedef complex<double> cd;

double s(cd a, cd b){
  return double(a.real()*b.imag()-a.imag()*b.imag());
}

int main(){
  cd a[4];

  for(;;){
    rep(i,4){
      double x,y;
      if(!~scanf(" %lf %lf", &x,&y))
        return 0;
      a[i]=cd(x,y);
    }
    
    if((s(a[0]-a[3], a[1]-a[3]) > 0 && 
        s(a[1]-a[3], a[2]-a[3]) > 0 &&
        s(a[2]-a[3], a[1]-a[3]) > 0 ) ||
       (s(a[0]-a[3], a[1]-a[3]) < 0 && 
        s(a[1]-a[3], a[2]-a[3]) < 0 &&
        s(a[2]-a[3], a[1]-a[3]) < 0 ))
      printf("IN\n");
    else
      printf("OUT\n");
  }
  
  return 0;
}

C++: //#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
//#include <stdio.h>
//#include <stdlib.h>
//#include <iomanip>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <functional>
//#include <time.h>
//#include <sstream>
//#include <queue>

using namespace std;


int main(){

	double x[4],y[4],dx[3],dy[3],dpx[3],dpy[3];
	double th[3], pth[3];
	int check = 0;
	bool ans = true;


	while (	cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3]){
		if (x[1] == 0 && y[1] == 0){
			swap(x[0], x[1]);
			swap(y[0], y[1]);
		}
		if (x[2] == 0 && y[2] == 0){
			swap(x[0], x[2]);
			swap(y[0], y[2]);
		}
		if (atan2(y[1]-y[0], x[1]-x[0]) > atan2(y[2]-y[0], x[2]-x[0])){
			swap(x[1], x[2]);
			swap(y[1], y[2]);
		}

		for (int i = 0; i < 3; i++){
			dx[i] = x[(i + 1) % 3] - x[i];
			dy[i] = y[(i + 1) % 3] - y[i];
			dpx[i] = x[3] - x[i];
			dpy[i] = y[3] - y[i];
			th[i] = atan2(dy[i], dx[i]);
			pth[i] = atan2(dpy[i], dpx[i]);
		}

		for (int i = 0; i < 3; i++){
			if (sin(th[i] - pth[i])>0){
				ans = false;
				break;
			}
		}
		cout << (ans ? "YES" : "NO" )<< endl;
	}
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

#include <complex>
typedef complex<double> Point;
typedef vector<Point> Polygon;


double dot(Point a, Point b){
  return real(conj(a) * b);
}
double cross(Point a, Point b){
  return imag(conj(a) * b);
}

Point curr(const Polygon& a, int x){ return a[x]; }
Point next(const Polygon& a, int x){ return a[(x + 1) % a.size()]; }

int sign(double x){
  if(x > EPS) return 1;
  if(x < -EPS) return -1;
  return 0;
}

enum{OUT, ON, IN};
int contains(const Polygon& P, const Point& p){
  bool in = false;
  REP(i, P.size()){
    Point a = curr(P, i) - p;
    Point b = next(P, i) - p;
    if(a.imag() > b.imag()) swap(a, b);
    if(a.imag() <= 0 && 0 < b.imag() && sign(cross(a, b)) < 0){
      in = !in;
    }
    if(cross(a, b) == 0 && dot(a, b) <= 0) return ON;
  }
  return in ? IN : OUT;
}

int main(){
  while(true){
    Polygon P(3);
    REP(i, 3) cin >> P[i].real() >> P[i].imag();
    Point p;
    cin >> p.real() >> p.imag();
    p.imag() -= EPS / 2;
    if(cin.eof()) break;
    if(contains(P, p) == IN) cout << "YES" << endl;
    else if(contains(P, p) == OUT) cout << "NO" << endl;
    else if(contains(P, p) == ON) assert(false);
  }
  return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }


struct P{ double x, y; };
bool operator > (P x, P y)
{ return x.x > y.x || (x.x == y.x && x.y > y.x); }

double CalcArea(P a, P b, P c)
{
	double A = sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
	double B = sqrt(pow(b.x - c.x, 2.0) + pow(b.y - c.y, 2.0));
	double C = sqrt(pow(c.x - a.x, 2.0) + pow(c.y - a.y, 2.0));

	double s = (A + B + C) / 2;

	return sqrt(s * (s - A) * (s - B) * (s - C));
}


int main()
{
	while(true)
	{
		vector<P> v(4);

		rep(i, 4)
			if(!(cin >> v[i].x >> v[i].y))
				return 0;

		double s = CalcArea(v[0], v[1], v[2]), ss = CalcArea(v[0], v[1], v[3]) + CalcArea(v[0], v[3], v[2]) + CalcArea(v[3], v[1], v[2]);

		if(s - EPS <= ss && ss <= s + EPS)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
}