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 <cassert>
#include <cmath>
#include <iostream>
#include <vector>
#include <iomanip>

struct Point
{
    float x;
    float y;
};
struct Line
{
    Line(const Point& a, const Point& b)
    : p1(a), p2(b) {}
    Point p1;
    Point p2;
};
double GetSlope(const Line& line)
{
    return
    (line.p2.y - line.p1.y) /
    (line.p2.x - line.p1.x);
}
bool IsParallel(const Line& l1, const Line&l2)
{
    // std::cerr << std::fixed << std::setprecision(100) << GetSlope(l1) << std::endl;
    // std::cerr << std::fixed << std::setprecision(100) << GetSlope(l2) << std::endl;
    return GetSlope(l1) == GetSlope(l2);
    // const double gosa = 1e-10;
    // double Slope1 = GetSlope(l1);
    // double Slope2 = GetSlope(l2);
    // return std::fabs(Slope1 - Slope2) < gosa;
}
bool IsParallel(const std::vector<Point>& points)
{
    assert(points.size() == 4);
    return IsParallel(Line(points[0], points[1]), Line(points[2], points[3]));
}
std::vector<Point> Input(std::istream& is)
{
    std::vector<Point> points(4);
    for(int i = 0; i < points.size(); ++i){
        is >> points[i].x >> points[i].y;
    }
    return points;
}
int main()
{
    int n;
    std::cin >> n;
    for(int i = 0; i < n; ++i) {
        std::vector<Point> p = Input(std::cin);
        // std::cout << (IsParallel(p) ? "YES" : "NO") << std::endl; 
        if((p[1].y-p[0].y)/(p[1].x-p[0].x) == (p[3].y-p[2].y)/(p[3].x-p[2].x)){
            std::cout << "YES";
        }else{
            std::cout << "NO";
        }
        std::cout << std::endl;
    }
    return 0;
}

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

int main()
{
    double a,s,d,f,g,h,j,k;
    double q,w,e,r;
        int n;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>a>>s>>d>>f>>g>>h>>j>>k;
        q=d-a;
    w=f-s;
    e=j-g;
    r=k-h;
        if(q*r==w*e&&q!=0&&w!=0&&e!=0&&r!=0)cout<<"YES"<<endl;
        else if(q==0&&e==0&&w==r)cout<<"YES"<<endl;
        else if(w==0&&r==0&&q==e)cout<<"YES"<<endl;
        else  cout<<"NO"<<endl;
    }
    return 0;
}

C++: #include<string>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<functional>
#include<map>
#include<stack>
#include<set>
#include<cmath>
 
#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)
 
#define EPS 1e-6
 
using namespace std;
 
int main(){
 
    int n;
    double x1,y1,x2,y2,x3,y3,x4,y4;
 
    cin >> n;
 
    rep(i,n){
 
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
 
    double a=y2-y1; double b=x2-x1;
    double d=y4-y3; double e=x4-x3;
 
    if(a*e-d*b==0) cout << "YES" << endl;
    else cout << "NO" << endl;
 
    }
 
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

int n;
double x1,x2,x3,x4,ya1,y2,y3,y4;

int main() {
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> x1 >> ya1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		if (x1 > x2) {
			double tmp = x1;
			x1 = x2;
			x2 = tmp;
			tmp = ya1;
			ya1 = y2;
			y2 = tmp;
		}
		if (x3 > x4) {
			double tmp = x3;
			x3 = x4;
			x4 = tmp;
			tmp = y3;
			y3 = y4;
			y4 = tmp;
		}

		if (x1 == x2) {
			if (x3 == x4) cout << "YES" << endl;
			else cout << "NO" << endl;
		} else {
			if (x3 == x4) cout << "NO" << endl;
			else {
				if ((y2 - ya1) / (x2 - x1) - (y4 - y3) / (x4 - x3) <= 0.000000001)
					cout << "YES" << endl;
				else cout << "NO" << endl;
			}
		}
	}

	return 0;
}

/*@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*@                       @*/
/*@ debug output erased ? @*/
/*@                       @*/
/*@@@@@@@@@@@@@@@@@@@@@@@@@*/

C++: #include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath>

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

using namespace std;

int n;
float x[4];
float y[4];

int main(){
	scanf("%d", &n);
	rep(i, n){
		rep(j, 4){
			scanf("%f%f", x + j, y + j);
		}

		float dx[2];
		float dy[2];
		dx[0] = x[0] - x[1];
		dx[1] = x[2] - x[3];
		dy[0] = y[0] - y[1];
		dy[1] = y[2] - y[3];

		// printf("(%f, %f) (%f, %f)\n", dx[0], dy[0], dx[1], dy[1]);

		printf("%s\n", fabs(dx[0] * dy[1] - dx[1] * dy[0]) < 1e-6 ? "YES" : "NO");
	}
	return 0;
}

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

int main() {
	int n;
	xy a, b, c, d;
	double delta = 0.001;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a.real() >> a.imag();
		cin >> b.real() >> b.imag();
		cin >> c.real() >> c.imag();
		cin >> d.real() >> d.imag();

		xy s = a - b, t = c - d;
		if (abs((conj(s)*t).imag()) < delta) cout << "YES" << endl;
		else cout << "NO" << endl;
	}

	return 0;

}

C++: #include<iostream>
#include<cmath>
using namespace std;
bool EQ(double a,double b){
  if(abs(a-b)<0.0000001) return true;
  return false;
  //  return a-0.0000001<b&&b<a+0.0000001;
}
int main(){
  int n;
  double x[4],y[4];
  cin>>n;
  while(n--){
    for(int j=0;j<4;j++) cin>>x[j]>>y[j];
    if(EQ((y[3]-y[2])*(x[1]-x[0]),(y[1]-y[0])*(x[3]-x[2])))cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

#define EPS (1e-9)

double cross_product( double x1, double y1,
					  double x2, double y2 )
{
	return ((x1 * y2) - (x2 * y1));
}

int main( void )
{
	int n;
	while ( 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;

			if (EPS > cross_product((x2-x1), (y2-y1), (x4-x3), (y4-y3)))
				cout << "YES" << endl;
			else
				cout << "NO" << endl;
		}
	}
	
	return 0;
}

C++: #include<iostream>
#define INF 10000000
using namespace std;
int main(){
  int n;
  double lI,lII,x1,y1,x2,y2,x3,y3,x4,y4;
  cin >> n;
  while(n--){
    cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
    //x2-x1が0になったらOUT?
    /*  lI = lII = INF;
    if(x1!=x2) lI = (y2-y1)/(x2-x1);
    if(x3!=x4) lII = (y4-y3)/(x4-x3);*/
    x2-=x1,y2-=y1,x4-=x3,y4-=y3;
    cout << ((x2==0&&x4==0)||(y2/x2 == y4/x4)?"YES":"NO") << endl;
  }
}

C++: #include <iostream>
#include <complex>
using namespace std;
#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)

#define X real()
#define Y imag()
typedef double D;
typedef complex<D>P;
#define EPS (1e-9)
#define DEQ(p1,p2) (abs((p1)-(p2)) < EPS)
 
inline D outprd(const P &a, const P &b){ return (conj(a) * b).Y; }
bool is_parallel(const P &a, const P &b, const P &c, const P &d){
    return DEQ(outprd(a-b, c-d), 0.0);
}

int main(){
    int n;
    cin >> n;
    REP(i,n){
        double x1, y1, x2, y2, x3, y3, x4, y4;
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
        P p1(x1,y1), p2(x2,y2), p3(x3,y3), p4(x4,y4);
        if(is_parallel(p1,p2,p3,p4)){
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}