Language: C++

//#include<unordered_map>//イテレータあるけど順序保持しないmap
//#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加
//メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI acos(-1.0)
#define answer(ans) cout<<ans<<endl;
 
signed main() {
int N,ans=0;
cin >> N;
vector<int> A(N+1),NeedRNode(N,0),MaxRNode(N,0),Node(N+1,1);
REP(i,N+1) cin >> A[i];
for(int j=N ; 0<j ; j--){
Node[j] = NeedRNode[j] + A[j];
NeedRNode[j-1] = (Node[j] +Node[j]%2)/2;
MaxRNode[j-1] =MaxRNode[j] + A[j];
}
if(NeedRNode[0] != 1||A[0]!=0 ) {
ans = -1;
answer(ans);
return 0;
}
vector<int> RNode(N+2,1);
REP(i,N+1){
    if(2*RNode[i]-A[i+1] <=MaxRNode[i+1]){
        RNode[i+1] = 2*RNode[i] - A[i+1];
    }
    else {
        RNode[i+1] = MaxRNode[i+1];
    }

}

for(int k=0;k<N+1;k++){
    ans += RNode[k]+A[k];
    answer(RNode[k]);
}
answer(ans);

}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:1: error: 'cin' was not declared in this scope
   37 | cin >> N;
      | ^~~
a.cc:6:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    5 | #include<valarray>//なんとなく追加
  +++ |+#include <iostream>
    6 | //メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
a.cc:33:21: error: 'cout' was not declared in this scope
   33 | #define answer(ans) cout<<ans<<endl;
      |                     ^~~~
a.cc:47:1: note: in expansion of macro 'answer'
   47 | answer(ans);
      | ^~~~~~
a.cc:33:21: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
   33 | #define answer(ans) cout<<ans<<endl;
      |                     ^~~~
a.cc:47:1: note: in expansion of macro 'answer'
   47 | answer(ans);
      | ^~~~~~
a.cc:33:32: error: 'endl' was not declared in this scope
   33 | #define answer(ans) cout<<ans<<endl;
      |                                ^~~~
a.cc:47:1: note: in expansion of macro 'answer'
   47 | answer(ans);
      | ^~~~~~
a.cc:6:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    5 | #include<valarray>//なんとなく追加
  +++ |+#include <ostream>
    6 | //メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
a.cc:33:21: error: 'cout' was not declared in this scope
   33 | #define answer(ans) cout<<ans<<endl;
      |                     ^~~~
a.cc:63:5: note: in expansion of macro 'answer'
   63 |     answer(RNode[k]);
      |     ^~~~~~
a.cc:33:21: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
   33 | #define answer(ans) cout<<ans<<endl;
      |                     ^~~~
a.cc:63:5: note: in expansion of macro 'answer'
   63 |     answer(RNode[k]);
      |     ^~~~~~
a.cc:33:32: error: 'endl' was not declared in this scope
   33 | #define answer(ans) cout<<ans<<endl;
      |                                ^~~~
a.cc:63:5: note: in expansion of macro 'answer'
   63 |     answer(RNode[k]);
      |     ^~~~~~
a.cc:33:32: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
   33 | #define answer(ans) cout<<ans<<endl;
      |                                ^~~~
a.cc:63:5: note: in expansion of macro 'answer'
   63 |     answer(RNode[k]);
      |     ^~~~~~
a.cc:33:21: error: 'cout' was not declared in this scope
   33 | #define answer(ans) cout<<ans<<endl;
      |                     ^~~~
a.cc:65:1: note: in expansion of macro 'answer'
   65 | answer(ans);
      | ^~~~~~
a.cc:33:21: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
   33 | #define answer(ans) cout<<ans<<endl;
      |                     ^~~~
a.cc:65:1: note: in expansion of macro 'answer'
   65 | answer(ans);
      | ^~~~~~
a.cc:33:32: error: 'endl' was not declared in this scope
   33 | #define answer(ans) cout<<ans<<endl;
      |                                ^~~~
a.cc:65:1: note: in expansion of macro 'answer'
   65 | answer(ans);
      | ^~~~~~
a.cc:33:32: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
   33 | #define answer(ans) cout<<ans<<endl;
      |                                ^~~~
a.cc:65:1: note: in expansion of macro 'answer'
   65 | answer(ans);
      | ^~~~~~