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>
using namespace std;
main(void){
	int T;cin>>T;
	double x1,x2,x3,x4,y1,y2,y3,y4;
	for(int t=1;t<=T;t++){
		cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
		if(abs((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4))<0.0000001)
			cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}

C++: #include <cstdio>

using namespace std;

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

int main()
{
    int n; scanf( "%d\n", &n );
    while( n > 0 ){
        loop:
        scanf("%lf %lf %lf %lf %lf %lf %lf %lf %lf\n", &x1, &y1, &y2, &y2, &y3, &y3, &y4, &y4 );
        double num1 = x2 - x1, num2 = x4 - x3, num3 = y2 - y1, num4 = y4 - y3;
        if( (num1 == 0 && num3 == 0) || (num2 == 0 && num4 == 0 ) )
        {
            printf( "YES\n" );
            n--;
            goto loop;
        }
        else
        {
            num2 /= num1;
            num4 /= num3;
            if( num3 == num4 || num3 == -num4 )
            {
                printf( "YES\n" );
                n--;
                goto loop;
            }
        }
        printf( "NO\n" );
        n--;
    }
}

C++: #include <iostream>

using namespace std;

typedef struct myvector{
  double x;
  double y;
}Vector;

Vector sub_vector(Vector& a, Vector& b)
{
  Vector ret;
  ret.x = b.x - a.x;
  ret.y = b.y - a.y;
  return ret;
}

double cross_product(Vector& a, Vector& b)
{
  return a.x * b.y - b.x * a.y;
}

int main()
{
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    Vector A, B, C, D;
    cin >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y >> D.x >> D.y;
    Vector AB = sub_vector(A, B);
    Vector CD = sub_vector(C, D);
    if(AB.x * CD.y == AB.y * CD.x)
      cout << "YES" << endl;
    else 
      cout << "NO" << endl;
  }
}

C++: #include<iostream>
#include<algorithm>
#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>
#include <utility>
#include <complex>
#include <vector>

using namespace std;

typedef complex<double> point;

const double EPS = 1e-7;
// double cross(point a,point b){
//     return imag(conj(a)*b);
// }
double cross(point a, point b) {
      return (a.real() * b.imag() - a.imag() * b.real());
}

bool is_parallel(point a1,point a2,point b1,point b2){
    return abs(cross(a2-a1,b2-b1)) < EPS;
}

int main(){
    int N;
    cin >> N;
    for(int i=0;i<N;i++){
        vector<point> ps(4);
        for(int j=0;j<4;j++){
            cin >> ps[j].real() >> ps[j].imag();
        }
        if(is_parallel(ps[0],ps[1],ps[2],ps[3])){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
    return 0;
}

C++: #include <cstdio>

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

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

int main() {
	double x[4], y[4];
	double dx[2], dy[2];
	int n;

	scanf("%d", &n);
	for (int i = 0;i < n;i++) {
		for (int k = 0;k < 4;k++) {
			scanf("%lf%lf", x + k, y + k);
		}
		dx[0] = x[1] - x[0];dy[0] = y[1] - y[0];
		dx[1] = x[3] - x[2];dy[1] = y[3] - y[2];

		if (dx[0] * dy[1] == dx[1] * dy[0]) {
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}

	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()
{
//	cut here before submit 
//	freopen("testcase.pl", "r", stdin);
	string str = "";
	int n;

	getline (cin, str );
	stringstream ssn(str);
	ssn >> n;

	int i,j;
	for (i = 0; i < n; ++i){
		vector <double> px (4, 0.0);
		vector <double> py (4, 0.0);
		getline (cin, str );
		stringstream ss(str);
		for (j = 0; j < 4; ++j){
			ss >> px[j] >> py[j];
		} // end for
		map <double, double> v;

		for (j = 0; j < 2; ++j){
			v[px[2*j + 1] - px[2*j]] = py[2*j + 1] - py[2*j];
		} // end for
		if (v.size() == 1){
			cout << "YES" << endl;
			continue;
		} // end if
		map <double, double>::iterator it = v.begin();
		double x = (*it).first;
		double y = (*it).second;
		++it;
		if ( fabs( (*it).first/x - (*it).second/y ) < 1e-6 ){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		} // end if
	} // end for
		
	return 0;
}

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[6]-c[4])/(c[2]-c[0])==(c[7]-c[5])/(c[3]-c[1]))printf("YES\n");
    else printf("NO\n");
    }
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		double x1,y1,x2,y2,x3,y3,x4,y4;
		scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
		if(y1==y2){
			if(y3==y4){
				printf("YES\n");
			}
			else printf("NO\n");
		}
		else if(y3==y4){
			printf("NO\n");
		}
		else{
			if((x1-x2)/(y1-y2)+0.000001>=(x3-x4)/(y3-y4)&&(x1-x2)/(y1-y2)-0.000001<=(x3-x4)/(y3-y4)){
				printf("YES\n");
			}
			else {
				printf("NO\n");
			}
		}
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>

#define PI 3.14159265359

#define INF 99999999;

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

#define EPS 1e-10

typedef long long ll;

using namespace std;



/*
class TheKingsArmyDiv2
{
public:
	int getNumber(vector <string> state)
	{

	}
};
*/


double a, b, c, d, e, f, g, h;
double det()
{
	double dx1, dy1, dx2, dy2;
	
	dx1 = a - c;
	dy1 = b - d;
	dx2 = e - g;
	dy2 = f - h;
	
	return dx1*dy2 - dy1*dx2;
}


int main()
{
	int n;
	
	cin >> n;
	while (n--)
	{
		cin >> a >> b >> c >> d >> e >> f >> g >> h;
		cout << (fabs(det()) < EPS ? "YES" : "NO") << endl;
	}
	
	return 0;
}