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 <cstdio>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main() {

	int n;
	double x[4] = { 0 }, y[4] = { 0 }, slope[2] = { 0 };
	bool ans[100];

	cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 4; j++) {
			cin >> x[j] >> y[j];
		}
		slope[0] = (y[1] - y[0]) / (x[1] - x[0]);
		slope[1] = (y[3] - y[2]) / (x[3] - x[2]);

		if (slope[0] == slope[1])
			ans[i] = true;
		else
			ans[i] = false;

		slope[0] = slope[1] = 0;

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

	for (int i = 0; i < n; i++) {
		if (ans[i])
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}

	return 0;
}

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

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

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

  return 0;
}

C++: #include<stdio.h>

int main(){

	int n=1, i, x[3][4000] = {},  y=0;

	for (n = 1; n > 0;n++){
		
		scanf("%d", &n);if (n == 0){ break; }

		for (i = 0; i < n; i++){
			scanf("%d %d %d",&x[0][i],&x[1][i],&x[2][i]);
		}
		for (i = 0; i < n; i++){
			if (x[1][i] * x[2][i] > 1000000){
				printf("%d\n", x[0][i],y++);
			}	
		}
		if (y == 0){ printf("NA\n"); y = 0; };
	}
	return 0;
}

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

int main(){
	int t;
	double x1, y1, x2, y2, x3, y3, x4, y4;
	scanf("%d", &t);
	while(t--){
		scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
		//printf("%f\n%f\n", (x2 - x1) * (y4 - y3), (x4 - x3) * (y2 - y1));
		printf("%s\n", ((double)(x2 - x1) * (y4 - y3) == (double)(x4 - x3) * (y2 - y1))? "YES" : "NO");
	}
	return 0;
}

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

int main(void) {
    double x1, y1, x2, y2, x3, y3, x4, y4;
    double slope1, slope2;
    int n;
    
    cin >> n;
    for(int i = 0; i < n; ++i) {
        scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
        slope1 = (y2 - y1) * (x4 - x3);
        slope2 = (y4 - y3) * (x2 - x1);
        
        if(abs(slope1 - slope2) < 0.0000000001) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
}

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

bool solve();

int main(){
	int n;cin>>n;
	while(n--){
		if(solve()){
			cout<<"YES";
		}else{
			cout<<"NO";
		}
		cout<<endl;
	}	
	return 0;
}

bool solve(){
	double x1,x2,y1,y2;
	double vx1,vx2,vy1,vy2;
	
	cin>>x1>>y1>>x2>>y2;
	vx1=x2-x1;vy1=y2-y1;
	cin>>x1>>y1>>x2>>y2;
	vx2=x2-x1;vy2=y2-y1;
	
	//vx1:vy1=vx2:vy2
	return (vx1*vy2==vy1*vx2);
}

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

bool hantei(double x[], double y[]);

int main() {
  int n;
  double x[4], y[4];
  scanf("%d", &n);
  for(int i=0;i<n;i++) {
    for(int j=0;j<4;j++) scanf("%lf %lf", &x[j], &y[j]);
    if(hantei(x, y))
      printf("YES\n");
    else printf("NO\n");
  }
}

bool hantei(double x[], double y[]) {
  if(x[0]==x[1]) {
    if(x[2]==x[3]) return true;
    else return false;
  } else if(x[2]==x[3]) return false;
  else {
    if(x[1]-x[0]/y[1]-y[0] == x[3]-x[2]/y[3]-y[2]) return true;
    else  return false;
  }
}

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

int main() {
	typedef complex<double> com;
	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;
		if ( - 1e-10 < ( conj( com( x2 - x1, y2 - y1 ) ) * com( x4 - x3, y4 - y3 ) ).imag() < 1e-10 )
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
}

C++: #include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
#define range(i, a, b) for (int i = a; i < b; ++i)
#define rep(i, n) range(i, 0, n)
const ll INF = 1e10;
#define pb push_back

int main()
{
    int n;
    cin >> n;
    rep(i, n)
    {
        vector<double> x(4), y(4);
        rep(j, 4) cin >> x[j] >> y[j];
        double a = (x[3] - x[2]) * (y[1] - y[0]) - (x[1] - x[0]) * (y[3] - y[2]);
        if (a != 0) {
            cout << "NO" << endl;
        } else {
            cout << "YES" << endl;
        }
    }
}

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

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

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

  return 0;
}

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

#define EPS (1e-9)
 
double cross(double x1,double y1,double x2,double y2){
	return ((x1*y2)-(x2*y1));
}
int main(){
	int n;
	while(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;
			if(EPS>fabs(cross((x2-x1) ,(y2-y1), (x4-x3), (y4-y3))))
				cout<<"YES"<<endl;
				else 
				cout<<"NO"<<endl;
		}
	}
	
}

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

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

C++: #include<cstdio>

int main(){
  int n;scanf("%d",&n);
  for(int i=0;i<n;i++){
    double d[8];
    for(int i=0;i<8;i++) scanf("%lf",&d[i]);
    if(d[1]==d[3]&&d[5]==d[7])
      puts("YES");
    else if((d[0]-d[2])*(d[5]-d[7])==(d[4]-d[6])*(d[1]-d[3]))
      puts("YES");
    else
      puts("NO");
  }
}

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

int main()
{
	double a, b, c, d, e, f, g, h;
	int x;
	cin >> x;
	for(int p=0;p<x;p++)
	{
		cin >> a >> b >> c >> d >> e >> f >> g >> h;
		double i = (d - b) / (c - a);
		double j = (h - f) / (g - e);
		if (i == j) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	return 0;
}