Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)

int main() {
    int n;
    cin >> n;
    ll a[n + 1];
    rep (i, 0, n + 1) cin >> a[i];

    ll s[n + 1]; //要素の最大の数
    rep (i, 0, n + 1) {
        if (i == 0){
            if (a[0]>=2){
                cout<<-1<<"\n";
                return 0;
            }
            s[i] = 1;
        }
        else {
            s[i] = (s[i - 1] - a[i - 1]) * 2;
        }
        // cout << s[i] << "\n";
        if (s[i] <= 0) {
            cout << -1 << "\n";
            return 0;
        }
    }

    ll ans = 0;
    ll b[n + 1]; //子から考えた要素の最大数
    per (i, 0, n + 1) {
        if (i == n) {
            b[i] = a[i];
            if (s[i] < b[i]) {
                cout << -1 << "\n";
                return 0;
            }
        } else {
            b[i] = min(b[i + 1] + a[i],s[i]);
            //if (b[i] > s[i]) b[i] = s[i];
        }
        ans += b[i];
        // cout << b[i] << "\n";
    } /*
     rep (i, 0, n + 1) cout << s[i] << " ";
     cout << "\n";
     rep (i, 0, n + 1) cout << b[i] << " ";
     cout << " \n";*/
    cout << ans << "\n";
}



Compiler output:
a.cc: In function 'int main()':
a.cc:9:5: error: 'll' was not declared in this scope
    9 |     ll a[n + 1];
      |     ^~
a.cc:10:30: error: 'a' was not declared in this scope
   10 |     rep (i, 0, n + 1) cin >> a[i];
      |                              ^
a.cc:12:7: error: expected ';' before 's'
   12 |     ll s[n + 1]; //要素の最大の数
      |       ^~
      |       ;
a.cc:15:17: error: 'a' was not declared in this scope
   15 |             if (a[0]>=2){
      |                 ^
a.cc:19:13: error: 's' was not declared in this scope
   19 |             s[i] = 1;
      |             ^
a.cc:22:13: error: 's' was not declared in this scope
   22 |             s[i] = (s[i - 1] - a[i - 1]) * 2;
      |             ^
a.cc:22:32: error: 'a' was not declared in this scope
   22 |             s[i] = (s[i - 1] - a[i - 1]) * 2;
      |                                ^
a.cc:25:13: error: 's' was not declared in this scope
   25 |         if (s[i] <= 0) {
      |             ^
a.cc:31:7: error: expected ';' before 'ans'
   31 |     ll ans = 0;
      |       ^~~~
      |       ;
a.cc:32:7: error: expected ';' before 'b'
   32 |     ll b[n + 1]; //子から考えた要素の最大数
      |       ^~
      |       ;
a.cc:35:13: error: 'b' was not declared in this scope
   35 |             b[i] = a[i];
      |             ^
a.cc:35:20: error: 'a' was not declared in this scope
   35 |             b[i] = a[i];
      |                    ^
a.cc:36:17: error: 's' was not declared in this scope
   36 |             if (s[i] < b[i]) {
      |                 ^
a.cc:41:13: error: 'b' was not declared in this scope
   41 |             b[i] = min(b[i + 1] + a[i],s[i]);
      |             ^
a.cc:41:35: error: 'a' was not declared in this scope
   41 |             b[i] = min(b[i + 1] + a[i],s[i]);
      |                                   ^
a.cc:41:40: error: 's' was not declared in this scope
   41 |             b[i] = min(b[i + 1] + a[i],s[i]);
      |                                        ^
a.cc:44:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   44 |         ans += b[i];
      |         ^~~
      |         abs
a.cc:44:16: error: 'b' was not declared in this scope
   44 |         ans += b[i];
      |                ^
a.cc:51:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   51 |     cout << ans << "\n";
      |             ^~~
      |             abs