Language: C++

#include <iostream>
#include <cmath>
using namespace std;
const double eps = 1e-8;

class P {
public:
	double x, y, z;
	P(){};
	P(double x, double y, double z) : x(x), y(y), z(z) {};
	P operator+(const P &p) {
		return P(x + p.x, y + p.y, z + p.z);
	}
	P operator-(const P &p) {
		return P(x - p.x, y - p.y, z - p.z);
	}
	P operator*(const double &n) {
		return P(x * n, y * n, z * n);
	}
	P operator/(const double &n) {
		return P(x / n, y / n, z / n);
	}
};

double dot(const P &a, const P &b) {
	return a.x * b.x + a.y * b.y + a.z * b.z;
}

P cross(const P &a, const P &b) {
	return P(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x);
}

int main() {
	P p[5];
	for (int i=0; i<5; ++i) cin >> p[i].x >> p[i].y >> p[i].z;

	P z = cross(p[3] - p[2], p[4] - p[2]);
	double a = dot(p[2] - p[0], z);
	double b = dot(p[1] - p[0], z);
	double c = abs(a);
	double d = abs(b) - c;

	if (abs(a) < eps || (b < -eps && eps < a) || (a < -eps && eps < b) || d < -eps) {
		cout << "HIT\n";
		return 0;
	}

	P i = (p[0] * d + p[1] * c) / (c + d);
	bool plus = false, minus = false;
	for (int i=0; i<3; ++i) {
		double t = dot(z, cross(p[(i + 1) % 3 + 2] - p[i + 2], i - p[i + 2]));
		if (-eps < t) plus = true;
		else if (eps > t) minus = true;
	}

	cout << ( ! plus || ! minus ? "MISS\n" : "HIT\n");
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:74: error: no match for 'operator-' (operand types are 'int' and 'P')
   51 |                 double t = dot(z, cross(p[(i + 1) % 3 + 2] - p[i + 2], i - p[i + 2]));
      |                                                                        ~ ^ ~~~~~~~~
      |                                                                        |          |
      |                                                                        int        P
In file included from /usr/include/c++/14/string:48,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  618 |     operator-(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:618:5: note:   template argument deduction/substitution failed:
a.cc:51:83: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'int'
   51 |                 double t = dot(z, cross(p[(i + 1) % 3 + 2] - p[i + 2], i - p[i + 2]));
      |                                                                                   ^
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1790 |     operator-(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note:   template argument deduction/substitution failed:
a.cc:51:83: note:   mismatched types 'const std::move_iterator<_IteratorL>' and 'int'
   51 |                 double t = dot(z, cross(p[(i + 1) % 3 + 2] - p[i + 2], i - p[i + 2]));
      |                                                                                   ^