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>

using namespace std;

int main(int argc, char **argv)
{
	int n;
	float s, t, m, a, b, k;
	cin >> n;
	while(n--){
		cin >> a >> b >> s >> t;
		k = 0;
		if(s-a == 0){
			m = 0;
			k = 1;
		} else if(t-b == 0){
			m = 0;
			k = 2;
		} else {
			m = (t-b)/(s-a);
		}
		cin >> a >> b >> s >> t;
		if(s-a == 0){
			if(k == 1){
				cout << "YES" << endl;
			} else {
				cout << "NO" << endl;
			}
		} else if(t-b == 0){
			if(k == 2){
				cout << "YES" << endl;
			} else {
				cout << "NO" << endl;
			}
		} else if(m == (t-b)/(s-a)){
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
 
int main(){
     
    int n;
    cin>>n;
    while(n--){
        double x1,y1,x2,y2,x3,y3,x4,y4;
        cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
        if(fabs(x1-x2)<1e-9){
            if(fabs(x3-x4)<1e-9)cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
        else{
            double a=(y1-y2)/(x1-x2);
            double b=(y3-y4)/(x3-x4);
            if(fabs(a-b)<1e-9)cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
    }
     
    return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
int main(){
  int n;
  double x[4],y[4];

  while(n--){
    for(int i = 0 ; i < 4 ; i++ )cin >> x[i] >> y[i];
    y[1]-=y[0];
    x[1]-=x[0];
    y[3]-=y[2];
    x[3]-=x[2];
    if(fabs(y[1]*x[3] - y[3]*x[1]) < 10e-10)cout << "YES";
    else cout << "NO";
    cout << endl;
    }
  return 0;
}

C++: 
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>

using namespace std;


bool solve(){
	double x[4],y[4];
	for(int i=0;i<4;i++){
		cin>> x[i]>> y[i];
	}
	if(x[1]==x[0] || x[3]==x[2]){
		if(x[1]==x[0] && x[3]==x[2]){
			cout<< "YES"<< endl;
		}else{
			cout<< "NO"<< endl;
		}
		return true;
	}
	double rad1 = atan( (y[1]-y[0]) / (x[1]-x[0]) );
	double rad2 = atan( (y[3]-y[2]) / (x[3]-x[2]) );
	if(rad1 == rad2){
		cout<< "YES"<< endl;
	}else{
		cout<< "NO"<< endl;
	}
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	int n;
	cin>> n;
	for(int i=0;i<n;i++){
		solve();
	}
	return 0;
}

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

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;
}