Language: C++

#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#define ll long long
using namespace std;
int main(){
  int n;
  
cin>>n;
  vector<ll>a(n);
  vector<ll>sum();
  for(int i=0;i<n;i++){
  cin>>a[i];
    
  sum[i]=(i==0?a[i]:sum[i-1]+a[i]);
  }
   ll max=1111111111111;
  for(int i=0;i<n;i++){
  max=min(max,abs(sum[i]-(sum[n-1]-sum[i])));
  }
  cout<<max<<endl;
return 0;  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:1: error: 'cin' was not declared in this scope
   10 | cin>>n;
      | ^~~
a.cc:5:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    4 | #include <cmath>
  +++ |+#include <iostream>
    5 | #define ll long long
a.cc:12:16: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   12 |   vector<ll>sum();
      |                ^~
a.cc:12:16: note: remove parentheses to default-initialize a variable
   12 |   vector<ll>sum();
      |                ^~
      |                --
a.cc:16:8: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   16 |   sum[i]=(i==0?a[i]:sum[i-1]+a[i]);
      |        ^
a.cc:16:28: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   16 |   sum[i]=(i==0?a[i]:sum[i-1]+a[i]);
      |                            ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:16:29: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   16 |   sum[i]=(i==0?a[i]:sum[i-1]+a[i]);
a.cc:16:15: error: operands to '?:' have different types '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} and 'std::vector<long long int> (*)()'
   16 |   sum[i]=(i==0?a[i]:sum[i-1]+a[i]);
a.cc:20:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   20 |   max=min(max,abs(sum[i]-(sum[n-1]-sum[i])));
      |                        ^
a.cc:20:34: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   20 |   max=min(max,abs(sum[i]-(sum[n-1]-sum[i])));
      |                                  ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:20:41: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   20 |   max=min(max,abs(sum[i]-(sum[n-1]-sum[i])));
      |                                         ^
a.cc:20:35: error: ISO C++ forbids using pointer to a function in subtraction [-fpermissive]
   20 |   max=min(max,abs(sum[i]-(sum[n-1]-sum[i])));
      |                           ~~~~~~~~^~~~~~~
a.cc:20:25: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   20 |   max=min(max,abs(sum[i]-(sum[n-1]-sum[i])));
      |                   ~~~~~~^~~~~~~~~~~~~~~~~~
a.cc:20:18: error: no matching function for call to 'abs(std::vector<long long int> (*)())'
   20 |   max=min(max,abs(sum[i]-(sum[n-1]-sum[i])));
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/c++/14/bits/stl_algo.h:71,
                 from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)' (near match)
  980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
/usr/include/stdlib.h:980:12: note:   conversion of argument 1 would be ill-formed:
a.cc:20:25: error: invalid conversion from 'std::vector<long long int> (*)()' to 'int' [-fpermissive]
   20 |   max=min(max,abs(sum[i]-(sum[n-1]-sum[i])));
      |                   ~~~~~~^~~~~~~~~~~~~~~~~~
      |                         |
      |                         std::vector<long long int> (*)()
In file included from /usr/include/c++/14/cstdlib:81:
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)' (near match)
   85 |   abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note:   conversion of argument 1 would be ill-formed:
a.cc:20:25: error: invalid conversion from 'std::vector<long long int> (*)()' to '__int128' [-fpermissive]
   20 |   max=min(max,abs(sum[i]-(sum[n-1]-sum[i])));
      |                   ~~~~~~^~~~~~~~~~~~~~~~~~
      |                         |
      |                         std::vector<long long int> (*)()
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)' (near match)
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note:   conversion of argument 1 would be ill-formed:
a.cc:20:25: error: invalid conversion from 'std::vector<long long int> (*)()' to 'long long int' [-fpermissive]
   20 |   max=min(max,abs(sum[i]-(sum[n-1]-sum[i])));
      |                   ~~~~~~^~~~~~~~~~~~~~~~~~
      |                         |
      |                         std::vector<long long int> (*)()
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)' (near match)
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note:   conversion of argument 1 would be ill-formed:
a.cc:20:25: error: invalid conversion from 'std::vector<long long int> (*)()' to 'long int' [-fpermissive]
   20 |   max=min(max,abs(sum[i]-(sum[n-1]-sum[i])));
      |                   ~~~~~~^~~~~~~~~~~~~~~~~~
      |                         |
      |                         std::vector<long long int> (*)()
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
  137 |   abs(__float128 __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:137:18: note:   no known conversion for argument 1 from 'std::vector<long long int> (*)()' to '__float128'
  137 |   abs(__float128 __x)
      |       ~~~~~~~~~~~^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:79:19: note:   no known conversion for argument 1 from 'std::vector<long long int> (*)()' to 'long double'
   79 |   abs(long double __x)
      |       ~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:75:13: note:   no known conversion for argument 1 from 'std::vector<long long int> (*)()' to 'float'
   75 |   abs(float __x)
      |       ~~~~~~^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:71:14: note:   no known conversion for argument 1 from 'std::vector<long long int> (*)()' to 'double'
   71 |   abs(double __x)
      |       ~~~~~~~^~~
a.cc:22:3: error: 'cout' was not declared in this scope
   22 |   cout<<max<<endl;
      |   ^~~~
a.cc:22:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:22:14: error: 'endl' was not declared in this scope
   22 |   cout<<max<<endl;
      |              ^~~~
a.cc:5:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    4 | #include <cmath>
  +++ |+#include <ostream>
    5 | #define ll long long