Problem p00035 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;
// ------ Classes ------ //
class Point {
public:
  long double px, py;
  Point() : px(0), py(0){};
  Point(long double px_, long double py_) : px(px_), py(py_){};
  friend bool operator==(const Point &p1, const Point &p2) {
    return p1.px == p2.px && p1.py == p2.py;
  }
  friend bool operator!=(const Point &p1, const Point &p2) {
    return p1.px != p2.px || p1.py != p2.py;
  }
  friend Point operator+(const Point &p1, const Point &p2) {
    return Point(p1.px + p2.px, p1.py + p2.py);
  }
  friend Point operator-(const Point &p1, const Point &p2) {
    return Point(p1.px - p2.px, p1.py - p2.py);
  }
  friend Point operator*(const Point &p1, long double d) {
    return Point(p1.px * d, p1.py + d);
  }
  friend Point operator*(long double d, const Point &p1) { return p1 * d; }
  friend Point operator/(const Point &p1, long double d) {
    return Point(p1.px / d, p1.py / d);
  }
  Point &operator+=(const Point &p1) {
    px += p1.px;
    py += p1.py;
    return *this;
  }
  Point &operator-=(const Point &p1) {
    px -= p1.px;
    py -= p1.py;
    return *this;
  }
  Point &operator*=(long double d) {
    px *= d;
    py *= d;
    return *this;
  }
  Point &operator/=(long double d) {
    px /= d;
    py /= d;
    return *this;
  }
};
class Segment {
public:
  Point p1, p2;
  Segment(Point p1_, Point p2_) : p1(p1_), p2(p2_){};
  Segment(long double p1x, long double p1y, long double p2x, long double p2y)
      : p1(Point(p1x, p1y)), p2(Point(p2x, p2y)){};
  friend bool operator==(const Segment &s1, const Segment &s2) {
    return (s1.p1 == s2.p1 && s1.p2 == s2.p2) ||
           (s1.p1 == s2.p2 && s1.p2 == s2.p1);
  }
  friend bool operator!=(const Segment &s1, const Segment &s2) {
    return !(s1 == s2);
  }
};
class Line {
public:
  Point p1, p2;
  Line(Point p1_, Point p2_) : p1(p1_), p2(p2_){};
  Line(long double p1x, long double p1y, long double p2x, long double p2y)
      : p1(Point(p1x, p1y)), p2(Point(p2x, p2y)){};
  friend bool operator==(const Line &s1, const Line &s2) {
    return (s1.p1 == s2.p1 && s1.p2 == s2.p2) ||
           (s1.p1 == s2.p2 && s1.p2 == s2.p1);
  }
  friend bool operator!=(const Line &s1, const Line &s2) { return !(s1 == s2); }
};
// ------ Functions ------ //
long double norm(const Point &a) { return a.px * a.px + a.py * a.py; }
long double abs(const Point &a) { return sqrtl(norm(a)); }
long double dot(const Point &a, const Point &b) {
  return a.px * b.px + a.py * b.py;
}
long double crs(const Point &a, const Point &b) {
  return a.px * b.py - a.py * b.px;
}
int ccw(Point p0, Point p1, Point p2) {
  Point a = p1 - p0, b = p2 - p0;
  if (crs(a, b) > 1e-10)
    return 1;
  if (crs(a, b) < -1e-10)
    return -1;
  if (dot(a, b) < -1e-10)
    return 2;
  if (norm(a) < norm(b))
    return -2;
  return 0;
}
// ------ Main ------ //
Point p1, p2, p3, p4;
int r1, r2, r3, r4;
int main() {
  while (~scanf("%Lf,%Lf,%Lf,%Lf,%Lf,%Lf,%Lf,%Lf", &p1.px, &p1.py, &p2.px,
                &p2.py, &p3.px, &p3.py, &p4.px, &p4.py)) {
    r1 = ccw(p1, p2, p3);
    r2 = ccw(p2, p3, p4);
    r3 = ccw(p3, p4, p1);
    r4 = ccw(p4, p1, p2);
    printf("%s\\n",
           (r1 == r2 && r2 == r3 && r3 == r4 && abs(r1) == 1) ? "YES" : "NO");
  }
  return 0;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;
// ------ Classes ------ //
class Point {
public:
  long double px, py;
  Point() : px(0), py(0){};
  Point(long double px_, long double py_) : px(px_), py(py_){};
  friend bool operator==(const Point &p1, const Point &p2) {
    return p1.px == p2.px && p1.py == p2.py;
  }
  friend bool operator!=(const Point &p1, const Point &p2) {
    return p1.px != p2.px || p1.py != p2.py;
  }
  friend Point operator+(const Point &p1, const Point &p2) {
    return Point(p1.px + p2.px, p1.py + p2.py);
  }
  friend Point operator-(const Point &p1, const Point &p2) {
    return Point(p1.px - p2.px, p1.py - p2.py);
  }
  friend Point operator*(const Point &p1, long double d) {
    return Point(p1.px * d, p1.py + d);
  }
  friend Point operator*(long double d, const Point &p1) { return p1 * d; }
  friend Point operator/(const Point &p1, long double d) {
    return Point(p1.px / d, p1.py / d);
  }
  Point &operator+=(const Point &p1) {
    px += p1.px;
    py += p1.py;
    return *this;
  }
  Point &operator-=(const Point &p1) {
    px -= p1.px;
    py -= p1.py;
    return *this;
  }
  Point &operator*=(long double d) {
    px *= d;
    py *= d;
    return *this;
  }
  Point &operator/=(long double d) {
    px /= d;
    py /= d;
    return *this;
  }
};
class Segment {
public:
  Point p1, p2;
  Segment(Point p1_, Point p2_) : p1(p1_), p2(p2_){};
  Segment(long double p1x, long double p1y, long double p2x, long double p2y)
      : p1(Point(p1x, p1y)), p2(Point(p2x, p2y)){};
  friend bool operator==(const Segment &s1, const Segment &s2) {
    return (s1.p1 == s2.p1 && s1.p2 == s2.p2) ||
           (s1.p1 == s2.p2 && s1.p2 == s2.p1);
  }
  friend bool operator!=(const Segment &s1, const Segment &s2) {
    return !(s1 == s2);
  }
};
class Line {
public:
  Point p1, p2;
  Line(Point p1_, Point p2_) : p1(p1_), p2(p2_){};
  Line(long double p1x, long double p1y, long double p2x, long double p2y)
      : p1(Point(p1x, p1y)), p2(Point(p2x, p2y)){};
  friend bool operator==(const Line &s1, const Line &s2) {
    return (s1.p1 == s2.p1 && s1.p2 == s2.p2) ||
           (s1.p1 == s2.p2 && s1.p2 == s2.p1);
  }
  friend bool operator!=(const Line &s1, const Line &s2) { return !(s1 == s2); }
};
// ------ Functions ------ //
long double norm(const Point &a) { return a.px * a.px + a.py * a.py; }
long double abs(const Point &a) { return sqrtl(norm(a)); }
long double dot(const Point &a, const Point &b) {
  return a.px * b.px + a.py * b.py;
}
long double crs(const Point &a, const Point &b) {
  return a.px * b.py - a.py * b.px;
}
int ccw(Point p0, Point p1, Point p2) {
  Point a = p1 - p0, b = p2 - p0;
  if (crs(a, b) > 1e-10)
    return 1;
  if (crs(a, b) < -1e-10)
    return -1;
  if (dot(a, b) < -1e-10)
    return 2;
  if (norm(a) < norm(b))
    return -2;
  return 0;
}
// ------ Main ------ //
Point p1, p2, p3, p4;
int r1, r2, r3, r4;
int main() {
  while (~scanf("%Lf,%Lf,%Lf,%Lf,%Lf,%Lf,%Lf,%Lf", p1.px, p1.py, p2.px, p2.py,
                p3.px, p3.py, p4.px, p4.py)) {
    r1 = ccw(p1, p2, p3);
    r2 = ccw(p2, p3, p4);
    r3 = ccw(p3, p4, p1);
    r4 = ccw(p4, p1, p2);
    printf("%s\\n",
           (r1 == r2 && r2 == r3 && r3 == r4 && abs(r1) == 1) ? "YES" : "NO");
  }
  return 0;
}