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")
		} else {
			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 <cmath>
using namespace std;

const double EPS = 1e-10;

signed main() {
  int n;

  cin >> n;
  while (n--) {
    double x[4], y[4];
    for (int i = 0; i < 4; cin >> x[i] >> y[i], i++);
    if (fabs((y[1] - y[0]) / (x[1] - x[0]) - (y[3] - y[2]) / (x[3] - x[2])) < EPS) {
      puts("YES");
    } else {
      puts("NO");
    }
  }

  return 0;
}

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

int main(){
  int n;
  double x[4],y[4],dx[2],dy[2];
  cin >> n;
  for(int i=0;i<n;i++){
	for(int j=0;j<4;j++)cin >> x[j] >> y[j]; 
	dx[0] = x[0] - x[1];
	dx[1] = x[2] - x[3];
	dy[0] = y[0] - y[1];
	dy[1] = y[2] - y[3];
	if(dx[0]*dy[1] == dx[1]*dy[0]) cout << "YES" << endl;
	else cout << "NO" << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <cmath>
 
using namespace std;
 
bool test (double x1, double y1, double x2, double y2) {
    return x1 * y2 == x2 * y1;
}
 
int main (void) {
    int n;
    cin >> n;
    while (n--) {
        double x1, x2, x3, x4, y1, y2, y3, y4;
        cin >> x1; cin >> y1;
        cin >> x2; cin >> y2;
        cin >> x3; cin >> y3;
        cin >> x4; cin >> y4;
        if (test(x1 - x2, y1 - y2, x3 - x4, y3 - y4)) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int main()
{
    int n;
    cin >> n;
    rep(j, n)
    {
        double a[8];
        rep(i, 8)
        {
            cin >> a[i];
        }
        double ans = (a[2] - a[0]) * (a[7] - a[5]) - (a[3] - a[1]) * (a[6] - a[4]);
        if((a[2] - a[0])==0 &&(a[6] - a[4])==0){
            cout<<"YES"<<endl;
        }else         if((a[2] - a[0])==0 ||(a[6] - a[4])==0){
            cout<<"NO"<<endl;
        }
        else if (ans < 0.0000001)
        {
            cout << "YES" << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    double x1,x2,x3,x4,y1,y2,y3,y4;
    for(int i=0;i<n;i++){
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
        if(x4-x3==0 || x2-x1==0){
            if(x4-x3==0 && x2-x1==0)
                cout << "YES" << endl;
            else
                cout << "NO" << endl;
        }
        else{
            double p=(y2-y1)/(x2-x1);
            double q=(y4-y3)/(x4-x3);
            if(p==q)
                cout << "YES" << endl;
            else
                cout << "NO" << endl;
        }
    }

}

C++: #include <iostream>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
 
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((y2-y1)/(x2-x1) == (y4-y3)/(x4-x3)) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
    return 0;
}

C++: #include <stdio.h>

int
main(void)
{
	char line[100];
	int n;

	if (fgets(line, sizeof line, stdin) == NULL) {
		return 1;
	}
	if (sscanf(line, "%d", &n) != 1) {
		return 1;
	}

	double x1, y1, x2, y2, x3, y3, x4, y4;
	
	while (n--) {
		fgets(line, sizeof line, stdin);
		sscanf(line, "%lf %lf %lf %lf %lf %lf %lf %lf",
				   &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);

		double ab = (y2 - y1)/(x2 - x1);
		double cd = (y4 - y3)/(x4 - x3);
		
		printf("%s\n", ((ab == cd) ? "YES" : "NO"));
	}

	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
#define ALL(a)  (a).begin(),(a).end()
#define REP(i,n) for(int i=0;i<(n);++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define dump(x) cerr << "  (L" << __LINE__ << ") " << #x << " = " << (x) << endl;
#define dumpv(x) cerr << "  (L" << __LINE__ << ") " << #x << " = "; REP(q,(x).size()) cerr << (x)[q] << " "; cerr << endl;
template<typename T1, typename T2>
ostream& operator<<(ostream& s, const pair<T1, T2>& d) {return s << "(" << d.first << "," << d.second << ")";}


double cross(complex<double>& a, complex<double>& b) {
  return a.real() * b.imag() - a.imag() * b.real();
}

int main() {
  int T; cin >> T;
  REP(t, T) {
    vector<double> in(8);
    REP(i, 8) cin >> in[i];
    
    complex<double> a(in[2]-in[0], in[3]-in[1]);
    complex<double> b(in[6]-in[4], in[7]-in[5]);
    double exter_product = cross(a, b);
    if (exter_product < EPS) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}

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){
            cout<<"YES"<<endl;
            continue;
        }
        s1=(a.second-b.second)/(a.first-b.first);
        s2=(c.second-d.second)/(c.first-d.first);
        if(s1==s2){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
            
        }
    }
    
    
    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <iostream>
#include <sstream>
#include <functional>
#include <utility>

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)

short n, i, j;
double a[4], b[4];

int main(){
	scanf("%d", &n);
	rep(i, n){
		rep(j, 4) scanf("%lf %lf", &a[j], &b[j]);
		if(a[1] - a[0] == a[3] - a[2] && b[1] - b[0] == b[3] - b[2]) 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--){
    double x[4],y[4];
    for(int i=0;i<4;i++){
      cin >> x[i] >> y[i];
    }
    if(abs((x[3]-x[2])*(y[1]-y[0])-(x[1]-x[0])*(y[3]-y[2])) < 1e-10){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
  }
}