Language: C

#include <algorithm>
#include <cassert>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <memory.h>
#include <random>
#include <set>
#include <stdint.h>
#include <vector>
using namespace std;

typedef pair<pair<int, int>, int> line;

template <typename T>
pair<T, T> cross(const line& l1, const line& l2)
{
    const int a1 = l1.first.first;
    const int b1 = l1.first.second;
    const int c1 = l1.second;

    const int a2 = l2.first.first;
    const int b2 = l2.first.second;
    const int c2 = l2.second;

    const T x = (T)(c1 * b2 - c2 * b1) / (a1 * b2 - a2 * b1);
    const T y = (T)(c1 * a2 - c2 * a1) / (b1 * a2 - b2 * a1);

    return make_pair(x, y);
}

int main()
{
    cin.tie(0);
    int n;
    cin >> n;

    vector<line> vs(n);
    for (auto& p : vs) {
        cin >> p.first.first >> p.first.second >> p.second;
    }

    mt19937 rng(time(nullptr));
    uniform_int_distribution<int> dist(0, n - 1);

    vector<float> xs, ys;
    const int SAMPLES = 1000000;

    for (int t = 0; t < SAMPLES; t++) {
    _rep:
        int i = dist(rng);
        int j = dist(rng);
        if (i == j)
            goto _rep;

        auto p = cross<float>(vs[i], vs[j]);
        xs.push_back(p.first);
        ys.push_back(p.second);
    }

    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());

    float lo_x = xs[SAMPLES / 2 - SAMPLES / 500];
    float hi_x = xs[SAMPLES / 2 + SAMPLES / 500];
    float lo_y = ys[SAMPLES / 2 - SAMPLES / 500];
    float hi_y = ys[SAMPLES / 2 + SAMPLES / 500];

    if (n < 1000) {
        lo_x = xs.front();
        hi_x = xs.back();
        lo_y = ys.front();
        hi_y = ys.back();
    }
    // cerr << lo_x << ", " << hi_x << endl;
    // cerr << lo_y << ", " << hi_y << endl;

    int lo_cnt_x = 0;
    int lo_cnt_y = 0;

    vector<double> rxs, rys;

    static int fs[40000];
    for (int i = 0; i < n; i++) {
        line a = vs[i];

#pragma clang loop vectorize(enable)
        for (int j = i + 1; j < n; j++) {
            const auto p = cross<float>(a, vs[j]);

            if (p.first < lo_x)
                lo_cnt_x++;
            if (p.second < lo_y)
                lo_cnt_y++;

            fs[j] = (lo_x <= p.first && p.first <= hi_x ? 1 : 0) | (lo_y <= p.second && p.second <= hi_y ? 2 : 0);
        }

        for (int j = i + 1; j < n; j++) {
            if ((fs[j] & 5) == 1) {
                rxs.push_back(cross<double>(vs[i], vs[j]).first);
            }
            if ((fs[j] & 10) == 2) {
                rys.push_back(cross<double>(vs[i], vs[j]).second);
            }
        }
    }

    int nn = (n * (n - 1) / 2 + 1) / 2;
    // cerr << lo_cnt_x << " + " << rxs.size() << " = " << lo_cnt_x + rxs.size() << " ~ " << nn << endl;
    // cerr << lo_cnt_y << " + " << rys.size() << " = " << lo_cnt_y + rys.size() << " ~ " << nn << endl;

    assert(lo_cnt_x < nn && lo_cnt_x + rxs.size() >= nn);
    assert(lo_cnt_y < nn && lo_cnt_y + rys.size() >= nn);

    // sort(rxs.begin(), rxs.end());
    // sort(rys.begin(), rys.end());

    nth_element(rxs.begin(), rxs.begin() + (nn - 1 - lo_cnt_x), rxs.end());
    nth_element(rys.begin(), rys.begin() + (nn - 1 - lo_cnt_y), rys.end());

    // for (int i = 0; i < rxs.size(); i++) {
    //     cout << "* " << i << ": " << rxs[i] << endl;
    // }

    // printf("%.12f %.12f\n", rxs[nn - 1 - lo_cnt_x], rys[nn - 1 - lo_cnt_y]);
    printf("%.12f %.12f\n", rxs[nn - 1 - lo_cnt_x], rys[nn - 1 - lo_cnt_y]);

    return 0;
}


Compiler output:
main.c:1:10: fatal error: algorithm: No such file or directory
    1 | #include <algorithm>
      |          ^~~~~~~~~~~
compilation terminated.