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 <bits/stdc++.h>

using namespace std;

class D3
{
public:
	long double X , Y , Z , EPS;

	D3(long double x_ = 0.0L , long double y_ = 0.0L , long double z_ = 0.0L)
	{
		X = x_;
		Y = y_;
		Z = z_;
		EPS = 1e-9L;
	}

	bool operator== (D3 Partner)
	{
		return abs(X - Partner.X) < EPS&&abs(Y - Partner.Y) < EPS&&abs(Z - Partner.Z) < EPS;
	}

	D3 operator*(long double ld)
	{
		return D3(X*ld , Y*ld , Z*ld);
	}

	D3 operator/(long double ld)
	{
		return  *this*( ld*-1.L );
	}
};

class Point :private D3
{

public:
	Point(long double x_ = 0.0L , long double y_ = 0.0L , long double z_ = 0.0L)
	{
		X = x_;
		Y = y_;
		Z = z_;
	}

	//x??§?¨??????????
	long double getX()
	{
		return X;
	}

	//y??§?¨??????????
	long double getY()
	{
		return Y;
	}

	//z??§?¨??????????
	long double getZ()
	{
		return Z;
	}

	bool operator== (Point Partner)
	{
		return *this == Partner;
	}
};

class Vec
{
private:
	Point SP;//Starting Point
	D3 Direction;

	//??????????????¨?§???????????????????????????????
	Vec(D3 Direction_ , Point SP_)
	{
		Direction = Direction_;
		SP = SP_;
	}
public:

	//?§??????¨???????????????????????????????????????????????????
	Vec(long double x_ = 0.0L , long double y_ = 0.0L , long double z_ = 0.0L , Point SP_ = Point())
	{
		*this = Vec(D3(x_ , y_ , z_) , SP_);
	}

	Vec operator+(Vec Partner)
	{
		return Vec(Direction.X + Partner.Direction.X , Direction.Y + Partner.Direction.Y , Direction.Z + Partner.Direction.Z , SP);
	}

	Vec operator*(Vec Partner)
	{
		return Vec(Direction.X * Partner.Direction.X , Direction.Y * Partner.Direction.Y , Direction.Z * Partner.Direction.Z , SP);
	}

	Vec operator*(long double ld)
	{
		return Vec(Direction*ld , SP);
	}

	Vec operator-(Vec Partner)
	{
		return *this + ( Partner*( -1.L ) );
	}

	Vec operator/(Vec Partner)
	{
		return Vec(Direction.X / Partner.Direction.X , Direction.Y / Partner.Direction.Y , Direction.Z / Partner.Direction.Z , SP);
	}

	Vec operator/(long double ld)
	{
		return *this*( 1.L / ld );
	}

	bool operator== (Vec Partner)
	{
		return Direction == Partner.Direction&&SP == Partner.SP;
	}


	//??????
	Vec Cross_product(Vec partner)
	{
		return Vec(Direction.Y*partner.Direction.Z - Direction.Z*partner.Direction.Y , Direction.Z*partner.Direction.X - Direction.X*partner.Direction.Z , Direction.X*partner.Direction.Y - Direction.Y*partner.Direction.X);
	}

	//??????
	double Inner_product(Vec partner)
	{
		return Direction.X*partner.Direction.X + Direction.Y*partner.Direction.Y + Direction.Z*partner.Direction.Z;
	}


	//???????????????????????????????????????
	Vec(Point A , Point B)
	{
		*this = Vec(A.getX() - B.getX() , A.getY() - B.getY() , A.getZ() - B.getZ() , B);
	}

	//?§?????????????
	Point getSP()
	{
		return SP;
	}

	//???????????????
	Point getGP()
	{
		return Point(SP.getX() + Direction.X , SP.getZ() + Direction.Z , SP.getZ() + Direction.Z);
	}

	//???????????????
	D3 getDirection()
	{
		return Direction;
	}

	//???????????????
	long double length()
	{
		return sqrtl(Direction.X*Direction.X + Direction.Y*Direction.Y + Direction.Z*Direction.Z);
	}

	//??????????????????(??????1)?????????
	Vec Unit_vec()
	{
		return Vec(*this) / ( *this ).length();
	}

	//????????????????????????
	Vec Inverse_vec()
	{
		return ( *this )*-1.L;
	}

	//?????´????????????
	bool Vertical(Vec Partner)
	{
		return ( *this ).Inner_product(Partner) == 0;
	}

	//??????????????????
	bool Parallel(Vec Partner)
	{
		return ( *this ).Unit_vec().getDirection() == Partner.Unit_vec().getDirection() || ( *this ).Unit_vec().Inverse_vec().getDirection() == Partner.Unit_vec().getDirection();
	}

};

int main()
{
	int N;
	cin>>N;
	for(size_t i = 0; i < N; i++)
	{
		long double D[8];
		for(size_t j = 0; j < 8; j++)
		{
			cin>>D[j];
		}
		Vec AB(Point(D[0],D[1]),Point(D[2],D[3])),CD(Point(D[4],D[5]),Point(D[6],D[7]));
		if(AB.Parallel(CD))
		{
			cout<<"YES"<<endl;
		} else
		{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}

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

int main() {
	typedef complex<double> com;
	int n;
	double x1, y1, x2, y2, x3, y3, x4, y4;
	cin >> n;
	for ( int i = 0; i < n; i++ ) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		if ( - 1e-10 < ( conj( com( x2 - x1, y2 - y1 ) ) * com( x4 - x3, y4 - y3 ) ).imag() < 1e-10 )
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
}

C++: #include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y-1);(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int i,j,k,T;
  cin>>T;
  while(T--){
    double xx,yy;
    ll x[4],y[4];
    rep(i,4){
      cin>>xx>>yy;
      x[i]=xx*1e6;
      y[i]=yy*1e6;
      //   cout<<x[i]<<","<<y[i]<<endl;
    }
    rep(i,2){
      x[i*2+1]-=x[i*2];
      y[i*2+1]-=y[i*2];
    }
    cout<<(x[1]*y[3]==x[3]*y[1]?"YES":"NO")<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<cmath>
using namespace std;
int main(){
  int n; cin >> n;
  while(n--){
    double x[4],y[4];
    for(int i=0;i<4;i++) cin >> x[i] >> y[i]; 
    if(abs((x[3] - x[2]) * (y[1] - y[0]) - (x[1] - x[0]) * (y[3] - y[2])) < 1e-10)
      cout<<"YES"<<endl;
    else
      cout<<"NO"<<endl;
  }
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
using namespace std;
typedef pair<int, int> pii;
#define MAX 99999999
int main(){
    typedef pair<double, double>pdd;
    vector<pdd>v(5);
    int n;cin>>n;
    rep(i,n){
        rep(i,4)cin>>v[i].first>>v[i].second;
        if(v[0].first<v[1].first)swap(v[0],v[1]);
        if(v[2].first<v[3].first)swap(v[2],v[3]);
        double d1=(v[0].second-v[1].second)/(v[0].first-v[1].first);
        double d2=(v[2].second-v[3].second)/(v[2].first-v[3].first);
        if(d1==d2&&(v[0].first-v[1].first!=0))cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}