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)
{
    int i;

    int datesets;
    scanf("%d", &datesets);

    while (datesets--) {
        double x[4], y[4];
        for (i = 0; i < 4; i++) {
            scanf(" %lf %lf", &x[i], &y[i]);
        }

        double judge = (x[0] - x[1]) * (y[2] - y[3])
                        - (x[2] - x[3]) * (y[0] - y[1]);
        if (judge == 0) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }
    }

    return 0;
}

C++: #include<iostream>
#define rep(i,x) for(int i=0;i<x;i++)
using namespace std;
int main(){
    int n;
    cin>>n;
    while(n--){
        double a[4][2];
        rep(i,4)rep(j,2)cin>>a[i][j];
        double line1=(a[1][1]-a[0][1])/(a[1][0]-a[0][0]);
        double line2=(a[3][1]-a[2][1])/(a[3][0]-a[2][0]);
        if(line1==line2)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int n;
double xa, ya, xb, yb, xc, yc, xd, yd, d1, d2;

int main() {
	scanf("%d",&n);
	rep(i,n) {
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &xa, &ya, &xb, &yb, &xc, &yc, &xd, &yd);
		if (xa==xb) d1 = 1e200;
		else d1 = (yb-ya)/(xb-xa);
		if (xc==xd) d2 = 1e200;
		else d2 = (yd-yc)/(xd-xc);
		if (abs(d1-d2)<1e-10) printf("YES\n");
		else printf("NO\n");
	}
}

C++: a#include <iostream>

using namespace std;



struct pt {

	double x;

	double y;

};



int main() {

	int num;

	cin >> num;

	while(num--) {

		pt p1, p2, p3, p4;

		cin >> p1.x >> p1.y;

		cin >> p2.x >> p2.y;

		cin >> p3.x >> p3.y;

		cin >> p4.x >> p4.y;

		pt v1 = {p1.x-p2.x, p1.y-p2.y};

		pt v2 = {p3.x-p4.x, p3.y-p4.y};

		if (v1.y==0 && v2.y==0) cout << "YES\n";

		else if (v1.x/v1.y == v2.x/v2.y) cout << "YES\n";

		else cout << "NO\n";

	}

	return 0;

}

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

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

    cin >> num;

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

        cross = abs((x2 - x1) * (y4 - y3) - (y2 - y1) * (x4 - x3));
        if(cross < 1e-11){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" << endl;
        }
    }
    return 0;
}

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

using namespace std;

void swap(double &x, double &y, double &xx, double &yy) 
{
  double tmp_x = x;
  double tmp_y = y;
  x = xx;
  y = yy;
  xx = tmp_x;
  yy = tmp_y;
}

bool isZero(double x) 
{
  return x < 0.000001;
}

void compute(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) 
{
  if (x1 > x2) swap(x1, y1, x2, y2);
  if (x3 > x4) swap(x3, y3, x4, y4);

  double diff_x12 = x2 - x1;
  double diff_y12 = y2 - y1;
  double diff_x34 = x4 - x3;
  double diff_y34 = y4 - y3;

  if (isZero(diff_x12) && isZero(diff_y12))
    cout << "NO" << endl;
  else if (isZero(diff_x34) && isZero(diff_y34))
    cout << "NO" << endl;  
  else if (!isZero(diff_x12) && !isZero(diff_x34)) {
    if (isZero(diff_y12) && isZero(diff_y34))
      cout << "YES" << endl;
    else {
      double ab = diff_y12 / diff_x12;
      double cd = diff_y34 / diff_x34;
      if (isZero(abs(ab - cd)))
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    }
  }
  else if (isZero(diff_x12) && isZero(diff_x34)) 
    cout << "YES" << endl;  
  else
    cout << "NO" << endl;  
}

int main(void) 
{
  int n;
  cin >> n;
  for (int i=0; i < n; i++) {
    double x1, y1, x2, y2, x3, y3, x4, y4;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
    compute(x1, y1, x2, y2, x3, y3, x4, y4);
  }
  
  return 0;
}

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

using namespace std;

typedef complex<double> Point;

int main() {
    int N;
    cin >> N;
    while(N--) {
        Point ps[4];
        for(int i = 0; i < 4; ++i) cin >> ps[i].real() >> ps[i].imag();
        Point v1 = ps[1]-ps[0], v2 = ps[3]-ps[2];
        /*
        double dot = v1.real()*v2.real() + v1.imag()*v2.imag();
        double n = norm(v1) * norm(v2);
        if(abs(dot*dot - n) < 1e-5) cout << "YES" << endl;
        else cout << "NO" << endl;
        */
        if(abs(arg(v1)-arg(v2)) < 1e-8) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

C++: #include <iostream>

struct Point2D {
	double x, y;
	Point2D operator-(Point2D &inp) {
		Point2D ans;
		ans.x = this->x - inp.x;
		ans.y = this->y - inp.y;
		return ans;
	}
	static double crossZ(Point2D &a, Point2D &b) {
		return a.x * b.y - a.y * b.x;
	}
};

int main() {
	int dataSet;
	Point2D p[4], v[2];
	for (std::cin >> dataSet; dataSet > 0; --dataSet) {
		std::cin >> p[0].x >> p[0].y >> p[1].x >> p[1].y >> p[2].x >> p[2].y >> p[3].x >> p[3].y;
		v[0] = p[1] - p[0];
		v[1] = p[3] - p[2];
		std::cout << ((Point2D::crossZ(v[0], v[1]) == 0.) ? "YES" : "NO") << '\n';
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef complex<double> xy_t; 
xy_t a[100], b[100], c[100], d[100];
double x, y;
int n;
int main()
{
	cin >> n;
	for(int i=0; i<n; i++)
	{
		cin >> x >> y;
		a[i]=xy_t(x, y);
		cin >> x >> y;
		b[i]=xy_t(x, y);
		cin >> x >> y;
		c[i]=xy_t(x, y);
		cin >> x >> y;
		d[i]=xy_t(x, y);
	}
	for(int i=0; i<n; i++)
	{
		if(abs((conj(b[i]-a[i])*(d[i]-c[i])).imag())<1e-10)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
	return 0;
}

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

struct vec {
	double x, y;
};

static vec P(double x, double y){
	vec P = {x, y};
	return P;
}

static vec sub(vec a, vec b){
	return P(a.x - b.x, a.y - b.y);
}

static double cross(vec a, vec b){
	return (a.x * b.y - a.y * b.x);
}

int main(void){
    
int n;
cin >> n;
double x1, y1, x2, y2, x3, y3, x4, y4;
for(int i = 0; i < n; i++){
	cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
	vec v1 = P(x1, y1);
	vec v2 = P(x2, y2);
	vec v3 = P(x3, y3);
	vec v4 = P(x4, y4);
	vec a = sub(v1, v2);
	vec b = sub(v3, v4);
	if (cross(a, b) == 0)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
return 0;

}

C++: #include "bits/stdc++.h"
using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
const double pi = acos(-1);
const double EPS = 1e-8;

double cross(pair<double,double> c,pair<double,double> d){
  return c.first * d.second - d.first * c.first;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<pair<double,double>> a(4);
  int n;
  pair<double,double> lineab, linecd;
  cin >> n;
  REP(i,n){
    REP(j,4){
      cin >> a[j].first >> a[j].second;
    }
    lineab.first = a[1].first - a[0].first;
    linecd.first = a[3].first - a[2].first;
    lineab.second = a[1].second - a[0].second;
    linecd.second = a[3].second - a[2].second;
    if (cross(lineab,linecd) == 0) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  
  
  return 0;
}