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

#include <stdio.h>

int main()
{
    int n=0, sum = 0, X;
    int t[100];
    int i = 0;
    int sun = 0;
    for(n=0; n<100 ;n++)
    {
        printf("%d個目の数値を入力してください=",n+1);
        scanf("%d",&t[n]);
        sum = sum + t[n];
    }
    
    while{
    sun = sun + t[i];
    i = i + 1;
       if (end_flag) {
               sun > sum/2;
                break;
        }
    }
  if(sum/2-sun > sun+t[i+1] ){
  i = i+1;
  }

 
    printf("%d\n",i);
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:16:10: error: expected '(' before '{' token
   16 |     while{
      |          ^
      |          (
main.c:19:12: error: 'end_flag' undeclared (first use in this function)
   19 |        if (end_flag) {
      |            ^~~~~~~~
main.c:19:12: note: each undeclared identifier is reported only once for each function it appears in
Language: Java

import java.util.*;
import java.util.InputMismatchException;
 
class Main {
  public static void main(String args[]) {
    
      Scanner sc = new Scanner(System.in);
      int all = sc.nextInt();
      int[] w = new int[all];
      int resurt;
      
      
      for(int i = 0; i<all; i++){
        w[i] = sc.nextInt();
      }
      for(int i = 0; i<all; i++){
        if(!(nibun(all,i,w))){resurt=i;}
        
      }
     
      int mae2;
      int ato2;
      for(int i=0; i<result; i++){
        mae2 += w[i];
      }
      for(int i=0; i<all-result; i++){
        ato2 += w[i+result];
      }

      scanner.close();
      System.out.println(mae2-ato2);
    
    
  }
  
  public static boolean nibun(int all, int t, int[] w){
    int mae;
    int ato;
    for (int i = 0; i<t; i++){
      mae += w[i];
    }
    for (int i = 0; i<all-t; i++){
      ato += w[i+t];
    }
    return mae>ato;
  }
}

Compiler output:
Main.java:23: error: cannot find symbol
      for(int i=0; i<result; i++){
                     ^
  symbol:   variable result
  location: class Main
Main.java:26: error: cannot find symbol
      for(int i=0; i<all-result; i++){
                         ^
  symbol:   variable result
  location: class Main
Main.java:27: error: cannot find symbol
        ato2 += w[i+result];
                    ^
  symbol:   variable result
  location: class Main
Main.java:30: error: cannot find symbol
      scanner.close();
      ^
  symbol:   variable scanner
  location: class Main
4 errors
Language: Java

import java.util.*;
import java.util.InputMismatchException;
 
class Main {
  public static void main(String args[]) {
    try {
      Scanner sc = new Scanner(System.in);
      int all = sc.nextInt();
      int[] w = new int[all];
      int resurt;
      
      
      for(int i = 0; i<all; i++){
        w[i] = sc.nextInt();
      }
      for(int i = 0; i<all; i++){
        if(!(nibun(all,i,w))){resurt=i};
        
      }
     
      int mae2;
      int ato2;
      for(int i=0; i<result; i++){
        mae2 += w[i];
      }
      for(int i=0; i<all-result; i++){
        mae2 += w[i+result];
      }
        
        
      
      
 
     
      System.out.println(x + y);
      scanner.close();
    
    }
  }
  
  public static boolean nibun(int all, int t, int[] w){
    int mae;
    int ato;
    for (int i = 0; i<t; i++){
      mae += w[i];
    }
    for (int i = 0; i<all-t; i++){
      ato += w[i+t];
    }
    return mae>ato;
  }
}

Compiler output:
Main.java:17: error: ';' expected
        if(!(nibun(all,i,w))){resurt=i};
                                      ^
Main.java:6: error: 'try' without 'catch', 'finally' or resource declarations
    try {
    ^
2 errors
Language: Java

import java.util.*;
import java.util.InputMismatchException;
 
class Main {
  public static void main(String args[]) {
    try {
      Scanner sc = new Scanner(System.in);
      int all = sc.nextInt();
      int[] w = new int[all];
      int resurt;
      
      
      for(int i = 0; i<all; i++){
        w[i] = sc.nextInt();
      }
      for(int i = 0; i<all; i++){
        if(!(nibun(all,i,w))){resurt=i}
        
      }
     
      int mae2;
      int ato2;
      for(int i=0; i<result; i++){
        mae2 += w[i]
      }
      for(int i=0; i<all-result; i++){
        mae2 += w[i+result]
      }
        
        
      
      
 
     
      System.out.println(x + y);
      scanner.close();
    
    }
  }
  
  public static boolean nibun(int all, int t, int[] w){
    int mae;
    int ato;
    for (int i = 0; i<t; i++){
      mae += w[i];
    }
    for (int i = 0; i<all-t; i++){
      ato += w[i+t]
    }
    return mae>ato;
  }
}

Compiler output:
Main.java:17: error: ';' expected
        if(!(nibun(all,i,w))){resurt=i}
                                      ^
Main.java:24: error: ';' expected
        mae2 += w[i]
                    ^
Main.java:27: error: ';' expected
        mae2 += w[i+result]
                           ^
Main.java:6: error: 'try' without 'catch', 'finally' or resource declarations
    try {
    ^
Main.java:48: error: ';' expected
      ato += w[i+t]
                   ^
5 errors
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
    int N, ans1 = 0, ans2 = 0, anans;
    cin >> N;
    vector<int> w(N), ans(N);
    ans[0] = 100000, ans[1] = 10000;
    for (int i = 0; i < N; ++i) {
        cin >> w[i];
    }
    for (int T = 2; T < N; ++T) {
        for (int j = 0; j < N; ++j) {
            if (j <= T) {
                ans1 += w[j];
            }
            else {
                ans2 += w[j];
            }
        }
        ans[T] = abs(ans1 - ans2);
        ans1 = 0, ans2 = 0;
    }
    ans[0] = 100000, ans[1] = 10000;
    anans = *min_element(ans.begin(), ans.end());

    }
}




Compiler output:
a.cc:31:1: error: expected declaration before '}' token
   31 | }
      | ^
Language: C++

#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
int main()
{
 int N;
 cin >> N;
 vector<int> vec(N);
 for(int i=0;i<N;i++){
     cin >> vec[i];
 }
int s1=0;
int s2 =0;
for(int T=0;T<=N;T++){
for(int i=0;i<T;i++) s1 +=vec[i];
for(int j=T;j<=N;j++)  s2 +=vec[i];
}
int ans = s1 - s2;
cout << abs(ans) << endl;
return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:33: error: 'i' was not declared in this scope
   17 | for(int j=T;j<=N;j++)  s2 +=vec[i];
      |                                 ^
Language: C++

#include<iostream>
#include<vector>
using namespace std;
int main(){
  int N,W,size,sum=0,sum1=0,sum2=0,ans;
  vector<int> v;
  for(int i=0;i<N;i++){
  	cin >> W;
    sum+=W;
    v.push_back(W);
  }
  size=v.size()
  for(int j=0;j<size();j++){
  	if(sum1<sum/N){
      sum1+=v[j];
      if(sum/N-sum1>sum/N-(sum1+v[j+1])){
      	size++;
      }
    }
    else{
      sum2+=v[j];
    }
  }
  ans=abs(sum1-sum2);
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:16: error: expected ';' before 'for'
   12 |   size=v.size()
      |                ^
      |                ;
   13 |   for(int j=0;j<size();j++){
      |   ~~~           
a.cc:13:15: error: 'j' was not declared in this scope
   13 |   for(int j=0;j<size();j++){
      |               ^
a.cc:13:21: error: 'size' cannot be used as a function
   13 |   for(int j=0;j<size();j++){
      |                 ~~~~^~
Language: C++

#include<stdio.h>

int n,w[101],s[101];

int min(int x,int y){return x>=y?y:x;}

int main(){
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&w[i]);
    s[i]=s[i-1]+w[i];
  }
  for(int i=0;i<mx;i++)if(s[i]*2>=s[n-1]){
    printf("%d",min(s[i]*2-s[n-1],s[n-1]-s[i-1]*2));
    break;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:17: error: 'mx' was not declared in this scope
   13 |   for(int i=0;i<mx;i++)if(s[i]*2>=s[n-1]){
      |                 ^~
Language: C++

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

int main(){
  int n;
  int s1=0,s2=0,min,s;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  
  for(int i=0;i<n;i++){
    	for(int j=0;j<=i;j++){
			s1+=a.at(j);
        }
    	for(int k=i+1;k<n;k++){
          	s2+=a.at(k);
        }
    s=s1-s2;
    s=fabs(s)
    if(min>s) min = s;
  }
  
  cout << min << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:14: error: expected ';' before 'if'
   22 |     s=fabs(s)
      |              ^
      |              ;
   23 |     if(min>s) min = s;
      |     ~~
Language: C++

#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
int main()
{
 int N;
 cin >> N;
 vector<int> vec(N);
 for(int i=0:i<N;i++){
     cin >> vec[i];
 }
int s1=0;
int s2 =0;
for(int T=1;T<N;T++){
for(int i=0;i<T;i++) s1 +=vec[i];
for(int i=T;i<N;i++)  s2 +=vec[i];
}
cout << abs(s1-s2) << endl;
return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:11: error: initializer in range-based 'for' loop
   10 |  for(int i=0:i<N;i++){
      |           ^
a.cc:10:17: error: expected ')' before ';' token
   10 |  for(int i=0:i<N;i++){
      |     ~           ^
      |                 )
a.cc:10:18: error: 'i' was not declared in this scope
   10 |  for(int i=0:i<N;i++){
      |                  ^
Language: C++

#include <iostream>
#include <limits>

using namespace std;

int main(int argc, char *argv[])
{
	int W[101], N;

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> W[i];
	}

	int ans = INT_MAX;
	for (int i = 1; i < N; i++) {
		int S1 = 0, S2 = 0;
		for (int j = 0; j < i; j++) {
			S1 += W[j];
		}
		for (int k = i; k < N; k++) {
			S2 += W[k];
		}
		ans = min(ans, S1 - S2 < 0 ? S2 - S1 : S1 - S2);
	}

	cout << ans << "\n";

	return 0;
}

Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:15:19: error: 'INT_MAX' was not declared in this scope
   15 |         int ans = INT_MAX;
      |                   ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <limits>
  +++ |+#include <climits>
    3 |
Language: C++

#include<iostream>
#include <algorithm>
using namespace std;
int main()
{
	double n;
	int w[100];
	double sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> w[i];
		sum += w[i];
	}
	double nowsum = 0;
	double ans = 100000;
	nowsum = w[0];
	for (int i = 1; i < n-1; i++)
	{
		nowsum += w[i];
		if (fabs((sum/2) - nowsum) < fabs(ans))
		{
			ans = fabs((sum/2) - nowsum);
			//cout << i << "," << sum<<","<<nowsum<<","<<abs((sum/2) - nowsum) << endl;
		}
	}
	cout << ans*2 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:21: error: 'fabs' was not declared in this scope; did you mean 'labs'?
   21 |                 if (fabs((sum/2) - nowsum) < fabs(ans))
      |                     ^~~~
      |                     labs
Language: C++

#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
int main()
{
 int N;
 cin >> N;
 vector<int> vec(N);
 for(int i=0;i<N;i++){
     cin >> vec[i];
 }
int s1=0;
int s2 =0;
for(int T=1;T<N;T++){
for(int i=0;i<T;i++) s1 +=vec[i];
for(int i=T;i<N;i++)  s2 +=vec[i];
}
cout << abs(s1-s2) << endl;
return 0
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:9: error: expected ';' before '}' token
   20 | return 0
      |         ^
      |         ;
   21 | }
      | ~
Language: C++

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

int main() {
  int n, w[n], t, s1=0, s2=0, x, y;
  
  cin >> n;
  for(int i=0;i<n;i++) {
    cin >> w[i];
    s2 += w[i];
  }
  s1 = w[0];
    
  for(int i=1;s2>=s1;i++) {
    s1 += w[i];
    s2 -= w[i];
  }
  x = s1 - x2;
  y = (s2 - s1) + w[i] * 2;
  if (x > y)
    cout <<  y << endl;
  else
    cout << x << endl;
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:12: error: 'x2' was not declared in this scope; did you mean 'x'?
   18 |   x = s1 - x2;
      |            ^~
      |            x
a.cc:19:21: error: 'i' was not declared in this scope
   19 |   y = (s2 - s1) + w[i] * 2;
      |                     ^
Language: C++

#include<iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n;
	int w[100];
	int sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> w[i];
		sum += w[i];
	}
	int nowsum = 0;
	double ans = 100000;
	nowsum = w[0];
	for (int i = 1; i < n-1; i++)
	{
		nowsum += w[i];
		if (fabs((sum/2) - nowsum) < fabs(ans))
		{
			ans = fabs((sum/2) - nowsum);
			//cout << i << "," << sum<<","<<nowsum<<","<<abs((sum/2) - nowsum) << endl;
		}
	}
	cout << ans*2 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:21: error: 'fabs' was not declared in this scope; did you mean 'labs'?
   21 |                 if (fabs((sum/2) - nowsum) < fabs(ans))
      |                     ^~~~
      |                     labs
Language: C++

#include <iostream>
#include <array>
#include<stdlib.h>
#include<algorithm>
using namespace std;
 int main(){
   array<int, 100> w;
   int n,s1,s2,ans;
   cin>>n;
   for(int i = 0; i<n; i++){
     cin>>w.at(i);
   }
   ans = 10000
   for(int i = 1; i < n; i++){
     s1 = 0;
     s2 = 0;
     for(int j = 1; j <= i; j++){
       s1 = s1 + w.at(j);
     }
     for(int j = i+1;j < n; j++){
       s2 = s2 + w.at(j);
     }
     if(ans > abs(s2-s1)){
       ans = abs(s2-s1);
     }
   }
   cout<<ans<<endl;
 }

Compiler output:
a.cc: In function 'int main()':
a.cc:13:15: error: expected ';' before 'for'
   13 |    ans = 10000
      |               ^
      |               ;
   14 |    for(int i = 1; i < n; i++){
      |    ~~~         
a.cc:14:19: error: 'i' was not declared in this scope
   14 |    for(int i = 1; i < n; i++){
      |                   ^
Language: C++

#include<bits/stdc++.h>

using namespace std;
int sumarraybegin(vector<int> &w,int n)
{
  int sum=0; 
  if(n==0)
  {
    sum+=w.at(0);
  }
  else{
    for(int i=0;i<n;i++)
    {
      sum += w.at(i);
    }
  }
  
  return sum;
}
int sumarrayend(vector<int> &w,int n,int b)
{
  int sum=0; 
  for(int i=n-1;i>b;i--)
  {
    sum += w.at(i);
  }
  return sum;
}
int main()
{
  int n;
  cin >> n;
  vector<int> w(n);
  vector<int> t(n);
  for(int i=0;i<n;i++)
  {
    cin >> w.at(i);
  }
  int s1;
  int s2;
  for(int i=0;i<n;i++)
  {
    s1=sumarraybegin(w,i);
    s2=sumarrayend(w,n,i);
    if(s1>s2){
      t.at(i)=s1-s2;
    }
    else{
      t.at(i)=s2-s1;
    }
  }
  sort(t.begin(),t.end());

  sout << t.at(0) << endl;
  
   
}

Compiler output:
a.cc: In function 'int main()':
a.cc:54:3: error: 'sout' was not declared in this scope; did you mean 'stdout'?
   54 |   sout << t.at(0) << endl;
      |   ^~~~
      |   stdout
Language: C

#include<stdio.h>
#include<stdlib.h>

int main(void)
{
    int n;
    int w[100];
    int i;
    int s[2]={0,0};
    int sum=0;
    int ans;

    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&w[i]);
        sum+=//w[i];printf("i,sum=%d,%d\n",i,sum);
    }
    
    i=0;
    while(s[0]<sum/2){
        s[0]+=w[i];
        i++;//printf("i,s=%d,%d\n",i,s[0]);
    }
    s[1]=sum-s[0];

    ans=abs(s[0]-s[1]);

    printf("%d\n",ans);
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:17:5: error: expected expression before '}' token
   17 |     }
      |     ^
Language: C++

#include<iostream>
#include<vector>
int main(){
  int N,W,sum=0,sum1=0,sum2=0,ans;
  vector<int> v;
  for(int i=0;i<N;i++){
  	cin >> W;
    sum+=W;
    v.push_back(W);
  }
  for(int j=0;j<N;j++){
  	if(sum1<sum/N){
      sum1+=v[j];
    }
    else{
      sum2+=v[j];
    }
  }
  ans=abs(sum1+sum2);
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:3: error: 'vector' was not declared in this scope
    5 |   vector<int> v;
      |   ^~~~~~
a.cc:5: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:5:10: error: expected primary-expression before 'int'
    5 |   vector<int> v;
      |          ^~~
a.cc:7:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    7 |         cin >> W;
      |         ^~~
      |         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:5: error: 'v' was not declared in this scope
    9 |     v.push_back(W);
      |     ^
a.cc:13:13: error: 'v' was not declared in this scope
   13 |       sum1+=v[j];
      |             ^
a.cc:16:13: error: 'v' was not declared in this scope
   16 |       sum2+=v[j];
      |             ^
a.cc:20:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   20 |   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:20:18: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   20 |   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 <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
  int N; scanf("%d", &N);
  int i, j;
  int W[100] = {};
  int S[101];

  S[0] = 0;
  
  for(i = 0; i < N; i++){
    scanf("%d", &W[i]);
    S[i + 1] = S[i] + W[i];
  }

  int min = 100000;
  
  for(j = 0; j < N; j++){
    if(abs(S[j] - (S[N + 1] - S[j])) < min){
      min = abs(2S[j] - S[N + 1]);
    }
  }

  printf("%d", min);
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:22:17: error: invalid suffix "S" on integer constant
   22 |       min = abs(2S[j] - S[N + 1]);
      |                 ^~
Language: C++

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

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

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

  int t = 0;
  vector<int> ans(n);
  for(t = 0; t < n; t++) {
    int s1 = 0, s2 = 0;
    for(int i = 0; i <= t; i++) s1 += w[i];
    for(int i = t+1; i < n; i++) s2 += w[i];
    ans[t] = abs(s1 - s2);
  }

  int min = *std::min_element(ans.begin(), ans.end());

  cout << min;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:19: error: 'min_element' is not a member of 'std'; did you mean 'tuple_element'?
   23 |   int min = *std::min_element(ans.begin(), ans.end());
      |                   ^~~~~~~~~~~
      |                   tuple_element
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <stlib.h>
#include <algorithm>
using namespace std;

int main(){
  int N; cin >> N;
  int w[110];
  int w_sum = 0;
  for (int i = 0; i < N; i++){
    cin >> w[i];
    w_sum += w[i];
  }
  
  int ans = 100000000;
  int s1 = 0,s2 = 0;
  for (int i = 0; i < N - 1; i++){
    s1 += w[i];
    s2 = w_sum - s1;
    int temp = abs (s1 - s2);
    ans = min(ans, temp);
  }
  cout << ans << endl;
}

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

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int sum=0;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }
  int k=0;
  sort(a.begin(),a,end());
  int ans=sum;
  for(int i=0;i<n;i++){
    sum-=a[i];
    k+=a[i];
    if(abs(sum-k)<ans){ans=abs(sum-k);}
  }
  cout<<ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:23: error: no matching function for call to 'end()'
   13 |   sort(a.begin(),a,end());
      |                    ~~~^~
In file included from /usr/include/c++/14/bits/algorithmfwd.h:39,
                 from /usr/include/c++/14/bits/stl_algo.h:59,
                 from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/initializer_list:99:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
   99 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
/usr/include/c++/14/initializer_list:99:5: note:   candidate expects 1 argument, 0 provided
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/range_access.h:74:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
   74 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/range_access.h:85:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
   85 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/range_access.h:106:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
  106 |     end(_Tp (&__arr)[_Nm]) noexcept
      |     ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note:   candidate expects 1 argument, 0 provided
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166:
/usr/include/c++/14/valarray:1249:5: note: candidate: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
 1249 |     end(valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/valarray:1249:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/valarray:1265:5: note: candidate: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/valarray:1265:5: note:   candidate expects 1 argument, 0 provided
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int cmp(void const *a, void const *b) {
	return *((int*)a) - *((int*)b);
}

int main(void) {
	int n, w[100];
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", w + i);
	}
	int s1, s2, min = INT_MAX;
	for (int i = 0,j; i < n; i++) {
		s1 = 0; s2 = 0;
		for (j = 0; j <= i; j++) {
			s1 += w[j];
		}
		for (; j < n; j++) {
			s2 += w[j];
		}
		if (min > abs(s1 - s2))
			min = abs(s1 - s2);
	}
	printf("%d\n", min);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:27: error: 'INT_MAX' was not declared in this scope
   16 |         int s1, s2, min = INT_MAX;
      |                           ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <math.h>
  +++ |+#include <climits>
    5 |
Language: C++

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





int main(){
	int N;
	
	cin>>N;
	int ans;
	vector<int>t(N+1);

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

	int S1=0,S2=0;


	for(int i =0;i<n;i++){
		for(int j=0;j<i+1;j++){
			S1 +=t[j];
		}
		for(int j=i+1;j<N;j++){
			S2 +=t[j];
		}

		if(i==0){
			ans =abs(S1-S2);
		}else{
			if(abs(S1-S2)<ans){
				ans=abs(S1-S2);
			}
		}
		S1=0;
		S2=0;
	}

	cin>>ans;

	
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:24: error: 'n' was not declared in this scope
   15 |         for(int i =0;i<n;i++){
      |                        ^
a.cc:22:24: error: 'n' was not declared in this scope
   22 |         for(int i =0;i<n;i++){
      |                        ^
Language: C++

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

int main() {
  int n, w[n], t, s1=0, s2=0;
  
  cin >> n;
  for(int i=0;i<n;i++) {
    cin >> w[i];
    s2 += w[i];
  }
  s1 = w[0];
    
  for(int i=1;s2-s1>0;i++) {
    s1 += w[i];
    s2 -= w[i];
  }
  
  cout << abs(s1-s2) << endl;
  
  return 0;
}


Compiler output:
a.cc:2:2: error: invalid preprocessing directive #incluce; did you mean #include?
    2 | #incluce <stdlib.h>
      |  ^~~~~~~
      |  include
Language: C

#include<stdio.h>
#include<cmath>
int main()
{
	int n,a[1005],s=0,i,t=0,minn=199999999;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		s+=a[i];
	}
	for(i=0;i<n;i++)
	{
		t+=a[i];
		if(minn>abs(s-2*t))
		minn=abs(s-2*t);
	}
	printf("%d",minn);
}

Compiler output:
main.c:2:9: fatal error: cmath: No such file or directory
    2 | #include<cmath>
      |         ^~~~~~~
compilation terminated.
Language: C++

#include <stdio.h>

int abs(int i){
	if(i > 0){
		return i;
	}else{
		return -i;
	}
}

int diff(int a,b){
	if(a>b){
		return a - b;
	}else{
		return b - a;
	}
}

int minn(int ary[],int n)
{
	int min = ary[0];
	int i;
	for(i = 0; i < n; i++){
		if(min > ary[i]){
			min = ary[i];
		}
	}
	
	return min;
}
	

int main(void)
{
	int n;
	scanf("%d",&n);
	
	int w[n];
	
	int i,j;
	
	for(i = 0; i < n; i++){
		scanf("%d",&w[i]);
	}
	
	int  total = 0;
	
	int s1[n],ans[n];
	
	for(i = 0; i < n; i++){
		total += w[i];
	}
	
	for(i = 0; i < n; i++){
		s1[i] = 0;
		for(j = 0; j <= i; j++){
			s1[i] += w[j];
		}
	}
	
	for(i = 0; i < n; i++){
		ans[i] = total - s1[i];
		ans[i] = diff(s1[i],ans[i]);
	}
	
	printf("%d\n",minn(ans,n));
	
	return 0;
}
	
	
	
	
	
		
	

	
			
	
	
	
	
	

Compiler output:
a.cc:11:16: error: 'b' has not been declared
   11 | int diff(int a,b){
      |                ^
a.cc: In function 'int diff(int, int)':
a.cc:12:14: error: 'b' was not declared in this scope
   12 |         if(a>b){
      |              ^
Language: C++

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

int main() {
  int n, w[n], t, s1=0, s2=0;
  
  cin >> n;
  for(int i=0;i<n;i++) {
    cin >> w[i];
    s2 += w[i]
  }
  s1 = w[0]
    
  for(int i=1;s2-s1>0;i++) {
    s1 += w[i];
    s2 -= w[i];
  }
  
  cout << abs(s2-s1) << endl;
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:15: error: expected ';' before '}' token
   10 |     s2 += w[i]
      |               ^
      |               ;
   11 |   }
      |   ~            
a.cc:12:12: error: expected ';' before 'for'
   12 |   s1 = w[0]
      |            ^
      |            ;
   13 | 
   14 |   for(int i=1;s2-s1>0;i++) {
      |   ~~~       
a.cc:14:23: error: 'i' was not declared in this scope
   14 |   for(int i=1;s2-s1>0;i++) {
      |                       ^
Language: C++

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

int main() {
  int n, w[n], t, s1=0, s2=0;
  
  cin >> n;
  for(int i=0;i<n;i++) {
    cin >> w[i];
    s2 += w[i]
  }
  s1 = w[0]
    
  for(int i=1;s2-s1>0;i++) {
    s1 += w[i];
    s2 -= w[i];
  }
  
  cout << abs(s1-s2) << endl;
  
  return 0;
}


Compiler output:
a.cc:2:2: error: invalid preprocessing directive #incluce; did you mean #include?
    2 | #incluce <stdlib.h>
      |  ^~~~~~~
      |  include
a.cc: In function 'int main()':
a.cc:11:15: error: expected ';' before '}' token
   11 |     s2 += w[i]
      |               ^
      |               ;
   12 |   }
      |   ~            
a.cc:13:12: error: expected ';' before 'for'
   13 |   s1 = w[0]
      |            ^
      |            ;
   14 | 
   15 |   for(int i=1;s2-s1>0;i++) {
      |   ~~~       
a.cc:15:23: error: 'i' was not declared in this scope
   15 |   for(int i=1;s2-s1>0;i++) {
      |                       ^
Language: C++

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

int main() {
  int N;
  int sum = 0,sum2 = 0;
  int std;
  int a,b,c =0;
  
  cin >> N;
  
	vector<int> vec(N);
	for (int i = 0; i < N; i++) {
		cin >> vec.at(i);
	}
  
	for (int j = 0; j < N; j++) {
      sum += vec.at(j);
    }

    if (sum % 2 = 0) {
      std = sum/2;
    } else {
      std = sum/2 + 1;
    }
  
    for (int k = 0; k < N; k++) {
      sum2 += vec.at(k);
      if(sum2 >= std && c == 0) {
        a = sum2;
        c = 1;
      }
    }
      
    b = sum - a;
      
    if ((a-b)>=0) {
      cout << a-b;
    } else {
      cout << -1*(a-b);
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:13: error: lvalue required as left operand of assignment
   21 |     if (sum % 2 = 0) {
      |         ~~~~^~~
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main(void)
{
    std::vector<int> w;
    int N, min = INT_MAX;

    std::cin >> N;

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

    for (int i = 0; i < N - 1; i++)
    {
        int tmp1 = 0, tmp2 = 0;
        for (int j = 0; j <= i; j++)
        {
            tmp1 += w[j];
        }
        for (int j = i + 1; j < N; j++)
        {
            tmp2 += w[j];
        }
        if (min > std::abs(tmp1 - tmp2))
        {
            min = std::abs(tmp1 - tmp2);
        }
    }

    std::cout << min << std::endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:18: error: 'INT_MAX' was not declared in this scope
    9 |     int N, min = INT_MAX;
      |                  ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <algorithm>
  +++ |+#include <climits>
    5 |
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 lowest=9900;
  int a=0,b=0;
  for(int i=0;i<N;i++){
    a+=W[i];
  }
  for(int i=0;i<N;i++){
    for(intj=0;j<=i;j++){
      b+=W[j];
    }
    lowest=min(lowest,abs(a-2b));
  }
  cout << lowest << endl;
}
      


Compiler output:
a.cc: In function 'int main()':
a.cc:16:9: error: 'intj' was not declared in this scope; did you mean 'int'?
   16 |     for(intj=0;j<=i;j++){
      |         ^~~~
      |         int
a.cc:16:16: error: 'j' was not declared in this scope
   16 |     for(intj=0;j<=i;j++){
      |                ^
a.cc:19:29: error: unable to find numeric literal operator 'operator""b'
   19 |     lowest=min(lowest,abs(a-2b));
      |                             ^~
Language: C++

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


int main(){
	int n,MX=-1;
	vector<int> v;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a;
		MX=max(a,MX);
		v.push_back(a);
	}
	
	int sum,sum2,ans=1e9;
	for(int i=1;i<=MX;i++){
		sum=sum2=0;
		for(int j=0;j<n;j++){
			if(i<=v[j]) sum+=v[j];
			else sum2+=v[j];
		}
		ans=min(ans,abs(sum-sum2));
	}
	
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:24: error: 'a' was not declared in this scope
   10 |                 cin >> a;
      |                        ^
Language: C++

#include<iostream>
#include <math.h>
#include <algorithm>
#include<queue>
#include <bits/stdc++.h>


using namespace std;

#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)

main(){
   int N, suma,sumb;
   cin >> N;
   int W[N];
   int sum[N];
   FOR(i,0,N){
       cin >> W[i];
   }

   FOR(t,0,N){
       FOR(j, 0 ,t){
           suma += W[j];
       }
       FOR(k, t, N){
           sumb += W[k];
       }
       sum[t] = abs(suma - sumb);
   }
   sort(sum);
    cout << sum[0] << endl;
}

Compiler output:
a.cc:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:30:8: error: no matching function for call to 'sort(int [N])'
   30 |    sort(sum);
      |    ~~~~^~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate: 'template<class _RAIter> void std::sort(_RAIter, _RAIter)'
 4762 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4762:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algo.h:4793:5: note: candidate: 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)'
 4793 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note:   candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare)'
  292 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note:   candidate expects 4 arguments, 1 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator)'
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note:   candidate expects 3 arguments, 1 provided
Language: Java

import java.lang.reflect.Array;
import java.util.*;
import static java.lang.Math.*;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] weight = new int[N];
        int sum =0;
        int sum2 = 0;
        int[] g = new int[N];
      for(int j =0; int < N ; j++){
      weight[j] = sc.nextInt();
      }
        for(int t =1; t < N; t ++) {
            for (int i = 0; i < N; i++) {
                if (weight[i] <= t) {
                    sum += weight[i];
                } else if(weight[i] > t){
                    sum2 += weight[i];
                }
            }
            g[t] = Math.abs(sum - sum2);
        }
        Arrays.sort(g);
        System.out.println(g[0]);

    }
}

Compiler output:
Main.java:14: error: '.class' expected
      for(int j =0; int < N ; j++){
                        ^
1 error
Language: C++

#include<iostream>
#include <math.h>
#include <algorithm>
#include<queue>
#include <bits/stdc++.h>


using namespace std;

#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)

main(){
   int N, suma,sumb;
   cin >> N;
   int W[N];
   int sum[N];
   FOR(i,0,N){
       cin >> W[i];
   }

   FOR(t,0,N){
       FOR(j, 0 ,t){
           suma += W[j];
       }
       FOR(k, t, N){
           sumb += W[k];
       }
       sum[t] = abs(suma - sumb);
   }
    cout << min(sum) << endl;
}

Compiler output:
a.cc:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:30:16: error: no matching function for call to 'min(int [N])'
   30 |     cout << min(sum) << endl;
      |             ~~~^~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 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,
                 from a.cc:3:
/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:30:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'int*'
   30 |     cout << min(sum) << endl;
      |             ~~~^~~~~
/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<stdio.h>
#include<stdlib.h>
int main(){
  int n,ans;
  int ave=0;
  int s1,s2;
  int w[100];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&w[i]);
    ave+=w[i];
  }
  ave/=2;
  for(int i=0;i<n;i++){
    if(w[i]<=ave){
      s1+=w[i];
    }
    else{
      s2+=w[i];
  }
  ans=abs(s1-s2);
  printf("%d",ans);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:24:1: error: expected declaration or statement at end of input
   24 | }
      | ^
Language: C++

#include <stdio.h>

int abs(int i){
	if(i > 0){
		return i;
	}else{
		return -i;
	}
}

int minn(int ary[],int n)
{
	int min = ary[0];
	int i;
	for(i = 0; i < n; i++){
		if(a[i] > min){
			min = a[i];
		}
	}
	
	return min;
}
	

int main(void)
{
	int n;
	scanf("%d",&n);
	
	int w[n];
	
	int i,j;
	
	for(i = 0; i < n; i++){
		scanf("%d",&w[i]);
	}
	
	int  s2 = 0,total = 0;
	
	int s1[n],ans[n];
	
	for(i = 0; i < n; i++){
		total += w[i];
	}
	
	for(i = 0; i < n; i++){
		for(j = 0; j <= i; j++){
			s1[i] += w[j];
		}
	}
	
	for(i = 0; i < n; i++){
		ans[i] = total - s1[i];
	}
	
	printf("%d\n",minn(ans,n));
	
	return 0;
}
	
	
	
	
	
		
	

	
			
	
	
	
	
	

Compiler output:
a.cc: In function 'int minn(int*, int)':
a.cc:16:20: error: 'a' was not declared in this scope
   16 |                 if(a[i] > min){
      |                    ^
Language: C++

#include <stdio.h>

int abs(int i){
	if(i > 0){
		return i;
	}else{
		return -i;
	}
}

int minn(int ary[],int n)
{
	int min = ary[0];
	int i;
	for(i = 0; i < n; i++){
		if(a[i] > min){
			min = a[i];
		}
	}
	
	return min;
}
	

int main(void)
{
	int n;
	scanf("%d",&n);
	
	int w[n];
	
	int i,j;
	
	for(i = 0; i < n; i++){
		scanf("%d",&w[i]);
	}
	
	int  s2 = 0;total = 0;
	
	int s1[n];ans[n];
	
	for(i = 0; i < n; i++){
		total += w[i];
	}
	
	for(i = 0; i < n; i++){
		for(j = 0; j <= i; j++){
			s1[i] += w[j];
		}
	}
	
	for(i = 0; i < n; i++){
		ans[i] = total - s1[i];
	}
	
	printf("%d\n",minn(ans,n));
	
	return 0;
}
	
	
	
	
	
		
	

	
			
	
	
	
	
	

Compiler output:
a.cc: In function 'int minn(int*, int)':
a.cc:16:20: error: 'a' was not declared in this scope
   16 |                 if(a[i] > min){
      |                    ^
a.cc: In function 'int main()':
a.cc:38:21: error: 'total' was not declared in this scope
   38 |         int  s2 = 0;total = 0;
      |                     ^~~~~
a.cc:40:19: error: 'ans' was not declared in this scope; did you mean 'abs'?
   40 |         int s1[n];ans[n];
      |                   ^~~
      |                   abs
Language: C++

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

using namespace std;

int main(void) {

	int a;
	int s, t;
	vector<int>vi;
	int ans = INT_MAX;
	cin >> a;

	for (int i = 0; i < a; i++) {
		int tmp;
		cin >> tmp;
		vi.push_back(tmp);
	}

	for (int i = 0; i < a; i++) {
		int sum1 = 0;
		int sum2 = 0;
		
		for (int j = 0; j <= i; j++) {
			sum1 += vi[j];
		}
		for (int j = i+1; j < a; j++) {
			sum2 += vi[j];
		}
		if (ans > abs(sum1 - sum2)) ans = abs(sum1 - sum2);
	}

	cout << ans << endl;

	return 0;
}

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

#include <stdio.h>
#include <stdlib.h>

int main()
{
  int i,n;
  int w[100];
  int sum[100];
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &w[i]);
  }
  int diff1,diff2;
  sum[0]=w[0];
  for (i = 1; i < n; i++) {
    sum[i]=sum[i-1]+w[i];
  }
  i=0;
  while(sum[i]<sum[n-1]/2) {
    i++;
  }
  diff1=abs((sum[n-1]-sum[i])-sum[i]);
  diff2=abs((sum[n-1]-sum[i-1])-sum[i-1]);
  if(diff2<diff1) diff1=diff2;
  printf("%d\n", diff1);
  return 0;
}a

Compiler output:
main.c:27:1: error: expected '=', ',', ';', 'asm' or '__attribute__' at end of input
   27 | }a
      | ^
Language: C++

#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cmath>

int main() {
    int N;
    std::cin >> N;

    std::vector<int> w;
    for (int i = 0; i < N; i += 1) {
        int wi;
        std::cin >> wi;
        w.push_back(wi);
    }

    int min_value = INT_MAX;
    for (int i = 0; i < N - 1; i += 1) {
        int s1 = std::accumulate(w.begin(), w.begin() + i + 1, 0);
        int s2 = std::accumulate(w.begin() + i + 1, w.end(), 0);
        int value = std::abs(s1 - s2);
        if (value < min_value) {
            min_value = value;
        }
    }

    std::cout << min_value << std::endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:21: error: 'INT_MAX' was not declared in this scope
   18 |     int min_value = INT_MAX;
      |                     ^~~~~~~
a.cc:6:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    5 | #include <cmath>
  +++ |+#include <climits>
    6 |
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 lowest=9900;
  int a=0,b=0;
  for(int j=1;j<N;j++){
      for(int k=1;k<=j;k++){
        a+=S[k];
        b+=S[N-1-k];
      }
      lowest=min(lowest,abs(a-b));
  }
  cout<< lowest << endl;
}
      

Compiler output:
a.cc: In function 'int main()':
a.cc:14:12: error: 'S' was not declared in this scope
   14 |         a+=S[k];
      |            ^
Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>	

using namespace std;

int main() {
	vector<int> w;
	int N;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		w.push_back(a);
	}
	pair<int, int> T;
	T = make_pair(0, 0);
	for (int i = 0; i < N; ++i) {
		T.first += w[i];
	}
	int minA = INT_MAX;
	for (int i = 0; i < N; ++i) {
		T.first -= w[i];
		T.second += w[i];
		minA = min(minA, abs(T.first - T.second));
	}
	cout << minA << endl;



	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:20: error: 'INT_MAX' was not declared in this scope
   26 |         int minA = INT_MAX;
      |                    ^~~~~~~
a.cc:9:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    8 | #include<cmath>
  +++ |+#include <climits>
    9 |
Language: C++

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

int main() {
  int N,min=100000,sum;
  cin >> N;
  vector<int> W(N);
  for(int i=0;i<N;i++){
  	cin >> W.at(i);
    sum+=W.at(i);
  }
  for(int T=0;T<N-1;T++){
    int sum1=0
  	for(int i=0;i<=T;i++){
      sum1+=W.at(i);
    }
    int aaa=abs(2*sum1-sum);
    if(min>aaa) min=aaa;
  }
  cout << min << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: expected ',' or ';' before 'for'
   14 |         for(int i=0;i<=T;i++){
      |         ^~~
a.cc:14:21: error: 'i' was not declared in this scope
   14 |         for(int i=0;i<=T;i++){
      |                     ^
Language: C++

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

int main() {
  int N,min=100000,sum;
  cin >> N;
  vector<int> W(N);
  for(int i=0;i<N;i++){
  	cin >> W.at(i);
    sum+=W.at(i);
  }
  for(T=0;T<N-1;T++){
    int sum1=0
  	for(int i=0;i<=T;i++){
      sum1+=W.at(i);
    }
    int aaa=abs(2*sum1-sum);
    if(min>aaa) min=aaa;
  }
  cout << min << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:7: error: 'T' was not declared in this scope
   12 |   for(T=0;T<N-1;T++){
      |       ^
a.cc:14:9: error: expected ',' or ';' before 'for'
   14 |         for(int i=0;i<=T;i++){
      |         ^~~
a.cc:14:21: error: 'i' was not declared in this scope
   14 |         for(int i=0;i<=T;i++){
      |                     ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <set>
#include <unordered_set>


using namespace std;


int main()
{
    int N;
    int W[100];
    int dp[100];
    cin >> N ;
    for(int i=0; i<N;i++){
        cin>>W[i];
    }
    dp[0] = W[0];
    for(int i=1; i<N; i++){
        dp[i] = W[i] + dp[i-1];
    }
    int min=INT_MAX;
    for(int i=0; i<N; i++){
        int S1= dp[i];
        int S2 = dp[N-1] - S1;
        min = std::min(min, abs(S2-S1));
    }

    cout<<min<<endl;
    
    return 0;
}

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

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

public class Main{ //ABC128B
	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[] min = new int[N-1];

		for(int i=0;i<N-1;i++) {

			int l = 0;
			int r = 0;
			for(int j=0;j<N;j++){
				if(j<=i){
					l += W[j];
				}else {
					r += W[j];
				}
			}
			min[i] = Math.abs(l-r);
		}//Math.abs();

		Arrays.sort(min);
		System.out.println(min[0]);
	}
}

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

#include<iostream>
#include<algorithm>
#include<cstdlib>
using namespace std;

int main(void){
    int N;
    cin >> N;
    int w[N];
    int min_sub = INT_MAX;
    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<t;i++){
            s1 += w[i];
        }
        for(int i=t;i<N;i++){
            s2 += w[i];
        }
        if(abs(s1-s2) < min_sub) min_sub = abs(s1-s2);
    }
    cout << min_sub << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:19: error: 'INT_MAX' was not declared in this scope
   10 |     int min_sub = INT_MAX;
      |                   ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include<cstdlib>
  +++ |+#include <climits>
    4 | using namespace std;