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>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb(in,tmp) in.push_back(tmp)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
  int n;
  cin>>n;
  rep(i,n){
    double a=543.5,b=629.3;
    double ax,ay,bx,by,cx,cy,dx,dy;
    cin>>ax>>ay>>bx>>by>>cx>>cy>>dx>>dy;
    int han=0;
    if(bx==ax)han++;
    else a=(by-ay)/(bx-ax);
    if(dx==cx)han++;
    else b=(dy-cy)/(dx-cx);
    //cout<<han<<" "<<a<<" "<<b<<endl;
    if(a==b||han==2)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
}

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

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;
        if ((x2-x1)==0 && (x4-x3)==0)
            cout << "YES" << endl;
        else {
            int d = abs((y2-y1)/(x2-x1) - (y4-y3)/(x4-x3));
            cout << ((d <= 1e-10)? "YES" : "NO") << endl;
        }
    }
    return 0;
}

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

using namespace std;

class Vector2D {
  private:
    double x;
    double y;
  public:
    Vector2D(double, double);
    Vector2D operator - (Vector2D vec2) {
      double newX = this->x - vec2.x;
      double newY = this->y - vec2.y;
      Vector2D newvec(newX, newY);
      return newvec;
    }
    double GetX() { return x; };
    double GetY() { return y; };
    bool isParallel(Vector2D);
};

Vector2D::Vector2D(double _x, double _y) {
  x = _x;
  y = _y;
}

bool Vector2D::isParallel(Vector2D vec2) {
  if (this->x == vec2.GetX() || this->y == vec2.GetY())
    return true;
  else if (abs(vec2.GetY()/this->y) == abs(vec2.GetX()/this->x))
    return true;
  else
    return false;
}

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

  double x1,y1,x2,y2,x3,y3,x4,y4;
  for (int dataset_i = 0; dataset_i < n; dataset_i++) {
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
    Vector2D vecAB = Vector2D(x2,y2) - Vector2D(x1,y1);
    Vector2D vecCD = Vector2D(x4,y4) - Vector2D(x3,y3);
    cout << (vecAB.isParallel(vecCD) ? "YES" : "NO") << endl;
  }

  return 0;
}

C++: #include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

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

    double v1x = x1 - x2, v1y = y1 - y2;
    double v2x = x3 - x4, v2y = y3 - y4;
    double prod = v1x * v2x + v1y * v2y;
    if (prod < 0.0) { prod *= -1; }

    double z1 = sqrt(v1x * v1x + v1y * v1y);
    double z2 = sqrt(v2x * v2x + v2y * v2y);

    puts(abs(prod - z1 * z2) < 0.0000001 ? "YES" : "NO");
  }

  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<cfloat>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

#define PI (3.1415926535)
#define EPS (1e-10)

int main(){
  int n; cin>>n;
  while(n-->0){
    double x1,x2,x3,x4,y1,y2,y3,y4;
    cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
    double xx1 = x1 - x2;
    double yy1 = y1 - y2;
    double xx2 = x3 - x4;
    double yy2 = y3 - y4;
    if(xx1 == 0 && xx2 == 0){
      cout << "YES" << endl;
      continue;
    }
    double r = xx1 / xx2;
    yy2 *= r;
    if(abs(yy1-yy2) < EPS)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  
  return 0;
}

C++: #include <stdio.h>

int
main(void)
{
	int n;

	scanf("%d", &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);

		if ((y2 - y1)/(x2 - x1) == (y4 - y3)/(x4 - x3)) {
			printf("YES\n");
		} else {
			printf("NO\n");
		}
	}

	return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cmath>

using namespace std;
int main(void)
{
	int n;
	double x[4],y[4];
	double k[2];
	scanf("%d",&n);
	for(int i = 0;i < n;i++)
	{
		for(int j = 0;j < 4;j++) scanf("%lf%lf",&x[j],&y[j]);
		k[0] = (y[0]-y[1])/(x[0]-x[1]);
		k[1] = (y[2]-y[3])/(x[2]-x[3]);
		if(k[0] == k[1]) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

C++: #include<iostream>
#include<complex>
#include<cmath>
#include<string>
#include<queue>
using namespace std;
typedef complex<double> xy_t;
int main()
{
  int n;
  double x,y;
  queue<string> qs;
  cin >> n;
  for( int i = 0; i < n; ++i){
    xy_t p[4];
    for( int j = 0; j < 4; ++j){
      cin >> x >> y;
      p[j] = xy_t(x,y);
    }
    double S =(conj(p[0] - p[1])*(p[2] - p[3])).imag();
    if( S == 0) qs.push("YES");
    else qs.push("NO");
  }
  while(!qs.empty()){
    cout << qs.front() << endl;
    qs.pop();
  }
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

#include <complex>
typedef complex<double> Point;
double cross(Point a, Point b){
  return imag(conj(a) * b);
}
struct Line : public vector<Point> {
  Line(Point a, Point b){
    push_back(a);
    push_back(b);
  }
  Point vector(){
    return back() - front();
  }
};
bool parallel(Line l, Line m){
  if(abs(cross(l.vector(), m.vector())) < EPS) return true;
  else return false;
}
Point input(){
  Point p;
  cin >> p.real() >> p.imag();
  return p;
}

int main(){
  int N;
  cin >> N;
  while(N--){
    Point a[4];
    REP(i, 4) a[i] = input();
    if(parallel(Line(a[0], a[1]), Line(a[2], a[3]))){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }
  return 0;
}

C++: #include<stdio.h>
#include<math.h>
 
int main(void)
{
    double x1, x2, x3, x4, y1, y2, y3, y4;
    int i = 0;
    int n;
    double s;
    double eps = 0.0000000001;
     
    scanf("%d", &n);
     
    for(i = 0; i < n; i++) {
        scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &x2, &x3, &x4, &y1, &y2, &y3, &y4);
         
        x2 -= x1;
        y2 -= y1;
        x4 -= x3;
        y4 -= y3;
         
        s = (x2 * y4) - (y2 * x4);
         
        s = abs(s);
         
        if (s < eps) {
            s = 0;
        }
         
        if (s == 0) {
            printf("YES\n");
        }
         
        else {
            printf("NO\n");
        }
    }
     
    return 0;
}