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

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:14:23: error: expected ')' before '{' token
   14 |   for (int i=1;i<n;i++{
      |       ~               ^
      |                       )
a.cc:20:18: error: no matching function for call to 'min(<unresolved overloaded function type>, int)'
   20 |     int ans = min(min,abs(r-l));
      |               ~~~^~~~~~~~~~~~~~
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: 'constexpr const _Tp& std::min(const _Tp&, const _Tp&) [with _Tp = int]'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:20: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const int&'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |         ~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
a.cc:22:16: error: 'ans' was not declared in this scope; did you mean 'abs'?
   22 |        cout << ans << endl;
      |                ^~~
      |                abs
Language: Java

import java.util.*;
class Main {
  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());
  }
  
  public static void main(String[] args) {
    int s1 = 0;
 	int s2 = 0;
    int diff = 200;
    
    for (int i=0; i<n; i++) {
      for (int j=0; j<=n; j++) {
        s1 += w[j];
      }
      for (int k=i+1; k<n; k++) {
        s2 += w[k];
      }
      if (Math.abs(s1-s2) < diff) {
        diff = Math.abs(s1-s2);
      }
      s1 = 0;
      s2 = 0;
    }
    
    System.out.println(diff);
  }
  
}


Compiler output:
Main.java:6: error: illegal start of type
  for(int i=0; i<n; i++) {
  ^
Main.java:6: error: > or ',' expected
  for(int i=0; i<n; i++) {
                  ^
Main.java:6: error: <identifier> expected
  for(int i=0; i<n; i++) {
                     ^
3 errors
Language: Java

import java.util.*;
class Main {
  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());
  }
  
  public static void main(String[] args) {
    int s1 = 0;
 	int s2 = 0;
    int diff = 200;
    
    for (int i=0; i<n; i++) {
      for (int j=0; j<=n; j++) {
        s1 += w[j];
      }
      for (int k=i+1; k<n; k++) {
        s2 += w[k];
      }
      if (Math.abs(s1-s2) < diff) {
        diff = Math.abs(s1-s2);
      }
      s1 = 0;
      s2 = 0;
    }
    
    System.out.println(diff);
  }
  
}


Compiler output:
Main.java:6: error: illegal start of type
  for (int i=0; i<n; i++) {
  ^
Main.java:6: error: > or ',' expected
  for (int i=0; i<n; i++) {
                   ^
Main.java:6: error: <identifier> expected
  for (int i=0; i<n; i++) {
                      ^
3 errors
Language: Java

import java.util.*;
class Main {
  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());
  }
  
  public static void main(String[] args) {
    int s1 = 0;
 	int s2 = 0;
    int diff = 200;
    
    for (int i=0; i<n; i++) {
      for (int j=0; j<=n; j++) {
        s1 += w[j];
      }
      for (int k=i+1; k<n; k++) {
        s2 += w[k];
      }
      if (Math.abs(s1-s2) < diff) {
        diff = Math.abs(s1-s2);
      }
      s1 = 0;
      s2 = 0;
    }
    
    System.out.println(diff);
  }
  
}

Compiler output:
Main.java:6: error: illegal start of type
  for (int i=0; i<n; i++) {
  ^
Main.java:6: error: > or ',' expected
  for (int i=0; i<n; i++) {
                   ^
Main.java:6: error: <identifier> expected
  for (int i=0; i<n; i++) {
                      ^
3 errors
Language: Java

import java.util.*;
class Main {
  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());
  }
  
  public static void main(String[] args) {
    int s1 = 0;
 	int s2 = 0;
    int diff = 200;
    
    for (int i=0; i<n; i++) {
      for (int j=0; j<=n; j++) {
        s1 += w[j];
      }
      for (int k=i+1; k<n; k++) {
        s2 += w[k];
      }
      if (Math.abs(s1-s2) < diff) {
        diff = Math.abs(s1-s2);
      }
      s1 = 0;
      s2 = 0;
    }
    
    System.out.println(diff);
  }
  

Compiler output:
Main.java:6: error: illegal start of type
  for (int i=0; i<n; i++) {
  ^
Main.java:6: error: > or ',' expected
  for (int i=0; i<n; i++) {
                   ^
Main.java:6: error: <identifier> expected
  for (int i=0; i<n; i++) {
                      ^
Main.java:30: error: reached end of file while parsing
  }
   ^
4 errors
Language: C++

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	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 ans = INT_MAX;
	int l = 0;
	int r = sum;
	for (int i = 0; i < n; i++) {
		l += w[i];
		r -= w[i];
		ans = min(ans, abs(l - r));
	}

	cout << ans << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:19: error: 'INT_MAX' was not declared in this scope
   23 |         int ans = 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 | #include <stdio.h>
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:19:42: error: 'prefix_sum' was not declared in this scope; did you mean 'presum'?
   19 |     mini = min(mini, abs(presum - (sum - prefix_sum)));
      |                                          ^~~~~~~~~~
      |                                          presum
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:19:26: error: 'prefix_sum' was not declared in this scope; did you mean 'presum'?
   19 |     mini = min(mini, abs(prefix_sum - (sum - prefix_sum)));
      |                          ^~~~~~~~~~
      |                          presum
Language: C++

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	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 ans = INT_MAX;
	int l = 0;
	int r = sum;
	for (int i = 0; i < n; i++) {
		l += w[i];
		r -= w[i];
		ans = min(ans, abs(l - r));
	}

	cout << ans << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:19: error: 'INT_MAX' was not declared in this scope
   22 |         int ans = 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 x;
  cin>>x;
  vector<int> a(x);
  int sum=0;
  
  for(int i=0;i<x;i++){
    cin>>a[i];
    sum +=a[i];
  }
  int mini=sum;
  int presum=0;
  
  for(int i=0;i<x:i++){
    cin>>a[i];
    presum += a[i];
    mini = min(mini, abs(prefix_sum - (sum - prefix_sum))); 
  }
  cout<<mini<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:15: warning: range-based 'for' loops with initializer only available with '-std=c++20' or '-std=gnu++20' [-Wc++20-extensions]
   16 |   for(int i=0;i<x:i++){
      |               ^
a.cc:16:18: error: found ':' in nested-name-specifier, expected '::'
   16 |   for(int i=0;i<x:i++){
      |                  ^
      |                  ::
a.cc:16:17: error: 'x' is not a class, namespace, or enumeration
   16 |   for(int i=0;i<x:i++){
      |                 ^
a.cc:22:1: error: expected primary-expression before '}' token
   22 | }
      | ^
a.cc:21:20: error: expected ')' before '}' token
   21 |   cout<<mini<<endl;
      |                    ^
      |                    )
   22 | }
      | ~                   
a.cc:16:6: note: to match this '('
   16 |   for(int i=0;i<x:i++){
      |      ^
a.cc:22:1: error: expected primary-expression before '}' token
   22 | }
      | ^
Language: C

#include <stdio.h>

  

int main (void){
  int n,i,j,sum=0,tmp,sum1 = 0;
  scanf("%d",&n);
  int a[n];
  for(i = 0;i<n;i++){
    scanf("%d",&a[i]);
    sum += a[i];
  }
   for (i=0; i<n; ++i) {
    for (j=i+1; j<n; ++j) {
      if (a[i] > a[j]) {
        tmp =  a[i];
        a[i] = a[j];
        a[j] = tmp;
      }
    }
   }
     for ( i = 0;i<n;i++){
       sum -=a[i];
       if(sum == 0)
         sum = 0;
       else(sum < 0){
         sum1 = sum + a[i-1];
       sum = sum *(-1);
       if(sum1 < sum)
         sum = sum1;
       }
     }
     printf("%d",sum);
   }

  


Compiler output:
main.c: In function 'main':
main.c:26:21: error: expected ';' before '{' token
   26 |        else(sum < 0){
      |                     ^
      |                     ;
Language: C

#include <stdio.h>

  

int main void(){
  int n,i,j,sum=0,tmp,sum1 = 0;
  scanf("%d",&n);
  int a[n];
  for(i = 0;i<n;i++){
    scanf("%d",&a[i]);
    sum += a[i];
  }
   for (i=0; i<n; ++i) {
    for (j=i+1; j<n; ++j) {
      if (a[i] > a[j]) {
        tmp =  a[i];
        a[i] = a[j];
        a[j] = tmp;
      }
    }
   }
     for ( i = 0;i<n;i++){
       sum -=a[i];
       if(sum == 0)
         sum = 0;
       else(sum < 0){
         sum1 = sum + a[i-1];
       sum = sum *(-1);
       if(sum1 < sum)
         sum = sum1;
       }
     }
     printf("%d",sum);
   }

  


Compiler output:
main.c:5:9: error: expected ';' before 'void'
    5 | int main void(){
      |         ^~~~~
      |         ;
main.c:5:15: error: expected identifier or '(' before ')' token
    5 | int main void(){
      |               ^
Language: C

#include <stdio.h>

  

int main void(){
  int n,i,j,sum=0,tmp,sum1 = 0;
  scanf("%d",&n);
  int a[n];
  for(i = 0;i<n;i++){
    scanf("%d",&a[i]);
    sum += a[i];
  }
   for (i=0; i<n; ++i) {
    for (j=i+1; j<n; ++j) {
      if (a[i] > a[j]) {
        tmp =  a[i];
        a[i] = a[j];
        a[j] = tmp;
      }
    }
     for ( i = 0;i<n;i++){
       sum -=a[i];
       if(sum == 0)
         sum = 0;
       else(sum < 0){
         sum1 = sum + a[i-1];
       sum = sum *(-1);
       if(sum1 < sum)
         sum = sum1;
       }
     }
     printf("%d",sum);
   }

  


Compiler output:
main.c:5:9: error: expected ';' before 'void'
    5 | int main void(){
      |         ^~~~~
      |         ;
main.c:5:15: error: expected identifier or '(' before ')' token
    5 | int main void(){
      |               ^
Language: C

#include <stdio.h>

  

int main void(){
  int n,i,sum=0,tmp,sum1 = 0;
  scanf("%d",&n);
  int a[n];
  for(i = 0;i<n;i++){
    scanf("%d",&a[i]);
    sum += a[i];
  }
   for (i=0; i<n; ++i) {
    for (j=i+1; j<n; ++j) {
      if (a[i] > a[j]) {
        tmp =  a[i];
        a[i] = a[j];
        a[j] = tmp;
      }
    }
     for ( i = 0;i<n;i++){
       sum -=a[i];
       if(sum == 0)
         sum = 0;
       else(sum < 0){
         sum1 = sum + a[i-1];
       sum = sum *(-1);
       if(sum1 < sum)
         sum = sum1;
       }
     }
     printf("%d",sum);
   }

  


Compiler output:
main.c:5:9: error: expected ';' before 'void'
    5 | int main void(){
      |         ^~~~~
      |         ;
main.c:5:15: error: expected identifier or '(' before ')' token
    5 | int main void(){
      |               ^
Language: C

#include <stdio.h>
int max int(int x,int y){
  

int main void(){
  int n,i,sum=0,tmp,sum1 = 0;
  scanf("%d",&n);
  int a[n];
  for(i = 0;i<n;i++){
    scanf("%d",&a[i]);
    sum += a[i];
  }
   for (i=0; i<n; ++i) {
    for (j=i+1; j<n; ++j) {
      if (a[i] > a[j]) {
        tmp =  a[i];
        a[i] = a[j];
        a[j] = tmp;
      }
    }
     for ( i = 0;i<n;i++){
       sum -=a[i];
       if(sum == 0)
         sum = 0;
       else(sum < 0){
         sum1 = sum + a[i-1];
       sum = sum *(-1);
       if(sum1 < sum)
         sum = sum1;
       }
     }
     printf("%d",sum);
   }

  

Compiler output:
main.c:2:8: error: expected ';' before 'int'
    2 | int max int(int x,int y){
      |        ^~~~
      |        ;
main.c:2:13: error: expected identifier or '(' before 'int'
    2 | int max int(int x,int y){
      |             ^~~
Language: C++


#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    int w[n];
    for(int i = 0; i < n; i++){
        scanf("%d", &w[i]);
    }

    sort(w, w+n);

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

    int L, R;
    int ans = W[n-1] - w[0];
    for(int i = 0; i < n; i++){
        L = 0;
        for(int j = i; j < n; j++){
            L += w[i];
        }
        R = sum - L;
        ans = min(ans, R - L);
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:15: error: 'W' was not declared in this scope
   23 |     int ans = W[n-1] - w[0];
      |               ^
Language: C++

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  
  int ans = 999999999;
  int sum = 0;
  int sum2;
  
  for(int i = 0; i < n; ++i){
	  cin >> a.at(i);
	  sum += a.at(i);
	  
	  sum2 = 0;  
	  
	  for(int j = i+1; j < n;++j){
		  sum2 += j.at(j);
	  }
	  
	  ans = min(ans,abs(sum2 - sum));
	  
  }
  
  cout << ans << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:29: error: request for member 'at' in 'j', which is of non-class type 'int'
   20 |                   sum2 += j.at(j);
      |                             ^~
Language: C++

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  
  int ans = 999999999;
  int sum = 0;
  int sum2;
  
  for(int i = 0; i < n; ++i){
	  cin >> a.at(i);
	  sum += a.at(i);
	  
	  sum2 = 0;  
	  
	  for(int j = i+1; j < n;++i){
		  sum2 += j.at(j);
	  }
	  
	  ans = min(ans,abs(sum2 - sum));
	  
  }
  
  cout << ans << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:29: error: request for member 'at' in 'j', which is of non-class type 'int'
   20 |                   sum2 += j.at(j);
      |                             ^~
Language: C++

#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int temp;
    int arr[n+1];
    arr[0]=0;
    for(int i=1;i<=n;i++){
        cin>>temp;
        arr[i] = arr[i-1]+temp;
    }
    int tofind = arr[n]/2;
    int lo = 1;
    int high = n;
    int mid = (lo+high)/2;
    while(lo<high){
        mid = (lo+high)/2;
        if(arr[mid]>=tofind){
            high =mid;
        }
        else{
            lo =mid+1;
        }
    }
    int ans;
    if(lo>1){
        ans = 2*min(abs(tofind-arr[lo-1]),abs(tofind - arr[lo]));
    }
  	else{
    	ans =2*abs(tofind - arr[lo])
    }
    cout<<ans;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:37: error: expected ';' before '}' token
   35 |         ans =2*abs(tofind - arr[lo])
      |                                     ^
      |                                     ;
   36 |     }
      |     ~
Language: C++

#include <iostream>
#include <cmath>

using namespace std;

int W[100];
int sum[100];

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

  int m = 10001;
  for(int i=0;i<N-1;i++){
    m = min(abs(sum[N-1] - 2sum[i]),m);
  }
  cout << m << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:28: error: unable to find numeric literal operator 'operator""sum'
   23 |     m = min(abs(sum[N-1] - 2sum[i]),m);
      |                            ^~~~
Language: C++

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
 intsum=0;

  for(inti=0;i<N;++i){
  cin >> a[i];
  sum += a[i];
   }


Compiler output:
a.cc: In function 'int main()':
a.cc:8:2: error: 'intsum' was not declared in this scope
    8 |  intsum=0;
      |  ^~~~~~
a.cc:10:7: error: 'inti' was not declared in this scope; did you mean 'int'?
   10 |   for(inti=0;i<N;++i){
      |       ^~~~
      |       int
a.cc:10:14: error: 'i' was not declared in this scope
   10 |   for(inti=0;i<N;++i){
      |              ^
a.cc:12:3: error: 'sum' was not declared in this scope
   12 |   sum += a[i];
      |   ^~~
a.cc:13:5: error: expected '}' at end of input
   13 |    }
      |     ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

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


int main(){
    int n, sum=0;
    int w[100];
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> w[i];
        sum += w[i];
    }
    int s1 = 0;
    int dif = sum;
    for(int i=0; i<n; i++){
        s1 += s[i];
        dif = min(dif, abs(s1- (sum - s1)));
    }
    cout << dif << endl;
    return 0;
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:15: error: 's' was not declared in this scope
   20 |         s1 += s[i];
      |               ^
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 sum=0;
		int[] w=new int[n];		
		for(int i=0;i<n;i++){
			w[i]=sc.nextInt();
			sum=sum+w[i];
		}
		 int l=sum;
		 int f =0;
		 int dif=sum;
		 
		for(int i=0;i<n;i++){
			l=l-w[i];
			f=f+w[i];
			if(Math.abs(l-f)>dif)break;
			dif=Math.abs(l-f);
		}
		
		
		System.out.println(dif);
	}



Compiler output:
Main.java:29: error: reached end of file while parsing
	}
	 ^
1 error
Language: C++

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

int abs(int x, int y) {
  if (x < y) {
    return y-x;
  }
  else{
    return x-y;
  }
}
int main(){
  int N;
  cin >>N;
  vector<int> wei(N);
  for(int i =0;i<N; i++){
    cin >> wei.at(i);
  }
  int S_1 =0;
  int S_2 =0;
  int res =100000;
  for(int T =1; T<N+1;i++){
    for(int j=0;j<N;j++){
      if( wei.at(j) <= T){
        S_1 =+ wei.at(j);        
      }
      else{
        S_2 =+ wei.at(j);
      }
    }
    if(abs(S_1,S_2)<=res){
      res =abs(S_1,S_2);
    }
  }
  cout << res <<endl;

}

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

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

int abs(int x, int y) {
  if (x < y) {
    return y-x;
  }
  else{
    return x-y;
  }
}
int main(){
  int N;
  cin >>N;
  vector<int> wei(N);
  for(int i =0;i<N; i++){
    cin >> wei.at(i);
  }
  int S_1 =0;
  int S_2 =0;
  int res =10000;
  for(i =0;i<N+1;i++){
    for(j=0;j<N;j++){
      if( wei.at(j) <= i){
        S_1 =+ wei.at(j);        
      }
      else{
        S_2 =+ wei.at(j);
      }
    }
    if(abs(S_1,S_2)<=res){
      res =abs(S_1,S_2);
    }
  }
  cout << res <<endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:7: error: 'i' was not declared in this scope
   22 |   for(i =0;i<N+1;i++){
      |       ^
a.cc:23:9: error: 'j' was not declared in this scope
   23 |     for(j=0;j<N;j++){
      |         ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main(void){
  int N;
  cin >> N;
  
  vector<int> W(N);
  vector<int> csum(N);
  
  for(int i=0;i<N;i++){
    cin >> W[i];
  }
  csum[0] = W[0];
  for(int i=1;i<N;i++){
    csum[i] = W[i] + csum[i-1];
  }
  int abs_min = 0;
  for(int i=1;i<N;i++){
  	abs_min = min(abs_min,abs(csum[N-1] - csum[i]));
  }
  
  cout << abs_min << endl;S
  return 0;
}
  
  
  


Compiler output:
a.cc: In function 'int main()':
a.cc:24:27: error: 'S' was not declared in this scope
   24 |   cout << abs_min << endl;S
      |                           ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main(void){
  int N;
  cin >> N;
  
  vector<int> W(N);
  vector<int> csum(N);
  
  for(int i=0;i<N;i++){
    cin >> W[i];
  }
  csum[0] = W[0];
  for(int i=1;i<N;i++){
    csum[i] = W[i] + csum[i-1];
  }
  int abs_min = 0;
  for(int i=1;i<N;i++){
  	abs_min = min(abs_min,abs(csum[N-1] - csum[i]));
  }
  
  cout << abs_min << endl;
  return 0;
  
  
  
  


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

#include <bits/stdc++.h>

using namespace std;

int main(void){
  int N;
  cin >> N;
  
  vector<int> W(N);
  vector<int> csum(N);
  
  for(int i=0;i<N;i++){
    cin >> W[i];
  }
  csum[0] = W[0];
  for(int i=1;i<N;i++){
    csum[i] = W[i] + csum[i-1];
  }
  int abs_min = 0;
  for(int i=1;i<N;i++){
  	abs_min = min(abs_min,abs(csum[N-1] - csum[i]));
  }
  
  cout << abs_min << endl;S
  return 0;
  
  
  
  

Compiler output:
a.cc: In function 'int main()':
a.cc:24:27: error: 'S' was not declared in this scope
   24 |   cout << abs_min << endl;S
      |                           ^
a.cc:25:12: error: expected '}' at end of input
   25 |   return 0;
      |            ^
a.cc:5:15: note: to match this '{'
    5 | int main(void){
      |               ^
Language: C

#include <stdio.h>
#include <math.h>

int main(void){
  
  int sum,p=0,q=0,r;
  scanf("%d\n",&r);
  
  int fac[r],i,half;
  scanf("%d",fac);
  for (i=0;i<r;i++)sum += fac[r];  
  i=0
  half = sum/2;
  
  while (p < half){
    p += fac[i];//半分が求まる
    i++}
  
  q = sum - p;
  printf("%d",q);
  return 0;
} 

Compiler output:
main.c: In function 'main':
main.c:12:6: error: expected ';' before 'half'
   12 |   i=0
      |      ^
      |      ;
   13 |   half = sum/2;
      |   ~~~~
main.c:17:8: error: expected ';' before '}' token
   17 |     i++}
      |        ^
      |        ;
Language: C

#include <stdio.h>
#include <math.h>

int main(void){
  
  int sum,p=0,q=0,r;
  scanf("%d\n",&r);
  
  int fac[r],i,half;
  scanf("%s",fac);
  for (i=0;i<r;i++)sum += fac[r];  
  i=0
  half = sum/2;
  
  while (p < half){
    p += fac[i];//半分が求まる
    i++}
  
  q = sum - p;
  printf("%d",q);
  return 0;
} 

Compiler output:
main.c: In function 'main':
main.c:12:6: error: expected ';' before 'half'
   12 |   i=0
      |      ^
      |      ;
   13 |   half = sum/2;
      |   ~~~~
main.c:17:8: error: expected ';' before '}' token
   17 |     i++}
      |        ^
      |        ;
Language: C

#include <stdio.h>
#include <math.h>

int main(void){
  int sum,p=0,q=0;
  scanf("%d\n",&r);
  
  int fac[r],i,half;
  scanf("%s",fac);
  for (i=0;i<r;i++)sum += fac[r];  
  i=0
  half = sum/2;
  
  while (p < half){
    p += fac[i];//半分が求まる
    i++}
  
  q = sum - p;
  printf("%d",q);
  return 0;
} 

Compiler output:
main.c: In function 'main':
main.c:6:17: error: 'r' undeclared (first use in this function)
    6 |   scanf("%d\n",&r);
      |                 ^
main.c:6:17: note: each undeclared identifier is reported only once for each function it appears in
main.c:11:6: error: expected ';' before 'half'
   11 |   i=0
      |      ^
      |      ;
   12 |   half = sum/2;
      |   ~~~~
main.c:16:8: error: expected ';' before '}' token
   16 |     i++}
      |        ^
      |        ;
Language: C++

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

int main(void){

  int n;
cin >> n;
  int w[n],a,sum,an;
  for(i = 0; i < n; i++){
    cin >> w[i];  
    sum += w[i];
  }
  
  for(i = 0; i < n; i++){
    a += w[i];
    an = min(abs(sum*2 - a), an);
  } 
    cout<< an << endl;
    return 0;
  
  
}


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

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

int main(){

  int n
cin >> n;
  int w[n],a,sum,an;
  for(i = 0; i < n; i++){
    cin >> w[i];  
    sum += w[i];
  }
  
  for(i = 0; i < n; i++){
    a += w[i];
    an = min(abs(sum*2 - a), an);
  } 
    cout<< an << endl;
    return 0;
  
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:1: error: expected initializer before 'cin'
    7 | cin >> n;
      | ^~~
a.cc:8:9: error: 'n' was not declared in this scope; did you mean 'yn'?
    8 |   int w[n],a,sum,an;
      |         ^
      |         yn
a.cc:9:7: error: 'i' was not declared in this scope
    9 |   for(i = 0; i < n; i++){
      |       ^
a.cc:10:12: error: 'w' was not declared in this scope
   10 |     cin >> w[i];
      |            ^
a.cc:14:7: error: 'i' was not declared in this scope
   14 |   for(i = 0; i < n; i++){
      |       ^
a.cc:15:10: error: 'w' was not declared in this scope
   15 |     a += w[i];
      |          ^
Language: C++

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

int main(void){

  int n
cin >> n;
  int w[n],a,sum,an;
  for(i = 0; i < n; i++){
    cin >> w[i];  
    sum += w[i];
  }
  
  for(i = 0; i < n; i++){
    a += w[i];
    an = min(abs(sum*2 - a), an);
  } 
    cout<< an << endl;
    return 0;
  
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:1: error: expected initializer before 'cin'
    7 | cin >> n;
      | ^~~
a.cc:8:9: error: 'n' was not declared in this scope; did you mean 'yn'?
    8 |   int w[n],a,sum,an;
      |         ^
      |         yn
a.cc:9:7: error: 'i' was not declared in this scope
    9 |   for(i = 0; i < n; i++){
      |       ^
a.cc:10:12: error: 'w' was not declared in this scope
   10 |     cin >> w[i];
      |            ^
a.cc:14:7: error: 'i' was not declared in this scope
   14 |   for(i = 0; i < n; i++){
      |       ^
a.cc:15:10: error: 'w' was not declared in this scope
   15 |     a += w[i];
      |          ^
Language: C++

#include <iostream>
using namespace std;

int main() {
	int n;
	cin >> n;
	int* w = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> w[i];
	}
	int s1 = 0, s2 = 0;
	s1 += w[0];
	int step1 = 0, step2 = 1;
	for (int i = 1; i < n; i++) {
		if (s1 > s2) {
			s2 += w[n - 1 - step1];
			step1++;
		}
		else {
			s1 += w[step2];
			step2++;
		}
	}
	cout << fabs(s1 - s2) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:17: error: 'fabs' was not declared in this scope; did you mean 'labs'?
   24 |         cout << fabs(s1 - s2) << endl;
      |                 ^~~~
      |                 labs
Language: C++

#include <iostream>
using namespace std;

int main() {
	int n;
	cin >> n;
	int* w = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> w[i];
	}
	int s1 = 0, s2 = 0;
	s1 += w[0];
	int step1 = 0, step2 = 1;
	for (int i = 1; i < n - 1; i++) {
		if (s1 > s2) {
			s2 += w[n - 1 - step1];
			step1++;
		}
		else {
			s1 += w[step2];
			step2++;
		}
	}
	cout << fabs(s1 - s2) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:17: error: 'fabs' was not declared in this scope; did you mean 'labs'?
   24 |         cout << fabs(s1 - s2) << endl;
      |                 ^~~~
      |                 labs
Language: C

#include<stdio.h>
#include<math.h>
int main(void) {
	
	int i,j,num,s1,s2,min=0;
	int w[100] = { 0 };
	scanf_s("%d", &num);

	for (i = 0; i < num; i++) {
		scanf_s("%d", &w[i]);
		min += w[i];
	}

	for (i = 0; i < num-1; i++) {
		s1 = s2 = 0;
		for (j = 0; j <= i; j++) {
			s1 += w[j];
		}
		for (j = i + 1; j < num; j++) {
			s2 += w[j];
		}
		if (abs(s1 - s2) < min) {
			min = abs(s1 - s2);
		}
	}
	printf("%d", min);

	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:7:9: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
    7 |         scanf_s("%d", &num);
      |         ^~~~~~~
      |         scanf
main.c:22:21: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   22 |                 if (abs(s1 - s2) < min) {
      |                     ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    2 | #include<math.h>
  +++ |+#include <stdlib.h>
    3 | int main(void) {
Language: Java

import java.util.ArrayList;
import java.util.Scanner;

public class question3 {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int count = Integer.parseInt(sc.next());
		ArrayList<Integer> integers = new ArrayList<Integer>(count);
		for (int i = 0; i < count; i++) {
			integers.add(Integer.parseInt(sc.next()));
		}
		int left = 0;
		int right = 0;
		for (int i = 0; i < count; i++) {
			if (right <= left) {
				int size = integers.size() - 1;
				right += integers.get(size);
				integers.remove(size);
			} else {
				left += integers.get(0);
				integers.remove(0);
			}
		}

		if(right>=left) {
			System.out.println(right-left);
		}else {
			System.out.println(left-right);
		}
		sc.close();
	}
}


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

N = int(input())
W = [int(x) for x in input().split()]

ans = float('inf')

for i in range(N):
	for j in range(i + 1):
		tmp = abs(sum(W[0: j + 1]) - sum(W[j + 1:]))
		if tmp < ans:
			ans = tmp

print(ans)

Compiler output:
a.cc:4:13: warning: multi-character character constant [-Wmultichar]
    4 | ans = float('inf')
      |             ^~~~~
a.cc:1:1: error: 'N' does not name a type
    1 | N = int(input())
      | ^
Language: C

#include <stdio.h>
#include <math.h>

int main(void){
  int sum,p=0,q=0;
  scanf("%d\n",&r);
  
  int fac[r],sum,i,half;
  scanf("%s",fac);
  for (i=0;i<r;i++)sum += fac[r];  
  i=0
  half = sum/2;
  
  while (p < half){
    p += fac[i];//半分が求まる
    i++}
  
  q = sum - p;
  printf("%d",q);
  return 0;
} 

Compiler output:
main.c: In function 'main':
main.c:6:17: error: 'r' undeclared (first use in this function)
    6 |   scanf("%d\n",&r);
      |                 ^
main.c:6:17: note: each undeclared identifier is reported only once for each function it appears in
main.c:8:14: error: redeclaration of 'sum' with no linkage
    8 |   int fac[r],sum,i,half;
      |              ^~~
main.c:5:7: note: previous declaration of 'sum' with type 'int'
    5 |   int sum,p=0,q=0;
      |       ^~~
main.c:11:6: error: expected ';' before 'half'
   11 |   i=0
      |      ^
      |      ;
   12 |   half = sum/2;
      |   ~~~~
main.c:16:8: error: expected ';' before '}' token
   16 |     i++}
      |        ^
      |        ;
Language: C++

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

int main(void){
  int N;
  std::cin >> N;
  std::vector<int> W(N, 0);
  for(int i = 0; i < N; ++i){
  	std::cin >> W[i];
  }
  
  std::vector<int> t = W, ps(N);
  std::partial_sum(t.begin(), t.end(), ps.begin());
  int sum = ps.back(); ps.pop_back();
  int min = 0x7FFFFFFF;
  for(int i = 0; i < N - 1; ++i){
    int a = ps[i], b = sum - ps[i];
    int diff = std::abs(a - b);
    if(min > diff) min = diff;
  }
  return diff;
}

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

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  scanf("%d",&n);
  int a[n],b[n],c[n];
  for(int i=0;i<n;i++)
  {
    scanf("%d",&c[i]);
    a[i]=c[i];
  }  
  b[n-1]=c[n-1];
  for(int i=1;i<n;i++)
  {
    a[i]+=a[i-1];
    int temp=n-1-i;
    b[temp]+=b[temp+1];
  }
  int ans=100000000;
  for(int i=0;i<n;i++)
  {
	int max=a[i],min=b[i],mid=c[i];
    if(max<min)
    {
      max=b[i];
      min=a[i];
    }
    int d=max-min-mid;
    if(d<0) d=-d;
    if(ans>d) ans=d;
  }
  printf("%d",ans);
  return 0;
}
    
}

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

#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include <cmath>
#include<bits/stdc++.h>
//for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
using ll = long long;
int main(){
    int n; cin >> n;
    int w[n]; cinf(n.w);
    int ans=1000000;
    int i=0;i<n-1;i++){
        int s1=0,s2=0;
        int j=0;j<n;j++){
            if(w[i]<w[j]) s2+=w[j];
            else s1+=w[j]; 
        }
        ans=min(ans,min(s1,s2));
    }
    cout << ans;
}

Compiler output:
a.cc:18:23: error: macro "cinf" requires 2 arguments, but only 1 given
   18 |     int w[n]; cinf(n.w);
      |                       ^
a.cc:12:9: note: macro "cinf" defined here
   12 | #define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
      |         ^~~~
a.cc: In function 'int main()':
a.cc:18:15: error: 'cinf' was not declared in this scope
   18 |     int w[n]; cinf(n.w);
      |               ^~~~
a.cc:20:22: error: expected ';' before ')' token
   20 |     int i=0;i<n-1;i++){
      |                      ^
      |                      ;
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>

using std::cin;
using std::cout;
using std::vector;

int main {
  int N;
  cin >> N;
  vector<int> v(N);
  for (auto & x: v) cin >> x;
  int S = std::accumulate(begin(v),end(v),0);
  int ans = S;
  int cumsum = 0;
  for (auto x:v) {
    cumsum += x;
    ans = std::min(ans, abs(cumsum, S - cumsum));
  }
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc:10:5: error: cannot declare '::main' to be a global variable
   10 | int main {
      |     ^~~~
a.cc:11:3: error: expected primary-expression before 'int'
   11 |   int N;
      |   ^~~
a.cc:11:3: error: expected '}' before 'int'
a.cc:10:10: note: to match this '{'
   10 | int main {
      |          ^
a.cc:12:3: error: 'cin' does not name a type
   12 |   cin >> N;
      |   ^~~
a.cc:13:17: error: 'N' was not declared in this scope
   13 |   vector<int> v(N);
      |                 ^
a.cc:14:3: error: expected unqualified-id before 'for'
   14 |   for (auto & x: v) cin >> x;
      |   ^~~
a.cc:15:16: error: 'accumulate' is not a member of 'std'
   15 |   int S = std::accumulate(begin(v),end(v),0);
      |                ^~~~~~~~~~
a.cc:18:3: error: expected unqualified-id before 'for'
   18 |   for (auto x:v) {
      |   ^~~
a.cc:22:3: error: 'cout' does not name a type
   22 |   cout << ans << endl;
      |   ^~~~
a.cc:23:3: error: expected unqualified-id before 'return'
   23 |   return 0;
      |   ^~~~~~
a.cc:24:1: error: expected declaration before '}' token
   24 | }
      | ^
Language: C++

#include<iostream>
#include<cmath>
using namspace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  int t = 0;
  for(int i = 0; i < n; i++) {
  	cin >> a[i];
    t += a[i];
  }
  t = ceil(t/a.length);
  int s1 = 0;
  int s2 = 0;
  for(int i = 0; i < n; i++) {
  	if(a[i] <= t) {
    	s1 += 1;
    } else
      s2 += 1;
  }
  cout << abs(s2 - s1);
  return 0;
}

Compiler output:
a.cc:3:7: error: expected nested-name-specifier before 'namspace'
    3 | using namspace std;
      |       ^~~~~~~~
a.cc: In function 'int main()':
a.cc:6:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    6 |   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:13:16: error: request for member 'length' in 'a', which is of non-class type 'int [n]'
   13 |   t = ceil(t/a.length);
      |                ^~~~~~
a.cc:22:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   22 |   cout << abs(s2 - s1);
      |   ^~~~
      |   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<stdio.h>
#include<math.h>
 
int abs_diff(int a, int b) {
  return fabs(a-b);
}
 
int main() {
  int N;
  int answer=0;
  int S1=0;
  int S2=0;
  scanf("%d", &N);
  int a[N];
  for (int i=0; i<N; i++){
    scanf("%d", &a[i]);
    S2 += a[i];
  }
  answer = 1;
  while(absdiff(S1, S2) > absdiff(S1+a[answer], S2-a[answer])) {
    S1 += a[answer];
    S2 -= a[answer];
    answer++;
  }
  printf("%d\n", absdiff(S1, S2));
 
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:20:9: error: implicit declaration of function 'absdiff'; did you mean 'abs_diff'? [-Wimplicit-function-declaration]
   20 |   while(absdiff(S1, S2) > absdiff(S1+a[answer], S2-a[answer])) {
      |         ^~~~~~~
      |         abs_diff
Language: C

#include<stdio.h>
#include<math.h>

int abs_diff(int a, int b) {
  return abs(a-b);
}

int main() {
  int N;
  int answer=0;
  int S1=0;
  int S2=0;
  scanf("%d", &N);
  int a[N];
  for (int i=0; i<N; i++){
    scanf("%d", &a[i]);
    S2 += a[i];
  }
  answer = 1;
  while(absdiff(S1, S2) > absdiff(S1+a[answer], S2-a[answer]))
    do {
      	S1 += a[answer];
      	S2 -= a[answer];
    	answer++;
  	}
  printf("%d\n", absdiff(S1, S2));

  return 0;
}


Compiler output:
main.c: In function 'abs_diff':
main.c:5:10: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
    5 |   return abs(a-b);
      |          ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    2 | #include<math.h>
  +++ |+#include <stdlib.h>
    3 | 
main.c: In function 'main':
main.c:20:9: error: implicit declaration of function 'absdiff'; did you mean 'abs_diff'? [-Wimplicit-function-declaration]
   20 |   while(absdiff(S1, S2) > absdiff(S1+a[answer], S2-a[answer]))
      |         ^~~~~~~
      |         abs_diff
main.c:26:3: error: expected 'while' before 'printf'
   26 |   printf("%d\n", absdiff(S1, S2));
      |   ^~~~~~
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 data[] = new int[n];

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

        int s1 = 0;
        int s2 = 0;

        int index = 0;
        int i = 0;
        int j = n;

        while (index < n) {
            if (s1 < s2) {
                s1 += data[i];
                i++;
            } else {
                s2 += data[j]
                j--;
            }
            index++;
        }

        if (s1 >= s2) {
            System.out.println(s1 - s2);
        } else {
            System.out.println(s2 - s1);
        }
	}
}

Compiler output:
Main.java:26: error: ';' expected
                s2 += data[j]
                             ^
1 error
Language: Java

import java.util.*;

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

    int n,i,j,t,min,s1,s2;
    int w[];

    n = sc.nextInt();

    w = new int w[n];

    for(i=0;i<n;i++){
      w[i] = sc.nextInt();
    }
    min = 99999;
    for(t=1;t<n,t++){
      s1=0;
      s2=0;
      for(i=0;i<t;i++){
        s1 += w[i];
      }
      for(;i<n;i++){
        s2 += w[i];
      }
      if(s1>s2){
        min = s1-s2;
      }else{
        min = s2-s1;
      }
      
    }
    System.out.println(min);
  }
}

Compiler output:
Main.java:12: error: '[' expected
    w = new int w[n];
               ^
Main.java:12: error: ']' expected
    w = new int w[n];
                    ^
Main.java:18: error: ';' expected
    for(t=1;t<n,t++){
               ^
3 errors
Language: C

#include<stdio.h>

int main(){
  int n;
  int i,j;
  int sum;
  int min,mink = -1 dif1=0, dif2=0;
  sum = 0;

  scanf("%d",&n);

  if(n<2 || n>100){
    return 0;
  }

  int a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);

    sum += a[i];
  }

  for(i=0;i<n;i++){
    for(j=0;j<=i;j++){
       dif1 = a[j];
    }
    dif2 = sum - dif1;

    if(dif2 > dif1)
      min = dif2 - dif1;
    else{
      min = dif1 - dif2;
    }

    if(mink == -1){
      mink = min;
    }else if(mink > min){
      mink = min;
    }
  }

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


Compiler output:
main.c: In function 'main':
main.c:7:21: error: expected ',' or ';' before 'dif1'
    7 |   int min,mink = -1 dif1=0, dif2=0;
      |                     ^~~~
main.c:25:8: error: 'dif1' undeclared (first use in this function)
   25 |        dif1 = a[j];
      |        ^~~~
main.c:25:8: note: each undeclared identifier is reported only once for each function it appears in
main.c:27:5: error: 'dif2' undeclared (first use in this function)
   27 |     dif2 = sum - dif1;
      |     ^~~~
Language: C

#include<stdio.h>

int main(){
  int n;
  int i,j;
  int sum;
  int min,mink = -1 dif1=0, dif2=0;
  sum = 0;

  scanf("%d",&n);

  if(n<2 || n>100){
    return 0;
  }

  int a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);

    sum += a[i];
  }

  for(i=0;i<n;i++){
    for(j=0;j<=i;j++){
       dif1 = a[j];
    }
    dif2 = sum - dif1;

    if(dif2 > dif1)
      min = dif2 - dif1;
    else{
      min = dif1 - dif2;
    }

    if(mink == -1){
      mink = min;
    }else if(mink > min){
      mink = min;
    }
  }

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

Compiler output:
main.c: In function 'main':
main.c:7:21: error: expected ',' or ';' before 'dif1'
    7 |   int min,mink = -1 dif1=0, dif2=0;
      |                     ^~~~
main.c:25:8: error: 'dif1' undeclared (first use in this function)
   25 |        dif1 = a[j];
      |        ^~~~
main.c:25:8: note: each undeclared identifier is reported only once for each function it appears in
main.c:27:5: error: 'dif2' undeclared (first use in this function)
   27 |     dif2 = sum - dif1;
      |     ^~~~
Language: C

#include <stdio.h>
#include <stdlib.h> 
int main (void)
{
    int b, i, tmp, tmp1, tmp2, tmp3, k, min, min1, ans;
    scanf("%d", &b);
    k = 0;
    int a [1000];
    for (i = 0; i < b; i++)
    {
        scanf("%d", &a[i]);
        tmp += a[i];
    }
    for (i = 0; i < b; i++)
    {
        tmp1 += a[i];
        min = tmp - tmp1;
        if (abs(min) < abs(min1))
        {
            ans = abs(min);
        }
        min1 = min;
    printf("%d\n", ans);
    return 0;
}

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

void solve();

int main() {
	solve();
	return 0;
}

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

int N;
vector<int> W, wforward, wback;

void solve() {
	cin >> N;
	W.resize(N);
	wforward.resize(N);
	wback.resize(N);
	for (int n = 0; n < N; n++)cin >> W[n];
	wforward[0] = W[0];
	for (int n = 1; n < N; n++)wforward[n] = wforward[n - 1] + W[n];
	wback[N - 1] = W[N - 1];
	for (int n = N - 2; n >= 0; n--)wback[n] = wback[n + 1] + W[n];
	int ans = INT_MAX;
	for (int n = 0; n < N - 1; n++) {
		ans = min(ans, abs(wforward[n]-wback[n+1]));
	}
	cout << ans << endl;
	return;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:28:19: error: 'INT_MAX' was not declared in this scope
   28 |         int ans = INT_MAX;
      |                   ^~~~~~~
a.cc:13:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   12 | #include <vector>
  +++ |+#include <climits>
   13 | using namespace std;
Language: C++

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

int main(){
  int n;
  cin>>n;
  vector<int>w(n);
  int s=0;
  for(int i=0;i<n;i++){
    cin>>w.at(i);
    s+=w[i];
  }

  int m=s;
  int prefix_s=0;
  for(int i=0;i<n;i++){
    cin>>w[i];
    prefix_s+= w[i];
    m=min(m,abs(prefix_s -(s -prefix_s)));
  }

  cout<<m<<endl;
  
      return 0;
    
  }
  

  
  
  
  
  
}
  
  
  

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

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}


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

    int w[n];
    rep(i,n){
        cin>>w[i];
        if(i>0){
            w[i] += w[i-1];
        }
    }

    int ans = 99999999;

    rep(i,n-1){
        nas = min(ans,abs(w[i]*2-w[n-1]));
    }

    cout << ans << endl;
    return 0;
}
 
 


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

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

int rangesum();
int main(){
  int N, i, tmp, min;
  cin >> N;
  int W[N];
  for(i = 0; i < N; i++){
    cin >> W[i];
  }
  min = 1000;
  for(i = 0; i < N-1; i++){
    tmp = abs(rangesum(0, i, W) - rangesum(i+1, N-1, W));
    if(min > tmp){
      min = tmp;
    }
  }
  cout << min << endl;
  return 0;
}
int rangesum(int l, int r, int *A){
  int i, tmp;
  for(i = l; i <= r; i++){
    tmp += A[i];
  }
  return tmp;
}
    
  

Compiler output:
a.cc: In function 'int main()':
a.cc:15:23: error: too many arguments to function 'int rangesum()'
   15 |     tmp = abs(rangesum(0, i, W) - rangesum(i+1, N-1, W));
      |               ~~~~~~~~^~~~~~~~~
a.cc:5:5: note: declared here
    5 | int rangesum();
      |     ^~~~~~~~
a.cc:15:43: error: too many arguments to function 'int rangesum()'
   15 |     tmp = abs(rangesum(0, i, W) - rangesum(i+1, N-1, W));
      |                                   ~~~~~~~~^~~~~~~~~~~~~
a.cc:5:5: note: declared here
    5 | int rangesum();
      |     ^~~~~~~~