Language: C++

#include <bits/stdc++.h>

using namespace std;

namespace {

    typedef double real;
    typedef long long ll;

    const real EPS = 1e-7;

    template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
        if (vs.empty()) return os << "[]";
        os << "[" << vs[0];
        for (int i = 1; i < vs.size(); i++) os << " " << vs[i];
        return os << "]";
    }
    template<class T> istream& operator>>(istream& is, vector<T>& vs) {
        for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;
        return is;
    }

    struct Point {
        double x, y;
        Point() {}
        Point(double x, double y) : x(x), y(y) {}
        Point operator+(const Point& p) const { return Point(x + p.x, y + p.y); }
        Point operator-(const Point& p) const { return Point(x - p.x, y - p.y); }
        Point operator*(double k) const { return Point(k * x, k * y); }
        Point operator/(double k) const { return Point(x / k, y / k); }
    };
    double dot(const Point& a, const Point& b) { return a.x * b.x + a.y * b.y; }
    double cross(const Point& a, const Point& b) { return a.x * b.y - a.y * b.x; }
    double norm(const Point& a) { return sqrt(dot(a, a)); }
    Point rot90(const Point& p) { return Point(-p.y, p.x); } // ?????´????????\?±???§??????90?????????????????¢ 
    double angle(const Point& a) { return atan2(a.y, a.x); } // x????????§??????????????¨??\?±???§????????´???????§?????§??¢?????????????????¢???????????§????????????a???????????±?????????    ostream& operator<<(ostream& os, const Point& p) { return os << "(" << p.x << "," << p.y << ")"; }
    istream& operator>>(istream& is, Point& p) { return is >> p.x >> p.y; }

    int ccw(Point a, Point b, Point c){
        b = b - a; c = c - a;
        if (cross(b, c) > EPS) return +1;      // a,b,c???????¬????????????´????????\?????§???        if (cross(b, c) < -EPS) return -1;     // a,b,c???????¬???????????????¨??\?????§???        if (dot(b, c) < 0) return +2;          // c--a--b ??¶??´??±???        if (norm(b) < norm(c)) return -2;      // a--b--c ??¶??´??±???        return 0;                              // a--c--b ??¶??´??±???    }

    struct Segment {
        Point a, b;
        Segment() {}
        Segment(const Point& a, const Point& b) : a(a), b(b) {}
    };
    bool intersects(const Segment& s, const Segment& t) {
        return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 && ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
    }
    Point projection(const Segment& l, const Point& p) {
        Point u = (p - l.a), v = (l.b - l.a);
        return l.a + (v / norm(v)) * (dot(u, v) / norm(v));
    }
    double dist(const Segment& s, const Point& p) {
        Point q = projection(Segment(s.a, s.b), p);
        Segment t(p, q);
        if (intersects(s, t)) return norm(t.b - t.a);
        return min(norm(s.a - p), norm(s.b - p));
    }
    double dist(const Segment& s, const Segment& t) {
        if (intersects(s, t)) return 0;
        return min( min(dist(s, t.a), dist(s, t.b)),
                min(dist(t, s.a), dist(t, s.b)) );
    }

    int N1, N2;
    vector<Point> A, B;
    void input() {
        cin >> N1;
        A.clear(); A.resize(N1); cin >> A;
        cin >> N2;
        B.clear(); B.resize(N2); cin >> B;
    }

    void solve() {
        real ans = 1e8;
        for (int i = 0; i < N1 - 1; i++) {
            Segment s(A[i], A[i + 1]);
            for (int j = 0; j < N2 - 1; j++) {
                Segment t(B[j], B[j + 1]);
                ans = min(ans, dist(s, t));
            }
        }
        cout << fixed << setprecision(12) << ans << endl;
    }
}

int main() {
    input(); solve();
    return 0;
}

Compiler output:
a.cc: In function 'int {anonymous}::ccw(Point, Point, Point)':
a.cc:48:57: error: a function-definition is not allowed here before '{' token
   48 |     bool intersects(const Segment& s, const Segment& t) {
      |                                                         ^
a.cc:51:56: error: a function-definition is not allowed here before '{' token
   51 |     Point projection(const Segment& l, const Point& p) {
      |                                                        ^
a.cc:55:51: error: a function-definition is not allowed here before '{' token
   55 |     double dist(const Segment& s, const Point& p) {
      |                                                   ^
a.cc:61:53: error: a function-definition is not allowed here before '{' token
   61 |     double dist(const Segment& s, const Segment& t) {
      |                                                     ^
a.cc:69:18: error: a function-definition is not allowed here before '{' token
   69 |     void input() {
      |                  ^
a.cc:76:18: error: a function-definition is not allowed here before '{' token
   76 |     void solve() {
      |                  ^
a.cc: In function 'int {anonymous}::main()':
a.cc:90:5: error: 'input' was not declared in this scope; did you mean 'int'?
   90 |     input(); solve();
      |     ^~~~~
      |     int
a.cc:90:14: error: 'solve' was not declared in this scope
   90 |     input(); solve();
      |              ^~~~~
a.cc: At global scope:
a.cc:92:2: error: expected '}' at end of input
   92 | }
      |  ^
a.cc:5:11: note: to match this '{'
    5 | namespace {
      |           ^
a.cc: In function 'int {anonymous}::ccw(Point, Point, Point)':
a.cc:87:1: warning: control reaches end of non-void function [-Wreturn-type]
   87 | }
      | ^