Language: C++

#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>
#include <quadmath.h> 

using namespace std;

typedef __float128 ld;

ld EPS = 1e-20;


ld add(ld a, ld b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}

struct point{
  ld x,y,z;
  point(){}
  point(ld x,ld y,ld z) : x(x) , y(y), z(z){}

  point operator + (point p){
    return point(add(x,p.x), add(y,p.y),add(z,p.z));
  }

  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y),add(z,-p.z));
  }
};


ld dist(point a,point b){
  return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2)+pow(a.z-b.z,2));
}

ld tetrahedra_volume(ld a,ld b,ld c,ld x,ld y,ld z){
#define sqr(x) ((x)*(x))
   ld tv=sqr(a*x)*(sqr(b)+sqr(c)-sqr(a)+sqr(y)+sqr(z)-sqr(x))
      +sqr(b*y)*(sqr(c)+sqr(a)-sqr(b)+sqr(z)+sqr(x)-sqr(y))
      +sqr(c*z)*(sqr(a)+sqr(b)-sqr(c)+sqr(x)+sqr(y)-sqr(z))
      -sqr(a*y*z)-sqr(b*z*x)-sqr(c*x*y)-sqr(a*b*c);

   ld V=sqrt(tv/144.0);
   if(V!=V)return -1;
   return sqrt(tv/144.0);
#undef sqr
}

ld tetrahedra_volume(point A,point B,point C,point D){
  ld a=dist(B,C),b=dist(C,A),c=dist(A,B);
  ld d=dist(D,A),e=dist(D,B),f=dist(D,C);
  ld V=tetrahedra_volume(a,b,c,d,e,f);
  if(V<0)return -1;
  return V;
}

int main(void){

  point P,Q,A,B,C;
  cin >> P.x >> P.y >> P.z;
  cin >> Q.x >> Q.y >> Q.z;
  cin >> A.x >> A.y >> A.z;
  cin >> B.x >> B.y >> B.z;
  cin >> C.x >> C.y >> C.z;

  ld res1=tetrahedra_volume(A,C,P,Q);
  ld res2=tetrahedra_volume(B,C,P,Q);
  ld res3=tetrahedra_volume(A,B,P,Q);
  if(res1==-1 || res2==-1 || res3==-1){
    cout << "MISS" << endl;
    return 0;
  }

  ld res4=tetrahedra_volume(A,B,C,P);
  ld res5=tetrahedra_volume(A,B,C,Q);

  if(res5==-1)cout << "MISS" << endl;
  else if(abs((res1+res2+res3)-(res4+res5))<EPS)cout << "MISS" << endl;
  else cout << "HIT" << endl;

  return 0;
}

Compiler output:
a.cc: In function 'ld dist(point, point)':
a.cc:37:18: error: call of overloaded 'pow(ld, int)' is ambiguous
   37 |   return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2)+pow(a.z-b.z,2));
      |               ~~~^~~~~~~~~~~
In file included from /usr/include/features.h:523,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
                 from /usr/include/c++/14/bits/requires_hosted.h:31,
                 from /usr/include/c++/14/cmath:41,
                 from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:173:1: note: candidate: 'double pow(double, double)'
  173 | __MATHCALL_VEC (pow,, (_Mdouble_ __x, _Mdouble_ __y));
      | ^~~~~~~~~~~~~~
/usr/include/c++/14/cmath:380:3: note: candidate: 'constexpr long double std::pow(long double, long double)'
  380 |   pow(long double __x, long double __y)
      |   ^~~
/usr/include/c++/14/cmath:376:3: note: candidate: 'constexpr float std::pow(float, float)'
  376 |   pow(float __x, float __y)
      |   ^~~
a.cc:37:33: error: call of overloaded 'pow(ld, int)' is ambiguous
   37 |   return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2)+pow(a.z-b.z,2));
      |                              ~~~^~~~~~~~~~~
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:173:1: note: candidate: 'double pow(double, double)'
  173 | __MATHCALL_VEC (pow,, (_Mdouble_ __x, _Mdouble_ __y));
      | ^~~~~~~~~~~~~~
/usr/include/c++/14/cmath:380:3: note: candidate: 'constexpr long double std::pow(long double, long double)'
  380 |   pow(long double __x, long double __y)
      |   ^~~
/usr/include/c++/14/cmath:376:3: note: candidate: 'constexpr float std::pow(float, float)'
  376 |   pow(float __x, float __y)
      |   ^~~
a.cc:37:48: error: call of overloaded 'pow(ld, int)' is ambiguous
   37 |   return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2)+pow(a.z-b.z,2));
      |                                             ~~~^~~~~~~~~~~
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:173:1: note: candidate: 'double pow(double, double)'
  173 | __MATHCALL_VEC (pow,, (_Mdouble_ __x, _Mdouble_ __y));
      | ^~~~~~~~~~~~~~
/usr/include/c++/14/cmath:380:3: note: candidate: 'constexpr long double std::pow(long double, long double)'
  380 |   pow(long double __x, long double __y)
      |   ^~~
/usr/include/c++/14/cmath:376:3: note: candidate: 'constexpr float std::pow(float, float)'
  376 |   pow(float __x, float __y)
      |   ^~~
a.cc: In function 'ld tetrahedra_volume(ld, ld, ld, ld, ld, ld)':
a.cc:47:13: error: call of overloaded 'sqrt(ld)' is ambiguous
   47 |    ld V=sqrt(tv/144.0);
      |         ~~~~^~~~~~~~~~
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:176:1: note: candidate: 'double sqrt(double)'
  176 | __MATHCALL (sqrt,, (_Mdouble_ __x));
      | ^~~~~~~~~~
/usr/include/c++/14/cmath:446:3: note: candidate: 'constexpr long double std::sqrt(long double)'
  446 |   sqrt(long double __x)
      |   ^~~~
/usr/include/c++/14/cmath:442:3: note: candidate: 'constexpr float std::sqrt(float)'
  442 |   sqrt(float __x)
      |   ^~~~
a.cc:49:15: error: call of overloaded 'sqrt(ld)' is ambiguous
   49 |    return sqrt(tv/144.0);
      |           ~~~~^~~~~~~~~~
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:176:1: note: candidate: 'double sqrt(double)'
  176 | __MATHCALL (sqrt,, (_Mdouble_ __x));
      | ^~~~~~~~~~
/usr/include/c++/14/cmath:446:3: note: candidate: 'constexpr long double std::sqrt(long double)'
  446 |   sqrt(long double __x)
      |   ^~~~
/usr/include/c++/14/cmath:442:3: note: candidate: 'constexpr float std::sqrt(float)'
  442 |   sqrt(float __x)
      |   ^~~~
a.cc: In function 'int main()':
a.cc:64:7: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'ld' {aka '__float128'})
   64 |   cin >> P.x >> P.y >> P.z;
      |   ~~~ ^~ ~~~
      |   |        |
      |   |        ld {aka __float128}
      |   std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/iostream:42,
                 from a.cc:3:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  170 |       operator>>(bool& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:170:7: note:   conversion of argument 1 would be ill-formed:
a.cc:64:12: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'ld' {aka '__float128'}
   64 |   cin >> P.x >> P.y >> P.z;
      |          ~~^
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
  174 |       operator>>(short& __n);
      |       ^~~~~~~~
/usr/include/c++/14/istream:174:7: note:   conversion of argument 1 would be ill-formed:
a.cc:64:12: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type 'ld' {aka '__float128'}
   64 |   cin >> P.x >> P.y >> P.z;
      |          ~~^
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  177 |       operator>>(unsigned short& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:177:7: note:   conversion of argument 1 would be ill-formed:
a.cc:64:12: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type 'ld' {aka '__float128'}
   64 |   cin >> P.x >> P.y >> P.z;
      |          ~~^
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
  181 |       operator>>(int& __n);
      |       ^~~~~~~~
/usr/include/c++/14/istream:181:7: note:   conversion of argument 1 would be ill-formed:
a.cc:64:12: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'ld' {aka '__float128'}
   64 |   cin >> P.x >> P.y >> P.z;
      |          ~~^
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  184 |       operator>>(unsigned int& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:184:7: note:   conversion of argument 1 would be ill-formed:
a.cc:64:12: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type 'ld' {aka '__float128'}
   64 |   cin >> P.x >> P.y >> P.z;
      |          ~~^
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  188 |       operator>>(long& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:188:7: note:   conversion of argument 1 would be ill-formed:
a.cc:64:12: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type 'ld' {aka '__float128'}
   64 |   cin >> P.x >> P.y >> P.z;
      |          ~~^
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  192 |       operator>>(unsigned long& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:192:7: note:   conversion of argument 1 would be ill-formed:
a.cc:64:12: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to a value of type 'ld' {aka '__float128'}
   64 |   cin >> P.x >> P.y >> P.z;
      |          ~~^
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  199 |       operator>>(long long& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:199:7: note:   conversion of argument 1 would be ill-formed:
a.cc:64:12: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type 'ld' {aka '__float128'}
   64 |   cin >> P.x >> P.y >> P.z;
      |          ~~^
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  203 |       operator>>(unsigned long long& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:203:7: note:   conversion of argument 1 would be ill-formed:
a.cc:64:12: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to a value of type 'ld' {aka '__float128'}
   64 |   cin >> P.x >> P.y >> P.z;
      |          ~~^
/usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  219 |       operator>>(float& __f)
      |       ^~~~~~~~
/usr/include/c++/14/istream:219:7: note:   conversion of argument 1 would be ill-formed:
a.cc:64:12: error: cannot bind non-const lvalue reference of type 'float&' to a value of type 'ld' {aka '__float128'}
   64 |   cin >> P.x >> P.y >> P.z;
      |          ~~^
/usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(