criyle/codenet-compile-errors huggingface dataset:
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();
      |     ^~~~~~~~
a.cc: In function 'int rangesum(int, int, int*)':
a.cc:26:16: error: expected ';' before '}' token
   26 |     tmp += A[i]
      |                ^
      |                ;
   27 |   }
      |   ~
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();
      |     ^~~~~~~~
a.cc: In function 'int rangesum(int, int, int*)':
a.cc:26:16: error: expected ';' before '}' token
   26 |     tmp += A[i]
      |                ^
      |                ;
   27 |   }
      |   ~
Language: C++

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

int sum();
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(sum(0, i, W) - sum(i+1, N-1, W));
    if(min > tmp){
      min = tmp;
    }
  }
  cout << min << endl;
  return 0;
}
int sum(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:18: error: too many arguments to function 'int sum()'
   15 |     tmp = abs(sum(0, i, W) - sum(i+1, N-1, W));
      |               ~~~^~~~~~~~~
a.cc:5:5: note: declared here
    5 | int sum();
      |     ^~~
a.cc:15:33: error: too many arguments to function 'int sum()'
   15 |     tmp = abs(sum(0, i, W) - sum(i+1, N-1, W));
      |                              ~~~^~~~~~~~~~~~~
a.cc:5:5: note: declared here
    5 | int sum();
      |     ^~~
a.cc: In function 'int sum(int, int, int*)':
a.cc:26:16: error: expected ';' before '}' token
   26 |     tmp += A[i]
      |                ^
      |                ;
   27 |   }
      |   ~
Language: C++

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

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(sum(0, i, W) - sum(i+1, N-1, W));
    if(min > tmp){
      min = tmp;
    }
  }
  cout << min << endl;
  return 0;
}
int sum(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:14:15: error: 'sum' was not declared in this scope
   14 |     tmp = abs(sum(0, i, W) - sum(i+1, N-1, W));
      |               ^~~
a.cc: In function 'int sum(int, int, int*)':
a.cc:25:16: error: expected ';' before '}' token
   25 |     tmp += A[i]
      |                ^
      |                ;
   26 |   }
      |   ~
Language: C++

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

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(sum(0, i, W) - sum(i+1, N-1, W));
    if(min > tmp){
      min = tmp;
    }
  }
  cout << min << endl;
  return 0;
}
int sum(int l, int r, int A[]){
  int i, tmp;
  for(i = l; i <= r; i++){
    tmp += A[i]
  }
  return tmp;
}
    
  

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

#include <iostream>

int main(int argc, char** argv)
{
   int N;
   int W[110];
   int S1=0;
   int S2=0;
   int sum = 0;
   int min;

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

   }

   min = sum;

   for(int T=1;T<N;T++){
      for(int j=0; j<T; j++){
         S1 += W[i];
      }

      if(abs(2*S1 - sum) < min) min= abs(2*S1 - sum);
   }

   std::cout << sum << endl;

   return 0;
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:23:18: error: 'i' was not declared in this scope
   23 |          S1 += W[i];
      |                  ^
a.cc:29:24: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   29 |    std::cout << sum << endl;
      |                        ^~~~
      |                        std::endl
In file included from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/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 <math.h>

int main (){
  int n,i,j,k,m,sum1=0,sum2=0,sa,o;
  scanf("%d",&n);
  int a[n],b[n];
  
  for (i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  
  for (j=0;j<n-1;j++){
    for (k=0;k<=j;k++){
      sum1+=a[j];
    }
    for (m=j+1;m<n;m++){
      sum2+=a[m];
    }
    b[j]=sum1-sum2;
  }
  sa=abs(b[0]);
  for (o=0;o<n-1;o++){
    if (sa>abs(b[o]){
      sa=abs(b[o]);
    }
  }
  printf("%d",sa);
}

Compiler output:
main.c: In function 'main':
main.c:22:6: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   22 |   sa=abs(b[0]);
      |      ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    2 | #include <math.h>
  +++ |+#include <stdlib.h>
    3 | 
main.c:24:21: error: expected ')' before '{' token
   24 |     if (sa>abs(b[o]){
      |        ~            ^
      |                     )
main.c:27:3: error: expected expression before '}' token
   27 |   }
      |   ^
Language: C

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

int main (){
  int n,i,j,k,m,sum1=0,sum2=0,sa,o;
  scanf("%d",&n);
  int a[n],b[n];
  
  for (i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  
  for (j=0;j<n-1;j++){
    for (k=0;k<=j;k++){
      sum1+=a[j];
    }
    for (m=j+1;m<n;m++){
      sum2+=a[m];
    }
    b[j]=sum1-sum2;
  }
  sa=abs(b[0]);
  for (o=0;o<n;o++){
    if (sa>abs(b[o]){
      sa=abs(b[o]);
    }
  }
  printf("%d",sa);
}

Compiler output:
main.c: In function 'main':
main.c:22:6: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   22 |   sa=abs(b[0]);
      |      ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    2 | #include <math.h>
  +++ |+#include <stdlib.h>
    3 | 
main.c:24:21: error: expected ')' before '{' token
   24 |     if (sa>abs(b[o]){
      |        ~            ^
      |                     )
main.c:27:3: error: expected expression before '}' token
   27 |   }
      |   ^
Language: C

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

int main (){
  int n,i,j,k,m,sum1,sum2,sa,o;
  scanf("%d",&n);
  int a[n],b[n];
  
  for (i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  
  for (j=0;j<n;j++){
    for (k=0;k<=j;k++){
      sum1+=a[j];
    }
    for (m=j+1;m<n;m++){
      sum2+=a[m];
    }
    b[j]=sum1-sum2;
  }
  sa=abs(b[0]);
  for (o=0;o<n;o++){
    if (sa>abs(b[o]){
      sa=abs(b[o]);
    }
  }
   printf("%d",sa);
}

Compiler output:
main.c: In function 'main':
main.c:22:6: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   22 |   sa=abs(b[0]);
      |      ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    2 | #include <math.h>
  +++ |+#include <stdlib.h>
    3 | 
main.c:24:21: error: expected ')' before '{' token
   24 |     if (sa>abs(b[o]){
      |        ~            ^
      |                     )
main.c:27:3: error: expected expression before '}' token
   27 |   }
      |   ^
Language: C

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

int main (){
  int n,i,j,k,m,sum1,sum2,sa,o;
  scanf("%d",&n);
  int a[n],b[n];
  
  for (i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  
  for (j=0;j<n;j++){
    for (k=0;k<=j;k++){
      sum1+=a[j];
    }
    for (m=j+1;m<n;m++){
      sum2+=a[m];
    }
    b[j]=sum1-sum2;
  }
  sa=abs(b[0]);
  for (o=0;o<n;o++){
    if (sa>abs(b[o]){
      sa=abs(b[o]);
    }
   printf("%d",sa);
}

Compiler output:
main.c: In function 'main':
main.c:22:6: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   22 |   sa=abs(b[0]);
      |      ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    2 | #include <math.h>
  +++ |+#include <stdlib.h>
    3 | 
main.c:24:21: error: expected ')' before '{' token
   24 |     if (sa>abs(b[o]){
      |        ~            ^
      |                     )
main.c:28:1: error: expected expression before '}' token
   28 | }
      | ^
main.c:28:1: error: expected declaration or statement at end of input
Language: C

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

int main (){
  int n,i,j,k,m,sum1,sum2,sa,o;
  scanf("%d",&n);
  int a[n],b[n];
  
  for (i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  
  for (j=0;j<n;j++){
    for (k=0;k<=j;k++){
      sum1+=a[j]
    }
    for (m=j+1;m<n;m++){
      sum2+=a[m];
    }
    b[j]=sum1-sum2;
  }
  sa=abs(b[0]);
  for (o=0;o<n;o++){
    if (sa>abs(b[o]){
      sa=abs(b[o]);
    }
   printf("%d",sa);
}

Compiler output:
main.c: In function 'main':
main.c:15:17: error: expected ';' before '}' token
   15 |       sum1+=a[j]
      |                 ^
      |                 ;
   16 |     }
      |     ~            
main.c:22:6: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   22 |   sa=abs(b[0]);
      |      ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    2 | #include <math.h>
  +++ |+#include <stdlib.h>
    3 | 
main.c:24:21: error: expected ')' before '{' token
   24 |     if (sa>abs(b[o]){
      |        ~            ^
      |                     )
main.c:28:1: error: expected expression before '}' token
   28 | }
      | ^
main.c:28:1: error: expected declaration or statement at end of input
Language: C

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

int main (){
  int n,i,j,k,m,sum1,sum2,sa,o;
  int a[],b[];
  
  scanf("%d",&n);
  
  for (i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  
  for (j=0;j<n;j++){
    for (k=0;k<=j;k++){
      sum1+=a[j]
    }
    for (m=j+1;m<n;m++){
      sum2+=a[m];
    }
    b[j]=sum1-sum2;
  }
  sa=abs(b[0]);
  for (o=0;o<n;o++){
    if (sa>abs(b[o]){
      sa=abs(b[o]);
    }
   printf("%d",sa);
}
        
  
  

Compiler output:
main.c: In function 'main':
main.c:6:7: error: array size missing in 'a'
    6 |   int a[],b[];
      |       ^
main.c:6:11: error: array size missing in 'b'
    6 |   int a[],b[];
      |           ^
main.c:16:17: error: expected ';' before '}' token
   16 |       sum1+=a[j]
      |                 ^
      |                 ;
   17 |     }
      |     ~            
main.c:23:6: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   23 |   sa=abs(b[0]);
      |      ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    2 | #include <math.h>
  +++ |+#include <stdlib.h>
    3 | 
main.c:25:21: error: expected ')' before '{' token
   25 |     if (sa>abs(b[o]){
      |        ~            ^
      |                     )
main.c:29:1: error: expected expression before '}' token
   29 | }
      | ^
main.c:29:1: error: expected declaration or statement at end of input
Language: C++

#include<bits/stdc++.h>

using namespace std;

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

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

  int rsum=0;
  int ans=sum;

  for(int i=0;i<n;i++)
  {
    rsum+=w.at(i);
    ans=min(ans,abs((sum-rsum)-rsum));
  }
  cout << ans << endl;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:18: error: template argument 1 is invalid
   11 |   vector<int. w(n);
      |                  ^
a.cc:11:18: error: template argument 2 is invalid
a.cc:14:14: error: 'w' was not declared in this scope
   14 |       cin >> w.at(i);
      |              ^
a.cc:23:11: error: 'w' was not declared in this scope
   23 |     rsum+=w.at(i);
      |           ^
Language: C++

#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int n, answer;
  cin >> n;
  int w[n], sum[n];
  cin >> w[0];
  sum[0] = w[0];
  for(int i = 1; i < n; i++){
    sum[i] = sum[i-1] + w[i];
  }
  answer = abs(sum[n-1] - sum * 2);
  for(int i =1; i < n; i++){
    int temp = abs(sum[n-1] - sum[i] *2);
    if(temp < answer)
      answer = temp;
  }
  cout << answer;
}  

Compiler output:
a.cc: In function 'int main()':
a.cc:13:31: error: invalid operands of types 'int [n]' and 'int' to binary 'operator*'
   13 |   answer = abs(sum[n-1] - sum * 2);
      |                           ~~~ ^ ~
      |                           |     |
      |                           |     int
      |                           int [n]
Language: C++

#include<stidio.h>
#include<math.h>
using namespace std;

int main(void){
  int a[100];
  int i, j, sub, s, min;
  cin >> n;
  for(i = 0; i < n; i++){
    cin >> a[i];
  }
  
  for(i = 0; i < n; i++){
    for(j = 0; j < i; j++){
      s += a[j];
    }
    sub[i] = fabs(all -s);
    
    if(sub[i]<sub[i-1]){
      min = sub[i];
      
    }
  }
  
  cout << min <<endl;
  return 0;
}
    

Compiler output:
a.cc:1:9: fatal error: stidio.h: No such file or directory
    1 | #include<stidio.h>
      |         ^~~~~~~~~~
compilation terminated.
Language: Java

import java.util.*;
class shashwat{
static Scanner in=new Scanner(System.in);
public static void main(String[] args) throws IOException 
	{ 
		int n=in.nextInt();
		int arr[]=new int[n];
		for(int i=0;i<n;i++)
			arr[i]=in.nextInt();
		int l[]=new int[n];
		int r[]=new  int[n];
		for(int i=0;i<n;i++) {
			if(i==0) {
				l[0]=arr[0];
				r[n-1]=arr[n-1];
			}
			else {
				l[i]=l[i-1]+arr[i];
				r[n-i-1]=r[n-i]+arr[n-i-1];
			}
		}
		//display(l);
		//display(r);
		int min=Integer.MAX_VALUE;
		for(int i=0;i<n-1;i++) {
			min=Math.min(min,Math.abs(l[i]-r[i+1]));
		}
			System.out.println(min);
		
		
		
		
	}

}

Compiler output:
Main.java:4: error: cannot find symbol
public static void main(String[] args) throws IOException 
                                              ^
  symbol:   class IOException
  location: class shashwat
1 error
Language: C++

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

int main(){
  
  int sum = 0;
  int N;
  vector<int>a(N);
  cin>>N;
  
  for(int i=0; i<N; i++){
    cin>>a(i);
    sum+=a(i);
  }
  
  int mini =sum;
  int p_sum
  for(int i=0; i<N;i++){
    cin>>a(i);
    p_sum+=a(i);
   ini = min(mini, abs(prefix_sum - (sum - prefix_sum)));
      cout<<mini<<endl;
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:12:11: error: no match for call to '(std::vector<int>) (int&)'
   12 |     cin>>a(i);
      |          ~^~~
a.cc:13:11: error: no match for call to '(std::vector<int>) (int&)'
   13 |     sum+=a(i);
      |          ~^~~
a.cc:18:3: error: expected initializer before 'for'
   18 |   for(int i=0; i<N;i++){
      |   ^~~
a.cc:18:16: error: 'i' was not declared in this scope
   18 |   for(int i=0; i<N;i++){
      |                ^
a.cc:23:4: error: expected '}' at end of input
   23 |   }
      |    ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

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

int main(){
  
  int sum = 0;
  int N;
  vector<int>a(N);
  cin>>N;
  
  for(int i=0; i<N; i++){
    cin>>a(i);
    sum+=a(i);
  }
  
  int mini =sum;
  int p_sum
  for(int i=0; i<N;i++){
    cin>>a(i);
    p_sum+=a(i);
    mini=min(mini,abs((sum-p_sum)-p_sum))
      cout<<mini<<endl;
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:12:11: error: no match for call to '(std::vector<int>) (int&)'
   12 |     cin>>a(i);
      |          ~^~~
a.cc:13:11: error: no match for call to '(std::vector<int>) (int&)'
   13 |     sum+=a(i);
      |          ~^~~
a.cc:18:3: error: expected initializer before 'for'
   18 |   for(int i=0; i<N;i++){
      |   ^~~
a.cc:18:16: error: 'i' was not declared in this scope
   18 |   for(int i=0; i<N;i++){
      |                ^
a.cc:23:4: error: expected '}' at end of input
   23 |   }
      |    ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int n;
    vector<int> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    int ans=INT_MAX;
    for(int i=1;i<=n;i++){
        int sum1=0,sum2=0;
        for(int j=0;j<n;j++){
            if(v[j]<=i){
                sum1+=v[i];
            }else{
                sum2+=v[i];
            }
        }
        ans = min(ans,abs(sum1-sum2));
    }
    cout<<ans;
}


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


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count_list [] = new int [n];
		int ans = 999999;

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

		for(int i = 1; i < n; i++) {
			int l = 0 ,r = 0;
			for(int j = 0; j < i; j++) {
				l += count_list[j];
			}
			for(int j = i; j < n; j++) {
				r += count_list[j];
			}

			ans = Math.min(ans,Math.abs(l-r));
			System.out.println(l + "-" + r);
		}
		System.out.println(ans);

Compiler output:
Main.java:30: error: reached end of file while parsing
		System.out.println(ans);
		                        ^
1 error
Language: C++

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>
#include <bitset>

#define P pair
#define X first
#define Y second
#define VSORT(v) sort(v.begin(), v.end())
#define VREV(v) reverse(v.begin(), v.end())
#define VMAX_P(v) max_element(v.begin(), v.end())
#define VMIN_P(v) min_element(v.begin(), v.end())
#define VMAX_IDX(v) distance(v.begin(), VMAX_P(v))
#define VMIN_IDX(v) distance(v.begin(), VMIN_P(v))
#define VCOPY(src, dst) copy(src.begin(), src.end(), back_inserter(dst))
#define SUPPER(src, dst) transform(src.begin(), src.end(), dst.begin(), toupper);
#define SLOWER(src, dst) transform(src.begin(), src.end(), dst.begin(), tolower);

using namespace std;
using ll = long long;

void displayVec(vector<int> v)
{
    for (int i = 0; i < v.size(); i++)
    {
        cout << v[i] << endl;
    }
    cout << endl;
}

int binarySearch(vector<int> v, int target)
{
    int left = -1;
    int right = v.size();

    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (v[mid] >= target)
        {
            right = mid;
        }
        else
        {
            left = mid;
        }
    }

    if (right < v.size() && v[right] == target)
    {
        return right;
    }
    return -1;
}

int main(int argc, const char *argv[])
{
    int n;
    cin >> n;
    vector<int> v(n), w(n);
    for (int i = 0; i < n; i++)
    {
        cin >> w[i];
    }

    v[0] = w[0];
    for (int i = 1; i < n; i++)
    {
        v[i] = v[i - 1] + w[i];
    }
    int min = INT_MAX;
    for (int i = 0; i < n; i++)
    {
        ans = min(ans, v[n - 1] - v[i]);
    }
    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:82:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   82 |         ans = min(ans, v[n - 1] - v[i]);
      |         ^~~
      |         abs
a.cc:82:18: error: 'min' cannot be used as a function
   82 |         ans = min(ans, v[n - 1] - v[i]);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~
a.cc:84:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   84 |     cout << ans << endl;
      |             ^~~
      |             abs
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 sum1,sum2;
  int MIN=1000000;
  for(int i=1;i<n-1;i++){
    sum1=sum2=0;
    for(int j=0;j<i;j++){
      sum1+=w[j];
    }
    for(int j=i;j<n;j++){
      sum2+=w[j];
    }
    MIN=min(MIN,abs(sum1-sum2));
}


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

#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    vector<int> w(n);
    for (int i=0; i<n; i++){
        cin>>w[i];
    }
    for (int i=0; i<n; i++){
        int l=0,r=0;
        for (int j=0; j<i; j++) l+=w[j];
        for (int j=i; j<n; j++) r+=w[j];
        ans=min(ans,abs(l-r));
    }
    cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:6:5: error: 'vector' was not declared in this scope
    6 |     vector<int> w(n);
      |     ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | using namespace std;
a.cc:6:12: error: expected primary-expression before 'int'
    6 |     vector<int> w(n);
      |            ^~~
a.cc:8:14: error: 'w' was not declared in this scope
    8 |         cin>>w[i];
      |              ^
a.cc:12:36: error: 'w' was not declared in this scope
   12 |         for (int j=0; j<i; j++) l+=w[j];
      |                                    ^
a.cc:13:36: error: 'w' was not declared in this scope
   13 |         for (int j=i; j<n; j++) r+=w[j];
      |                                    ^
a.cc:14:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   14 |         ans=min(ans,abs(l-r));
      |         ^~~
      |         abs
a.cc:16:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   16 |     cout<<ans<<endl;
      |           ^~~
      |           abs
Language: C++

#include <iostream>
#include <stdio.h>
#include <string>
#include <regex>
#include <cstdlib>
using namespace std;

int main() {
	int n;
	scanf_s("%d", &n);

	int* w = new int[n];
	for (int s = 0; s < n; s++) {
		scanf_s("%d", &w[s]);
	}

	int* front = new int[n];
	int* back = new int[n];
	int* absolute = new int[n];
	int count = 0;

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

		for (int j = 0; j < n - count; j++) {
			back[count] = back[count] + w[n - j - 1];
		}

		absolute[count] = abs(front[count] - back[count]);
	}

	int culmin = absolute[0];
	for (int mi = 0; mi < n; mi++) {
		if (absolute[mi] < culmin) {
			culmin = absolute[mi];
		}
	}
	printf("%d\n", culmin);

	delete[] w,front,back,absolute;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   10 |         scanf_s("%d", &n);
      |         ^~~~~~~
      |         scanf
Language: C++

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

int main(){
    int n;
    scanf("%d", &n);
    for(int i=1;i<=n;i++) scanf("%d", &a[i]);
    
    int lo = 1, hi = 100;
    int ans = 1e9;
    for(int i=0;i<100;i++){
        int mid1 = lo + (hi-lo)/3;
        int mid2 = lo + 2*(hi-lo)/3;

        int s1 = 0, s2 = 0;
        for(int i=1;i<=n;i++){
            if(a[i] <= mid1) s1+=a[i];
            else s2+=a[i];
        }

        int t1 = 0, t2 = 0;
        for(int i=1;i<=n;i++){
            if(a[i] <= mid2) t1+=a[i];
            else t2+=a[i];
        }
        ans = min(ans, abs(s1-s2));
        ans = min(ans, abs(t1-t2));
        if(abs(s1-s2) <= abs(t1-t2)){
            hi = mid2;
        }
        else{
            lo = mid1;
        }
    }
    printf("%d\n", ans);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:40: error: 'a' was not declared in this scope
    7 |     for(int i=1;i<=n;i++) scanf("%d", &a[i]);
      |                                        ^
a.cc:17:16: error: 'a' was not declared in this scope
   17 |             if(a[i] <= mid1) s1+=a[i];
      |                ^
a.cc:23:16: error: 'a' was not declared in this scope
   23 |             if(a[i] <= mid2) t1+=a[i];
      |                ^
Language: C

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

    int n,i,j,ans,z;
    int w[100];
    int sum1[100];
    int sum3[100];
    int sum=0;

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

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

    for(i=0;i<n;i++){
        sum3[i]=0#;
        for(j=i;j<n;j++){
            sum3[i]+=w[j];
        }
        sum1[i]=sum-sum3[i];

    }

    ans=sum;


    for(i=0;i<n;i++){
        z=abs(sum1[i]-sum3[i]);
        if(z<ans){
            ans=z;
        }
    }
    printf("%d",ans);
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:21:18: error: stray '#' in program
   21 |         sum3[i]=0#;
      |                  ^
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> W(n);
  for(int i=0;i<n;i++){
    cin >> w[i];
    w[i]+=i>0?w[i-1]:0;
  }
  int ans=w[n-1];
  for(int i=0;i<n;i++){
    ans=min(ans,abs(w[n-1]-2*w[i]));
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:12: error: 'w' was not declared in this scope
   11 |     cin >> w[i];
      |            ^
a.cc:14:11: error: 'w' was not declared in this scope
   14 |   int ans=w[n-1];
      |           ^
Language: C++

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

// 絶対値を返す関数
int abs(int num) {
  return (num < 0) ? -num : num;
}

// 配列のn番目までの総和を求める関数
int sumArr(int *arr, int n) {
  int sum = 0;
  int i = 0;
  while (i < n) {
    sum += arr[i++];
  }
  return sum;
}

int main() {
  int n;
  scanf("%d", &n);
  int *warr = malloc(sizeof(int) * n);
  if (warr == NULL) {
    exit(-1);
  }
  int i;
  for (i = 0; i < n; i++) {
    scanf("%d", warr+i);
  }

  int flag = 1;
  int diff = 10000000;
  for (flag = 1; flag < n; flag++)  {
    if (abs(diff) > abs(sumArr(warr, n) - 2*sumArr(warr, flag))) {
      diff = abs(sumArr(warr, n) - 2*sumArr(warr, flag));
    }
  }
  printf("%d\n", diff);


  return 0;


}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:21: error: invalid conversion from 'void*' to 'int*' [-fpermissive]
   22 |   int *warr = malloc(sizeof(int) * n);
      |               ~~~~~~^~~~~~~~~~~~~~~~~
      |                     |
      |                     void*
Language: C++

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  int sum = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    sum += a[i];
  }
  int mini = sum;
  int sum_sum = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    sum_sum +=a[i];
    mini = min(mini,abs(sum_sum - (sum - sum_sum)))
  }
  cout << mini << endl;
}

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

N = int(input())
W = list(map(int, input().split()))

l = W[0]
r = sum(W[1:])
diff = abs(l - r)
for i in range(1, N):
    l += W[i]
    r -= W[i]
    new_diff = abs(l-r)
    if new_diff < diff:
        diff = new_diff
print(diff)

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

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

using namespace std;

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

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

#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  vll A(n);
  FOR(i,0,n){
    ci(A[i])
  }
  ll ans=10000;
  FOR(i,1,n){
    FOR(j,0,n){
      ll a=0;
      ll b=0;
      	if(j<i) a+=A[j];
      	else b+=A[j];
    }
    ans=rM(ans,abs(a-b));
  }
  co(ans)
}

Compiler output:
a.cc: In function 'int main()':
a.cc:90:20: error: 'a' was not declared in this scope
   90 |     ans=rM(ans,abs(a-b));
      |                    ^
a.cc:27:23: note: in definition of macro 'rM'
   27 | #define rM(a,b) min(a,b)
      |                       ^
a.cc:90:22: error: 'b' was not declared in this scope
   90 |     ans=rM(ans,abs(a-b));
      |                      ^
a.cc:27:23: note: in definition of macro 'rM'
   27 | #define rM(a,b) min(a,b)
      |                       ^
Language: C++

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

int main(){
    int n;
    cin>>n;
    int w[n];
    int sum = 0;
    for (int i=0;i<n;i++) {
        cin>>w[i];
        sum += w[i];
        }
    
    int abs_min = sum + 1;
    for (int i=0;i<n;i++){
        int lsum = 0;
        for (int j=0; j<=i; j++){
            lsum += w[j];
        }
        int rl_abs_min = abs((sum - lsum) - lsum)
        if (abs_min > rl_abs_min){
            abs_min = rl_abs_min;
        }
    }
    cout<<abs_in<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:9: error: expected ',' or ';' before 'if'
   22 |         if (abs_min > rl_abs_min){
      |         ^~
a.cc:26:11: error: 'abs_in' was not declared in this scope; did you mean 'abs_min'?
   26 |     cout<<abs_in<<endl;
      |           ^~~~~~
      |           abs_min
Language: C++

#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
int main(){
  int n;
  	cin>>n;
  vector<int>A(n);
  cin>>A[0];
  
  for(int i=1;i<n;i++){
	cin>>A[i];
    A[i]+=A[i-1];
  }
  
  ll ans=10000;
  for(int i=0;i<n-1;i++){
	ans=min(ans,abs(A[n-1]-2*A[i]));
  }
  
  cout<<ans<<endl;
}
    

Compiler output:
a.cc: In function 'int main()':
a.cc:17:3: error: 'll' was not declared in this scope
   17 |   ll ans=10000;
      |   ^~
a.cc:19:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   19 |         ans=min(ans,abs(A[n-1]-2*A[i]));
      |         ^~~
      |         abs
a.cc:22:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   22 |   cout<<ans<<endl;
      |         ^~~
      |         abs
Language: C++

#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
int main(){
  int n;
  	cin>>n;
  vector<int>A(n);
  cin>>A[0];
  
  for(int i=1;i<n;i++){
	cin>>A[i];
    A[i]+=A[i-1];
  }
  
  ll ans=10000;
  for(int i=0;i<n-1;i++){
	ans=min(ans,abs(A[n-1]-s*A[i]));
  }
  
  cout<<ans<<endl;
}
    

Compiler output:
a.cc: In function 'int main()':
a.cc:17:3: error: 'll' was not declared in this scope
   17 |   ll ans=10000;
      |   ^~
a.cc:19:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   19 |         ans=min(ans,abs(A[n-1]-s*A[i]));
      |         ^~~
      |         abs
a.cc:19:32: error: 's' was not declared in this scope
   19 |         ans=min(ans,abs(A[n-1]-s*A[i]));
      |                                ^
a.cc:22:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   22 |   cout<<ans<<endl;
      |         ^~~
      |         abs
Language: C

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

int main(void)
{
	int i,n,w[100],sum=0,s1=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&w[i]);
		sum += w[i];
	}
	
	int ans = sum;
	for(i=0;i<n;i++){
		s1 += w[i];
		ans = min(ans,abs(sum-2*s1));
	}
	printf("%d\n",ans);
	
	return 0;
}


Compiler output:
main.c: In function 'main':
main.c:16:23: error: implicit declaration of function 'min'; did you mean 'main'? [-Wimplicit-function-declaration]
   16 |                 ans = min(ans,abs(sum-2*s1));
      |                       ^~~
      |                       main
Language: C++

// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{  int n,t;
 cin>>n>>t;
 int x=0;
    vector<int> vec(n);
 vector<int> sum(n-1);
 for(int i=0;i<n;i++){
 cin>>vec.at(i);
 }
 int sum1=0;
 int sum2=0;
 
 for(t=0;t<n-1;t++){
      for(int i=0;i<t;i++){
 sum1+=vec.at(i);
 }
 for(int i=t;i<n;i++){
 sum2+=vec.at(i);
 }
 if(sum1>sum2){
 sum.at(t)=sum1-sum2;
     }else{
 sum.at(t)=sum2-sum1;
    }
     sum1=0;
     sum2=0;
 }
 
 sort(sum.begin(),sum.end());
 cout<<sum.at(0)<<endl;
 }
 
    
    

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/





Compiler output:
a.cc: In function 'int main()':
a.cc:9:5: error: 'vector' was not declared in this scope
    9 |     vector<int> vec(n);
      |     ^~~~~~
a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    3 | #include <cstdlib>
  +++ |+#include <vector>
    4 | using namespace std;
a.cc:9:12: error: expected primary-expression before 'int'
    9 |     vector<int> vec(n);
      |            ^~~
a.cc:10:9: error: expected primary-expression before 'int'
   10 |  vector<int> sum(n-1);
      |         ^~~
a.cc:12:7: error: 'vec' was not declared in this scope
   12 |  cin>>vec.at(i);
      |       ^~~
a.cc:19:8: error: 'vec' was not declared in this scope
   19 |  sum1+=vec.at(i);
      |        ^~~
a.cc:22:8: error: 'vec' was not declared in this scope
   22 |  sum2+=vec.at(i);
      |        ^~~
a.cc:25:2: error: 'sum' was not declared in this scope; did you mean 'sum2'?
   25 |  sum.at(t)=sum1-sum2;
      |  ^~~
      |  sum2
a.cc:27:2: error: 'sum' was not declared in this scope; did you mean 'sum2'?
   27 |  sum.at(t)=sum2-sum1;
      |  ^~~
      |  sum2
a.cc:33:7: error: 'sum' was not declared in this scope; did you mean 'sum2'?
   33 |  sort(sum.begin(),sum.end());
      |       ^~~
      |       sum2
a.cc:33:2: error: 'sort' was not declared in this scope; did you mean 'short'?
   33 |  sort(sum.begin(),sum.end());
      |  ^~~~
      |  short
Language: C++

// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{  int n,t;
 cin>>n>>t;
 int x=0;
    vector<int> vec(n);
 vector<int> sum;
 for(int i=0;i<n;i++){
 cin>>vec.at(i);
 }
 int sum1=0;
 int sum2=0;
 
 for(t=1;t<n;t++){
      for(int i=0;i<t;i++){
 sum1+=vec.at(i);
 }
 for(int i=t;i<n;i++){
 sum2+=vec.at(i);
 }
 if(sum1>sum2){
 sum.at(t)=sum1-sum2;
     }else{
 sum.at(t)=sum2-sum1;
    }
     sum1=0;
     sum2=0;
 }
 
 sort(sum.begin(),sum.end());
 cout<<sum.at(1)<<endl;
 }
 
    
    

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/





Compiler output:
a.cc: In function 'int main()':
a.cc:9:5: error: 'vector' was not declared in this scope
    9 |     vector<int> vec(n);
      |     ^~~~~~
a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    3 | #include <cstdlib>
  +++ |+#include <vector>
    4 | using namespace std;
a.cc:9:12: error: expected primary-expression before 'int'
    9 |     vector<int> vec(n);
      |            ^~~
a.cc:10:9: error: expected primary-expression before 'int'
   10 |  vector<int> sum;
      |         ^~~
a.cc:12:7: error: 'vec' was not declared in this scope
   12 |  cin>>vec.at(i);
      |       ^~~
a.cc:19:8: error: 'vec' was not declared in this scope
   19 |  sum1+=vec.at(i);
      |        ^~~
a.cc:22:8: error: 'vec' was not declared in this scope
   22 |  sum2+=vec.at(i);
      |        ^~~
a.cc:25:2: error: 'sum' was not declared in this scope; did you mean 'sum2'?
   25 |  sum.at(t)=sum1-sum2;
      |  ^~~
      |  sum2
a.cc:27:2: error: 'sum' was not declared in this scope; did you mean 'sum2'?
   27 |  sum.at(t)=sum2-sum1;
      |  ^~~
      |  sum2
a.cc:33:7: error: 'sum' was not declared in this scope; did you mean 'sum2'?
   33 |  sort(sum.begin(),sum.end());
      |       ^~~
      |       sum2
a.cc:33:2: error: 'sort' was not declared in this scope; did you mean 'short'?
   33 |  sort(sum.begin(),sum.end());
      |  ^~~~
      |  short
Language: C++

// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{  int n,t;
 cin>>n>>t;
 int x=0;
    vector<int> vec(n);
 vector<int> sum(n-1);
 for(int i=0;i<n;i++){
 cin>>vec.at(i);
 }
 int sum1=0;
 int sum2=0;
 
 for(t=1;t<n;t++){
      for(int i=0;i<t;i++){
 sum1+=vec.at(i);
 }
 for(int i=t;i<n;i++){
 sum2+=vec.at(i);
 }
 if(sum1>sum2){
 sum.at(t)=sum1-sum2;
     }else{
 sum.at(t)=sum2-sum1;
    }
     sum1=0;
     sum2=0;
 }
 
 sort(sum.begin(),sum.end());
 cout<<sum.at(1)<<endl;
 }
 
    
    

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/





Compiler output:
a.cc: In function 'int main()':
a.cc:9:5: error: 'vector' was not declared in this scope
    9 |     vector<int> vec(n);
      |     ^~~~~~
a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    3 | #include <cstdlib>
  +++ |+#include <vector>
    4 | using namespace std;
a.cc:9:12: error: expected primary-expression before 'int'
    9 |     vector<int> vec(n);
      |            ^~~
a.cc:10:9: error: expected primary-expression before 'int'
   10 |  vector<int> sum(n-1);
      |         ^~~
a.cc:12:7: error: 'vec' was not declared in this scope
   12 |  cin>>vec.at(i);
      |       ^~~
a.cc:19:8: error: 'vec' was not declared in this scope
   19 |  sum1+=vec.at(i);
      |        ^~~
a.cc:22:8: error: 'vec' was not declared in this scope
   22 |  sum2+=vec.at(i);
      |        ^~~
a.cc:25:2: error: 'sum' was not declared in this scope; did you mean 'sum2'?
   25 |  sum.at(t)=sum1-sum2;
      |  ^~~
      |  sum2
a.cc:27:2: error: 'sum' was not declared in this scope; did you mean 'sum2'?
   27 |  sum.at(t)=sum2-sum1;
      |  ^~~
      |  sum2
a.cc:33:7: error: 'sum' was not declared in this scope; did you mean 'sum2'?
   33 |  sort(sum.begin(),sum.end());
      |       ^~~
      |       sum2
a.cc:33:2: error: 'sort' was not declared in this scope; did you mean 'short'?
   33 |  sort(sum.begin(),sum.end());
      |  ^~~~
      |  short
Language: C++

// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{  int n,t;
 cin>>n>>t;
 int x=0;
    vector<int> vec(n);
 vector<int> sum(n-1);
 for(int i=0;i<n;i++){
 cin>>vec.at(i);
 }
 int sum1=0;
 int sum2=0;
 
 for(t=1;t<n;t++){
      for(int i=0;i<t;i++){
 sum1+=vec.at(i);
 }
 for(int i=t;i<n;i++){
 sum2+=vec.at(i);
 }
 if(sum1>sum2){
 sum.at(t)=sum1-sum2;
     }else{
 sum.at(t)=sum2-sum1;
    }
     sum1=0;
     sum2=0;
 }
 
 sort(sum.begin(),sum.end());
 cout<<sum.at(0)<<endl;
 }
 
    
    

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/




Compiler output:
a.cc: In function 'int main()':
a.cc:9:5: error: 'vector' was not declared in this scope
    9 |     vector<int> vec(n);
      |     ^~~~~~
a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    3 | #include <cstdlib>
  +++ |+#include <vector>
    4 | using namespace std;
a.cc:9:12: error: expected primary-expression before 'int'
    9 |     vector<int> vec(n);
      |            ^~~
a.cc:10:9: error: expected primary-expression before 'int'
   10 |  vector<int> sum(n-1);
      |         ^~~
a.cc:12:7: error: 'vec' was not declared in this scope
   12 |  cin>>vec.at(i);
      |       ^~~
a.cc:19:8: error: 'vec' was not declared in this scope
   19 |  sum1+=vec.at(i);
      |        ^~~
a.cc:22:8: error: 'vec' was not declared in this scope
   22 |  sum2+=vec.at(i);
      |        ^~~
a.cc:25:2: error: 'sum' was not declared in this scope; did you mean 'sum2'?
   25 |  sum.at(t)=sum1-sum2;
      |  ^~~
      |  sum2
a.cc:27:2: error: 'sum' was not declared in this scope; did you mean 'sum2'?
   27 |  sum.at(t)=sum2-sum1;
      |  ^~~
      |  sum2
a.cc:33:7: error: 'sum' was not declared in this scope; did you mean 'sum2'?
   33 |  sort(sum.begin(),sum.end());
      |       ^~~
      |       sum2
a.cc:33:2: error: 'sort' was not declared in this scope; did you mean 'short'?
   33 |  sort(sum.begin(),sum.end());
      |  ^~~~
      |  short
Language: C++

// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{  int n,t;
 cin>>n>>t;
 int x=0;
    vector<int> vec(n);
 vector<int> sum(n-1);
 for(int i=0;i<n;i++){
 cin>>vec.at(i);
 }
 int sum1=0;
 int sum2=0;
 for(t=1;t<n;t++){
      for(int i=0;i<t;i++){
 sum1+=vec.at(i);
 }
 for(int i=t;i<n;i++){
 sum2+=vec.at(i);
 }
 if(sum1>sum2){
 sum.at(i)=sum1-sum2;
     }else{
 sum.at(i)=sum2-sum1;
    }
     sum1=0;
     sum2=0;
 }
 sort(sum.begin(),sum.end());
 cout<<sum.at(0)<<endl;
 }
 
    
    

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/




Compiler output:
a.cc: In function 'int main()':
a.cc:9:5: error: 'vector' was not declared in this scope
    9 |     vector<int> vec(n);
      |     ^~~~~~
a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    3 | #include <cstdlib>
  +++ |+#include <vector>
    4 | using namespace std;
a.cc:9:12: error: expected primary-expression before 'int'
    9 |     vector<int> vec(n);
      |            ^~~
a.cc:10:9: error: expected primary-expression before 'int'
   10 |  vector<int> sum(n-1);
      |         ^~~
a.cc:12:7: error: 'vec' was not declared in this scope
   12 |  cin>>vec.at(i);
      |       ^~~
a.cc:18:8: error: 'vec' was not declared in this scope
   18 |  sum1+=vec.at(i);
      |        ^~~
a.cc:21:8: error: 'vec' was not declared in this scope
   21 |  sum2+=vec.at(i);
      |        ^~~
a.cc:24:2: error: 'sum' was not declared in this scope; did you mean 'sum2'?
   24 |  sum.at(i)=sum1-sum2;
      |  ^~~
      |  sum2
a.cc:24:9: error: 'i' was not declared in this scope
   24 |  sum.at(i)=sum1-sum2;
      |         ^
a.cc:26:2: error: 'sum' was not declared in this scope; did you mean 'sum2'?
   26 |  sum.at(i)=sum2-sum1;
      |  ^~~
      |  sum2
a.cc:26:9: error: 'i' was not declared in this scope
   26 |  sum.at(i)=sum2-sum1;
      |         ^
a.cc:31:7: error: 'sum' was not declared in this scope; did you mean 'sum2'?
   31 |  sort(sum.begin(),sum.end());
      |       ^~~
      |       sum2
a.cc:31:2: error: 'sort' was not declared in this scope; did you mean 'short'?
   31 |  sort(sum.begin(),sum.end());
      |  ^~~~
      |  short