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)
		}
		if fpoints[0] == fpoints[2] && fpoints[4] == fpoints[6] {
			fmt.Println("YES")
			continue
		}
		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 <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string.h>
#include <queue>
#include <stack>
#include <utility>
#include <queue>
#include <cmath>
#define mp make_pair
#define pii pair<int,int> 
#define ff first
#define ss second

using namespace std;

double x1,x2,x3,x4,y2,y3,y4,y5;//y1 crash with include cmath...
double g1,g2;
int tc;

int main()
{
	scanf("%d",&tc);
	while(tc--)
	{
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y5,&x2,&y2,&x3,&y3,&x4,&y4);
		/*g1=(y2-y5)/(x2-x1); //seeems broken with infinity loll
		g2=(y4-y3)/(x4-x3);
		printf("%.2lf,%.2lf\n",g1,g2);*/
		if(abs((x2-x1)*(y4-y3)-(x4-x3)*(y2-y5))<1e-10)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
		
	}
	return 0;
}

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((y[1]-y[0])/(x[1]-x[0])==(y[3]-y[2])/(x[3]-x[2])) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }

  return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-11

template<class T> T add(T x, T y){ if(abs(x+y) < EPS*(abs(x)+abs(y))) return 0; return x + y; }
template<class T> inline bool semieq(T x, T y){ return abs(x - y) < EPS; }
template<class T> inline bool semige(T x, T y){ return x - y > -EPS; }
template<class T> inline bool semile(T x, T y){ return y - x > -EPS; }

template<class Type> struct Line;

template<class Type>
struct P
{
  friend struct Line<Type>;
private:
  Type x, y;

public:
  P(const Type x = 0, const Type y = 0) : x(x), y(y) {}
  void setter(Type x, Type y) { this->x = x;  this->y = y;  return ; }
  Type getX(){ return x; }
  Type getY(){ return y; }
  inline double getSlope(){ return semieq(x, (Type)0) ? INF : 1.0 * y / x; }
  inline double getSlope(P p){ return (this - p).getSlope(); }
  P  operator +  (const P p){ return P(add(x,  p.x), add(y,  p.y)); }
  P  operator -  (const P p){ return P(add(x, -p.x), add(y, -p.y)); }
  P  operator *  (const Type d){ return P(x * d, y * d); }
  P& operator += (const P p){ x = add(x,  p.x);  y = add(y,  p.y);  return *this; }
  P& operator -= (const P p){ x = add(x, -p.x);  y = add(y, -p.y);  return *this; }
  P& operator *= (const Type d){ x *= d;  y *= d;  return *this; }
  bool operator == (const P p){ return  semieq(x, p.x) &&  semieq(y, p.y); }
  bool operator != (const P p){ return !semieq(x, p.x) || !semieq(y, p.y); }
  Type operator * (const P p){ return add(x * p.x,  y * p.y); }
  Type operator / (const P p){ return add(x * p.y, -y * p.x); }
};

template<class Type>
struct Line
{
private:
  P<Type> S, T;

public:
  Line(const Type sx, const Type sy, const Type tx, const Type ty) : S(sx, sy), T(tx, ty) {}
  Line(const P<Type> S, const P<Type> T) : S(S), T(T) {}
  inline P<Type> getS(){ return S; }
  inline P<Type> getT(){ return T; }
  inline double getSlope(){ return S.getSlope(T); }
  inline bool isParallel(Line<Type> L){ return semieq((S.x-T.x)*(L.S.y-L.T.y), (L.S.x-L.T.x)*(S.y-T.y));}
  inline bool isVertical(Line<Type> L){ return semieq((S.x-T.x)*(L.S.x-L.T.x), (L.T.y-L.S.y)*(S.y-T.y));}
};

typedef long double Point;

int n;
P<Point> A[4];
Point x, y;

int main()
{
  cin >> n;

  while(n--){
    rep(i, 4){
      cin >> x >> y;
      A[i].setter(x, y);
    }
    Line<Point> AB(A[0], A[1]);
    Line<Point> CD(A[2], A[3]);
    puts(AB.isParallel(CD) ? "YES" : "NO");
  }

  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n;
  double xa,ya,xb,yb,xc,yc,xd,yd,a2,a1;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>xa>>ya>>xb>>yb>>xc>>yc>>xd>>yd;
    a1=(yb-ya)/(xb-xa);
    a2=(yd-yc)/(xd-xc);
    if(a1==a2)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
  }
}

C++: #include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <climits>
#include <utility>

#define PRINT(STR) cout << STR << endl;
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()

typedef long long ll;

using namespace std;

int nextInt() { int n = -1; cin >> n; return n; }
double nextDouble() { double d = -1; cin >> d; return d; }
ll nextll() { ll n = -1; cin >> n; return n; }
string nextString() { string str; cin >> str; return str; }

int INF = 9999999;

// BEGIN //////////////////////////////////////////////////////////////


int main() {
	int N;
	cin >> N;
	double x1, y1, x2, y2, x3, y3, x4, y4;
	REP(i, N) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;

		if (x2 - x1 == 0 || x4 - x3 == 0) {
			if (y2 - y1 == 0 && y4 - y3 == 0) {
				PRINT("YES");
			} else {
				PRINT("NO");
			}
		} else {
			if ((y2 - y1) / (x2 - x1) - (y4 - y3) / (x4 - x3) < 1e-8) {
				PRINT("YES");
			} else {
				PRINT("NO");
			}
		}
	}

	return 0;
}

// END   //////////////////////////////////////////////////////////////

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


typedef complex<double> xy_t;

double cross_product(xy_t a,xy_t b){
	return (conj(a)*b).imag();
}
const double eps=1e-11;
double x[4],y[4];
int n;

int main(){
	cin>>n;
	rep(i,0,n){
		rep(j,0,4){
			cin>>x[j]>>y[j];
		}
		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]))<eps;
		cout<<(p?"YES":"NO")<<endl;
	}
}

C++: #include <iostream>
#include <math.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	double x1, y1, x2, y2, x3, y3, x4, y4;
	double eps = 0.0000000001;
	while (n--){
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		double s1 = x2 - x1,
			   t1 = y2 - y1,
			   s2 = x4 - x3,
			   t2 = y4 - y3;
		double v = fabs(s1 * t2 - s2 * t1);
		if (v < eps) cout << "YES\n";
		else         cout << "NO\n";
	}
	return 0;
}