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;
  double x[4],y[4];
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<4;j++)
      cin>>x[j]>>y[j];
    if((x[3]-x[2])==0&&(x[1]-x[0])==0) cout<<"YES"<<endl;
    else if((x[3]-x[2])==0||(x[1]-x[0])==0) cout<<"NO"<<endl;
    else if((y[3]-y[2])/(x[3]-x[2])==(y[1]-y[0])/(x[1]-x[0])) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
    int n;
    double x1,x2,x3,x4,y1,y2,y3,y4;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;

        double line1,line2;
        line1=(y2-y1)/(x2-x1);
        line2=(y4-y3)/(x4-x3);
        (line1==line2)? cout<<"YES"<<endl : cout<<"NO"<<endl;
    }
    return 0;
}

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

struct vec{
	double x;
	double y;
};

int main(){
	int n;
	cin>>n;
	double x[4],y[4];//0:A 1:B 2:C 3:D
	rep(i,n){
		rep(j,4)cin>>x[j]>>y[j];
		vec ABvec;
		vec CDvec;
		ABvec.x=x[1]-x[0];
		ABvec.y=y[1]-y[0];
		CDvec.x=x[3]-x[2];
		CDvec.y=y[3]-y[2];
		double elmeet=abs(ABvec.x*CDvec.x+ABvec.y*CDvec.y);
		double ABnolme=sqrt(pow(ABvec.x,2)+pow(ABvec.y,2));
		double CDnolme=sqrt(pow(CDvec.x,2)+pow(CDvec.y,2));
		if(abs(ABnolme*CDnolme-elmeet)<10e-7)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include <string>
#include<stdio.h>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
	double x1[100], y1[100], x2[100], y2[100], x3[100], y3[100], x4[100], y4[100];
	double tendAB, tendCD;
	int num;
	int pos = 0;

	cin >> num;
	while (num--) {
		cin >> x1[pos] >> y1[pos] >> x2[pos] >> y2[pos] >> x3[pos] >> y3[pos] >> x4[pos] >> y4[pos];
		pos++;
	}
	for (int i = 0; i < pos; i++) {
		tendAB = (y1[i] == y2[1]) ? 0 : (x2[i] - x1[i]) / (y2[i] - y1[i]);
		tendCD = (y3[i] == y4[1]) ? 0 : (x4[i] - x3[i]) / (y4[i] - y3[i]);
		if (tendAB == tendCD) cout << "YES" << endl; else cout << "NO" << endl;
	}

	return 0;
}

C++: #include <iostream>

using namespace std;

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;
		AB = ( ya - yb ) / ( xa - xb );
		CD = ( yc - yd ) / ( xc - xd );
		if ( AB == CD )
		{
			cout << "YES" << endl;
		}
		else if ( AB != CD )
		{
			cout << "NO" << endl;
		}

		i = i + 1;
	}

	return 0;
}

C++: #include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
 
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
 
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD
 
int main(){
int n;
cin>>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);
P a(x2-x1,y2-y1);
P b(x4-x3,y4-y3);
double cr = imag(conj(a)*b);
if(abs(cr)<1e-9){
  cout<<"YES"<<endl;
}else{
  cout<<"NO"<<endl;
}
}
  return 0;
}

C++: #include <cstdio>
#include <cmath>
using namespace std;
const double EPS = 1e-10;
typedef struct{
  double x,y;
}point;

int main(void){
  int n;
  char str[200];
  point A,B,C,D;

  fgets(str,sizeof(str),stdin);
  sscanf(str,"%d",&n);
  while(n--){
    fgets(str,sizeof(str),stdin);
    sscanf(str,"%lf %lf %lf %lf %lf %lf %lf %lf",&A.x,&A.y,&B.x,&B.y,&C.x,&C.y,&D.x,&D.y);
    if(fabs((B.x-A.x)*(D.y-C.y)-(D.x-C.x)*(B.y-A.y)) < EPS){
      printf("YES\n");
    }
    else{
      printf("NO\n");
    }
  }
  return 0;
}

C++: #include<stdio.h>
#include<string.h>
#include<iostream>

using namespace std;
double cross(long double x1,long double y1,long double x2,long double y2);

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


double cross(long double x1,long double y1,long double x2,long double y2){
	return (x1-x2)/(y1-y2);
}

C++: #include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
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;
		cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
		if((x1==x2&&y1==y2)||(x3==x4&&y3==y4))cout<<"NO"<<endl;
		else if(fabs(x2-x1)<0.00000000001&&fabs(x4-x3)<0.00000000001)cout<<"YES"<<endl;
		else if(fabs((y2-y1)/(x2-x1)-(y4-y3)/(x4-x3))<0.0000000000001)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
 
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
 
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD
 
int main(){
int n;
cin>>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);
P a(x2-x1,y2-y1);
P b(x4-x3,y4-y3);
double cr = imag(conj(a)*b);
if(abs(cr)<1e-11){
  cout<<"YES"<<endl;
}else{
  cout<<"NO"<<endl;
}
}
  return 0;
}

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

typedef complex<double> P;

// ?¨±?????????????????
#define EPS (1e-10)
// 2??????????????????????????????????????????
#define EQ(a,b) (abs((a)-(b)) < 0)

// ?????? (cross product) : a??b = |a||b|sin??
double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}

// 2??´?????????????????? : a//b <=> cross(a, b) = 0
int is_parallel(P a1, P a2, P b1, P b2) {
  return EQ( cross(a1-a2, b1-b2), 0.0 );
}

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

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

C++: #include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <math.h>
#include <functional>
#include <algorithm>

typedef long long Int;
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
using namespace std;

int main(){
	int n;
	cin >> n;

	REP(i, n){

		double p[8];
		REP(i, 8){
			cin >> p[i];
		}

		double dx1 = (p[0] - p[2]);
		double dx2 = (p[4] - p[6]);
		double dy1 = (p[1] - p[3]);
		double dy2 = (p[5] - p[7]);


		if (!dx1||!dx2){
			if (!dy1&&!dy2){
				cout << "YES" << endl;
				continue;
			}
			cout << "NO" << endl;
			continue;
		}

		string ans = (dy2/dx2 == dy1/dx1) ? "YES" : "NO";


		cout << ans << endl;
	}
	return 0;
}