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 <cstdio>
using namespace std;

const double EPS = 1e-9;

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

bool get_line( double , double , double , double , double& );

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

	double a1, a2;

	bool result1 , result2;

	int num;

	cin >> num;

	for( int i = 0 ; i < num ; i++ )
	{
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;

		result1 = get_line( x1 , x2 , y1 , y2 , a1 );
		result2 = get_line( x3 , x4 , y3 , y4 , a2 );

		if( result1 == false && result2 == false )
		{
			cout << "YES" << endl;
		}
		else
		{
			if( a1 - a2 >= -1e-10 && a1 - a2 <= 1e-10 ) cout << "YES" << endl;
			else cout << "NO" << endl;
		}
	}

	return 0;
}

bool get_line( double x1 , double x2 , double y1 , double y2 , double& a )
{
	if( x1 - x2 >= -1e-10 && x1 - x2 <= 1e-10 )
	{
		return false;
	}
	else
	{
		a = ( y1 - y2 ) / ( x1 - x2 );

		return true;
	}
}

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

int main(void){

	double n,x1,x2,x3,x4,y1,y2,y3,y4,x5,x6,y5,y6;

	cin>>n;
	for(int i=0;i<n;i++){
	cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
	x5=x2-x1;x6=x4-x3;
	y5=y2-y1;y6=y4-y3;
	if(x5*y6-x6*y5==0) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
	}
    return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
void judge(double,double,double,double,double,double,double,double);
#define EPS 0.00001

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;
		judge(x1, y1, x2, y2, x3, y3, x4, y4);
	}
	
	return 0;
}

void judge(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) {
	double abx = x2 - x1;
	double aby = y2 - y1;
	double cdx = x4 - x3;
	double cdy = y4 - y3;
	if (abs(abx * cdy - aby * cdx) <= EPS) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return;

}

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

#define EPS 1e-10
 
struct point{
	double x;
	double y;
};

struct line{
	double a;
	double b;
};

bool get_line( const point& a , const point& b , line *a_b );
istream& operator >> ( istream& s , point& p );
 
int main(void)
{
	point a, b, c, d;
 
    line a_b, c_d;
 
    bool result1 , result2;
 
    int num;
 
    cin >> num;
 
    for( int i = 0 ; i < num ; i++ )
    {
        cin >> a >> b >> c >> d;
 
        result1 = get_line( a , b , &a_b );
        result2 = get_line( c , d , &c_d );
 
        if( result1 == false && result2 == false )
        {
            cout << "YES" << endl;
        }
        else
        {
            if( fabs(a_b.a - c_d.a) < EPS ) cout << "YES" << endl;
            else cout << "NO" << endl;
        }
    }
 
    return 0;
}

istream& operator >> ( istream& s , point& p )
{
	return s >> p.x >> p.y;
}

bool get_line( const point& a , const point& b , line *a_b )
{
	if( fabs(a.x - b.x) < EPS ) return false;
	else{
		a_b->a = (a.y - b.y)/(a.x - b.x);
		a_b->b = a.y - (a.x * a_b->a);
		return true;
	}
}

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

using namespace std;

int main(){
  int n;
  cin >> n;
  for(int i=0;i<n;++i){
    double x1,y1,x2,y2,x3,y3,x4,y4;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
    double vx = x2-x1 , vy = y2-y1;
    double ux = x4-x3 , uy = y4-y3;
    if(abs(vx*uy-ux*vy)<1.e-8){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }
}

C++: #include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath>

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

int n;
double x[4];
double y[4];

int main(){
	scanf("%d", &n);
	rep(i, n){
		rep(j, 4){
			scanf("%lf%lf", x + j, y + j);
		}

		double dx[2];
		double dy[2];
		dx[0] = x[0] - x[1];
		dx[1] = x[2] - x[3];
		dy[0] = y[0] - y[1];
		dy[1] = y[2] - y[3];

		// printf("(%lf, %lf) (%lf, %lf)\n", dx[0], dy[0], dx[1], dy[1]);

		printf("%s\n", fabs(dx[0] * dy[1] - dx[1] * dy[0]) < 1e-9 ? "YES" : "NO");
	}
	return 0;
}

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

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

    double x1 = 0.0;
    double y1 = 0.0;
    double x2 = 0.0;
    double y2 = 0.0;
    double x3 = 0.0;
    double y3 = 0.0;
    double x4 = 0.0;
    double y4 = 0.0;

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

    double a = (y2 - y1) / (x2 - x1);
    double b = (y4 - y3) / (x4 - x3);
    double c = (y3 - y4) / (x3 - x4);
    if(a == b || a == c){
      cout << "YES" << endl;
    }
    else{
      cout << "NO" << endl;
    }
  }

  return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
  double a,b,c,d,e,f,g,h;
  int t;

  cin >> t;
  while(t--){
    cin >> a >> b >> c >> d >> e >> f >> g >> h;
    
    c -= a,d -= b,g -= e,h -= f;
    
    cout << (c*g-d*h ? "NO" : "YES") << endl;
  }
  
  return 0;
}

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

int main() {
  // ifstream cin("../test.txt");
  int n;
  cin >> n;
  while (n--) {
    double x[4], y[4];
    for (int i = 0; i < 4; i++) {
      cin >> x[i] >> y[i];
    }
    // if((x2-x1)*(y4-y3)==(x4-x3)*(y2-y1))cout<<"YES"<<endl;
    double d = (x[1] - x[0]) * (y[3] - y[2]) - (x[3] - x[2]) * (y[1] - y[0]);
    if ((x[1] - x[0]) * (y[3] - y[2]) == (x[3] - x[2]) * (y[1] - y[0])) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}

C++: #include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;


#define rep(i,n) for(int i=0;i<(n);i++)

const double EPS = 1e-6;
const double INF = 100000000;




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

    return 0;
}