Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n := nextInt()
	for i := 0; i < n; i++ {
		scanner.Scan()
		points := strings.Split(scanner.Text(), " ")
		fpoints := make([]float64, 0)
		for _, v := range points {
			tmp, _ := strconv.ParseFloat(v, 64)
			fpoints = append(fpoints, tmp)
		}
		if fpoints[0] == fpoints[2] && fpoints[4] == fpoints[6] {
			fmt.Println("YES")
		} else {
			a := (fpoints[1] - fpoints[3]) / (fpoints[0] - fpoints[2])
			b := (fpoints[5] - fpoints[7]) / (fpoints[4] - fpoints[6])
			if a == b {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		}
	}
}

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

int main(){
	int n;
	double t[100][8];
	cin >> n;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 8; j++){
			cin >> t[i][j];
		}
	}
	for(int i = 0; i < n; i++){
		if(t[i][0] == t[i][2]){
			if(t[i][4] == t[i][6]){
				cout << "YES" << endl;
			}
			else{
				cout << "NO" << endl;
			}
		}
		else if(t[i][1] == t[i][3]){
			if(t[i][5] == t[i][7]){
				cout << "YES" << endl;
			}
			else{
				cout << "NO" << endl;
			}
		}
		else if((t[i][1]-t[i][3])*(t[i][4]-t[i][6]) == (t[i][5]-t[i][7])*(t[i][0]-t[i][2])){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
}

C++: #include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
int n,AB,CD;
double ax,ay,bx,by,cx,cy,dx,dy,ab,cd,abx,aby,cdx,cdy;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		AB=CD=0;
		cin>>ax>>ay>>bx>>by>>cx>>cy>>dx>>dy;
		abx=(ax-bx);
		cdy=(cy-dy);
		aby=(ay-by);
		cdx=(cx-dx);
		if(abx==0.0&&aby==0.0)AB=1;
		if(cdx==0.0&&cdy==0.0)CD=1;
		if(abx*cdy==cdx*aby&&AB==0&&CD==0){
				cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  
  double x1, y1, x2, y2, x3, y3, x4, y4;
  int dataSets;
  cin >> dataSets;
  for(int i=0;i<dataSets;i++){
    bool flag=false;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;

    
    if((x2-x1)==0 || (x4-x3)==0){
      if((x2-x1) == (x4-x3)){
	if(x1==x3){
	  flag = true;
	}
      }
    }else if((y2-y1)/(x2-x1) == (y4-y3)/(x4-x3)){
      // cout << "here" << endl;
      flag = true;
    }

    if(flag){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
    
  }

}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <map>
#include <fstream>
#include <array>
#include <utility>
#include <functional>
#include <stack>
#include <math.h>

using namespace std;
typedef long long Int;
#define REP(i , x) for(Int i = 0 ; i < x ; ++i)
typedef pair<int, int> P;


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

	REP(i, n){
		double x1, y1, x2, y2, x3, y3, x4, y4;

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

		x1 *= 1000000;
		x2 *= 1000000;
		x3 *= 1000000;
		x4 *= 1000000;
		y1 *= 1000000;
		y2 *= 1000000;
		y3 *= 1000000;
		y4 *= 1000000;

		double dx1 = x2 - x1;
		double dx2 = x4 - x3;
		double dy1 = y2 - y1;
		double dy2 = y4 - y3;

		double ww = dy1 / dx1;
		double www = dy2 / dx2;

		string ans = (dy1 / dx1 == dy2 / dx2) ? "YES" : "NO";

		if (!dx1 || !dx2){
			ans = "NO";
		}

		cout << ans << endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
	double x1, y1, x2, y2, x3, y3, x4, y4;
	int N;
	cin >> N;
	
	for (int i=0; i<N; i++) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		
		if ( ( (x1==x2) && (y1==y2) ) || ( (x3==x4) && (y3==y4) ) ) {
			cout << "NO" << endl;
			continue;
		}
		
		long long int LHS = (1e+7 * (y2 - y1)) * (1e+7 * (x4 - x3));
		long long int RHS = (1e+7 * (y4 - y3)) * (1e+7 * (x2 - x1));
		cout << LHS << " " << RHS << endl;
		//if ( (y2 - y1) * (x4 - x3) == (y4 - y3) * (x2 - x1) ) cout << "YES" << endl;
		if ( LHS == RHS ) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
		
	return 0;
}

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

int main(){
    double x1, y1, x2, y2, x3, y3, x4, y4, 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 ((y2 - y1)/ (x2 - x1) == (y4 - y3) / (x4 - x3)){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
}

C++: #include <iostream>
     
int main() {
    int n;
    std::cin >> n;
    while(n--){
		double x1, y1, x2, y2, x3, y3, x4, y4;
		std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		int ix1 = x1*10000, iy1 = y1*10000, ix2 = x2*10000, iy2 = y2*10000,
			ix3 = x3*10000, iy3 = y3*10000, ix4 = x4*10000, iy4 = y4*10000;
		int a = iy1 - iy2, b = ix2 - ix1, c = iy3 - iy4, d = ix4 - ix3;
		if(!((long long int)a*d - (long long int)b*c))
			std::cout << "YES" << std::endl;
		else
			std::cout << "NO" << std::endl;
		}
    return 0;
}

C++: // うまくいくかどうかテスト

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

C++: #include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<memory>
#include<array>

using namespace std;

int main()
{
  array<double, 4> x;
  array<double, 4> y;

  int n;
  cin >> n;

  for ( auto j = 0; j < n; ++j )
    {
      for ( auto i = 0; i < 4; ++i )
        {
          cin >> x[i];
          cin >> y[i];
        }
      
      double abx = x[1] - x[0];
      double aby = y[1] - y[0];
      double cdx = x[3] - x[2];
      double cdy = y[3] - y[2];
      
      if ( abx * cdy - aby * cdx == 0 )
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    }
  
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <climits>
#include <utility>

#define PRINT(STR) cout << STR << endl;
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()

typedef long long ll;

using namespace std;

int nextInt() { int n = -1; cin >> n; return n; }
double nextDouble() { double d = -1; cin >> d; return d; }
ll nextll() { ll n = -1; cin >> n; return n; }
string nextString() { string str; cin >> str; return str; }

int INF = 9999999;
double EPS = 1e-17;
// BEGIN //////////////////////////////////////////////////////////////


int main() {
	int N;
	scanf("%d", &N);
	double x1, y1, x2, y2, x3, y3, x4, y4;
	for (int i = 0; i < N; i++) {
		 scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
		 double s = x1 - x2, t = y1 - y2, u = x3 - x4, v = y3 - y4;
		 if (s * v - t * u < EPS) {
			 PRINT("YES");
		 } else {
			 PRINT("NO");
		 }
	}

	return 0;
}

// END   //////////////////////////////////////////////////////////////

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

using namespace std;

#define error 1e-10

int main(){
	double x[5],y[5];
	int n;
	double parallel1,parallel2;

	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=1;j<5;j++)
			cin>> x[j]>> y[j];
		parallel1=(y[2]-y[1])/(x[2]-x[1]);
		parallel2=(y[4]-y[3])/(x[4]-x[3]);
		(fabs(parallel1-parallel2)<error) ? cout<<"YES"<<endl : cout<<"NO"<<endl;
	}
	return 0;
}