Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n := nextInt()
	for i := 0; i < n; i++ {
		scanner.Scan()
		points := strings.Split(scanner.Text(), " ")
		fpoints := make([]float64, 0)
		for _, v := range points {
			tmp, _ := strconv.ParseFloat(v, 64)
			fpoints = append(fpoints, tmp)
		}
		a := (fpoints[1]-fpoints[3])/(fpoints[0]-fpoints[2])
		b := (fpoints[5]-fpoints[7])/(fpoints[4]-fpoints[6])
		if a == b {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

C++: #include<iostream>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<algorithm>

using namespace std;

int main(void)
{
  double x=0.0,y=0.0;
  double x1=0.0,y1=0.0;
  int n=0;
  int i=0;
  double a,b;

  cin>>n;

  for(i=0;i<n;i++)
    {
      cin>>x>>y>>x1>>y1;
      a=(y1-y)/(x1-x);
      cin>>x>>y>>x1>>y1;
      b=(y1-y)/(x1-x);

      if(a==b)
        puts("YES");
      else
        puts("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;
  double x[4],y[4];
  cin>>n;
  for(;n--;){
    for(j=0;j<4;j++){
      cin>>x[j];
      cin>>y[j];
    }

    if((x[0]-x[1])*(y[2]-y[3])==(x[2]-x[3])*(y[0]-y[1]))cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <complex>
#include <cmath>
using namespace std;
typedef complex<double> xy_t;
xy_t P[110];
double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }
const double eps = 1e-11;
int main() {
 int N;
 double x[4], y[4];
 cin >> N;
 for (int t=0; t<N; ++t) {
  for (int i=0; i<4; ++i) {
   cin >> x[i] >> y[i];
  }
  xy_t a[2] = { xy_t(x[0],y[0])-xy_t(x[1],y[1]), xy_t(x[2],y[2])-xy_t(x[3],y[3]) };
  bool p = abs(cross_product(a[0],a[1])/2) < eps;
  cout << (p ? "YES" : "NO") << endl;
 }
}

C++: #include <stdio.h>

double slope(double x1, double x2, double y1, double y2) {

	double slp;

	if ((x1 - x2) == 0 || (y1 - y2) == 0)
		slp = 0;
	else
		slp = (x1 - x2) / (y1 - y2);

	return slp;
}

int main(void)
{
	int n;
	double x1[100], x2[100], x3[100], x4[100], y1[100], y2[100], y3[100], y4[100];
	int i = 0;
	double slope1, slope2;

	scanf("%d",&n);

	while (i < n) {
		scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1[i],&y1[i],&x2[i],&y2[i],&x3[i],&y3[i],&x4[i],&y4[i]);
		i++;
	}

	for (i = 0; i < n; i++) {
		slope1 = slope(x1[i],x2[i],y1[i],y2[i]);
		slope2 = slope(x3[i], x4[i], y3[i], y4[i]);

		printf("slope1 = %lf\n",slope1);

		printf("slope2 = %lf\n", slope2);


		if (slope1 == slope2) {
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}

	return 0;
}

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


int main() {
  int n;
  cin >> n;
  while (n--) {
    float x[4], y[4];
    float eps = 1e-15;
    for (int i = 0; i < 4; i++) cin >> x[i] >> y[i];
    if (((abs(y[3] - y[2]) < eps && abs(x[3] - x[2]) < eps)) || (abs(x[1] - x[0]) < eps && abs(y[1] - y[0]) < eps)) {
      cout << "NO" << endl;
    } else if (abs((y[3] - y[2]) * (x[1] - x[0]) - (y[1] - y[0]) * (x[3] - x[2])) < eps) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}

C++: 
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>

using namespace std;


bool solve(){
	double x[4],y[4];
	for(int i=0;i<4;i++){
		cin>> x[i]>> y[i];
	}
	double rad1 = atan2(y[1]-y[0],x[1]-x[0]);
	double rad2 = atan2(y[3]-y[2],x[3]-x[2]);
	if(rad1 == rad2){
		cout<< "YES"<< endl;
	}else{
		cout<< "NO"<< endl;
	}
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	int n;
	cin>> n;
	for(int i=0;i<n;i++){
		solve();
	}
	return 0;
}

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


int main(){
	double x1,x2,x3,x4,y1,y2,y3,y4,value1,value2;
	int n;
	scanf("%d",&n);
	for(int i=0; i<n; i++){
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
		value1 = (y1-y2)/(x1-x2);
		value2 = (x3-x4)/(y3-y4);

		if(value1 == value2){
			printf("YES\n");
		}else{
			printf("NO\n");
		}

	}
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9 + 7;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
const int mod = 1e9 + 7;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
using Point = complex<double>;
double dot(Point a, Point b) {return real(conj(a) * b);}
double cross(Point a, Point b) {return imag(conj(a) * b);}

int main() {
    int n; cin >> n;
    while (n--) {
        double xa, ya, xb, yb, xc, yc, xd, yd;
        cin >> xa >> ya >> xb >> yb >> xc >> yc >> xd >> yd;
        //cout << cross(Point(xa - xb, ya - yb), Point(xc - xd, yc - yd)) << endl;
        if (abs(cross(Point(xa - xb, ya - yb), Point(xc - xd, yc - yd))) < 1e-12) {
            cout << "YES" << endl;
        } else cout << "NO" << endl;
    }
}

C++: // 2014/07/21 Tazoe

#include <iostream>
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;

		int X1 = (int)(x1*100000.0);
		int Y1 = (int)(y1*100000.0);
		int X2 = (int)(x2*100000.0);
		int Y2 = (int)(y2*100000.0);
		int X3 = (int)(x3*100000.0);
		int Y3 = (int)(y3*100000.0);
		int X4 = (int)(x4*100000.0);
		int Y4 = (int)(y4*100000.0);

		long long ABX = X2-X1;
		long long ABY = Y2-Y1;
		long long CDX = X4-X3;
		long long CDY = Y4-Y3;

//		cout << ABX*CDY << endl;
//		cout << ABY*CDX << endl;

		if(ABX*CDY==ABY*CDX){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}

	return 0;
}

C++: #include <iostream>
#include <stack>
#include <stdio.h>
#include <cmath>
using namespace std;
double x[4],y[4];//p,1,2,3
double a[2],b[2],c[2];
void make_line(double x1,double y1,double x2,double y2,int num){
	if(x1!=x2&&y1!=y2){
		a[num]=(y1-y2)/(x1-x2);
		b[num]=-1;
		c[num]=-a[num]*x1+y1;
	}else if(x1==x2){
		a[num]=1;
		b[num]=0;
		c[num]=-x1;
	}else if(y1==y2){
		a[num]=0;
		b[num]=1;
		c[num]=-y1;
	}
	return;
}
int main()
{
	int n;
	cin>>n;
	while(n--){
		bool ans=false;
		cin>>x[0]>>y[0]>>x[1]>>y[1]>>x[2]>>y[2]>>x[3]>>y[3];
		make_line(x[0],y[0],x[1],y[1],0);
		make_line(x[2],y[2],x[3],y[3],1);
		if(a[0]==0){
			ans=(a[1]==0);
		}else if(abs((b[0]/a[0])-(b[1]/a[1]))<0.00000001){
			ans=true;
		}
		printf(ans?"YES\n":"NO\n");
	}
    return 0;
}

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

class vec2d {
public:
  double x,y;
  void set(double x=0.0,double y=0.0) {
    this->x = x;
    this->y = y;
  }
};
double cross(vec2d A,vec2d B) {
  return (A.x*B.y - B.x*A.y);
}
bool is_paralles(vec2d A,vec2d B) {
  if(fabs(cross(A,B)) < 1e-12) return true;
  return false;
}

int main() {
  int n; cin >> n;
  for(int i=0;i<n;i++) {
    vec2d AB,CD;
    double x1,y1,x2,y2,x3,y3,x4,y4;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
    AB.set(x2-x1,y2-y1);
    CD.set(x4-x3,y4-y3);
    if(is_paralles(AB,CD)) {
      cout << "YES" << endl;
    }
    else {
      cout << "NO" << endl;
    }
  }
}