Language: C++

 <bits/stdc++.h>
typedef long long lint;
using namespace std;

// セグメント木
// ref:https://ei1333.github.io/luzhiled/snippets/structure/segment-tree.html
template <typename Mnd>
struct segment_tree {
    int sz;
    vector<Mnd> data;
    function<Mnd(Mnd, Mnd)> f;
    Mnd e;
    //サイズだけ指定して初期化
    segment_tree(int _sz, function<Mnd(Mnd, Mnd)> _f, Mnd _e) : f(_f), e(_e) {
        sz = 1;
        while (sz < _sz) sz <<= 1;
        data.assign(sz * 2, e);
    }
    //参照渡しなので代入とかもできる
    Mnd& operator[](const int& k) {
        return data[k + sz];
    }
    //木を構築 O(n)
    void build() {
        for (int i = sz - 1; i > 0; i--) data[i] = f(data[2 * i], data[2 * i + 1]);
    }
    //更新しつつ木を再構築 O(log n)
    void update(int k, Mnd x) {
        data[k += sz] = x;
        while (k >>= 1) data[k] = f(data[2 * k], data[2 * k + 1]);
    }
    //[a,b)でのクエリに答える　O(log n)
    Mnd query(int a, int b) const {
        Mnd l = e, r = e;
        for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if (a & 1) l = f(l, data[a++]);
            if (b & 1) r = f(r, data[--b]);
        }
        return f(l, r);
    }
};

int main() {
    int n;
    cin >> n;
    segment_tree<lint> a(
        n, [](lint a, lint b) { return max(a, b); }, 0);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    a.build();
    lint money = 1000;
    for (int i = 0; i < n - 1; i++) {
        if (i + 1 < n && a[i] == a[i + 1]) {
            continue;
        }
        if (a[i] < a[i + 1]) {
            int nkab = money / a[i];
            money += nkab * (a[i + 1] - a[i]);
        }
    }
    cout << money << endl;
}

Compiler output:
a.cc:1:2: error: expected unqualified-id before '<' token
    1 |  <bits/stdc++.h>
      |  ^
a.cc:10:5: error: 'vector' does not name a type
   10 |     vector<Mnd> data;
      |     ^~~~~~
a.cc:11:5: error: 'function' does not name a type; did you mean 'union'?
   11 |     function<Mnd(Mnd, Mnd)> f;
      |     ^~~~~~~~
      |     union
a.cc:14:27: error: 'function' has not been declared
   14 |     segment_tree(int _sz, function<Mnd(Mnd, Mnd)> _f, Mnd _e) : f(_f), e(_e) {
      |                           ^~~~~~~~
a.cc:14:35: error: expected ',' or '...' before '<' token
   14 |     segment_tree(int _sz, function<Mnd(Mnd, Mnd)> _f, Mnd _e) : f(_f), e(_e) {
      |                                   ^
a.cc: In constructor 'segment_tree<Mnd>::segment_tree(int, int)':
a.cc:14:65: error: class 'segment_tree<Mnd>' does not have any field named 'f'
   14 |     segment_tree(int _sz, function<Mnd(Mnd, Mnd)> _f, Mnd _e) : f(_f), e(_e) {
      |                                                                 ^
a.cc:14:67: error: '_f' was not declared in this scope
   14 |     segment_tree(int _sz, function<Mnd(Mnd, Mnd)> _f, Mnd _e) : f(_f), e(_e) {
      |                                                                   ^~
a.cc:14:74: error: '_e' was not declared in this scope; did you mean 'e'?
   14 |     segment_tree(int _sz, function<Mnd(Mnd, Mnd)> _f, Mnd _e) : f(_f), e(_e) {
      |                                                                          ^~
      |                                                                          e
a.cc:17:9: error: 'data' was not declared in this scope
   17 |         data.assign(sz * 2, e);
      |         ^~~~
a.cc: In member function 'Mnd& segment_tree<Mnd>::operator[](const int&)':
a.cc:21:16: error: 'data' was not declared in this scope
   21 |         return data[k + sz];
      |                ^~~~
a.cc: In member function 'void segment_tree<Mnd>::build()':
a.cc:25:42: error: 'data' was not declared in this scope
   25 |         for (int i = sz - 1; i > 0; i--) data[i] = f(data[2 * i], data[2 * i + 1]);
      |                                          ^~~~
a.cc:25:52: error: there are no arguments to 'f' that depend on a template parameter, so a declaration of 'f' must be available [-fpermissive]
   25 |         for (int i = sz - 1; i > 0; i--) data[i] = f(data[2 * i], data[2 * i + 1]);
      |                                                    ^
a.cc:25:52: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
a.cc: In member function 'void segment_tree<Mnd>::update(int, Mnd)':
a.cc:29:9: error: 'data' was not declared in this scope
   29 |         data[k += sz] = x;
      |         ^~~~
a.cc:30:35: error: there are no arguments to 'f' that depend on a template parameter, so a declaration of 'f' must be available [-fpermissive]
   30 |         while (k >>= 1) data[k] = f(data[2 * k], data[2 * k + 1]);
      |                                   ^
a.cc: In member function 'Mnd segment_tree<Mnd>::query(int, int) const':
a.cc:36:33: error: 'data' was not declared in this scope
   36 |             if (a & 1) l = f(l, data[a++]);
      |                                 ^~~~
a.cc:37:33: error: 'data' was not declared in this scope
   37 |             if (b & 1) r = f(r, data[--b]);
      |                                 ^~~~
a.cc: In function 'int main()':
a.cc:45:5: error: 'cin' was not declared in this scope
   45 |     cin >> n;
      |     ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 |  <bits/stdc++.h>
a.cc:46:18: error: 'lint' was not declared in this scope; did you mean 'int'?
   46 |     segment_tree<lint> a(
      |                  ^~~~
      |                  int
a.cc:46:22: error: template argument 1 is invalid
   46 |     segment_tree<lint> a(
      |                      ^
a.cc:47:15: error: 'lint' is not a type
   47 |         n, [](lint a, lint b) { return max(a, b); }, 0);
      |               ^~~~
a.cc:47:23: error: 'lint' is not a type
   47 |         n, [](lint a, lint b) { return max(a, b); }, 0);
      |                       ^~~~
a.cc: In lambda function:
a.cc:47:40: error: 'max' was not declared in this scope
   47 |         n, [](lint a, lint b) { return max(a, b); }, 0);
      |                                        ^~~
a.cc: In function 'int main()':
a.cc:47:55: error: expression list treated as compound expression in initializer [-fpermissive]
   47 |         n, [](lint a, lint b) { return max(a, b); }, 0);
      |                                                       ^
a.cc:49:17: error: invalid types 'int[int]' for array subscript
   49 |         cin >> a[i];
      |                 ^
a.cc:51:7: error: request for member 'build' in 'a', which is of non-class type 'int'
   51 |     a.build();
      |       ^~~~~
a.cc:52:9: error: expected ';' before 'money'
   52 |     lint money = 1000;
      |         ^~~~~~
      |         ;
a.cc:54:27: error: invalid types 'int[int]' for array subscript
   54 |         if (i + 1 < n && a[i] == a[i + 1]) {
      |                           ^
a.cc:54:35: error: invalid types 'int[int]' for array subscript
   54 |         if (i + 1 < n && a[i] == a[i + 1]) {
      |                                   ^
a.cc:57:14: error: invalid types 'int[int]' for array subscript
   57 |         if (a[i] < a[i + 1]) {
      |              ^
a.cc:57:21: error: invalid types 'int[int]' for array subscript
   57 |         if (a[i] < a[i + 1]) {
      |                     ^
a.cc:58:24: error: 'money' was not declared in this scope
   58 |             int nkab = money / a[i];
      |                        ^~~~~
a.cc:58:33: error: invalid types 'int[int]' for array subscript
   58 |             int nkab = money / a[i];
      |                                 ^
a.cc:59:31: error: invalid types 'int[int]' for array subscript
   59 |             money += nkab * (a[i + 1] - a[i]);
      |                               ^
a.cc:59:42: error: invalid types 'int[int]' for array subscript
   59 |             money += nkab * (a[i + 1] - a[i]);
      |                                          ^
a.cc:62:5: error: 'cout' was not declared in this scope
   62 |     cout << money << endl;
      |     ^~~~
a.cc:62:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:62:13: error: 'money' was not declared in this scope
   62 |     cout << money << endl;
      |             ^~~~~
a.cc:62:22: error: 'endl' was not declared in this scope
   62 |     cout << money << endl;
      |                      ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 |  <bits/stdc++.h>