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

using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> w(n);
    int ans=1e7;
    for(int i=0;i<n;i++) cin >> w[i];
    for(int t=0;t<n;t++){
        int s1=0,s2=0;
        for(int i=0;i<n;i++){
            if(i<=t) s1+=w[i];
            else s2+=w[i];
        }
        ans=min(ans,abs(s1-s2));
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:5: error: 'cin' was not declared in this scope
    4 |     cin >> n;
      |     ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:5:5: error: 'vector' was not declared in this scope
    5 |     vector<int> w(n);
      |     ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | using namespace std;
a.cc:5:12: error: expected primary-expression before 'int'
    5 |     vector<int> w(n);
      |            ^~~
a.cc:7:33: error: 'w' was not declared in this scope
    7 |     for(int i=0;i<n;i++) cin >> w[i];
      |                                 ^
a.cc:11:26: error: 'w' was not declared in this scope
   11 |             if(i<=t) s1+=w[i];
      |                          ^
a.cc:12:22: error: 'w' was not declared in this scope
   12 |             else s2+=w[i];
      |                      ^
a.cc:14:21: error: 'abs' was not declared in this scope; did you mean 'ans'?
   14 |         ans=min(ans,abs(s1-s2));
      |                     ^~~
      |                     ans
a.cc:14:13: error: 'min' was not declared in this scope; did you mean 'main'?
   14 |         ans=min(ans,abs(s1-s2));
      |             ^~~
      |             main
a.cc:16:5: error: 'cout' was not declared in this scope
   16 |     cout << ans << endl;
      |     ^~~~
a.cc:16:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:16:20: error: 'endl' was not declared in this scope
   16 |     cout << ans << endl;
      |                    ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | using namespace std;
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef unsigned long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 1e12;

int main() {
  int n;
  cin>>n;
  vector<int> w(n);
  rep(i,0,n)cin>>w[i];
  int min=INF;
  rep(i,1,n){
    int sumb=0;
    int suma=0;
    rep(j,0,i)sumb+=w[i];
    rep(j,i,n)suma+=w[i];
    int ans=abs(sumb-suma);
    if(ans<=min)min=ans;
  }
  cout<<min<<endl;
}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:11: warning: overflow in conversion from 'll' {aka 'long long unsigned int'} to 'int' changes value from '1000000000000' to '-727379968' [-Woverflow]
   20 |   int min=INF;
      |           ^~~
a.cc: At global scope:
a.cc:31:1: error: expected declaration before '}' token
   31 | }
      | ^
Language: C++

#include<iostream>
using namespace std;
int main(){
  int a[101], n, t, ans = 100*100;
  a[0] = 0;
  cin >> n;
  for(int i=1; i<=n; i++){
    cin >> t; 
    a[i] = a[i-1] + t;
  }
  int toatal = a[n];
  for(int i=1; i<=n; i++){
    ans = min(ans, abs(total - 2*a[i]));
  }
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:24: error: 'total' was not declared in this scope; did you mean 'toatal'?
   13 |     ans = min(ans, abs(total - 2*a[i]));
      |                        ^~~~~
      |                        toatal
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> a(N);
int sum = 0;
 for (int i = 0; i < N; ++i) {
 cin >> a[i];
 sum += a[i];
 }
 
 int mini = sum;
 int prefix_sum = 0;
 for (int i = 0; i < N; ++i) {
 cin >> a[i];
 prefix_sum += a[i];
 mini = min(mini, abs(prefix_sum - (sum - prefix_sum)));
 }
 
 cout << mini << endl;
 return 0;
 }
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> a(N);
int sum = 0;
 for (int i = 0; i < N; ++i) {
 cin >> a[i];
 sum += a[i];
 }
 
 int mini = sum;
 int prefix_sum = 0;
 for (int i = 0; i < N; ++i) {
 prefix_sum += a[i];
 mini = min(mini, abs(prefix_sum - (sum - prefix_sum)));
 }
 
 cout << mini << endl;
 return 0;
 }

Compiler output:
a.cc:26:5: error: redefinition of 'int main()'
   26 | int main() {
      |     ^~~~
a.cc:3:5: note: 'int main()' previously defined here
    3 | int main() {
      |     ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long int lint;

int main(){
    int n;
    cin >> n;
    int arr[n];
    for(int i=0; i<n; i++) cin >> arr[i];
    int toplam = 0;
    for(int i=0; i<n; i++){
        toplam += arr[i];
    }
    int cntr = 0;
    int a;
    for(int i=0; i<n; i++){
        cntr+=arr[i];
        if(cntr > toplam/2){
            a = i;
            break;
        }
    }
    int n_cntr = cntr-arr[a];
    int sonuc = min(abs(toplam-(2*cntr)), abs(toplam-(2*n_cntr));
    cout << sonuc;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:65: error: expected ')' before ';' token
   24 |     int sonuc = min(abs(toplam-(2*cntr)), abs(toplam-(2*n_cntr));
      |                    ~                                            ^
      |                                                                 )
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
const int INF=10010010;
int main(){
  int N;
  cin>>N;
  vector<int>W(N);
  int sum=0;
  rep(i,N){
    cin>>W[i];
    sum+=W[i];
  }
  int tmp=0;
  int res=INF;
  int ans=INF;
  rep(i,N){
    tmp+=W[i];
    res=sum-tmp;
    ans=min(tmp-res);
  }
  cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:12: error: no matching function for call to 'min(int)'
   20 |     ans=min(tmp-res);
      |         ~~~^~~~~~~~~
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:   candidate expects 2 arguments, 1 provided
/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, 1 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:   template argument deduction/substitution failed:
a.cc:20:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   20 |     ans=min(tmp-res);
      |         ~~~^~~~~~~~~
/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:   candidate expects 2 arguments, 1 provided
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
const int INF=1001001001;
int main(){
  int N;
  cin>>N;
  vector<int>W(N);
  int sum=0;
  rep(i,N){
    cin>>W[i];
    sum+=W[i];
  }
  int tmp=0;
  int res=INF;
  int ans=INF;
  rep(i,N){
    tmp+=W[i];
    res=sum-tmp;
    ans=min(tmp-res);
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:12: error: no matching function for call to 'min(int)'
   20 |     ans=min(tmp-res);
      |         ~~~^~~~~~~~~
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:   candidate expects 2 arguments, 1 provided
/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, 1 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:   template argument deduction/substitution failed:
a.cc:20:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   20 |     ans=min(tmp-res);
      |         ~~~^~~~~~~~~
/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:   candidate expects 2 arguments, 1 provided
Language: C++

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

int main() {
  int N;
  cin>>N;
  int W[N];
  for(int i=0;i<N;i++;) cin>>W[i];
  int b=0;
  for(int i=0;i<N;i++) b+=W[i];
  int a=0;
  int ans=b;
  for(int i=0;i<N-1;i++){
    a+=W[i];
    b-=W[i];
    int c=abs(a-b);
    ans=min(ans,c);
  }
  cout<<ans<<endl;
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:22: error: expected ')' before ';' token
    8 |   for(int i=0;i<N;i++;) cin>>W[i];
      |      ~               ^
      |                      )
a.cc:8:23: error: expected primary-expression before ')' token
    8 |   for(int i=0;i<N;i++;) cin>>W[i];
      |                       ^
Language: Java

import java.util.Scanner;
import java.util.Arrays;

public class ABC129B {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] W = new int[N];
        for (int i = 0; i < N; i++) {
            W[i] = Integer.parseInt(sc.next());
        }

        int left = 0;
        int right = 0;
        int dif = 100000;
        for (int i = 0; i < N; i++) {
            left = sum(Arrays.copyOfRange(W, 0, i));
            right = sum(Arrays.copyOfRange(W, i, W.length));
            dif = Math.min(dif, Math.abs(left - right));
        }
        System.out.println(dif);
    }

    private static int sum(int[] temp) {
        int n = temp.length;
        int ret = 0;
        for (int i = 0; i < n; i++) {
            ret += temp[i];
        }
        return ret;
    }
}


Compiler output:
Main.java:4: error: class ABC129B is public, should be declared in a file named ABC129B.java
public class ABC129B {
       ^
1 error
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
  cin>>n;
  int a[101];
  set<int> s;
  
  for (int i=0;i<n;i++)
    cin>>a[i];
  int sum=0;
  sum=accumulate(a,a+n,sum);
  int sum1=sum;
  for(int i=0;i<n-1;i++)
  { if(!sum-accumulate(a,a+1+i,0))
    {cout<<0;goto start
    }
    else 
      s.insert(sum-accumulate(a,a+1+i,0));
     
  
  
  
  }
auto it=s.begin();
  cout<<*it;

start:
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:24: error: expected ';' before '}' token
   17 |     {cout<<0;goto start
      |                        ^
      |                        ;
   18 |     }
      |     ~                   
a.cc:29:1: error: jump to label 'start'
   29 | start:
      | ^~~~~
a.cc:17:19: note:   from here
   17 |     {cout<<0;goto start
      |                   ^~~~~
a.cc:26:6: note:   crosses initialization of 'std::_Rb_tree_const_iterator<int> it'
   26 | auto it=s.begin();
      |      ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
  cin>>n;
  int a[101];
  set<int> s;
  
  for (int i=0;i<n;i++)
    cin>>a[i];
  int sum=0;
  sum=accumulate(a,a+n,sum);
  int sum1=sum;
  for(int i=0;i<n-1;i++)
  { if(!sum-accumulate(a,a+1+i,0))
    {cout<<0;goto start;break;
    }
    else 
      s.insert(sum-accumulate(a,a+1+i,0));
     
  
  
  
  }
auto it=s.begin();
  cout<<*it;

start:
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:1: error: jump to label 'start'
   29 | start:
      | ^~~~~
a.cc:17:19: note:   from here
   17 |     {cout<<0;goto start;break;
      |                   ^~~~~
a.cc:26:6: note:   crosses initialization of 'std::_Rb_tree_const_iterator<int> it'
   26 | auto it=s.begin();
      |      ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
  cin>>n;
  int a[101];
  set<int> s;
  
  for (int i=0;i<n;i++)
    cin>>a[i];
  int sum=0;
  sum=accumulate(a,a+n,sum);
  int sum1=sum;
  for(int i=0;i<n-1;i++)
  { if(!sum-accumulate(a,a+1+i,0))
    {cout<<0;goto start;
    }
    else 
      s.insert(sum-accumulate(a,a+1+i,0));
     
  
  
  
  }
auto it=s.begin();
  cout<<*it;

start:
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:1: error: jump to label 'start'
   29 | start:
      | ^~~~~
a.cc:17:19: note:   from here
   17 |     {cout<<0;goto start;
      |                   ^~~~~
a.cc:26:6: note:   crosses initialization of 'std::_Rb_tree_const_iterator<int> it'
   26 | auto it=s.begin();
      |      ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
  cin>>n;
  a[101];
  set<int> s;
  
  for (int i=0;i>n;i++)
    cin<<a[i];
  int sum=0;
  sum=accumulate(a,a+n,sum);
  int sum1=sum;
  for(int i=0;i<n-1;i++)
  { if(!sum-accumulate(a,a+1+i,0))
    {cout<<0;goto start;
    }
    else 
      s.insert(sum-accumulate(a,a+1+i,0));
     
  
  
  
  }
auto it=s.begin();
  cout<<*it;

start:
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'a' was not declared in this scope
    7 |   a[101];
      |   ^
a.cc:29:1: error: jump to label 'start'
   29 | start:
      | ^~~~~
a.cc:17:19: note:   from here
   17 |     {cout<<0;goto start;
      |                   ^~~~~
a.cc:26:6: note:   crosses initialization of 'std::_Rb_tree_const_iterator<int> it'
   26 | auto it=s.begin();
      |      ^~
Language: C++

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

int main() {
  
  int N;
  int num = 0;
  int num2 = 0;
  int num6 = 0;
  int answer;
  
  cin >> N;
  
  vector<int> W(N);
  
  for(int i = 0;i < N;++i){
    cin >> W[i];
  }
  
  for(int i = 0;i < N;++i){
    num = W[i] + num;
  }
  
  for(int i = 0;i < N - 1;++i){
    num2 = num2 + W[i];
    int num3 = num - num2;
    int num4 = abs(num2 - num3);
    
    num6 = num6 + W[i + 1];
    int num7 = num - num6;
    int num8 = abs(num6 - num7);
    
    if(num4 == 0){
      cout << 0 << endl;
      return 0;
    }
    else{
      answer = min(num4,num8);
    }
  }
   
  cout << answer << endl;
  


Compiler output:
a.cc: In function 'int main()':
a.cc:43:26: error: expected '}' at end of input
   43 |   cout << answer << endl;
      |                          ^
a.cc:5:12: note: to match this '{'
    5 | int main() {
      |            ^
Language: C++

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

int main() {
  
  int N;
  int num = 0;
  int num2 = 0;
  
  cin >> N;
  
  vector<int> W(N);
  
  for(int i = 0;i < N;++i){
    cin >> W[i];
  }
  
  for(int i = 0;i < N;++i){
    num = W[i] + W[i + 1];
  }
  
  for(int i = 0;i < N;++i){
    num2 = W[i] + W[i + 1];
    if(num2 == num - num2){
      cout << 0 << endl;
      return;
    }
  }
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:7: error: return-statement with no value, in function returning 'int' [-fpermissive]
   26 |       return;
      |       ^~~~~~
Language: C++

#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#define ll long long
int main(){
  int n;
  
std::cin>>n;
  vector<ll>a(n);
  ll sum=0;
  vector<ll>sum();
  for(int i=0;i<n;i++){
  std::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])));
  }
return 0;  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:6: error: 'cin' is not a member of 'std'
    9 | std::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:10:3: error: 'vector' was not declared in this scope
   10 |   vector<ll>a(n);
      |   ^~~~~~
a.cc:10:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:3:
/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:5:12: error: expected primary-expression before 'long'
    5 | #define ll long long
      |            ^~~~
a.cc:10:10: note: in expansion of macro 'll'
   10 |   vector<ll>a(n);
      |          ^~
a.cc:5:12: error: expected primary-expression before 'long'
    5 | #define ll long long
      |            ^~~~
a.cc:12:10: note: in expansion of macro 'll'
   12 |   vector<ll>sum();
      |          ^~
a.cc:14:8: error: 'cin' is not a member of 'std'
   14 |   std::cin>>a[i];
      |        ^~~
a.cc:14:8: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:14:13: error: 'a' was not declared in this scope
   14 |   std::cin>>a[i];
      |             ^
a.cc:16:6: error: invalid types 'long long int[int]' for array subscript
   16 |   sum[i]=(i==0?a[i]:sum[i-1]+a[i]);
      |      ^
a.cc:16:24: error: invalid types 'long long int[int]' for array subscript
   16 |   sum[i]=(i==0?a[i]:sum[i-1]+a[i]);
      |                        ^
a.cc:20:22: error: invalid types 'long long int[int]' for array subscript
   20 |   max=min(max,abs(sum[i]-(sum[n-1]-sum[i])));
      |                      ^
a.cc:20:30: error: invalid types 'long long int[int]' for array subscript
   20 |   max=min(max,abs(sum[i]-(sum[n-1]-sum[i])));
      |                              ^
a.cc:20:39: error: invalid types 'long long int[int]' for array subscript
   20 |   max=min(max,abs(sum[i]-(sum[n-1]-sum[i])));
      |                                       ^
a.cc:20:7: error: 'min' was not declared in this scope; did you mean 'std::min'?
   20 |   max=min(max,abs(sum[i]-(sum[n-1]-sum[i])));
      |       ^~~
      |       std::min
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
#define pint pair<int,int>
#define pdouble pair<double,double>
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int sum = 0;
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }
    int sum2 = 0;
    rep(i,n){
        sum2 += a[i];
        if(sum2*2 >= sum){
            cout << min(abs(sum-sum2*2),abs(sum-sum2*2+a[i]*2) << endl;
            return 0;
        }
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:64: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'
   25 |             cout << min(abs(sum-sum2*2),abs(sum-sum2*2+a[i]*2) << endl;
      |                                         ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
#define pint pair<int,int>
#define pdouble pair<double,double>
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int sum = 0;
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }
    int sum2 = 0;
    rep(i,n){
        sum2 += a[i];
        if(sum2*2 >= sum){
            cout << min(abs(sum-sum2*2),abs(sum-sum2*2-a[i]*2) << endl;
            return 0;
        }
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:64: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'
   25 |             cout << min(abs(sum-sum2*2),abs(sum-sum2*2-a[i]*2) << endl;
      |                                         ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
Language: C++

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

int main(){
  int n,min=10000,s1,s2;cin>>n;
  vector<int> w(n,0);
  REP(i,n) cin>>w.at(i);
  REP(i,n-1){
    s1=s2=0;
    REP(j,n){
      if(j<=i) s1+=w.at(j);
      else s2+=w.at(j);
    }
    min=min(min,abs(s1-s2));
  }
  cout<<min;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:12: error: 'min' cannot be used as a function
   15 |     min=min(min,abs(s1-s2));
      |         ~~~^~~~~~~~~~~~~~~~
Language: C++

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

int main(){
  int n,min=10000,s1,s2;cin>>n;
  vector<int> w(n,0);
  REP(i,n) cin>>w.at(i);
  REP(i,n-1){
    s1=s2=0;
    REP(j,n){
      j<=i?s1+=w.at(j):s2+=w.at(j);
    }
    min=min(min,abs(s1-s2));
  }
  cout<<min;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:12: error: 'min' cannot be used as a function
   14 |     min=min(min,abs(s1-s2));
      |         ~~~^~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
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];
  }
  int mini=sum;
  int tmp=0;
  for (int i=0;i<N;++i){
    tmp+=W[i];
    mini=min(mini,abs(tmp-(sum-tmp)));
  }
  cout<<mini<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:3: error: 'vector' was not declared in this scope
    5 |   vector<int> W(N);
      |   ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | using namespace std;
a.cc:5:10: error: expected primary-expression before 'int'
    5 |   vector<int> W(N);
      |          ^~~
a.cc:8:10: error: 'W' was not declared in this scope
    8 |     cin>>W[i];
      |          ^
a.cc:14:10: error: 'W' was not declared in this scope
   14 |     tmp+=W[i];
      |          ^
Language: C++

#include <iostream>
#include <vector>
using namespace std;
int main(){
  int N; cin>>N;
  int W;
  int ttl=0;  
  for (int i=0;i<N;++i){
    cin>>W[i];
    ttl+=W[i];
  }
  int mini=ttl;
  int tmp=0;
  for (int i=0;i<N;++i){
    tmp+=W[i];
    mini=min(mini,abs(tmp-(ttl-tmp)));
  }
  cout<<mini<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:11: error: invalid types 'int[int]' for array subscript
    9 |     cin>>W[i];
      |           ^
a.cc:10:11: error: invalid types 'int[int]' for array subscript
   10 |     ttl+=W[i];
      |           ^
a.cc:15:11: error: invalid types 'int[int]' for array subscript
   15 |     tmp+=W[i];
      |           ^
Language: C++

#include <iostream>
using namespace std;
int main(){
  int N; cin>>N;
  int W;
  for (int i=0;i<N;++i)cin>>W[i];
  int ttl=0;
  for (int i=0;i<N;++i)ttl+=W[i];
  int mini=ttl;
  int tmp=0;
  for (int i=0;i<N;++i){
    tmp+=W[i];
    mini=min(mini,abs(tmp-(ttl-tmp)));
  }
  cout<<mini<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:30: error: invalid types 'int[int]' for array subscript
    6 |   for (int i=0;i<N;++i)cin>>W[i];
      |                              ^
a.cc:8:30: error: invalid types 'int[int]' for array subscript
    8 |   for (int i=0;i<N;++i)ttl+=W[i];
      |                              ^
a.cc:12:11: error: invalid types 'int[int]' for array subscript
   12 |     tmp+=W[i];
      |           ^
Language: C++

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

int main () {
int n, a, b; cin >> n;
  vector<int> p(n);
  rep(i,n) {
    cin >> p.at(i);
    a += p.at(i);
  }
  int ans = 1e9;
  rep(i,n) {
    b += p.at(i);
    a -= p.at(i);
    ans = min(ans,abs(a-b));
  }
  coout << ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:3: error: 'coout' was not declared in this scope
   18 |   coout << ans;
      |   ^~~~~
Language: C++

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

int main(void) {
	int n;
	cin >> n;
	vector<int> w(n);
	for (int i = 0; i < n; i++) {
		cin >> w[i];
	}
	int ans = 1e9;
	for (int i = 0; i < n; i++) {
		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;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:28: error: 'r' was not declared in this scope
   13 |                 int l = 0; r = 0;
      |                            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);

  for(int i=0;i<n;i++){
    cin>>a[i];
    
  }
  int mi=100000000;
  int g=0;

  int t=0;
  for(int i=0;i<n-1;i++){
    for(int j=n-1;j>i;j--){
      g+=a[j];
      
    }
    for(int q=0;q<i;q++){
      t+=a[i];
    }
    mi=min(mi,abs(b,t));
  }
    cout<<mi<<endl;
  }
      

Compiler output:
a.cc: In function 'int main()':
a.cc:24:19: error: 'b' was not declared in this scope
   24 |     mi=min(mi,abs(b,t));
      |                   ^
Language: C++

#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;
 
int w[N];

signed main() {
    IOS;
    #ifdef LOCAL
        freopen("input.txt","r", stdin);
        freopen("output.txt","w",stdout);
    #endif
    int n, s = 0;  cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> w[i], s += w[i];
    int p = s, t = 0;
    for(int i = 1; i <= n; i++){
        t += w[i];  s -= w[i];
        p = min(p, abs(s-t))
    }   
    cout << p;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:29: error: expected ';' before '}' token
   34 |         p = min(p, abs(s-t))
      |                             ^
      |                             ;
   35 |     }
      |     ~
Language: C++

#include<iostream>
#include<algorithm>
#include<math.h>

int main(){
  int N, w, o = 0, e = 0, ans;
  cin >> N;
  for (int i = 0; i < N; i++){
    cin >> w;
    if (i%2 == 0){
      e += w;
    } else {
      o += w;
    }
  }
  ans = (e > o) ? (e - o) : (o - e);
  
  cout << ans << 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:18:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   18 |   cout << ans << 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:18:18: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   18 |   cout << ans << 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)
      |     ^~~~
Language: C++

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

int main(){
  int N, w, o = 0, e = 0, ans;
  cin >> N;
  for (int i = 0; i < N; i++){
    cin >> w;
    if (i%2 == 0){
      e += w;
    } else {
      o += w;
    }
  }
  ans = (e > o) ? (e - o) : (o - e)
  
  cout << ans << endl;
  
  return 0;
}

Compiler output:
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 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:17:36: error: expected ';' before 'cout'
   17 |   ans = (e > o) ? (e - o) : (o - e)
      |                                    ^
      |                                    ;
   18 | 
   19 |   cout << ans << endl;
      |   ~~~~
Language: C++

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

int main(){
  int N, w, o = 0; e = 0, ans;
  cin >> N;
  for (int i = 0; i < N; i++){
    cin >> w;
    if (i%2 == 0){
      e += w;
    } else {
      o += w;
    }
  }
  ans = (e > o) ? (e - o) : (o - e)
  
  cout << ans << endl;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:20: error: 'e' was not declared in this scope
    7 |   int N, w, o = 0; e = 0, ans;
      |                    ^
a.cc:7:27: error: 'ans' was not declared in this scope; did you mean 'abs'?
    7 |   int N, w, o = 0; e = 0, ans;
      |                           ^~~
      |                           abs
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 a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
Language: C++

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

int main(){
  int N, w, o = 0; e = 0, ;
  cin >> N;
  int w[N];
  for (int i = 0; i < N; i++){
    cin >> w;
    if (i%2 == 0){
      e += w;
    } else {
      o += w;
    }
  }
  ans = (e > o) ? (e - o) : (o - e)
  
  cout << ans << endl;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:20: error: 'e' was not declared in this scope
    7 |   int N, w, o = 0; e = 0, ;
      |                    ^
a.cc:7:27: error: expected primary-expression before ';' token
    7 |   int N, w, o = 0; e = 0, ;
      |                           ^
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 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:7: error: conflicting declaration 'int w [N]'
    9 |   int w[N];
      |       ^
a.cc:7:10: note: previous declaration as 'int w'
    7 |   int N, w, o = 0; e = 0, ;
      |          ^
a.cc:18:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
   18 |   ans = (e > o) ? (e - o) : (o - e)
      |   ^~~
      |   abs
Language: C++

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

int main() {
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    int wa=0;
    for(int i=0;i<n;i++) wa+=a[i];
    int waf=0;
    int sa=100000000;
    for(int i=0;(i+1)/2;i++) {
        waf+=a[i];
        wab=wa-waf;
        sa=min(sa, abs(waf-wab));
    }

    cout<<sa<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:9: error: 'wab' was not declared in this scope; did you mean 'waf'?
   15 |         wab=wa-waf;
      |         ^~~
      |         waf
Language: C++

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
void main()
{
	int n;

	scanf("%d", &n);

	int *weight = malloc(n*sizeof(int));
	
	for(int i=0; i<n; i++)
		scanf("%d", weight+i);

	int s1=0, s2=0, sd=0;
	for(int t=0; t<n; t++)
	{
		s1 = 0, s2=0;
		printf("This is t= %d \n",t);
		for(int j=0; j<=t; j++)
		{
			printf("Adding to s1 %d\n", weight[j]);
			s1=s1+weight[j];
		}
		for(int j=t+1; j<n; j++)
		{
			printf("Adding to s2 %d\n", weight[j]);

			s2 = s2+weight[j];
		}
		int s = abs(s1-s2);
		printf("difference %d\n", s);
		if(t==1)
			sd = abs(s1-s2);
		else if(sd>abs(s1-s2))
			sd = abs(s1-s2);
	}

	printf("%d\n", sd);

	free(weight);

}



Compiler output:
a.cc:4:1: error: '::main' must return 'int'
    4 | void main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:10:29: error: invalid conversion from 'void*' to 'int*' [-fpermissive]
   10 |         int *weight = malloc(n*sizeof(int));
      |                       ~~~~~~^~~~~~~~~~~~~~~
      |                             |
      |                             void*
Language: C++

#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
int main() {
	int n,allsum = 0;
	cin >> n;
	vector<int> list(n);
	rep(i, n) {
		cin >> list[i];
		allsum += list[i];
	}
	int amount = allsum,k = 0;

	rep(i, n) {
		rep(j, i + 1) {
			int k += list[j];
		}
		int balance = min(abs(k), abs(amount - k));
	}
	cout << balance << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:31: error: expected initializer before '+=' token
   16 |                         int k += list[j];
      |                               ^~
a.cc:20:17: error: 'balance' was not declared in this scope
   20 |         cout << balance << endl;
      |                 ^~~~~~~
Language: C++

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

int main() {
    int n;
    cin >> n;
    vector<int> w(n);
    for(auto& e: w){
        cin >> e;
    }
    vector<int> s_1(n+1), s_2(n+1);
    s_1[0] = 0;
    s_2[n] = 0;
    for(int i = 1;i <= n;i++){
        s_1[i] = s_1[i-1] + w[i];
    }
    for(int i = n - 1;i >= 0;i--){
        s_2[i] = s_2[i+1] + w[i];
    }
    int res = 0;
    for(int i = 1;i <= n;i++){
        res = min(res, abs(s_1[i-1] - s_2[i]))
    }
    cout << res << endl;
    return 0;
}

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

#include <stdio.h>
 
int* bubbleSort(int* N, int len){
  int i,j;
 
  for(i=0; i<len; i++){
    for(j=len-1; j>i; j--){
      if(N[j] < N[j-1]){
        temp = N[j];
        N[j] = N[j-1];
        N[j-1] = temp;
      }
    }
  }
 
  return N;
}
 
int main(){
  int w[100];
  int N, sum1=0, sum2=0;
  
  scanf("%d", &N);
  for(int i=0;i<N;i++){
    scanf("%d",&w[i]);
  	sum1+= w[i];
  }
  bubbleSort(w, N);
  int delta=1000;
  for(int i=0;i<N;i++){
    sum2 += w[i];
    if(sum1 - sum2 > 0 && sum1 - sum2 < delta)delta = sum1 - sum2;
    else if(sum2 - sum1 < delta) 
    {
      delta = sum2 - sum1;
      break;
    }
  }
  printf("%d", delta);
  return 0;
}

Compiler output:
a.cc: In function 'int* bubbleSort(int*, int)':
a.cc:9:9: error: 'temp' was not declared in this scope
    9 |         temp = N[j];
      |         ^~~~
Language: C++

#include <stdio.h>
 
int* bubbleSort(int* N, int len){
  int i,j;
 int temp;
  for(i=0; i<len; i++){
    for(j=len-1; j>i; j--){
      if(N[j] < N[j-1]){
        temp = N[j];
        N[j] = N[j-1];
        N[j-1] = temp;
      }
    }
  }
 
  return N;
}
 
int main(){
  int w[100];
  int N, sum1=0, sum2=0;
  
  scanf("%d", &N);
  for(int i=0;i<N;i++){
    scanf("%d",&w[i]);
  	sum1+= w[i];
  }
  bubbleSort(w, N);
  int delta=1000;
  for(int i=0;i<N;i++){
    sum2 += w[i];
    if(sum1 - sum2 > 0 && sum1 - sum2 < delta)delta = sum1 - sum2;
    else if(sum2 - sum1 < delta) 
    {
      delta = sum2 - sum1;
      break;
    }
  }
  printf("%d", delta);
  return 0;


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

#include <stdio.h>

int* bubbleSort(int* N, int len){
  int i,j;

  for(i=0; i<len; i++){
    for(j=len-1; j>i; j--){
      if(N[j] < N[j-1]){
        temp = N[j];
        N[j] = N[j-1];
        N[j-1] = temp;
      }
    }
  }

  return N;
}

int main(){
  int w[100];
  int N, sum1=0, sum2=0;
  
  scanf("%d", &N);
  for(int i=0;i<N;i++){
    scanf("%d",&w[i]);
  	sum1+= w[i];
  }
  bubbleSort(w, N);
  int delta=1000;
  for(int i=0;i<N;i++){
    sum2 += w[i];
    if(sum1 - sum2 > 0 && sum1 - sum2 < delta)delta = sum1 - sum2;
    else if(sum2 - sum1 < delta) 
    {
      delta = sum2 - sum1;
      break;
    }
  }
  printf("%d", delta);
  return 0;
}
    
    
  
    
    

Compiler output:
a.cc: In function 'int* bubbleSort(int*, int)':
a.cc:9:9: error: 'temp' was not declared in this scope
    9 |         temp = N[j];
      |         ^~~~
Language: C++

#include <iostream>
#include <vector>

using namspace std;

int abs(int a){
  return a >= 0 ? a: -a;
}

int main(){
  int N;
  vector<int> w;
  cin >> N;
  for(int i=0;i<N;i++){
    int input;
    cin >> input;
    w.push_back(input);
  }
  int ans=10000000000;
  int S1=0,S2=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(w[j]>i){
        S1+=w[j];
      }else{
        S2+=w[j];
      }
    }
    int X=abs(S1-S2);
    if(X<ans){
      ans=X;
    }
  }
  cout << ans;
}

Compiler output:
a.cc:4:7: error: expected nested-name-specifier before 'namspace'
    4 | using namspace std;
      |       ^~~~~~~~
a.cc: In function 'int main()':
a.cc:12:3: error: 'vector' was not declared in this scope
   12 |   vector<int> w;
      |   ^~~~~~
a.cc:12: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:12:10: error: expected primary-expression before 'int'
   12 |   vector<int> w;
      |          ^~~
a.cc:13:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   13 |   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:17:5: error: 'w' was not declared in this scope
   17 |     w.push_back(input);
      |     ^
a.cc:19:11: warning: overflow in conversion from 'long int' to 'int' changes value from '10000000000' to '1410065408' [-Woverflow]
   19 |   int ans=10000000000;
      |           ^~~~~~~~~~~
a.cc:23:10: error: 'w' was not declared in this scope
   23 |       if(w[j]>i){
      |          ^
a.cc:34:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   34 |   cout << ans;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C++

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

int main(){
  int n;
  cin >> n;
  vector<int> w(n);
  rep(i,n) cin >> w[i];
  int ans = 1e9;
  
  rep(i+1,n-1){
    int left,right;
    left = 0;
    right = 0;
    int k = i;
    rep(j,i) left += w[j];
    rep(k,n) rihgt += w[k];
    ans = min(min,abs(left-right));
  }
    cout << ans << endl;
}

Compiler output:
a.cc:2:4: error: expected constructor, destructor, or type conversion before '(' token
    2 | rep(i,n) for(int i=0;i<n;i++);
      |    ^
a.cc:2:22: error: 'i' does not name a type
    2 | rep(i,n) for(int i=0;i<n;i++);
      |                      ^
a.cc:2:26: error: 'i' does not name a type
    2 | rep(i,n) for(int i=0;i<n;i++);
      |                          ^
a.cc: In function 'int main()':
a.cc:9:7: error: 'i' was not declared in this scope
    9 |   rep(i,n) cin >> w[i];
      |       ^
a.cc:9:3: error: 'rep' was not declared in this scope
    9 |   rep(i,n) cin >> w[i];
      |   ^~~
Language: C++

#include <iostream>
using namespace std;

int pref[102], a[102];
int main() {
  int n;
  cin>>n;
  int i;
  for(i=1;i<=n;i++) cin>>a[i], pref[i] = pref[i-1] + a[i];
  
  int mi = pref[n] - 2*pref[i];
  
  for(i=2 i<n; i++)
    mi = min(mi, pref[n]-2*pref[i]);
  cout<<mi;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:10: error: expected ';' before 'i'
   13 |   for(i=2 i<n; i++)
      |          ^~
      |          ;
a.cc:13:19: error: expected ';' before ')' token
   13 |   for(i=2 i<n; i++)
      |                   ^
      |                   ;
Language: C++

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

int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++){
  cin >> vec.at(i);
  }
  int sum;
  for (int i = 0; i < n; i++){
  sum += vec.at(i);
  }
  vector <int> sum1(n);
  for (int i = 0; i < n; i++){
   for (int j = 0; j < i; j++){
   sum1.at(i) += vec.at(j);
   }
  }
  vector <int> sum2(n);
  for (int i = 0; i < n; i++){
  sum2.at(i) = abs(2*sum1.at(i) - sum);
  }
  sort(sum2.begin(),sum2.end());
  cout << sum2.at(0)
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:21: error: expected ';' before '}' token
   26 |   cout << sum2.at(0)
      |                     ^
      |                     ;
   27 | }
      | ~
Language: Java

import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] array = new int[n];
      for(int i = 0;i < array.length;i++){
      	array[i] = sc.nextInt();
      }
      int s1 = 0;
      int s2 = 0;
      for(int i = 0;i < array.length;i++){
      	s2 += array[i];
      }
      
      int count = -1;
      for(int i = 0;i < array.length;i++){
      	if(s1 < s2){
          s1 += array[i];
          s2 -= array[i];
          count++;
        }
      }
      if(count < 0)count = 0
      System.out.println(Math.min(Math.abs(s1-s2),Math.abs(s1-s2+array[count]*2)));
    }
}

Compiler output:
Main.java:24: error: ';' expected
      if(count < 0)count = 0
                            ^
1 error
Language: Java

import java.util.*;

class Main{
  static Scanner sc = new Scanner(System.in);
  public static void main(String args[]){
    int n=sc.nextInt();
    int a[] = new int[n+1];
    a[0]=0;
    for(int i=1;i<=n;i++){
      a[i]=a[i-1]+sc.nextInt();
    }
    int min=Integer.max;
    for(int t=1;t<n;t++){
      min=Math.min(Math.abs((a[t]-a[0])-(a[n]-a[t])),min);
    }
  }
}

Compiler output:
Main.java:12: error: cannot find symbol
    int min=Integer.max;
                   ^
  symbol:   variable max
  location: class Integer
1 error
Language: C++

n = int(input())
s = list(map(int,input().split()))
minsum = 9999
sum1 = 0
sum2 = 0
for i in range(n):
    for j in range(i):
        sum1 += s[j]
    for k in range(i+1,n):
        sum2 += s[k]
    minsum = min(minsum,abs(sum1-sum2))
print(minsum)

Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n = int(input())
      | ^
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:13:8: error: expected ';' before '+' token
   13 |   rep(i+1,n){
      |        ^
a.cc:2:26: note: in definition of macro 'rep'
    2 | #define rep(i,n) for(int i=0;i<n;i++)
      |                          ^
a.cc:13:8: error: lvalue required as left operand of assignment
   13 |   rep(i+1,n){
      |        ^~
a.cc:2:26: note: in definition of macro 'rep'
    2 | #define rep(i,n) for(int i=0;i<n;i++)
      |                          ^
a.cc:2:33: error: expected ')' before ';' token
    2 | #define rep(i,n) for(int i=0;i<n;i++)
      |                     ~           ^
a.cc:13:3: note: in expansion of macro 'rep'
   13 |   rep(i+1,n){
      |   ^~~
a.cc:13:7: error: 'i' was not declared in this scope
   13 |   rep(i+1,n){
      |       ^
a.cc:2:34: note: in definition of macro 'rep'
    2 | #define rep(i,n) for(int i=0;i<n;i++)
      |                                  ^
a.cc:13:9: error: lvalue required as increment operand
   13 |   rep(i+1,n){
      |         ^
a.cc:2:34: note: in definition of macro 'rep'
    2 | #define rep(i,n) for(int i=0;i<n;i++)
      |                                  ^
Language: Java

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] W = new int[N];
        for (int i = 0; i < N; i++)
            W[i] = sc.nextInt();
        
        int sum = 0;

        for(int i = 0; i < N; i++)
            sum += W[i];
        
        int ans = sum;
        
        for(int i = 0; i < N; i++){
            int sum_i = sum_t(W, i);
            if(Math.abs((sum_i)-(sum-sum_i)) < ans)
                ans = Math.abs((sum_i)-(sum-sum_i));
        }
        System.out.println(ans);
        sc.close();
    }
    
    static int sum_t(int[] a, int t){
        int sum = 0;
        for(int i = 0; i < t; i++)
            sum += a[i];
        return sum;
    }
}

Compiler output:
Main.java:3: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:3: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
                         ^
  symbol:   class Scanner
  location: class Main
2 errors
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[i];
  }
  
  int ans;
  int s;
  for (int i = 0; i < N; i++) {
    s += W[i];
  }
  for (int i = 0; i < N; i++) {
    int s1 = 0;
    int s2 = 0;
    for (int j = 0; j < i+1; j++) {
      s1 += W[j]
    }
    s2 = s - s1;
    
    if (i = 0) ans = abs(s1 - s2);
    else if ans = min(ans, abs(s1 - s2));
    
  }
  
  cout << ans << endl;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:17: error: expected ';' before '}' token
   21 |       s1 += W[j]
      |                 ^
      |                 ;
   22 |     }
      |     ~            
a.cc:26:13: error: expected '(' before 'ans'
   26 |     else if ans = min(ans, abs(s1 - s2));
      |             ^~~
      |             (
Language: C++

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

int main(){
	int N;
	cin >> N;
	vector<int> W(N);
	int sum = 0;
	int ans1, ans2;
	for(int i = 0; i < N; i++){
		cin >> W.at(i);
		sum += W.at(i);
	}
	sum /= 2;
	int com = 0;
	for(int i = 0; i < N; i++){
		com += W.at(i);
		if(som > sum){
			ans1 = com - sum;
			if(ans1 < 0) ans1 *= (-1);
			ans2 = com - sum - W.at(i);
			if(ans2 < 0) ans2 += (-1);
		}
	}
	int ans = min(ans1, ans2);
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:20: error: 'som' was not declared in this scope; did you mean 'com'?
   18 |                 if(som > sum){
      |                    ^~~
      |                    com