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 <complex>
#include <vector>

using namespace std;

typedef complex<double> P;
struct L : public vector<P> {
    L(const P &a, const P &b) {
        push_back(a);
        push_back(b);
    }
};

const double EPS = 1e-8;

int cross(P a, P b)
{
    return imag(conj(a) * b);
}

bool intersectLL(const L &l, const L &m)
{
    return abs(cross(l[1]-l[0], m[1]-m[0])) > EPS;
}

int main()
{
    int n;

    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        P p[4];
        double x, y;

        scanf("%lf %lf", &x, &y);
        p[0] = P(x, y);
        scanf("%lf %lf", &x, &y);
        p[1] = P(x, y);
        scanf("%lf %lf", &x, &y);
        p[2] = P(x, y);
        scanf("%lf %lf", &x, &y);
        p[3] = P(x, y);

        puts(intersectLL(L(p[0], p[1]), L(p[2], p[3])) ? "NO" : "YES");
    }

    return 0;
}

C++: /**
 * 
 */
import java.util.*;
/**
 * @author afterCmidday
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		final double eps = 1e-10;
		int n;
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt();
		for(int i = 0;i < n;i++){
			double x1 = scan.nextDouble(), y1 = scan.nextDouble(), x2 = scan.nextDouble(), y2 = scan.nextDouble();
			double a = x2 - x1, b = y2 - y1;
			double x3 = scan.nextDouble(), y3 = scan.nextDouble(), x4 = scan.nextDouble(), y4 = scan.nextDouble();
			double c = x4 - x3, d = y4 - y3;
			double e = a * d - b * c;
			if(Math.abs(e) < eps){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}

	}

}

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;
		}
		
		double LHS = 1000000.0 * (y2 - y1) * (x4 - x3);
		double RHS = 1000000.0 * (y4 - y3) * (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<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<string>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

typedef long long ll;


int main()
{
	int n;
	cin >> n;
	double x1, y1, x2, y2, x3, y3, x4, y4;
	for(int i=0;i<n;i++){
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		double a = (y2 - y1)*(x4 - x3) - (y4 - y3)*(x2 - x1);
		if (fabs(a) < EPS )printf("YES\n");
		else printf("NO\n");
	}
	
	return 0;
}

C++: #include <iostream>
#include <string>
#include <cctype>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <map> // pair
#include <set>
#include <string>

#define MAXSIZE 200000
#define PI 3.141592653589
using namespace std;

template<typename T>
T add(T a,T b){
  return a+b;
}

namespace A
{
  int f(void){
    return 1;
  }
}


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

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

    if(abs((x1-x2)*(y3-y4)-(x3-x4)*(y1-y2))<0.000001){
      std::cout << "YES" << '\n';
    }else{
      std::cout << "NO" << '\n';
    }
  }
}

C++: #include <iostream>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
using namespace std;
typedef long long  ll;
const int MAX = 10000;

/** Problem0021 : Parallelism **/
int main()
{
	int n;
	cin >> n;
	rep(k, n) {
		double x1, y1, x2, y2, x3, y3, x4, 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 <bits/stdc++.h>

using namespace std;
typedef long long ll;

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

    float Ax, Ay, Bx, By, Cx, Cy, Dx, Dy;
    vector<pair<float, float> > A;
    vector<pair<float, float> > B;
    vector<pair<float, float> > C;
    vector<pair<float, float> > D;

    for(int i = 0; i < n; i++){
        cin >> Ax >> Ay >>  Bx >>  By >>  Cx >>  Cy >>  Dx >> Dy;
        A.push_back(make_pair(Ax, Ay));
        B.push_back(make_pair(Bx, By));
        C.push_back(make_pair(Cx, Cy));
        D.push_back(make_pair(Dx, Dy));
    }

    for(int i = 0; i < n; i++){
        float a = 0;
        float b = 0;
        //0除算対策
        if(A[i].first == B[i].first ){
            a = 9999999;
        }else{
            a = (A[i].second - B[i].second) / (A[i].first - B[i].first);
        }

        if(C[i].first == D[i].first){
            b = 9999999;
        }else{
             b = (C[i].second - D[i].second) / (C[i].first - D[i].first);
        }

        if(a == b){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define EPS 1e-6

using namespace std;

typedef complex<double> P;

int main()
{
	int n;
	cin >> n;
	while(n--)
	{
		vector<P> p;
		rep(i,4)
		{
			double a,b;
			cin >> a >> b;
			p.push_back(P(a,b));
		}

		P a = p[1] - p[0];
		P b = p[3] - p[2];
		double t = a.real()*b.imag() - a.imag()*b.real();
		if(fabs(t) < EPS)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
	return 0;
}

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

int main(int argc, char const* argv[]) {
  int n;
  cin >> n;
  for (int i = 0; i < n; i += 1) {
    float x1, y1, x2, y2, x3, y3, x4, y4;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
    float AB, CD;
    AB = (x2-x1!=0)?(y2-y1)/(x2-x1):0;
    CD = (x4-x3!=0)?(y4-y3)/(x4-x3):0;
    if (AB == 0 && CD == 0) {
      float vAB = y2-y1, vCD = y4-y3;
      if (vAB == vCD) cout<<"YES"<<endl;
      else cout<<"NO"<<endl;
    } else {
      if (AB == CD) cout<<"YES"<<endl;
      else cout<<"NO"<<endl;
    }
  }
  return 0;
}

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

#define EPS 1e-10

int main() {
    int n; cin >> n;
    double x1, y1, x2, y2, x3, y3, x4, y4;
    for (int i = 0; i < n; i++) {
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
        if (abs(x1-x2) < EPS && abs(x3-x4) < EPS) {
            if (abs(x1-x3) > EPS) cout << "YES" << endl;
            else cout << "NO" << endl;
            continue;
        }

        double s1 = (y2-y1)/(x2-x1);
        double s2 = (y4-y3)/(x4-x3);
        if ( abs(s1-s2) < EPS ) {
            if ( abs((y1 - x1 * s1) - (y3 - x3 * s2)) < EPS ) {
                cout << "NO" << endl;
            } else {
                cout << "YES" << endl;
            }
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}

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

using namespace std;
double cross(long double x1,long double y1,long double x2,long double y2);

int main(){
	long double x1,y1,x2,y2;
	long double x3,y3,x4,y4;
	long double ans1,ans2;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
	cin>>x1>>y1>>x2>>y2;
	cin>>x3>>y3>>x4>>y4;
	ans1=cross(x1,y1,x2,y2);
	ans2=cross(x3,y3,x4,y4);
	//cout<<ans1<<" "<<ans2<<endl;
	if(ans1-ans2==0.0)
		cout<<"YES"<<endl;
	else 
		cout<<"NO"<<endl;
	}
}


double cross(long double x1,long double y1,long double x2,long double y2){
	return (x1-x2)/(y1-y2);
}