criyle/codenet-compile-errors huggingface dataset:
Language: C++

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

int main(){
    int n;
    cin >> n;

    int sum = 0;
    vector<int> w(n);
    for (int i = 0; i < n; i++){
        cin >> w[i];
        sum += w[i];
    }

    int diff = 5000000;
    int sum2 = 0;
    int sum1;
    for (int i = 0; i<n; i++){
        sum2 += w[i];
        sum1 = sum - sum2;
        diff = min(abs(sum2 - sum1),diff)
    }

    cout << diff << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:42: error: expected ';' before '}' token
   21 |         diff = min(abs(sum2 - sum1),diff)
      |                                          ^
      |                                          ;
   22 |     }
      |     ~
Language: C++

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

int main(){
    int n;
    cin >> n;

    int sum = 0;
    vector<int> w(n);
    for (int i = 0; i < n; i++){
        cin >> w[i];
        sum += w[i];
    }

    int diff = 5000000;
    int sum2 = 0;
    for (int i = 0; i<n; i++){
        sum2 += w[i];
        int sum1 = sum - sum2;
        diff = min(abs(sum2 - sum1),diff)
    }

    cout << diff << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:42: error: expected ';' before '}' token
   20 |         diff = min(abs(sum2 - sum1),diff)
      |                                          ^
      |                                          ;
   21 |     }
      |     ~
Language: C++

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

int main(){
  int n;
  cin >> n;
  vector<int> w(n);
  for(int i=0;i<n;i++){
    cin >> w.at(i);}
  int sum = 0;
  for(int i=0;i<n;i++){
    sum += w.at(i);}
  int a = 0;
  int b = 0;
  b = sum;
  for(int i=0;i<n;i++){
    a += w.at(i);
    b = min(b,abs(2*a-sum);)}
  cout << b << endl;
  return 0;
}
            
    
    
  

Compiler output:
a.cc: In function 'int main()':
a.cc:18:27: error: expected ')' before ';' token
   18 |     b = min(b,abs(2*a-sum);)}
      |            ~              ^
      |                           )
a.cc:18:28: error: expected primary-expression before ')' token
   18 |     b = min(b,abs(2*a-sum);)}
      |                            ^
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b+1;i++)
#define Per(i,b,a) for(int i=b;i>=a;i--)
int main(){
    int N;
    cin>>N;
    int *W = new int[N];
    rep(i,N) cin>>W[i];
    int sum = 0;
    rep(i,N) sum += W[i];
    int ans = sum;
    int sum = 0;
    rep(i,N){
        sum+=W[i];
        ans = min(ans,abs(N-2*sum));
    }
    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:9: error: redeclaration of 'int sum'
   27 |     int sum = 0;
      |         ^~~
a.cc:24:9: note: 'int sum' previously declared here
   24 |     int sum = 0;
      |         ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
  
int main(){
    int n;
    cin>>n;
    vector<int> s(n,0);
    int min=100000;
    rep(i,n){
        int a;
        cin>>a;
        s[i]=(i==0)?a:s[i-1]+a;
    }
    rep(i,n-1){
        if(abs(s[i]-(s[n-1]-s[i]))<min)min=abs(s[i]-(s[n-1]-s[i]);
    }
    cout<<min<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:66: error: expected ')' before ';' token
   19 |         if(abs(s[i]-(s[n-1]-s[i]))<min)min=abs(s[i]-(s[n-1]-s[i]);
      |                                               ~                  ^
      |                                                                  )
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
  
int main(){
    int n;
    cin>>n;
    vector<int> s(n,0);
    int min=100000;
    rep(i,n){
        int a;
        cin>>a;
        s[i]=(i==0)?a[i]:s[i-1]+a[i];
    }
    rep(i,n-1){
        if(abs(s[i]-(s[n-1]-s[i]))<min)min=abs(s[i]-(s[n-1]-s[i]);
    }
    cout<<min<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:22: error: invalid types 'int[int]' for array subscript
   16 |         s[i]=(i==0)?a[i]:s[i-1]+a[i];
      |                      ^
a.cc:16:34: error: invalid types 'int[int]' for array subscript
   16 |         s[i]=(i==0)?a[i]:s[i-1]+a[i];
      |                                  ^
a.cc:19:66: error: expected ')' before ';' token
   19 |         if(abs(s[i]-(s[n-1]-s[i]))<min)min=abs(s[i]-(s[n-1]-s[i]);
      |                                               ~                  ^
      |                                                                  )
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main(){
 int b;
  cin >> b;
  long long int sum=0;
  vector<long long int>v(b),ans(b);
  
  for(int i=0;i<b;i++)cin >> v[i];
  ans[0]=v[0];
  for(int i=1;i<b;i++)ans[i]=ans[i-1]+v[i];
  sum = ans[b-1];
  long long int s1,s2;
  long long int min1=INT_MAX;
  for(int i=0;i<b;i++){
    sum1 = ans[i];
    sum2=sum-sum1;
    min1 = min(min1,abs(sum1-sum2));
  }    
  cout << min1;
  
  

}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:5: error: 'sum1' was not declared in this scope; did you mean 'sum'?
   18 |     sum1 = ans[i];
      |     ^~~~
      |     sum
a.cc:19:5: error: 'sum2' was not declared in this scope; did you mean 'sum'?
   19 |     sum2=sum-sum1;
      |     ^~~~
      |     sum
Language: C++

#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a,c=0,d=0,e=INT_MAX;
  cin>>a;
  int b[a];
  rep(i,a){
    cin>>b[i];
    c+=b[i];
  }
  rep(i,a){
    d+=b[i];
    c-=b[i];
    e=min(fabs(d-c),e);
  }
  cout<<e;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:10: error: no matching function for call to 'min(__gnu_cxx::__enable_if<true, double>::__type, int&)'
   16 |     e=min(fabs(d-c),e);
      |       ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:16:10: note:   deduced conflicting types for parameter 'const _Tp' ('double' and 'int')
   16 |     e=min(fabs(d-c),e);
      |       ~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:16:10: note:   mismatched types 'std::initializer_list<_Tp>' and 'double'
   16 |     e=min(fabs(d-c),e);
      |       ~~~^~~~~~~~~~~~~
Language: C++

#include<iostream>
#include<algorithm>

using namespace std;

int main(void)

{
    int n, i, j, m = INT_MAX, l = 0, r = 0, dif;
    cin>>n;
    int ara[n];
    for(i = 0; i < n; i++)
        cin>>ara[i];
    for(i = 1; i < n; i++){
        for(j = 0; j < i; j++){
            l += ara[j];
        }
        for(j = i; j < n; j++){
            r += ara[j];
        }
        dif = abs(l-r);
        if(dif < m)
            m = dif;
        l = 0;
        r = 0;
    }
    cout<<m<<"\n";
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:22: error: 'INT_MAX' was not declared in this scope
    9 |     int n, i, j, m = INT_MAX, l = 0, r = 0, dif;
      |                      ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include<algorithm>
  +++ |+#include <climits>
    3 | 
a.cc:16:13: error: 'l' was not declared in this scope
   16 |             l += ara[j];
      |             ^
a.cc:19:13: error: 'r' was not declared in this scope
   19 |             r += ara[j];
      |             ^
a.cc:21:9: error: 'dif' was not declared in this scope; did you mean 'div'?
   21 |         dif = abs(l-r);
      |         ^~~
      |         div
a.cc:21:19: error: 'l' was not declared in this scope
   21 |         dif = abs(l-r);
      |                   ^
a.cc:21:21: error: 'r' was not declared in this scope
   21 |         dif = abs(l-r);
      |                     ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int saisyouti = 100000;
    vector<int>omosa(n);
    for(int i=0; i<n; i++){
        cin >> omosa.at(i);
    }
    
    for(int i=0; i<n; i++){
        int sum_1=0,sum_2=0;
        
        int ans=0;
        int zettaiti;
        
        for(int j=0; j<=i; j++){
            sum_1 += omosa.at(j);
        }
        for(int k=i+1; k<n; k++){
            sum_2 += omosa.at(k);
        }
        zettaiti = sum_1 - sum_2;
        if(zettaiti<0) zettaiti = -zettaiti;
        
       saisyouti = min(zettaiti,saisyouti);
        
        
    }
    cout << saisyouti << endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:31:31: error: expected '}' at end of input
   31 |     cout << saisyouti << endl;
      |                               ^
a.cc:3:11: note: to match this '{'
    3 | int main(){
      |           ^
Language: C++

#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
int n,a[150],maxx;
ll sum1,sum2,ans=1e9+7;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i],maxx=max(maxx,a[i]);
	for(int i=0;i<maxx;i++){
		for(int j=0;j<n;j++){
			if(a[j]<=i)sum1+=a[j];
			else sum2+=a[j];
		}
		ans=minn(ans,abs(sum1-sum2));
	}
	cout<<ans;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:21: error: 'minn' was not declared in this scope
   38 |                 ans=minn(ans,abs(sum1-sum2));
      |                     ^~~~
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> W(N);
    for(int i=0;i<N;i++) cin >> W.at(i);
    int S1=0,S2=0;
    for(int i=0;i<N/2;i++) S1 += W.at(i);
    for(int i=N/2;i<N;i++) S2 += W.at(i);
    int flag=1;
    if(S2>S1){
        int iti=N/2;
        while(flag){
            if((iti<N) && abs((S1+W.at(iti))-(S2-W.at(iti))) < abs(S1 - S2)){
                S1 += W.at(iti);S2 -= W.at(iti);iti++;
            }
            else flag=0;
        }
    }
    else{
        int iti=N/2-1;
        while(flag){
            if((0<=iti) && abs((S1-W.at(iti))-(S2+W.at(iti))) < abs(S1 - S2)){
                S1 -= W.at(iti);S2 += W.at(iti);iti--;
            }
            else flag=0;
        }
    }
    cout << abs(S1-S2) << endl;
    return 0;

Compiler output:
a.cc: In function 'int main()':
a.cc:33:14: error: expected '}' at end of input
   33 |     return 0;
      |              ^
a.cc:5:11: note: to match this '{'
    5 | int main(){
      |           ^
Language: C++

#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> W(N);
	for(int i = 0; i < N; ++i) {
		cin >> W[i];
	}
	int sum = 0;
	for(int i = 0; i < N; ++i) {
		sum += W[i];
	}
	int b = 0, pos = 0;
	while(b <= sum / 2) {
		b += A[pos];
		++pos;
	}
	cout << min(b * 2 - sum, sum - (b - A[pos - 1]) * 2) << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:22: error: 'A' was not declared in this scope
   18 |                 b += A[pos];
      |                      ^
a.cc:21:45: error: 'A' was not declared in this scope
   21 |         cout << min(b * 2 - sum, sum - (b - A[pos - 1]) * 2) << endl;
      |                                             ^
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> W(N);
	for(int i = 0; i < N; ++i) {
		cin >> W[i];
	}
	int sum = 0;
	for(int i = 0; i < N; ++i) {
		sum += W[i];
	}
	int b = 0, pos = 0;
	while(b <= sum / 2) {
		b += A[pos];
		++pos;
	}
	cout << min(b * 2 - sum, sum - (b - A[pos - 1]) * 2) << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:9: error: 'vector' was not declared in this scope
    7 |         vector<int> W(N);
      |         ^~~~~~
a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    2 | #include <algorithm>
  +++ |+#include <vector>
    3 | using namespace std;
a.cc:7:16: error: expected primary-expression before 'int'
    7 |         vector<int> W(N);
      |                ^~~
a.cc:9:24: error: 'W' was not declared in this scope
    9 |                 cin >> W[i];
      |                        ^
a.cc:13:24: error: 'W' was not declared in this scope
   13 |                 sum += W[i];
      |                        ^
a.cc:17:22: error: 'A' was not declared in this scope
   17 |                 b += A[pos];
      |                      ^
a.cc:20:45: error: 'A' was not declared in this scope
   20 |         cout << min(b * 2 - sum, sum - (b - A[pos - 1]) * 2) << endl;
      |                                             ^
Language: C++

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  int s1 = 0;
  int s2 = 0;
  int ans = 1e9;
  vector<int> w(n);
  for(int i = 0; i < n; i++) {
    cin >> w[i];
  }
  for(int i = 1; i < n - 1; i++) {
    for(int j = 0; j < n; j++) {
      if(i >= j) {
        s1 += w[j];
      }else {
        s2 += w[j];
      }
    }
    ans = min(ans, abs(s2- s1));
    s2 = 0;
    s1 = 0;
  }
  cout << ans << endl;
}
        

Compiler output:
a.cc:1:10: fatal error: bits/stdc++h: No such file or directory
    1 | #include <bits/stdc++h>
      |          ^~~~~~~~~~~~~~
compilation terminated.
Language: C++

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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int N;
    cin >> N;
    vector<int> W(N);
    REP(i, N) {
        cin >> W[i];
    }
    sort(ALL(W));
    int l = 0;
    int h = accumulate(ALL(W), 0);
    int res = h;
    REP(i, N) {
        l += W[i];
        h -= W[i];
        res = min(res, abs(h - l));
    }
    cout << res << endl;
    return 0;
}


Compiler output:
a.cc:8:7: error: 'LL' does not name a type; did you mean 'ALL'?
    8 | const LL LINF = 1e18;
      |       ^~
      |       ALL
a.cc:9:7: error: 'LL' does not name a type; did you mean 'ALL'?
    9 | const LL mod = 1e9+7;
      |       ^~
      |       ALL
Language: C++

#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    int N;
    vector<int> W;

    cin>>N;
    int sum = 0:
    for(int i = 0;i < N;i++) {
        int w;
        cin>>w;
        W.push_back(w);
        sum += w;
    }

    int diff = sum;
    int take = 0;
    for(int i = 0;i < N;i++) {
        take += W[i];
        sum -= W[i];
        diff = min(diff,abs(sum-take));
    }

    cout<<diff<<endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:16: error: expected ',' or ';' before ':' token
   30 |     int sum = 0:
      |                ^
a.cc:31:19: error: 'i' was not declared in this scope
   31 |     for(int i = 0;i < N;i++) {
      |                   ^
Language: C++

#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    int N;
    vector<int> W;

    cin>>N;
    int sum = 0:
    for(int i = 0;i < N;i++) {
        int w;
        cin>>w;
        W.push_back(w);
        sum += w;
    }

    int diff = sum;
    int take = 0;
    for(int i = 0;i < N;i++) {
        take += w[i];
        sum -= w[i];
        diff = min(diff,abs(sum-take));
    }

    cout<<diff<<endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:16: error: expected ',' or ';' before ':' token
   30 |     int sum = 0:
      |                ^
a.cc:31:19: error: 'i' was not declared in this scope
   31 |     for(int i = 0;i < N;i++) {
      |                   ^
a.cc:41:17: error: 'w' was not declared in this scope
   41 |         take += w[i];
      |                 ^
Language: C++

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,W;
  int ans; 
  vector<int> weight(N);
  rep(i,N) {
    cin >> weight.at(i);
    ans+=weight.at(i);
  }
  rep(i,N){
    ans-=2*weigt.at(i);
    if(ans<0){
      cout<<min(-ans,ans+2*weigt.at(i))<<endl;
      break;
    }    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:12: error: 'weigt' was not declared in this scope; did you mean 'weight'?
   16 |     ans-=2*weigt.at(i);
      |            ^~~~~
      |            weight
a.cc:21:2: error: expected '}' at end of input
   21 | }
      |  ^
a.cc:5:11: note: to match this '{'
    5 | int main(){
      |           ^
Language: C++

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




    int main(){
        int n;
        std::cin >> n;
        std::vector<int> w(n);
        rep(i, n) std::cin >> w[i];
        
        for (int i = 1; i < n; ++i)
        {
            int ans = 1e9;
            int l = 0, r = 0;
            for(int j = 0; j < i; j++) l += w[i];
            for (int j = i; j < n; j++) r += w[i];
            ans = min(ans, abs(i-r));
        }
        std::cout << ans << "\n";
        return 0;
    }


Compiler output:
a.cc: In function 'int main()':
a.cc:23:22: error: 'ans' was not declared in this scope; did you mean 'abs'?
   23 |         std::cout << ans << "\n";
      |                      ^~~
      |                      abs
Language: C++

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




    int main(){
        int n;
        std::cin >> n;
        std::vector<int> w(n);
        rep(i, n) std::cin >> w[i];
        
        for (int i = 1; i < n; ++i)
        {
            int ans 1e9;
            int l = 0, r = 0;
            for(int j = 0; j < i; j++) l += w[i];
            for (int j = i; j < n; j++) r += w[i];
            ans = min(ans, abs(i-r));
        }
        std::cout << ans << "\n";
        return 0;
    }


Compiler output:
a.cc: In function 'int main()':
a.cc:17:21: error: expected initializer before numeric constant
   17 |             int ans 1e9;
      |                     ^~~
a.cc:21:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   21 |             ans = min(ans, abs(i-r));
      |             ^~~
      |             abs
a.cc:23:22: error: 'ans' was not declared in this scope; did you mean 'abs'?
   23 |         std::cout << ans << "\n";
      |                      ^~~
      |                      abs
Language: C++

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




    int main(){
        int n;
        std::cin >> n;
        std::vector<int> w(n);
        rep(i, n) std::cin >> w[i];
        int ans 1e9;
        for (int i = 1; i < n; ++i)
        {
            int l = 0, r = 0;
            for(int j = 0; j < i; j++) l += w[i];
            for (int j = i; j < n; j++) r += w[i];
            ans = min(ans, abs(i-r));
        }
        std::cout << ans << "\n";
        return 0;
    }


Compiler output:
a.cc: In function 'int main()':
a.cc:14:17: error: expected initializer before numeric constant
   14 |         int ans 1e9;
      |                 ^~~
a.cc:20:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   20 |             ans = min(ans, abs(i-r));
      |             ^~~
      |             abs
a.cc:22:22: error: 'ans' was not declared in this scope; did you mean 'abs'?
   22 |         std::cout << ans << "\n";
      |                      ^~~
      |                      abs
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> W(N);
  int sum = 0;
  for (int i = 0; i < N; i++){
    cin >> W[i];
    sum += W[i];
    M = max(M,W[i]);
  }
  int Tsum = 0;
  int minD = sum;
  for (int i = 0; i < N; i++){
    Tsum += W[i];
    minD = min(minD,abs(sum - Tsum - Tsum));
  }
  cout << minD;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:5: error: 'M' was not declared in this scope
   11 |     M = max(M,W[i]);
      |     ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> W(N);
  int sum = 0;
  int M = 0;
  for (int i = 0; i < N; i++){
    cin >> W[i];
    sum += W[i];
    M = max(M,W[i]);
  }
  int minD = sum;
  for (int T = -1; T <= max; T++){
    int D = 0;
    for (int i = 0; i < N; i++){
      if (W[i] <= T){
        D += W[i];
      } else {
        D -= W[i];
      }
    }
    if (minD < abs(D)) minD = abs(D);
  }
  cout << minD;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:22: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<='
   15 |   for (int T = -1; T <= max; T++){
      |                    ~~^~~~~~
Language: C++

#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <vector>

#define rep(x,y) for(int x = 0;x < y;++x)

int main() {

    int N;
    std::cin >> N;
    std::vector<int> W(N);


    int min_value = INT_MAX;
    int left = 0, right;
    rep(i, N) {
        right += W[i];
    }

    rep(i, N - 1) {
        left += W[i];
        right -= W[i];
        min_value = std::min(min_value, abs(left - right));
    }

   std:: cout << min_value << '\n';
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:21: error: 'INT_MAX' was not declared in this scope
   17 |     int min_value = INT_MAX;
      |                     ^~~~~~~
a.cc:7:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    6 | #include <vector>
  +++ |+#include <climits>
    7 |
Language: C

#include <bits/stdc++.h>
using namespace std;
int a[10101];
int main()
{
    int n,i;
    scanf("%d",&n);
    for(i=1; i<=n; i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=2; i<=n; i++)
    {
        a[i]+=a[i-1];
    }
    int Min=1e+8;
    for(i=2; i<=n; i++)
    {
        if(a[i]-a[i-1]<Min)
        {
            Min=a[i]-a[i-1];
        }
    }
    printf("%d\n",Min);
    return 0;
}









Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

int a[105];
int b[105];
int c[105];
int abs(int x){
if(x>=0)return x;
return -x;
}
int main(){
int n;
b[0]=0;
c[0]=0;
scanf("%d",&n);
c[n+1]=0;
for(int i=1;i<=n;i++){
    scanf("%d",&a[i]);
}
for(int i=1;i<=n;i++){
    b[i]=b[i-1]+a[i];
}
for(int i=1;i<=n;i++){
    c[i]=c[i-1]+a[n-i+1];
}
int y=abs(b[1]-c[n-1]);
for(int i=1;i<=n;i++){
    if(abs(b[i]-c[n-i])<y)y=abs(b[i]-c[n-i]);
}
printf("%d\n",y);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:1: error: 'scanf' was not declared in this scope
   12 | scanf("%d",&n);
      | ^~~~~
a.cc:27:1: error: 'printf' was not declared in this scope
   27 | printf("%d\n",y);
      | ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | int a[105];
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
int mini=10000000;
int N; cin >> N;
vector<int> a(N);
for(int i=0;i<N;i++)cin>>a[i];
vector<int> s(N+1, 0);
for(int i=0;i<N;i++)s[i+1]=s[i]+a[i];
rep(i,N) if( abs( (s[i]-s[0]) - (s[N]-s[i]) )<mini )mini=abs( (s[i]-s[0]) - (s[N]-s[i]);
cout <<mini<< endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:88: error: expected ')' before ';' token
   11 | rep(i,N) if( abs( (s[i]-s[0]) - (s[N]-s[i]) )<mini )mini=abs( (s[i]-s[0]) - (s[N]-s[i]);
      |                                                             ~                          ^
      |                                                                                        )
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
int mini=10000000;
int N; cin >> N;
vector<int> a(N);
for(int i=0;i<N;i++)cin>>a[i];
vector<int> s(N+1, 0);
for(inti=0;i<N;i++)s[i+1]=s[i]+a[i];
rep(i,N) if( abs( (s[i]-s[0]) - (s[N]-s[i]) )<mini )mini=abs( (s[i]-s[0]) - (s[N]-s[i]);
cout <<mini<< endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:5: error: 'inti' was not declared in this scope; did you mean 'int'?
   10 | for(inti=0;i<N;i++)s[i+1]=s[i]+a[i];
      |     ^~~~
      |     int
a.cc:10:12: error: 'i' was not declared in this scope
   10 | for(inti=0;i<N;i++)s[i+1]=s[i]+a[i];
      |            ^
a.cc:11:88: error: expected ')' before ';' token
   11 | rep(i,N) if( abs( (s[i]-s[0]) - (s[N]-s[i]) )<mini )mini=abs( (s[i]-s[0]) - (s[N]-s[i]);
      |                                                             ~                          ^
      |                                                                                        )
Language: C++

#include<iostream>
#include<cstdlib>
#include<numeric>
using namespace std;
int main(){
int n;
  cin >> n;
  // w array
  int w[n];
  for (int i = 0; i < n; i++)
    cin >> w[i];
  int sum = accumulate(w,w+n, 0);
  int res = w[0];
  int ans = abs(sum - res*2);
  for (int i = 1; i < n; i++){
  	res += w[i];
    int temp =abs(sum - res*2) 
    (temp < ans)? ans = temp : ans += 0;
  }
  cout << ans<<'\n';
 
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:5: error: expression cannot be used as a function
   17 |     int temp =abs(sum - res*2)
      |               ~~~~~~~~~~~~~~~~
   18 |     (temp < ans)? ans = temp : ans += 0;
      |     ^~~~~~~~~~~~
Language: C++

#include<iostream>
#include<numeric>
using namespace std;
int main(){
int n;
  cin >> n;
  // w array
  int w[n];
  for (int i = 0; i < n; i++)
    cin >> w[i];
  int sum = accumulate(w,w+n, 0);
  int res = w[0];
  int ans = abs(sum - res*2);
  for (int i = 1; i < n; i++){
  	res += w[i];
    int temp =abs(sum - res*2) 
    (temp < ans)? ans = temp : ans += 0;
  }
  cout << ans<<'\n';

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:5: error: expression cannot be used as a function
   16 |     int temp =abs(sum - res*2)
      |               ~~~~~~~~~~~~~~~~
   17 |     (temp < ans)? ans = temp : ans += 0;
      |     ^~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
using in = int64_t;

int check(vector<int> w,int i,int n){
   int sum1=0;
  int sum2=0;
  for(int j=0;j<=i;j++){sum1+=w[j];}
  for(int j=i+1;j<n;j++){sum2+=w[j];}
  int sa = abs(sum1-sum2);
  return sa;
}

int main(){
  int n;
  cin>>n;
  int w[110];
  
  int a=0;
  for(int i=0;i<n;i++) a+=w[i];
  for(int i=0;i<n-1;i++){
    a=min(check(w,i,n),a);
  }
  cout<<a;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:17: error: could not convert '(int*)(& w)' from 'int*' to 'std::vector<int>'
   26 |     a=min(check(w,i,n),a);
      |                 ^
      |                 |
      |                 int*
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
using in = int64_t;

int check(vector<int> w,int i,int n){
   int sum1=0;
  int sum2=0;
  for(int j=0;j<=i;j++){sum1+=w[j];}
  for(int j=i+1;j<n;j++){sum2+=w[j];}
  int sa = abs(sum1-sum2);
  return sa;
}

int main(){
  int n;
  cin>>n;
  int w[110];
  
  for(int i=0;i<n-1;i++){
    a=min(check(w,i,n),a);
  }
  cout<<a;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:5: error: 'a' was not declared in this scope
   24 |     a=min(check(w,i,n),a);
      |     ^
a.cc:24:17: error: could not convert '(int*)(& w)' from 'int*' to 'std::vector<int>'
   24 |     a=min(check(w,i,n),a);
      |                 ^
      |                 |
      |                 int*
a.cc:26:9: error: 'a' was not declared in this scope
   26 |   cout<<a;
      |         ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
using in = int64_t;

int check(vector<int> w,int i){
   int sum1=0;
  int sum2=0;
  for(int j=0;j<=i;j++){sum1+=w[j];}
  for(int j=i+1;j<n;j++){sum2+=w[j];}
  int sa = abs(sum1-sum2);
  return sa;
}

int main(){
  int n;
  cin>>n;
  int w[110];
  
  for(int i=0;i<n-1;i++){
    a=min(check(w,i),a);
  }
  cout<<a;
}


Compiler output:
a.cc: In function 'int check(std::vector<int>, int)':
a.cc:13:19: error: 'n' was not declared in this scope
   13 |   for(int j=i+1;j<n;j++){sum2+=w[j];}
      |                   ^
a.cc: In function 'int main()':
a.cc:24:5: error: 'a' was not declared in this scope
   24 |     a=min(check(w,i),a);
      |     ^
a.cc:24:17: error: could not convert '(int*)(& w)' from 'int*' to 'std::vector<int>'
   24 |     a=min(check(w,i),a);
      |                 ^
      |                 |
      |                 int*
a.cc:26:9: error: 'a' was not declared in this scope
   26 |   cout<<a;
      |         ^
Language: C

A = int(input())
W = list(map(int,input().split()))
tmp = 0
ans = 0
wa = 0

for i in range (A):
    wa += W[i]
for i in range (A):
    tmp += W[i]
    tmp_r = wa-tmp
    if i == 0:
        ans = tmp
    if ans > abs(tmp-tmp_r):
        ans = abs(tmp-tmp_r)
print(ans)

Compiler output:
main.c:1:1: warning: data definition has no type or storage class
    1 | A = int(input())
      | ^
main.c:1:1: error: type defaults to 'int' in declaration of 'A' [-Wimplicit-int]
main.c:1:5: error: expected expression before 'int'
    1 | A = int(input())
      |     ^~~
Language: C++

#include <bits/stdc++.h>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

int main(){
  int n;
  cin >> n;
  vector<int> w(n);
  int ans = 10e9;
  rep(i,n){
    cin >> w[i];
  }
  rep(i,n){
    int l=0;,r=0;
    for(int j=0;j=i;j++)l+=w[j];
    for(int j=i;j=n;j++)r+=w[j];
    ans = min(ans,abs(l-r));
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:13: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+10' to '2147483647' [-Woverflow]
   12 |   int ans = 10e9;
      |             ^~~~
a.cc:17:13: error: expected primary-expression before ',' token
   17 |     int l=0;,r=0;
      |             ^
a.cc:17:14: error: 'r' was not declared in this scope
   17 |     int l=0;,r=0;
      |              ^
Language: C++


import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int[] data = new int[n];
    int[] data2 = new int[n];
    int min=100;

    for (int i = 0;i<n ;i++ ) {
      data[i] = sc.nextInt();
    }
    
    data2[0]=data[0];
    for (int t = 1;t<n ;t++ ) {
      data2[t] = data2[t-1]+data[t];
      }

      for (int i = 0;i<n ;i++ ) {
        int t1 = data2[n-1]-data2[i];
        int t0 = data2[i];
        int pre = Math.abs(t1-t0);
        min = Math.min(min,pre);
      }
      System.out.println(min);
    }

  }


Compiler output:
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.*;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
    3 | public class Main{
      | ^~~~~~
Language: C++

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

int main(){
  int n;
  cin >> n;
  vector<int> cum;
  int tmp;
  cin >> tmp;
  cum.push_back(tmp);
  for(int i=0; i<n-1; i++){
    cin >> tmp;
    cum.push_back(cum.at(i)+tmp);
  }
  int SUM = cum.at(n-1);
  int ans = 100000000;
  for(auto c : cum){
    ans = min(abs((SUM-c)-c),ans)
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:34: error: expected ';' before '}' token
   18 |     ans = min(abs((SUM-c)-c),ans)
      |                                  ^
      |                                  ;
   19 |   }
      |   ~
Language: C++

#include<iostream>
#include<vector>
#include<cmath>
using namespace std;

int main()
{
  int n;
  cin>>n;
  vector<int> a(n+1,0);
  for(int i=1;i<=n;i++)
    {
     int x;
     cin>>x;
     a[i]=a[i-1]+x;
    }
  
  int res=1e6;
  
  for(int i=0;i<n;i++)
  {
     res=min(res,abs(a[i]-(a[n]-a[i]));
  }
  
  cout<<res<<endl;
  
  
 return 0; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:39: error: expected ')' before ';' token
   22 |      res=min(res,abs(a[i]-(a[n]-a[i]));
      |             ~                         ^
      |                                       )
Language: C++

#include<iostream>
#include<cmath>
using namespace std;

int min(int a,int b)
{
 return(a>b?b:a); 
}


int main()
{
  int n;
  cin>>n;
  int * a=new int[n];
  
  for(int i=0;i<n;i++) 
    cin>>a[i];
  
   int i=0;j=n-1;
   int ans=1e5+5;
  int sums=0,sume=0;
   while(i<j)
   {  
     if(sums>sume)
        {
          sume+=a[j];
          j--;
        }     
     else
        {
         sums+=a[i];
         i++;
        }
      ans=min(ans,abs(sums-sume));
   }
  
  
  cout<<ans<<endl;
 return 0; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:12: error: 'j' was not declared in this scope
   20 |    int i=0;j=n-1;
      |            ^
Language: C++

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

int main() {
  int n;
  cin >> n;
  vector<int> w(n);
  for(int i=0; i<n; i++){
    cin >> w.at(i);
  }
  int ans, tot, com;
  ans=1.0e8;
  tot=0;
  for(int i=0; i<n; i++){
    tot += w.at(i);
  }
  for(int i=0; i<n; i++){
    com += w.at(i);
    ans = min(ans, abs((tot - com) - com))
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:43: error: expected ';' before '}' token
   19 |     ans = min(ans, abs((tot - com) - com))
      |                                           ^
      |                                           ;
   20 |   }
      |   ~
Language: C++

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

int main() {
  int n;
  cin >> n;
  vector<int> w(n);
  for(int i=0; i<n; i++){
    cin >> w.at(i);
  }
  int s1, s2, ans, tot, com;
  ans=100;
  tot=0;
  for(int i=0; i<n; i++){
    tot += w.at(i);
  }
  for(int i=0; i<n; i++){
    for(int j=0; j<i; j++){
      s1 += w.at(j);
    }
    s2 = tot - s1;
    com = max(s1, s2) - min(s1, s2);
    ans = min(ans, com);
    if(con == 0){
      break;
    }
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:8: error: 'con' was not declared in this scope; did you mean 'com'?
   24 |     if(con == 0){
      |        ^~~
      |        com
Language: C++

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

int main() {
  int n;
  cin >> n;
  vector<int> w(n);
  for(int i=0; i<n; i++){
    cin >> w.at(i);
  }
  int s1, s2, ans, tot, com;
  ans=100;
  tot=0;
  for(int i=0; i<n, i++){
    tot += w.at(i);
  }
  for(int i=0; i<n, i++){
    for(int j=0; j<i, j++){
      s1 += w.at(j);
    }
    s2 = tot - s1;
    com = max(s1, s2) - min(s1, s2);
    ans = min(ans, com);
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:24: error: expected ';' before ')' token
   14 |   for(int i=0; i<n, i++){
      |                        ^
      |                        ;
a.cc:17:24: error: expected ';' before ')' token
   17 |   for(int i=0; i<n, i++){
      |                        ^
      |                        ;
a.cc:18:26: error: expected ';' before ')' token
   18 |     for(int j=0; j<i, j++){
      |                          ^
      |                          ;
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >> N;
  vector<int>v(N); for(auto& e :v) cin >> e;
  int mini = (1 << 30);
  sort(v.begin(),v.end());
  for(int i = 1; i < N; ++i)
    mini = min(mini, abs(
      accumulate(v.begin(),v.begin() + i,0) - accumulate(v.begin() + i,v.end())
    ,0));
  cout << mini << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:57: error: no matching function for call to 'accumulate(__gnu_cxx::__normal_iterator<int*, std::vector<int> >, std::vector<int>::iterator)'
   10 |       accumulate(v.begin(),v.begin() + i,0) - accumulate(v.begin() + i,v.end())
      |                                               ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/numeric:62,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:58,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_numeric.h:134:5: note: candidate: 'template<class _InputIterator, class _Tp> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp)'
  134 |     accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
      |     ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:134:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_numeric.h:161:5: note: candidate: 'template<class _InputIterator, class _Tp, class _BinaryOperation> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp, _BinaryOperation)'
  161 |     accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,
      |     ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:161:5: note:   candidate expects 4 arguments, 2 provided
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >> N;
  vector<int>v(N); for(auto& e :v) cin >> e;
  int mini = (1 << 30);
  sort(v.begin(),v.end());
  for(int i = 1; i < N; ++i)
    mini = min(mini, abs(
      accumulate(v.begin(),v.begin() + i) - accumulate(v.begin() + i,v.end())
    ));
  cout << mini << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:17: error: no matching function for call to 'accumulate(std::vector<int>::iterator, __gnu_cxx::__normal_iterator<int*, std::vector<int> >)'
   10 |       accumulate(v.begin(),v.begin() + i) - accumulate(v.begin() + i,v.end())
      |       ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/numeric:62,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:58,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_numeric.h:134:5: note: candidate: 'template<class _InputIterator, class _Tp> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp)'
  134 |     accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
      |     ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:134:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_numeric.h:161:5: note: candidate: 'template<class _InputIterator, class _Tp, class _BinaryOperation> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp, _BinaryOperation)'
  161 |     accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,
      |     ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:161:5: note:   candidate expects 4 arguments, 2 provided
a.cc:10:55: error: no matching function for call to 'accumulate(__gnu_cxx::__normal_iterator<int*, std::vector<int> >, std::vector<int>::iterator)'
   10 |       accumulate(v.begin(),v.begin() + i) - accumulate(v.begin() + i,v.end())
      |                                             ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:134:5: note: candidate: 'template<class _InputIterator, class _Tp> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp)'
  134 |     accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
      |     ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:134:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_numeric.h:161:5: note: candidate: 'template<class _InputIterator, class _Tp, class _BinaryOperation> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp, _BinaryOperation)'
  161 |     accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,
      |     ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:161:5: note:   candidate expects 4 arguments, 2 provided
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >> N;
  Nvector<int>v(N); for(auto& e :v) cin >> e;
  int mini = (1 << 30);
  sort(v.begin(),v.end());
  for(int i = 1; i < N; ++i)
    mini = min(mini, abs(
      accumulate(v.begin(),v.begin() + i) - accumulate(v.begin() + i,v.end())
    ));
  cout << mini << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:3: error: 'Nvector' was not declared in this scope
    5 |   Nvector<int>v(N); for(auto& e :v) cin >> e;
      |   ^~~~~~~
a.cc:5:11: error: expected primary-expression before 'int'
    5 |   Nvector<int>v(N); for(auto& e :v) cin >> e;
      |           ^~~
a.cc:5:34: error: 'v' was not declared in this scope
    5 |   Nvector<int>v(N); for(auto& e :v) cin >> e;
      |                                  ^
a.cc:7:8: error: 'v' was not declared in this scope
    7 |   sort(v.begin(),v.end());
      |        ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i=0; i<n; i++) cin >> v.at(i);
  int sum1=0,sum2=0;
  sort(v.begin(),v.end());
  for(int i=0; i<n; i++){
    if (sum1<=sum2) sum1+=v.at(i);
    else sum2+=v.at(i);
  }
  cout << abs(sum1-sum2) << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    7 |   cin >> n;
      |   ^~~
      |   std::cin
In file included 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:8:3: error: 'vector' was not declared in this scope
    8 |   vector<int> v(n);
      |   ^~~~~~
a.cc:8:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:2:
/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:8:10: error: expected primary-expression before 'int'
    8 |   vector<int> v(n);
      |          ^~~
a.cc:9:33: error: 'v' was not declared in this scope
    9 |   for(int i=0; i<n; i++) cin >> v.at(i);
      |                                 ^
a.cc:11:8: error: 'v' was not declared in this scope
   11 |   sort(v.begin(),v.end());
      |        ^
a.cc:11:3: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   11 |   sort(v.begin(),v.end());
      |   ^~~~
      |   std::sort
In file included from /usr/include/c++/14/algorithm:86,
                 from a.cc:3:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
a.cc:16:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   16 |   cout << abs(sum1-sum2) << endl;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:16:29: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   16 |   cout << abs(sum1-sum2) << endl;
      |                             ^~~~
      |                             std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~