Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define int long long;

int main() {
  int N; cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  
  int ans = 0;
  int L = 0;
  rep(i, N) L += A[i];
  
  int m = 0;
  int M = 0;
  rep(i, N) {
    if(m < L/2) m += A[i];
    if(m == L/2) {
      cout << 0 << endl;
      return 0;
    }
    if(m > L/2) {
      M = m;
      m -= A[i];
      break;
    }
  }
  
  ans = 1+min((L+1)/2-m, M-(L-1)/2);
  
  cout << ans <<endl;
}

Compiler output:
a.cc:4:18: error: declaration does not declare anything [-fpermissive]
    4 | #define int long long;
      |                  ^~~~
a.cc:6:1: note: in expansion of macro 'int'
    6 | int main() {
      | ^~~
a.cc:6:5: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | int main() {
      |     ^~~~
a.cc: In function 'int main()':
a.cc:4:18: error: declaration does not declare anything [-fpermissive]
    4 | #define int long long;
      |                  ^~~~
a.cc:7:3: note: in expansion of macro 'int'
    7 |   int N; cin >> N;
      |   ^~~
a.cc:7:7: error: 'N' was not declared in this scope
    7 |   int N; cin >> N;
      |       ^
a.cc:4:18: error: template argument 1 is invalid
    4 | #define int long long;
      |                  ^~~~
a.cc:8:10: note: in expansion of macro 'int'
    8 |   vector<int> A(N);
      |          ^~~
a.cc:4:18: error: template argument 2 is invalid
    4 | #define int long long;
      |                  ^~~~
a.cc:8:10: note: in expansion of macro 'int'
    8 |   vector<int> A(N);
      |          ^~~
a.cc:8:13: error: expected primary-expression before '>' token
    8 |   vector<int> A(N);
      |             ^
a.cc:8:15: error: 'A' was not declared in this scope
    8 |   vector<int> A(N);
      |               ^
a.cc:4:18: error: declaration does not declare anything [-fpermissive]
    4 | #define int long long;
      |                  ^~~~
a.cc:3:24: note: in expansion of macro 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                        ^~~
a.cc:9:3: note: in expansion of macro 'rep'
    9 |   rep(i, N) cin >> A[i];
      |   ^~~
a.cc:9:7: error: 'i' was not declared in this scope
    9 |   rep(i, N) cin >> A[i];
      |       ^
a.cc:3:28: note: in definition of macro 'rep'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                            ^
a.cc:4:13: error: expected primary-expression before 'long'
    4 | #define int long long;
      |             ^~~~
a.cc:3:40: note: in expansion of macro 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                        ^~~
a.cc:9:3: note: in expansion of macro 'rep'
    9 |   rep(i, N) cin >> A[i];
      |   ^~~
a.cc:4:13: error: expected ')' before 'long'
    4 | #define int long long;
      |             ^~~~
a.cc:3:40: note: in expansion of macro 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                        ^~~
a.cc:9:3: note: in expansion of macro 'rep'
    9 |   rep(i, N) cin >> A[i];
      |   ^~~
a.cc:3:39: note: to match this '('
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                       ^
a.cc:9:3: note: in expansion of macro 'rep'
    9 |   rep(i, N) cin >> A[i];
      |   ^~~
a.cc:4:22: error: expected ')' before ';' token
    4 | #define int long long;
      |                      ^
a.cc:3:40: note: in expansion of macro 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                        ^~~
a.cc:9:3: note: in expansion of macro 'rep'
    9 |   rep(i, N) cin >> A[i];
      |   ^~~
a.cc:3:23: note: to match this '('
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                       ^
a.cc:9:3: note: in expansion of macro 'rep'
    9 |   rep(i, N) cin >> A[i];
      |   ^~~
a.cc:3:43: error: expected primary-expression before ')' token
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                           ^
a.cc:9:3: note: in expansion of macro 'rep'
    9 |   rep(i, N) cin >> A[i];
      |   ^~~
a.cc:9:7: error: 'i' was not declared in this scope
    9 |   rep(i, N) cin >> A[i];
      |       ^
a.cc:3:49: note: in definition of macro 'rep'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                                 ^
a.cc:4:18: error: declaration does not declare anything [-fpermissive]
    4 | #define int long long;
      |                  ^~~~
a.cc:11:3: note: in expansion of macro 'int'
   11 |   int ans = 0;
      |   ^~~
a.cc:11:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   11 |   int ans = 0;
      |       ^~~
      |       abs
a.cc:4:18: error: declaration does not declare anything [-fpermissive]
    4 | #define int long long;
      |                  ^~~~
a.cc:12:3: note: in expansion of macro 'int'
   12 |   int L = 0;
      |   ^~~
a.cc:12:7: error: 'L' was not declared in this scope
   12 |   int L = 0;
      |       ^
a.cc:4:18: error: declaration does not declare anything [-fpermissive]
    4 | #define int long long;
      |                  ^~~~
a.cc:3:24: note: in expansion of macro 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                        ^~~
a.cc:13:3: note: in expansion of macro 'rep'
   13 |   rep(i, N) L += A[i];
      |   ^~~
a.cc:4:13: error: expected primary-expression before 'long'
    4 | #define int long long;
      |             ^~~~
a.cc:3:40: note: in expansion of macro 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                        ^~~
a.cc:13:3: note: in expansion of macro 'rep'
   13 |   rep(i, N) L += A[i];
      |   ^~~
a.cc:4:13: error: expected ')' before 'long'
    4 | #define int long long;
      |             ^~~~
a.cc:3:40: note: in expansion of macro 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                        ^~~
a.cc:13:3: note: in expansion of macro 'rep'
   13 |   rep(i, N) L += A[i];
      |   ^~~
a.cc:3:39: note: to match this '('
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                       ^
a.cc:13:3: note: in expansion of macro 'rep'
   13 |   rep(i, N) L += A[i];
      |   ^~~
a.cc:4:22: error: expected ')' before ';' token
    4 | #define int long long;
      |                      ^
a.cc:3:40: note: in expansion of macro 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                        ^~~
a.cc:13:3: note: in expansion of macro 'rep'
   13 |   rep(i, N) L += A[i];
      |   ^~~
a.cc:3:23: note: to match this '('
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                       ^
a.cc:13:3: note: in expansion of macro 'rep'
   13 |   rep(i, N) L += A[i];
      |   ^~~
a.cc:3:43: error: expected primary-expression before ')' token
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                           ^
a.cc:13:3: note: in expansion of macro 'rep'
   13 |   rep(i, N) L += A[i];
      |   ^~~
a.cc:4:18: error: declaration does not declare anything [-fpermissive]
    4 | #define int long long;
      |                  ^~~~
a.cc:15:3: note: in expansion of macro 'int'
   15 |   int m = 0;
      |   ^~~
a.cc:15:7: error: 'm' was not declared in this scope; did you mean 'tm'?
   15 |   int m = 0;
      |       ^
      |       tm
a.cc:4:18: error: declaration does not declare anything [-fpermissive]
    4 | #define int long long;
      |                  ^~~~
a.cc:16:3: note: in expansion of macro 'int'
   16 |   int M = 0;
      |   ^~~
a.cc:16:7: error: 'M' was not declared in this scope
   16 |   int M = 0;
      |       ^
a.cc:4:18: error: declaration does not declare anything [-fpermissive]
    4 | #define int long long;
      |                  ^~~~
a.cc:3:24: note: in expansion of macro 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                        ^~~
a.cc:17:3: note: in expansion of macro 'rep'
   17 |   rep(i, N) {
      |   ^~~
a.cc:4:13: error: expected primary-expression before 'long'
    4 | #define int long long;
      |             ^~~~
a.cc:3:40: note: in expansion of macro 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                        ^~~
a.cc:17:3: note: in expansion of macro 'rep'
   17 |   rep(i, N) {
      |   ^~~
a.cc:4:13: error: expected ')' before 'long'
    4 | #define int long long;
      |             ^~~~
a.cc:3:40: note: in expansion of macro 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                        ^~~
a.cc:17:3: note: in expansion of macro 'rep'
   17 |   rep(i, N) {
      |   ^~~
a.cc:3:39: note: to match this '('
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                       ^
a.cc:17:3: note: in expansion of macro 'rep'
   17 |   rep(i, N) {
      |   ^~~
a.cc:4:22: error: expected ')' before ';' token
    4 | #define int long long;
      |                      ^
a.cc:3:40: note: in expansion of macro 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                        ^~~
a.cc:17:3: note: in expansion of macro 'rep'
   17 |   rep(i, N) {
      |   ^~~
a.cc:3:23: note: to match this '('
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                       ^
a.cc:17:3: note: in expansion of macro 'rep'
   17 |   rep(i, N) {
      |   ^~~
a.cc:3:43: error: expected primary-expression before ')' token
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                           ^
a.cc:17:3: note: in expansion of macro 'rep'
   17 |   rep(i, N) {
      |   ^~~