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 <cstdio>
#include <cmath>
main(){
	double a,b,c,d,e,f,g,h;
	for(scanf("%lf",&a);~scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f,&g,&h);)
		puts(fabs((c-a)*(h-f)-(d-b)*(g-e))>1e-10?"NO":"YES");
	return 0;
}

C++: #include <stdio.h>

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

  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( (y2-y1)/(x2-x1) == (y4-y3)/(x4-x3) ){
      printf("YES\n");
    }else{
      printf("NO\n");
    }
  }
  return 0;
  
}

C++: #include<stdio.h>

int main(void){
	int n,i;
	double ax,ay,bx,by,cx,cy,dx,dy;	//入力
	double ab,cd;	//傾き;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&ax,&ay,&bx,&by,&cx,&cy,&dx,&dy);
		//傾きを求める
		ab=(by-ay)/(bx-ax);
		cd=(dy-cy)/(dx-cx);
		if(ab==cd)
			printf("YES\n");
		else
			printf("NO\n");
	}

	return 0;
}

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

int main(){

	typedef struct{
		double x, y;
	}_td;

	int n;
	_td p1, p2, p3, p4;
	double del, eps;
	eps = 0.000001;
	
	cin >> n;
	
	for(int i=0; i<n; i++){
		cin >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y >> p4.x >> p4.y;
		del = (p2.x - p1.x) * (p4.y - p3.y) - (p2.y - p1.y) * (p4.x - p3.x);
		if(abs(del) < eps) cout << "YES" << endl;
		else cout << "NO" << endl;
	}

	return 0;

}

C++: #define	_USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
using namespace std;

int main(){

	int n;
	cin>>n;
	double x1,y1,x2,y2,x3,y3,x4,y4;
	
	while(n>0){
		double a=99999,b=99999;
	cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
		
		if(x2!=x1){
		a=(y2-y1)/(x2-x1);
		}
		if(x4!=x3){
		b=(y4-y3)/(x4-x3);
		}
		if(a==b)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
		
		n--;
	}
}

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

using namespace std;

int main(){

	int n; cin >> n;
	double x[4],y[4]; //??\????????§?¨?

	for(int i=0;i<n;i++){
		for(int j=0;j<4;j++){
			cin >> x[j] >> y[j];
		}

		if( (y[0]-y[1])*(x[3]-x[2]) + (x[0]-x[1])*(y[2]-y[3])  == 0){

			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}

	}
	return 0;
}

C++: #include <iostream>

using namespace std;

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

  return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
using namespace std;
typedef pair<int, int> pii;
#define MAX 99999999
int main(){
    typedef pair<double, double>pdd;
    vector<pdd>v(5);
    int n;cin>>n;
    rep(i,n){
        rep(i,4)cin>>v[i].first>>v[i].second;
        double d1=(v[0].second-v[1].second)/(v[0].first-v[1].first);
        double d2=(v[2].second-v[3].second)/(v[2].first-v[3].first);
        if(abs(d1-d2)<EPS)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}

C++: #include<stdio.h>

int main(void)
{
	double a[2]={0},b[2]={0},c[2]={0},d[2]={0},x1,x2,y1,y2;
	int i;
	scanf("%d",&i);//繰り返す回数の入力

	while(i!=0)
	{
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&a[0],&a[1],&b[0],&b[1],&c[0],&c[1],&d[0],&d[1]);//入力した数の読み込み
		x1 = b[0]-a[0];   y1 = b[1]-a[1];//傾きを求めるのに必要な数を求める
		x2 = d[0]-c[0];   y2 = d[1]-c[1];
		if(x1==0 && x2==0)//傾き0のときは０で割ることができないため
			printf("YES\n");
		else if(x1==0 || x2==0)//片方が傾き0のとき
			printf("NO\n");
		else if(y1/x1 == y2/x2)//傾きが等しい＝平衡
			printf("YES\n");
		else //傾きが等しくない＝平衡ではない
			printf("NO\n");

		i-=1;
	}
 return 0;
}

C++:  
 #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 
 using namespace std;
 
 double abs(double x)
 {
   if(x<0) return -x;
   else return x;       
 }
  
 int main()
 {
   double x1,y1,x2,y2,x3,y3,x4,y4;
   int n;
   cin>>n;
   while(n--)
   {
     cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
     if(x2==x1&&x3==x4) cout<<"YES"<<endl;
     else 
     {
       double k1=(y2-y1)/(x2-x1);
       double k2=(y4-y3)/(x4-x3);
       if(abs(k1-k2)<0.01) cout<<"YES"<<endl;
       else cout<<"NO"<<endl;     
     }          
   }
   //while(1);      
   return 0;    
 }

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++)

// 主に以下の資料を参考に作成した。
// - http://www.prefield.com/algorithm
// - http://www.deqnotes.net/acmicpc/2d_geometry/
// - https://github.com/infnty/acm/tree/master/lib/geometry
// - サークルの先輩が作ったライブラリ

/* 基本要素 */

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-9;    // 許容誤差。問題によって変える
#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 a = P(x1, y1);
    P b = P(x2, y2);
    P c = P(x3, y3);
    P d = P(x4, y4);
    
    if (EQ(cross(a-b, c-d), 0)) {
      std::cout << "YES" << std::endl;
    }else {
      std::cout << "NO" << std::endl;
    }
  }

  
  return 0;
}

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

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

int main(){
  int n;cin>>n;
  for(int i=0;i<n;++i){
    vector<pair<double, double>> coordinates;
    for(int j=0;j<4;++j){
      double a,b;cin>>a>>b;
      coordinates.emplace_back(make_pair(a,b));
    }
    int tan1,tan2;
    tan1 =10000*fabs((coordinates[2].second-coordinates[1].second)/(coordinates[2].first-coordinates[1].first));
    tan2 =10000*fabs((coordinates[4].second-coordinates[3].second)/(coordinates[4].first-coordinates[3].first));
   // cout<<tan1<<" "<<tan2<<endl;
    tan1 == tan2 ? cout<<"YES"<<endl : cout<<"NO"<<endl;
  }
  return EXIT_SUCCESS;
}