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<iostream>
using namespace std;
int main(){
	int n=0,ax[100],ay[100],bx[100],by[100],cx[100],cy[100],dx[100],dy[100];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>ax[i]>>ay[i]>>bx[i]>>by[i]>>cx[i]>>cy[i]>>dx[i]>>dy[i];
	}
	for(int i=0;i<n;i++){
		int A=0,B=0;
		A=ax[i]*by[i]-bx[i]*ay[i];
		B=cx[i]*dy[i]-dx[i]*cy[i];
		if(A==B){
			cout<<"YES"<<endl;
		}
		else{
			cout<<"NO"<<endl;
		}
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n; cin >> n;
  for (int _ = 0; _ < n; ++_) {
    double xa, ya, xb, yb; cin >> xa >> ya >> xb >> yb;
    double th0 = atan2(yb - ya, xb - xa);
    double xc, yc, xd, yd; cin >> xc >> yc >> xd >> yd;
    double th1 = atan2(yd - yc, xd - xc);
    cout << (abs(th1 - th0) < 1e-10 ? "YES" : "NO") << '\n';
  }
}

C++: //#define _USE_MATH_DEFINES
//#include <cmath>
#include <iostream>
//#include <stdio.h>
//#include <stdlib.h>
//#include <iomanip>
//#include <vector>
#include <string>
//#include <algorithm>
//#include <functional>
//#include <time.h>
//#include <sstream>
//#include <queue>

using namespace std;


int main(){

	int n;
	double p[8];
	double k1, k2;
	bool ans = false;

	cin >> n;

	while (n--){
		ans = false;
		for (int i = 0; i < 8; i++){
			cin >> p[i];
		}

		if (p[0] == p[2] || p[4] == p[6]){
			if (p[0] == p[2] && p[4] == p[6])ans = true;
		}
		else{
			k1 = (p[3] - p[1]) / (p[2] - p[0]);
			k2 = (p[7] - p[5]) / (p[6] - p[4]);
			if (k1 == k2)ans = true;
			if (k1 > k2 && (k1 -k2 ) < 0.000000001) ans = true;
			if (k2 > k1 && (k2 - k1) < 0.000000001) ans = true;
		}

		cout << (ans ? "YES" : "NO") << endl;
	}


	return 0;
}

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

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

using namespace std;
typedef long long ll;

typedef long double R;
typedef complex<R> P;

const R EPS = 1e-13;
const R PI = acos(-1);
int sgn(R a) {
    if (a < -EPS) return -1;
    if (a > EPS) return 1;
    return 0;
}


bool near(P a, P b) {
    return !sgn(abs(a-b));
}

void solve() {
    P p[4];
    for (int i = 0; i < 4; i++) {
        double x, y;
        cin >> x >> y;
        p[i] = P(x, y);
    }
    double r1 = arg(p[1]-p[0]);
    double r2 = arg(p[3]-p[2]);
    if (r1 < 0) r1 += PI;
    if (r2 < 0) r2 += PI;
    if (sgn(r1-r2)) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        solve();
    }
    return 0;
}

C++: // Parallelism
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0021& lang=jp
// https://onlinejudge.u-aizu.ac.jp/#/problems/0021
// 中央×前

#include <iostream>
#include <vector>
#include <string>
#include <complex>
using namespace std;

#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define REP(i,n) for(int i=0;i<n;i++)
#define pb push_back


// vectorの中身をcout << vs;で表示
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
    o << "{";
    for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i];
    o << "}";
    return o;
}

typedef complex<double> xy_t;
const double eps = 1e-11;

double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }

double signed_area(xy_t v1, xy_t v2) {
	return cross_product(v1, v2) / 2;
}

bool is_pararell(xy_t a, xy_t b, xy_t c, xy_t d) {
	xy_t v1 = xy_t(b.real()-a.real(), b.imag()-a.imag());
	xy_t v2 = xy_t(d.real()-c.real(), d.imag()-c.imag());

	// cout << signed_area(v1, v2) << endl;

	if (abs(signed_area(v1, v2)) < eps) return true;
	else return false;
}


int main(void) {
	// cin, coutの結びつきを解除し、速くする
	cin.tie(0);
   	ios::sync_with_stdio(false);

	int n; cin >> n;
	vector<string> vs;
	while(n--) {
		double x1, x2, x3, x4;
		double y1, y2, y3, y4;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		xy_t a = xy_t(x1, y1);
		xy_t b = xy_t(x2, y2);
		xy_t c = xy_t(x3, y3);
		xy_t d = xy_t(x4, y4);
		if (is_pararell(a, b, c, d)) vs.pb("YES");
		else vs.pb("NO");
	}

	for (auto v:vs) {
		if (v == "YES") YES;
		else NO;
	}


}

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

using namespace std;

void myswap(double* a,double* b)
{
	double temp=*a;
	*a=*b;
	*b=temp;
}
int main()
{
	double x1,x2,x3,y1,y2,y3,x4,y4;
	int n;
	double AB,CD; 

	cin>>n;

	for(int i=0;i<n;i++)
	{
		cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
		if(x1>x2)
		{
			myswap(&x1,&x2);
			myswap(&y1,&y2);
		}
		if(x3>x4)
		{
			myswap(&x3,&x4);
			myswap(&y3,&y4);
		}

		if((x2-x1)==0||(x4-x3)==0)
		{
			if((x2-x1)==0&&(x4-x3)==0)
			{
				cout<<"YES"<<endl;
			}
			else
			{
				cout<<"NO"<<endl;
			}
			continue;
		}
		
		AB=(y2-y1)/(x2-x1);
		CD=(y4-y3)/(x4-x3);
		if(AB<CD)
		{
			myswap(&AB,&CD);
		}

		if((AB-CD)<0.001)
		{
			cout<<"YES"<<endl;
		}
		else
		{
			cout<<"NO"<<endl;
		}

	}
	

	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <climits>
using namespace std;

int main(){
    double EPS = 1e-12;
    double x[4];
    double y[4];
    double s;
    double t;
    double u;
    double v;
    int n;
    cin >> n;

    for (int t = 0;t < n;++t) {
        for (int i = 0;i < 4;++i){
            cin >> x[i] >> y[i]; 
        }
    }
    s = x[1] - x[0];
    t = y[1] - y[0];
    u = x[3] - x[2];
    v = y[3] - y[2];

    if(s * v - t * u > 0){
        double m = s * v - t * u;
    }
    else{
        double m = t * u - s * v;
    }


    cout << "NO" << endl;
}

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

#define m1 (y2 - y1) / (x2 - x1)
#define m2 (y4 - y3) / (x4 - x3)

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

C++: #include<stdio.h>
int main(void)
{
	int n;
	int i,j;
	double x[5],y[5];
	double xx,yy;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		for(j=0;j<4;j++){
			scanf("%lf %lf",&x[j],&y[j]);
		}
		xx=x[2]-x[0];
		yy=y[2]-y[0];
		if(x[3]-x[1]==xx && y[3]-y[1]==yy){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}
	return 0;
}