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 n; cin >> n;
	for (int i=0; i<n; i++) {
		double x1,x2,x3,x4,y1,y2,y3,y4;
		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<iostream>
using namespace std;
int main() {
	double zhyoxy[4], line1, line2;
	char hantei[2];
	int time;
	cin >> time;
	for (int i = 0; i < time; ++i) {
		for (int i = 0; i < 4; ++i) {
			cin >> zhyoxy[i];
		}
		if (zhyoxy[3] == zhyoxy[1]) {
			hantei[0] = 'y';
		}
		else if (zhyoxy[2] == zhyoxy[0]) {
			hantei[0] = 'x';
		}
		line1 = (zhyoxy[3] - zhyoxy[1]) / (zhyoxy[2] - zhyoxy[0]);
		for (int i = 0; i < 4; ++i) {
			cin >> zhyoxy[i];
		}
		if (zhyoxy[3] == zhyoxy[1]) {
			hantei[1] = 'y';
		}
		else if (zhyoxy[2] == zhyoxy[0]) {
			hantei[1] = 'x';
		}
		line2 = (zhyoxy[3] - zhyoxy[1]) / (zhyoxy[2] - zhyoxy[0]);
		if (line1 == line2||zhyoxy[0]==zhyoxy[1]) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

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

using namespace std;

int n;
double x1, x2, x3, x4, y1, y2, y3, y4, slope1, slope2;

double abs(double s) {
    return s < 0 ? -s : s;
}

int main(void) {
    cin >> n;
    while(n--) {
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
        slope1 = (y1 - y2) / (x1 - x2);
        slope2 = (y3 - y4) / (x3 - x4);

        if(slope1 == slope2) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}

C++: //0021
#include <bits/stdc++.h>
using namespace std;

int main(){
	double x1,y1,x2,y2,x3,y3,x4,y4;
	double AB,CD;
	int n;
	cin>>n;
	while(n--){
		cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;

		AB = (y1-y2)/(x1-x2);
		CD = (y3-y4)/(x3-x4);
		if(AB == CD)
			cout<<"YES"<<endl;

		else
			cout<<"NO"<<endl;
	}
	return 0;
}
//0021
#include <bits/stdc++.h>
using namespace std;

int main(){
	double x1,y1,x2,y2,x3,y3,x4,y4;
	double AB,CD;
	int n;
	cin>>n;
	while(n--){
		cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;

		AB = (y1-y2)/(x1-x2);
		CD = (y3-y4)/(x3-x4);
		if(AB == CD)
			cout<<"YES"<<endl;

		else
			cout<<"NO"<<endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <cmath>
#include <cfloat>

int n;

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; ++i){
		double x[4][2];
		for(int j = 0; j < 4; ++j){
			scanf("%lf%lf", x[j], x[j] + 1);
		}
		double y[2][2] = {
			{x[0][0] - x[1][0], x[0][1] - x[1][1]},
			{x[2][0] - x[3][0], x[2][1] - x[3][1]}
		};

		//printf("%lf\n", y[0][0] * y[1][1] - y[0][1] * y[1][0]);

		if(std::abs(y[0][0] * y[1][1] - y[0][1] * y[1][0]) < 1e-9){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	return 0;
}

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

C++: #include<iostream>
#include<cmath>
#include<cassert>
#include<cstdlib>
using namespace std;
#define EPS 0.0000001


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


		if (abs((y2 - y1)*(x4 - x3) - (y4 - y3)*(x2 - x1)) < EPS) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}

C++: #include <iostream>
#include <complex>
#include <cmath>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )

using namespace std;

typedef complex<double> P;

int main(){
  double x1,y1,x2,y2,x3,y3,x4,y4;
  int n;
  P a,b;
  cin>>n;
  for(;n>0;n--){
    cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
    a = P(x2-x1,y2-y1);
    b = P(x4-x3,y4-y3);
    if (abs(a/abs(a)-b/abs(b))<EPS)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}

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

int main(void){
    int n;
    cin >> n;
    rep(i,n) {

    double x[4],y[4],a,b,c,d,p,q,det,ansx,ansy;
    //入力を多少簡略化
    for(int i=0;i<4;i++) {
        scanf("%lf" ,&x[i]);
        scanf("%lf" ,&y[i]);
    }
    //(x1,y1)(x2,y2)を結ぶax+by=p の係数
    a = y[0]-y[1];  b = x[1]-x[0];
    p = x[1]*y[0]-x[0]*y[1];
    //(x3,y3)(x4,y4)を結ぶcx+dy=q の係数
    c = y[2]-y[3];  d = x[3]-x[2];
    q = x[3]*y[2]-x[2]*y[3];
    //係数についての行列式
    det = a*d-c*b;
    if(a*d == b*c) puts("YES");
    else puts("NO");
    /*
    //det=0で解は存在しない(この問題については２線分は同一直線上にないから)
    if(fabs(det) < 0.00001) puts("YES");
    //逆行列を用いて解を導出
    else {
        /*
        ansx = (d*p - b*q)/det;
        ansy = (-c*p + a*q)/det;
        //ansxがどちらの線分のx座標範囲にも含まれるかを判定
        if((x[0] - ansx)*(x[1] - ansx) <= 0.00001 && (x[2] - ansx)*(x[3] - ansx) <= 0.00001 ) {
            printf("YES (%lf, %lf)\n",ansx,ansy);
        } else puts("NO");
        
       puts("NO");
    }
    */
    
}

C++: //
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <array>
#include <numeric>
#include <functional>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<complex>

using namespace std;

#define REP(i,m,n) for(int i=m;i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef pair<int, int> pii;

// const ll inf = INT_MAX;
const double eps = 1e-5;
const double pi = acos(-1.0);
const int di[][2] = {{1,0},{0,1},{-1,0},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}};

int main(){
	int n;
	scanf("%d\n", &n);
	double x[4], y[4];
	rep(i,n){
		rep(j,4){
			scanf("%lf %lf", &x[j], &y[j]);
		}
		double dx[2], dy[2];
		dx[0] = x[1] - x[0];
		dx[1] = x[3] - x[2];
		dy[0] = y[1] - y[0];
		dy[1] = y[3] - y[2];
		if(std::abs(dy[1]*dx[0] - dy[0]*dx[1]) < eps) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>

#define FOR(i, a) for(int i=0;i<(int)a;++i)
typedef long long ll;
using namespace std;

void solver() {
    int N;
    cin>>N;
    for(int i=0;i<N;++i) {
        double x1, x2, x3, x4, y1, y2, y3, y4;
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
        auto slope1=(y2-y1)/(x2-x1);
        auto slope2=(y4-y3)/(x4-x3);
        if(slope1==slope2){
            cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }
}

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

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