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;

void Solution()
{
    int n;
    
    cin>>n;
    
    while(n--)
    {
        float x1, y1;
        float x2, y2;
        float x3, y3;
        float x4, y4;
        
        cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
        
        float ab = (y2 - y1) / (x2 - x1); // when "y / x = " another line's data, it can be seen as parallel
        float cd = (y4 - y3) / (x4 - x3);
        
        if (ab == cd )
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }
    }
}

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

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

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

int main() {
	int n;
	double x1, x2, x3, x4, y1, y2, y3, y4;
	vector<double> X1, Y1, X2, Y2;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		X1.push_back(x2 - x1); Y1.push_back(y2 - y1);
		X2.push_back(x4 - x3); Y2.push_back(y4 - y3);
	}
	for (int i = 0; i < n; i++) {
		if (Y1[i] / X1[i] == Y2[i] / X2[i])cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

C++: #include<iostream>
#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)))) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
		if (x2 > x1&&x4 > x3 && ((y1 - y2) / (x2 - x1) == (y3 - y4) / (x4 - x3))) {
			cout << "YES" << endl;
		}
		else
			cout << "NO" << endl;
	}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
#include <complex>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;
const D EPS = (1e-10);    // 許容誤差。問題によって変える
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

// 内積　dot(a,b) = |a||b|cosθ
D dot(P a, P b) {
  return (conj(a)*b).X;
}
// 外積　cross(a,b) = |a||b|sinθ
D cross(P a, P b) {
  return (conj(a)*b).Y;
}


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;
    P a1 = P(x1, y1);
    P a2 = P(x2, y2);
    P a3 = P(x3, y3);
    P a4 = P(x4, y4);
    
    if (EQ(cross(a1-a2, a3-a4), 0)) {
      std::cout << "YES" << std::endl;
    }else {
      std::cout << "NO" << std::endl;
    }
  }

  
  return 0;
}

C++: #include<stdio.h>

int main(void){
	int n,i;
	float ax,ay,bx,by,cx,cy,dx,dy;
	float datax_1,datax_2,datay_1,datay_2;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%f %f %f %f %f %f %f %f",&ax,&ay,&bx,&by,&cx,&cy,&dx,&dy);
		datax_1=bx-ax;
		datax_2=dx-cx;
		datay_1=by-ay;
		datay_2=dy-cy;
		if(datax_1==datax_2 && datay_1==datay_2)
			printf("YES\n");
		else
			printf("No\n");
	}

	return 0;
}

C++: #include<stdio.h>
#include<math.h>

int main(){
	double x1,x2,x3,x4,y1,y2,y3,y4;
	int ans[100]={0};
	int n,i;
	
	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);
		
		if((x1==x2) && (x3==x4))printf("YES\n");
		else if((x1==x2) || (x3==x4))printf("NO\n");
		else if(((y1-y2)/(x1-x2)-(y3-y4)/(x3-x4))==0.0)printf("YES\n");
		else printf("NO\n");
	}	
return 0;
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<set>
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;
	bool f=0;
	cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
	double yy1=(y2-y1),yy2=y4-y3;
	if(yy1==0)yy1=0.0000001;
	if(yy2==0)yy2=0.0000001;
	double r1=(x2-x1) / (y2-y1);
	double r2=(x4-x3) / (y4-y3);
	if(abs(r1-r2 ) <=0.000001  )f=1;
	if(f)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

typedef pair<double, double> XY;

bool para(XY p, XY q) {
    double k;
    if (p.first == 0 && q.first == 0) return false;
    else k = q.first / p.first;
    if ((abs(p.second * k - q.second) * 1000000) < 1) return true;
    return false;
}

int main() {
    int n;
    cin >> n;
    REP(i,n) {
        double ax, ay, bx, by, cx, cy, dx, dy;
        cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy;
        XY AB = make_pair(ax-bx, ay-by);
        XY CD = make_pair(cx-dx, cy-dy);
        if (para(AB, CD)) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

C++: #include<iostream>
int main()
{
	int n;
	std::cin >> n;
	for (int i = 0; i < n; i++)
	{
		long double x1, y1, x2, y2, x3, y3, x4, y4;
		std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		std::cout << (x1 == x2 && x3 == x4 || (y1 - y2) / (x1 - x2) == (y3 - y4) / (x3 - x4) ? "YES" : "NO") << std::endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string.h>
#include <queue>
#include <stack>
#include <utility>
#include <queue>
#include <cmath>
#define mp make_pair
#define pii pair<int,int> 
#define ff first
#define ss second

using namespace std;

double x1,x2,x3,x4,y2,y3,y4,y5;//y1 crash with include cmath...
double g1,g2;
int tc;

int main()
{
	scanf("%d",&tc);
	while(tc--)
	{
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y5,&x2,&y2,&x3,&y3,&x4,&y4);
		/*g1=(y2-y5)/(x2-x1); //seeems broken with infinity loll
		g2=(y4-y3)/(x4-x3);
		printf("%.2lf,%.2lf\n",g1,g2);*/
		if(abs((x2-x1)*(y4-y3)-(x4-x3)*(y2-y5))<1e-10)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
		
	}
	return 0;
}

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

int main(){

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

  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<4;j++) cin>>x[j]>>y[j];
    if((y[1]-y[0])/(x[1]-x[0])==(y[3]-y[2])/(x[3]-x[2])) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }

  return 0;
}