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>
 
using namespace std;
 
int main() {
    double x1,x2,x3,x4;
    double y1,y2,y3,y4;
    double incAB, incCD;
    int count=0;
    cin>>count;
    for(int i=0; i<count; i++) {
        cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
        incAB = (y2-y1) / (x2-x1);
        incCD = (y4-y3) / (x4-x3);
        if(incAB == incCD) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}

C++: #!/usr/bin/python
# -*- coding:utf-8 -*-

def main():
	numData = int(raw_input())
	count = 0
	while count < numData:
		line = raw_input()
		coords = map(float, line.strip().split())
		result = isParallel(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5], coords[6], coords[7])

		if result :
			print "YES"
		else:
			print "NO"

		count += 1

def isParallel(x1, y1, x2, y2, x3, y3, x4, y4):
	# 小数点以下最大５桁までの精度で計算すればよい
	x1 = int(x1 * 100000)
	y1 = int(y1 * 100000)
	x2 = int(x2 * 100000)
	y2 = int(y2 * 100000)
	x3 = int(x3 * 100000)
	y3 = int(y3 * 100000)
	x4 = int(x4 * 100000)
	y4 = int(y4 * 100000)
	# 直線ABの傾きが無限大かどうか
	if (x2 == x1):
		# 傾き無限大ならば、CDもそうなら平行
		return x4 == x3
	else:
		# 有限の傾きならば傾きが等しければOK
		return (y2 - y1)/(x2 - x1) == (y4 - y3)/(x4 - x3)

main()

C++: //
//  main.cpp
//  main
//
//  Created by h3037175 on 2018/01/22.
//  Copyright © 2018年 h3037175. All rights reserved.
//

#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
#include<algorithm>
#include<utility>
using namespace std;
double zeti(double);
int main() {
    pair<double,double> a;
    pair<double,double> b;
    pair<double,double>c;
    pair<double,double>d;
    int n;
    double s1,s2;
    cin>>n;
    for(int i=0;i<n;++i){
        cin>>a.first>>a.second>>b.first>>b.second>>c.first>>c.second>>d.first>>d.second;
        if((a.first==b.first&&c.first==d.first) || (a.second==b.second&&c.second==d.second)){
            cout<<"YES"<<endl;
            continue;
        }
        else if(a.first==b.first||c.first==d.first||a.second==b.second || c.second == d.second){
            cout<<"NO"<<endl;
            continue;
        }
        s1=(a.second-b.second)/(a.first-b.first);
        s2=(c.second-d.second)/(c.first-d.first);
        cout<<s1<<" "<<s2<<endl;
        if(s1==s2){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
            
        }
    }
    
    
    return 0;
}

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

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 <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
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 ;
		if( ((x1-x2)/(y1-y2)) == ((x3-x4)/(y3-y4)) ){
			cout << "YES" << "\n" ;
		}
		else{
			cout << "NO" << "\n" ;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <complex>
#include <cmath>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )

using namespace std;

typedef complex<double> P;

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

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

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

  cin >> n;

  for ( int i = 0; i < n; i++ ){
      cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
 
   
      if ( abs((y2 - y1)*(x4 - x3) - (y4 - y3)*(x2 - x1) ) < EPS ) cout << "YES" << endl;
      else cout << "NO" << endl;
  }
  return 0;
}