Language: C++

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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 

int main(){
    int n;
    cin >> n
    vector<int> a(n);
    REP(i, n) cin >> a[i];
 
 int ans1;
    // +-+-の場合
    if(n.at(0) <= 0) a[i] = a[i] + abs(1 - a[i]);
        for(int i = 0; i < N; i++){
            if(i % 2 == 0){
                if(a[i] + a[i + 1] >= 0 ){
                    ans1 += -1 - a[i];
                    a[i] + a[i + 1] = a[i] + (-1 - a[i]);
                }
            }else if(i % 2 == 1){
                if(a[i] + a[i + 1] >= 0){
                    ans1 += abs(1 - a[i]);
                    a[i] + a[i + 1] = a[i] + abs(1 - a[i]);
                }
            }
        }
 int ans2;
     if(n.at(0) <= 0) a[i] = a[i] + abs(1 - a[i]);
        for(int i = 0; i < N; i++){
                if(a[i] + a[i + 1] >= 0){
                    ans2 += abs(1 - a[i]);
                    a[i] + a[i + 1] = a[i] + abs(1 - a[i]);
 
            }else if(i % 2 == 1){
            if(i % 2 == 0){
                if(a[i] + a[i + 1] >= 0 ){
                    ans2 += -1 - a[i];
                    a[i] + a[i + 1] = a[i] + (-1 - a[i]);
                }
            }
            }
        }       
// +-+-の場合
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:13: error: expected ';' before 'vector'
   38 |     cin >> n
      |             ^
      |             ;
   39 |     vector<int> a(n);
      |     ~~~~~~   
a.cc:40:22: error: 'a' was not declared in this scope
   40 |     REP(i, n) cin >> a[i];
      |                      ^
a.cc:44:10: error: request for member 'at' in 'n', which is of non-class type 'int'
   44 |     if(n.at(0) <= 0) a[i] = a[i] + abs(1 - a[i]);
      |          ^~
a.cc:44:22: error: 'a' was not declared in this scope
   44 |     if(n.at(0) <= 0) a[i] = a[i] + abs(1 - a[i]);
      |                      ^
a.cc:44:24: error: 'i' was not declared in this scope
   44 |     if(n.at(0) <= 0) a[i] = a[i] + abs(1 - a[i]);
      |                        ^
a.cc:45:28: error: 'N' was not declared in this scope
   45 |         for(int i = 0; i < N; i++){
      |                            ^
a.cc:47:20: error: 'a' was not declared in this scope
   47 |                 if(a[i] + a[i + 1] >= 0 ){
      |                    ^
a.cc:52:20: error: 'a' was not declared in this scope
   52 |                 if(a[i] + a[i + 1] >= 0){
      |                    ^
a.cc:59:11: error: request for member 'at' in 'n', which is of non-class type 'int'
   59 |      if(n.at(0) <= 0) a[i] = a[i] + abs(1 - a[i]);
      |           ^~
a.cc:59:23: error: 'a' was not declared in this scope
   59 |      if(n.at(0) <= 0) a[i] = a[i] + abs(1 - a[i]);
      |                       ^
a.cc:59:25: error: 'i' was not declared in this scope
   59 |      if(n.at(0) <= 0) a[i] = a[i] + abs(1 - a[i]);
      |                         ^
a.cc:60:28: error: 'N' was not declared in this scope
   60 |         for(int i = 0; i < N; i++){
      |                            ^
a.cc:61:20: error: 'a' was not declared in this scope
   61 |                 if(a[i] + a[i + 1] >= 0){
      |                    ^