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 <stdio.h>
#include <string.h>
#include <string>
#include <algorithm>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>

#define abs(a) (a > 0 ? a:-a)
using namespace std;

void q21() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		double ax, ay, bx, by, cx, cy, dx, dy;
		cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy;
		if (bx - ax == 0 || dx - cx == 0) {
			if (bx - ax == dx - cx) {
				cout << "YES" << endl;
				continue;
			}
		}
		else if (abs((by - ay) / (bx - ax) - (dy - cy) / (dx - cx)) <= 0.00001 ){
			cout << "YES" << endl;
			continue;
		}
		cout << "NO" << endl;
	}
}

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

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <cstdlib>
#include <queue>
#include <vector>
#include <set>
#include <stdio.h>
#include <cstdio>
#include <cmath>
#include <complex> 
using namespace std;
typedef complex<double> xy_t;
xy_t P[2];
int N;
double x,y,z,w;
const double eps = 1e-11;
int main() {
cin >> N;
for( int j = 0;j < N ;j++) {
for(int i = 0;i < 2;i++) {
	cin >> x >> y >> z >> w;
	P[i] = xy_t(z-x,w-y);
}
	double s =  (P[0].real()*P[1].imag()-P[0].imag()*P[1].real())/2;
bool p;
if (abs(s) < eps) p = true;
else p = false;
cout << (p ? "YES" : "NO") << endl;
}
}

C++: #include <algorithm>
#include <vector>
#include <complex>
using namespace std;
//---------------------------------------------------------------
using Point = complex<double>;
const double eps = 1e-10;
double cross(const Point &a, const Point &b) { return imag(conj(a) * b); }
//---------------------------------------------------------------

#include <iostream>
int main() {
    int n; cin >> n;
    while (n--) {
        vector<double> x(4), y(4);
        for (int i = 0; i < 4; i++) {
            cin >> x[i] >> y[i];
        }
        Point v[2] = {
            Point(x[0], y[0]) - Point(x[1], y[1]),
            Point(x[2], y[2]) - Point(x[3], y[3])
        };
        double res = cross(v[0], v[1]);
        cout << (abs(res) < eps ? "YES" : "NO") << endl;
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

class Vector2D {
  private:
    double x;
    double y;
  public:
    Vector2D(double, double);
    Vector2D operator - (Vector2D vec2) {
      double newX = this->x - vec2.x;
      double newY = this->y - vec2.y;
      Vector2D newvec(newX, newY);
      return newvec;
    }
    double GetX() { return x; };
    double GetY() { return y; };
    bool isParallel(Vector2D);
};

Vector2D::Vector2D(double _x, double _y) {
  x = _x;
  y = _y;
}

bool Vector2D::isParallel(Vector2D vec2) {
  if (x == 0 && vec2.GetX() == 0)
    return true;
  else if (y == 0 && vec2.GetY() == 0)
    return true;
  else if (vec2.GetX()/x == vec2.GetY()/y)
    return true;
  else
    return false;
}

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

  double x1,y1,x2,y2,x3,y3,x4,y4;
  for (int dataset_i = 0; dataset_i < n; dataset_i++) {
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
    Vector2D vecAB = Vector2D(x2,y2) - Vector2D(x1,y1);
    Vector2D vecCD = Vector2D(x4,y4) - Vector2D(x3,y3);
    cout << (vecAB.isParallel(vecCD) ? "YES" : "NO") << endl;
  }

  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  double ax,ay,bx,by,cx,cy,dx,dy,ans1,ans2,x,y;
   for(int i=0;i<n;i++){
     cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy;
     x = ax - bx;
     y = ay - by;
     ans1 = y / x;
     x = cx - dx;
     y = cy - dy;
     ans2 = y / x;
     if(ans1==ans2) cout << "YES" << endl;
     if(ans1!=ans2) cout << "NO" << endl;
   }
   return 0;
}

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

class vec2d {
public:
  double x,y;
  void set(double x=0.0,double y=0.0) {
    this->x = x;
    this->y = y;
  }
};
double cross(vec2d A,vec2d B) {
  return (A.x*B.y - B.x*A.y);
}
bool is_paralles(vec2d A,vec2d B) {
  if(cross(A,B) == 0.0) return true;
  return false;
}

int main() {
  int n;
  vec2d AB,CD;
  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;
    AB.set(x2-x1,y2-y1);
    CD.set(x4-x3,y4-y3);
    if(is_paralles(AB,CD)) {
      cout << "YES" << endl;
    }
    else {
      cout << "NO" << endl;
    }
  }
}

C++: #include<iostream>

using namespace std;

int main(){
	int n;
	cin >> n;
	while (n--){
		double a[2], b[2], c[2], d[2];
		cin >> a[0] >> a[1] >> b[0] >> b[1] >> c[0] >> c[1] >> d[0] >> d[1];
		if ((b[0] - a[0])*(d[1] - c[1]) - (b[1] - a[1])*(d[0] - c[0]) == 0) cout << "YES" << endl;
		else cout << "NO" << endl;
	}

	return 0;

}

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

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

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
double x1,Y1,x2,y2,x3,y3,x4,y4;
int n;
int main()
{
  cin>>n;
  for(int i = 0;i < n;i++){
    cin>>x1>>Y1>>x2>>y2>>x3>>y3>>x4>>y4;
    double a =(Y1-y2)/(x1-x2);
    double b =(y4-y3)/(x4-x3);
    if(x1-x2==0 && x4-x3==0){
      cout <<"YES"<<endl;
    }
      if(a==b)
      cout <<"YES"<<endl;
    else
      cout<<"NO"<<endl;
  }
  return 0;
}

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

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 (abx * cdy - aby * cdx == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return;

}

C++: #include <cstdio>

int main(int argc, char *argv[]) {
	int dataN;
	scanf("%d", &dataN);
	for (int i = 0; i < dataN; i++) {
		float x1, y1, x2, y2, x3, y3, x4, y4;
		scanf("%f %f %f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
		
		float res1 = 1.0f, res2 = 2.0f;
		bool flg1 = false, flg2 = false;
		
		if (x2 > x1) res1 = (y2-y1)/(x2-x1);
		else if (x2 == x1) flg1 = true;
		else res1 = (y1-y2)/(x1-x2);
		
		if (x4 > x3) res2 = (y4-y3)/(x4-x3);
		else if (x4 == x3) flg2 = true;
		else res2 = (y3-y4)/(x3-x4);
		
		if (res1 == res2) {
			puts("YES");
		}
		else {
			if (flg1 && flg2) puts("YES");
			else puts("NO");
		}
	}
	return 0;
}

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

typedef complex<double> xy_t;
double x[4], y[4];

const double EPS = 1e-11;
int main()
{
    int N;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < 4; j++) {
            cin >> x[j] >> y[j];
        }
        if (abs((y[1] - y[0])*(x[3] - x[2]) - (y[3] - y[2])*(x[1] - x[0])) < EPS)
            cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}