Go: package main

import "fmt"

func abs(x float64) float64 {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	var n int
	var x1, y1, x2, y2, x3, y3, x4, y4 float64
	fmt.Scan(&n)
	for i := 0 ; i < n; i++ {
		fmt.Scanf("%f %f %f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4)
		if abs((x2-x1)*(y4-y3) - (y2-y1)*(x4-x3)) < 1e-10 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

C++: #include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <math.h>
#include <functional>
#include <algorithm>

typedef long long Int;
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
using namespace std;

int main(){
	int n;
	cin >> n;

	REP(i, n){

		double p[8];
		REP(i, 8){
			cin >> p[i];
		}

		double dx1 = (p[0] - p[2]);
		double dx2 = (p[4] - p[6]);
		double dy1 = (p[1] - p[3]);
		double dy2 = (p[5] - p[7]);


		if (!dx1||!dx2){
			if (!dy1&&!dy2){
				cout << "YES" << endl;
				continue;
			}
			cout << "NO" << endl;
			continue;
		}

		string ans = (abs(dy2/dx2-dy1/dx1) < 1e-8 ) ? "YES" : "NO";


		cout << ans << endl;
	}
	return 0;
}

C++: #include <stdio.h>

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

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

C++: #include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
#define INF 0x7FFFFFFF
const double EPS = 1e-10;


inline bool eq(double a, double b) { return fabs(b - a) < EPS;}

struct p_t{
  double x;
  double y;
  double norm() { return x * x + y * y; }
  double abs() { return sqrt(norm()); }
};
struct l_t{
	p_t a, b;
};

double cross(p_t p,p_t q);
p_t line(p_t p,p_t q);

bool asc(p_t left,p_t right) {
    return left.x == right.x ? left.y < right.y : left.x < right.x;
}
int Crosspoint(l_t l,l_t m);

int main(){
  int n;
  cin>>n;
  for(int t=0;t<n;t++){
    p_t p,q,r,k,s;
    cin>>p.x>>p.y>>q.x>>q.y>>r.x>>r.y>>k.x>>k.y>>s.x>>s.y;
    l_t pq,qr,rp,ks;
    pq.a=p;
    pq.b=q;
    qr.a=q;
    qr.b=r;
    rp.a=r;
    rp.b=p;
    ks.a=k;
    ks.b=s;
    int ans=0;
    ans+=Crosspoint(pq,ks);
    ans+=Crosspoint(qr,ks);
    ans+=Crosspoint(rp,ks);
    if(ans==1){
      cout<<"OK"<<endl;
    }
    else{
      cout<<"NG"<<endl;
    }
  }
}


p_t line(p_t p,p_t q){
  p_t z;
  z.x=q.x-p.x;
  z.y=q.y-p.y;
  return z;
}


double cross(p_t p,p_t q){
  return p.x*q.y-p.y*q.x;
}

int Crosspoint(l_t l,l_t m){
  p_t aa,bb,cc,dd;
  aa.x=l.b.x-l.a.x;
  aa.y=l.b.y-l.a.y;
  bb.x=m.b.x-m.a.x;
  bb.y=m.b.y-m.a.y;
  cc=aa;
  dd.x=l.b.x-m.a.x;
  dd.y=l.b.y-m.a.y;
	double A = cross(aa,bb);
	double B = cross(cc,dd);
	if (abs(A) < EPS && abs(B) < EPS) return 0;
  if(B/A>0&&B/A<1) return 1;
  return 0;
}

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

using namespace std;

int main(){
    
  int n;
  cin >> n;
  while(n--){

    double x1,x2,x3,x4;
    double y1,y2,y3,y4;

    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
    if( ( y2 - y1 ) / ( x2 - x1 ) == ( y4 - y3 ) / ( x4 - x3 ) ){
      printf("YES\n");
    }
    else printf("NO\n");
  }
}

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

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

C++: #include <iostream>

using namespace std;

typedef struct myvector{
  double x;
  double y;
}Vector;

Vector sub_vector(Vector& a, Vector& b)
{
  Vector ret;
  ret.x = b.x - a.x;
  ret.y = b.y - a.y;
  return ret;
}

double cross_product(Vector& a, Vector& b)
{
  return a.x * b.y - b.x * a.y;
}

int main()
{
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    Vector A, B, C, D;
    cin >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y >> D.x >> D.y;
    Vector AB = sub_vector(A, B);
    Vector CD = sub_vector(C, D);
    if(cross_product(AB, CD) == 0)
      cout << "YES" << endl;
    else 
      cout << "NO" << endl;
  }
}

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

using namespace std;
typedef pair<double, double> P;

void solve()
{
	int n;
	while(cin >> n)
	{
		while(n--)
		{
			vector<P> p(4);
			for(int i = 0; i < 4; ++i)
			{
				cin >> p[i].first >> p[i].second;
			}
			if((p[0].first == p[1].first && p[0].second == p[1].second) || (p[2].first == p[3].first && p[2].second == p[3].second))
			{
				cout << "NO" << endl;
			}
			else if((p[0].first == p[1].first && p[2].first != p[3].first) || (p[0].first != p[1].first && p[2].first == p[3].first))
			{
				cout << "NO" << endl;
			}
			else if((p[1].second - p[0].second) / (p[1].first - p[0].first) == (p[3].second - p[2].second) / (p[3].first - p[2].first))
			{
				cout << "YES" << endl;
			}
			else
			{
				cout << "NO" << endl;
			}
		}
	}
}

int main()
{
	solve();
	return(0);
}

C++: #include<stdio.h>
#include<string.h>
#include<iostream>

using namespace std;
double cross(double x1,double y1,double x2,double y2);

int main(){
	double x1,y1,x2,y2;
	double x3,y3,x4,y4;
	double ans1,ans2;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
	cin>>x1>>y1>>x2>>y2;
	cin>>x3>>y3>>x4>>y4;
	ans1=cross(x1,y1,x2,y2);
	ans2=cross(x3,y3,x4,y4);
	if(ans1==ans2)
		cout<<"YES"<<endl;
	else 
		cout<<"NO"<<endl;
	}
}


double cross(double x1,double y1,double x2,double y2){
	return (x1-x2)/(y1-y2);
}

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

int main()
{
  int n;
  float x[2], y[2], a[2];

  scanf("%d", &n);
  for (int i = 0; i < n; i++){
    for (int j = 0; j < 2; j++){
      for (int k = 0; k < 2; k++){
        scanf("%f%f", &x[k], &y[k]);
      }
      a[j] = (y[1] - y[0]) / (x[1] - x[0]);
    }
    if (a[0] == a[1]){
      puts("YES");
    }
    else {
      puts("NO");
    }
  }

  return (0);
}

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

C++: #include <iostream>
#include <string>
#include <vector>
#include <cmath>
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;
        if (y1 == y2 && y3 == y4) {
            cout << "YES" << endl;
            continue;
        } else if (y1 == y2 || y3 == y4) {
            cout << "NO" << endl;
            continue;
        }
        double a = (x2 - x1) / (y2 - y1);
        double b = (x4 - x3) / (y4 - y3);
        if (abs(a - b) < 1e-8) {
            cout << "YES" << endl;
            continue;
        }
        cout << "NO" << endl;
    }
    return 0;
}