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 <algorithm>
#include <cassert>
#include <cmath>
#include <stdio.h>
  
using namespace std;
  
//-------------------------------------------------------------------------
// geometric library
  
namespace geometry {
  
#define EPS 1E-10 ///< 0とみなすサイズ。適当
 
struct point {
    double x;
    double y;
 
    point& operator += (const point& rhs) { x += rhs.x; y += rhs.y; return *this; }
    point& operator -= (const point& rhs) { x -= rhs.x; y -= rhs.y; return *this; }
    point& operator /= (double factor) { x /= factor; y /= factor; return *this; }
    point& operator *= (double factor) { x *= factor; y *= factor; return *this; }
    bool operator == (const point& rhs) const { return (std::abs(x - rhs.x) < EPS) && (std::abs(y - rhs.y) < EPS); }
    bool operator != (const point& rhs) const { return !(*this == rhs); }
};
 
typedef point vector;
  
struct circle {
    point center;
    double radius;
};
  
struct line { // ax + by + c = 0
    double a;
    double b;
    double c;
};
 
enum rotate_dir {
    rotate_None = 0,
    rotate_CW   = 1,
    rotate_CCW  = -1
};
 
point operator + (const point& p1, const point& p2)
{
    point p(p1);
    p += p2;
    return p;
}
 
point operator / (const point& p1, double factor)
{
    point p(p1);
    p /= factor;
    return p;
}
  
point operator - (const point& p1, const point& p2)
{
    point p(p1);
    p -= p2;
    return p;
}
 
std::istream& operator >> (std::istream& is, point& p)
{
    is >> p.x >> p.y;
    return is;
}
 
///! 2点の距離
double get_distance(const point& p1, const point& p2)
{
    return sqrt(pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2));
}
  
///! 2直線の交点
bool get_crosspoint(const line& l1, const line& l2, point *result)
{
    double denominator = l1.a * l2.b - l1.b * l2.a;
    if (std::abs(denominator) < EPS) {
        return false;
    }
    result->x = (l1.b * l2.c - l2.b * l1.c) / denominator;
    result->y = (l2.a * l1.c - l1.a * l2.c) / denominator;
    return true;
}
  
///! 2点の垂直2等分線
bool get_bisector(const point& p1, const point& p2, line *result)
{
    if (p1 == p2) {
        return false;
    }
    result->a = 2 * (p1.x - p2.x);
    result->b = 2 * (p1.y - p2.y);
    result->c = -(p1.y - p2.y) * (p1.y + p2.y) - (p1.x - p2.x) * (p1.x + p2.x);
    return true;
}

bool get_line(const point& p1, const point& p2, line *result)
{
    if (p1 == p2) {
        return false;
    }
    result->a = p2.y - p1.y;
    result->b = p1.x - p2.x;
    result->c = p1.y * p2.x - p1.x * p2.y;
    return true;
}
  
///! 外接円を求める
bool get_circum_circle(const point& p1, const point& p2, const point& p3, circle *result)
{
    double a = get_distance(p1, p2);
    double b = get_distance(p2, p3);
    double c = get_distance(p3, p1);
  
    // 半径の公式
    result->radius = a * b * c / sqrt((a + b + c) * (-a + b + c) * (a - b + c) * (a + b - c));
  
    line line_p1p2;
    line line_p2p3;
  
    // 頂点の垂直2等分線の交点が外心
    return get_bisector(p1, p2, &line_p1p2) &&
           get_bisector(p2, p3, &line_p2p3) &&
           get_crosspoint(line_p1p2, line_p2p3, &result->center);
}
 
double cross_product(const point& p1, const point& p2)
{
    return p1.x * p2.y - p2.x * p1.y;
}
 
///! p1-p2-p3が左右どちらの方向に折れているかを判定
rotate_dir direction(const point& p1, const point& p2, const point& p3)
{
    vector p1_p3 = p1 - p3;
    vector p2_p3 = p2 - p3;
    double cross = cross_product(p1_p3, p2_p3);
 
    if (std::abs(cross) < EPS) {
        return rotate_None;
    } else if (cross > 0) {
        return rotate_CW;
    } else {
        return rotate_CCW;
    }
}
  
// (p1s, p1e)と(p2s, p2e)の線分交差判定.EPS以下で接している場合はtrue、重なっている場合はfalse
bool intersect(const point& p1s, const point& p1e, const point& p2s, const point& p2e)
{
    assert(p1s != p1e && p2s != p2e);
    return
        (direction(p1s, p1e, p2s) != direction(p1s, p1e, p2e)) &&
        (direction(p2s, p2e, p1s) != direction(p2s, p2e, p1e));
}
 
// targetが三角形p1,p2,p3の内部にあるかどうか
bool is_inside_triangle(const point& p1, const point& p2, const point& p3, const point& target)
{
    point center_of_gravity = (p1 + p2 + p3) / 3; // 重心
 
    if (center_of_gravity == target) return true;
 
    // 重心とtargetを結んだ線分が三角形の辺と交叉するなら、点は三角形の外部にある
    bool intersect_any =
        intersect(p1, p2, center_of_gravity, target) ||
        intersect(p2, p3, center_of_gravity, target) ||
        intersect(p3, p1, center_of_gravity, target);
 
    return !intersect_any;
}

bool is_parallel(const point& p1, const point& p2, const point& p3, const point& p4)
{
    line l1, l2;
    point cross;

    if (!get_line(p1, p2, &l1) || !get_line(p3, p4, &l2)) {
        return false; // p1-p2, p3-p4で直線が作れない
    }
    return get_crosspoint(l1, l2, &cross) == false;
}
 
} // namespace geometry
  
//-------------------------------------------------------------------------
// solution
  
using namespace geometry;
 
int main(void)
{
    point p1,p2,p3,p4,cross;
    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> p1 >> p2 >> p3 >> p4;
        cout << (is_parallel(p1, p2, p3, p4) ? "YES" : "NO") << endl;
    }

    return 0;
}

C++: #include <stdio.h>
struct point{
    double x;
    double y;
};
int main(){
    int n;
    point a[4];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        for(int j=0;j<4;j++){
            scanf("%lf%lf",&a[j].x,&a[j].y);
        }
        if(a[1].x==a[0].x){
            if(a[3].x==a[2].x)printf("YES\n");
            else printf("NO\n");
        }
        else  if(a[1].y==a[0].y){
            if(a[3].y==a[2].y)printf("YES\n");
            else printf("NO\n");
        }
        else  if(a[3].x==a[2].x){
            printf("NO\n");
        }
        else if(a[3].y==a[2].y){
            printf("NO\n");
        }
        else if(((a[1].x-a[0].x)*(a[3].y-a[2].y))==((a[3].x-a[2].x)*(a[1].y-a[0].y)))printf("YES\n");
        else printf("NO\n");
    }
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 1e9
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
const double eps=1e-15;
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;
    // cout<<abs(y1-y2)/abs(x1-x2)<<endl;
    // cout<<abs(y3-y4)/abs(x3-x4)<<endl;
    if((((y1-y2)/(x1-x2))<=(((y3-y4)/(x3-x4))+eps))&&
       (((y1-y2)/(x1-x2))>=(((y3-y4)/(x3-x4))-eps)))
      cout<<"YES"<<endl;
    else
      cout<<"NO"<<endl;
  }
  return 0;
}