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++: //
//  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){
            cout<<"YES"<<endl;
            continue;
        }
        
        if((a.second-b.second)/(a.first-b.first)==(c.second-d.second)/(c.first-d.first)){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
            
        }
    }
    
    
    return 0;
}

C++: #include <iostream>
#include <stdio.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;

int main(){
	int n;
	cin >> n;
	double x1,y1,x2,y2,x3,y3,x4,y4;
	REP(i,n){
		cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
		if((y1-y2)/(x1-x2) - (y3-y4)/(x3-x4) < 1.0e-10){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

C++: #include<stdio.h>

int main(void)
{
	double x[4]={0},y[4]={0},x1,x2,y1,y2;
	int i;
	scanf("%d",&i);

	while(i!=0)
	{
		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]);
		x1 = x[1]-x[0];   y1 = y[1]-y[0];
		x2 = x[3]-x[2];   y2 = y[3]-y[2];
		if(x1==0 && x2==0)
			printf("YES\n");
		else if(x1==0  || x2==0)
			printf("NO\n");
		else if((y1/x1) == (y2/x2))
			printf("YES\n");
		else 
			printf("NO\n");

		i-=1;
	}
 return 0;
}

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

int main() {
	int n;
	double x1, x2, x3, x4, y1, y2, y3, y4;
	vector<double> X1, Y1, X2, Y2;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		X1.push_back(x2 - x1); Y1.push_back(y2 - y1);
		X2.push_back(x4 - x3); Y2.push_back(y4 - y3);
	}
	for (int i = 0; i < n; i++) {
		double det = fabs(X1[i] * Y2[i] - X2[i] * Y1[i]);
		if (fabs(det)<1e-10)cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

struct Vector2D
{
	double x, y;

	Vector2D()
	{

	}

	Vector2D(Vector2D v0, Vector2D v1)
	{
		this->x = v1.x - v0.x;
		this->y = v1.y - v0.y;
	}
};

double outer(Vector2D a, Vector2D b)
{
	return a.x * b.y - a.y * b.x;
}

int main()
{
	int n;
	for (cin >> n; n--;)
	{
		vector<Vector2D> p(4);

		for (int i = 0; i < 4; i++)
		{
			cin >> p.at(i).x >> p.at(i).y;
		}

		Vector2D ab = Vector2D(p.at(0), p.at(1));
		Vector2D cd = Vector2D(p.at(2), p.at(3));

		if (outer(ab, cd) == 0)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
}

C++: #include<iostream>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
using namespace std;

int main(){
	int n;
	scanf("%d",&n);
	for(int x=0;x<n;++x){
		double m1,m2;
		double x1,x2,y1,y2;
		scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
		m1 = (y2-y1)/(x2-x1);
		scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
		m2 = (y2-y1)/(x2-x1);
		if(m1==m2){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}

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

int main(){
	int t;
	double x1, y1, x2, y2, x3, y3, x4, y4;
	scanf("%d", &t);
	while(t--){
		scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
		//printf("%f\n%f\n", (x2 - x1) * (y4 - y3), (x4 - x3) * (y2 - y1));
		printf("%s\n", ((double)(x2 - x1) * (y4 - y3) == (double)(x4 - x3) * (y2 - y1))? "YES" : "NO");
	}
	return 0;
}

C++: #include<cmath>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cstdio>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define fori(i,k,n) for(int i=k;i<n;i++)
using namespace std;
const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
const int dX[8] = { 0, 1, 1, 1, 0, -1, -1, -1 }, dY[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
/*
(char)'1' - (int)48 = (int)1; 


*/


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

	}
	return 0;

}

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

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

float x1, y1, x2, y2, x3, y3, x4, y4;

int main(void) {
	int n;
	cin >> n;
	bool flag;
	while (n--) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		if (x1 == x2 && x3 == x4) {
			flag = true;
		} else if (((y2 - y1) / (x2 - x1)) == ((y4 - y3) / (x4 - x3))){
			flag = true;
		} else {
			flag = false;
		}
		if (flag) 
			cout << "YES\n";
		else 
			cout << "NO\n";
	}
}

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

int main(){
  int n;//データ数
  double x[4];
  double y[4];
  cin >> n ;
  while(n--){
  //入力フェイズ
  for(int i=0;i<4;i++){
    cin >> x[i] >> y[i];
  }
  //傾きの求め方 yの増加量/xの増加量
  if((y[0]-y[1])*(x[2]-x[3])==(x[0]-x[1])*(y[2]-y[3]))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
}

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

struct TCoordinate
{
	float x;
	float y;
};

struct TLine
{
	TCoordinate StartPoint;
	TCoordinate EndPoint;
	float GetInclination()
	{
		return (EndPoint.y - StartPoint.y) / (EndPoint.x - StartPoint.x);
	}
};

int main()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		TLine AB, CD;
		cin >> AB.StartPoint.x >> AB.StartPoint.y
		    >> AB.EndPoint.x   >> AB.EndPoint.y
		    >> CD.StartPoint.x >> CD.StartPoint.y
		    >> CD.EndPoint.x   >> CD.EndPoint.y;
		if(AB.GetInclination() == CD.GetInclination()){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
	return 0;
}