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<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;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	while(n-- >0 ){
            vector<double>x(4),y(4);
            for(int i=0;i<4;i++)
	             cin>>x[i]>>y[i];
	    if( fabs((x[1]-x[0])*(y[3]-y[2]) - (x[3]-x[2])*(y[1]-y[0])) <1.0e-10  )          
			cout << "YES" << endl;
            else
                       cout << "NO" << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <sstream>
using namespace std;
int main(){
	double a,b,c,d,e,f,g,h;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a>>b>>c>>d>>e>>f>>g>>h;
		if((d-b)/(c-a)==(h-f)/(g-e)){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}

C++: #include <stdio.h>

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

int main() {
	int n;
	scanf("%d", &n);
	rep(q, n) {
		double x[4], y[4];
		rep(i, 4) scanf("%lf%lf", x+i, y+i);
		double x1=x[1]-x[0], x2=x[3]-x[2], y1=y[1]-y[0], y2=y[3]-y[2];
		if(x1*y2-x2*y1==0) printf("YES\n");
		else printf("NO\n");
	}
}

C++: #include <stdio.h>
#include <math.h>

int
main(void)
{
	char line[100];
	int n;

	if (fgets(line, sizeof line, stdin) == NULL) {
		return 1;
	}
	if (sscanf(line, "%d", &n) != 1) {
		return 1;
	}

	for (int i = 0; i < n; i++) {
		if (fgets(line, sizeof line, stdin) == NULL) {
			return 1;
		}
		
		double x1, y1, x2, y2, x3, y3, x4, y4;
		
		if (sscanf(line, "%lf %lf %lf %lf %lf %lf %lf %lf",
				   &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4) != 8) {
			return 1;
		}
		
		double a = INFINITY;
		double b = INFINITY;

		if (x1 != x2) {
			a = (y2 - y1)/(x2 - x1);
		}
		if (x3 != x4) {
			b = (y4 - y3)/(x4 - x3);
		}
		
		printf("%s\n", ((a == b) ? "YES" : "NO"));
	}

	return 0;
}