Go: package main

import (
        "fmt"
        "math/big"
)

func main() {
        var x1, x2, x3, x4, y1, y2, y3, y4 big.Float
        var n int
        fmt.Scanf("%d", &n)
        for i := 0; i < n; i++ {
                fmt.Scanf("%f %f %f %f %f %f %f %f",
                        &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4)
                var lx, ly, mx, my, mul1, mul2, sub, zz big.Float
                lx.Sub(&x2, &x1)
                ly.Sub(&y2, &y1)
                mx.Sub(&x4, &x3)
                my.Sub(&y4, &y3)
                mul1.Mul(&lx, &my)
                mul2.Mul(&ly, &mx)
                sub.Sub(&mul1, &mul2)
                zz.SetFloat64(0.0)

                if sub.Cmp(&zz) == 0 {
                        fmt.Println("YES")
                } else {
                        fmt.Println("NO")
                }
        }
}

C++: #include <bits/stdc++.h>
using namespace std;

#define REP(i, s, e) for(int i = (int)(s); i < (int)(e); ++i)
#define rep(i, n) REP(i, 0, n)

#define X real()
#define Y imag()

using D = double;
using P = complex<D>;

const D EPS = 1e-10;
namespace std {
  bool operator < (const P& a, const P& b) {
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
};

struct L : array<P, 2> {
  L(const P& a, const P& b) {
    front() = a;
    back() = b;
  }
  P vec() const {
    return back() - front();
  }
};
// struct L : vector<P> {
//   L(const P& a, const P& b) {
//     push_back(a);
//     push_back(b);
//   }
//   P vec() const {
//     return back() - front();
//   }
// };
D dot(const P& a, const P& b) {
  return (conj(a)*b).X;
}
D cross(const P& a, const P& b) {
  return (conj(a)*b).Y;
}
int ccw(P a, P b, P c) {
  b -= a;
  c -= a;
  if(cross(b, c) > 0) return +1; // ccw
  if(cross(b, c) < 0) return -1; // cw
  if(dot(b, c) < 0) return +2; // L c-a-b
  if(norm(b) < norm(c)) return -2; // L a-b-c
  return 0;
}

bool intersectLL(const L& l, const L& m) {
  return abs(cross(l.vec(), m.vec())) > EPS ||
    abs(cross(l[1] - l[0], m[0] - l[0])) < EPS;
}

int main() {
  int n;
  cin >> n;
  while(n--) {
    vector<D> d(8);
    rep(i, 8) cin >> d[i];
    L s{P{d[0], d[1]}, P{d[2], d[3]}}, t{P{d[4], d[5]}, P{d[6], d[7]}};
    if(abs(cross(s.vec(), t.vec())) < EPS) cout << "YES" << endl;
    else cout << "NO" << endl;
    //    cout << s.vec().X << " " << s.vec().Y << endl;
    //    cout << t.vec().X << " " << t.vec().Y << endl;
    //    if(intersectLL(s, t)) cout << "NO" << endl;
    //    else cout << "YES" << endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
main(void){
	int T;cin>>T;
	double x1,x2,x3,x4,y1,y2,y3,y4;
	for(int t=1;t<=T;t++){
		cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
		if(abs((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4))<0.0000000001)
			cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}

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

int main(){

int n;
scanf("%d",&n);

float x[4],y[4];

for(int i=0;i<n;i++){
scanf("%f %f %f %f %f %f %f %f",&x[0],&y[0],&x[1],&y[1],&x[2],&y[2],&x[3],&y[3]);

float det=(y[1]-y[0])*(x[2]-x[3])-(x[0]-x[1])*(y[3]-y[2]);

if(det==0)
	printf("YES\n");
else
	printf("NO\n");
}

return 0;
}

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

int main(){
  double x1,y1,x2,y2,x3,y3,x4,y4;
  int n;
  cin>>n;
  while(n--){
    cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
    double a,b,c,d;
    a=y2-y1;
    b=y4-y3;
    c=x2-x1;
    d=x4-x3;
    
      if(a/c==d/b)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}
  return 0;

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

int main()
{
    int n;
    cin >> n;
    for(int i=0; i<n; i++)
    {
        double x1, x2, x3, x4;
        double y1, y2, y3, y4;
        cin >>  x1 >>  y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
        double dxa = x2 - x1;
        double dya = y2 - y1;
        double dxb = x4 - x3;
        double dyb = y4 - y3;
        if(fabs(dxb * dya - dxa * dyb) <= DBL_EPSILON * fmax(1, fmax(fabs(dxb * dya), fabs(dxa * dyb))))
        {
           cout << "YES" << endl; 
        }
        else
        {
            cout << "NO" << endl; 
        }
    }
    return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>

typedef long long ll;
using namespace std;

int main()
{
	int T;
	scanf("%d",&T);

	for(int t=0;t<T;t++){
		double pos[8];
		double eps = 10e-7;
		for(int i=0;i<8;i++){
			scanf("%lf",pos+i);
		}

		if(abs((pos[1]-pos[3])/(pos[0]-pos[2])-(pos[1+4]-pos[3+4])/(pos[0+4]-pos[2+4]))<eps){
			cout << "YES" << endl;
		}else
		{
			cout << "NO" << endl;	
		}
	}
}

C++: #include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>
#include <vector>
#include <list>
#include <iterator>

#include <cmath>

typedef std::pair<double,double> Vec;
typedef std::pair<Vec,Vec> Line;

Vec operator+(const Vec& lhs, const Vec& rhs) {
	return std::make_pair(lhs.first+rhs.first, lhs.second+rhs.second);
}

Vec operator-(const Vec& lhs, const Vec& rhs) {
	return std::make_pair(lhs.first-rhs.first, lhs.second-rhs.second);
}

Vec lineToVec(const Line& l) {
	return l.first - l.second;
}

double cross(const Vec& lhs, const Vec& rhs) {
  return lhs.first*rhs.second - lhs.second*rhs.first;
}

int main(void){
	using namespace std;

	int n;
	cin >> n;

	vector< pair<Line,Line> > input;
	input.reserve(n);

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

		auto AB = make_pair( make_pair(x1,y1), make_pair(x2,y2) );
		auto CD = make_pair( make_pair(x3,y3), make_pair(x4,y4) );

		input.push_back(make_pair(AB,CD));
	}

	for(auto itr=input.begin(); itr!=input.end(); itr++){
		auto AB = itr->first;
		auto CD = itr->second;

		auto cr = cross( lineToVec(AB), lineToVec(CD) );

		if( abs(cr) <10e-10 ){
			cout << "YES";
		}
		else{
			cout << "NO";
		}
		if( distance( itr, input.end() )>1 ){
			cout << endl;
		}
	}
}

C++: //
//  main.cpp
//  main
//
//  Created by h3037175 on 2018/01/22.
//  Copyright © 2018年 h3037175. All rights reserved.
//

#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
#include<algorithm>
#include<utility>
using namespace std;
double zeti(double);
int main() {
    pair<double,double> a;
    pair<double,double> b;
    pair<double,double>c;
    pair<double,double>d;
    int n;
    double s1,s2;
    cin>>n;
    for(int i=0;i<n;++i){
        cin>>a.first>>a.second>>b.first>>b.second>>c.first>>c.second>>d.first>>d.second;
        if((a.first==b.first&&c.first==d.first) || (a.second==b.second&&c.second==d.second)){
            cout<<"YES"<<endl;
            continue;
        }
        else if(a.first==b.first||c.first==d.first||a.second==b.second || c.second == d.second){
            cout<<"NO"<<endl;
            continue;
        }
        s1=(a.second-b.second)/(a.first-b.first);
        s2=(c.second-d.second)/(c.first-d.first);
        if(s1==s2){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
            
        }
    }
    
    
    return 0;
}

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

int main(int argc, char const* argv[]) {
  int n;
  cin >> n;
  for (int i = 0; i < n; i += 1) {
    float x1, y1, x2, y2, x3, y3, x4, y4;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
    float AB, CD;
    //AB = (y2 - y1) / (x2 - x1);
    //CD = (y4 - y3) / (x4 - x3);
    AB = (x2-x1!=0)?(y2-y1)/(x2-x1):0;
    CD = (x4-x3!=0)?(y4-y3)/(x4-x3):0;
    if (AB == CD) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}