criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

long long A[200001];
map<long long, int> mp;

int N;

int check(int K){
  if (K==1) {
    for (i=1;i<N;++i) {
      if (A[i]<=A[i-1]) {
        return 0;
      }
    }
    return 1;
  }
  mp.clear();
  int i,j,k;
  for (i=1;i<N;++i) {
    if (A[i]<=A[i-1]) {
      map<long long, int>::iterator it=mp.lower_bound(A[i]);
      mp.erase(it, mp.end());

      j=A[i]-1;
      while (1) {
        mp[j]+=1;
        if (mp[j]<K) {
          break;
        } else {
          mp.erase(j);
          j--;
          if (j==-1) {
            return 0;
          }
        }
      }
    }
    //cout << K << mp[0] << " " << mp[1] << " " << mp[2] << " " << mp[3] << " " << endl;
  }
  return 1;
}

int main(){
  int i,K;
  cin >> N;
  for (i=0;i<N;++i) {
    cin >> A[i];
  }
  int L=1,U=N;
  while (U>L) {
    K=(U+L)/2;
    if (check(K)==0) { //NG
      //cout << K << "NG" << endl;
      L=K+1;
    } else { //OK
      //cout << K << "OK" << endl;
      U=K-1;
    }
  }
  if (U==L) {
    if (check(L)==1) {
      cout << L << endl;
    } else {
      cout << (L+1) << endl;
    }
  } else {
    cout << L << endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int check(int)':
a.cc:14:10: error: 'i' was not declared in this scope
   14 |     for (i=1;i<N;++i) {
      |          ^
Language: C++

#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

long long A[200001];
map<long long, int> mp;

int N;

int check(int K){
  mp.clear();
  int i,j,k;
  for (i=1;i<N;++i) {
    if (A[i]<=A[i-1]) {
      //map<long long, int>::iterator it=mp.lower_bound(A[i]);
      //mp.erase(it, mp.end());

      j=A[i]-1;
      while (1) {
        mp[j]+=1;
        if (mp[j]<K) {
          break;
        } else {
          mp.erase(j)
          j--;
          if (j==-1) {
            return 0;
          }
        }
      }
    }
    //cout << K << mp[0] << " " << mp[1] << " " << mp[2] << " " << mp[3] << " " << endl;
  }
  return 1;
}

int main(){
  int i,K;
  cin >> N;
  for (i=0;i<N;++i) {
    cin >> A[i];
  }
  int L=1,U=N;
  while (U>L) {
    K=(U+L)/2;
    if (check(K)==0) { //NG
      //cout << K << "NG" << endl;
      L=K+1;
    } else { //OK
      //cout << K << "OK" << endl;
      U=K-1;
    }
  }
  if (U==L) { //直前でLが上がってきた
    if (check(L)==1) {
      cout << L << endl;
    } else {
      cout << (L+1) << endl;
    }
  } else {
    cout << L << endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int check(int)':
a.cc:26:22: error: expected ';' before 'j'
   26 |           mp.erase(j)
      |                      ^
      |                      ;
   27 |           j--;
      |           ~
Language: C++

#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<bitset>
#include<random>
#include<cstdint>
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
#define shosu setprecision(17)
  
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
ll longinf=(1ll<<60);
ll inf=1ll<<29;

int n;
int main(){
      int n;
      cin>>n;
      int a[n];
      rep0(i,n)cin>>a[i];
      int ng=0;
      int ok=2*1e5;
      int counter[40];
      fill(counter,counter+40,1);
      while(ok-ng>1){
            bool good=true;
            int now=(ok+ng)/2;
            fill(counter,counter+40,0);
            rep0(i,n-1){
                  if(a[i+1]>a[i]) continue;
                  if(a[i+1]>39)continue;
                  while(1){
                        if(counter[j]==now-1){
                          counter[j]=0;
                              j--;
                        }
                        else{
                              counter[j]++;
                              break;
                        }
                        if(j==0){
                              good=false;
                              break;
                        }
                  }
                  //rep0(i,10) cout<<counter[i]<<" ";
                  //cout<<endl;
                  }
                  //cout<<endl;
            if(good) ok=now;
            else ng=now;
      }
      cout<<ok<<endl;
      return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:43:36: error: 'j' was not declared in this scope
   43 |                         if(counter[j]==now-1){
      |                                    ^
a.cc:51:28: error: 'j' was not declared in this scope
   51 |                         if(j==0){
      |                            ^
Language: C++

#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<bitset>
#include<random>
#include<cstdint>
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
#define shosu setprecision(17)
  
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
ll longinf=(1ll<<60);
ll inf=1ll<<29;

int n;
int main(){
      int n;
      cin>>n;
      int a[n];
      rep0(i,n)cin>>a[i];
      int ng=0;
      int ok=2*1e5;
      while(ok-ng>1){
            bool good=true;
            int now=(ok+ng)/2;
            mp<int,int> counter;
            rep0(i,n-1){
                  int j=a[i+1];
                  while(1){
                        if(counter[j]>=now-1){
                              j--;
                        }
                        else{
                              counter[j]++;
                              break;
                        }
                        if(j<=0){
                              good=false;
                              break;
                        }
                  }
                  //rep0(i,10) cout<<counter[i]<<" ";
                  //cout<<endl;
                  }
                  //cout<<endl;
            if(good) ok=now;
            else ng=now;
      }
      cout<<ok<<endl;
      return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:13: error: 'mp' was not declared in this scope
   36 |             mp<int,int> counter;
      |             ^~
a.cc:36:16: error: expected primary-expression before 'int'
   36 |             mp<int,int> counter;
      |                ^~~
a.cc:40:28: error: 'counter' was not declared in this scope
   40 |                         if(counter[j]>=now-1){
      |                            ^~~~~~~
Language: C++

#include <iostream>
#include <vector>
using namespace std;

using pll = pair<long long, long long>;

void normalize(vector<pll> &nums) {
    if (nums.size() > 1) {
        if (nums[nums.size()-1].first == nums[nums.size()-2].first) {
            nums[nums.size()-2].second += nums[nums.size()-1].second;
            nums.pop_back();
        }
    }
}

void zouka(vector<pll> &nums) {
    if (nums.back().second == 1) {
        nums.back().first += 1;
    }
    else {
        nums.back().second--;
        nums.push_back(pll(nums.back().first+1, 1));
    }
    normalize(nums);
}

int main() {
    int N; cin >> N;
    vector<long long> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];
    long long low = 0, high = N+1;
    while (high - low > 1) {
        long long mid = (low + high) / 2;
        
        vector<pll> nums;
        nums.push_back(pll(0, a[0]));
        bool ok = true;
        for (int i = 1; i < N; ++i) {
            if (a[i-1] < a[i]) nums.push_back(pint(0, a[i] - a[i-1]));
            else {
                long long sum = 0;
                while (nums.size() > 0 && sum + nums.back().second <= a[i-1] - a[i]) {
                    sum += nums.back().second;
                    nums.pop_back();
                }
                nums.back().second -= a[i-1] - a[i] - sum;

                if (nums.back().first == mid-1) {
                    if (nums.size() == 1) {
                        ok = false;
                        break;
                    }
                    long long num = nums.back().second;
                    nums.pop_back();
                    zouka(nums);
                    nums.push_back(pll(0, num));
                }
                else zouka(nums);
            }
            normalize(nums);
        }

        if (ok) high = mid;
        else low = mid;
    }
    cout << high << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:47: error: 'pint' was not declared in this scope; did you mean 'uint'?
   39 |             if (a[i-1] < a[i]) nums.push_back(pint(0, a[i] - a[i-1]));
      |                                               ^~~~
      |                                               uint
Language: C++

#include<iostream>
#include<stack>
using namespace std;
int main() {
	static int N, A[200001] = {};
	cin >> N;
	for (int i = 1;i <= N;++ i) cin >> A[i];
	int ans = 0, max = N, mid, halfDiff, tmp;
	while(halfDiff = max - ans >> 1) { // 二分探索
		bool check = false;
		mid = ans + halfDiff;
		stack<pair<int, int> > stk;
		for (int j = 1;j <= N;++ j) { // シミュレーション
			if (A[j - 1] < A[j]) stk.push(make_pair(A[j], 1)); // 文字数が増えるパターン
			else { // 文字数が減るパターン
				while (!stk.empty() && stk.top.first > A[j]) stk.pop();
				if (stk.empty()) stk.push(make_pair(A[j], 1));
				while (++ stk.top().second > mid) {
					tmp = mid == 1 ? 1 : stk.top().first;
					if (tmp == 1) goto break_label;
					stk.pop();
					if (stk.empty() || stk.top().first != tmp - 1) stk.push(make_pair(tmp - 1, 1));
				}
			}
		}
		check = true;
		break_label:;
		(check ? max : ans) = mid;
	}
	cout << max;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:60: error: invalid use of member function 'std::stack<std::pair<int, int> >::top' (did you forget the '()' ?)
   16 |                                 while (!stk.empty() && stk.top.first > A[j]) stk.pop();
      |                                                        ~~~~^~~
a.cc:16:64: error: expected ')' before 'first'
   16 |                                 while (!stk.empty() && stk.top.first > A[j]) stk.pop();
      |                                       ~                        ^~~~~
      |                                                                )
a.cc:16:64: error: 'first' was not declared in this scope
   16 |                                 while (!stk.empty() && stk.top.first > A[j]) stk.pop();
      |                                                                ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main(){
    int N;
    int A[200000];
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];

    int l=0, r=N;
    while(r-l>1){
        int b=0;
        int m=(l+r+1)/2;
        if(m==1){
            if(N==1) goto ok;
            else goto ng;
        }
        cerr << "m=" << m << ": ";
        map<int,int> state;
        for(int i=1;i<N;i++){
            if(A[i-1]>=A[i]){
                int j = A[i];
                if(j>b){
                    state[j]=1;
                    b=j;
                }
                else state[j]++;
                while(state[j]>=m){
                    state[j]=0;
                    if(j<=1){
                        goto ng;
                    }else{
                        state[j-1]++;
                        j--;
                    }
                }
            }
        }
        ok: r = m; cerr << "ok" << endl; continue;
        ng: l = m; cerr << "ng" << endl; continue;
    }
    cout << r << endl;
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:9: error: jump to label 'ok'
   42 |         ok: r = m; cerr << "ok" << endl; continue;
      |         ^~
a.cc:18:27: note:   from here
   18 |             if(N==1) goto ok;
      |                           ^~
a.cc:22:22: note:   crosses initialization of 'std::map<int, int> state'
   22 |         map<int,int> state;
      |                      ^~~~~
a.cc:43:9: error: jump to label 'ng'
   43 |         ng: l = m; cerr << "ng" << endl; continue;
      |         ^~
a.cc:19:23: note:   from here
   19 |             else goto ng;
      |                       ^~
a.cc:22:22: note:   crosses initialization of 'std::map<int, int> state'
   22 |         map<int,int> state;
      |                      ^~~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; (i) < (n); ++ (i))
#define loop(i,a,n) for (int i = (a); (i) < (n); ++ (i))
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 0
//#define int ll
using namespace std;
typedef vector<int> vi;
int N;
vector<ll> NU,NN;

pair<int,int> che(ll num, int ind, int ite) {
    int old = 0,now = 1;
    ll a;
    loop(i,ind+1,N) {
        a = NU[i];
        if(a == num && i!=ind +1) {
            now++;
        } else if(a > num) {
            pair<int,int> oldp = che(NN[ite + 1], i-1, ite + 1);
            old = max(oldp.first,old);
            i = oldp.second;
        } else if(a < num) {
            return make_pair(max(now,old),i-1);
        }
    }
    return make_pair(max(now,old),N);
}

signed main(){
    ll c;
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    rep(i,N) {
        cin >> c;
        NU.push_back(c);
        NN.push_back(c);
    }
    sort(NN.begin(),NN.end());
    NN.erase(unique(NN.begin(),NN.endl()),NN.end());
    cout << che(NN[0], -1,0).first << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:35: error: 'class std::vector<long long int>' has no member named 'endl'; did you mean 'end'?
   44 |     NN.erase(unique(NN.begin(),NN.endl()),NN.end());
      |                                   ^~~~
      |                                   end
Language: C++

#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 1e9+7
#define N 400001
#define MAX_V 400010
#define vec vector<int>
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
template<typename A, size_t NNN, typename T>
void Fill(A (&array)[NNN], const T &val){
    fill( (T*)array, (T*)(array+NNN), val );
}
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umap unordered_map<ll,int,custom_hash>
struct pair_hash
{
    template<class T1,class T2>
    size_t operator() (const pair<T1,T2> &p)const{
        return hash<T1>()(p.first)^hash<T2>()(p.second);
    }
};

ll modpow(ll x,ll n){
    if(n<0)return 1;
    if(n==0) return 1;
    ll res=modpow(x*x,n/2);
    if(n&1) res=res*x;
    return res;
}
main(){
    int n=in();
    int a[N];
    rep(i,n)a[i]=in();
    bool flag=true;
    rep(i,n-1)if(a[i]>=a[i+1])flag=false;
    if(flag){cout<<1;return 0;}
    vec t;
    rep(i,n)t.pb(a[i]);
    sort(ALL(t));
    t.erase(unique(ALL(t)),t.end());
    rep(i,n){
        a[i]=lower_bound(ALL(t),a[i])-t.begin();
        a[i]++;
    }
    int l=1,r=n;
    while(l<r-1){
        int mid=l+r>>1;
        int t=0;
        int s=0;
        while(modpow(mid,t)<1e18/mid){
            t++;
        }
        ll temp=0;
        rep2(i,1,n-1){
            if(a[i]<=t){
                if(!(&a[i-1]<a[i])){
                ll d=modpow(mid,t-a[i]);
                temp=((temp)/d+1)*d;
                }
            }
            else if(!(&a[i]>a[i-1])){
              s++;if(s==mid){temp++;s=0;}}
        }
        if(modpow(mid,t)<=temp)l=mid;
        else r=mid;
    }
  cout<<r;
}


Compiler output:
a.cc:56:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   56 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:82:29: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   82 |                 if(!(&a[i-1]<a[i])){
      |                      ~~~~~~~^~~~~
a.cc:87:28: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   87 |             else if(!(&a[i]>a[i-1])){
      |                       ~~~~~^~~~~~~
Language: C++

#include<bits/stdc++.h>
#define rep(i,l,r) for (int i=l;i<=r;i++)
#define per(i,l,r) for (int i=l;i>=r;i--)
using namespace std;
typedef long long ll;
int n,x,ans;
int a[400500],st[400500];
map<int,int> c;
bool jud(int mid){
    int now=mid;
    c.clear();
    int tot=0;
    rep(i,2,n){
        if (a[i]>a[i-1]) continue;
        while (tot&&st[tot]>a[i]){
            mp[st[tot]]=0;
            tot--;
        }
        st[++tot]=a[i];
        int x=a[i];
        c[x]++;
        if (mid==1) return 0;
        while (c[x]>=mid) c[x]=0,c[--x]++;
        if (x<=0) return 0;
    }
    return 1;
}
int main(){
    scanf("%d",&n);
    rep(i,1,n) scanf("%d",&a[i]);
    int l=1,r=n,ans=n;
    while (l<=r){
        int mid=(l+r)/2;
        if (jud(mid)) ans=mid,r=mid-1;
        else l=mid+1;
    }
    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'bool jud(int)':
a.cc:16:13: error: 'mp' was not declared in this scope
   16 |             mp[st[tot]]=0;
      |             ^~
Language: C++

   int n; cin >> n;
    vi a(n);
    FOR(x, a) cin >> x;
    map<int,int> cnt;
    rng (i, 1, n) {
        if(a[i] > a[i-1]) continue;
        cnt[a[i]]++;
    }

    int ma = 0;
    int sum = 0;
    FOR(p, cnt) {
        sum += p.second;
        if (p.second > ma) {
            ma = max(ma, sum / p.first + (sum % p.first != 0));
        }
    }
    println(ma + 1);

Compiler output:
a.cc:1:11: error: 'cin' does not name a type
    1 |    int n; cin >> n;
      |           ^~~
a.cc:2:5: error: 'vi' does not name a type; did you mean 'void'?
    2 |     vi a(n);
      |     ^~
      |     void
a.cc:3:8: error: expected constructor, destructor, or type conversion before '(' token
    3 |     FOR(x, a) cin >> x;
      |        ^
a.cc:4:5: error: 'map' does not name a type
    4 |     map<int,int> cnt;
      |     ^~~
a.cc:5:9: error: expected constructor, destructor, or type conversion before '(' token
    5 |     rng (i, 1, n) {
      |         ^
a.cc:12:8: error: expected constructor, destructor, or type conversion before '(' token
   12 |     FOR(p, cnt) {
      |        ^
a.cc:18:12: error: expected constructor, destructor, or type conversion before '(' token
   18 |     println(ma + 1);
      |            ^
Language: C++

#include<iostream>
using namespace std;

int main(){
    long int s[1000000000]=0,l[20000];
    long long int n,maxl,max;
    cin>>n;
    cin>>l[0];
    for(int i=0;i<l[0];i++){
        s[i]=1;
    }
    for(int i=1;i<n;i++){
        cin>>l[i];
        if(l[i]>l[i-1]){
            for(int k=l[i-1];k<l[i];k++){
                s[k]=1;
            }
        }
        else{
            s[l[i]-1]++;
            for(int k=l[i];s[k]!=0;k++){
                s[k]=0;
            }
        }
    }
    max=1;
    for(int i=0;s[i]!=0;i++){
        if(s[i]>max)max=s[i];
    }
    cout<<max<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:28: error: array must be initialized with a brace-enclosed initializer
    5 |     long int s[1000000000]=0,l[20000];
      |                            ^
Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
#define endl '\n'
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 222222


ll a[MAX];

int main(void) {
  ios::sync_with_stdio(false); cin.tie(0);


  cin >> n;
  rep(i, n) cin >> a[i];
  priority_queue<pll, vpll> pq;
  ans = 1;
  FOR(i, 1, n) {
    if (a[i] <= a[i - 1]) {
      while (!pq.empty()) {
        pll p = pq.top();
        pq.pop();
        if (p.first > a[i]) continue;
        if (p.second < ans) {
          p.second++;
          pq.push(p);
          break;
        }
        else {
          while (!pq.empty) {
            pll pp = pq.top();
            if (pp.second < ans) {
              if (pp.first == 1) ans++;
              pp.second++;
              pq.push(pp);
              break;
            }
          }
        }
      }

      if (pq.empty()) {
        pq.push(make_pair(a[i], 2));
        ans = max(2LL, ans);
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:67:22: error: cannot convert 'std::priority_queue<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> > >::empty' from type 'bool (std::priority_queue<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> > >::)() const' to type 'bool'
   67 |           while (!pq.empty) {
      |                      ^~~~~
a.cc:67:22: error: in argument to unary !
   67 |           while (!pq.empty) {
      |                   ~~~^~~~~
Language: C++

#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    int64_t n;
    cin >> n;

    // len
    vector<int64_t> a;
    int64_t prev = (1L << 30);
    for (auto i : irange(0, n)) {
        int64_t aa;
        cin >> aa;
        if (prev >= aa) {
            a.push_back(aa);
        }

        prev = aa;
    }

    auto r = irange(1L, static_cast<int64_t>(a.size()) + 1L);
    auto it = partition_point(r.begin(), r.end(), [&a](int64_t t){
        // len, char
        vector<pair<int64_t, int>> seq;

        seq.emplace_back(a[0], 0);
        // prev len
        int64_t s = a[0];
        for (int64_t i_block = 1; i_block < a.size(); ++i_block) {
            auto len = a[i_block];

#if 0
            cerr << "[" << t << "]" << len << endl;
            for (const auto& kv : seq) {
                cerr << kv.first << ", " << kv.second << endl;
            }
#endif
            if (s < len) {
                if (seq.back().second == 0) {
                    seq.back().first += len - s;
                } else {
                    seq.emplace_back(len - s, 0);
                }
                s = len;
            }

            while (s > len) {
                if (s - seq.back().first >= len) {
                    s -= seq.back().first;
                    seq.pop_back();
                } else {
                    seq.back().first -= s - len;
                    s = len;
                }
            }

            bool found = false;
            for (auto ii = seq.rbegin(); ii != seq.rend(); ++ii) {
                auto&& block = *ii;
                if (block.second + 1 < t) {
                    if (block.first == 1) {
                        ++block.second;
                    } else {
                        --block.first;
                        seq.emplace(ii.base(), 1, block.second + 1);
                    }

                    found = true;
                    break;
                }
            }

            if (!found) {
                return true;
            }
        }

        return false;
    });

    cout << *it << endl;
}

Compiler output:
a.cc:2:10: fatal error: boost/range/irange.hpp: No such file or directory
    2 | #include <boost/range/irange.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
using namespace std;

int main(){
    long long int s[1000000000]=0,l[20000];
    long long int n,maxl,max;
    cin>>n;
    cin>>l[0];
    for(int i=0;i<l[0];i++){
        s[i]=1;
    }
    for(int i=1;i<n;i++){
        cin>>l[i];
        if(l[i]>l[i-1]){
            for(int k=l[i-1];k<l[i];k++){
                s[k]=1;
            }
        }
        else{
            s[l[i]-1]++;
            for(int k=l[i];s[k]!=0;k++){
                s[k]=0;
            }
        }
    }
    max=1;
    for(int i=0;s[i]!=0;i++){
        if(s[i]>max)max=s[i];
    }
    cout<<max<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:33: error: array must be initialized with a brace-enclosed initializer
    5 |     long long int s[1000000000]=0,l[20000];
      |                                 ^
Language: C++

                cnt+=1;
                life= getlife(v[i]);

Compiler output:
a.cc:1:17: error: 'cnt' does not name a type; did you mean 'int'?
    1 |                 cnt+=1;
      |                 ^~~
      |                 int
a.cc:2:17: error: 'life' does not name a type
    2 |                 life= getlife(v[i]);
      |                 ^~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

const int ms = 2e5 + 20;

int n;
int a[ms];
int v[3 * ms];
map<int, int> p;

int root(int u) {
  if (!p.count(u)) return u;
  if (p[u] == u) return u;
  return p[u] = root(p[u]);
}

bool can(int sigma) {
  for (int i = 0; i < 3 * ms; i++) {
    p[i] = i;
    v[i] = sigma - 1;
  }
  set<int> cur;
  for (int i = n - 2; i > -1; i--) {
    if (a[i] >= a[i + 1]) {
      int at = root(a[i + 1]);
      if (at == 0) return false;
      assert(v[at] > 0);
      v[at]--;
      if (v[at] == 0) {
        p[at] = at - 1;
      }
      cur.insert(at);
      vector<int> aux;
      for (auto it = cur.upper_bound(a[i + 1]); it != cur.end(); it++) {
        aux.push_back(*it);
      }
      for (auto x : aux) {
        cur.erase(x);
        v.erase(x);
        p.erase(x);
      }
    }
  }
  return true;
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  int ok = 1;
  for (int i = 0; i + 1 < n; i++) {
    if (a[i] >= a[i + 1]) ok = 0;
  } 
  if (ok) {
    puts("1");
    return 0;
  }
  int lo = 2, hi = n + 2;
  while (lo < hi) {
    int md = (lo + hi) / 2;
    if (can(md)) {
      hi = md;
    } else {
      lo = md + 1;
    }
  }
  cout << lo << endl;
}

Compiler output:
a.cc: In function 'bool can(int)':
a.cc:40:11: error: request for member 'erase' in 'v', which is of non-class type 'int [600060]'
   40 |         v.erase(x);
      |           ^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;



int main() {
	int N;
	cin >> N;

	vector<ll> A(N);
	for (auto& e : A) {
		cin >> e;
	}

	int l = 0, r = N;
	while (r - l > 1) {
		int mid = (l + r) / 2;

		unordered_map<int, int> mp;
		mp[A[0]] = 0;
		bool ok = true;
		for (int i = 1; i<N; i++) {
			if (A[i - 1] < A[i]) {
				auto it = --mp.end();
				if (it->second == 0) {
					mp.erase(it);
				}
				mp[A[i]] = 0;
			} else {
				auto it = mp.lower_bound(A[i]);
				if (it->second == mid - 1) {
					while (it != mp.begin() && it->second == mid - 1) {
						--it;
					}
					if (it == mp.begin() && it->second == mid - 1) {
						ok = false;
						break;
					}
					if (it->first != 1 && mp.find(it->first - 1) == mp.end()) {
						mp[it->first - 1] = it->second;
					}
					it->second++;
					mp.erase(next(it, 1), mp.end());
					assert(it->first < A[i]);
					mp[A[i]] = 0;
				} else {
					if (A[i] != 1 && mp.lower_bound(A[i] - 1) == it) {
						mp[A[i] - 1] = it->second;
					}
					mp[A[i]] = it->second + 1;
				}
			}
		}
		if (ok) {
			r = mid;
		} else {
			l = mid;
		}
	}
	cout << r << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:43: error: no match for 'operator--' (operand type is 'std::unordered_map<int, int>::iterator' {aka 'std::__detail::_Insert_base<int, std::pair<const int, int>, std::allocator<std::pair<const int, int> >, std::__detail::_Select1st, std::equal_to<int>, std::hash<int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::iterator'})
   25 |                                 auto it = --mp.end();
      |                                           ^~~~~~~~~~
a.cc:31:46: error: 'class std::unordered_map<int, int>' has no member named 'lower_bound'
   31 |                                 auto it = mp.lower_bound(A[i]);
      |                                              ^~~~~~~~~~~
a.cc:48:61: error: 'class std::unordered_map<int, int>' has no member named 'lower_bound'
   48 |                                         if (A[i] != 1 && mp.lower_bound(A[i] - 1) == it) {
      |                                                             ^~~~~~~~~~~
Language: C++

#include<iostream>
using namespace std;
long long int s[1000000000]=0,l[20000];
int main(){
    long long int n,maxl,max;
    cin>>n;
    cin>>l[0];
    for(int i=0;i<l[0];i++){
        s[i]=1;
    }
    for(int i=1;i<n;i++){
        cin>>l[i];
        if(l[i]>l[i-1]){
            for(int k=l[i-1];k<l[i];k++){
                s[k]=1;
            }
        }
        else{
            s[l[i]-1]++;
            for(int k=l[i];s[k]!=0;k++){
                s[k]=0;
            }
        }
    }
    max=1;
    for(int i=0;s[i]!=0;i++){
        if(s[i]>max)max=s[i];
    }
    cout<<max<<endl;
}

Compiler output:
a.cc:3:29: error: array must be initialized with a brace-enclosed initializer
    3 | long long int s[1000000000]=0,l[20000];
      |                             ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int maxn=(2e5)+10;
const int mx=(1e9)+1;
int n,a[maxn];
int b[maxn];
bool solve(int mid) {
	cnt=100;
	memset(b,0,sizeof(b)); int sz=0;
	for (int i=1;i<=n;i++) {
		if (a[i]>cnt) continue;
		if (sz<a[i]) {
			for (int j=sz+1;j<=a[i];j++) b[j]=1;
			sz=a[i];
		} else {
			b[a[i]]++;
			int j=a[i];
			while (j>=1) {
				if (b[j]>mid) { b[j-1]++; b[j]=1; j--; }
				else break;
			}
			if (b[0]) return 0;
			sz=a[i];
		}
	}
	return 1;
}
bool ck() {
	for (int i=1;i<n;i++)
		if (a[i]>=a[i+1]) return 0;
	return 1;
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	for (int i=1;i<=n;i++) read(a[i]);
	if (ck()) {
		printf("1\n");
		return 0;
	}	
	int l=2,r=n,mid,res;
	while (l<=r) {
		mid=(l+r)/2;
		if (solve(mid)) r=mid-1,res=mid;
		else l=mid+1;
	}
	printf("%d\n",res);
	return 0;
}

Compiler output:
a.cc: In function 'bool solve(int)':
a.cc:14:9: error: 'cnt' was not declared in this scope; did you mean 'int'?
   14 |         cnt=100;
      |         ^~~
      |         int
Language: C++

#include <iostream>
#include <stack>
#include <vector>
#include <cassert>
using namespace std;

typedef struct{
  int len;
  int val;
}Number ;

void dump(stack<Number> S){
  return;
  stack<Number> tmp;
  while(!S.empty()){
    tmp.push(S.top());
    S.pop();
  }

  //cout <<"dump: " ;
  while(!tmp.empty()){
    Number top = tmp.top(); tmp.pop();
    assert(tmp.len > 0);
    //for(int i = 0;i < top.len ;i++){
      //cout << (char)('a' + top.val-1);
    //}
    //cout <<" ";
  }
  //cout << endl;
}

void decrease(stack<Number>  & S, int current_length, int target_length){
  while(!S.empty() && current_length > target_length){
    Number top = S.top();
    if (current_length - top.len >= target_length){
      S.pop();
      current_length -= top.len;
    } else if (current_length - top.len < target_length){
      //S.top().len -= current_length - target_length;
      S.top().len = target_length - (current_length - S.top().len);
      break;
    }
  }
}

int add(stack<Number> & S, int val, const int length){
  int new_val = val;
  stack<Number> tmp_stack;
  while(!S.empty()){
    Number top = S.top();
    S.pop();
    if (top.val != val){
      Number a = {top.len-1, top.val};
      Number b = {1        , top.val+1};
      if (a.len != 0){
	S.push(a);
      }
      S.push(b);
      break;
    } else if (top.val == val){
      Number a = {top.len, 1};
      tmp_stack.push(a);
    }
  }

  if (S.empty()){
    new_val = new_val + 1;
    while(!tmp_stack.empty()){
      Number top = tmp_stack.top();
      tmp_stack.pop();
      S.push(top);
    }

    Number top = S.top();
    S.pop();
    Number a = {top.len-1, top.val};
    Number b = {1,new_val};
    if (a.len != 0){
      S.push(a);
    }
    S.push(b);
  } else {
    while(!tmp_stack.empty()){
      S.push(tmp_stack.top());
      tmp_stack.pop();
    }
  }
  return new_val;
}

int solve(vector<int> & in){
  stack<Number> S;
  const int n = in.size();
  int val = 1;
  int length = in[0];
  S.push((Number){in[0], val});
  for(int i = 1;i < n;i++){
    //dump(S);
    if (length < in[i]){
      //cout <<"push" << endl;
      S.push((Number){in[i] - length, 1});
    } else if (length == in[i]){
      //cout << "add" << endl;
      val = max(val, add(S, val, in[i]));
    } else if (in[i] < length){
      //cout <<"decrease add " << endl;
      decrease(S, length, in[i]);
      //dump(S);
      val = max(val, add(S, val, in[i]));
    }
    length = in[i];
    //dump(S);
  }
  return val;
}

int main(){
  int n;
  cin >> n;
  vector<int> in(n);
  for(int i = 0;i < n;i++){
    cin >> in[i];
  }
  cout << solve(in) << endl;
  return 0;
}


Compiler output:
In file included from /usr/include/c++/14/cassert:44,
                 from a.cc:4:
a.cc: In function 'void dump(std::stack<Number>)':
a.cc:23:16: error: 'class std::stack<Number>' has no member named 'len'
   23 |     assert(tmp.len > 0);
      |                ^~~
Language: C++

using namespace std;

int main() {
	int n;
	int nowlen;
	cin >> n;
	int bufrank = 0;
	int buflen = 0;
	int maxmoji = 1;
	
	for(int i = 0; i < n; i++){
		cin >> nowlen;
		if(nowlen > buflen){
			bufrank = bufrank*pow(maxmoji, nowlen-buflen);
			buflen = nowlen;
		}
		else{
			int shortrank = bufrank / pow(maxmoji, buflen-nowlen);
			if(shortrank == pow(maxmoji, nowlen)){
				maxmoji++;
				bufrank = shortrank+1;
				buflen = nowlen;
			}
			else{
				bufrank++;
				buflen = nowlen;
			}
		}
		//cout << nowlen << endl;
		//cout << bufrank << "," << buflen << endl;
	}
	cout << maxmoji;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:9: error: 'cin' was not declared in this scope
    6 |         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 | using namespace std;
a.cc:14:43: error: 'pow' was not declared in this scope
   14 |                         bufrank = bufrank*pow(maxmoji, nowlen-buflen);
      |                                           ^~~
a.cc:18:51: error: 'pow' was not declared in this scope
   18 |                         int shortrank = bufrank / pow(maxmoji, buflen-nowlen);
      |                                                   ^~~
a.cc:32:9: error: 'cout' was not declared in this scope
   32 |         cout << maxmoji;
      |         ^~~~
a.cc:32:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

#include <bits/stdc++.h>
using namespace std;

int n,m;
int i,j,k;
string str;
int a[200000];

bool test(){
    vector<int> d,dv;
    d.push_back(a[0]);
    dv.push_back(1);
    
    for(i=1;i<n;i++){
        if(a[i] > a[i-1]){
            d.push_back(a[i]);
            dv.push_back(1);
        }
        else if(a[i] == a[i-1]){
            dv[dv.size()-1]++;
        }
        else{
            while(d[d.size()-1] > a[i]){
                j = d[d.size()-1]-1;
                k = (dv[dv.size()-1]-1)/m;
                d.pop_back();
                dv.pop_back();
                if(k > 0){
                    if(j == 0)return false;
                    else if(d.size() > 0 && d[d.size()-1] == j){
                        dv.[dv.size()-1] += k;
                    }
                    else{
                        d.push_back(j);
                        dv.push_back(k);
                    }
                }
                else if(d.size() == 0){
                    break;
                }
            }
            if(d[d.size()-1] == a[i]){
                dv[dv.size()-1]++;
            }
            else{
                d.push_back(a[i]);
                dv.push_back(2);
            }
        }
    }
    while(d.size() > 0){
        j = d[d.size()-1]-1;
        k = (dv[dv.size()-1]-1)/m;
        d.pop_back();
        dv.pop_back();
        if(k > 0){
            if(j == 0)return false;
            else if(d.size() > 0 && d[d.size()-1] == j){
                dv.[dv.size()-1] += k;
            }
            else{
                d.push_back(j);
                dv.push_back(k);
            }
        }
    }
    return true;
}
int main(){
    cin >> n;
    for(i=0;i<n;i++){
        cin >> a[i];
    }
    int s = 0, e = n;
    while(e-s>1){
        m = (e+s+1)/2;
        if(test()){
            e = m;
        }
        else{
            s = m;
        }
    }
    cout << e << endl;
}

Compiler output:
a.cc: In function 'bool test()':
a.cc:31:28: error: expected unqualified-id before '[' token
   31 |                         dv.[dv.size()-1] += k;
      |                            ^
a.cc:59:20: error: expected unqualified-id before '[' token
   59 |                 dv.[dv.size()-1] += k;
      |                    ^
Language: C++

#include <bits/stdc++.h>
typedef long long ll;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,last;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>n;
    rep(i,n)cin>>a[i];
    ans=1;
    ll flags=n;
    rep(i,n-1){
        if(a[i]<a[i+1])continue;
        else{
            if(!fl){
                ans++;
                flags=i;
                break;
            }
        }
    }
    if(a[flags]==a[flags+1])cnt=1;
    ll lim=2;
    rrep(i,flags+1,n){
        if(a[i]<a[i+1])continue;
        if(a[i]==a[i+1])cnt++;
        if(cnt==pow(lim,a[i])&&a[i]!=1){
            cnt=0;
            ans++;
            lim++;
        }
        if(a[i]==1)ans++,kim++,b=1;
    }
    if(b==1)ans--;
    Cout(ans);
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:54:26: error: 'kim' was not declared in this scope; did you mean 'lim'?
   54 |         if(a[i]==1)ans++,kim++,b=1;
      |                          ^~~
      |                          lim
Language: C++

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int s[100];
int main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n){
        cin>>a[i];
      assert(a[i]<100)
    }
    bool d=true;
    rep(i,n-1){
        if(a[i]>=a[i+1])d=false;
    }
    if(d){
        cout<<1<<endl;
        return 0;
    }
    rep(i,n)a[i]=min(a[i],100);
    rep(i,a[0])s[i]=1;
    int ans=1;
    rep(i,n-1){
            REP(j,a[i+1],100)s[j]=0;
            int ok=false;
            for(int j=a[i+1]-1;j>=0;--j){
                if(s[j]<ans){
                    ++s[j];
                    REP(k,j+1,a[i+1])s[k]=1;
                    ok=true;
                    break;
                }
            }
            if(!ok){
                ++ans;
                s[a[i+1]-1]=ans;
            }
    }
    cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:5: error: expected ';' before '}' token
   35 |     }
      |     ^
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<cmath>
using namespace std;
int n,tmp[1<<18],A[1<<18],MA[1<<18];
map<int,int>M;
int cnt[1<<18];
bool check(int k)
{
	stack<int>S,P;
	S.push(0);
	P.push(0);
	for(int i=0;i<=n;i++)
	{
		while(!S.empty()&&S.top()>A[i])
		{
			int p=S.top();S.pop();
			int Mp=P.top();P.pop();
			int next,Mnext;
			if(S.top()<A[i])
			{
				next=A[i];
				Mnext=MA[i];
			}
			else
			{
				next=S.top();
				Mnext=P.top();
			}
			int d=p-next;
			long long take=1;
			if(log(cnt[Mp])<=d*log(k))take=cnt[Mp];
			else
			{
				for(int j=0;j<d;j++)
				{
					take*=k;
				}
			}
			if(cnt[Mp]>take)cnt[Mp]-=take;
			else cnt[Mp]=0;
			cnt[Mnext]+=(cnt[Mp]+take-1)/take+(S.top()<A[i]);
			cnt[Mp]=0;
		}
		if(S.top()<A[i])S.push(A[i]),P.push(MA[i]);;
		cnt[MA[i]]++;
	}
	return cnt[0]==1;
}
main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>tmp[i];
		A[i]=tmp[i];
	}
	sort(tmp,tmp+n);
	int sz=0;
	for(int i=0;i<n;i++)
	{
		if(M[tmp[i]]==0)
		{
			M[tmp[i]]=++sz;
		}
	}
	A[n]=0;
	M[0]=0;
	for(int i=0;i<=n;i++)MA[i]=M[A[i]];
	int L=0,R=2e5;
	for(int cnt=0;cnt<100;cnt++)
	{
		int M=(L+R)/2;
		if(check(M))R=M;
		else L=M;
		cnt[0]=0;
	}
	cout<<R<<endl;
}

Compiler output:
a.cc:53:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   53 | main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:79:20: error: invalid types 'int[int]' for array subscript
   79 |                 cnt[0]=0;
      |                    ^
Language: C++

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int s[100];
int main(){
    int n;
    cin>>n;
    vector<pint> v;
    int a[n];
    rep(i,n){
        cin>>a[i];
        assert(a[i]<=100);
    }
    bool d=true;
    rep(i,n-1){
        if(a[i]>=a[i+1])d=false;
    }
    if(d){
        cout<<1<<endl;
        return 0;
    }
    rep(i,n)a[i]=min(a[i],100);
    rep(i,a[0])s[i]=1;
    int ans=1;
    rep(i,n-1){
        if(a[i+1]>a[i]){
            REP(j,a[i],a[i+1])s[j]=1;
        }
        if(a[i]>=a[i+1]){
            REP(j,a[i+1],100)s[j]=0;
            int ok=false;
            for(int j=a[i+1]-1;j>=0;--j){
                if(s[j]<ans){
                    ++s[j];
                    ok=true;
                    break;
                }
            }
            if(!ok){
                ++ans;
                s[a[i+1]-1]=ans;
            }
        }
    }


    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:9: error: 'assert' was not declared in this scope
   34 |         assert(a[i]<=100);
      |         ^~~~~~
a.cc:15:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
   14 | #include<functional>
  +++ |+#include <cassert>
   15 | using namespace std;
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
 
int main(void) {
	int n; cin >> n;
	long long int a[n]; long long int e;
	long long int ans = 0, sum = 0, ch = 0;
	int i;
	for (i = 0; i < n; i++) { cin >> a[i]; }
 
	int *b = max_element(a, a + n);
	long long int c = *(max_element(a, a + n));
	long long int d = *(max_element(a, a + n));
 
	for (i = *b; i < n - 1; i++) {
		if (c > a[i + 1]) {
			sum += 1;
			c = a[i + 1];
			ch = 0;
		}
		else if (c == a[i + 1]) { ch += 1; if (ch == 1) { ans += 1; } else if (ch == c * c) { ans += 1; } }
		else { ans += (sum + 1) / 2; sum = 0; c = a[i + 1]; }
		ch = 0;
	}
	ans += (sum + 1) / 2;
	sum = 0;
 
	if (b == 0) { cout << ans << endl; }
	else { e = a[d] - a[d - 1]; }
 
	for (i = *b; i > 0; i--) {
		if ((e)*(d - a[i - 1]) >= 0) {
			e = d - a[i - 1];
			ch = 0;
			continue;
		}
		if (d == a[i - 1]) {
			ch += 1;
			if (ch == 1) { ans += 1; }
			else if (ch == c * c) { ans += 1; }
		}
		else { ans += 1; ch = 0; }
	}
 
	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:29: error: cannot convert 'long long int*' to 'int*' in initialization
   12 |         int *b = max_element(a, a + n);
      |                  ~~~~~~~~~~~^~~~~~~~~~
      |                             |
      |                             long long int*