Language: C++

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
 
#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(), x.end()
 
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
 
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a) {
	os << '{';
	for(int i=0;i<sz(a);i++)
	{
		if(i>0&&i<=sz(a)-1)
			os << ", ";
		os << a[i];
	}
	os << '}';
    return os;
}
struct Node{
    int l;
    int r;
    Node* left;
    Node* right;
    bool lazy;
    int val;
    bool nula;
    Node()
    {
        left=NULL;
        right=NULL;
        lazy=false;
    }
    void extend()
    {
        if(left==NULL&&l!=r)
        {
            left=new Node();
            right=new Node();
            int m=(l+r)>>1;
            left->l=l;
            left->r=m;
            right->l=m+1;
            right->r=r;
        }
    }
    void prop()
    {
        if(nula)
        {
            nula=false;
            left->nula=true;
            right->nula=true;
            left->lazy=false;
            right->lazy=false;
            if(left->val==0)
                left->val=1;
            if(right->val==0)
                right->val=1;
        }
        if(lazy)
        {
            lazy=false;
            left->lazy=true;
            right->lazy=true;
            left->nula=false;
            right->nula=false;
            left->val=0;
            right->val=0;
        }
    }
    void set(int qs,int qe)
    {
        if(qs>r||qe<l)
            return;
        if(qs<=l&&qe>=r){
            lazy=true;
            nula=false;
            val=0;
            return;
        }
        extend();
        prop();
        left->set(qs,qe);
        right->set(qs,qe);
    }
    void set_nula(int qs,int qe)
    {
        if(qs>r||qe<l)
            return;
        if(qs<=l&&qe>=r){
            nula=true;
            lazy=false;
            if(val==0)
                val=1;
            return;
        }
        extend();
        prop();
        left->set_nula(qs,qe);
        right->set_nula(qs,qe);
    }
    int get(int p)
    {
        if(l>p||r<p)
            return 0;
        if(l==r&&l==p)
            return val;
        extend();
        prop();
        return left->get(p)+right->get(p);
    }
    void sett(int p,int k)
    {
        if(l>p||r<p)
            return;
        if(l==r&&l==p)
        {
            lazy=false;
            nula=false;
            val=k;
            return;
        }
        extend();
        prop();
        left->sett(p,k);
        right->sett(p,k);
    }
};
vector<int> niz;
bool test(int m)
{
   // printf("Testiram %i:\n",m);
    Node* root=new Node();
    root->l=0;
    root->r=1e9;
    for(auto p:niz)
    {
 
        //printf("Usao za %i\n",p);
        int t=root->get(p);
        //printf("Trenutna vrednos u p:%i\n",t);
        root->set_nula(0,p);
        if(p<(int)1e9)
            root->set(p+1,(int)1e9);
        t++;
        root->sett(p,t);
        //printf("%i %i %i\n",p,t,root->get(p));
        int tr=p;
        while(t>m)
        {
            if(tr==1)
                return false;
            root->sett(tr,1);
            int nxt=root->get(tr-1);
            nxt++;
            root->sett(tr-1,nxt);
            t=nxt;
            tr--;
        }
    }
    return true;
}
int main()
{
    int n;
    scanf("%i",&n);
    bool test5=true;
    int last=0;
    for(int i=0;i<n;i++)
    {
        int a;
        scanf("%i",&a);
        if(a<=last)
            test5=false;
        last=a;
        if(a<30)
            niz.pb(a);
    }
    if(test5)
    {
        printf("1\n");
        return 0;
    }
    int l=2,r=2e5+5;
    while(l<r)
    {
        int m=(l+r)>>1;
        if(test(m))
            r=m;
        else
            l=m+1;
    }
    printf("%i\n",l);
    return 0;
}#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
 
#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(), x.end()
 
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
 
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a) {
	os << '{';
	for(int i=0;i<sz(a);i++)
	{
		if(i>0&&i<=sz(a)-1)
			os << ", ";
		os << a[i];
	}
	os << '}';
    return os;
}
struct Node{
    int l;
    int r;
    Node* left;
    Node* right;
    bool lazy;
    int val;
    bool nula;
    Node()
    {
        left=NULL;
        right=NULL;
        lazy=false;
    }
    void extend()
    {
        if(left==NULL&&l!=r)
        {
            left=new Node();
            right=new Node();
            int m=(l+r)>>1;
            left->l=l;
            left->r=m;
            right->l=m+1;
            right->r=r;
        }
    }
    void prop()
    {
        if(nula)
        {
            nula=false;
            left->nula=true;
            right->nula=true;
            left->lazy=false;
            right->lazy=false;
            if(left->val==0)
                left->val=1;
            if(right->val==0)
                right->val=1;
        }
        if(lazy)
        {
            lazy=false;
            left->lazy=true;
            right->lazy=true;
            left->nula=false;
            right->nula=false;
            left->val=0;
            right->val=0;
        }
    }
    void set(int qs,int qe)
    {
        if(qs>r||qe<l)
            return;
        if(qs<=l&&qe>=r){
            lazy=true;
            nula=false;
            val=0;
            return;
        }
        extend();
        prop();
        left->set(qs,qe);
        right->set(qs,qe);
    }
    void set_nula(int qs,int qe)
    {
        if(qs>r||qe<l)
            return;
        if(qs<=l&&qe>=r){
            nula=true;
            lazy=false;
            if(val==0)
                val=1;
            return;
        }
        extend();
        prop();
        left->set_nula(qs,qe);
        right->set_nula(qs,qe);
    }
    int get(int p)
    {
        if(l>p||r<p)
            return 0;
        if(l==r&&l==p)
            return val;
        extend();
        prop();
        return left->get(p)+right->get(p);
    }
    void sett(int p,int k)
    {
        if(l>p||r<p)
            return;
        if(l==r&&l==p)
        {
            lazy=false;
            nula=false;
            val=k;
            return;
        }
        extend();
        prop();
        left->sett(p,k);
        right->sett(p,k);
    }
};
vector<int> niz;
bool test(int m)
{
   // printf("Testiram %i:\n",m);
    Node* root=new Node();
    root->l=0;
    root->r=1e9;
    for(auto p:niz)
    {
 
        //printf("Usao za %i\n",p);
        int t=root->get(p);
        //printf("Trenutna vrednos u p:%i\n",t);
        root->set_nula(0,p);
        if(p<(int)1e9)
            root->set(p+1,(int)1e9);
        t++;
        root->sett(p,t);
        //printf("%i %i %i\n",p,t,root->get(p));
        int tr=p;
        while(t>m)
        {
            if(tr==1)
                return false;
            root->sett(tr,1);
            int nxt=root->get(tr-1);
            nxt++;
            root->sett(tr-1,nxt);
            t=nxt;
            tr--;
        }
    }
    return true;
}
int main()
{
    int n;
    scanf("%i",&n);
    bool test5=true;
    int last=0;
    for(int i=0;i<n;i++)
    {
        int a;
        scanf("%i",&a);
        if(a<=last)
            test5=false;
        last=a;
        if(a<30)
            niz.pb(a);
    }
    if(test5)
    {
        printf("1\n");
        return 0;
    }
    int l=2,r=2e5+5;
    while(l<r)
    {
        int m=(l+r)>>1;
        if(test(m))
            r=m;
        else
            l=m+1;
    }
    printf("%i\n",l);
    return 0;
}

Compiler output:
a.cc:207:2: error: stray '#' in program
  207 | }#include <bits/stdc++.h>
      |  ^
a.cc:207:3: error: 'include' does not name a type
  207 | }#include <bits/stdc++.h>
      |   ^~~~~~~
a.cc:225:39: error: redefinition of 'template<class T1, class T2> std::ostream& operator<<(std::ostream&, const std::pair<_T1, _T2>&)'
  225 | template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
      |                                       ^~~~~~~~
a.cc:19:39: note: 'template<class T1, class T2> std::ostream& operator<<(std::ostream&, const std::pair<_T1, _T2>&)' previously declared here
   19 | template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
      |                                       ^~~~~~~~
a.cc:226:28: error: redefinition of 'template<class T> std::ostream& operator<<(std::ostream&, const std::vector<_Tp>&)'
  226 | template<class T> ostream& operator<<(ostream& os, const vector<T>& a) {
      |                            ^~~~~~~~
a.cc:20:28: note: 'template<class T> std::ostream& operator<<(std::ostream&, const std::vector<_Tp>&)' previously declared here
   20 | template<class T> ostream& operator<<(ostream& os, const vector<T>& a) {
      |                            ^~~~~~~~
a.cc:237:8: error: redefinition of 'struct Node'
  237 | struct Node{
      |        ^~~~
a.cc:31:8: note: previous definition of 'struct Node'
   31 | struct Node{
      |        ^~~~
a.cc:347:13: error: redefinition of 'std::vector<int> niz'
  347 | vector<int> niz;
      |             ^~~
a.cc:141:13: note: 'std::vector<int> niz' previously declared here
  141 | vector<int> niz;
      |             ^~~
a.cc:348:6: error: redefinition of 'bool test(int)'
  348 | bool test(int m)
      |      ^~~~
a.cc:142:6: note: 'bool test(int)' previously defined here
  142 | bool test(int m)
      |      ^~~~
a.cc:381:5: error: redefinition of 'int main()'
  381 | int main()
      |     ^~~~
a.cc:175:5: note: 'int main()' previously defined here
  175 | int main()
      |     ^~~~