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(){
    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);

    x2 -= x1;
    y2 -= y1;
    x4 -= x3;
    y4 -= y3;

    if(x2 == 0 || x4 == 0){
        if(x2 == 0 && x4 == 0){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }else{
        if(y2/x2 == y4/x4){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }

    return 0;
}

C++: #include	<iostream>
#include	<cstdio>
#include	<cmath>

using namespace std;

int main(void) {
	int ds;
	cin >> ds;
	
	for(int i = 0; i < ds; i++) {
		double X[4], Y[4];
		double a1, a2;
		double b1, b2;
		
		for(int j = 0; j < 4; j++) {
			cin >> X[j] >> Y[j];
		}
		a1 = abs(Y[1] - Y[0]);
		b1 = (X[1] - X[0]);
		
		a2 = abs(Y[3] - Y[2]);
		b2 = (X[3] - X[2]);
		
		a1 /= b1;
		a2 /= b2;
		
		if(a1 == a2) {
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

C++: #include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;


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

const double EPS = 1e-6;
const double INF = 100000000;

bool solve(double x1,double y1,double x2,double y2,double x3,double y3,double x4,double y4){
    double ax,ay,bx,by;
    ax=x2-x1;ay=y2-y1;
    bx=x4-x3;by=y4-y3;
    double A=ay/ax;
    double B=by/bx;
    
    
    if(A-B < EPS)return true;
    else return false;
    
}



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;
        cout<<(solve(x1, y1, x2, y2, x3, y3, x4, y4)? "YES":"NO")<<endl;
        
    }

    return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <algorithm>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#define swap(a,b) {a=a+b; b=a-b; a=a-b;}
#define abs(a) (a > 0 ? a:-a)

using namespace std;


void q21() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		double ax, ay, bx, by, cx, cy, dx, dy;
		cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy;
		if (bx - ax == 0 || dx - cx == 0) {
			if (bx - ax == dx - cx) {
				cout << "YES" << endl;
				continue;
			}
		}
		else if (abs((by - ay) / (bx - ax) - (dy - cy) / (dx - cx)) <= 0.001 ){
			cout << "YES" << endl;
			continue;
		}
		cout << "NO" << endl;
	}
}

int main() {
	q21();
	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>
#include <vector>
#include <list>
#include <iterator>

#include <cmath>

typedef std::pair<double,double> Vec;
typedef std::pair<Vec,Vec> Line;

Vec operator+(const Vec& lhs, const Vec& rhs) {
	return std::make_pair(lhs.first+rhs.first, lhs.second+rhs.second);
}

Vec operator-(const Vec& lhs, const Vec& rhs) {
	return std::make_pair(lhs.first-rhs.first, lhs.second-rhs.second);
}

Vec lineToVec(const Line& l) {
	return l.first - l.second;
}

double cross(const Vec& lhs, const Vec& rhs) {
  return lhs.first*rhs.second - lhs.second*rhs.first;
}

int main(void){
	using namespace std;

	int n;
	cin >> n;

	vector< pair<Line,Line> > input;
	input.reserve(n);

	double x1,y1,x2,y2,x3,y3,x4,y4;
	while(cin
		>> x1 >> y1
		>> x2 >> y2
		>> x3 >> y3
		>> x4 >> y4){

		auto AB = make_pair( make_pair(x1,y1), make_pair(x2,y2) );
		auto CD = make_pair( make_pair(x3,y3), make_pair(x4,y4) );

		input.push_back(make_pair(AB,CD));
	}

	for(auto itr=input.begin(); itr!=input.end(); itr++){
		auto AB = itr->first;
		auto CD = itr->second;

		auto cr = cross( lineToVec(AB), lineToVec(CD) );

		if( abs(cr) <10e-200 ){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
}

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

int main(){
	double a[8];
	int n;
	cin >> n;
	while (n--) {
		for (int i = 0; i < 8; i++) cin >> a[i];
		int dx1 = (a[0] - a[2]) / (a[1] - a[3]);
		int dx2 = (a[4] - a[6]) / (a[5] - a[7]);
		if (dx1 == dx2) printf("YES\n");
		else printf("NO");
	}
	return 0;
}

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

using namespace std;

typedef complex<double> P;

#define EPS (1e-10)
#define EQ(a, b) (abs((a) - (b)) < EPS)
#define EQV(a, b) ((EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()))

double cross(P a, P b) 
{
    return (a.real() * b.imag() - a.imag() * b.real());
}

bool is_parallel(P a1, P a2, P b1, P b2) 
{
    return EQ(cross(a1 - a2, b1 - b2), 0.0);
}


int main()
{
    int num;
    double  x1, y1, x2, y2, x3, y3, x4, y4;
    
    cin >> num;
    for (int i = 0; i < num; i++) {
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
        
        if (is_parallel(P(x1, y1), P(x2, y2), P(x3, y3), P(x4, y4)))
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }

    return 0;
}

C++: #include<iostream>

using namespace std;

bool get_line( double x1 , double x2 , double y1 , double y2 , double& a , double& b );

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

	double a1, a2;
	double b1, b2;

	bool result1 , result2;

	int num;

	cin >> num;

	for( int i = 0 ; i < num ; i++ )
	{
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;

		result1 = get_line( x1 , x2 , y1 , y2 , a1 , b1 );
		result2 = get_line( x3 , x4 , y3 , y4 , a2 , b2 );

		if( result1 == false && result2 == false ) cout << "YES" << endl;

		else
		{
			if( a1 != a2 ) cout << "NO" << endl;
			else cout << "YES" << endl;
		}
	}

	return 0;
}

bool get_line( double x1 , double x2 , double y1 , double y2 , double& a , double& b )
{
	if( x1 - x2 >= -0.0001 && x1 - x2 <= 0.0001 ) return false;

	a = ( y1 - y2 ) / ( x1 - x2 );
	b = y1 - a * x1;

	return true;
}

C++: #include <stdio.h>

int
main(void)
{
	int n;

	scanf("%d", &n);

	double x1, y1, x2, y2, x3, y3, x4, y4;
	
	while (n--) {
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf",
				   &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);

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

	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 (abs((y2 - ya1) / (x2 - x1) - (y4 - y3) / (x4 - x3)) <= 0.00000000001)
					cout << "YES" << endl;
				else cout << "NO" << endl;
			}
		}
	}

	return 0;
}

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