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<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))
		printf("YES\n");
		else
		printf("NO\n");
	}
}

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

int main(){
	int n;
	double a1,a2,b1,b2
	double c1,c2,d1,d2;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a1>>a2>>b1>>b2>>c1>>c2>>d1>>d2;
		if( (b2-a2)/(b1-a1) == (d2-c2)/(d1-c1) )
			cout<<"YES"<<endl;
		else 
			cout<<"NO"<<endl;
	}

}

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

int main(){
	double x1,x2,x3,x4,y1,y2,y3,y4;
	int n;
	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((y1-y2)*(x3-x4)==(x1-x2)*(y3-y4)){
				printf("YES\n");
			}
			else{
				printf("NO\n");
			}
		}
	
	return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
  double x1, x2, x3, x4, y1, y2, y3, y4;
  double a1, a2, b1, b2;
  int n;
  cin >> n;
  for(int i =0; i < n; i++){
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
    
    a1 = x2 - x1;
    a2 = x4 - x3;
    b1 = y2 - y1;
    b2 = y4 - y3;
    
    if (a1 * b2 == a2 * b1 ) cout << "YES"<< endl;
    else cout << "NO" << endl;
  }
}

C++: #include <iostream>

using namespace std;

int main(void){

  double x1,x2,x3,x4;
  double y1,y2,y3,y4;
  
  int n;
  cin >> n;
  while(n--){

    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;

    double katamuki1,katamuki2;
    katamuki1 =   ( y1 - y2 ) / ( x1 - x2 );
    katamuki2 =   ( y3 - y4 ) / ( x3 - x4 );
    if( katamuki1 == katamuki2 )cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <math.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	double x1, y1, x2, y2, x3, y3, x4, y4;
	while (n--){
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		double s1 = x2 - x1,
			   t1 = y2 - y1,
			   s2 = x4 - x3,
			   t2 = y4 - y3;
		double v = fabs(s1 * t2 - s2 * t1);
		if (v < 0.00001) cout << "YES\n";
		else             cout << "NO\n";
	}
	return 0;
}

C++: for i in range(int(input())):
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split())
    det = abs((y1-y2) * (x3-x4) - (x1-x2) * (y3-y4))
    if det<1e-12 :
        print("YES")
    else:
        print("NO")

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

int main()
{
    int n;
    cin >> n;
    for(int i=0; i<n; i++)
    {
        double x1, x2, x3, x4;
        double y1, y2, y3, y4;
        cin >>  x1 >>  y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
        double dxa = x2 - x1;
        double dya = y2 - y1;
        double dxb = x4 - x3;
        double dyb = y4 - y3;
        if(fabs(dxb * dya - dxa * dyb) <= DBL_EPSILON)
        {
           cout << "YES" << endl; 
        }
        else
        {
            cout << "NO" << endl; 
        }
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int n;
double x[4],y[4];
cin>>n;
for(;n--;){
for(int i=0;i<4;i++){
cin>>x[i];
cin>>y[i];
}
if((x[0]-x[1])*(y[2]-y[3])-(x[2]-x[3])*(y[0]-y[1])==0){
cout<<"YES"<<endl;
}else{
cout<<"NO"<<endl;
}
}
return 0;
}

C++: #include <stdio.h>

int main()
{
	int n;
	double x[4],y[4];
	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 4; j++){
			scanf("%d %d",&x[j],&y[j]);
		}
		if((y[1] - y[0]) * (x[3] - x[2]) == (x[1] - x[0]) * (y[3] - y[2])){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

typedef long double R;
typedef complex<R> P;

const R EPS = 1e-11;
const R PI = acos(-1);
int sgn(R a) {
    if (a < -EPS) return -1;
    if (a > EPS) return 1;
    return 0;
}


bool near(P a, P b) {
    return !sgn(abs(a-b));
}

void solve() {
    P p[4];
    for (int i = 0; i < 4; i++) {
        double x, y;
        cin >> x >> y;
        p[i] = P(x, y);
    }
    double r1 = arg(p[1]-p[0]);
    double r2 = arg(p[3]-p[2]);
    if (r1 < 0) r1 += PI;
    if (r2 < 0) r2 += PI;
    if (sgn(r1-r2)) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        solve();
    }
    return 0;
}

C++: #include <iostream>
#include <complex.h>
#include <math.h>
using namespace std;

const double eps = pow(10, -11);
double x[4], y[4];
int N;
typedef complex<double> xy_t;

double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag();}
int main() {
  cin >> N; //問題数
  for (int t=0; t<4; ++t) {
    for (int i=0; i<4; ++i)
	  cin >> x[i] >> y[i]; //x0,y0..x3,y3
	xy_t a[2] = {
	  xy_t(x[0], y[0]) - xy_t(x[1],y[1]),
	  xy_t(x[2], y[2]) - xy_t(x[3],y[3])
	  };
	  double s = cross_product(a[0] , a[1])/2;
	  bool p = abs(s) < eps;
	  cout << (p ? "YES" : "NO") << endl;
	  }
	 }

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

#define EPS 10e-8
#define PI 3.1415926535

typedef complex<double> Point;

int n;
Point ps[4];

int main() {
  scanf("%d", &n);
  while (n--) {
    for (int i=0; i<4; i++) {
      double x, y;
      scanf("%lf%lf", &x, &y);
      ps[i] = Point(x, y);
    }

    double t = abs(arg((ps[3]-ps[2])/(ps[1]-ps[0])));
    if ((-EPS < t && t < EPS) || (PI-EPS < t && t  < PI+EPS)) {
      puts("YES");
    } else {
      puts("NO");
    }
  }
}

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

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define RFOR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))

using namespace std;

typedef complex<double> point;
typedef pair<int, int> paii;
typedef long long ll;

double dot(point va, point vb){
	return real(va) * real(vb) + imag(va) * imag(vb);
}

int main()
{
	int n;
	cin >> n;
	
	FOR(i, 0, n)
	{
		double x, y;
		point pt[4];
		
		FOR(j, 0, 4)
		{
			cin >> x >> y;
			pt[j] = point(x, y);
		}
		
		point s = pt[1] - pt[0], t = pt[3] - pt[2];
		
		double dt = dot(s, t);
		
		if( abs(dt - abs(s)*abs(t)) < 0.000000000000001 )
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	
	return 0;
}

C++: #include<stdio.h>

int main(){
  int n,i;
  double x1,y1,x2,y2,x3,y3,x4,y4;

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