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(void)
{
	double x[4];
	double y[4];
	int n;
	cin >> n;
	while(n--){
		for(int i=0; i<4; i++){
			cin >> x[i] >> y[i];
		}
		double d1,d2;
		d1 = (y[1]-y[0])/(x[1]-x[0]);
		d2 = (y[3]-y[2])/(x[3]-x[2]);
		if(d1==d2) 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.00001;
}

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;  
  if (!isZero(diff_x12) && !isZero(diff_x34)) {
    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 <bits/stdc++.h>
using namespace std;
using ld = long double;

int main()
{
	int n;
	ld x1, x2, x3, x4, y1, y2, y3, y4;
	cin >> n;
	while (n--) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		ld dx1 = x2 - x1, dy1 = y2 - y1;
		ld dx2 = x4 - x3, dy2 = y4 - y3;
		if (abs(dx1 * dy2 - dy1 * dx2) < 1e11 && (dx1 * dx2 >= 1e11 || (dx1 == 0 && dy2 == 0 && dy1 * dy2 > 0))) {
			puts("YES");
		}
		else {
			puts("NO");
		}
	}
	return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

typedef long long ll;

int n;
double x[5];
double y[5];

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 4; j++) {
			cin >> x[j] >> y[j];
		}

		double k = (x[1] - x[0])*(x[3] - x[2]) + (y[1] - y[0])*(y[3] - y[2]);
		double j = sqrt((x[1] - x[0])*(x[1] - x[0]) + (y[1] - y[0])*(y[1] - y[0]))*sqrt((x[3] - x[2])*(x[3] - x[2]) + (y[3] - y[2])*(y[3] - y[2]));
		if (fabs(k - j) < EPS || fabs(k + j) < EPS)cout << "YES" << endl;
		else cout << "NO" << endl;
	}

	
	return 0;
}

C++: #include<iostream>
#define DFF 1e-10
using namespace std;
int main(){
  int n;
  cin >>n;
  while(n--){
    double p[4][2],ans;
    for(int i=0; i<4; i++) for(int j=0; j<2; j++) cin >>p[i][j];
    for(int i=0; i<2; i++) for(int j=0; j<2; j++) p[i*2+1][j]-=p[i*2][j];
    ans = p[1][0]*p[3][1]-p[1][1]*p[3][0];
    if(ans>-DFF && ans<DFF) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}

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

using namespace std;
const double EPS = 1e-10;

int main()
{
	double xa, ya, xb, yb, xc, yc, xd, yd;
	double AB, CD;
	int num = 0, i = 0;

	cin >> num;
	while ( i < num )
	{
		cin >> xa >> ya >> xb >> yb >> xc >> yc >> xd >> yd;
		if ( fabs( ( xa - xb ) * ( yc - yd ) - ( xc - xd ) * ( ya - yb ) ) < EPS )
		{	
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}

		i = i + 1;
	}

	return 0;
}

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(cross_product(AB, CD) == 0.00000)
      cout << "YES" << endl;
    else 
      cout << "NO" << endl;
  }
}

C++: #include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

int main(){
    int mod=1000000007;
    int n;
    scanf("%d",&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 (abs((y3-y4)*(x1-x2)-(y1-y2)*(x3-x4))<1e-10) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

int main() {
  int n;
  cin >> n;
  
  REP(i, n) {
    double x[4], y[4];
    REP(i, 4) cin >> x[i] >> y[i];

    double x1, x2, y1, y2;
    x1 = x[0] - x[1];
    y1 = y[0] - y[1];
    x2 = x[2] - x[3];
    y2 = y[2] - y[3];
    
    if(abs(x1 * y2 - x2 * y1) < EPS) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
}

C++: #include<bits/stdc++.h>
using namespace std;

#define EPS 0.0000001

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(abs((y2-y1)*(x4-x3)-(y4-y3)*(x2-x1)) <EPS )cout << "YES" << endl;
      else cout << "NO" << endl;
    }


  return 0;
}

C++: #include <bits/stdc++.h>
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;
}