Go: package main

import "fmt"

func abs(x float64) float64 {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	var n int
	var x1, y1, x2, y2, x3, y3, x4, y4 float64
	fmt.Scan(&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)
		if abs((x2-x1)*(y4-y3) - (y2-y1)*(x4-x3)) < 1e-10 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

C++: #include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <cstdio>
using namespace std;

#define FOR(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long>PLL;
typedef queue<int> QI;
typedef priority_queue<int> maxpq;
typedef priority_queue<int, vector<int>, greater<int> > minpq;

struct edge{int to, cost;};

void begin(){cin.tie(0); ios::sync_with_stdio(false);};
int gcd(int a, int b){if(a%b==0){return(b);}else{return(gcd(b,a%b));}};
int lcm(int m, int n){if((0 == m)||(0 == n)){return 0;} return ((m / gcd(m, n)) * n);};
unsigned long long comb(long n, long m){unsigned long long c = 1; m = (n - m < m ? n - m : m);
    for(long ns = n - m + 1, ms = 1; ms <= m; ns ++, ms ++){c *= ns; c /= ms;} return c;};

// ワーシャルフロイド法
void warshallFloyd(int d[100][100], int n){
    for(int k = 0; k < n; ++k)
        for(int i = 0; i < n; ++i)
            for(int j = 0; j < n; ++j)
                if(d[i][k] != -1 && d[k][j] != -1){
                    if(d[i][j] == -1){
                        d[i][j] = d[i][k] + d[k][j];
                    }else{
                        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
                    }
                }
};


// d:隣接行列  n:グラフのサイズ  s:始点  dist:始点からの距離が入る配列
void dijkstra(int d[1000][1000], int n, int s, int dist[1000]){
    FOR(i, n) dist[i] = -1;
    dist[s] = 0;
    priority_queue<PII, vector<PII>, greater<PII> > q;
    q.push(PII(0, s));
    while (!q.empty()) {
        PII p = q.top(); q.pop();
        int i = p.second;
        if(dist[i] < p.first) continue;
        for(int j = 0; j < n; j++){
            if(d[i][j] == -1) continue;
            if(dist[j] == -1){
                dist[j] = dist[i] + d[i][j];
                q.push(PII(dist[j], j));
            }else if(dist[j] > dist[i] + d[i][j]){
                dist[j] = dist[i] + d[i][j];
                q.push(PII(dist[j], j));
            }
        }
    }
};

// 線分の交差判定
bool isCross(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4){
    // 並行な場合
    int m = (x2-x1)*(y4-y3)-(y2-y1)*(x4-x3);
    if(m == 0) return false;
    // 媒介変数の値が0より大きく1以下なら交差する、これは問題の状況によって変わるかも。
    double r =(double)((y4-y3)*(x3-x1)-(x4-x3)*(y3-y1))/m;
    double s =(double)((y2-y1)*(x3-x1)-(x2-x1)*(y3-y1))/m;
    return (0 < r && r <= 1 && 0 < s && s <= 1);
};


bool isParallel(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4){
    if((x2-x1)*(y4-y3)-(y2-y1)*(x4-x3) == 0.0) return true;
    else return false;
};

int main(int argc, const char * argv[]){
    begin();
    int n; double d[8];
    cin >> n;
    FOR(i, n){
        FOR(j, 6) cin >> d[i];
        cout << (isParallel(d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7]) ? "YES" : "NO") << endl;
    }
}

C++: #include<stdio.h>
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		float x1,x2,x3,x4,y1,y2,y3,y4;
		scanf("%f%f%f%f%f%f%f%f",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
		float k1=(y2-y1)/(x2-x1),k2=(y4-y3)/(x4-x3);
		if(k1==k2)printf("YES\n");
		else printf("NO\n");}
	return 0;}

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

using namespace std;

int main(void)
{
  double x=0.0,y=0.0;
  double x1=0.0,y1=0.0;
  int n=0;
  int i=0;
  double a,b;

  cin>>n;

  for(i=0;i<n;i++)
    {
      cin>>x>>y>>x1>>y1;
      a=(y1-y)/(x1-x);

      cin>>x>>y>>x1>>y1;
      b=(y1-y)/(x1-x);
	
      if(a==b)
        puts("YES");
      else
        puts("NO");
    }

}

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

int main()
{
	int n ;
	double ax,ay,bx,by,cx,cy,dx,dy ;

	cin >> n ;
	for( int i = 0 ; i < n ; i ++ )
	{
		cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy ;

		if( (ay-by)/(ax-bx) == (cy-dy)/(cx-dx) ) cout << "YES" << endl ;
		else	cout << "NO" << endl ;
	}
	return 0 ;
}

C++: #include<complex>
#include<iostream>
using namespace std;
typedef complex<double> P;

int cross(P a, P b, P c, P d);

int main(){
    int n;
    cin >>n;
    for(int i = 0; i < n; i++){
        P a, b, c, d;
        cin >>a.real() >>a.imag() >>b.real() >>b.imag() >>c.real() >>c.imag() >>d.real() >>d.imag();
        if(cross(a, b, c, d)){
            cout <<"YES" <<endl;
        } else{
            cout <<"NO" <<endl;
        }
        return 0;
    }
}
int cross(P a, P b, P c, P d){
    P x = a - b, y = c - d;
    int ret;
    if(!(x.real() * y.imag() - x.imag() * y.real())){
        ret = 1;
    } else{
        ret = 0;
    }
    return ret;
}

C++: #include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-10
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<double,double> P;
static const int INF=1<<24;

int main(){
	double x[3],y[3];
	int n;
	cin>>n;
	rep(i,n){
		rep(j,4){
			cin>>x[j]>>y[j];
			//cout<<x[j]<<" "<<y[j]<<endl;
		}
		P a( x[1]-x[0] ,y[1]-y[0]), b( x[3]-x[2] ,y[3]-y[2]);
		bool f;
		if(abs(a.F*b.S-b.F*a.S)<=EPS) f=true;
		else f=false;
		//CP c(3.0,2.0);
		//cout<<real(c)<<" "<<imag(c)<<endl;
		//cout<<real(a)<<" "<<imag(a)<<" "<<real(b)<<" "<<imag(b)<<endl;
		if(f) cout<<"YES\n";
		else cout<<"NO\n";
	}
	return 0;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;

	double x[4];
	double y[4];

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

		double m1 = (y[1] - y[0]) / (x[1] - x[0]);
		double m2 = (y[3] - y[2]) / (x[3] - x[2]);

		cout << (m1 == m2 ? "YES" : "NO") << endl;

		--n;
	}

	return 0;
}

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

const double EPS = 1e-8;
typedef double D;

struct P {
  D x, y;
  P(D xs, D ys) : x(xs), y(ys) { }
  P() { }
};

P operator -(P a, P b) { return P(a.x - b.x, a.y - b.y); }

struct L {
  P a, b;
  L(P as, P bs) : a(as), b(bs) { }
};

int sign(D a, D b = 0.0) {
  if(a < b - EPS) return -1;
  if(a > b + EPS) return +1;
  return 0;
}

P vec(P from, P to) { return to - from; }
D inp(P a, P b) { return a.x*b.x + a.y*b.y; }
D outp(P a, P b) { return a.x*b.y - a.y*b.x; }

bool iLL(L l, L m) {
  return sign(outp(vec(l.a, l.b), vec(m.a, m.b))) != 0 || // テ・ツケツウティツ。ツ古」ツ?ァテ」ツ?ェテ」ツ??
    sign(outp(vec(l.a, l.b), vec(l.a, m.a))) == 0;   // テ・ツ青古」ツ?佚ァツ崢エテァツキツ?
}

int main() {
  int N; cin >> N;
  while(N--) {
    double x1, y1, x2, y2, x3, y3, x4, y4;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
    if(iLL(L(P(x1,y1), P(x2,y2)), L(P(x3,y3),P(x4,y4))) == 0) {
      cout << "YES" << endl;
    }
    else {
      cout << "NO" << endl;
    }
  }
}