func_code_string: #include <bits/stdc++.h>   using namespace std;   const long double EPS = 1e-8;   const int N = 1e5 + 10;   int n, q;   int sgn(long double x) { return x < -EPS ? -1 : x > EPS; }   struct Point {     Point() {}     long double x, y;     Point(long double x, long double y) : x(x), y(y) {}     void read() { cin >> x >> y; }     Point operator-(const Point& p) { return Point(x - p.x, y - p.y); }     long double operator*(const Point& p) { return x * p.x + y * p.y; }     long double operator^(const Point& p) { return x * p.y - y * p.x; }     long double length() { return hypotl(x, y); }   } poly[N];   using Vec = Point;   long double getIntersection(Point p, Vec v, Point q, Vec w) {     return (w ^ (p - q)) / (v ^ w);   }   long double work(Point p, Vec v) {     long double ret = 0;     vector<pair<long double, int> > pos;     for (int i = 1; i <= n; i++) {       int s1 = sgn(v ^ (poly[i] - p));       int s2 = sgn(v ^ (poly[i + 1] - p));       if (s1 == s2) continue;       long double o = getIntersection(p, v, poly[i], poly[i + 1] - poly[i]);       if (s1 > s2)         pos.push_back({o, s1 && s2 ? 2 : 1});       else         pos.push_back({o, s1 && s2 ? -2 : -1});     }     sort(pos.begin(), pos.end());     int flag = 0;     for (int i = 0; i + 1 < pos.size(); i++) {       flag += pos[i].second;       if (flag) ret += pos[i + 1].first - pos[i].first;     }     return ret * v.length();   }   int main() {     ios ::sync_with_stdio(false);     cin >> n >> q;     for (int i = 1; i <= n; i++) poly[i].read();     poly[n + 1] = poly[1];     while (q--) {       Point a, b;       a.read();       b.read();       cout << fixed << setprecision(20) << work(a, b - a) << endl;     }     return 0;   }   