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[1] == fpoints[3] {
			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 <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <math.h>
#include <functional>
#include <algorithm>

typedef long long Int;
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
using namespace std;

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

	REP(i, n){

		double p[8];
		REP(i, 8){
			cin >> p[i];
		}

		double q1 = (p[1] - p[3]) / (p[0] - p[2]);
		double q2 = (p[5] - p[7]) / (p[4] - p[6]);
		string ans = (q1 == q2) ? "YES" : "NO";


		cout << ans << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int n,i;
	double x1, y1, x2, y2, x3, y3, x4, y4,a,b;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		if (x1 - x2 == 0 && x3 - x4 == 0) {
			cout << "YES" << endl;
		}
		else if (x1 - x2 == 0 && x3 - x4 != 0) {
			cout << "NO" << endl;
		}
		else if (x1 - x2 != 0 && x3 - x4 == 0) {
			cout << "NO" << endl;
		}
		else {
			a = (y1 - y2) / (x1 - x2);
			b = (y3 - y4) / (x3 - x4);
			if (a == b) {
				cout << "YES" << endl;
			}
			else if(a != b) {
				cout << "NO" << endl;
			}
		}
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)

typedef double D;
typedef complex<D> P;
typedef pair<P, P> L;
typedef vector<P> VP;
const D EPS = 1e-9;
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

D dot(P a, P b) {
  return (conj(a)*b).X;
}

D cross(P a, P b) {
  return (a.X*b.Y-a.Y*b.X);
}

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;
    P a, b, c, d;
    a = P(x1, y1);
    b = P(x2, y2);
    c = P(x3, y3);
    d = P(x4, y4);
    if (EQ(cross(a-b, c-d), 0.0)) {
      std::cout << "YES" << std::endl;
    }else {
      std::cout << "NO" << std::endl;
    }
  }

}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#define rep(i,b,n) for(int i=b;i<n;i++)
#define Rrep(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)
using namespace std;
typedef complex<double> point;
typedef pair<int, int> paii;
typedef long long ll;
double cross(point va, point vb){
    return real(va) * imag(vb) - imag(va) * real(vb);
}
int is_parallel(point a1, point a2, point b1, point b2) {
  return EQ( cross(a1-a2, b1-b2), 0.0 );
}
int main(){
    int n;
    cin >> n;
    rep(i, 0, n){
        double x, y;
        point pt[4];
        rep(j, 0, 4){
            cin >> x >> y;
            pt[j] = point(x, y);
        }
        if( is_parallel(pt[0], pt[1], pt[2], pt[3]) )
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
}

C++: #include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

#define vcitr vector<int>::iterator
#define vcsitr vector<string>::iterator
#define mapcitr map<char, int>::iterator
#define mapsitr map<string, int>::iterator

typedef long long ll;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }

struct Point2D { 
	double x, y;
	Point2D (double a=0, double b=0) { x=a; y=b; }
};

int main() {
	int n; cin >> n;
	
	for (int i=0; i<n; i++) {
		Point2D a, b, c, d;
		
		cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y >> d.x >> d.y;
		
		double p = (a.y-b.y)/(a.x-b.x), q = (c.y-d.y)/(c.x-d.x);
		
		if (p==q) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	
	return 0;
}

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

int main() {
	int n;
	float x[4],y[4];
	float slope1,slope2;
	
	cin >> n;
	for ( int i = 0; i < n; i++ ) {
		for ( int j = 0; j < 4; j++ )
			cin >> x[j] >> y[j];
		slope1 = (y[1] - y[0]) / (x[1] - x[0]);
		slope2 = (y[3] - y[2]) / (x[3] - x[2]);
		if ( slope1 == slope2 )
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
}

C++: #include<iostream>
#include<cmath>
#include<algorithm>

using namespace std;

double ESP = 1e-10;

struct point {
  double x, y;
};

int main() {
  int n;
  point P[4];

  cin >> n;
  while(n--){
    for(int i = 0; i < 4; i++){
      cin >> P[i].x >> P[i].y;
    }

    if(abs((P[1].y - P[0].y)*(P[3].x - P[2].x) - (P[3].y - P[2].y)*(P[1].x - P[0].x)) < ESP) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }

    return 0;
}

C++: ans :: [Double] -> String
ans (x1:y1:x2:y2:x3:y3:x4:y4:_)
  | (y2 == y1) && (x2 == x1) = "NO"
  | (y4 == y3) && (x4 == x3) = "NO"
  | y2 == y1  = if y4 == y3 then "YES" else "NO"
  | x4 == x3  = if x2 == x1 then "YES" else "NO"
  | otherwise = if (y2-y1) * (x4-x3) == (y4-y3) * (x2-x1)
                then "YES"
                else "NO"

main = do
  c <- getContents
  let i = map (map read) $ map words $ drop 1 $ lines c :: [[Double]]
      o = map ans i
  mapM_ putStrLn o

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#define range(s,n) for(int i = s; i < n; i++)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

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

	while(cin >> n){
		range(0,n){
			cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
			if(  (y1-y2)/(x1-x2)==(y3-y4)/(x3-x4))
				cout << "YES" << endl;
			else
				cout << "NO" << endl;
		}
	}
}

C++: #include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int main(){
	int n;
	float x1,x2,x3,x4;
	float y1,y2,y3,y4;
	float a1,a2;
	
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%f%f%f%f%f%f%f%f",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
		a1 = (y2-y1)/(x2-x1);
		a2 = (y4-y3)/(x4-x3);
		if(a1==a2)
		printf("YES\n");
		else
		printf("NO\n");
	}
}