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++: #include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	int k;
	double x1,x2,x3,x4,y1,y2,y3,y4;
	double veku1[2];
	double veku2[2];
	double veku3[2];
	double t;
	double m;
	cin >> k;

	for (int i = 0; i < k; i++) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		veku1[0] = x2 - x1;
		veku1[1] = y2 - y1;
		veku2[0] = x4 - x3;
		veku2[1] = y4 - y3;
		if (veku1[0] == 0) {
			if (veku2[0] != 0) {
				cout << "NO" << endl;
			} else {
				cout << "YES" << endl;
			}
		} else if (veku1[1] == 0){
			if (veku2[1] != 0) {
				cout << "NO" << endl;
			} else {
				cout << "YES" << endl;
			}
		} else {
			if ((veku2[0] / veku1[0]) == (veku2[1] / veku1[1])) {
				cout << "YES" << endl;
			} else {
				cout << "NO" << endl;
			}
		}
	}
	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <iostream>


using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
	{
		double x[4], y[4];
		for (int j = 0; j < 4; ++j)
			scanf("%lf %lf", x+j, y+j);

		double x1 = x[1] - x[0];
		double y1 = y[1] - y[0];
		double x2 = x[3] - x[2];
		double y2 = y[3] - y[2];
		if (abs(x1) < 0.00001 && abs(x2) < 0.00001
			|| abs(y1/x1-y2/x2) < 0.00001)
			puts("YES");
		else
			puts("NO");
	}

	return 0;
}

C++: #include<complex>
#include<iostream>
int main(){const double E=1e-10;int n;double x1,y1,x2,y2,x3,y3,x4,y4;std::cin>>n;while(n--){std::cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;std::cout<<((std::abs((y2-y1)*(x4-x3)-(y4-y3)*(x2-x1))<E)?"YES\n":"NO\n");}}

C++: #include <iostream>
#include <stdio.h>
#include <complex>
#include <cmath>
using namespace std;
#define rep(i,p) for(int i=0;i<p;i++)
typedef complex<double> xy_t;

// ??????: a.x*b.x
double dot_product(xy_t a, xy_t b) { 
  return (conj(a)*b).real(); 
}
// ??????: a.x*b.y - b.x*a.y
// ????§???¢????¬????????????¢????????????
double cross_product(xy_t a, xy_t b) { 
  return (conj(a)*b).imag(); 
}
// ?????±: ????????¨ p ??????????????´?????? b ????????±
xy_t projection(xy_t p, xy_t b) { 
  return b*dot_product(p,b)/norm(b); 
}
xy_t P[120];
const double eps = 1e-11;
double x[4], y[4];
int N;
int main() {
  cin>>N;//????????°
  for (int t=0; t<N; ++t) {
    for (int i=0; i<4; ++i)
      cin >> x[i] >> y[i]; // x0,y0..x3,y3
      xy_t a[2] = {
      xy_t(x[0],y[0]) - xy_t(x[1],y[1]),
      xy_t(x[2],y[2]) - xy_t(x[3],y[3])
      };
    bool p = abs(cross_product(a[0],a[1])/2) < eps;
    cout << (p ? "YES" : "NO") << endl;
  }
}

C++: #include <bits/stdc++.h>

using namespace std;

typedef long double ld;
typedef complex<ld> P;

const ld eps = 1e-12;

P input() {
	ld x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
	return P(x1-x2, y1-y2);
}
ld dot(P p1, P p2) {
	return p1.real()*p2.real() + p1.imag()*p2.imag();
}
int main() {
	int n; cin >> n;
	for (int i = 0; i < n; ++i) {
		P p1 = input();
		P p2 = input();
		ld d = dot( p1 * P(0, 1), p2 );
		if ( abs(d) < eps ) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
}

C++: #include <iostream>
#include <stack>
#include <stdio.h>
#include <cmath>
using namespace std;
double x[4],y[4];//p,1,2,3
double a[2],b[2],c[2];
void make_line(double x1,double y1,double x2,double y2,int num){
	if(x1!=x2&&y1!=y2){
		a[num]=(y1-y2)/(x1-x2);
		b[num]=-1;
		c[num]=-a[num]*x1+y1;
	}else if(x1==x2){
		a[num]=1;
		b[num]=0;
		c[num]=-x1;
	}else if(y1==y2){
		a[num]=0;
		b[num]=1;
		c[num]=-y1;
	}
	return;
}
int main()
{
	int n;
	cin>>n;
	while(n--){
		bool ans=false;
		cin>>x[0]>>y[0]>>x[1]>>y[1]>>x[2]>>y[2]>>x[3]>>y[3];
		make_line(x[0],y[0],x[1],y[1],0);
		make_line(x[2],y[2],x[3],y[3],1);
		if(a[0]==0){
			ans=(a[1]==0);
		}else if((b[0]/a[0])==(b[1]/a[1])){
			ans=true;
		}
		printf(ans?"YES\n":"NO\n");
	}
    return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
void judge(double,double,double,double,double,double,double,double);
#define EPS 0.000001

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

	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		judge(x1, y1, x2, y2, x3, y3, x4, y4);
	}
	
	return 0;
}

void judge(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) {
	double abx = x2 - x1;
	double aby = y2 - y1;
	double cdx = x4 - x3;
	double cdy = y4 - y3;
	if (abs(abx * cdy - aby * cdx) <= EPS) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return;

}

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