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 <stdio.h>
#include <math.h>

int main(void){
    int n;
    cin >> n;
    rep(i,n) {

    double x[4],y[4],a,b,c,d,p,q,det,ansx,ansy;
    //入力を多少簡略化
    for(int i=0;i<4;i++) {
        scanf("%lf" ,&x[i]);
        scanf("%lf" ,&y[i]);
    }
    //(x1,y1)(x2,y2)を結ぶax+by=p の係数
    a = y[0]-y[1];  b = x[1]-x[0];
    p = x[1]*y[0]-x[0]*y[1];
    //(x3,y3)(x4,y4)を結ぶcx+dy=q の係数
    c = y[2]-y[3];  d = x[3]-x[2];
    q = x[3]*y[2]-x[2]*y[3];
    //係数についての行列式
    det = a*d-c*b;
    if(det == 0) puts("YES");
    else puts("NO");
    /*
    //det=0で解は存在しない(この問題については２線分は同一直線上にないから)
    if(fabs(det) < 0.00001) puts("YES");
    //逆行列を用いて解を導出
    else {
        /*
        ansx = (d*p - b*q)/det;
        ansy = (-c*p + a*q)/det;
        //ansxがどちらの線分のx座標範囲にも含まれるかを判定
        if((x[0] - ansx)*(x[1] - ansx) <= 0.00001 && (x[2] - ansx)*(x[3] - ansx) <= 0.00001 ) {
            printf("YES (%lf, %lf)\n",ansx,ansy);
        } else puts("NO");
        
       puts("NO");
    }
    */
    }
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

int n;
double x1,x2,x3,x4,ya1,y2,y3,y4;

int main() {
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> x1 >> ya1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		if (x1 > x2) {
			double tmp = x1;
			x1 = x2;
			x2 = tmp;
			tmp = ya1;
			ya1 = y2;
			y2 = tmp;
		}
		if (x3 > x4) {
			double tmp = x3;
			x3 = x4;
			x4 = tmp;
			tmp = y3;
			y3 = y4;
			y4 = tmp;
		}

		if (x1 == x2) {
			if (x3 == x4) cout << "YES" << endl;
			else cout << "NO" << endl;
		} else {
			if (x3 == x4) cout << "NO" << endl;
			else {
				if ((y2 - ya1) / (x2 - x1) - (y4 - y3) / (x4 - x3) <= 0.000001)
					cout << "YES" << endl;
				else cout << "NO" << endl;
			}
		}
	}

	return 0;
}

/*@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*@                       @*/
/*@ debug output erased ? @*/
/*@                       @*/
/*@@@@@@@@@@@@@@@@@@@@@@@@@*/

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

int main(int argc, const char * argv[]) {
    int num;
    std::cin >> num;
    double x1,y1,x2,y2,x3,y3,x4,y4;
    
    for(int i = 0;i < num;i++){
        std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
        double a = (y1-y2)/(x1-x2);
        double b = (y3-y4)/(x3-x4);
         std::cout <<  (a==b ? "YES":"NO") << '\n';
    }
}

C++: #include <bits/stdc++.h>

//const static double	de_PI	= 3.14159265358979323846;
//const static int	de_MOD	= 1000000007;
//const static int	de_MAX	= 999999999;
//const static int	de_MIN = -999999999;

int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());

	int n = 0;
	std::cin >> n;

	double x1 = 0, y1 = 0, x2 = 0, y2 = 0;
	double slope1 = 0, slope2 = 0;
	std::vector<std::string> ans(n);

	for (int i = 0; i < n; i++) {
		std::cin >> x1 >> y1 >> x2 >> y2;
		slope1 = (y2 - y1) / (x2 - x1);
		std::cin >> x1 >> y1 >> x2 >> y2;
		slope2 = (y2 - y1) / (x2 - x1);

		if (slope1 == slope2) {
			ans[i] = "YES";
		}
		else {
			ans[i] = "NO";
		}
	}

	for (int i = 0; i < n; i++) {
		std::cout << ans[i] << std::endl;
	}

}

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 = nextInt();
	REP(i, N) {
		double x1 = nextDouble();
		double y1 = nextDouble();
		double x2 = nextDouble();
		double y2 = nextDouble();
		double x3 = nextDouble();
		double y3 = nextDouble();
		double x4 = nextDouble();
		double y4 = nextDouble();
		if (x1 > x2) {
			double t = x2;
			x2 = x1; x1 = t;
			t = y2; y2 = y1; y1 = t;
		}
		if (x3 > x4) {
			double t = x4;
			x4 = x3; x3 = t;
			t = y4; y4 = y3; y3 = t;
		}
		if ((y2 - y1) / (x2 - x1) - (y4 - y3) / (x4 - x3) < 0.000006) {
			PRINT("YES");
		} else {
			PRINT("NO");
		}
	}

	return 0;
}

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

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

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

C++: #include <iostream>
#include <vector>
using namespace std;
 
int main() {
    int n;
    double ax,ay,bx,by,cx,cy,dx,dy;
    vector<int> r;
    cin >> n;
    for (int i=0; i<n; i++)
    {
        cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy;
        if (ax == bx)
        {
            cx == dx ? r.push_back(1) : r.push_back(0);
        } else if (cx == dx) {
            r.push_back(0);
        } else {
            (ay-by)/(ax-bx) == (cy-dy)/(cx-dx) ? r.push_back(1) : r.push_back(0);
        }
    }
    for (int i=0; i<n; i++)
    {
        r[i] == 1 ? cout << "YES" << endl : cout << "NO" << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int n;
double X1, X2, X3, X4, Y1, Y2, Y3, Y4;

int main(){
	cin >> n;
	REP(i, n){
		cin >> X1 >> Y1 >> X2 >> Y2 >> X3 >> Y3 >> X4 >> Y4;
		if ((X2 - X1)*(Y4 - Y3) == (X4 - X3)*(Y2 - Y1)){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
}

C++: #include<iostream>
#include<math.h>

using namespace std;

int main()
{
	double x1,x2,x3,x4,y1,y2,y3,y4,rad1,rad2;
	int n,i;
	
	cin >> n ;
	
	for(i=0;i<n;i++)
	{
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4 ;
		
		rad1=atan((x2-x1)/(y2-y1));
		rad2=atan((x4-x3)/(y4-y3));
		
		if(rad1==rad2 || rad1==rad2+180.0)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
}

C++: #include <iostream>

int main(){
	int a;
	double x1,y1,x2,y2,x3,y3,x4,y4;
	std::cin>>a;
	for(int s=0;s<a;s++){
		std::cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
		if((y2-y1)/(x2-x1)==(y4-y3)/(x4-x3)){
			std::cout<<"YES"<<std::endl;
		}else{
			std::cout<<"NO"<<std::endl;
		}
		
    }
    return 0;
}