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 <stdio.h>
#include <stdlib.h>

double calc(double dx1, double dy1, double dx2, double dy2) {

    if(dx1 == 0.0 || dx2 == 0.0) {
        return dx1 == dx2;
    }
    return (dy1/dx1) == (dy2/dx2);
}

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

    scanf("%d", &n);
    for(i=0; i<n; ++i) {
        scanf("%lf %lf %lf %lf %lf %lf %lf %lf",
              &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
        if(calc(x2-x1, y2-y1, x4-x3, y4-y3)) {
            printf("YES\n");
        }else {
            printf("NO\n");
        }
    }

    return 0;
}

C++: #include <iostream>
#include<cmath>
#include<iomanip>
#include<stdio.h>
#include<memory.h>
using namespace std;

int main()
{
	int n;
	while (cin >> n)
	{
		double **a = new double*[n];
		char **b = new char*[n];
		for (int i = 0; i < n; i++)
		{
			a[i] = new double[8];
			b[i] = new char[4];
			memset(a[i], 0, sizeof(a[i]));
			memset(b[i], 0, sizeof(b[i]));
		}
		for (int i = 0; i < n; i++)
			for (int j = 0; j < 8; j++)
				cin >> a[i][j];
		for (int i = 0; i < n; i++)
			if (fabs(a[i][0] - a[i][2]) < 10e-3 || fabs(a[i][4] - a[i][6]) < 10e-3)
				if (fabs(a[i][0] - a[i][2]) < 10e-3 && fabs(a[i][4] - a[i][6]) < 10e-3)
					b[i][0] = 'Y', b[i][1] = 'E', b[i][2] = 'S';
				else
					b[i][0] = 'N', b[i][1] = 'O';
			else
				if(fabs((a[i][3]-a[i][1])/(a[i][2]-a[i][0])-(a[i][7]-a[i][5])/(a[i][6]-a[i][4]))<10e-3)
					b[i][0] = 'Y', b[i][1] = 'E', b[i][2] = 'S';
				else
					b[i][0] = 'N', b[i][1] = 'O';
		for (int i = 0; i < n; i++)
			cout << b[i] << endl;
		for (int i = 0; i < n; i++)
			delete a[i], b[i];
		delete a, b;
	}
	return 0;
}

C++: #include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

int n;
int main() {
    cin>>n;
    double x1,y1;
    double x2,y2;
    double x3,y3;
    double x4,y4;
    rep(i,n) {
        cin>>x1>>y1;
        cin>>x2>>y2;
        cin>>x3>>y3;
        cin>>x4>>y4;
        double tx1 = x1-x2 + 1e-8;
        double ty1 = y1-y2 + 1e-8;
        double tx2 = x3-x4 + 1e-8;
        double ty2 = y3-y4 + 1e-8;


        double t1 = tx1*ty2;
        double t2 = tx2*ty1;

        if(t1==t2) {
            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;
#define rep(i,n) for(int i=0;i<n;i++)

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

	cin >> n;

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

	return 0;
}

C++: #include <iostream>
#include <vector>

int main(int argc, const char * argv[]) {
    std::vector<int> r;
    int num;
    std::cin >> num;
    double xa,ya,xb,yb,xc,yc,dx,dy;
    
    for(int i = 0;i < num;i++){
        std::cin >> xa >> ya>> xb >> yb >> xc >> yc >> dx >> dy;
        double a = (yb - ya) / (xb - xa);
        double b = (dy - yc) / (dx - xc);
        if(a == b){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }
}

C++: #include<stdio.h>
 
int main(void){
    double x[4],y[4];
    int n,i;
     
    scanf("%d",&n);
     
    for(i=0;i<n;i++){
        scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x[0],&y[0],&x[1],&y[1],&x[2],&y[2],&x[3],&y[3]);
         
        if(((y[1]-y[0])/(x[1]-x[0])) == ((y[3]-y[2])/(x[3]-x[2])))printf("YES\n");
        else printf("NO\n");
    }
     
    return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
const double eps = 1e-9;
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;
        x1 -= x2;
        y1 -= y2;
        x3 -= x4;
        y3 -= y4;
        cout << (abs(x1 * y3 - y1 * x3) < eps ? "YES" : "NO") << endl;
    }
    return 0;
}

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

using namespace std;

void swap(double &x, double &y, double &xx, double &yy) 
{
  double tmp_x = x;
  double tmp_y = y;
  x = xx;
  y = yy;
  xx = tmp_x;
  yy = tmp_y;
}

void compute(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) 
{
  if (x1 > x2) swap(x1, y1, x2, y2);
  if (x3 > x4) swap(x3, y3, x4, y4);

  double diff_x12 = x2 - x1;
  double diff_y12 = y2 - y1;
  double diff_x34 = x4 - x3;
  double diff_y34 = y4 - y3;

  if (diff_x12 == 0.0 && diff_y12 == 0.0)
    cout << "NO" << endl;
  else if (diff_x34 == 0.0 && diff_y34 == 0.0)
    cout << "NO" << endl;  
  else if (diff_x12 != 0 && diff_x34 != 0) {
    if (diff_y12 == 0.0 && diff_y34 == 0.0)
      cout << "YES" << endl;
    else {
      double ab = diff_y12 / diff_x12;
      double cd = diff_y34 / diff_x34;
      if (abs(ab - cd) < 0.00001)
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    }
  }
  else if (diff_x12 == 0.0 && diff_x34 == 0.0) {
    cout << "YES" << endl;  
  }
  else
    cout << "NO" << endl;  
}

int main(void) 
{
  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;
    compute(x1, y1, x2, y2, x3, y3, x4, y4);
  }
  
  return 0;
}

C++: #include<iostream>
#include<cmath>
using namespace std;
#define EPS 1e-10
double x[4],y[4];
double det(){
  double x1,x2,y1,y2;
  x1 = x[0] - x[1];
  y1 = y[0] - y[1];
  x2 = x[2] - x[3];
  y2 = y[2] - y[3];
  return x1 * y2 - y1 * x2;
}

int main(void){
  int n;
  cin >> n;
  while(n--){
    for(int i = 0 ; i < 4 ; i ++)cin>>x[i]>>y[i];
    cout<<(vabs(det())<CPS?"YES":"NO")<<endl;

  }
  return 0;
}

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

const double eps=1e-9;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    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;
        x2-=x1;
        y2-=y1;
        x4-=x3;
        y4-=y3;
        if(x2<eps&&x4<eps) cout<<"YES\n";
        else if(y2<eps&&y4<eps) cout<<"YES\n";
        else if(x2*y4-x4*y2<eps) cout<<"YES\n";
        else cout<<"NO\n";
    }
    return 0;
}