Language: C++

#include <algorithm>
#include <iostream>
#include <list>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

// index が条件を満たすかどうか
bool isOK(vector<int> & a, int index, int key) {
    if (a[index] < key) return true;
    else return false;
}

// 汎用的な二分探索のテンプレ
int binary_search(vector<int> & a, int key) {
    int ok = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(a, mid, key)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main() {
  int n;
  cin >> n;
  vector<int> la(n);
  for (int i = 0; i < n; ++i) {
    cin >> la[i];
  }
  vector<int> lc;
  lc.push_back(la[0]);
  for (int i = 1; i < la.size(); ++i) {
    int key = la[i];
    int ret = binary_search(lc, key);
    if (ret == lc.size()) {
      lc.push_back(key);
    }
    else {
      lc[ret] = key;
    }
  }
  cout << lc.size() << endl;
}


Compiler output:
a.cc:14:11: error: 'vector' was not declared in this scope
   14 | bool isOK(vector<int> & a, int index, int key) {
      |           ^~~~~~
a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    3 | #include <list>
  +++ |+#include <vector>
    4 | using namespace std;
a.cc:14:18: error: expected primary-expression before 'int'
   14 | bool isOK(vector<int> & a, int index, int key) {
      |                  ^~~
a.cc:14:28: error: expected primary-expression before 'int'
   14 | bool isOK(vector<int> & a, int index, int key) {
      |                            ^~~
a.cc:14:39: error: expected primary-expression before 'int'
   14 | bool isOK(vector<int> & a, int index, int key) {
      |                                       ^~~
a.cc:14:46: error: expression list treated as compound expression in initializer [-fpermissive]
   14 | bool isOK(vector<int> & a, int index, int key) {
      |                                              ^
a.cc:20:19: error: 'vector' was not declared in this scope
   20 | int binary_search(vector<int> & a, int key) {
      |                   ^~~~~~
a.cc:20:19: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:20:26: error: expected primary-expression before 'int'
   20 | int binary_search(vector<int> & a, int key) {
      |                          ^~~
a.cc:20:36: error: expected primary-expression before 'int'
   20 | int binary_search(vector<int> & a, int key) {
      |                                    ^~~
a.cc:20:43: error: expression list treated as compound expression in initializer [-fpermissive]
   20 | int binary_search(vector<int> & a, int key) {
      |                                           ^
a.cc: In function 'int main()':
a.cc:37:3: error: 'vector' was not declared in this scope
   37 |   vector<int> la(n);
      |   ^~~~~~
a.cc:37:3: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:37:10: error: expected primary-expression before 'int'
   37 |   vector<int> la(n);
      |          ^~~
a.cc:39:12: error: 'la' was not declared in this scope; did you mean 'll'?
   39 |     cin >> la[i];
      |            ^~
      |            ll
a.cc:41:10: error: expected primary-expression before 'int'
   41 |   vector<int> lc;
      |          ^~~
a.cc:42:3: error: 'lc' was not declared in this scope; did you mean 'll'?
   42 |   lc.push_back(la[0]);
      |   ^~
      |   ll
a.cc:42:16: error: 'la' was not declared in this scope; did you mean 'll'?
   42 |   lc.push_back(la[0]);
      |                ^~
      |                ll
a.cc:45:15: error: reference to 'binary_search' is ambiguous
   45 |     int ret = binary_search(lc, key);
      |               ^~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:2228:5: note: candidates are: 'template<class _FIter, class _Tp, class _Compare> bool std::binary_search(_FIter, _FIter, const _Tp&, _Compare)'
 2228 |     binary_search(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2194:5: note:                 'template<class _FIter, class _Tp> bool std::binary_search(_FIter, _FIter, const _Tp&)'
 2194 |     binary_search(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~~~
a.cc:20:5: note:                 'int binary_search'
   20 | int binary_search(vector<int> & a, int key) {
      |     ^~~~~~~~~~~~~