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() {
double x1,x2,x3,x4,y1,y2,y3,y4;
int n;
cin>>n;
for(int jjj=1;jjj<=n;jjj++){
	cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
	if(x1==x2||x3==x4){
		if(x3==x4&&x1==x2){
			cout<<"YES"<<endl;
		}
		else{
			cout<<"NO"<<endl;
		}}
	else{
		if((y2-y1)/(x2-x1)==(y4-y3)/(x4-x3)){
			cout<<"YES"<<endl;
		}
		else{
			cout<<"NO"<<endl;
		}
	}	
	}

	return 0;
}

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

  return 0;

}

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

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

int main(){
  double a,b,c,d,e,f,g,h,m[4];
  int s;
  cin>>s;
  for(int j=0;j<s;j++){
    cin>>a>>b>>c>>d>>e>>f>>g>>h;
    m[0]=c-a;
    m[1]=g-e;
    m[2]=d-b;
    m[3]=h-f;
    if(m[2]*m[0]==m[3]*m[1])cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<queue>
#include<vector>
using namespace std;

int main() {
	double x1, y1, x2, y2, x3, y3, x4, y4;
	int n;
	cin >> n;
	while (n--) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		if ((y2 - y1) / (x2 - x1) == (y4 - y3) / (x4 - x3))
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

C++: //C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<long long,long long> P;
double eps=1e-10;
int main(){
  int d;
  cin>>d;
  for(int dd=0;dd<d;dd++){
  double x1,x2,x3,x4,y1,y2,y3,y4;
  cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
  double c=(x2-x1)*(y3-y4)-(y2-y1)*(x3-x4);
  if(abs(c)<eps)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  }
}

C++: #include<bits/stdc++.h>
#define P pair<int,int>
using namespace std;
 
int main(){
    int a;
    cin>>a;
    double b[12];
    for(int c=0;c<a;c++){
	for(int d=0;d<8;d++)scanf("%lf",&b[d]);
	b[8]=b[2]-b[0];
	b[9]=b[3]-b[1];
	b[10]=b[6]-b[4];
	b[11]=b[7]-b[5];
	if(b[8]/b[9]==b[10]/b[11])puts("YES");
	else puts("NO");
	}
    }

C++: #include "bits/stdc++.h"

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define PI 3.14159265358979

#define _CRT_SECURE_NO_WARNINGS

using namespace std;

//================================================
bool func(vector<LD>x, vector<LD>y) {
	LD A = (y[1] - y[0]) * (x[1] - x[0]);
	LD B = (y[3] - y[2]) * (x[3] - x[2]);

	if (A == B) return true;
	else return false;	
}


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int num;
	cin >> num;

	REP(i, num) {
		vector<LD>x(4);
		vector<LD>y(4);

		REP(i, 4) cin >> x[i] >> y[i];
		cout << (func(x, y) ? "YES" : "NO") << "\n";
	}
	return 0;
}

C++: //C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<long long,long long> P;
double eps=1e-9;
int main(){
  int d;
  cin>>d;
  for(int dd=0;dd<d;dd++){
  double x1,x2,x3,x4,y1,y2,y3,y4;
  cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
  double c=(x2-x1)*(y3-y4)-(y2-y1)*(x3-x4);
  if(abs(c)<eps)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  }
}

C++: /*
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_3_A&lang=jp
所要時間は15分程度。一つ目の例題をACしてしまえばやるだけといいった印象。
着席位置は{中央x中央}
*/


#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<complex>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::make_pair;
using std::vector;
using std::queue;
using std::deque;
using std::priority_queue;
using std::next_permutation;
//using std::iota;
using std::sort;
using std::greater;
using std::max;
using std::min;
using std::abs;
using std::complex;

#define INF 999999999;
#define MOD 1000000007

using ulli = unsigned long long int;

//#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

using Comp = complex<double>;

int n;
double x1, y1n, x2, y2, x3, y3, x4, y4;

int main(){
	cin.tie(0);
	std::ios::sync_with_stdio(false);

    scanf("%d", &n);
    for(int i = 0; i < n; i++){
            scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1n, &x2, &y2, &x3, &y3, &x4, &y4);
            //printf("%f %f %f %f %f %f %f %f", x1, y1n, x2, y2, x3, y3, x4, y4);
            Comp ab = Comp(x2-x1, y2-y1n);
            Comp cd = Comp(x4-x3, y4 - y3);
            double s = ab.real() * cd.imag() - ab.imag()*cd.real();
            //dbug(s)
            if(abs(s) < 0.0000000001) printf("YES\n");
            else printf("NO\n");
    }

    return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

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

typedef complex<double> P;
struct Line : public vector<P>
{
  Line(P a=P(), P b=P()) {
    push_back(a); push_back(b);
  }
};

double cross(P const& a, P const& b) {
  return imag(conj(a)*b);
}

bool is_parallel(Line const& s, Line const& t) {
  return abs(cross(s[1]-s[0], t[1]-t[0])) < 1e-5;
}

int main() {
  int N; cin >> N;
  rep(tc, 2) {
    P ps[4]; rep(i, 4) cin >> ps[i].real() >> ps[i].imag();
    cout << (is_parallel(Line(ps[0], ps[1]), Line(ps[2], ps[3])) ? "YES\n" : "NO\n");
  }
}

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

int main(){
	double x1,x2,x3,x4,y1,y2,y3,y4;
	double a1=0,a2=0;
	char hantei1,hantei2;
	int n,i;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
		
		if(x1!=x2)a1=(y1-y2)/(x1-x2);
		else if(x1==x2)hantei1='T';
		if(x3!=x4)a2=(y3-y4)/(x3-x4);
		else if(x3==x4)hantei2='T';
		
	if(a1==a2 || hantei1==hantei2)printf("YES\n");
	else printf("NO\n");
		
		hantei1='A';
		hantei2='B';
		a1=0;
		a2=0;
	}
	
	
return 0;
}