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<string>
#include<algorithm>

using namespace std;

int main(){
	int n;
	double x1,x2,x3,x4;
	double y1,y2,y3,y4;
	
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
		if((x2-x1)*(y4-y3)-(x4-x3)*(y2-y1)==0)
		printf("YES\n");
		else
		printf("NO\n");
	}
}

C++: #include <iostream>

int main(){
	double x1 , y1 , x2 , y2 , x3 , y3 , x4 , y4;
	int n;
	std::cin >> n;
	for(int i=0 ; i<n ; i++){
		std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		bool parallel=false;
		if(x1==x2 && x3==x4) {
			parallel=true;
			goto result;
		}
		else if(x1==x2 || x3==x4) {
			goto result;
		}
		else if ((y2-y1)/(x2-x1)==(y4-y3)/(x4-x3)) {
			parallel=true;
		}
		result:
		std::cout << ( parallel ? "YES" : "NO") << std::endl;
	}
	return 0; 
}

C++: #include <iostream>

using namespace std;

typedef struct _POINT {
	double x;
	double y;
} POINT;

typedef struct _LINE {
	POINT a;
	POINT b;
} LINE;

bool isParallel (LINE l1, LINE l2) {
	double f1 = l1.b.x - l1.a.x;
	double g1 = l1.b.y - l1.a.y;
	double f2 = l2.b.x - l2.a.x;
	double g2 = l2.b.y - l2.a.y;

	double det = f2*g1 - f1*g2;
	if (det == 0.0)
		return true;
	else
		return false;
}

int main() {
	LINE ab, cd;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> ab.a.x >> ab.a.y >> ab.b.x >> ab.b.y >> cd.a.x >> cd.a.y >> cd.b.x >> cd.b.y;
		if (isParallel(ab, cd))
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

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

using namespace std;

typedef complex<double> P;

#define EPS (1e-7)

double cross(P const& a, P const& b) {
  return imag(conj(a)*b);
}

bool is_parallel(P const& a1, P const& a2, P const& b1, P const& b2)
{ return abs(cross(a2-a1, b2-b1)) < EPS; }

int main() {
  
  int N; cin >> N;
  for(int i=0; i<N; i++) {
    P ps[4];
    for(int i=0; i<4; i++)
      cin >> ps[i].real() >> ps[i].imag();
    printf("%s\n", (is_parallel(ps[0], ps[1], ps[2], ps[3]) ? "YES" : "NO" ));
  }
  
  return 0;
}

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;
    //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 <stdio.h>
int main(void)
{
    double x1,y1,x2,y2,x3,y3,x4,y4,AB,CD;
    int n,i;
    
    scanf("%d",&n);
    {
        for(i=0;i<n;i++)
        {
            scanf("%lf",&x1); scanf("%lf",&y1);
            scanf("%lf",&x2); scanf("%lf",&y2);
            scanf("%lf",&x3); scanf("%lf",&y3);
            scanf("%lf",&x4); scanf("%lf",&y4);
            
            AB=(y2-y1)/(x2-x1);
            CD=(y4-y3)/(x4-x3);
            
            if(AB==CD) printf("YES\n");
            else printf("NO\n");
        }
    }
    
    return 0;
}

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

typedef struct xyz{
    double x;
    double y;
}XYZ;

int main(void){

    int times;
    cin >> times;

    XYZ a,b,c,d;
    double x1,y1,x2,y2;

    while(times > 0){
        cin >> a.x >> a.y;
        cin >> b.x >> b.y;
        cin >> c.x >> c.y;
        cin >> d.x >> d.y;

        x1 = a.x - b.x;
        y1 = a.y - b.y;
        x2 = c.x - d.x;
        y2 = c.y - d.y;

        

        if(fabs((y1 * x2) - (y2 * x1)) <= 1e-10){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }

        times--;
    }


    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n;
  double xa,ya,xb,yb,xc,yc,xd,yd,a2,a1;
  while(1){
    cin>>n;
    if(n==EOF)break;
    for(int i=0;i<n;i++){
      cin>>xa>>ya>>xb>>yb>>xc>>yc>>xd>>yd;
      a1=(yb-ya)/(xb-xa);
      a2=(yd-yc)/(xd-xc);
      if(a1==a2)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
 
typedef long long ll;
typedef pair<int, int> ii;

#define EPS 1e-10

int main(){

	int n;
	cin >> n;
	while(n--){
		double x1, x2,x3,x4,y1,y2,y3,y4;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		double cross = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
		if(fabs(cross) < EPS) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	
	return 0;
}

C++: #include <iostream>
#include <stack>
#include <stdio.h>
using namespace std;
double a,b,c;//ax+by+c=0
double x[4],y[4];//p,1,2,3
void make_line(double x1,double y1,double x2,double y2){
	if(x1!=x2&&y1!=y2){
		a=(y1-y2)/(x1-x2);
		b=-1;
		c=-a*x1+y1;
	}else if(x1==x2){
		a=1;
		b=0;
		c=-x1;
	}else if(y1==y2){
		a=0;
		b=1;
		c=-y1;
	}
	return;
}
//bool check(int p,int q,int r){
//	make_line(x[p],y[p],x[q],y[q]);//line pq
//	if((a*x[r]+b*y[r]+c)*(a*x[0]+b*y[0]+c)<=0)return false;
//	return true;
//}

int main()
{
	int n;
	cin>>n;
	while(n--){
		cin>>x[0]>>y[0]>>x[1]>>y[1]>>x[2]>>y[2]>>x[3]>>y[3];
		double tmp;
		make_line(x[0],y[0],x[1],y[1]);
		tmp=a;
		make_line(x[2],y[2],x[3],y[3]);
		printf(tmp==a?"YES\n":"NO\n");
	}
    return 0;
}

C++: #include <iostream>

const int NUM = 8;

bool isParallel(const double* point);

int main()
{
	int n;
	double point[NUM];
	std::cin >> n;
	while (n-- > 0) {
		for (int i = 0; i < NUM; i++) {
			std::cin >> point[i];
		}
		if ( isParallel(point) ) {
			std::cout << "YES" << std::endl;
		} else {
			std::cout << "NO" << std::endl;
		}
	}
}

bool isParallel(const double* point) {
	return (point[3] - point[1]) / (point[2] - point[0]) == (point[7] - point[5]) / (point[6] - point[4]);
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
using namespace std;
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;
		double a,b,c,d,e,f;
		a=sqrt(pow(x2-x1,2)+pow(y2-y1,2));
		c=sqrt(pow(x4-x3,2)+pow(y4-y3,2));
		b=abs(x1-x3);
		d=abs(x2-x4);
		e=abs(y1-y3);
		f=abs(y2-y4);
		b=b*e;
		d=d*f;
		if(a==c&&b==d){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}

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;
	while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4){
		if((y1-y2)*(x3-x4) == (x1-x2)*(y3-y4) ){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
}