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

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

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗する

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) の絶対値

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//配列の受け取り

main(){
  int n=in(),a[n],num,ans=0;
  forin(a,n);
  for (int i=0;i<n-1;i++){
    for (int i2=i+1;i<n;i2++){
      if (a[i2]==0) continue;
      else if (i%2==i2%2){
        num=a[i]+a[i2];
        while(num%2=0){
          num/=2;
          if (num==1) {
            ans++;
            a[i2]=0;
          }
        }
      }
    }
  }
  cout << ans << endl;
}

Compiler output:
a.cc:26:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   26 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:34:18: error: lvalue required as left operand of assignment
   34 |         while(num%2=0){
      |               ~~~^~
Language: C++

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

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗する

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) の絶対値

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//配列の受け取り

main(){
  int n=in(),a[n],num,ans=0;
  forin(a,n);
  for (int i=0;i<n-1;i++){
    for (int i2=i+1;i<n;i2++){
      if (a[i2]==0) continue;
      else if (i%2==i2%2){
        num=a[i]+a[i2]
        while(num%2=0){
          num/=2;
          if (num==1) {
            ans++;
            a[i2]=0;
          }
        }
      }
    }
  }
  cout << ans << endl;
}


Compiler output:
a.cc:26:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   26 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:33:23: error: expected ';' before 'while'
   33 |         num=a[i]+a[i2]
      |                       ^
      |                       ;
   34 |         while(num%2=0){
      |         ~~~~~
Language: C++

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int N;
    ll Ai;
    vector<ll> A;
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> Ai;
        A.push_back(Ai);
    }
    sort(A.begin(), A.end(), greater<ll>());
    vector<bool> used(A.size(), false);
    int n=0;
    for(int i=0;i<N;i++){
        if(used[i]) continue;
        for(int j=i+1;j<N;j++){
            auto s = A.at(i) + A.at(j);
            if(!(s&(s-1))){
                n++;
                used[i]=true;
                used[j]=true;
                break;
            }
        }
    }
    cout<<n<<endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   19 |     sort(A.begin(), A.end(), greater<ll>());
      |     ^~~~
      |     short
Language: C++

#include <iostream>
#include <map>
#include <cmath>
using namespace std;

const int maxn = 2e5 + 7;
typedef long long ll;
ll a[maxn], mi[50];
int n;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    map<ll, int> mp;
    for (int i = 0; i < n; i++) {
        mp[a[i]] = 1;
    }
    for (int i = 0; i <= 40; i++) {
        mi[i] = pow(2l, i);
    }
    int ans = 0;
    sort(a, a+n);
    for (int i = n-1; i >= 0; i--) {
        if (mp[a[i]] != 1) continue;
        else {
            for (int j = 0; j <= 40; j++) {
                ll m = mi[j];
                ll tmp = m - a[i];
                if (mp[tmp] != 0) {
                    mp[tmp] = 0;
                    ans++;
                    break;
                }
            }
        }
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:5: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   23 |     sort(a, a+n);
      |     ^~~~
      |     sqrt
Language: C++

// In the name of Allah. Ya ali!
#include<bits/stdc++.h>
#define double long double
typedef long long ll;
const ll MAX_N = 2e5+100;
const ll MOD = 1e9+7;
using namespace std;

int a[MAX_N];
multiset<int> d[50];

int main()
{
    int n;
    cin >> n;
    for(int i = 0;i<n;++i)
        cin >> a[i];
    for(int i = 0;i<n;++i)
        d[log2(a[i]&-a[i])].insert(a[i]/(a[i]&(-a[i])));
    ll ans = 0;
    for(int i = 0;i<50;++i)
    {
        multiset<int> st = d[i];
        for(auto it = st.rbegin();it!=st.rend();++it)
        {
            if (!d[i].count(*it))
                continue;
            ll x = (1ll<<((int)ceil(log2(*it))))-1;
            x^=*it;
            x++;
            if (d[i].count(x))
            {
                d[i].erase(d[i].find(*it));
                d[i].erase(d[i].find(x));
                ans++;
            }
        }
    }
    cout << ans;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:10: error: invalid types 'std::multiset<int> [50][__gnu_cxx::__enable_if<true, double>::__type {aka double}]' for array subscript
   19 |         d[log2(a[i]&-a[i])].insert(a[i]/(a[i]&(-a[i])));
      |          ^
Language: C++

#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int N, A[200000];
vector<int> G[200000];
int match[200000];
bool used[200000];

bool dfs(int v) {
    used[v] = true;
    for (int u : G[v]) {
        int w = match[u];
        if (w < 0 || (!used[w] && dfs(w))) {
            match[v] = u;
            match[u] = v;
            return true;
        }
    }
    return false;
}

int bipartite_matching() {
    int ret = 0;
    memset(match, -1, sizeof(match));
    REP(v, N) {
        if (match[v] < 0) {
            memset(used, 0, sizeof(used));
            if (dfs(v)) ret++;
        }
    }
    return ret;
}

int main() {
    cin >> N;
    REP(i, N) cin >> A[i];
    sort(A, A + N);

    REP(i, N) {
        ll p = 2;
        while (true) {
            if (p > 2e9) break;

            int rest = p - A[i];
            p <<= 1;
            if (rest < 1) continue;

            auto lb = lower_bound(A, A + N, rest);
            auto ub = upper_bound(A, A + N, rest);
            for (auto it = lb; it != ub; it++) {
                if (it - A == i) continue;
                G[i].push_back(it - A);
            }
        }
    }

    cout << bipartite_matching() << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int bipartite_matching()':
a.cc:38:5: error: 'memset' was not declared in this scope
   38 |     memset(match, -1, sizeof(match));
      |     ^~~~~~
a.cc:7:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    6 | #include <map>
  +++ |+#include <cstring>
    7 |
Language: C++

#include<bits/stdc++.h>
#include<bits/extc++.h>
#define fi first
#define sf scanf
#define se second
#define pf printf
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mem(x,y) memset((x),(y),sizeof(x))
#define fup(i,x,y) for(int i=(x);i<=(y);++i)
#define fdn(i,x,y) for(int i=(x);i>=(y);--i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef std::pair<int,int> pii;
using namespace std;

const int __=2e5+5;

int a[__];
gp_hash_table<int,int>vis;

int main()
{
//    pf("%lld\n%d\n0",1ll<<31,(int)(1e9));
    int n;sf("%d",&n);
    fup(i,1,n)
    {
        sf("%d",&a[i]);
        ++vis[a[i]];
    }
    sort(a+1,a+1+n);
    int ans=0;
    fdn(i,n,1)
        if(vis[a[i]])
        {
            --vis[a[i]];
            for(ll j=(1ll<<31);j;j>>=1)
                if(vis[j-a[i]])
                    ++ans,--vis[j-a[i]];
        }
    pf("%d\n",ans);
    return 0;
}


Compiler output:
a.cc:23:1: error: 'gp_hash_table' does not name a type
   23 | gp_hash_table<int,int>vis;
      | ^~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:32:11: error: 'vis' was not declared in this scope
   32 |         ++vis[a[i]];
      |           ^~~
a.cc:37:12: error: 'vis' was not declared in this scope
   37 |         if(vis[a[i]])
      |            ^~~
Language: C++

// B. 

#include <sstream>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

vector<int> G[400000];
int match[400000];
bool used[400000];

void add_edge(int u, int v) {
	G[u].push_back(v);
	G[v].push_back(u);
}

bool dfs(int v) {
	used[v] = true;
	int i;
	for (i = 0; i < (int)G[v].size(); ++i) {
		int u = G[v][i];
		int w = match[u];
		if (w < 0 || !used[w] && dfs(w)) {
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}

int main(int argc, char *argv[])
{
/*
	map<int, int> m;
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		m[a] += 1;
	}
	int ans = 0;
	for (int i = 1; i <= 30; ++i) {
		int b = 1 << i;
		for (auto kv : m) {
			if (kv.first == b - kv.first) {
				int cnt = kv.second / 2;
				ans += cnt;
				kv.second -= cnt * 2;
			} else {
				int r = b - kv.first;
				if (r < kv.first) {
					break;
				}
				if (r > 0 && m.find(r) != m.end()) {
					int cnt = min(kv.second, m[r]);
					ans += cnt;
					kv.second -= cnt;
					m[r] -= cnt;
				}
			}
		}
	}
*/
	map<int, vector<int>> m;
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		m[a[i]].push_back(a[i]);
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 1; j <= 30; ++j) {
			int b = (1 << j) - a[i];
			if (b > 0 && m.find(b) != m.end()) {
				for (int x : m[b]) {
					if (x != i) {
						add_edge(i, n + x);
					}
				}
			}
		}
	}
	memset(match, -1, sizeof(match));
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		if (match[i] < 0) {
			memset(used, 0, sizeof(used));
			cnt += dfs(i);
		}
	}
	int ans = cnt / 2;
	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:89:9: error: 'memset' was not declared in this scope
   89 |         memset(match, -1, sizeof(match));
      |         ^~~~~~
a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    7 | #include <map>
  +++ |+#include <cstring>
    8 |
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; i++)

define int long long

int beki(int x)
{
	int s=0, tmp=1;
	while(tmp<=x)
	{
		s++;
		tmp*=2;
	}
	return tmp;
}

signed main()
{
	int n;
	int a[200010];
	cin >> n;
	rep(i, n) cin >> a[i];
	sort(a, a+n);
	map<int, int> T;
	rep(i, n) T[a[i]]++;
	int ans=0;
	rep(j, n)
	{
		int i=n-1-j;
		T[a[i]]--;
		int tmp=beki(a[i])-a[i];
		if(T[tmp]>0)
		{
			ans++;
			T[tmp]--;
		}
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc:7:1: error: 'define' does not name a type
    7 | define int long long
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:34:25: error: 'beki' was not declared in this scope
   34 |                 int tmp=beki(a[i])-a[i];
      |                         ^~~~
Language: Java

package tasks;

import personalUtil.FasterScanner;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.stream.Collectors;

public class TaskB {
    public void solve(int testNumber, FasterScanner in, PrintWriter out) {
        int n = in.nextInt();
        ArrayList<Integer> a = new ArrayList<>();
        for(int i = 0; i < n; i++){
            a.add(in.nextInt());
        }

        a.sort(Comparator.reverseOrder());

        int com = Integer.MAX_VALUE;

        int ans = 0;
        for(int i = 0; i < a.size(); i++){
            int cn = a.get(i);
            while(cn < (com >> 1)){
                com = com >> 1;
            }
            int target = 1 + (com ^ cn);
            // System.out.println(cn + " " + target + " " + com);
            if(a.contains(target)){
                ans++;
                a.remove(Integer.valueOf(target));
            }
        }

        out.println(ans);
    }
}


Compiler output:
Main.java:10: error: class TaskB is public, should be declared in a file named TaskB.java
public class TaskB {
       ^
Main.java:3: error: package personalUtil does not exist
import personalUtil.FasterScanner;
                   ^
Main.java:11: error: cannot find symbol
    public void solve(int testNumber, FasterScanner in, PrintWriter out) {
                                      ^
  symbol:   class FasterScanner
  location: class TaskB
3 errors
Language: Java

import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        boolean b[] = new boolean[n];

        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
            b[i] = true;
        }

        int count=0;

        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                if(i == j){
                    break;
                }else{
                    int num = a[i] + a[j];
                    if((num & (num-1) == 0) && b[i] && b[j]){
                        count++;
                        b[i] = false;
                        b[j] = false;
                    }

                }
            }
        }

        System.out.println(count);

 
    }



}

Compiler output:
Main.java:23: error: bad operand types for binary operator '&'
                    if((num & (num-1) == 0) && b[i] && b[j]){
                            ^
  first type:  int
  second type: boolean
1 error
Language: Java

import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        boolean b[] = new boolean[n];

        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
            b[i] = true;
        }

        int count=0;

        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                if(i == j){
                    break;
                }else{
                    int num = a[i] + a[j];
                    if(!(num & (num-1)) && b[i] && b[j]){
                        count++;
                        b[i] = false;
                        b[j] = false;
                    }

                }
            }
        }

        System.out.println(count);

 
    }



}


Compiler output:
Main.java:23: error: bad operand type int for unary operator '!'
                    if(!(num & (num-1)) && b[i] && b[j]){
                       ^
1 error
Language: C++

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

unordered_map<ll,ll>mp;
ll tp[55];

void tow()
{
    tp[0]=1;
    for(ll i=1;i<=35;i++)tp[i]=tp[i-1]*2;
}

int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(null);
     cout.tie(null);
    ll n;
    tow();
    cin>>n;
    vector<ll>vc;
    for(int i=0;i<n;i++)
    {
        ll m;cin>>m;vc.pb(m);
        mp[m]++;
    }
    sort(vc.begin(),vc.end());
  ll cnt=0;
    for(int i=n-1;i>=0;i--)
    {
          if(mp[vc[i]]>0)
          {
              mp[vc[i]]--;
              for(int j=0;j<=35;j++)
              {
                  ll k= vc[i]-tp[j];
                  if(mp[k]>0)
                  {
                      cnt++;
                      mp[k]--;
                      break;
                  }
              }
          }
         // cout<<cnt<<"\n";

    }
    cout<<cnt<<"\n";
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:14: error: 'null' was not declared in this scope
   18 |      cin.tie(null);
      |              ^~~~
Language: C

#include <stdio.h>
#include <math.h>
int main(void){
	int n,a[n],i,j,count=0;
  	scanf("%d", &n);
  	for(i=0;i<n;i++){
      	scanf("%d", &a[i]);
    }
  		
  	for(i=0;i<n-1;i++){
      	for(j=i+1;j<n;j++){
          	for(int k=0;k<30){
				if(a[i]+a[j]==pow(2,k)){
                  	count++;
                }
            }
        }
    }
  	printf("%d", count);
}

Compiler output:
main.c: In function 'main':
main.c:12:33: error: expected ';' before ')' token
   12 |                 for(int k=0;k<30){
      |                                 ^
      |                                 ;
Language: C

#include <stdio.h>
#include <math.h>
int main(void){
  int N;
  int hoge[];
  int i,j,n,k;
  int pow;
  k = hoge[i] * hoge[j];
  pow = pow(k,1.0/2.0);
  
  scanf("%d",N);
  
  for (i = 0; i < N; i++){
    scanf("%d",hoge[i]);
  }
  
  for (i = 0; i < N; i++){
    for (j = 1; j < N; j++){
      if(k == pow){
        n++;
      }
    }
  }
      
    printf("%d¥n",n);  
  	return (0);
}      

Compiler output:
main.c: In function 'main':
main.c:5:7: error: array size missing in 'hoge'
    5 |   int hoge[];
      |       ^~~~
main.c:9:9: error: called object 'pow' is not a function or function pointer
    9 |   pow = pow(k,1.0/2.0);
      |         ^~~
main.c:7:7: note: declared here
    7 |   int pow;
      |       ^~~
Language: C

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int main() {
  int n = in();
  vector<Int> A(n);
  map<Int, int> M;
  for (int i = 0; i < n; ++i) {
    A[i] = lin();
    M[A[i]]++;
  }

  const auto del = [&] (const Int v) {
    --M[v];
    if (M[v] == 0) {
      M.erase(v);
    }
  };

  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  int res = 0;
  for (int i = 0; i < A[i]; ++i) {
    if (M.count(A[i]) == 0) continue;
    del(A[i]);
    Int target = 1;
    while (target <= A[i]) target *= 2;
    if (M.count(target - A[i]) > 0) {
      ++res;
      del(target - A[i]);
    }
  }

  printf("%d\n", res);

  return 0;
}


Compiler output:
main.c:1:10: fatal error: cstdio: No such file or directory
    1 | #include <cstdio>
      |          ^~~~~~~~
compilation terminated.
Language: C++


#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5+5;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    2019;
ll n;ll lo=1;ll hi=2e5;
ll arr[N];
bool fn(ll x)
{
	ll t;
	map<ll,ll> mp;
	if(x==1)
	{
		for(int i=2;i<=n;i++)
		if(arr[i]<=arr[i-1]) return 0;
		return 1;
	}
	for(int i=2;i<=n;i++)
	if(arr[i]<=arr[i-1])
	{
		t=arr[i];
		mp.erase(mp.upper_bound(t),mp.end());

  while(t>0&&mp[t]==x-1)
		{
			mp.erase(t);
			t--;
		}
		if(!t)
		return 0;
		else
		mp[t]++;
	}
	return 1;
}
int main()
{  fast
cin>>n;
//int ans=1;
for(int i=1;i<=n;i++)cin>>arr[i];
while(lo<=hi)
{
	ll mid=(lo+hi)/2;
//	cout<<mid<<endl;
	if(fn(mid))
	ans=mid,hi=mid;
	else
	lo=mid+1;
}
cout<<hi<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:54:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   54 |         ans=mid,hi=mid;
      |         ^~~
      |         abs
Language: C++

#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
 
using namespace std;
 
typedef long long ll;
 
bool Check(vector<int> a, int m) {
  int n = a.size();
  vector<pair<int, int>> rle;
 
  for (int i = 0; i < n; ++i) {
    int diff = a[i] - (i > 0 ? a[i - 1] : 0);
    if (diff > 0) {
      rle.push_back({0, diff});
      continue;
    }
 
    while (diff < 0) {
      int take = min(-diff, rle.back().second);
      diff += take;
      rle.back().second -= take;
      if (rle.back().second == 0) {
        rle.pop_back();
      }
    }
 
    int numDigits = 0;

    while (!rle.empty() && rle.back().first == m - 1) {
      numDigits += rle.back().second;
      rle.pop_back();
    }
    if (rle.empty()) return false;
 
    int curValue = rle.back().first;
    int curLen = rle.back().second;
    rle.pop_back();

    if (curLen > 1) {
      rle.push_back({curValue, curLen - 1});
    }
    rle.push_back({curValue + 1, 1});
 
    if (numDigits > 0) {
      rle.push_back({0, numDigits});
    }
 
  }
  return true;
}
 
int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
 
  int l = 1; int r = n;
  while (r - l > 1) {
    int m = (l + r) / 2;
    if (Check(a, m)) {
      r = m;
    } else {
      l = m;
    }
  }
  int result = r;
  if (Check(l)) result = l;
  cout << result << endl;
 
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:77:13: error: could not convert 'l' from 'int' to 'std::vector<int>'
   77 |   if (Check(l)) result = l;
      |             ^
      |             |
      |             int
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const int MAX_LG = 105
const int MAX_N = 2e5 + 5;

int arr [MAX_N];
int n;
int can (int k) {
  if (k == 0) return false;
  
  vector<int> cur (arr[0], 0);
  for (int i = 1; i < n; i++) {
    if (arr[i] > arr[i - 1]) {
      while ((int) cur.size() < arr[i]) {
        cur.push_back(0);
      }
    } else {
      while ((int) cur.size() > arr[i]) {
        cur.pop_back();
      }

      int t = (int) cur.size() - 1;
      while (true) {
        if (t < 0) return false;
        cur[t]++;
        if (cur[t] == k) {
          cur[t] = 0;
          t--;
        } else {
          break;
        }
      }
    }
  }
  return true;
}

int main () {
  ios::sync_with_stdio(false);

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }

  int flag = 1;
  for (int i = 1; i < n; i++) {
    if (arr[i] <= arr[i - 1]) {
      flag = 0;
    }
  }

  if (flag) {
    cout << 1 << endl;
    return 0;
  }

  for (int i = 0; i < n; i++) {
    arr[i] = min(arr[i], MAX_LG);
  }

  int ans = 0;
  for (int k = 1 << 20; k != 0; k /= 2) {
    if (!can(ans + k)) {
      ans += k;
    }
  }

  cout << ans + 1 << endl;
}


Compiler output:
a.cc:8:1: error: expected ',' or ';' before 'const'
    8 | const int MAX_N = 2e5 + 5;
      | ^~~~~
a.cc:10:10: error: 'MAX_N' was not declared in this scope; did you mean 'MAX_LG'?
   10 | int arr [MAX_N];
      |          ^~~~~
      |          MAX_LG
a.cc: In function 'int can(int)':
a.cc:15:20: error: 'arr' was not declared in this scope
   15 |   vector<int> cur (arr[0], 0);
      |                    ^~~
a.cc: In function 'int main()':
a.cc:48:12: error: 'arr' was not declared in this scope
   48 |     cin >> arr[i];
      |            ^~~
a.cc:53:9: error: 'arr' was not declared in this scope
   53 |     if (arr[i] <= arr[i - 1]) {
      |         ^~~
a.cc:64:5: error: 'arr' was not declared in this scope
   64 |     arr[i] = min(arr[i], MAX_LG);
      |     ^~~
Language: C++

 #pragma GCC optimize("O3")
 #pragma GCC optimize("unroll-loops")
 #pragma GCC optimize("fast-math")
#include<bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

// #define int long long
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

void accell() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}
const int N = 1e6;

int mp[N];

bool check(int sz, vector<int>&a) {
    set<int>st;
    for (int i = 1; i < a.size(); ++i) {
        int c = a[i];
        if (c >= 1e6)
            continue;
        if (a[i - 1] >= a[i]) {
            while (c >= 1 && mp[c] + 1 == sz) {
                mp[c] = 0;
                st.insert(c);
                --c;
            }
            if (c == 0)
                return false;
            mp[c]++;
            st.insert(c);
        } else {
            auto it = st.upper_bound(c);
            vector<int>musor;
            while (it != st.end()) {
                ++it;
                musor.push_back(*it);
            }
            for (auto x : musor) {
                mp[x] = 0;
                st.erase(x);
            }
        }
    }
    for (auto &it : mp)
        it.second = 0;
    st.clear();
    return true;
}


signed main() {
    accell();
    int n;
    cin >> n;
    vector<int>a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int l = 0;
    int r = (1 << 30);
    while (r - l > 1) {
        int m = l + r >> 1;
        if (!check(m, a))
            l = m;
        else
            r = m;
    }
    cout << r << endl;
    return 0;
}


Compiler output:
a.cc: In function 'bool check(int, std::vector<int>&)':
a.cc:57:12: error: request for member 'second' in 'it', which is of non-class type 'int'
   57 |         it.second = 0;
      |            ^~~~~~
Language: C++

#include<bits/stdc++.h>

using namespace std;

map <long long, long long> t, add;

long long a[End + 50005];
long long n;

long long End = 1000000005;

void push (long long i, long long l, long long r) {
    if (add[i] == -1) {
        return;
    }

    t[i] = add[i] * (r - l);

    if (l + 1 != r) {
        add[i * 2 + 1] = add[i];
        add[i * 2 + 2] = add[i];
    }
    add[i] = -1;
}

long long get(long long i, long long l, long long r, long long ql, long long qr) {

    push(i, l, r);

    if (r <= ql || qr <= l) {
        return 0;
    }


    if (ql <= l && r <= qr) {

        return t[i];
    }

    long long m = (l + r) / 2;

    return get(i * 2 + 1, l, m, ql, qr) + get(i * 2 + 2, m, r, ql, qr);
}

void update(long long i, long long l, long long r, long long ql, long long qr, long long qx) {

    push(i, l, r);

    if (r <= ql || qr <= l) {
        return;
    }
    if (ql <= l && r <= qr) {
        add[i] = qx;
        push(i, l, r);
        return;
    }

//    push(i, l, r);

    long long m = (l + r) / 2;

    update(i * 2 + 1, l, m, ql, qr, qx);
    update(i * 2 + 2, m, r, ql, qr, qx);

    t[i] = t[i * 2 + 1] + t[i * 2 + 2];
}

//void build(long long i, long long l, long long r) {
//    if (l + 1 == r) {
//        t[i] = a[l];
//        return;
//    }
//
//    long long m = (l + r) / 2;
//    t[i] = t[i * 2 + 1] + t[i * 2 + 2];
//}

bool check (long long x) {
    long long h = a[0] - 1;

    if (x == 1) {
        return false;
    }

    for (long long i = 1; i < n; ++i) {
        update(0, 0, End + 5, a[i], End + 5, 0);
        h = min(h, a[i] - 1);
        if (a[i - 1] < a[i]) {
            h = a[i] - 1;
        }
        long long z = get(0, 0, End + 5, h, h + 1);
        if (z + 1 == x) {
            if (!h) {
                return false;
            } else {
//                while (get(0, 0, End + 5, h, h + 1))
                update(0, 0, End + 5, h - 1, h, 1);
                --h;
            }
        } else {
            update(0, 0, End + 5, h, h + 1, z + 1);
        }
    }

    return true;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    cin >> n;


    cin >> a[0];

    bool fl = true;
    for (long long i = 1; i < n; ++i) {
        cin >> a[i];
        if (a[i - 1] >= a[i]) {
            fl = false;
        }
    }

    if (fl) {
        cout << 1 << '\n';
        return 0;
    }

    long long l = 0, r = n + 5;

    while (r - l > 1) {
        long long m = l + ((r - l) >> 1);

        t.clear();
        add.clear();
        if (check(m)) {
            r = m;
        } else {
            l = m;
        }
    }

    cout << r << '\n';


    return 0;
}

//10
//1 9 12 1 8 7 5 1 6 1


Compiler output:
a.cc:7:13: error: 'End' was not declared in this scope
    7 | long long a[End + 50005];
      |             ^~~
a.cc: In function 'bool check(long long int)':
a.cc:79:19: error: 'a' was not declared in this scope
   79 |     long long h = a[0] - 1;
      |                   ^
a.cc: In function 'int main()':
a.cc:116:12: error: 'a' was not declared in this scope
  116 |     cin >> a[0];
      |            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, a[200008];

bool f(ll x){
	map<ll, ll> dp;
	zep(i, 1, n){
		if(a[i] <= a[i-1]){
			if(mid == 1){
				return false;
			}
			if(a[i] < a[i-1]){
				vector<ll> er;
				for(auto it = dp.upper_bound(a[i]); it != dp.end(); it++){
					er.push_back((*it).first);
				}
				zep(j, 0, er.size()){
					dp.erase(er[j]);
				}
			}
			
			ll at = a[i];
			if(dp.find(at) != dp.end()){(*dp.find(at)).second++;}
			else{dp[at] = 1;}
			
			while(dp.find(at) != dp.end() && dp[at] == x){
				dp.erase(at);
				at--;
				if(dp.find(at) == dp.end()){
					dp[at] = 1;
				}
				else{
					dp[at]++;
				}
				if(at < 1){return false;}
			}
		}
	}
	return true;
}

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n;
	zep(i, 0, n){cin >> a[i];}
	
	ll ok = n;
	ll ng = 0;
	while(ok-ng > 1){
		ll mid = (ok+ng)/2;
		if(f(mid)){ok = mid;}
		else{ng = mid;}
	}
	print(ok)
	return 0;
}


Compiler output:
a.cc: In function 'bool f(ll)':
a.cc:19:28: error: 'mid' was not declared in this scope
   19 |                         if(mid == 1){
      |                            ^~~
Language: C++

#include <cstdio>
#include <iostream>
#include <set>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define fi first
#define se second
using namespace std;
inline char nc()
{
    return getchar();
    static char buf[100000],*l=buf,*r=buf;
    return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
template<class T> void read(T &x)
{
    x=0; int f=1,ch=nc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=nc();}
    while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=nc();}
    x*=f;
}
typedef pair<int,int> pii;
const int maxn=2e5+50;
int n,a[maxn];
set<pii> s;
bool upd(int x,int c)
{
    set<pii>::iterator it=s.lower_bound(make_pair(x,0));
    int y=0; if(it!=s.end()&&it->fi==x) y=it->se,s.erase(it);
    if(++y==c) return x==1?0:upd(x-1,c);
    s.insert(make_pair(x,y));
    return 1;
}
bool check(int c)
{
    s.clear();
    for(int i=2;i<=n;++i)
    {
        // debug("%d %d\n",c,i);
        if(a[i]<=a[i-1])
        {
            while(s.size()&&s.rbegin()->fi>a[i])
            {
                set<pii>::it=s.end(); --it; s.erase(it);
            }
            if(!upd(a[i],c)) return 0;
        }
    }
    return 1;
}
int main()
{
    read(n);
    for(int i=1;i<=n;++i) read(a[i]);
    int l=1,r=n,an=-1;
    while(l<=r)
    {
        int mid=(l+r)>>1;
        if(check(mid)) r=mid-1,an=mid;
        else l=mid+1;
    }
    printf("%d\n",an);
    return 0;
}

Compiler output:
a.cc: In function 'bool check(int)':
a.cc:43:27: error: 'it' is not a member of 'std::set<std::pair<int, int> >'
   43 |                 set<pii>::it=s.end(); --it; s.erase(it);
      |                           ^~
a.cc:43:41: error: 'it' was not declared in this scope; did you mean 'i'?
   43 |                 set<pii>::it=s.end(); --it; s.erase(it);
      |                                         ^~
      |                                         i
Language: C++

#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<algorithm>
#include<ctime>
#include<map>
using namespace std;
inline int read()
{
	int kkk=0,x=1;
	char c=getchar();
	while((c<'0' || c>'9') && c!='-')
		c=getchar();
	if(c=='-')
		c=getchar(),x=-1;
	while(c>='0' && c<='9')
		kkk=(kkk<<3)+(kkk<<1)+(c-'0'),c=getchar();
	return kkk*x;
}
int n,len[200001],ans,F;
map<int,int> Q;
inline int check(int lim)
{
	Q.clear();
	for(register int i=2;i<=n;++i)
		if(len[i]<=len[i-1])
		{
			while(!Q.empty())
			{
				int zone=Q.rbegin()->first;
				if(zone>len[i])
					Q.erase(zone);
				else
					break;
			}
			int mem=len[i];
			while(Q[mem]+1==lim)
			{
				Q.erase(mem);
				--mem;
			}
			if(!mem)
				return 0;
			Q[mem]+=1;
		}
	return 1;
}
int main()
{
	n=read();
	for(register int i=1;i<=n;++i)
	{
		len[i]=read();
		if(len[i]<=len[i-1])
			F=1;
	}
	if(!F)
	{
		puts("1");
		return 0;
	}
	l=2,r=n;
	while(l<=r)
	{
		int mid=(l+r)/2;
		if(check(mid))
			ans=mid,r=mid-1;
		else
			l=mid+1;
	}
	printf("%d\n",ans);
	return 0;
}

Compiler output:
a.cc: In function 'int check(int)':
a.cc:28:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   28 |         for(register int i=2;i<=n;++i)
      |                          ^
a.cc: In function 'int main()':
a.cc:54:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   54 |         for(register int i=1;i<=n;++i)
      |                          ^
a.cc:65:9: error: 'l' was not declared in this scope
   65 |         l=2,r=n;
      |         ^
a.cc:65:13: error: 'r' was not declared in this scope
   65 |         l=2,r=n;
      |             ^
Language: C++

#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<algorithm>
#include<ctime>
#include<map>
using namespace std;
inline int read()
{
	int kkk=0,x=1;
	char c=getchar();
	while((c<'0' || c>'9') && c!='-')
		c=getchar();
	if(c=='-')
		c=getchar(),x=-1;
	while(c>='0' && c<='9')
		kkk=(kkk<<3)+(kkk<<1)+(c-'0'),c=getchar();
	return kkk*x;
}
int n,len[200001],maxn,l=2,r,ans,F;
map<int,int> Q;
inline int check(int lim)
{
	Q.clear();
	for(register int i=2;i<=n;++i)
		if(len[i]<=len[i-1])
		{
			while(!Q.empty())
			{
				int zone=Q.rbegin()->first;
				if(zone>len[i])
					Q.erase(zone);
				else
					break;
			}
			int mem=len[i];
			while(Q[mem]+1==lim)
			{
				Q.erase(mem);
				--mem;
			}
			if(!mem)
				return 0;
			Q[mem]+=1;
		}
	return 1;
}
int main()
{
	n=read();
	for(register int i=1;i<=n;++i)
	{
		len[i]=read();
		r=max(r,len[i]);
		if(a[i]<=a[i-1])
			F=1;
	}
	if(!F)
	{
		puts("1");
		return 0;
	}
	while(l<=r)
	{
		int mid=(l+r)/2;
		if(check(mid))
			ans=mid,r=mid-1;
		else
			l=mid+1;
	}
	printf("%d\n",ans);
	return 0;
}

Compiler output:
a.cc: In function 'int check(int)':
a.cc:28:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   28 |         for(register int i=2;i<=n;++i)
      |                          ^
a.cc: In function 'int main()':
a.cc:54:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   54 |         for(register int i=1;i<=n;++i)
      |                          ^
a.cc:58:20: error: 'a' was not declared in this scope
   58 |                 if(a[i]<=a[i-1])
      |                    ^
Language: C++

#include<cstdio>
#include<bits/stdc++.h>
 
#define fec(i, x, y) (int i = head[x], y = g[i].to; i; i = g[i].ne, y = g[i].to)
#define dbg(...) fprintf(stderr, __VA_ARGS__)
#define File(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)
#define fi first
#define se second
#define pb push_back
 
template<typename A, typename B> inline bool smax(A &a, const B &b) {return a < b ? a = b , 1 : 0;}
template<typename A, typename B> inline bool smin(A &a, const B &b) {return b < a ? a = b , 1 : 0;}
 
typedef long long ll; typedef unsigned long long ull; typedef std::pair<int, int> pii;
 
template<typename I> inline void read(I &x) {
	int f = 0, c;
	while (!isdigit(c = getchar())) c == '-' ? f = 1 : 0;
	x = c & 15;
	while (isdigit(c = getchar())) x = (x << 1) + (x << 3) + (c & 15);
	f ? x = -x : 0;
}

const int N = 2e5 + 7;

int n, tp, mid;
int a[N];
struct Pair { int l, r, v; } s[N];

inline bool qadd(int x) {
	while (tp && s[tp].l > x) --tp;
	assert(tp);
	s[tp].r = x;
	if (s[tp].v != mid) {
		if (x == s[tp].l) ++s[tp].v;
		else ++tp, --s[tp - 1].r, s[tp] = (Pair){ x, x, s[tp - 1].v + 1 };
	} else {
//		dbg("* mid = %d, x = %d, tp = %d\n", mid, x, tp);
		if (tp == 1) return 1;
//		if (s[tp - 1].l == s[tp - 1].r) ++s[--tp].v;
//		else s[tp] = (Pair){ s[tp - 1].r, s[tp - 1].r, s[tp - 1].v + 1 }, --s[tp - 1].r;
		qadd(q[--tp].r);
		++tp, s[tp] = (Pair){ s[tp - 1].r + 1, x, 1 };
	}
	return 0;
}

inline bool check() {
	tp = 0;
	for (int i = 1; i <= n; ++i) {
		if (a[i] <= a[i - 1]) { if (qadd(a[i])) return 0; }
		else s[++tp] = (Pair){ a[i - 1] + 1, a[i], 1 };
		while (tp > 1 && s[tp].v == s[tp - 1].v) s[tp - 1].r = s[tp].r, --tp;
		assert(s[tp].r == a[i]);
	}
	return 1;
}

inline void work() {
	int l = 1, r = n;
	while (l < r) {
		mid = (l + r) >> 1;
		if (check()) r = mid;
		else l = mid + 1;
	}
	printf("%d\n", l);
}

inline void init() {
	read(n);
	for (int i = 1; i <= n; ++i) read(a[i]);
}

int main() {
	#ifdef hzhkk
	freopen("hkk.in", "r", stdin);
	#endif
	init();
	work();
	fclose(stdin), fclose(stdout);
	return 0;
}

Compiler output:
a.cc: In function 'bool qadd(int)':
a.cc:42:22: error: 'q' was not declared in this scope
   42 |                 qadd(q[--tp].r);
      |                      ^
Language: C++

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <random>
#include <complex>
#include <random>
 
using namespace std;

struct String {
    int lim;
    unordered_map<int, int> c;

    void trim(int x) {
        while (!c.empty() && prev(c.end())->first >= x) {
            c.erase(--c.end());
        }
    }

    bool add(int to) {
        c[to]++;
        while (to >= 0 && c[to] == lim) {
            if (to == 0) {
                return false;
            }
            c[to] = 0;
            c[to - 1]++;
            to--;
        }
        return true;
    }

    String(int lim_) {
        lim = lim_;
    }
};

int n;
vector<int> a;

bool can(int x) {
    String cur(x);
    int clen = 0;
    for (int i = 0; i < n; i++) {
        if (clen < a[i]) {

        } else {
            cur.trim(a[i]);
            if (!cur.add(a[i] - 1)) {
                return false;
            }
        }
        clen = a[i];
    }
    return true;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;
    a.resize(n);
    for (auto &t : a) {
        cin >> t;
    }  
    int l = 0;
    int r = n;
    while (r - l > 1) {
        int m = (r + l) >> 1;
        if (can(m)) {
            r = m;
        } else {
            l = m;
        }
    }       
    cout << r << endl;
}


Compiler output:
a.cc: In member function 'void String::trim(int)':
a.cc:31:21: 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'})
   31 |             c.erase(--c.end());
      |                     ^~~~~~~~~
Language: C++

#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
using namespace std;
//using namespace boost::multiprecision;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}


int main(){
  
  int n;
  cin>>n;
  REP(i,n){
    cin>>a[i];
  }
  
  int l = 0, r = n;//(l,r]
  while(r-l>1){
    int k = (l+r)/2;
    bool flag = true;
    map<int, int> mp;
    REP(i,n){
      if(i==0)continue;
      if(a[i] > a[i-1])continue;
      for(int j = a[i]-1; j>=0; j--){
        if(mp[j] == k-1){
          mp[j] = 0;
          if(j == 0){
            flag = false;
          }
        }else{
          mp[j]++;
          break;
        }
      }
      if(!flag){
        break;
      }
    }
    if(flag){
      r = k;
    }else{
      l = k;
    } 
  }
  cout<<r<<endl;
  return 0; 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:71:10: error: 'a' was not declared in this scope
   71 |     cin>>a[i];
      |          ^
a.cc:81:10: error: 'a' was not declared in this scope
   81 |       if(a[i] > a[i-1])continue;
      |          ^
a.cc:82:19: error: 'a' was not declared in this scope
   82 |       for(int j = a[i]-1; j>=0; j--){
      |                   ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
ll n;
vector<ll> vec;
bool judge(ll x){
  map<ll,ll> mp;
  for(int i=1;i<n;i++){
    if(vec[i-1]>=vec[i]){
      mp[vec[i]]++;
      auto itr=mp.lower_bound(vec[i]);
      for(auto itr1=mp.end(),itr1!=itr;itr1--) mp.erase(itr1);
    }
    ll pos=vec[i];
    while(1){
      if(mp[pos]>=x){
        if(pos<=1){
          return false;
        }
        mp.erase(pos);
        if(mp.find(pos-1)!=mp.end()) mp[pos-1]=1;
        else mp[pos-1]++;
        pos--;
      }
      else break;
    }
  }
  return true;
}
signed main(){
  cin>>n;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    vec.push_back(a);
  }
  ll lb=0,rb=1000000007;
  while(rb-lb>1){
    ll mid=(lb+rb)/2;
    if(judge(mid)) rb=mid;
    else lb=mid;
  }
  cout<<rb<<endl;
}


Compiler output:
a.cc: In function 'bool judge(ll)':
a.cc:13:34: error: expected ';' before '!=' token
   13 |       for(auto itr1=mp.end(),itr1!=itr;itr1--) mp.erase(itr1);
      |                                  ^~
      |                                  ;
a.cc:13:34: error: expected primary-expression before '!=' token
   13 |       for(auto itr1=mp.end(),itr1!=itr;itr1--) mp.erase(itr1);
      |                                  ^~
Language: C++

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <tuple> 
#include <random>
#include <cassert>
#include <limits>
//#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define REP(i, N) for (int (i) = 0; (i) < (N); ++(i))

int N;
vector<int> A;

struct T {
	ll frm, len, chr;
	T(ll frm = 0, ll len = 0, ll chr = 0) : frm(frm), len(len), chr(chr) {}
};

vector<T> str;

void debug(int idx = 0) {
	cerr << idx << endl;
	int sz = str.size();
	for (int i = 0; i < sz; ++i) {
		T tmp = str[i];
		cerr << tmp.frm << ' ' << tmp.len << ' ' << tmp.chr << endl;
	}
}

void extend(ll len, ll chr = 0) {
	if (str.back().chr == chr) {
		str.back().len += len;
	} else {
		ll frm = str.back().frm + str.back().len;
		str.emplace_back(T(frm, len, chr));
	}
}

// cb -> cc
bool increment(int var) {
	if (str.size() == 1) {
		if (str[0].chr == var - 1) return false;
		str[0].len--;
		ll frm = str[0].frm + str[0].len;
		ll chr = str[0].chr + 1;
		if (str[0].len == 0) str.pop_back();
		str.emplace_back(T(frm, 1, chr));
	} else if (str.back().chr == var - 1) {
		T bck = str.back();	str.pop_back();
		bck.chr = 0;
		if (str.back().len == 1) {
			str.back().chr++;
		} else {
			str.back().len--;
			T bckbck = str.back();
			bckbck.frm += bckbck.len;
			bckbck.len = 1;
			bckbck.chr++;
			str.emplace_back(bckbck);
		}
		str.emplace_back(bck);
	} else if (str.back().len == 1) {
		T bck = str.back();	str.pop_back();
		if (str.back().chr == bck.chr + 1) {
			str.back().len++;
		} else {
			bck.chr++;
			str.emplace_back(bck);
		}
	} else {
		ll chr = str.back().chr;
		str.back().len--;
		str.emplace_back(T(str.back().frm + str.back().len, 1, chr + 1));
	}
	return true;
}

void cut(int idx) {//cerr<<"cutting: "<<idx<<endl;
	while (str.back().frm >= idx) str.pop_back();
	str.back().len -= str.back().frm + str.back().len - idx;//debug(10000);
	// auto itr = prev(upper_bound(str.begin(), str.end(), T(idx, -1, 0)));
}

bool check(int var) {
	vector<T>().swap(str);
	str.emplace_back(T(0, A[0], 0));
	//debug(0);
	for (int i = 1; i < N; ++i) {
		if (A[i - 1] < A[i]) {
			extend(A[i] - A[i - 1]);
		} else if (A[i - 1] == A[i]) {
			if (not increment(var)) return false;
		} else {
			cut(A[i]);//debug(100);
			if (not increment(var)) return false;
		}
		//debug(i);
	}
	return true;
}

int main() {

	cin >> N;
	
	A.resize(N);
	REP(i, N) cin >> A[i];
	
	/*
	cout << check(2) << endl;
	return 0;
	//*/
	
	int ok = 1 << 30, ng = 0;
	while (abs(ok - ng) > 1) {
		int md = (ok + ng) >> 1;
		if (check(md)) {
			ok = md;
		} else {
			ng = md;
		}
	}
	
	cout << ok << endl;

}



Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define ll long long
using namespace std;
signed main(){
	int n;
	cin>>n;
	vector<int> a;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		a.pb(x);
	}
	int lef = 1, rig = n;
	vector<int> b = a;
	int lef = 1, rig = n;	
	while(rig-lef>1){
		int k = (lef+rig)/2;
		map<int,int> mope;
		set<int> pos;
		bool fl = true;
		int last = a[0];
		for(int i=1;i<n;i++){
			//cout<<3<<endl;
			if(a[i] >= last){
				last = a[i];
				mope[last]++;
				pos.insert(last);
			}
			else{
				/* set<int>::iterator it = pos.upper_bound( a[i] );
				while( it != pos.end()  ){
					mope[*it]=0;
					++it;
				}
				it  = pos.upper_bound( a[i] );
				pos.erase(it,pos.end()); */
				last = a[i];
				mope[last]++;
				pos.insert(last);
			}
			while( mope[last] == k && last>0){
				mope[last] = 0;
				pos.erase(last);
				last --;
				mope[last]++;
				pos.insert(last);
			}
			if(last == 0){
				fl = false;
				goto end;
			}
			/* for(int j=1;j<=last;j++){
				cout<<mope[j]<<" ";
			}
			cout<<endl; */
		}
		end: n=n+0;
		if( fl == true){
			rig = k;
		}
		else{
			lef = k;
		}
	}
	cout<<rig<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:13: error: redeclaration of 'long long int lef'
   19 |         int lef = 1, rig = n;
      |             ^~~
a.cc:17:13: note: 'long long int lef' previously declared here
   17 |         int lef = 1, rig = n;
      |             ^~~
a.cc:19:22: error: redeclaration of 'long long int rig'
   19 |         int lef = 1, rig = n;
      |                      ^~~
a.cc:17:22: note: 'long long int rig' previously declared here
   17 |         int lef = 1, rig = n;
      |                      ^~~