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){cout<<-1<<"\n";return 0}
      |                 ^
a.cc:15:49: error: expected ';' before '}' token
   15 |             if (A[0]>=2){cout<<-1<<"\n";return 0}
      |                                                 ^
      |                                                 ;
a.cc:16:13: error: 's' was not declared in this scope
   16 |             s[i] = 1;
      |             ^
a.cc:19:13: error: 's' was not declared in this scope
   19 |             s[i] = (s[i - 1] - a[i - 1]) * 2;
      |             ^
a.cc:19:32: error: 'a' was not declared in this scope
   19 |             s[i] = (s[i - 1] - a[i - 1]) * 2;
      |                                ^
a.cc:22:13: error: 's' was not declared in this scope
   22 |         if (s[i] <= 0) {
      |             ^
a.cc:28:7: error: expected ';' before 'ans'
   28 |     ll ans = 0;
      |       ^~~~
      |       ;
a.cc:29:7: error: expected ';' before 'b'
   29 |     ll b[n + 1]; //子から考えた要素の最大数
      |       ^~
      |       ;
a.cc:32:13: error: 'b' was not declared in this scope
   32 |             b[i] = a[i];
      |             ^
a.cc:32:20: error: 'a' was not declared in this scope
   32 |             b[i] = a[i];
      |                    ^
a.cc:33:17: error: 's' was not declared in this scope
   33 |             if (s[i] < b[i]) {
      |                 ^
a.cc:38:13: error: 'b' was not declared in this scope
   38 |             b[i] = min(b[i + 1] + a[i],s[i]);
      |             ^
a.cc:38:35: error: 'a' was not declared in this scope
   38 |             b[i] = min(b[i + 1] + a[i],s[i]);
      |                                   ^
a.cc:38:40: error: 's' was not declared in this scope
   38 |             b[i] = min(b[i + 1] + a[i],s[i]);
      |                                        ^
a.cc:41:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   41 |         ans += b[i];
      |         ^~~
      |         abs
a.cc:41:16: error: 'b' was not declared in this scope
   41 |         ans += b[i];
      |                ^
a.cc:48:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   48 |     cout << ans << "\n";
      |             ^~~
      |             abs