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-8

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

/*
	この解答は、どうやら誤差死。
	長さを求める平方根と
	掛け算とで誤差が出る模様。
	
	double の計算のときには
	如何に計算しないかがカギ。
*/

double dot (double xa, double ya, double xb, double yb )
{
	return (xa*xb + ya*yb );
}

double calc_len (double x, double y )
{
	return (x*x + y*y );
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.Parallelism", "r", stdin );
	int n;
	scanf ("%d", &n );
	rep (i, n ){
		double x1, y1, x2, y2, x3, y3, x4, y4;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		double d = dot (x2-x1, y2-y1, x4-x3, y4-y3 );
		double len1 = calc_len (x2-x1, y2-y1 );
		double len2 = calc_len (x4-x3, y4-y3 );

		if (fabs (len1*len2 - fabs(d*d ) ) < EPS ){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		} // end if
	} // end loop
		
	return 0;
}

C++: #include <algorithm>
#include <deque>
#include <iostream>
#include <functional>

using namespace std;

int main()
{
	int i,num;
	float x[4],y[4];
	cin >> num;

	for ( i = 0 ; i< num; i++ ) {
		cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3];

		if( (x[0]-x[1])*(y[2]-y[3]) == (y[0]-y[1])*(x[2]-x[3]) ){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

typedef struct myvector{
  double x;
  double y;
}Vector;

Vector sub_vector(Vector& a, Vector& b)
{
  Vector ret;
  ret.x = b.x - a.x;
  ret.y = b.y - a.y;
  return ret;
}

double cross_product(Vector& a, Vector& b)
{
  return a.x * b.y - b.x * a.y;
}

int main()
{
  int n;
  Vector A, B, C, D;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y >> D.x >> D.y;
    Vector AB = sub_vector(A, B);
    Vector CD = sub_vector(C, D);
    if(int(cross_product(AB, CD)) == 0)
      cout << "YES" << endl;
    else 
      cout << "NO" << endl;
  }
}

C++: #include <iostream>

using namespace std;

class Vector2D {
  private:
    double x;
    double y;
  public:
    Vector2D(double, double);
    Vector2D operator - (Vector2D vec2) {
      double newX = this->x - vec2.x;
      double newY = this->y - vec2.y;
      Vector2D newvec(newX, newY);
      return newvec;
    }
    double GetX() { return x; };
    double GetY() { return y; };
};

Vector2D::Vector2D(double _x, double _y) {
  x = _x;
  y = _y;
}

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

  double x1,y1,x2,y2,x3,y3,x4,y4;
  for (int dataset_i = 0; dataset_i < n; dataset_i++) {
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
    Vector2D vecAB = Vector2D(x2,y2) - Vector2D(x1,y1);
    Vector2D vecCD = Vector2D(x4,y4) - Vector2D(x3,y3);
    if (vecAB.GetX() == 0 && vecCD.GetX() == 0)
      cout << "YES" << endl;
    else if (vecAB.GetY() == 0 && vecCD.GetY() == 0)
      cout << "YES" << endl;
    else if (vecCD.GetX()/vecAB.GetX() == vecCD.GetY()/vecCD.GetY())
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <climits>
#include <utility>

#define PRINT(STR) cout << STR << endl;
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()

typedef long long ll;

using namespace std;

int nextInt() { int n = -1; cin >> n; return n; }
double nextDouble() { double d = -1; cin >> d; return d; }
ll nextll() { ll n = -1; cin >> n; return n; }
string nextString() { string str; cin >> str; return str; }

int INF = 9999999;
double EPS = 1e-9;
// BEGIN //////////////////////////////////////////////////////////////


int main() {
	int N;
	scanf("%d", &N);
	double x1, y1, x2, y2, x3, y3, x4, y4;
	REP(i, N) {
		 scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);

		if (x2 - x1 < EPS || x4 - x3 < EPS) {
			if (y2 - y1 < EPS && y4 - y3 < EPS) {
				PRINT("YES");
			} else {
				PRINT("NO");
			}
		} else {
			if ((y2 - y1) / (x2 - x1) - (y4 - y3) / (x4 - x3) < EPS) {
				PRINT("YES");
			} else {
				PRINT("NO");
			}
		}
	}

	return 0;
}

// END   //////////////////////////////////////////////////////////////

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

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

C++: #include<stdio.h>
#include<math.h>

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

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

typedef struct vec{
    double x;
    double y;
}vec_s;

int main(void){
    int n = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        double Point[8];
        for(int j = 0; j < 8; j++){
            Point[j] = 0;
        }
        for(int j = 0; j < 8; j++){
            cin >> Point[j];
        }
        vec_s V0 = {Point[0], Point[1]};
        vec_s V1 = {Point[2], Point[3]};
        vec_s V2 = {Point[4], Point[5]};
        vec_s V3 = {Point[6], Point[7]};
        vec_s a = {(V0.x - V1.x), (V0.y - V1.y)};
	    vec_s b = {(V2.x - V3.x), (V2.y - V3.y)};
	    if ((a.x * b.y - a.y * b.x) == 0){
	    		cout << "YES" << endl;
	    	}
	    	else{
	    		cout << "NO" << endl;
	    	}
    }
}

C++: #include <iostream>

using namespace std;

int main()
{
	int n;
	double x[4], y[4];

	cin >> n;

	for(int i = 0; i < n; i++){
		cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3];

		if((x[1]-x[0] == 0 && x[3]-x[2] == 0) || (y[1]-y[0] == 0 && y[3]-y[2] == 0))
			cout << "YES" << endl;
		else if(((y[1]-y[0])/(x[1]-x[0])) == ((y[3]-y[2])/(x[3]-x[2])))
			cout << "YES" << endl;
		else 
			cout << "NO" << endl;
	}

	return 0;
}