Language: C++

#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

class SegmentTree {
    using F = function<ll(ll, ll)>;
    const F f;
    int n, init;
    vector<int> node;

public:
    SegmentTree(int sz, const F f, ll init) : f(f), init(init) {
        n = 1;
        while (n < sz) n <<= 1;
        node.assign(2 * n, init);
    }

    void update(int x, ll val) {
        x += n;
        node[x] = val;
        while (x >>= 1) {
            node[x] = f(node[2 * x + 0], node[2 * x + 1]);
        }
    }

    // [a:b)
    ll query(int a, int b) {
        ll l = init, r = init;
        for (a += n, b += n; a < b; a >>= 1, b >>= 1) {
            if (a & 1) l = f(l, node[a++]);
            if (b & 1) r = f(node[--b], r);
        }
        return f(l, r);
    }
};


// verified
//   http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_A&lang=jp
void AOJ_DSL_2_A() {
    ll n, q, c, x, y;
    cin >> n >> q;
    SegmentTree seg(n, [](ll a, ll b) { return min(a, b); }, 2147483647LL);
    while (q--) {
        cin >> c >> x >> y;
        if (c) cout << seg.query(x, y + 1) << "\n";
        else seg.update(x, y);
    }
}


// verified
//   https://atcoder.jp/contests/abc125/tasks/abc125_c
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); }
void AtCoder_2019_4_27_C() {
    int n, a;
    cin >> n;
    SegmentTree seg(n, gcd, 0);
    for (int i = 0; i < n; i++) { cin >> a; seg.update(i, a); }
    int ans = 1;
    for (int i = 0; i < n; i++) ans = max(ans, gcd(seg.query(0, i), seg.query(i + 1, n)));
    cout << ans << "\n";
}

int main() {
    // AOJ_DSL_2_A();
    AtCoder_2019_4_27_C();
    return 0;
}

Compiler output:
a.cc:7:15: error: 'function' does not name a type; did you mean 'union'?
    7 |     using F = function<ll(ll, ll)>;
      |               ^~~~~~~~
      |               union
a.cc:8:11: error: 'F' does not name a type
    8 |     const F f;
      |           ^
a.cc:13:31: error: 'F' does not name a type
   13 |     SegmentTree(int sz, const F f, ll init) : f(f), init(init) {
      |                               ^
a.cc: In constructor 'SegmentTree::SegmentTree(int, int, ll)':
a.cc:13:47: error: class 'SegmentTree' does not have any field named 'f'
   13 |     SegmentTree(int sz, const F f, ll init) : f(f), init(init) {
      |                                               ^
a.cc: In member function 'void SegmentTree::update(int, ll)':
a.cc:23:23: error: 'f' was not declared in this scope
   23 |             node[x] = f(node[2 * x + 0], node[2 * x + 1]);
      |                       ^
a.cc: In member function 'll SegmentTree::query(int, int)':
a.cc:31:28: error: 'f' was not declared in this scope
   31 |             if (a & 1) l = f(l, node[a++]);
      |                            ^
a.cc:32:28: error: 'f' was not declared in this scope
   32 |             if (b & 1) r = f(node[--b], r);
      |                            ^
a.cc:34:16: error: 'f' was not declared in this scope
   34 |         return f(l, r);
      |                ^
a.cc: In function 'void AOJ_DSL_2_A()':
a.cc:44:24: error: invalid user-defined conversion from 'AOJ_DSL_2_A()::<lambda(ll, ll)>' to 'int' [-fpermissive]
   44 |     SegmentTree seg(n, [](ll a, ll b) { return min(a, b); }, 2147483647LL);
      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:44:24: note: candidate is: 'constexpr AOJ_DSL_2_A()::<lambda(ll, ll)>::operator long long int (*)(ll, ll)() const' (near match)
   44 |     SegmentTree seg(n, [](ll a, ll b) { return min(a, b); }, 2147483647LL);
      |                        ^
a.cc:44:24: note:   no known conversion from 'long long int (*)(ll, ll)' {aka 'long long int (*)(long long int, long long int)'} to 'int'
a.cc:13:33: note:   initializing argument 2 of 'SegmentTree::SegmentTree(int, int, ll)'
   13 |     SegmentTree(int sz, const F f, ll init) : f(f), init(init) {
      |                         ~~~~~~~~^
a.cc: In function 'void AtCoder_2019_4_27_C()':
a.cc:59:24: error: invalid conversion from 'int (*)(int, int)' to 'int' [-fpermissive]
   59 |     SegmentTree seg(n, gcd, 0);
      |                        ^~~
      |                        |
      |                        int (*)(int, int)
a.cc:13:33: note:   initializing argument 2 of 'SegmentTree::SegmentTree(int, int, ll)'
   13 |     SegmentTree(int sz, const F f, ll init) : f(f), init(init) {
      |                         ~~~~~~~~^