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

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main(){
  ll n;
  cin >> n;
  vector<ll> vec(n+1);
  rep(i, n+1) cin >> vec[i];
  ll smallest = 0;
  for(ll i=n; i>=0; i--){
    if(i == n){
      if(vec[i] == 0){
        cout << -1 << endl;
        return 0;
      }else{
        smallest += vec[i];
      }
    }else{
      smallest = vec[i] + (smallest+1)/2;
    }
  }
  if(1 < smallest){
    cout << -1 << endl;
    return 0;
  }
  ll res = 0;
  ll current = 0;
  vector<ll> mx;
  rep(i, n+1){
    if(i == 0) mx.push_back(1);
    else mx.push_back(min((mx[i-1]-vec[i-1])*2), (ll)1e18);
  }
  for(ll i=n; i>=0; i--){
    current = min(current+vec[i], mx[i]);
    res += current;
  }
  cout << res << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:26: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
   35 |     else mx.push_back(min((mx[i-1]-vec[i-1])*2), (ll)1e18);
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   template argument deduction/substitution failed:
a.cc:35:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   35 |     else mx.push_back(min((mx[i-1]-vec[i-1])*2), (ll)1e18);
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   candidate expects 2 arguments, 1 provided
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main(){
  ll n;
  cin >> n;
  vector<ll> vec(n+1);
  rep(i, n+1) cin >> vec[i];
  ll smallest = 0;
  for(ll i=n; i>=0; i--){
    if(i == n){
      if(vec[i] == 0){
        cout << -1 << endl;
        return 0;
      }else{
        smallest += vec[i];
      }
    }else{
      smallest = vec[i] + (smallest+1)/2;
    }
  }
  if(1 < smallest){
    cout << -1 << endl;
    return 0;
  }
  ll res = 0;
  ll current = 0;
  vector<ll> mx;
  rep(i, n+1){
    if(i == 0) mx.push_back(1);
    else mx.push_back(min((mx[i-1]-vec[i-1])*2), 1e18);
  }
  for(ll i=n; i>=0; i--){
    current = min(current+vec[i], mx[i]);
    res += current;
  }
  cout << res << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:26: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
   35 |     else mx.push_back(min((mx[i-1]-vec[i-1])*2), 1e18);
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   template argument deduction/substitution failed:
a.cc:35:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   35 |     else mx.push_back(min((mx[i-1]-vec[i-1])*2), 1e18);
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   candidate expects 2 arguments, 1 provided
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main(){
  ll n;
  cin >> n;
  vector<ll> vec(n+1);
  for(ll i=0; i<=n; i++) cin >> vec[i];
  ll res = 0;
  ll current = 0;
  vector<ll> mx(n+1);
  for(ll i=0; i<=n; i++){
    if(i == 0) mx[i] = 1;
    else{
      if((mx[i-1]-vec[i-1])*2 < vec[i]){
        cout << -1 << endl;
        return 0;
      }
      mx[i] = (mx[i-1]-vec[i-1])*2;
    }
  }
  for(ll i=n; i>=0; i--){
    if(i == n){
      if(vec[i] > mx[i]){
        cout << -1 << endl;
        return 0;
      }
      current += vec[i];
      res += current;
    }else{
      current = min(vec[i]+current, mx[i]);
      res += current;
    }
  }
  cout << r << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:11: error: 'r' was not declared in this scope
   39 |   cout << r << endl;
      |           ^
Language: C++

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

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

    vector<ll> ma(n+1);

    ll num_m = 1;
    for(int i = 0; i < n+1; i++){
        ma[i] = num_m - a[i];
        if(ma[i] < 0){
            cout << -1;
            return 0;
        }
        num_m = min(ma[i]*2, 100000000000000);
    }
    
    ll num_before = a[n];

    vector<ll> num_b(n);
    for(int i = n-1; i >= 0 ; i--){
        num_b[i] = min(num_before, ma[i]);
        num_before = num_b[i] + a[i];
    }

    ll num_all=a[n];
    for(int i= 0; i < n; i++){
        num_all += num_b[i] + a[i];
    }
    cout << num_all;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:20: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type, long int)'
   20 |         num_m = min(ma[i]*2, 100000000000000);
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:20:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long int')
   20 |         num_m = min(ma[i]*2, 100000000000000);
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:20:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   20 |         num_m = min(ma[i]*2, 100000000000000);
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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

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

    vector<ll> ma(n+1);

    ll num_m = 1;
    for(int i = 0; i < n+1; i++){
        ma[i] = num_m - a[i];
        if(ma[i] < 0){
            cout << -1;
            return 0;
        }
        num_m = min(ma[i]*2, INT32_MAX);
    }
    
    ll num_before = a[n];

    vector<ll> num_b(n);
    for(int i = n-1; i >= 0 ; i--){
        num_b[i] = min(num_before, ma[i]);
        num_before = num_b[i] + a[i];
    }

    ll num_all=a[n];
    for(int i= 0; i < n; i++){
        num_all += num_b[i] + a[i];
    }
    cout << num_all;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:20: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type, int)'
   20 |         num_m = min(ma[i]*2, INT32_MAX);
      |                 ~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:20:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   20 |         num_m = min(ma[i]*2, INT32_MAX);
      |                 ~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:20:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   20 |         num_m = min(ma[i]*2, INT32_MAX);
      |                 ~~~^~~~~~~~~~~~~~~~~~~~
Language: C++

# include <iostream>
# include <algorithm>
using  namespace  std ;
typedef  long  long ll;

int a [ 100050 ];

void  solve ()
{
    int n;
    ll ans = 1 , m = 1 , sum = 0 ;
    cin >> n;
    for ( int i = 0 ; i <= n; i ++)
    {
        cin >> a [i];
        sum+= a [i];
    }
    if ( (n> 0 && a [ 0 ]> 0) || (n == 0 && a [ 0 ]> 1 ) )// Special judgment
    {
        cout << -1<<endl;
        return ;
    }
    for ( int i = 1 ; i <= n; i ++)
    {
        m = min (m << 1 , sum); // Maximum number of nodes in layer i
        ans+= m;
        if (a [i]> m)
        {
            cout << -1 <<endl;
            return ;
        }
        m- = a [i]; // Number of non-leaf nodes in layer i
        sum- = a [i]; // Number of leaf nodes after layer i + 1
    }
    cout << ans << endl ;
}
int  main ()
{
    ios :: sync_with_stdio ( 0 );
    cin .tie ( 0 ); cout .tie ( 0 );
    solve ();
    return  0 ;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:32:12: error: expected primary-expression before '=' token
   32 |         m- = a [i]; // Number of non-leaf nodes in layer i
      |            ^
a.cc:33:14: error: expected primary-expression before '=' token
   33 |         sum- = a [i]; // Number of leaf nodes after layer i + 1
      |              ^
Language: C++

# include <iostream>
# include <algorithm>
using  namespace  std ;
typedef  long  long ll;

int a [ 100050 ];

void  solve ()
{
    int n;
    ll ans = 1 , m = 1 , sum = 0 ;
    cin >> n;
    for ( int i = 0 ; i <= n; i ++)
    {
        cin >> a [i];
        sum+= a [i];
    }
    if (n> 0 && a [ 0 ]> 0 || n == 0 && a [ 0 ]> 1 ) // Special judgment
    {
        cout << -1<<endl;
        return ;
    }
    for ( int i = 1 ; i <= n; i ++)
    {
        m = min (m << 1 , sum); // Maximum number of nodes in layer i
        ans+= m;
        if (a [i]> m)
        {
            cout << -1 <<endl;
            return ;
        }
        m- = a [i]; // Number of non-leaf nodes in layer i
        sum- = a [i]; // Number of leaf nodes after layer i + 1
    }
    cout << ans << endl ;
}
int  main ()
{
    ios :: sync_with_stdio ( 0 );
    cin .tie ( 0 ); cout .tie ( 0 );
    solve ();
    return  0 ;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:32:12: error: expected primary-expression before '=' token
   32 |         m- = a [i]; // Number of non-leaf nodes in layer i
      |            ^
a.cc:33:14: error: expected primary-expression before '=' token
   33 |         sum- = a [i]; // Number of leaf nodes after layer i + 1
      |              ^
Language: C++

# include <iostream>
# include <algorithm>
using  namespace  std ;
typedef  long  long ll;

int a [ 100050 ];

void  solve ()
{
    int n;
    ll ans = 1 , m = 1 , sum = 0 ;
    cin >> n;
    for ( int i = 0 ; i <= n; i ++)
    {
        cin >> a [i];
        sum + = a [i];
    }
    if (n> 0 && a [ 0 ]> 0 || n == 0 && a [ 0 ]> 1 ) // Special judgment
    {
        cout << "-1 \ n" ;
        return ;
    }
    for ( int i = 1 ; i <= n; i ++)
    {
        m = min (m << 1 , sum); // Maximum number of nodes in layer i
        ans + = m;
        if (a [i]> m)
        {
            cout << "-1 \ n" ;
            return ;
        }
        m- = a [i]; // Number of non-leaf nodes in layer i
        sum- = a [i]; // Number of leaf nodes after layer i + 1
    }
    cout << ans << '\ n' ;
}
int  main ()
{
    ios :: sync_with_stdio ( 0 );
    cin .tie ( 0 ); cout .tie ( 0 );
    solve ();
    return  0 ;
}


Compiler output:
a.cc:35:20: warning: unknown escape sequence: '\040'
   35 |     cout << ans << '\ n' ;
      |                    ^~~~~
a.cc:35:20: warning: multi-character character constant [-Wmultichar]
a.cc: In function 'void solve()':
a.cc:16:15: error: expected primary-expression before '=' token
   16 |         sum + = a [i];
      |               ^
a.cc:20:17: warning: unknown escape sequence: '\040'
   20 |         cout << "-1 \ n" ;
      |                 ^~~~~~~~
a.cc:26:15: error: expected primary-expression before '=' token
   26 |         ans + = m;
      |               ^
a.cc:29:21: warning: unknown escape sequence: '\040'
   29 |             cout << "-1 \ n" ;
      |                     ^~~~~~~~
a.cc:32:12: error: expected primary-expression before '=' token
   32 |         m- = a [i]; // Number of non-leaf nodes in layer i
      |            ^
a.cc:33:14: error: expected primary-expression before '=' token
   33 |         sum- = a [i]; // Number of leaf nodes after layer i + 1
      |              ^
Language: C++

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;
template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}

vector<ll> dp;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<ll> v(n+1);
  rep(i, n+1) cin >> v[i];
  // dp[i] = i番目の最大頂点数
  dp = vector<ll> (n+100, -1);
  dp[0] = 1;

  // // n == 0の時の処理
  if(n == 0 && v[0] > 1){
    cout << -1 << endl;
    return 0;
  }else if(n == 0 && v[0] == 1){
    cout << 1 << endl;
    return 0;
  }else if(n == 0){
    cout << -1 << endl;
    return 0;
  }

  ll res = 0;
  for (int i = 0; i < n+1; ++i) {
    dp[i+1] = (dp[i] - v[i]) * 2;
  }
  // print(dp);

  ll kid = v[n];
  // ans[i] = 深さiの頂点数
  vector<int> ans(n+1);
  ans[n] = kid;
  // ans[0] = 1;
  for (int i = n; i >= 1 ; --i) {
    kid = min(dp[i-1], kid+v[i-1]);
    ans[i-1] = kid;
  }
  print(ans);

  // 構築できるかチェック
  bool flag = false;
  for(int i = 0; i <= n; i++){
    res += ans[i];
    ll inner_node = ans[i] - v[i];
    if(inner_node <= 0) flag = true;
  }
  // print(ans);

  if(flag) cout << -1 << endl;
  else cout << res << endl;
}


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

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

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;


int main(){
  int N; cin >> N;
  vector<ll> a(N + 1);
  ll S = 0;
  rep(i, N + 1) {
    cin >> a[i];
    S += a[i];
  }

  ll ans = 0;
  ll f = 1;
  for (int i = 0; i <= N; ++i){
    ans += f;
    if (f < a[i]){
      cout << -1 << endl;
      return 0;
    }
    f -= a[i];
    S -= a[i];
    f *= 2;
    f = min(f, S);
  }
  cut << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:3: error: 'cut' was not declared in this scope
   49 |   cut << ans << endl;
      |   ^~~
Language: C++

#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N + 1);
    rep(i, N + 1) cin >> A[i];
    vector<ll> lim(N + 1);
    rep(i, N + 1) {
        lim[i] = num;
        num -= A[i];
        if(i != N && num <= 0) {
            cout << -1 << endl;
            return 0;
        }
        num = min(num * 2, INF);
    }

    ll cnt = 0;
    ll ans = 0;
    for(int i = N; i >= 0; i--) {
        if(cnt > (lim[i] - A[i]) * 2) {
            cout << -1 << endl;
            return 0;
        }
        if(cnt > lim[i] - A[i]) {
            cnt = lim[i] - A[i];
        }
        cnt += A[i];
        ans += cnt;
    }

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

Compiler output:
a.cc: In function 'int main()':
a.cc:33:18: error: 'num' was not declared in this scope; did you mean 'enum'?
   33 |         lim[i] = num;
      |                  ^~~
      |                  enum
Language: C++

def dfs(i,pre,n,a,ans):
    if (pre*2 < a[i]): return -1
    ans[i] += a[i]
    if (i == n):
        return a[i]

    pre = pre*2 - a[i]
    u = dfs(i+1,pre,n,a,ans);
    if (u<0 or pre*2 < u): return -1;
    ans[i] += min(pre, u)
    return min(pre, u) + a[i]



n = int(input())
a = list(map(int,input().split()))

if (n == 0):
    if (a[0] == 0):
        print(-1)
    else:
        print(1)
    exit()

ans = [1] + [0]*n
u = dfs(1,1,n,a,ans)
if (n!=0 and a[0] != 0): u = -1

if (u >= 0):
    print(sum(ans))
else:
    print(-1)


Compiler output:
a.cc:1:1: error: 'def' does not name a type
    1 | def dfs(i,pre,n,a,ans):
      | ^~~
a.cc:9:5: error: expected unqualified-id before 'if'
    9 |     if (u<0 or pre*2 < u): return -1;
      |     ^~
a.cc:10:5: error: 'ans' does not name a type
   10 |     ans[i] += min(pre, u)
      |     ^~~
Language: C++

#include <iostream>
using namespace std;
 
int main()
{
  int a, result = 1, sum = 0, l = 1;
  cin >> a;
  
  if (a == 0)
  {
    cin >> a
    cout << (a == 1 ? 1 : -1);
    return 0;
  }
  else
  {
    int b[a+1];
    for (int i=0; i<=a; i++)
    {
      cin >> b[i];
    }
    
    if (b[0] != 0)
    {
      cout << -1;
      return 0;
    }
    
    for (int i=0; i<=1; i++)
    {
      if (l*2 < sum)
        l *= 2;
      else
        l = sum;
      
      result += l;
    }

    cout << result;
    return 0;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:13: error: expected ';' before 'cout'
   11 |     cin >> a
      |             ^
      |             ;
   12 |     cout << (a == 1 ? 1 : -1);
      |     ~~~~
Language: C++

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



int main() {

    int N;
    int A[100001];
    cin >> N;
    for (int i = 0; i < N + 1; i++) cin >> A[i];
    //今の深さの点の数
    int now = 1;
    //int mae = 0;
    long long ans = 0;
    //末端の数
    int sum = 0;
    //分岐した回数
    int route = 1;
    
    for (int i = 0; i < N + 1; i++)
    {
        sum += A[i];
    }
    //long long s = sum;
    //cout << sum << endl;
    for (int i = 0; i < N + 1; i++)
    {
        /*
        //cout << now <<route<< endl;
        ans += now;
        //cout << now<< " ";
        now -= A[i];
        sum -= A[i];
        now = min(now * 2, sum);

        //cout << now << endl;
        if (i != N && now <= 0)
        {
            cout << -1 << endl;
            return 0;
        }
        else if (i == N && now != 0)
        {
            cout << -1 << endl;
            return 0;
        }*/
        
        
        ans += now;
        now -= A[i];
        s -= A[i];
        //できるだけ早く分岐しておく
        int  a = now;
        
        //now 2倍ルート
        if (route + a < sum)
        {
            //新しい分岐はa個
            now += a;
            route += a;
        }
        //nowがそれ以降の和になるルート
        else
        {
            //基本的にrouteは1+枝の数
            //ある瞬間のroute-1がそれまでの葉の数と等しければいい
            //分岐した数だけ葉が増える、route+=nはA[i]=nを意味する
            //つまりrouteはそれまでのA[i]の和、route= sum-sumA[i]
            //now-A[i]（分岐＝葉の数）=葉以外の数、
            //葉の枚数＋全部の和-分岐の数（）

            //now=sum-sumA[i-1]なら、

            //新しい分岐はsum-route個
            //（最終的な道の数）ー（今の道の数）をnow（今の道の数）に足して（最終的な道の数）にする
            now += sum - route;
            //now = s;
            route += sum - route;
        }
        //now = min(a * 2, s);

        if (i != N && now <= 0)
        {
            cout << -1 << endl;
            return 0;
        }
        else if (i == N && now != 0)
        {
            cout << -1 << endl;
            return 0;
        }


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

Compiler output:
a.cc: In function 'int main()':
a.cc:52:9: error: 's' was not declared in this scope
   52 |         s -= A[i];
      |         ^
Language: C++

#include <iostream>
using namespace std;

void main()
{
  int a, result = 0, sum = 0;
  cin >> a;
  {
    int b[a+1];
    for (int i=0; i<=a; i++)
    {
      cin >> b[i];
    }
    
    for (int i=a; i>=0; i--)
    {
      if (b[i] > (1 << i))
      {
        cout << -1;
        return;
      }
      
      if (sum + b[i] > (1 << i))
        result += (1 << i);
      else
      {
        sum += b[i];
        result += sum;
      }
    }
    
    cout << result;
  }
}

Compiler output:
a.cc:4:1: error: '::main' must return 'int'
    4 | void main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:20:9: error: return-statement with no value, in function returning 'int' [-fpermissive]
   20 |         return;
      |         ^~~~~~
Language: C++

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

int main(){
    int64_t N,leaf;
    cin >> N;
    int64_t cnt = 0;
    bool judge = true;
    vector<int64_t> ha(N+1);
    vector<int64_t> zyougen(N+1,-1);
    zyougen.at(0) = 1;
    for (int64_t i = 0; i < N+1; i++){
        cin >> ha.at(i);
    }
    if(N == 0){
        if(ha.at(0) == 1){
            cout << 1 << endl;
        }
        else{
            cout << -1 << endl;
        }
        return 0;
    }
    if(ha.at(0) != 0){
        cout << -1 << endl;
        return 0;
    }
    for (int64_t i = 0; i < N+1; i++){
        if(i != N && zyougen.at(i) >= 1e10){
            if(i<N){
                zyougen.at(i+1) = 1e10;
            }
        }
        else if(i != N && zyougen.at(i) >= ha.at(i)){
            if(i<N){
                //zyougen.at(i+1) = zyougen.at(i)*2 - ha.at(i+1);
                zyougen.at(i+1) = (zyougen.at(i)-ha.at(i))*2;
            }
        }
        else if(i == N && zyougen.at(i) >= ha.at(i))
    
        }else{
            //cout << "i" << i << endl;
            judge = false;
            break;
        }
    }
    
    if(judge == true){
        leaf = 0;
        for (int64_t i = N; i >= 0; i--){
            // if(zyougen.at(i) >= ha.at(i)+leaf){
            //     leaf = leaf+ha.at(i);
            // }else{
            //     leaf = zyougen.at(i)+ha.at(i);
            // }
            leaf = min(zyougen.at(i),leaf+ha.at(i));
            
            cnt += leaf;
        }
    }
    if(judge == false){
        cout << -1 << endl;
    }else{
        cout << cnt << endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:9: error: expected primary-expression before '}' token
   42 |         }else{
      |         ^
a.cc:42:10: error: 'else' without a previous 'if'
   42 |         }else{
      |          ^~~~
a.cc:45:13: error: break statement not within loop or switch
   45 |             break;
      |             ^~~~~
a.cc: At global scope:
a.cc:49:5: error: expected unqualified-id before 'if'
   49 |     if(judge == true){
      |     ^~
a.cc:62:5: error: expected unqualified-id before 'if'
   62 |     if(judge == false){
      |     ^~
a.cc:64:6: error: expected unqualified-id before 'else'
   64 |     }else{
      |      ^~~~
a.cc:67:5: error: expected unqualified-id before 'return'
   67 |     return 0;
      |     ^~~~~~
a.cc:68:1: error: expected declaration before '}' token
   68 | }
      | ^
Language: C++

#include <iostream>

using namespace std;

int main()
{
  int n;
  int *a;
  long int *b;
  
  cin >> n;
  a = (int*)malloc(( n + 1 ) * sizeof( int ));
  b = (long int*)malloc(( n + 1 ) * sizeof( long int ));
  for ( int i = 0 ; i <= n ; ++i ) {
    cin >> a[i];
  }
  
  if ( 1 <= n && 1 <= a[0] ) {
    cout << -1 << endl;
    return 0;
  }
  b[0] = 1 - a[0];
  long int total_a = 0;
  for ( int i = 2 ; i <= n ; ++i ) {
    total_a += a[i];
  }
  for ( int i = 1 ; i <= n ; ++i ) {
    int tmp_b = 2 * b[i - 1] - a[i];
    tmp_b = min( tmp_b, total_a );
    if ( tmp_b < b[i - 1] - a[i] ) {
      cout << -1 << endl;
      return 0;
    }
    b[i] = tmp_b;
    total_a -= a[i + 1];
  }
  
  long int total = 0;
  for ( int i = 0 ; i <= n ; ++i ) {
    total += a[i] + b[i];
  }
  cout << total << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:16: error: no matching function for call to 'min(int&, long int&)'
   29 |     tmp_b = min( tmp_b, total_a );
      |             ~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:29:16: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long int')
   29 |     tmp_b = min( tmp_b, total_a );
      |             ~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
Language: C++

#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};


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

    ll n;
    cin >> n;
    vector<ll> a(n+1);
    rep(i,n+1){
        cin >> a[i];
    }
    auto tmp = a;
    for(ll i = n;i > 0;--i){
        tmp[i-1] += (tmp[i]+1)/2;
    }
    if(tmp[0] >= 2) {
        cout << -1 << endl;
        return 0;
    }
    vector<ll> max(n+1,1);
    for(ll i = 1;i <= n;++i){
        max[i] = (2*max[i-1])-a[i];
    }
    ll ans = 0;
    int flag = 0;
    ll t;
    for(ll i = n;i > 0;--i){
        if(flag){
            ans += max[i] + a[i];
        }
        else if(a[i] <= max[i-1]){
            ans += a[i];
            a[i-1] += a[i];
        }else {
            ans += a[i];
            flag = 1;
            t = (a[i]+1)/2
        }
    }
    ans++;
    cout << ans << endl;
    cout << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:51:27: error: expected ';' before '}' token
   51 |             t = (a[i]+1)/2
      |                           ^
      |                           ;
   52 |         }
      |         ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 5;
const int INF = 1e9;

ll n, a[MAXN], b[MAXN];
int main(){
    cin >> n;
    for(int i = 0; i <= n; i++) cin >> a[i];
    int f = a[0] == 0;
    b[0] = 1;
    for(int i = 1; i <= n; i++){
        b[i] = min(INF, b[i-1] * 2 - a[i]);
        f &= b[i] >= 0;
    }
    if(!f){ cout << -1; return 0; }
    b[n] = 0;
    ll ans = a[n];
    for(int i = n - 1; ~i; i--){
        b[i] = min(b[i], b[i+1] + a[i+1]);
        ans += a[i] + b[i];
    }
    cout << ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:19: error: no matching function for call to 'min(const int&, ll)'
   14 |         b[i] = min(INF, b[i-1] * 2 - a[i]);
      |                ~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:14:19: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   14 |         b[i] = min(INF, b[i-1] * 2 - a[i]);
      |                ~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:14:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   14 |         b[i] = min(INF, b[i-1] * 2 - a[i]);
      |                ~~~^~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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

int main(){
    int64_t N,leaf;
    cin >> N;
    int64_t cnt = 0;
    bool judge = true;
    vector<int64_t> ha(N+1);
    vector<int64_t> zyougen(N+1,-1);
    zyougen.at(0) = 1;
    for (int64_t i = 0; i < N+1; i++){
        cin >> ha.at(i);
    }
    if(N == 0){
        if(ha.at(0) == 1){
            cout << 1 << endl;
        }
        else{
            cout << -1 << endl;
        }
        return 0;
    }
    if(ha.at(0) != 0){
        cout << -1 << endl;
        return 0;
    }
    for (int64_t i = 0; i < N+1; i++){
        if(i != N && zyougen.at(i) >= 1e10){
            if(i<N){
                zyougen.at(i+1) = 1e10;
            }
        }
        else if(i != N && zyougen.at(i) >= ha.at(i)){
            if(i<N){
                //zyougen.at(i+1) = zyougen.at(i)*2 - ha.at(i+1);
                zyougen.at(i+1) = (zyougen.at(i)-ha.at(i))*2;
            }
        }
        // else if(i == N && zyougen.at(i) >= 0){
        //     zyougen.at(i) = zyougen.at(i-1)*2;
        }else{
            //cout << "i" << i << endl;
            judge = false;
            break;
        }
    }
    // for (int64_t i = 0; i < N+1; i++){
    //     cout << zyougen.at(i) << endl;
    // }
    // cout << "==========" << endl;
    if(judge == true){
        leaf = 0;
        for (int64_t i = N; i >= 0; i--){
            // if(zyougen.at(i) >= ha.at(i)+leaf){
            //     leaf = leaf+ha.at(i);
            // }else{
            //     leaf = zyougen.at(i)+ha.at(i);
            // }
            leaf = min(zyougen.at(i),leaf+ha.at(i));
            //cout << leaf << endl;
            cnt += leaf;
        }
    }
    if(judge == false){
        cout << -1 << endl;
    }else{
        cout << cnt << endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:10: error: 'else' without a previous 'if'
   42 |         }else{
      |          ^~~~
a.cc:45:13: error: break statement not within loop or switch
   45 |             break;
      |             ^~~~~
a.cc: At global scope:
a.cc:52:5: error: expected unqualified-id before 'if'
   52 |     if(judge == true){
      |     ^~
a.cc:65:5: error: expected unqualified-id before 'if'
   65 |     if(judge == false){
      |     ^~
a.cc:67:6: error: expected unqualified-id before 'else'
   67 |     }else{
      |      ^~~~
a.cc:70:5: error: expected unqualified-id before 'return'
   70 |     return 0;
      |     ^~~~~~
a.cc:71:1: error: expected declaration before '}' token
   71 | }
      | ^
Language: C++

#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
 
ll n,k,x,y;
 
int main(){
  ll ans=0;
  cin >> n ;
  vi a(n+1),b(n+1),c(n+1),d(n+1);
  REP(i,n+1) cin>>a[i];
 
 
  if (a[0]!=0){
    if (n!=0){
      cout<<-1<<endl;
      return 0;
    }else{
      cout<<1<<endl;
      return 0;
    }
  }
 
 
 
  d[n]=a[n];
  for(ll i=n-1;i>=0;i--){
    d[i]=d[i+1]+a[i];
  }
 
  
  ll nown=1;
  b[0]=1;
  c[1]=1;
  for(ll i=1;i<n+1;i++){
    nown=min(nown,llMAX/2)*2;
    b[i]=nown;
    nown-=a[i];
    c[i]=nown;
    //この時点のnownとしたから数えたやつを比較
    if (b[i]>d[i]){
      b[i]=d[i];
      c[i]=d[i]-a[i];
      for(ll j=i+1;j<n+1;j++){
        b[j]=d[j];
      }
    }
 
  }
 
 
 
  int flag=0;
  for(ll i=0;i<n+1;i++){
    ans+=b[i];
    flag+=(b[i]<0);
    flag+=(c[i]<0);
  }
  if (flag!=0){
    cout<<-1<<endl;
    return 0;
  }
 
 
 
  cout<<ans<<endl;
  return 0;
}
 
/*
10
0 0 1 1 2 3 5 8 28 21 34
*/

Compiler output:
a.cc: In function 'int main()':
a.cc:42:13: error: no matching function for call to 'min(long long int&, long int)'
   42 |     nown=min(nown,llMAX/2)*2;
      |          ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:42:13: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long int')
   42 |     nown=min(nown,llMAX/2)*2;
      |          ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:42:13: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   42 |     nown=min(nown,llMAX/2)*2;
      |          ~~~^~~~~~~~~~~~~~
Language: C++

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N; std::cin >> N; 
  std::vector<int64_t> A(N+1), B(N+1); 
  for(int i = 0; i <= N; ++i) std::cin >> A[i];
  B[N] = 0;
  for(int i = N-1; i >= 0; --i) B[i] = B[i+1]+A[i+1];
  B[0] = 1 - A[0];
  for(int i = 0; i < N; ++i) {
    // B[i+1] <= 2B[i] - A[i+1]
    B[i+1] = std::min(B[i+1], B[i]*2-A[i+1]);
    if(B[i+1] < 0) fin(-1);
  }
  int64_t ans = 0;
  for(int i = 0; i <= N; ++i) ans += A[i]+B[i];
  fin(ans);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:2:8: error: 'cin' is not a member of 'std'
    2 |   std::cin.tie(0); std::ios::sync_with_stdio(false);
      |        ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | int main() {
a.cc:2:25: error: 'std::ios' has not been declared
    2 |   std::cin.tie(0); std::ios::sync_with_stdio(false);
      |                         ^~~
a.cc:3:15: error: 'cin' is not a member of 'std'
    3 |   int N; std::cin >> N;
      |               ^~~
a.cc:3:15: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:4:8: error: 'vector' is not a member of 'std'
    4 |   std::vector<int64_t> A(N+1), B(N+1);
      |        ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | int main() {
a.cc:4:15: error: 'int64_t' was not declared in this scope
    4 |   std::vector<int64_t> A(N+1), B(N+1);
      |               ^~~~~~~
a.cc:1:1: note: 'int64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
  +++ |+#include <cstdint>
    1 | int main() {
a.cc:4:24: error: 'A' was not declared in this scope
    4 |   std::vector<int64_t> A(N+1), B(N+1);
      |                        ^
a.cc:4:32: error: 'B' was not declared in this scope
    4 |   std::vector<int64_t> A(N+1), B(N+1);
      |                                ^
a.cc:5:36: error: 'cin' is not a member of 'std'
    5 |   for(int i = 0; i <= N; ++i) std::cin >> A[i];
      |                                    ^~~
a.cc:5:36: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:11:19: error: 'min' is not a member of 'std'
   11 |     B[i+1] = std::min(B[i+1], B[i]*2-A[i+1]);
      |                   ^~~
a.cc:12:20: error: 'fin' was not declared in this scope
   12 |     if(B[i+1] < 0) fin(-1);
      |                    ^~~
a.cc:14:10: error: expected ';' before 'ans'
   14 |   int64_t ans = 0;
      |          ^~~~
      |          ;
a.cc:15:31: error: 'ans' was not declared in this scope
   15 |   for(int i = 0; i <= N; ++i) ans += A[i]+B[i];
      |                               ^~~
a.cc:16:7: error: 'ans' was not declared in this scope
   16 |   fin(ans);
      |       ^~~
a.cc:16:3: error: 'fin' was not declared in this scope
   16 |   fin(ans);
      |   ^~~
Language: C++

#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<map>
#include <bits/stdc++.h>
typedef long long ll;
#define N 100010
using namespace std;
int a[N];
int solve()
{
	ll n;
	ll add;
	cin>>n;
	ll ans;
	for (int i=0;i<=n;i++) 
	{
		cin>>a[i];
		add+=a[i];
	}
	ll now;
	if (n==0)
	{
		if (a[i]==1)
			return 1;
		else
			return -1;
	}
   else
   {
        if(a[0]!=0)
            return -1;
   }
   for (int i=0;i<=n;i++)
	{
		now=min(ll(1<<i),add);
		ans+=now; 
		now-=a[i];
		add-=a[i];
		if (now<0)
			return -1;
	}
	if (now!=0)
		return -1;
	return ans;
}

int main() 
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
//	int t;
//	cin>>t;
//	while (t--) 
		cout<<solve()<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int solve()':
a.cc:25:23: error: 'i' was not declared in this scope
   25 |                 if (a[i]==1)
      |                       ^
Language: C++

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

#define DUMP(x) cout << #x << " = " << (x) << endl;
#define REP(i, n) for((ll)i = 0; i < (n); i++)
#define REPR(i, n) for((ll)i = (n); i >= 0; i--)
#define FOR(i, a, b) for((ll)i = (a); i < (b); i++)
#define FOREACH(x, a) for(auto& (x) : (a))

const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    ll N; cin >> N;
    ll A[N + 1];            // 各depthにおける葉の数を表す
    ll B[N + 1];            // 各depthにおける頂点の最大数を表す 
    bool is_exist = true;   // 条件を満たす二分木が存在するか
    REP(i, N + 1) {
        cin >> A[i];
        if (i == 0) {
            B[i] = 1 - A[i]; 
        } else {
            B[i] = (B[i - 1] - A[i - 1]) * 2;
        }
        if (B[i] <= 0) is_exist = false;
    }

    ll ans;
    if (!is_exist) {
        ans = -1;
    } else {
        ans = 0;
        ll v = 0;
        for(ll i = N; i >= 0; i--) {
            v += A[i];
            if (v > B[i]) v = B[i];
            ans += v;
        }
    }
    cout << ans << "\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:9: error: 'i' was not declared in this scope
   25 |     REP(i, N + 1) {
      |         ^
a.cc:7:27: note: in definition of macro 'REP'
    7 | #define REP(i, n) for((ll)i = 0; i < (n); i++)
      |                           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
// __uint128_t

int main(){
    ll N; cin >> N;
    ll SUM = 0;
    vector<ll> C(N+1); for(int i = 0; i < N+1; i++) cin >> C[i];
    if(C[0] > 0) {cout << -1 << endl; return 0;}
    vector<ll> P(N+1); P[N] = 0, P[N-1] = C[N];
    
    for(int i = N-1; i >= 0; i--){
        P[i] = C[i+1] + P[i+1];
    }


    ll temp = 1;
    for(int i = 0; i <= N-1; i++){
        P[i] = min(temp - C[i], P[i]); temp = 2*P[i];
        if((i <= N && P[i] <　0) || temp <= -1) {cout << -1 << endl;return 0;}

    }
    for(int i = 0; i < N+1; i++) SUM += C[i]+P[i];
    cout << SUM << endl;
}

Compiler output:
a.cc:22:29: error: extended character 　 is not valid in an identifier
   22 |         if((i <= N && P[i] <　0) || temp <= -1) {cout << -1 << endl;return 0;}
      |                             ^
a.cc: In function 'int main()':
a.cc:22:29: error: '\U000030000' was not declared in this scope
   22 |         if((i <= N && P[i] <　0) || temp <= -1) {cout << -1 << endl;return 0;}
      |                             ^~~
Language: C++

#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
     int a[n+1];
     int maxi[n+1];
     maxi[0] = 1;
     for (int i=0;i<n+1;i++)
        {
            cin>>a[i];
            if(i != 0)
              maxi[i] = maxi[i-1]*2 - a[i-1]*2;
        }
    int par = a[n];
    int sum =0;
     for(int i=n;i>0;i--)
     {
         if(a[i] >pow(2,i)|| maxi[i]<a[i])
         {
             printf("-1");
              return 0;
         }
         else
         {
             sum = sum+par;
             if(par+a[i-1]< maxi[i-1])
                par = par+a[i-1];
             else
                 {
                     par = maxi[i-1]
                 }

         }
     }
   printf("%d",sum+1);
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:37: error: expected ';' before '}' token
   36 |                      par = maxi[i-1]
      |                                     ^
      |                                     ;
   37 |                  }
      |                  ~