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;
double x1,y1,x2,y2;
double a,b,c,d;

double chaji(){
	double dx=x2-x1,dy=y2-y1;
	double aa=c-a,bb=d-b;
	return (dx*bb-dy*aa);
}
int main(){
	int N;cin>>N;
	while(N--){
		cin>>a>>b>>c>>d;
		cin>>x1>>y1>>x2>>y2;
		double ans1=chaji();
		x1=(x1+x2)/2;
		y1=(y1+y2)/2;
		x2=(a+c)/2;
		y2=(b+d)/2;
		if(x2==x1&&y2==y1){x2=a;y2=b;}
		double ans2=chaji();
		if(ans1==0&&ans2!=0)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}

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

using namespace std;
typedef complex<double> xy_t;  
const double eps = 1e-11;
double cross_product(xy_t a, xy_t b) {
    return (conj(a) * b).imag();
}

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];
        }
        xy_t a[2] = {
            xy_t(x[0], y[0]) - xy_t(x[1], y[1]),
            xy_t(x[2], y[2]) - xy_t(x[3], y[3])
        };
        bool p = abs(cross_product(a[0], a[1])) * 0.5 < eps;
        cout << (p ? "YES" : "NO") << endl;
    }
}

C++: #include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
using namespace std;
 
int main(){
    int n;
    cin>>n;
    rep(i,0,n){
        int ans=0;
        double x1,y1,x2,y2,x3,y3,x4,y4,m1,m2;
        cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
        if(x1==x2||x3==x4){
            if(x1==x2&&x3==x4) ans=1;
        }else{
            m1=(y2-y1)/(x2-x1);
            m2=(y4-y3)/(x4-x3);
            if(fabs(m1-m2)==0) ans=1;
        }
        if(ans) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
using namespace std;

int main() {
	int a; cin >> a;
	for (int b = 0; b < a; b++) {
		double x1, y1, x2, y2, x3, y3, x4, y4;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		double x5 = x2 - x1, y5 = y2 - y1, x6 = x4 - x3, y6 = y4 - y3;
		if (x5 == 0 && x6 == 0 || y5 == 0 && y6 == 0) {
			puts("YES");
		}
		else if (x5 == 0 || x6 == 0 || y5 == 0 || y6 == 0) {
			puts("NO");
		}
		else {
			if (abs(x6 / y6 - x5 / y5) <= 0.0000001)puts("YES");
			else puts("NO");
		}
	}
}

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

int main(){
  int n;
  double ax,ay,bx,by,cx,cy,dx,dy;

  cin >> n;
  for(int i=0;i<n;i++){
    cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy;
    if( !(ax-bx) && !(cx-dx) )cout << "YES\n";
    if( abs( (ay-by)/(ax-bx) - (cy-dy)/(cx-dx) ) < 1e-10)cout << "YES\n";
    else cout << "NO\n";
  }
}

C++: #include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define repf(i, f, l) for(int i = f; i < (int)l; ++i)

#ifdef ONLINE_JUDGE
#define DEBUG false
#else
#define DEBUG true
#endif

#define pb emplace_back
#define lb lower_bound
#define ul unsigned long
#define ull unsigned long long
#define ll long long
#define INF 1000000007
#define MOD 1000000007
#define fs first
#define sd second

#define ALL(c) (c).begin(),(c).end()

#define DBG0(x)    {if(DEBUG){ cout << #x << ": " << x << "\t"; }}
#define DBG(x)     {if(DEBUG){DBG0(x); cout << endl;}}
#define DBG2(x, y) {if(DEBUG){DBG0(x); DBG(y);}}
#define DBG3(x, y, z) {if(DEBUG){DBG0(x); DBG2(y, z);}}
#define DBG4(w, x, y, z) {if(DEBUG){DBG0(w); DBG3(x, y, z);}}

const double EPS = 1.0e-9;
template <class T>
ostream& operator<<(ostream& os, vector<T> xs){ for(T x: xs) os << x << ' '; return os; }
template <class S, class T>
ostream& operator<<(ostream& os, pair<S,T> st){ os << "(" << st.first << "," << st.second <<")"; return os; }

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ul> vul;
typedef vector<ull> vull;
typedef vector<bool> vbl;
typedef pair<int, int> pii;

typedef complex<double> Point;
istream& operator>>(istream& is, Point &pt){
    double a, b;
    is >> a >> b;
    pt.real(a); pt.imag(b);
    return is;
}

ostream& operator<<(ostream& os, const Point &pt){
    os << make_pair(pt.real(), pt.imag());
    return os;
}

inline double cross(const Point &a, const Point &b){
    return (a.real()*b.imag() - a.imag()*b.real());
}

inline double myarg(Point &a){
    double ret = arg(a);
    return (ret >= 0 ? ret : ret + 2*M_PI);
}

inline double signed_area(const Point &a, const Point &b, const Point &c){
    Point ab = b - a;
    Point ac = c - a;
    return cross(ab, ac) / 2.0;
}

inline bool intersect(const Point &a1, const Point &a2, const Point &b1, const Point &b2) {
    return ((cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS) &&
            (cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS));
}

void sort_by_arg(vector<Point> &pts){
    sort(pts.begin(), pts.end(), [](Point a, Point b){ return (myarg(a) < myarg(b)); });
}

double area(vector<Point> &vs){
    int n = vs.size();
    vector<Point> pts(n - 1);
    rep(i, n - 1) pts[i] = vs[i + 1] - vs[0];
    sort_by_arg(pts);
    double ans = 0.0;
    rep(i, n - 1) ans += cross(vs[i], vs[i + 1]);
    return ans / 2.0;
}

int main(void){

    int n;
    cin >> n;
    while(n-->0){
        Point a,b,c,d;
        cin >> a >> b >> c >> d;
//        DBG4(a, b, c, d);
//        DBG(cross(b - a, d - c));
        if((cross(b - a, d - c)) == 0.0)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    return 0;
}

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

int main()
{
    int n;
    cin>>n;
    while(n--){
        pair<double,double>a[4];
        for(int i=0;i<4;i++){
            cin>>a[i].first>>a[i].second;
        }
        if((a[1].first-a[0].first)*(a[3].second-a[2].second)-(a[3].first-a[2].first)*(a[1].second-a[0].second)<1e-10)
            cout<<"NO"<<endl;
        else
            cout<<"YES"<<endl;
    }
    return 0;
}

C++: #include<stdio.h> 
  
int main(){ 
  
  int n,i,flgx,flgy,j; 
  double x[4],y[4],kata,kata2; 
  
  
  scanf("%d",&n); 
  
  for(i=0;i<n;i++){ 
    for(j = 0;j < 4;j++){ 
    scanf("%lf",&x[j]);     
    scanf("%lf",&y[j]); 
    }   
      
    flgx = flgy =0; 
  
    if( (x[0]-x[1])!=0 )kata = (y[0] - y[1])/(x[0] - x[1]); 
      
    else flgx = 1;  
      
    if( (x[2]-x[3])!=0 )kata2 = (y[2] - y[3])/(x[2] - x[3]); 
      
    else flgy = 1;  
  
    if(kata == kata2||(flgx == 1&&flgy == 1))printf("YES\n"); 
  
    else printf("NO\n"); 
  } 
    
  return 0; 
}