Language: C++

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

int main(){
  int n,min,count=0,countmin=0,countmax=0,k=0,l;
  cin >> n;
  vector<int> w(n),sa(n-1);
  rep(i,n){
    cin >>w[i];
  }
  rep(i,n){
    count+=w[i];
  }
  rep(i,n-1){
    rep1(j,i+1;n){
      countmax+=w[j];
    }
    countmin=count-countmax;
    sa[i]=countmax-countmin;
    countmax=0;
    countmin=0;
  }
  while(sa[k]>0){
    k++;
  }
  if(k>0)
    cout << min(sa[k-1],-sa[k]);
  else
    cout << sa[0];
}

Compiler output:
a.cc:17:17: error: macro "rep1" requires 3 arguments, but only 2 given
   17 |     rep1(j,i+1;n){
      |                 ^
a.cc:4:9: note: macro "rep1" defined here
    4 | #define rep1(i,s,n) for(int i=s;i<n;i++)
      |         ^~~~
a.cc:2:17: error: 'srd' is not a namespace-name
    2 | using namespace srd;
      |                 ^~~
a.cc: In function 'int main()':
a.cc:8:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    8 |   cin >> n;
      |   ^~~
      |   std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:9:3: error: 'vector' was not declared in this scope
    9 |   vector<int> w(n),sa(n-1);
      |   ^~~~~~
a.cc:9:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:9:10: error: expected primary-expression before 'int'
    9 |   vector<int> w(n),sa(n-1);
      |          ^~~
a.cc:11:11: error: 'w' was not declared in this scope
   11 |     cin >>w[i];
      |           ^
a.cc:14:12: error: 'w' was not declared in this scope
   14 |     count+=w[i];
      |            ^
a.cc:17:5: error: 'rep1' was not declared in this scope
   17 |     rep1(j,i+1;n){
      |     ^~~~
a.cc:21:5: error: 'sa' was not declared in this scope
   21 |     sa[i]=countmax-countmin;
      |     ^~
a.cc:25:9: error: 'sa' was not declared in this scope
   25 |   while(sa[k]>0){
      |         ^~
a.cc:29:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   29 |     cout << min(sa[k-1],-sa[k]);
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:29:17: error: 'sa' was not declared in this scope
   29 |     cout << min(sa[k-1],-sa[k]);
      |                 ^~
a.cc:29:31: error: 'min' cannot be used as a function
   29 |     cout << min(sa[k-1],-sa[k]);
      |                               ^
a.cc:31:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   31 |     cout << sa[0];
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:31:13: error: 'sa' was not declared in this scope
   31 |     cout << sa[0];
      |             ^~