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 <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)
class Point{
  public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}
  Point operator + (Point p){return Point(x+p.x,y+p.y);}
  Point operator - (Point p){return Point(x-p.x,y-p.y);}
  Point operator * (double a){return Point(a*x,a*y);}
  Point operator / (double a){return Point(x/a,y/a);}
  bool operator < (const Point &p) const{
    return x!=p.x?x<p.x:y<p.y;
  }
  bool operator == (const Point &p) const{
    return fabs(x-p.x)<EPS&&fabs(y-p.y)<EPS;
  }
};
struct seg{Point p1,p2;};
//??????
double dot(Point a,Point b){
  return a.x*b.x+a.y*b.y;
}
//??????
double cross(Point a,Point b){
  return a.x*b.y-a.y*b.x;
}
//??´?????????
bool C90(seg s1,seg s2){
  return equals(dot(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}
bool C0(seg s1,seg s2){
  return equals(cross(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}


main(){
  int n;
  cin>>n;
  while(n--){
    seg a,b;
    cin>>a.p1.x>>a.p1.y>>a.p2.x>>a.p2.y;
    cin>>b.p1.x>>b.p1.y>>b.p2.x>>b.p2.y;
    if(C0(a,b))cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
}

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

const double eps=1e-8;

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 dx1=x[1]-x[0], dx2=x[3]-x[2], dy1=y[1]-y[0], dy2=y[3]-y[2];
		bool ans=true;
		if(dx1==0){
			if(dx2!=0) ans=false;	
		}
		else{
			double a=dx2/dx1, b=dy2/dy1;
			if(fabs(a-b)>eps) ans=false; 
		}
		
		if(ans) printf("YES\n");
		else printf("NO\n");
	}
}

C++: #include <cstdio>

int main(void)
{
    double x1, y1, x2, y2, x3, y3, x4, y4;
    double m1, m2;
    
    int n;
    scanf("%d", &n);
    while (n != 0){
        scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
        m1 = (y2 - y1) / (x2 - x1);
        m2 = (y4 - y3) / (x4 - x3);
        (m1 == m2) ? printf("YES\n") : printf("NO\n");
        n--;
    }
    
    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
{
	float x, y;

	Vector2D()
	{

	}

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

float 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<bits/stdc++.h>
using namespace std;
 
signed main(){
int a;
cin>>a;
double c[8];
for(int b=0;b<a;b++){
    for(int d=0;d<8;d++)scanf("%lf",&c[d]);
    if(c[0]==c[1]&&c[2]==c[3])printf("YES\n");
    else if((c[2]-c[0])/(c[3]-c[1])==(c[6]-c[4])/(c[7]-c[5]))printf("YES\n");
    else printf("NO\n");
    }
}

C++: #include <iostream>

int main(){
	double x1,y1,x2,y2,x3,y3,x4,y4;
	int n;
	std::cin >> n;
	for(int i=0 ; i<n ; ++i){
		std::cin >>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
		bool parallel=false;
		if(x1==x2 && x3==x4) {
			parallel=true;
		}
		else if(x1==x2 || x3==x4) {
		}
		else if ((y2-y1)/(x2-x1)==(y4-y3)/(x4-x3)) {
			parallel=true;
		}
		std::cout << ( parallel ? "YES" : "NO") << std::endl;
	}
	return 0; 
}

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

class Point
{
public:
	double m_X;
	double m_Y;
	Point(double x, double y)
		: m_X( x )
		, m_Y( y )
	{}
};

class LineSegment
{
private:
	Point m_Start;
	Point m_End;
public:
	LineSegment(Point start, Point end)
		: m_Start( start )
		, m_End( end )
	{}
	double CalcSlope()
	{
		return((m_End.m_Y - m_Start.m_Y) / (m_End.m_X - m_Start.m_X));
	}
};

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

	std::cin >> n;

	for (int data_no = 0; data_no < n; ++data_no)
	{
		Point start1{ x1, y1 };
		Point end1{ x2, y2 };
		Point start2{ x3, y3 };
		Point end2{ x4, y4 };

		LineSegment line1{ start1, end1 };
		double line1_slope = line1.CalcSlope();

		LineSegment line2{ start2, end2 };
		double line2_slope = line2.CalcSlope();

		if (line1_slope == line2_slope)
		{
			std::cout << "YES" << std::endl;
		}
		else
		{
			std::cout << "NO" << std::endl;
		}
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  double a[2],b[2],c[2],d[2];
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    for(int j=0;j<2;j++) cin >> a[j] >> b[j] >> c[j] >> d[j];
    if(a[0]-b[0]==0&&c[0]-d[0]==0) cout << "YES" << endl;
    else if(a[1]-b[1]==0&&c[1]-d[1]==0) cout << "YES" << endl;
    else if(a[0]*d[0]+a[1]*d[1]==b[0]*c[0]+b[1]*c[1]) cout << "YES" << endl;
    else cout << "NO" << endl;
  }   
  return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main() {
	int n;
	cin >> n;
	for (int z = 0; z < n; z++) {
		long float x1, x2, x3,y1, y2, y3, y4, x4 ;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		if (y1 > y2) {
			swap(y1, y2);
			swap(x1, x2);
		}
		if (y3 > y4) {
			swap(y3, y4);
			swap(x3, x4);
		}
		if ((x1 > x2&&x3 > x4 && ((y2 - y1) / (x1 - x2) == (y4 - y3) / (x3 - x4))) || (x2 > x1&&x4 > x3 && ((y1 - y2) / (x2 - x1) == (y3 - y4) / (x4 - x3)))) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
}

C++: #include<iostream>

using namespace std;

int main(){
	int n;
	cin >> n;

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

	while (n--){
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		cout <<(( (y2 - y1)*(x4 - x3) == (x2 - x1)*(y4 - y3) ) ? "YES\n" : "NO\n");
	}

	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
using namespace std;

int main() {

    int n;
    cin >> n;

    double a, b, c, d, e, f, g, h;
    while(cin >> a >> b >> c >> d >> e >> f >> g >> h) {
        double vx = c - a;
        double vy = d - b;
        double wx = g - e;
        double wy = h - f;

        if(vx * wy - vy * wx == 0) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
     
    return 0;
}

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

/* ?¨±?????????????????*/
#define EPS (1e-10)
/* 2?????????????????????????????????????????? */
#define EQ(a,b) (abs((a)-(b)) < EPS)

/* ?????? (cross product) : a??b = |a||b|sin */
double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}


/* 2??´?????????????????? : a//b <=> cross(a, b) = 0 */
int isParallel(P a1, P a2, P b1, P b2) {
  return EQ( cross(a1-a2, b1-b2), 0.0 );
}

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

  while(n--) {
    cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy;
    P a(ax, ay), b(bx, by), c(cx, cy), d(dx, dy);
    cout << (isParallel(a, b, c, d) ? "YES" : "NO") << endl;
  }

  return 0;
}