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 <stdio.h>
#include <math.h>


int main(){
	double x1,x2,x3,x4,y1,y2,y3,y4,value1,value2;
	int n;
	scanf("%d",&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);
		value1 = (y1-y2)/(x1-x2);
		value2 = (x3-x4)/(y3-y4);

		if(value1 == value2){
			printf("YES\n");
		}else{
			printf("NO\n");
		}

	}
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9 + 7;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
const int mod = 1e9 + 7;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
using Point = complex<double>;
double dot(Point a, Point b) {return real(conj(a) * b);}
double cross(Point a, Point b) {return imag(conj(a) * b);}

int main() {
    int n; cin >> n;
    while (n--) {
        double xa, ya, xb, yb, xc, yc, xd, yd;
        cin >> xa >> ya >> xb >> yb >> xc >> yc >> xd >> yd;
        //cout << cross(Point(xa - xb, ya - yb), Point(xc - xd, yc - yd)) << endl;
        if (abs(cross(Point(xa - xb, ya - yb), Point(xc - xd, yc - yd))) < 1e-12) {
            cout << "YES" << endl;
        } else cout << "NO" << endl;
    }
}

C++: // 2014/07/21 Tazoe

#include <iostream>
using namespace std;

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;

		int X1 = (int)(x1*100000.0);
		int Y1 = (int)(y1*100000.0);
		int X2 = (int)(x2*100000.0);
		int Y2 = (int)(y2*100000.0);
		int X3 = (int)(x3*100000.0);
		int Y3 = (int)(y3*100000.0);
		int X4 = (int)(x4*100000.0);
		int Y4 = (int)(y4*100000.0);

		long long ABX = X2-X1;
		long long ABY = Y2-Y1;
		long long CDX = X4-X3;
		long long CDY = Y4-Y3;

//		cout << ABX*CDY << endl;
//		cout << ABY*CDX << endl;

		if(ABX*CDY==ABY*CDX){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}

	return 0;
}

C++: #include <iostream>
#include <stack>
#include <stdio.h>
#include <cmath>
using namespace std;
double x[4],y[4];//p,1,2,3
double a[2],b[2],c[2];
void make_line(double x1,double y1,double x2,double y2,int num){
	if(x1!=x2&&y1!=y2){
		a[num]=(y1-y2)/(x1-x2);
		b[num]=-1;
		c[num]=-a[num]*x1+y1;
	}else if(x1==x2){
		a[num]=1;
		b[num]=0;
		c[num]=-x1;
	}else if(y1==y2){
		a[num]=0;
		b[num]=1;
		c[num]=-y1;
	}
	return;
}
int main()
{
	int n;
	cin>>n;
	while(n--){
		bool ans=false;
		cin>>x[0]>>y[0]>>x[1]>>y[1]>>x[2]>>y[2]>>x[3]>>y[3];
		make_line(x[0],y[0],x[1],y[1],0);
		make_line(x[2],y[2],x[3],y[3],1);
		if(a[0]==0){
			ans=(a[1]==0);
		}else if(abs((b[0]/a[0])-(b[1]/a[1]))<0.00000001){
			ans=true;
		}
		printf(ans?"YES\n":"NO\n");
	}
    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cmath>
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(fabs(cross(A,B)) < 1e-12) return true;
  return false;
}

int main() {
  int n; cin >> n;
  for(int i=0;i<n;i++) {
    vec2d AB,CD;
    double x1,y1,x2,y2,x3,y3,x4,y4;
    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>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <climits>
using namespace std;

int main(){
    double EPS = 1e-12;
    double x[4];
    double y[4];
    double s;
    double t;
    double u;
    double v;
    int n;
    cin >> n;

    for (int t = 0;t < n;++t) {
        for (int i = 0;i < 4;++i){
            cin >> x[i] >> y[i]; 
        }
    }
    s = x[1] - x[0];
    t = y[1] - y[0];
    u = x[3] - x[2];
    v = y[3] - y[2];

    if(s * v - t * u > 0){
        double m = s * v - t * u;
    }
    else{
        double m = t * u - s * v;
    }

    if( m < EPS){
//        cout << "YES" << endl;
    }
//    else{
//        cout << "NO" << endl;
//    }
//    return 0;


    cout << "NO" << endl;
}

C++: #include<iostream>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ;  i++)
int main(void){
	int n;
	cin>>n;
	rep(k,n){
		double x[4];
		double y[4];
		double ans[2];
		rep(i,4)cin>>x[i]>>y[i];
		rep(i,2)ans[i] = (x[i+2] - x[i]) / (y[i+2]-y[i]);
		if(ans[0]==ans[1])cout<<"YES";
		else cout<<"NO";
		cout<<endl;
	}
}

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

int main(){
	int n;cin >> n;
	double a[8];
	while(n--){
		for(int i = 0;i < 8;i++)cin >> a[i];
		double y1 = a[3]-a[1];double x1 = a[2]-a[0];
		double y2 = a[7]-a[5];double x2 = a[6]-a[4];
		if(!x1 || !x2){
			if(!x1 && !x2)cout << "YES" << endl;
			else cout << "NO";
		}else{
			if(y1/x1 == y2/x2)cout << "YES" << endl;
			else cout << "NO" << endl;
		}
	}
	return 0; 
}

C++: #include <iostream>
#include <complex>
#include <cmath>
using namespace std;
constexpr double eps = 1e-11;
using C = complex<double>;

int main(){
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    C V[4];
    for(int j=0;j<4;j++){
      double x, y;
      cin >> x >> y;
      V[j] = C(x, y);
    }
    C AB = V[1] - V[0];
    C CD = V[3] - V[2];
    double area = (conj(AB) * CD).imag();
    if(abs(area) < eps)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}

C++: #include <cstdio>
#include <complex>
#include <vector>
#include <cmath>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

typedef complex<double> P;
typedef vector<P> VP;
const double EPF = 1e-2;

#define X real()
#define Y imag()
#define EQ(x,y) (abs(x-y) < EPF)

double dot(P a, P b) {
  return (conj(a)*b).X;
}
double cross(P a, P b) {
  return (conj(a)*b).Y;
}
double distPP(P a, P b) {
  return sqrt(dot(a-b,a-b));
}
P crosspoint(P a, P b, P c, P d) {//ac , bd
  double d1 = cross(d-b,b-a);
  double d2 = cross(d-b,c-a);
  if(EQ(d1,0) & EQ(d2,0)) return a;
  if(EQ(d2,0)) return a;
  return a + (c-a)*d1/d2;
}
P normal_vector(P a) {
  P b(-a.Y, a.X);
  return b;
}
P polar(double r, double theta) {
  P a(r*cos(theta),r*sin(theta));
  return a;
}

int main() {
  int n;
  scanf("%d",&n);
  REP(i,n) {
    double x,y;
    P a,b,c,d;
    scanf("%lf %lf", &x, &y);
    a = P(x,y);
    scanf("%lf %lf", &x, &y);
    b = P(x,y);
    scanf("%lf %lf", &x, &y);
    c = P(x,y);
    scanf("%lf %lf", &x, &y);
    d = P(x,y);
    
    if(EQ(cross(a-b, c-d),0))printf("YES\n");
    else printf("NO\n");
  }
  return 0;
}

C++: #define scanf_s scanf
//#define gets_s gets
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX 201
#define _MAX 100
#define ABC 26
int main(void)
{
	int n;
	double x1, y1, x2, y2, x3, y3, x4, y4, a1, b1, a2, b2;
	scanf_s("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf_s("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
		a1 = (y1 - y2) / (x1 - x2);
		a2 = (y3 - y4) / (x3 - x4);
		if (a1 == a2)
			printf("YES\n");
		else
			printf("NO\n");
	}
}