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

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  int n; scanf("%d", &n);
  int a, p; long long ans = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a);
    if (a > i) {
      puts("-1");
      return;
    }
    if (i && a-p > 1) {
      puts("-1");
      return;
    }
    if (i && a <= p) ans += p;
    p = a;
  }
  ans += p;
  printf("%lld", ans);
}

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
using namespace std;
main(){
long a,b=-1,n,res=-1;
cin>>n;
while(n--){
cin>>a;
if(a>b+1)return cout<<-1;
res+=a>b?1:a;
b=a;
}
cout<<res;
}


Compiler output:
a.cc:3:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    3 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:8:21: error: cannot convert 'std::basic_ostream<char>' to 'int' in return
    8 | if(a>b+1)return cout<<-1;
      |                 ~~~~^~~~
      |                     |
      |                     std::basic_ostream<char>
Language: C++

#include<bits/stdc++.h>
using namespace std;
main(){
int a,b=-1,n,res=-1;
cin>>n;
while(n--){
cin>>a;
if(a>now+1){
cout<<-1<<endl;
return 0;
}
res+=a>now?1:a;
now=a;
}
cout<<res;
}


Compiler output:
a.cc:3:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    3 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:8:6: error: 'now' was not declared in this scope; did you mean 'pow'?
    8 | if(a>now+1){
      |      ^~~
      |      pow
a.cc:12:8: error: 'now' was not declared in this scope; did you mean 'pow'?
   12 | res+=a>now?1:a;
      |        ^~~
      |        pow
Language: C++

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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 1000001;

int N;

void solve() {
    cin >> N;
    vector<ll> a(N);
    for (auto& i : a) cin >> i;
    for (int i = N - 1; i >= 0; --i) {
		if (a[i] > i) {
			cout << -1;
			return;
		}
		
		ans += a[i];
		// cout << "Adding " << a[i] << " " << i << "\n";
		ll dist = a[i];
		int o = i;
		for (int j = 1; j < dist && o - j >= 0; j++) {
			if (a[o - j] + 1 == a[o - j + 1]) {
				// cout << "hi";
				--i;
			} else if (a[o - j] >= a[o - j + 1]) {
				break;
			} else {
				cout << -1;
				return;
			}
		}
	}
	cout << ans;
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Compiler output:
a.cc: In function 'void solve()':
a.cc:42:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   42 |                 ans += a[i];
      |                 ^~~
      |                 abs
a.cc:58:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   58 |         cout << ans;
      |                 ^~~
      |                 abs
Language: C++

int main() {
  cout << -1 << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:2:3: error: 'cout' was not declared in this scope
    2 |   cout << -1 << endl;
      |   ^~~~
a.cc:2:17: error: 'endl' was not declared in this scope
    2 |   cout << -1 << endl;
      |                 ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  vi A(N+1,-1);
  REP(i,1,N) cin>>A[i];
  int ans=0;
  REP(i,1,N){
    if(A[i-1]+1<A[i]){
      ans=-1;
      flag=0;
    }
  }
  if(flag){
  map<int,int> M;
  REP(i,1,N){
    int X=i-A[i];
    M[X]=max(M[X],A[i]);
  }
  for(auto p:M) ans+=p.second;
  }
  cout<<ans<<endl;
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:27:7: error: 'flag' was not declared in this scope
   27 |       flag=0;
      |       ^~~~
a.cc:30:6: error: 'flag' was not declared in this scope
   30 |   if(flag){
      |      ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  vi A(N+1,-1);
  REP(i,1,N) cin>>A[i];
  int ans=0;
  REP(i,1,N){
    if(A[i-1]+1<A[i]){
      ans=-1;
      goto XYZ;
    }
  }
  map<int,int> M;
  REP(i,1,N){
    int X=i-A[i];
    M[X]=max(M[X],A[i]);
  }
  for(auto p:M) ans+=p.second;
  XYZ:;
  cout<<ans<<endl;
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:36:3: error: jump to label 'XYZ'
   36 |   XYZ:;
      |   ^~~
a.cc:27:12: note:   from here
   27 |       goto XYZ;
      |            ^~~
a.cc:30:16: note:   crosses initialization of 'std::map<long long int, long long int> M'
   30 |   map<int,int> M;
      |                ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  vi A(N+1,-1);
  REP(i,1,N) cin>>A[i];
  int ans=0;
  REP(i,1,N){
    if(A[i-1]+1<A[i]){
      ans=-1;
      goto XYZ;
    }
  }
  map<int,int> M;
  REP(i,1,N){
    int X=i-A[i];
    M[X]=max(M[X],A[i]);
  }
  for(auto p:M) ans+=p.second;
  XYZ:
  cout<<ans<<endl;
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:36:3: error: jump to label 'XYZ'
   36 |   XYZ:
      |   ^~~
a.cc:27:12: note:   from here
   27 |       goto XYZ;
      |            ^~~
a.cc:30:16: note:   crosses initialization of 'std::map<long long int, long long int> M'
   30 |   map<int,int> M;
      |                ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  vi A(N+1,-1);
  REP(i,1,N) cin>>A[i];
  REP(i,1,N){
    if(A[i-1]+1<A[i]){
      cout<<-1<<endl;
      goto XYZ;
    }
  }
  map<int,int> M;
  REP(i,1,N){
    int X=i-A[i];
    M[X]=max(M[X],A[i]);
  }
  int ans=0;
  for(auto p:M) ans+=p.second;
  cout<<ans<<endl;
  XYZ:;
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:37:3: error: jump to label 'XYZ'
   37 |   XYZ:;
      |   ^~~
a.cc:26:12: note:   from here
   26 |       goto XYZ;
      |            ^~~
a.cc:34:7: note:   crosses initialization of 'long long int ans'
   34 |   int ans=0;
      |       ^~~
a.cc:29:16: note:   crosses initialization of 'std::map<long long int, long long int> M'
   29 |   map<int,int> M;
      |                ^
Language: C++

#include<iostream>
using namespace std;
long long a[200100],b[200100],n,m,ans;
bool flag;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
    	cin>>a[i]
    	b[i]=i-a[i];
    	if(a[i]>=i||a[i]>a[i-1]+1){
    		flag=true;
		}
	} 
	if(flag){
		cout<<"-1";
		return 0;
	}
	for(int i=n;i>0;i--){
      if(i!=n&&b[i]==b[i+1])continue;
      ans+=a[i];
    }
    cout<<ans;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:18: error: expected ';' before 'b'
    8 |         cin>>a[i]
      |                  ^
      |                  ;
    9 |         b[i]=i-a[i];
      |         ~
Language: C++

#include<iostream>
using namespace std;
long long a[200100],b[200100],n,m,ans;
bool flag;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
    	cin>>a[i]
    	b[i]=i-a[i];
    	if(a[i]>=i||a[i]>a[i-1]+1){
    		flag=true;
		}
	} 
	if(flag){
		cout<<"-1";
		return 0;
	}
	for(int i=n;i>0;i--){
      if(i!=n&&b[i]==b[i+1])continue;
      ans+=a[i];
    }
    cout<<ans;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:18: error: expected ';' before 'b'
    8 |         cin>>a[i]
      |                  ^
      |                  ;
    9 |         b[i]=i-a[i];
      |         ~
Language: C++

#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

const int MOD = 1e9 + 7;

long long inq(long long a, long long b)
{
    if (b == 0) return 1;
    long long l = inq(a, b / 2);
    if (b % 2) return l * l % MOD * a % MOD;
    return l * l % MOD;
}

int n;
int a[500000];
long long ans = 0;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    int d = 0;
    for (int i = n - 1; i >= 0; i--)
    {
        if (a[i] > i) cout << -1, exit(0);
        if (a[i] + 1 == a[i + 1]) continue
        else if (a[i] + 1 < a[i + 1]) cout << -1, exit(0);
        else ans += a[i];
    }
    cout << ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:103:43: error: expected ';' before 'else'
  103 |         if (a[i] + 1 == a[i + 1]) continue
      |                                           ^
      |                                           ;
  104 |         else if (a[i] + 1 < a[i + 1]) cout << -1, exit(0);
      |         ~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define elif else if
#define se second
#define fi first
typedef long long ll;
typedef multiset<ll> S;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}

int main(){
    int n;cin>>n;
    vi v(n);
    ll ans=0;
    rep(i,n)cin>>v[i];
    if(v[0]!=0){
        cout<<-1<<endl;
        return 0;
    }
    for(int i=n-1;i>0;i--){
        ans+=v[i];
        rep(j,v[i]-1){
            if(i-j-1<0){
                cout<<-1<<endl;
                return 0;
            }
            v[i-j-1]-=v[i]-j-1;
          if(v[i-j-1]<0){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
}


Compiler output:
a.cc:24:12: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   24 | bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
      |            ^~~~
a.cc:24:20: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   24 | bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
      |                    ^~~~
a.cc:25:12: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   25 | bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
      |            ^~~~
a.cc:25:20: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   25 | bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
      |                    ^~~~
a.cc: In function 'int main()':
a.cc:50:2: error: expected '}' at end of input
   50 | }
      |  ^
a.cc:27:11: note: to match this '{'
   27 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int n, a[222222], res = 0, now = 0;
    cin>>n;
    rep(i, n) {
        cin>>a[i];
    }
    reverse(a, a + n);
    rep(i, n) {
        if(a[i] < now) {
            cout<<-1<<endl;
            return 0;
        }
        if(a[i] > now) {
            res += now + 1;
            now = a[i] - 1;
        } else {
            if(now) res++, now--;
        }
    }
    cout<<(now ? -1 : res)<<endl
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:33: error: expected ';' before '}' token
   40 |     cout<<(now ? -1 : res)<<endl
      |                                 ^
      |                                 ;
   41 | }
      | ~
Language: C++

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n;
vector<ll> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        ll temp;
        cin >> temp;
        a.push_back(temp);
    }
    ll ans=0;
    ll count=0;
    set<ll> 
    for(int i=1;i<n;i++){
        if(a[i]-a[i-1]>1){
            cout<<-1<<"\n";
            return 0;
        }
        if(a[i]-a[i-1]==1){
            count++;
        }
        else{
            ans+=count;
            count=a[i];
        }
    }
    ans+=count;
    cout << ans << "\n";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:53:5: error: expected unqualified-id before 'for'
   53 |     for(int i=1;i<n;i++){
      |     ^~~
a.cc:53:17: error: 'i' was not declared in this scope
   53 |     for(int i=1;i<n;i++){
      |                 ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int n;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  vector<int> b(n);
  range(i, 0, n) {
    cin >> b[i];
    b[i] -= i;
  }
  long long res = 0;
  map<int, int> xpos;
  map<int, int> p;
  range(i, 0, n) {
    if(b[i] < -i || b[i] > 0) {
      cout << -1;
      return 0;
    }
    pos[-b[i]] = i;
    if(p.find(-b[i]) == p.end()) p[-b[i]] = i;
  }
  int cur = -1;
  for(auto it : pos) {
    if(p[it.first] < cur) {
      cout << -1;
      return 0;
    }
    cur = max(cur, it.second);
    res += it.second - it.first;
  }
  cout << res;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:5: error: 'pos' was not declared in this scope; did you mean 'xpos'?
   28 |     pos[-b[i]] = i;
      |     ^~~
      |     xpos
a.cc:32:17: error: 'pos' was not declared in this scope; did you mean 'xpos'?
   32 |   for(auto it : pos) {
      |                 ^~~
      |                 xpos
Language: C++

//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include<iomanip>

using namespace std;
 
const long long N = 400;
const long long inf = 1e15 + 7;
long long a[N];
long long n;
 
int main() 
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i]
	}
  	cout << -1;
  exit(0);
	if (a[0] != 0)
	{
		cout << -1;
		exit(0);
	}
	for (int i = 1; i < n; i++)
	{
		if (a[i] > a[i - 1] && a[i] - a[i - 1] > 1)
		{
			cout << -1;
			exit(0);
		}
	}


}
	
            


 

Compiler output:
a.cc: In function 'int main()':
a.cc:29:28: error: expected ';' before '}' token
   29 |                 cin >> a[i]
      |                            ^
      |                            ;
   30 |         }
      |         ~
Language: C++

//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include<iomanip>

using namespace std;
 
const long long N = 400;
const long long inf = 1e15 + 7;
long long a[N];
long long n;
 
int main() 
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i]
	}
	if (a[0] != 0)
	{
		cout << -1;
		exit(0);
	}
	for (int i = 1; i < n; i++)
	{
		if (a[i] > a[i - 1] && a[i] - a[i - 1] > 1)
		{
			cout << -1;
			exit(0);
		}
	}


}
	
            


 

Compiler output:
a.cc: In function 'int main()':
a.cc:29:28: error: expected ';' before '}' token
   29 |                 cin >> a[i]
      |                            ^
      |                            ;
   30 |         }
      |         ~
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
  fastIO;
  int n;
  cin >> n;
  ll a[n];
  for(int i = 0 ; i < n ; i ++ )
    cin >> a[i];
  if(a[i] > 0){
  	cout << "-1\n";
    return 0;
  }
  for(int i = 1 ; i < n ; i ++ ){
    if(a[i] - a[i - 1] > 1){
      cout << "-1\n";
      return 0;
    }
  }
  ll res = a[0];
  set<int> tt;
  for(int i = n - 1; i >= 0 ; i -- ){
    if(!tt.count(a[i] - i)){
      res += a[i];
      tt.insert(a[i] - i);
    }
  }
  cout << res << "\n";
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:8: error: 'i' was not declared in this scope
   20 |   if(a[i] > 0){
      |        ^
Language: C++

#include <iostream>
using namespace std;

long long solve(int* a, int n) {
    if (n == 1) {
        if (a[n - 1] == 0) {
            return 0;
        }
        return -1;
    }
    if (n >= 2 && a[n - 2] < a[n - 1] - 1) {
        return -1;
    }
    long long rest = solve(a, n - 1, a[n - 1] - 1);
    if (rest == -1) {
        return -1;
    }
    return rest + 1;
}

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


Compiler output:
a.cc: In function 'long long int solve(int*, int)':
a.cc:14:27: error: too many arguments to function 'long long int solve(int*, int)'
   14 |     long long rest = solve(a, n - 1, a[n - 1] - 1);
      |                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:4:11: note: declared here
    4 | long long solve(int* a, int n) {
      |           ^~~~~
Language: C++

#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>


using namespace std;

using ll = long long;

int main(){
    int N;cin >> N;
    vector<int> vec;
    for(int i = 0;i < N;i++){
        int b;cin >> b;
        vec.push_back(b);
    }
    if(vec.front() != 0){
        cout<<-1<<endl;
        return 0;
    }
    int now = vec.back();
    int ans = 0;
    for(int i = N-2;i >= 0;i--){
       // cout<<i<<endl;
    //    if(i == 0)continue;
        if(now == vec.at(i) || now - 1 == vec.at(i) || now < vec.at(i)){
            if(now <= vec.at(i)){
                ans += now;
            }else{
                ans++;
            }
            now = vec.at(i);
        }else{
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
}


Compiler output:
In file included from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:2:
/usr/include/c++/14/bits/allocator.h: In destructor 'std::_Vector_base<int, std::allocator<int> >::_Vector_impl::~_Vector_impl()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = int]': target specific option mismatch
  182 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/stl_vector.h:132:14: note: called from here
  132 |       struct _Vector_impl
      |              ^~~~~~~~~~~~
Language: C++

/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(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 print2(x,y) cout << (x) << “ “ << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << “ \n”[i==n-1];};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll A[200010];
    cin >> N;
	rep(i,0,N) cin >> A[i];
	rep(i,0,N-1){
		if(A[i+1] - A[i] >= 2){
			print(-1);
			return 0;
		}
	}
	if(A[0] != 0){
		print(-1);
		return 0;
	}
	A[N] = -INF;
	ll ans = 0;
	rep(i,0,N){
		if(A[i+1] - A[i] < 0){
			ll idx = i;
			ll val = 0;
			while(idx >= 0){
				if(A[idx] == A[i]){
					val += A[i];
				}else{
					break;
				} 
				idx—-;
			}
			ans += val;
		}
	}
	print(ans);
}


Compiler output:
a.cc:9:47: error: extended character — is not valid in an identifier
    9 | #define rrep(i,m,n) for(ll i = (m); i >= (n); i—)
      |                                               ^
a.cc:11:36: error: extended character “ is not valid in an identifier
   11 | #define print2(x,y) cout << (x) << “ “ << (y) << endl;
      |                                    ^
a.cc:11:38: error: extended character “ is not valid in an identifier
   11 | #define print2(x,y) cout << (x) << “ “ << (y) << endl;
      |                                      ^
a.cc:12:66: error: extended character “ is not valid in an identifier
   12 | #define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << “ \n”[i==n-1];};
      |                                                                  ^
a.cc:12:69: error: extended character ” is not valid in an identifier
   12 | #define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << “ \n”[i==n-1];};
      |                                                                     ^
a.cc:42:33: error: extended character — is not valid in an identifier
   42 |                                 idx—-;
      |                                 ^
a.cc: In function 'int main()':
a.cc:42:33: error: 'idx\U00002014' was not declared in this scope
   42 |                                 idx—-;
      |                                 ^~~~
a.cc:42:38: error: expected primary-expression before ';' token
   42 |                                 idx—-;
      |                                      ^
Language: C++

#include <iostream>
#include <string.h>

using namespace std;

int N[210000];
int M[210000];
int ans,n;

bool build(int x,int n)
{
    if(M[x]==n)
        return true;
    if(x==0||n==0)
        return false;
    if(build(x-1,n-1))
    {
        ans++;
        M[x]=n;
        return true;
    }
    return false;
}

bool mtime()
{
    for(int i=1; i<n; i++)
    {
        if(N[i]-N[i-1]>1)
            return true;
    }
    return false;
}

int main()
{
    for(int i=0; i<n; i++)
    {
        cin>>N[i];
    }
    if(N[0]!=0||mtime())
    {
        cout<<-1<<endl;
        continue;
    }
    ans=0;
    bool flag=true;
    memset(M,0,sizeof(M));
    for(int i=n-1; i>0&&flag; i--)
    {
        flag=build(i,N[i]);
    }
    if(flag)
        cout<<ans;
    else
        cout<<-1;
    cout<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:44:9: error: continue statement not within a loop
   44 |         continue;
      |         ^~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
ll a[100100];
ll ans=0;
map<ll,ll> m;

int main(){
	cin>>n;
	REP(i,n)
		cin>>a[i];
		
	if(a[0]!=0){
		cout<<-1<<endl;
		return 0;
	}
	for(int i=1;i<n;i++){

		if(a[i]>a[i-1]+1){
			cout<<-1<<endl;
			return 0;
		}
	}
	for(int i=0;i<n;i++)
		map[i-a[i]]=a[i];
	for(auto it=m.begin();it!=m.end();it++){
		ans+=it->second;
	}
	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:22: error: expected ']' before '-' token
   46 |                 map[i-a[i]]=a[i];
      |                      ^
      |                      ]
a.cc:46:21: error: redeclaration of 'auto i'
   46 |                 map[i-a[i]]=a[i];
      |                     ^
a.cc:45:17: note: 'int i' previously declared here
   45 |         for(int i=0;i<n;i++)
      |                 ^
a.cc:46:31: error: use of 'i' before deduction of 'auto'
   46 |                 map[i-a[i]]=a[i];
      |                               ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n,c=0;
  cin>>n;
  a[n];
  cin>>a[0];
  if(a[0]!=0){
    cout<<-1;
    return 0;
  }
  for(int i=1;i<n;i++){
    cin>>a[i];
    if(a[i-1]+1==a[i]){
      c++;
    }else if(a[i-1]+1>a[i]){
      c+=a[i];
    }else{
      cout<<-1;
      return 0;
    }
  }
  cout<<c;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'a' was not declared in this scope
    7 |   a[n];
      |   ^
Language: C++

/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	ll N;
	cin >> N;
	ll A[N];
	for (ll i = 0; i < N; ++i) cin >> A[i];
 
	// 
	ll ans = 0;
	if (A[0]!=0) ans = -1;
	else{
		REP(i,N-1){
			if (A[i+1]>=A[i]+2){
				ans = -1;
				break;
			}
			if (A[i+1]==0) // 何もしない
			if (A[i+1]>=A[i]+1){
				ans++;
			}
			if (A[i+1]<=A[i]+1){
				ans += A[i+1];
			}
		}
	
	// else ans = 100;
	//出力
	cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:135:2: error: expected '}' at end of input
  135 | }
      |  ^
a.cc:107:12: note: to match this '{'
  107 | int main() {
      |            ^
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	ll n;
	cin>>n;
	vector<ll> a(n);
	for(ll i = 0; i < n; i++){
		cin >> a[i];
	}

	if(n==1){
		cout<<(a[0]==0?0:-1)<<endl;
		return 0;
	}

	ll now=0;
	ll ans=0;
	for(int i = 1; i < n; i++){
		if(now<a[i]){
			if(now+1!=a[i]){
				cout << -1 << endl;
				return 0;
			}
			ans -= now;
			now++;
			ans += now;
		}else if(now==a[i]){
			cnt++;
			ans+=now;
		}else{
			now=a[i];
			ans+=now;
		}
	}

	cout << ans << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:25: error: 'cnt' was not declared in this scope; did you mean 'int'?
   48 |                         cnt++;
      |                         ^~~
      |                         int
Language: C++

#include <bits/stdc++.h>

#define x first
#define y second
#define x1 X1 
#define x2 X2
#define y1 Y1
#define y2 Y2
#define mp make_pair
#define pb push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> pii;

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }
inline int read ()
{
	int sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

const int Maxn = 2e5 + 100;

int N, A[Maxn], delta[Maxn];

int main()
{
#ifdef hk_cnyali
	freopen("C.in", "r", stdin);
	freopen("C.out", "w", stdout);
#endif
	N = read();
	for (int i = 1; i <= N; ++i) A[i] = read();
	if (A[i])
	{
		cout<<"-1"<<endl;
		return 0;
	}
	for (int i = 1; i <= N; ++i)
	{
		delta[i] = A[i] - A[i - 1];
		if (delta[i] > 0 && delta[i] != 1)
		{
			cout<<"-1"<<endl;
			return 0;
		}
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:39:15: error: 'i' was not declared in this scope
   39 |         if (A[i])
      |               ^
Language: C++

/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

int a[MAXN];
int pref[MAXN];

int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    int n = readInt();
    for (int i = 1; i <= n; i++) {
    	a[i] = readInt();
		pref[i] = pref[i - 1] + (!a[i]);
    }
    cout << -1;
    return 0;
    int mn = MOD;
    int ans = 0;
    for (int i = n; i >= 1; i--) {
    	if (!a[i]) continue;    	
    	int l = i - (a[i]-1) - 1;
    	if (l < 1) {
    		cout << -1;
    		return 0;
    	}
    	if (l > mn) {
			cout << -1;
			return 0;    	
    	}
    	if (l == mn) {
    		ans ++;
    	}
    	mn = min(mn, l);
    	if (l+1 <= i - 1) {
    		int s = pref[r] - pref[l];
			if (s) {
				cout << -1;
				return 0;
			}
    	}
    }
    cout << accumulate(a + 1, a + 1 + n, 0) - ans;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:101:30: error: 'r' was not declared in this scope
  101 |                 int s = pref[r] - pref[l];
      |                              ^
Language: C++

/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

int a[MAXN];
int pref[MAXN];

int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    int n = readInt();
    for (int i = 1; i <= n; i++) {
    	a[i] = readInt();
		pref[i] = pref[i - 1] + (!a[i]);
    }
    cout << -1;
    return 0;
    int mn = MOD;
    int ans = 0;
    for (int i = n; i >= 1; i--) {
    	if (!a[i]) continue;    	
    	int l = i - (a[i]-1) - 1;
    	if (l < 1) {
    		cout << -1;
    		return 0;
    	}
    	if (l > mn) {
			cout << -1;
			return 0;    	
    	}
    	if (l == mn) {
    		ans ++;
    	}
    	mn = min(mn, l);
    	if (l < r) {
    		int s = pref[r] - pref[l];
			if (s) {
				cout << -1;
				return 0;
			}
    	}
    }
    cout << accumulate(a + 1, a + 1 + n, 0) - ans;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:100:17: error: 'r' was not declared in this scope
  100 |         if (l < r) {
      |                 ^
Language: C++

#include <iostream>
#include <vector>

using namespace std;

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

  if (a[0] > 0) {
    cout << -1;
    return 0;
  }

  ll ans = 0;
  ll count = 0;
  for (int i = 1; i < n; i++) {
    if (a[i] - a[i - 1] > 1) {
      cout << -1;
      return 0;
    }
    else if (a[i] - a[i - 1] == 1) {
      count++;
    }
    else {
      ans += count;
      count = a[i];
    }
  }
  ans += count;
  cout << ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:3: error: 'll' was not declared in this scope
   19 |   ll ans = 0;
      |   ^~
a.cc:20:5: error: expected ';' before 'count'
   20 |   ll count = 0;
      |     ^~~~~~
      |     ;
a.cc:27:7: error: 'count' was not declared in this scope
   27 |       count++;
      |       ^~~~~
a.cc:30:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   30 |       ans += count;
      |       ^~~
      |       abs
a.cc:30:14: error: 'count' was not declared in this scope
   30 |       ans += count;
      |              ^~~~~
a.cc:34:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
   34 |   ans += count;
      |   ^~~
      |   abs
a.cc:34:10: error: 'count' was not declared in this scope
   34 |   ans += count;
      |          ^~~~~
Language: C++

#include <iostream>
#include <cstdio>
using namespace std;
int n,a[200005];
ll ans;
int main()
{
	cin>>n;
	for (int i=1;i<=n;++i)
	{
		cin>>a[i];
		if (i==1 && a[i]) return (int)puts("-1")*0;
		else if (a[i]==a[i-1]+1) ans++;
		else if (a[i]<a[i-1]+1) ans+=a[i];
		else if (a[i]>a[i-1]+1) return (int)puts("-1")*0;
	}
	cout<<ans<<endl;
}

Compiler output:
a.cc:5:1: error: 'll' does not name a type
    5 | ll ans;
      | ^~
a.cc: In function 'int main()':
a.cc:13:42: error: 'ans' was not declared in this scope; did you mean 'abs'?
   13 |                 else if (a[i]==a[i-1]+1) ans++;
      |                                          ^~~
      |                                          abs
a.cc:14:41: error: 'ans' was not declared in this scope; did you mean 'abs'?
   14 |                 else if (a[i]<a[i-1]+1) ans+=a[i];
      |                                         ^~~
      |                                         abs
a.cc:17:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   17 |         cout<<ans<<endl;
      |               ^~~
      |               abs
Language: C++

include <cstdio>

const int maxn=200000;

int read()
{
  int x=0,f=1;
  char ch=getchar();
  while((ch<'0')||(ch>'9'))
    {
      if(ch=='-')
        {
          f=-f;
        }
      ch=getchar();
    }
  while((ch>='0')&&(ch<='9'))
    {
      x=x*10+ch-'0';
      ch=getchar();
    }
  return x*f;
}

int n,a[maxn+10];
long long ans;

int main()
{
  n=read();
  for(int i=1; i<=n; ++i)
    {
      a[i]=read();
      if(a[i]>=i)
        {
          puts("-1");
          return 0;
        }
    }
  for(int i=2; i<=n; ++i)
    {
      if(a[i]>a[i-1]+1)
        {
          puts("-1");
          return 0;
        }
      if(a[i]==a[i-1]+1)
        {
          ++ans;
        }
      else
        {
          ans+=a[i];
        }
    }
  printf("%lld\n",ans);
  return 0;
}

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <cstdio>
      | ^~~~~~~
a.cc: In function 'int read()':
a.cc:8:11: error: 'getchar' was not declared in this scope
    8 |   char ch=getchar();
      |           ^~~~~~~
a.cc:1:1: note: 'getchar' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | include <cstdio>
a.cc: At global scope:
a.cc:25:9: error: 'maxn' was not declared in this scope
   25 | int n,a[maxn+10];
      |         ^~~~
a.cc: In function 'int main()':
a.cc:33:7: error: 'a' was not declared in this scope
   33 |       a[i]=read();
      |       ^
a.cc:36:11: error: 'puts' was not declared in this scope
   36 |           puts("-1");
      |           ^~~~
a.cc:42:10: error: 'a' was not declared in this scope
   42 |       if(a[i]>a[i-1]+1)
      |          ^
a.cc:44:11: error: 'puts' was not declared in this scope
   44 |           puts("-1");
      |           ^~~~
a.cc:47:10: error: 'a' was not declared in this scope
   47 |       if(a[i]==a[i-1]+1)
      |          ^
a.cc:56:3: error: 'printf' was not declared in this scope
   56 |   printf("%lld\n",ans);
      |   ^~~~~~
a.cc:56:3: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
Language: C++

#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,k,a[MAXN];
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<n;i++)
        if(a[i]-a[i-1]>1) 
        {
            puts("-1");
            return 0;
        }
    if(a[0]!=0) 
    {
        puts("-1");
        return 0;
    }
    int ans=0;
    for(int i=1;i<n;i++)
        if(a[i]!=a[i-1]+1) ans+=a[i-1];
    ans+=a[n-1];
    printf("%d\n",ans);
    return 0;
}



Compiler output:
a.cc:6:9: error: 'pair' does not name a type
    6 | typedef pair<int,int> P;
      |         ^~~~
a.cc:7:11: error: 'MAXN' was not declared in this scope
    7 | int n,k,a[MAXN];
      |           ^~~~
a.cc: In function 'int main()':
a.cc:10:5: error: 'scanf' was not declared in this scope
   10 |     scanf("%d",&n);
      |     ^~~~~
a.cc:12:21: error: 'a' was not declared in this scope
   12 |         scanf("%d",&a[i]);
      |                     ^
a.cc:14:12: error: 'a' was not declared in this scope
   14 |         if(a[i]-a[i-1]>1)
      |            ^
a.cc:16:13: error: 'puts' was not declared in this scope
   16 |             puts("-1");
      |             ^~~~
a.cc:19:8: error: 'a' was not declared in this scope
   19 |     if(a[0]!=0)
      |        ^
a.cc:21:9: error: 'puts' was not declared in this scope
   21 |         puts("-1");
      |         ^~~~
a.cc:26:12: error: 'a' was not declared in this scope
   26 |         if(a[i]!=a[i-1]+1) ans+=a[i-1];
      |            ^
a.cc:27:10: error: 'a' was not declared in this scope
   27 |     ans+=a[n-1];
      |          ^
a.cc:28:5: error: 'printf' was not declared in this scope
   28 |     printf("%d\n",ans);
      |     ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | #define MOD 1000000007