Language: C++

#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef double LD;
typedef complex<LD> Point;
typedef pair<Point, Point> Line;
const LD EPS = 1e-10;
#define X real() // x座標を取得
#define Y imag() // y座標を取得
#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θ
LD dot(Point a, Point b){
    return (conj(a)*b).X;
}

// 外積 cross(a, b) = |a||b|sinθ
LD cross(Point a, Point b){
    return (conj(a)*b).Y;
}

int ccw(Point a, Point b, Point c){
    b -= a; c -= a;
    if (cross(b, c) > 0)   return +1;       // counter clockwise
    if (cross(b, c) < 0)   return -1;       // clockwise
    if (dot(b, c) < 0)     return +2;       // c--a--b on line
    if (norm(b) < norm(c)) return -2;       // a--b--c on line
    return 0;
}


// 交差判定 (isec) ****************************
// 点　 := 平面座標にある点
// 直線 := 点と点を通るどこまでも続く線
// 線分 := 点と点を結んでその両端で止まっている線

// 直線と点
bool isecLP(Point a1, Point a2, Point b){
    return abs(ccw(a1, a2, b)) != 1;
}

// 直線と直線
bool isecLL(Point a1, Point a2, Point b1, Point b2) {
    return !isecLP(a2-a1, b2-b1, 0) || isecLP(a1, b1, b2);
}

// 直線と線分
bool isecLS(Point a1, Point a2, Point b1, Point b2) {
    return cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS;
}

// 線分と線分
bool isecSS(Point a1, Point a2, Point b1, Point b2) {
    return ccw(a1, a2, b1)*ccw(a1, a2, b2) <= 0 && ccw(b1, b2, a1)*ccw(b1, b2, a2) <= 0;
}

// 線分と点
bool isecSP(Point a1, Point a2, Point b) {
    return !ccw(a1, a2, b);
}

// ********************************************


// 距離 (dist) ********************************
// 点pの直線aへの射影点を返す
Point proj(Point a1, Point a2, Point p){
    return a1 + dot(a2-a1, p-a1) / norm(a2-a1) * (a2-a1);
}

// 点pの直線aへの反射点を返す
Point reflection(Point a1, Point a2, Point p){
    return 2.0L*proj(a1, a2, p) - p;
}

// 直線と点
LD distLP(Point a1, Point a2, Point p){
    return abs(proj(a1, a2, p) - p);
}

// 直線と直線
LD distLL(Point a1, Point a2, Point b1, Point b2) {
    return isecLL(a1, a2, b1, b2) ? 0 : distLP(a1, a2, b1);
}

// 直線と線分
LD distLS(Point a1, Point a2, Point b1, Point b2) {
    return isecLS(a1, a2, b1, b2) ? 0 : min(distLP(a1, a2, b1), distLP(a1, a2, b2));
}

// 線分と点
LD distSP(Point a1, Point a2, Point p) {
    Point r = proj(a1, a2, p);
    if(isecSP(a1, a2, r)) return abs(r-p);
    return min(abs(a1-p), abs(a2-p));
}

// 線分と線分
LD distSS(Point a1, Point a2, Point b1, Point b2) {
    if(isecSS(a1, a2, b1, b2)) return 0;
    return min(min(distSP(a1, a2, b1), distSP(a1, a2, b2)), min(distSP(b1, b2, a1), distSP(b1, b2, a2)));
}

// ********************************************


// 2直線の交点 (crosspoint) *******************
Point crosspointLL(Point a1, Point a2, Point b1, Point b2){
    LD d1 = cross(b2-b1, b1-a1);
    LD d2 = cross(b2-b1, a2-a1);
    if (EQ(d1, 0) && EQ(d2, 0)) return a1;
    if (EQ(d2, 0)) throw "not exist crosspoint";
    return a1 + d1/d2 * (a2-a1);
}
// ********************************************


/*************** using variables ***************/
Point p[4];
int q;
/**********************************************/

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> q;
    REP(i, q){
        LD xp, yp;
        REP(i, 4){
            cin >> xp >> yp;
            p[i] = Point(xp, yp);
        }
        LD ans = distSS(p[0], p[1], p[2], p[3]);
        printf("%.10Lf\n", ans);
    }
}



Compiler output:
a.cc: In function 'Point reflection(Point, Point, Point)':
a.cc:93:16: error: no match for 'operator*' (operand types are 'long double' and 'Point' {aka 'std::complex<double>'})
   93 |     return 2.0L*proj(a1, a2, p) - p;
      |            ~~~~^~~~~~~~~~~~~~~~
      |            |        |
      |            |        Point {aka std::complex<double>}
      |            long double
In file included from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127,
                 from a.cc:1:
/usr/include/c++/14/complex:400:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const complex<_Tp>&, const complex<_Tp>&)'
  400 |     operator*(const complex<_Tp>& __x, const complex<_Tp>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/complex:400:5: note:   template argument deduction/substitution failed:
a.cc:93:31: note:   mismatched types 'const std::complex<_Tp>' and 'long double'
   93 |     return 2.0L*proj(a1, a2, p) - p;
      |                               ^
/usr/include/c++/14/complex:409:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const complex<_Tp>&, const _Tp&)'
  409 |     operator*(const complex<_Tp>& __x, const _Tp& __y)
      |     ^~~~~~~~
/usr/include/c++/14/complex:409:5: note:   template argument deduction/substitution failed:
a.cc:93:31: note:   mismatched types 'const std::complex<_Tp>' and 'long double'
   93 |     return 2.0L*proj(a1, a2, p) - p;
      |                               ^
/usr/include/c++/14/complex:418:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const _Tp&, const complex<_Tp>&)'
  418 |     operator*(const _Tp& __x, const complex<_Tp>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/complex:418:5: note:   template argument deduction/substitution failed:
a.cc:93:31: note:   deduced conflicting types for parameter '_Tp' ('long double' and 'double')
   93 |     return 2.0L*proj(a1, a2, p) - p;
      |                               ^
In file included from /usr/include/c++/14/valarray:605,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166:
/usr/include/c++/14/bits/valarray_after.h:407:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)'
  407 |     _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:407:5: note:   template argument deduction/substitution failed:
a.cc:93:31: note:   mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'long double'
   93 |     return 2.0L*proj(a1, a2, p) - p;
      |                               ^
/usr/include/c++/14/bits/valarray_after.h:407:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)'
  407 |     _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:407:5: note:   template argument deduction/substitution failed:
a.cc:93:31: note:   mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'long double'
   93 |     return 2.0L*proj(a1, a2, p) - p;
      |                               ^
/usr/include/c++/14/bits/valarray_after.h:407:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)'
  407 |     _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:407:5: note:   template argument deduction/substitution failed:
a.cc:93:31: note:   'Point' {aka 'std::complex<double>'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
   93 |     return 2.0L*proj(a1, a2, p) - p;
      |                               ^
/usr/include/c++/14/bits/valarray_after.h:407:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)'
  407 |     _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:407:5: note:   template argument deduction/substitution failed:
a.cc:93:31: note:   mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'long double'
   93 |     return 2.0L*proj(a1, a2, p) - p;
      |                               ^
/usr/include/c++/14/bits/valarray_after.h:407:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const valarray<typename _Dom::value_type>&, const _Expr<_Dom1, typename _Dom1::value_type>&)'
  407 |     _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:407:5: note:   template argument deduction/substitution failed:
a.cc:93:31: note:   'Point' {aka 'std::complex<double>'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
   93 |     return 2.0L*proj(a1, a2, p) - p;
      |                               ^
/usr/include/c++/14/valarray:1198:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__multiplies, _Tp>::result_type> std::operator*(const valarray<_Tp>&, const valarray<_Tp>&)'
 1198 | _DEFINE_BINARY_OPERATOR(*, __multiplies)
      | ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/valarray:1198:1: note:   template argument deduction/substitution failed:
a.cc:93:31: note:   mismatched types 'const std::valarray<_Tp>' and 'long double'
   93 |     return 2.0L*proj(a1, a2, p) - p;
      |                               ^
/usr/include/c++/14/valarray:1198:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__multiplies, _Tp>::result_type> std::operator*(const valarray<_Tp>&, const typename valarray<_Tp>::value_type&)'
 1198 | _DEFINE_BINARY_OPERATOR(*, __multiplies)
      | ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/valarray:1198:1: note:   template argument deduction/substitution failed:
a.cc:93:31: note:   mismatched types 'const std::valarray<_Tp>' and 'long double'
   93 |     return 2.0L*proj(a1, a2, p) - p;
      |                               ^
/usr/include/c++/14/valarray:1198:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__multiplies, _Tp>::result_type> std::operator*(const typename valarray<_Tp>::value_type&, const valarray<_Tp>&)'
 1198 | _DEFINE_BINARY_OPERATOR(*, __multiplies)
      | ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/valarray:1198:1: note:   template argument deduction/substitution failed:
a.cc:93:31: note:   'Point' {aka 'std::complex<double>'} is not derived from 'const std::valarray<_Tp>'
   93 |     return 2.0L*proj(a1, a2, p) - p;
      |                               ^