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)
		}
		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<stdio.h>

int main()
{
	int n,x;
	double x1,y1,x2,y2,x3,y3,x4,y4,p,q;

	scanf("%d",&n);
	for(x=0;x<n;x++)
	{
		for(;;)
		{
			scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
			if(x1>100||y1>100||x2>100||y2>100||x3>100||y3>100||x4>100||y4>100)
			{
			}
			else if(x1<-100||y1<-100||x2<-100||y2<-100||x3<-100||y3<-100||x4<-100||y4<-100)
			{
			}
			else
			{
				break;
			}
		}

		x2-=x1;
		y2-=y1;
		x1=0;
		y1=0;
		x4-=x3;
		y4-=y3;
		x3=0;
		y3=0;

		p=x2/y2;
		q=x4/y4;

		if(p==q)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

struct Vector {
  double x, y;
  Vector() {}
  Vector(double x, double y): x(x), y(y) {}
  Vector operator+(Vector v) { return Vector(x + v.x, y + v.y); }
  Vector operator-(Vector v) { return Vector(x - v.x, y - v.y); }
  Vector operator*(double k) { return Vector(x * k, y * k); }
  Vector operator/(double k) { return Vector(x / k, y / k); }
  bool operator==(Vector v)  { return abs(x - v.x) < 1e-10 && abs(y - v.y) < 1e-10; }
  friend void input(Vector &v) { cin >> v.x >> v.y; }
  friend double norm(Vector v) { return dot(v, v); }
  friend double  abs(Vector v) { return sqrt(norm(v)); }
  friend double   dot(Vector v1, Vector v2) { return v1.x * v2.x + v1.y * v2.y; }
  friend double cross(Vector v1, Vector v2) { return v1.x * v2.y - v1.y * v2.x; }
  friend void show(Vector v) { if (abs(v.x) < 1e-10) v.x = 0.0; if (abs(v.y) < 1e-10) v.y = 0.0; printf("%.10f %.10f\n", v.x, v.y); }
  friend bool ccw(Vector v, Vector v1, Vector v2) { return cross(v1 - v, v2 - v) > 1e-10; }
  friend bool  cw(Vector v, Vector v1, Vector v2) { return cross(v1 - v, v2 - v) < -1e-10; }
  friend bool parallel(Vector v1, Vector v2) { return abs(cross(v1, v2)) < 1e-10; }
  friend bool onLine(Vector v, Vector v1, Vector v2) { return v == v1 || v == v2 || (parallel(v1 - v, v2 - v) && dot(v1 - v, v2 - v) < -1e-10); }
  friend int direct(Vector v1, Vector v2, Vector v) { if (ccw(v1, v2, v)) return  1; if ( cw(v1, v2, v)) return -1; if (dot(v2 - v1, v - v1) < -1e-10) return  2; if (dot(v1 - v2, v - v2) < -1e-10) return -2; return 0; }
};
typedef Vector Point;

int main(void) {
  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    Point p[4];
    for (int j = 0; j < 4; j++) {
      input(p[j]);
    }
    cout << (parallel(p[0] - p[1], p[2] - p[3]) ? "YES" : "NO") << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;
#define EPS 1e-6
int main()
{
//	cut here before submit 
//	freopen("testcase.pl", "r", stdin);
	string str = "";
	int n;

	getline (cin, str );
	stringstream ssn(str);
	ssn >> n;

	int i,j;
	for (i = 0; i < n; ++i){
		vector <double> px (4, 0.0);
		vector <double> py (4, 0.0);
		getline (cin, str );
		stringstream ss(str);
		for (j = 0; j < 4; ++j){
			ss >> px[j] >> py[j];
		} // end for
		multimap <double, double> v;

		for (j = 0; j < 2; ++j){
			v.insert (make_pair (px[2*j + 1] - px[2*j], py[2*j + 1] - py[2*j] ) );
		} // end for

		multimap <double, double>::iterator it = v.begin();
		double xp = (*it).first;
		double yp = (*it).second;
		++it;		
		double xa = (*it).first;
		double ya = (*it).second;
		bool found = false;

		if (fabs(xp) >= EPS && fabs(yp) >= EPS){
			if ( fabs( (*it).first/xp - (*it).second/yp ) < EPS ){
				found = true;
			}else{
				found = false;
			} // end if
		}else{	// if (xp == 0. || yp == 0. )
			if (fabs(xp) < EPS && fabs(yp) >= EPS ){ // xp == 0. && yp != 0.
				if (fabs(xa) < EPS){
					found = true;
				}else{
					found = false;
				} // end if
			}else if (fabs(xp) >= EPS && fabs(yp) < EPS){ // xp != 0. && yp == 0.
				if (fabs(ya) < EPS){
					found = true;
				}else{
					found = false;
				} // end if
			}else{ // if (xp == 0. && yp == 0.)
				if (fabs(xa) < EPS && fabs(ya) < EPS){
					found = true;
				}else{
					found = false;
				} // end if
			} // end if
		} // end if

		if (found ){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		} // end if

	} // end for
		
	return 0;
}

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

int main(){
	double x1,x2,x3,x4,y1,y2,y3,y4;
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
			scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
		if( ((y1-y2)==0&&(y3-y4)!=0&&(x1-x2)==0&&(x3-x4)!=0) || ((x1-x2)!=0&&(x3-x4)==0&&(y1-y2)==0&&(y3-y4)!=0)){
			
				printf("NO\n");
		}
			else if((y1-y2)*(x3-x4)==(x1-x2)*(y3-y4)){
				printf("YES\n");
			}
			else{
				printf("NO\n");
			}
		}
	
	return 0;
}

C++: #include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int n;cin>>n;
	for(;n--;)
	{
		double a,b,c,d,e,f,g,h;cin>>a>>b>>c>>d>>e>>f>>g>>h;
		cout<<(fabs((d-b)*(g-e)-(h-f)*(c-a))<1e-8?"YES":"NO")<<endl;
	}
}

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

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int n;
double x[100], y[100];

int main(){
	cin >> n;
	REP(i, n){
		REP(i, 4) cin >> x[i] >> y[i];
		if ((x[0] - x[1])*(y[2] - y[3]) == (x[2] - x[3])*(y[0] - y[1])){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
}