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 <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <array>
#include <numeric>
#include <functional>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<complex>

using namespace std;

#define REP(i,m,n) for(int i=m;i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef pair<int, int> pii;

// const ll inf = INT_MAX;
const double eps = 1e-5;
const double pi = acos(-1.0);
const int di[][2] = {{1,0},{0,1},{-1,0},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}};

int main(){
	int n;
	scanf("%d\n", &n);
	double x[4], y[4];
	rep(i,n){
		rep(j,4){
			scanf("%lf %lf", &x[j], &y[j]);
		}
		double dx[2], dy[2];
		dx[0] = x[1] - x[0];
		dx[1] = x[3] - x[2];
		dy[0] = y[1] - y[0];
		dy[1] = y[3] - y[2];
		printf("%lf\n",std::abs(dy[1]*dx[0] - dy[0]*dx[1]));
		if(std::abs(dy[1]*dx[0] - dy[0]*dx[1]) <= eps) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

C++: #include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
#define range(i, a, b) for (int i = a; i < b; ++i)
#define rep(i, n) range(i, 0, n)
const ll INF = 1e10;
#define pb push_back

int main()
{
    int n;
    cin >> n;
    rep(i, n)
    {
        vector<double> x(4), y(4);
        rep(j, 4) cin >> x[j] >> y[j];
        double a = (x[3] - x[2]) * (y[1] - y[0]) - (x[1] - x[0]) * (y[3] - y[2]);
        cout << a << endl;
        if (a != 0) {
            cout << "NO" << endl;
        } else {
            cout << "YES" << endl;
        }
    }
}

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

using namespace std;

struct point {
	double x, y;
};

struct segLine {
	point s, e;	
}segA, segB;

int main() {
	int t;
	scanf ("%d", &t);
	while (t--) {
		scanf ("%lf%lf%lf%lf", &segA.s.x, &segA.s.y, &segA.e.x, &segA.e.y);
		scanf ("%lf%lf%lf%lf", &segB.s.x, &segB.s.y, &segB.e.x, &segB.e.y);
		if ((segA.e.y-segA.s.y)*(segB.e.x-segB.s.x)==(segB.e.y-segB.s.y)*(segA.e.x-segA.s.x))  printf ("YES\n");
		else printf ("NO\n");
	}
	return 0; 
}

C++: #include <iostream>
 
using namespace std;
 
 
 
struct pt {
 
    double x;
 
    double y;
 
};
 
 
 
int main() {
 
    int num;
 
    cin >> num;
 
    while(num--) {
 
        pt p1, p2, p3, p4;
 
        cin >> p1.x >> p1.y;
 
        cin >> p2.x >> p2.y;
 
        cin >> p3.x >> p3.y;
 
        cin >> p4.x >> p4.y;
 
        pt v1 = {p1.x-p2.x, p1.y-p2.y};
 
        pt v2 = {p3.x-p4.x, p3.y-p4.y};
 
        if (v1.y==0 && v2.y==0) cout << "YES\n";
 
        else if (v1.x/v1.y == v2.x/v2.y) cout << "YES\n";
 
        else cout << "NO\n";
 
    }
 
    return 0;
 
}

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");
        }
    }
}