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 Point{
  double x, y;
  Point(){ x = 0; y = 0; }
  Point(double x_, double y_){ x = x_; y = y_; }
};

struct Segment{
  Point a, b;
  Segment(): a(), b(){}
  Segment(Point a_, Point b_){ a = a_; b = b_; }
};

static double ER = 1.0e-8;

bool isZero(double x){
  return (abs(x) < ER);
}

bool isEqual(double x, double y){
  return isZero(x - y);
}

int isIntersection_ss(const Segment& ab, const Segment& cd){
  double m = (ab.b.x - ab.a.x)*(cd.b.y - cd.a.y)
    - (ab.b.y - ab.a.y)*(cd.b.x - cd.a.x);
  if(isZero(m)) return false;
  double r = ((cd.a.x - ab.a.x)*(cd.b.y - cd.a.y)
              - (cd.a.y - ab.a.y)*(cd.b.x - cd.a.x)) / m;
  double s = ((cd.a.x - ab.a.x)*(ab.b.y - ab.a.y)
              - (cd.a.y - ab.a.y)*(ab.b.x - ab.a.x)) / m;
  if(r < 0 || r > 1 || s < 0 || s > 1)  return true;
  return false;
}

bool isPointInnerTriangle(const Point& a, const Point& b,
			  const Point& c, const Point& p){
  if(isEqual((a.x - c.x)*(a.y - b.y), (a.x - b.x)*(a.y - c.y))) return false;
  return isIntersection_ss(Segment(a, b), Segment(c, p)) &&
    isIntersection_ss(Segment(b, c), Segment(a, p)) &&
    isIntersection_ss(Segment(c, a), Segment(b, p));
}

int main(){
  Point a, b, c, p;
  while(cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y >> p.x >> p.y){
    if(isPointInnerTriangle(a, b, c, p)) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  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)) ;

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

	cout << "max = " << m << endl;
    }

    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;
}

C++: #include<iostream>
#include<cstdlib>
#include<stdio.h>
using namespace std;

int main()
{
 double x1, y1, x2, y2, x3, y3, xp, yp, a, b, c;
 while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp)
 {
     a = (x2-x1)*(yp-y1)-(y2-y1)*(xp-x1);
     b = (x3-x2)*(yp-y2)-(y3-y2)*(xp-x2);
     c = (x1-x3)*(yp-y3)-(y1-y3)*(xp-x3);
     
     if((a>0 && b>0 && c>0)||(a<0 && b<0 && c<0))
         cout<<"YES"<<endl;
     else
         cout<<"NO"<<endl;
 }
 return 0;
}

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

using namespace std;

vector<double> simlu_eq(int N, vector<vector<double>> M){
    int i, j, k, n;
    double pivot, mul;
    
    for (i = 0; i < N; ++i){
        pivot = M[i][i];
        for (j = 0; j < N + 1; ++j){
            M[i][j] = (1 / pivot) * M[i][j];
        }
        
        
        for (k = i + 1; k < N; ++k){
            mul = M[k][i];
            for (n = i; n < N + 1; ++n){
                M[k][n] = M[k][n] - mul * M[i][n];
            }
        }
    }
    
    // for (auto x:M){for(auto y:x){ cout << y << " ";}cout << endl;}

        
     for (i = N -1; i > 0; --i){
         for (k = i -1; k >= 0; --k){
             mul = M[k][i];
             for (n = i; n < N + 1; ++n){
                 M[k][n] = M[k][n] - mul * M[i][n];
             }
         }
     }
      
    // for (auto x:M){for(auto y:x){ cout << y << " ";}cout << endl;}
  
      
    vector<double> res;
    for (i = 0; i < N; ++i){
        res.push_back(M[i][N]);
    }
    return res;
}


int main(){
    vector<double> a(2), b(2), c(2), p(2), ab(2), ac(2);
    while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &a[0], &a[1], &b[0], &b[1], &c[0], &c[1], &p[0], &p[1])+1){
        ab[0] = b[0] - a[0];
        ab[1] = b[1] - a[1];
        ac[0] = c[0] - a[0];
        ac[1] = c[1] - a[1];
 
    
    vector<vector<double>>M;
    M = vector<vector<double>>(2, vector<double>(3));
    M[0][0] = ab[0];  M[0][1] = ac[0];  M[0][2] = p[0];
    M[1][0] = ab[1];  M[1][1] = ac[1];  M[1][2] = p[1];
    vector<double> w = simlu_eq(2, M);
    
    if (w[0] > 0 && w[1] > 0 && w[0] + w[1] < 1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    }
}

C++: #include <iostream>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    double x[3], y[3];
    double xp, yp;
    double ax, ay, bx, by;
    while (cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> xp >> yp) {
        string res = "YES";
        for (int i=0; i<3; ++i) {
            ax = x[(i+1)%3] - x[i];
            ay = y[(i+1)%3] - y[i];
            bx = xp - x[i];
            by = yp - y[i];
            if (ax * by - ay * bx < 0) {
                res = "NO";
            }
        }
        cout << res << "\n";
    }
    return 0;
}

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

int main()
{
	double x1, x2, x3, y1, y2, y3, xp, yp;
	while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp){
		vector<bool> vec(3, true);
		if (x1 * y2 - y1 * x2 < 0) vec[0] = false;
		if (x2 * y3 - y2 * x3 < 0) vec[1] = false;
		if (x3 * y1 - y3 * x1 < 0) vec[2] = false;
		if (vec[0] * vec[1] * vec[2] || !(vec[0] + vec[1] + vec[2])) cout << "YES\n";
		else cout << "NO\n";
	}
	cout.flush();
}

C++: #include <stdio.h>
int main(){
	float d,e,f,g,h,i,m,n,x;
	for(;~scanf("%f%f%f%f%f%f%f%f",&d,&e,&f,&g,&h,&i,&m,&n);){
		x=(h-f)*(n-g)-(m-f)*(i-g);
		bool ret=x*(f-d)*(n-e)>x*(m-d)*(g-e)&&x*(d-h)*(n-i)>x*(m-h)*(e-i);
		puts(ret?"YES":"NO");
	}
}