Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n := nextInt()
	for i := 0; i < n; i++ {
		scanner.Scan()
		points := strings.Split(scanner.Text(), " ")
		fpoints := make([]float64, 0)
		for _, v := range points {
			tmp, _ := strconv.ParseFloat(v, 64)
			fpoints = append(fpoints, tmp)
		}
		if fpoints[0] == fpoints[2] && fpoints[4] == fpoints[6] {
			fmt.Println("YES")
			continue
		}
		a := (fpoints[1]-fpoints[3])/(fpoints[0]-fpoints[2])
		b := (fpoints[5]-fpoints[7])/(fpoints[4]-fpoints[6])
		if a == b {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define EPS 1e-9
#define PI 3.141592653589793238462643383279

using namespace std;

template<class T>
struct point{
	T x, y;
	point &operator+=(const point &a ){ x += a.x; y += a.y; }
	point &operator-=(const point &a ){ x -= a.x; y -= a.y; }
	point operator+(const point &a ){ return (point){x+a.x, y+a.y }; }
	point operator-(const point &a ){ return (point){x-a.x, y-a.y }; }
	operator point<double>()const{ return (point<double>){x, y }; }
};

template<class T>
point<T> operator*(T c, const point<T> &a ){ return (point<T>){c*a.x, c*a.y }; }
point<double> &operator/=(point<double> &a, double c ){ a.x /= c; a.y /= c; return a; }
template<class T>
point<double> operator/(const point<T> &a, double c ){ return (point<double>){ a.x/c, a.y/c }; }

// for integar number
template<class T>
bool operator<(const point<T> &a, const point<T> &b ){
	return (a.x < b.x || ((a.x == b.x ) && (a.y < b.y ) ) );
}

template<class T>
bool operator==(const point<T> &a, const point<T> &b ){
	return a.x == b.x && a.y == b.y;
} 

template<class T>
bool operator!=(const point<T> &a, const point<T> &b ){
	return a.x != b.x || a.y != b.y;
}

//  for real number
bool operator<(const point<double> &a, const point<double> &b ){
	return (a.x + EPS < b.x || (abs (a.x - b.x ) < EPS && (a.y + EPS < b.y ) ) );
}

bool operator==(const point<double> &a, const point<double> &b ){
	return abs (a.x - b.x) < EPS && abs (a.y - b.y ) < EPS;
}

bool operator!=(const point<double> &a, const point<double> &b ){
	return abs (a.x - b.x ) > EPS || abs (a.y - b.y ) > EPS;
}

// inner product
template<class T>
T dot(const point<T> &a, const point<T> &b ){ return a.x*b.x + a.y*b.y; }

// outer product
template<class T>
T cross(const point<T> &a, const point<T> &b ){ return a.x*b.y - a.y*b.x; }

// distance betwwen origin(0,0) to point a
template<class T>
double abs(const point<T> &a ){ return sqrt (a.x*a.x + a.y*a.y ); }

template<class T>
T abs2(const point<T> &a ){ return a.x*a.x + a.y*a.y; }

point<double> rot(const point<double> &a, double theta ){
	return (point<double>){a.x*cos(theta) - a.y*sin(theta), a.x*sin(theta) + a.y*cos(theta ) };
}

// x 軸の正方向を基準とした場合のベクトル a の角度を [0, 2*PI) の範囲で求める
template<class T> double arg(const point<T> &a ){
	double t = atan2(a.y, a.x );
	return t<0.? t+2.*PI : t;
}

template<class T>
struct line{
	point<T> a, b;
	operator line<double>()const{ return (line<double>){a, b}; }
};

template<class T>
struct segment{
	point<T> a, b;
	operator line<T>()const { return (line<T>){a,b}; }
};

template<class T>
struct polygon:vector< point<T> >{
	polygon(){}
	polygon(int n ):vector< point<T> >(n){}
};

template<class T>
struct circle{
	point<T> c;
	T r;
};

// 点 p を直線 L 上に射影した点を求める
template<class T>
point<double> proj(const point<T> &p, const line<T> &L ){
	return L.a + dot(p-L.a, L.b-L.a)/abs2(L.b-L.a)*(L.b-L.a);
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.0021", "r", stdin );
	int n;
	scanf ("%d", &n );
	rep (t, n ){
		point<double> v1, v2;
		double x[4], y[4];
		rep (i, 4 ) scanf ("%lf %lf", &x[i], &y[i] );
		v1.x = x[1] - x[0], v1.y = y[1] - y[0];
		v2.x = x[3] - x[2], v2.y = y[3] - y[2];
		double res = cross (v1, v2 );
		if (abs (res ) < EPS ){
			printf ("YES\n" );
		}else{
			printf ("NO\n" );
		} // end if		
	} // end loop
		
	return 0;
}

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

#include <algorithm>
#include <string>
using namespace std;

int main()
{
    double a,s,d,f,g,h,j,k;
    double q,w,e,r;
        int n;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>a>>s>>d>>f>>g>>h>>j>>k;
        q=d-a;
    w=f-s;
    e=j-g;
    r=k-h;
        if(q*r==w*e)cout<<"YES"<<endl;
        else  cout<<"NO"<<endl;
    }
    return 0;
}

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

int main(){
  int n, i;
  double x1, x2, x3, x4, y1, y2, y3, y4, slopeofAB, slopeofCD;

  cin >> n;

  for(i = 0; i < n; i++){
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;

    slopeofAB = (y2 - y1) / (x2 - x1);
    slopeofCD = (y4 - y3) / (x4 - x3);

    if(slopeofAB == slopeofCD){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }

  return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>

using namespace std;
int main(){
	int n;
	cin >> n;
	for(int i = 0;i < n;i++){
		double x1,y1,x2,y2,x3,y3,x4,y4;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;

		
		if((x2 - x1)*(y4 - y3) - (x4 - x3)*(y2 - y1) > 0.00000001){
			cout << "NO" << endl;
		}
		else{
			cout << "YES" << endl;
		}

	}
	return 0;
}

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

using namespace std;
typedef pair<double, double> P;

void solve()
{
	int n;
	while(cin >> n)
	{
		while(n--)
		{
			vector<P> p(4);
			for(int i = 0; i < 4; ++i)
			{
				cin >> p[i].first >> p[i].second;
			}
			if(p[0].first == p[1].first && p[0].second == p[1].second || p[2].first == p[3].first && p[2].second == p[3].second)
			{
				cout << "NO" << endl;
			}
			else if(p[0].first == p[1].first && p[2].first != p[3].first || p[0].first != p[1].first && p[2].first == p[3].first)
			{
				cout << "NO" << endl;
			}
			else if((p[1].second - p[0].second) / (p[1].first - p[0].first) == (p[3].second - p[2].second) / (p[3].first - p[2].first))
			{
				cout << "YES" << endl;
			}
		}
	}
}

int main()
{
	solve();
	return(0);
}