criyle/codenet-compile-errors huggingface dataset:
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);
 }
 
    
    

// 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
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);
 }
 
    
    

// 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:17:26: error: expected ';' before ')' token
   17 |       for(int i=0;i<t,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
Language: C++

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

int main()
{
    int64_t n;
    cin>>n;
    vector<int64_t>w(n);
    int64_t sum=0;
    REP(i,n){cin>>w.at(i);sum+=w.at(i);}
    int mini=sum;
    int s1=0;
    REP(i,n)
    {
        s1+=w.at(i);
        mini=min(mini,abs(s1-(sum-s1)));
    }
    cout<<mini<<endl;
}


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

#include<stdio.h>

int main(){
int n,a,b,c;
  a=0;b=0;c=0
  scanf("%d",&n);
  int s[n];
  for(int i=0;i<n;++i){
    scanf("%d",&s[i]);
   a+=s[i];
  }
  int B = a;
  int k =0;
while(b<B){
  b+=s[k];
  B -=s[k];
  ++k;
}
  int C = a;
  int l=1;
  while(c<C){
  c+=s[n-l];
    C -=s[n-l];
   ++l;
  }
  if(b-B<c-C)
    printf("%d",b-B);
  else
    printf("%d",c-C);
}


Compiler output:
main.c: In function 'main':
main.c:5:14: error: expected ';' before 'scanf'
    5 |   a=0;b=0;c=0
      |              ^
      |              ;
    6 |   scanf("%d",&n);
      |   ~~~~~
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(int i=0;i<t,i++){
 sum1+=vec.at(i);
 }
 for(int i=t;i<n;i++){
 sum2+=vec.at(i);
 }
 for(t=1;t<n;t++){
 if(sum1>sum2){
 sum.at(i)=sum1-sum2;
     }else{
 sum.at(i)=sum2-sum1;
    }
    }
 sort(sum.begin(),sum.end());
 cout>>sum.at(0);
 }
 
    
    

// 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:16:21: error: expected ';' before ')' token
   16 |  for(int i=0;i<t,i++){
      |                     ^
      |                     ;
a.cc:17:8: error: 'vec' was not declared in this scope
   17 |  sum1+=vec.at(i);
      |        ^~~
a.cc:20:8: error: 'vec' was not declared in this scope
   20 |  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:29:7: error: 'sum' was not declared in this scope; did you mean 'sum2'?
   29 |  sort(sum.begin(),sum.end());
      |       ^~~
      |       sum2
a.cc:29:2: error: 'sort' was not declared in this scope; did you mean 'short'?
   29 |  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(int i=0;i<t,i++){
 sum1+=vec.at(i);
 }
 for(int i=t,i<n;i++){
 sum2+=vec.at(i);
 }
 for(t=1;t<n;t++){
 if(sum1>sum2){
 sum.at(i)=sum1-sum2;
     }else{
 sum.at(i)=sum2-sum1;
    }
    }
 sort(sum.begin(),sum.end());
 cout>>sum.at(0);
 }
 
    
    

// 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:16:21: error: expected ';' before ')' token
   16 |  for(int i=0;i<t,i++){
      |                     ^
      |                     ;
a.cc:17:8: error: 'vec' was not declared in this scope
   17 |  sum1+=vec.at(i);
      |        ^~~
a.cc:19:15: error: expected ';' before '<' token
   19 |  for(int i=t,i<n;i++){
      |               ^
      |               ;
a.cc:19:15: error: expected primary-expression before '<' token
a.cc:20:8: error: 'vec' was not declared in this scope
   20 |  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:29:7: error: 'sum' was not declared in this scope; did you mean 'sum2'?
   29 |  sort(sum.begin(),sum.end());
      |       ^~~
      |       sum2
a.cc:29:2: error: 'sort' was not declared in this scope; did you mean 'short'?
   29 |  sort(sum.begin(),sum.end());
      |  ^~~~
      |  short
Language: C++

#include<iostream>
#include <string.h>
#include <algorithm>
#include <string>
#include <math.h>
typedef long long ll;
using namespace std;

double gcd( double m, double n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
    double p=0;
	// ユークリッドの方法
	while( m > n )
	{
        m = m/2;
        p+=1;
	}
	return p;
}//gcd

int main()
{
    int a[100],n,h=0,l=0,f=0,b=0,ans;
    memset(a,0,sizeof(a));
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for(int i = 0; i < n; i++)
    {
        if(h<=l)
        {
            h+=a[f];
            f++;
        }else
        {
            l+=a[n-1-b];
            b++;
        }
    }
    if(h >= l)
    {
        ans = h-l;
    }
    else
    {
        ans = l-h;
    }
    
    cout << ans << ensl;
 




    return 0;
}

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

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
  int n,c;
  char s,w[999][n];
  scanf("%d",&n);
  int e[n],k[n],i;
  scanf("%s",s);
  w[999][0]=strtok(s, " ");
  for(i=1;i<n;i++){
    w[999][i]=strtok(NULL, " ");
  }
  int a=0,b=0;
  for(i=0;i<n;i++){
    e[i]=atoi(w[999][i]);
    a=a+e[i];
  }
  for(i=0;i<n;i++){
    b=b+e[i];
    k[i]=abs(a-2*b);
  }
  c=k[0];
  for(i=0;i<n-1;i++){
    if(k[i+1]<c){
      c=k[i+1];
    }
  }
  printf("%d",c);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:20: error: invalid conversion from 'char' to 'char*' [-fpermissive]
   10 |   w[999][0]=strtok(s, " ");
      |                    ^
      |                    |
      |                    char
In file included from a.cc:3:
/usr/include/string.h:356:39: note:   initializing argument 1 of 'char* strtok(char*, const char*)'
  356 | extern char *strtok (char *__restrict __s, const char *__restrict __delim)
      |                      ~~~~~~~~~~~~~~~~~^~~
a.cc:10:19: error: invalid conversion from 'char*' to 'char' [-fpermissive]
   10 |   w[999][0]=strtok(s, " ");
      |             ~~~~~~^~~~~~~~
      |                   |
      |                   char*
a.cc:12:21: error: invalid conversion from 'char*' to 'char' [-fpermissive]
   12 |     w[999][i]=strtok(NULL, " ");
      |               ~~~~~~^~~~~~~~~~~
      |                     |
      |                     char*
a.cc:16:23: error: invalid conversion from 'char' to 'const char*' [-fpermissive]
   16 |     e[i]=atoi(w[999][i]);
      |               ~~~~~~~~^
      |                       |
      |                       char
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/c++/14/stdlib.h:36,
                 from a.cc:2:
/usr/include/stdlib.h:105:30: note:   initializing argument 1 of 'int atoi(const char*)'
  105 | extern int atoi (const char *__nptr)
      |                  ~~~~~~~~~~~~^~~~~~
Language: C++

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
  int n,c;
  char s,w[999][n];
  scanf("%d",&n);
  int e[n],k[n],i;
  scanf("%s",s);
  w[999][0]=strtok(s, " ");
  for(i=1;i<n;i++){
    w[999][i]=strtok(NULL, " ");
  }
  int a=0,b=0;
  for(i=0;i<n;i++){
    e[i]=atoi(w[i]);
    a=a+e[i];
  }
  for(i=0;i<n;i++){
    b=b+e[i];
    k[i]=abs(a-2*b);
  }
  c=k[0];
  for(i=0;i<n-1;i++){
    if(k[i+1]<c){
      c=k[i+1];
    }
  }
  printf("%d",c);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:20: error: invalid conversion from 'char' to 'char*' [-fpermissive]
   10 |   w[999][0]=strtok(s, " ");
      |                    ^
      |                    |
      |                    char
In file included from a.cc:3:
/usr/include/string.h:356:39: note:   initializing argument 1 of 'char* strtok(char*, const char*)'
  356 | extern char *strtok (char *__restrict __s, const char *__restrict __delim)
      |                      ~~~~~~~~~~~~~~~~~^~~
a.cc:10:19: error: invalid conversion from 'char*' to 'char' [-fpermissive]
   10 |   w[999][0]=strtok(s, " ");
      |             ~~~~~~^~~~~~~~
      |                   |
      |                   char*
a.cc:12:21: error: invalid conversion from 'char*' to 'char' [-fpermissive]
   12 |     w[999][i]=strtok(NULL, " ");
      |               ~~~~~~^~~~~~~~~~~
      |                     |
      |                     char*
Language: C++

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <queue> 
using namespace std;
int main(void){
    int n,i,sum1=0,sum2=0,ans=10000000000;
    cin>>n;
    int w[n];
    for(i=0;i<n;i++){
        cin>>w[i];
        sum1+=w[i];
    }
    for(i=0;i<n;i++){
        sum2+=w[i];
        sum1-=w[i];
        ans=min(abs(sum1-sum2));
    }
    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:31: warning: overflow in conversion from 'long int' to 'int' changes value from '10000000000' to '1410065408' [-Woverflow]
   11 |     int n,i,sum1=0,sum2=0,ans=10000000000;
      |                               ^~~~~~~~~~~
a.cc:21:16: error: no matching function for call to 'min(int)'
   21 |         ans=min(abs(sum1-sum2));
      |             ~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:5:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   template argument deduction/substitution failed:
a.cc:21:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   21 |         ans=min(abs(sum1-sum2));
      |             ~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   candidate expects 2 arguments, 1 provided
Language: C++

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <queue> 
using namespace std;
int main(void){
    int n,isum1=0,sum2=0,ans=10000000000;
    cin>>n;
    int w[n];
    for(i=0;i<n;i++){
        cin>>w[i];
        sum1+=w[i];
    }
    for(i=0;i<n;i++){
        sum2+=w[i];
        sum1-=w[i];
        ans=min(abs(sum1-sum2));
    }
    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:30: warning: overflow in conversion from 'long int' to 'int' changes value from '10000000000' to '1410065408' [-Woverflow]
   11 |     int n,isum1=0,sum2=0,ans=10000000000;
      |                              ^~~~~~~~~~~
a.cc:14:9: error: 'i' was not declared in this scope
   14 |     for(i=0;i<n;i++){
      |         ^
a.cc:16:9: error: 'sum1' was not declared in this scope; did you mean 'sum2'?
   16 |         sum1+=w[i];
      |         ^~~~
      |         sum2
a.cc:18:9: error: 'i' was not declared in this scope
   18 |     for(i=0;i<n;i++){
      |         ^
a.cc:20:9: error: 'sum1' was not declared in this scope; did you mean 'sum2'?
   20 |         sum1-=w[i];
      |         ^~~~
      |         sum2
Language: C++

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
  int n,c;
  char s,w[999999][n];
  scanf("%d",&n);
  int e[n],k[n],i;
  scanf("%s",s);
  w[0]=strtok(s, " ");
  for(i=1;i<n;i++){
    w[i]=strtok(NULL, " ");
  }
  int a=0,b=0;
  for(i=0;i<n;i++){
    e[i]=atoi(w[i]);
    a=a+e[i];
  }
  for(i=0;i<n;i++){
    b=b+e[i];
    k[i]=abs(a-2*b);
  }
  c=k[0];
  for(i=0;i<n-1;i++){
    if(k[i+1]<c){
      c=k[i+1];
    }
  }
  printf("%d",c);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:15: error: invalid conversion from 'char' to 'char*' [-fpermissive]
   10 |   w[0]=strtok(s, " ");
      |               ^
      |               |
      |               char
In file included from a.cc:3:
/usr/include/string.h:356:39: note:   initializing argument 1 of 'char* strtok(char*, const char*)'
  356 | extern char *strtok (char *__restrict __s, const char *__restrict __delim)
      |                      ~~~~~~~~~~~~~~~~~^~~
a.cc:10:7: error: incompatible types in assignment of 'char*' to 'char [n]'
   10 |   w[0]=strtok(s, " ");
      |   ~~~~^~~~~~~~~~~~~~~
a.cc:12:9: error: incompatible types in assignment of 'char*' to 'char [n]'
   12 |     w[i]=strtok(NULL, " ");
      |     ~~~~^~~~~~~~~~~~~~~~~~
Language: C++

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
  int n,c;
  char s,w[n];
  scanf("%d",&n);
  int e[n],k[n],i;
  scanf("%s",s);
  w[0]=strtok(s, " ");
  for(i=1;i<n;i++){
    w[i]=strtok(NULL, " ");
  }
  int a=0,b=0;
  for(i=0;i<n;i++){
    e[i]=atoi(w[i]);
    a=a+e[i];
  }
  for(i=0;i<n;i++){
    b=b+e[i];
    k[i]=abs(a-2*b);
  }
  c=k[0];
  for(i=0;i<n-1;i++){
    if(k[i+1]<c){
      c=k[i+1];
    }
  }
  printf("%d",c);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:15: error: invalid conversion from 'char' to 'char*' [-fpermissive]
   10 |   w[0]=strtok(s, " ");
      |               ^
      |               |
      |               char
In file included from a.cc:3:
/usr/include/string.h:356:39: note:   initializing argument 1 of 'char* strtok(char*, const char*)'
  356 | extern char *strtok (char *__restrict __s, const char *__restrict __delim)
      |                      ~~~~~~~~~~~~~~~~~^~~
a.cc:10:14: error: invalid conversion from 'char*' to 'char' [-fpermissive]
   10 |   w[0]=strtok(s, " ");
      |        ~~~~~~^~~~~~~~
      |              |
      |              char*
a.cc:12:16: error: invalid conversion from 'char*' to 'char' [-fpermissive]
   12 |     w[i]=strtok(NULL, " ");
      |          ~~~~~~^~~~~~~~~~~
      |                |
      |                char*
a.cc:16:18: error: invalid conversion from 'char' to 'const char*' [-fpermissive]
   16 |     e[i]=atoi(w[i]);
      |               ~~~^
      |                  |
      |                  char
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/c++/14/stdlib.h:36,
                 from a.cc:2:
/usr/include/stdlib.h:105:30: note:   initializing argument 1 of 'int atoi(const char*)'
  105 | extern int atoi (const char *__nptr)
      |                  ~~~~~~~~~~~~^~~~~~
Language: C++

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
  int n,c;
  char s;
  scanf("%d",&n);
  int w[n],k[n],i;
  scanf("%s",s);
  w[0]=atoi(strtok(s, " "););
  for(i=1;i<n;i++){
    w[i]=atoi(strtok(NULL, " "););
  }
  int a=0,b=0;
  for(i=0;i<n;i++){
    a=a+w[i];
  }
  for(i=0;i<n;i++){
    b=b+w[i];
    k[i]=abs(a-2*b);
  }
  c=k[0];
  for(i=0;i<n-1;i++){
    if(k[i+1]<c){
      c=k[i+1];
    }
  }
  printf("%d",c);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:20: error: invalid conversion from 'char' to 'char*' [-fpermissive]
   10 |   w[0]=atoi(strtok(s, " "););
      |                    ^
      |                    |
      |                    char
In file included from a.cc:3:
/usr/include/string.h:356:39: note:   initializing argument 1 of 'char* strtok(char*, const char*)'
  356 | extern char *strtok (char *__restrict __s, const char *__restrict __delim)
      |                      ~~~~~~~~~~~~~~~~~^~~
a.cc:10:27: error: expected ')' before ';' token
   10 |   w[0]=atoi(strtok(s, " "););
      |            ~              ^
      |                           )
a.cc:10:28: error: expected primary-expression before ')' token
   10 |   w[0]=atoi(strtok(s, " "););
      |                            ^
a.cc:12:32: error: expected ')' before ';' token
   12 |     w[i]=atoi(strtok(NULL, " "););
      |              ~                 ^
      |                                )
a.cc:12:33: error: expected primary-expression before ')' token
   12 |     w[i]=atoi(strtok(NULL, " "););
      |                                 ^
Language: Java

package brincandeira;

import java.util.Scanner;

public class Main.extension {
	
	public static void main(String[]args) {

		Scanner tc = new Scanner(System.in);
		
		int k = 0, l = 0, z = 0;
		
		
		int x = tc.nextInt();
		
		int a[] = new int[x];
		
		for (int i = 0; i < x; i++) a[i] = tc.nextInt();
		
		if(x % 2 == 0) {
			z = x/ 2;
			int b[] = new int[z];
			int c[] = new int[z];
			
			
			for (int i = 0; i < z; i++) b[i] = a[i];
				
			for (int i = 0; i < z; i++) c[i] = a[i+z];
			
			
			
			for (int i = 0; i < z; i++) k += b[i];

			for (int i = 0; i < z; i++) l += c[i];
			
			
			if(k <= l) k = l - k;
			
			else k -= l;
			
			System.out.println(k);
	
			} else {
			z = x - 1;
			z /= 2;
			
			
			int b[] = new int[z];
			int c[] = new int[z];
			
			for (int i = 0; i < z; i++) b[i] = a[i];
			
			for (int i = 0; i < z; i++) c[i] = a[i+z];
			
			
			for (int i = 0; i < z; i++) k += b[i];

			for (int i = 0; i < z; i++) l += c[i];
			

			k = (l-a[z]+a[x-1]) - (k + a[z]);
			
			
			System.out.println(k);
			
		}
		
	}
}


Compiler output:
Main.java:5: error: '{' expected
public class Main.extension {
                 ^
1 error
Language: C++


#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

using ll = long long;
using namespace std;

#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define LFOR(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define FORR(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define LFORR(i,a,b) for(ll i = (int)(a); i >= (ll)(b); i--)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define LREP(i,n) LFOR(i,0,(ll)(n)-1)
#define REPR(i,n) FORR(i,(int)(n)-1,0)
#define LREPR(i,n) LFORR(i,(ll)(n)-1,0)

#define SIZ(v) int(v.size())
const int INF = 1e8;
const ll LINF = 1e15;





int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> ws;
  REP(i,n){
    int k;
    cin >> k;
    if (!i) ws.push_back(k);
    else ws.push_back(k+w[i-1]);
  }
  int ans;
  REP(i,n-1){
    int dd = ws[n-1]-2*ws[i];
    ans = min(ans, max(dd,-dd));
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:50:25: error: 'w' was not declared in this scope
   50 |     else ws.push_back(k+w[i-1]);
      |                         ^
Language: Java

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] W = new int[N];
		for(int i=0; i<N; i++) {
			W[i] = sc.nextInt();
		}
		
		int min = 20000;
		for(int i=0; i<N; i++) {
			int t =Math.abs(calcsum1(W,i) - calcsum2(W,i));
			if(t<min) {min = t;}
		}
		System.out.println(min);
		
		sc.close();
		
	}
	
	static int calcsum1(int[] W,int t) {
		int sum = 0;
		for(int i=0;i<=t; i++) {
			sum += W[i];
		}
		return sum;
	}
	
	static int calcsum2(int[] W,int t) {
		int sum = 0;
		for(int i=t+1;i<=W.length-1; i++) {
			sum += W[i];
		}
		return sum;
	}

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

#include <stdio.h>
 
int main()
{
    int n=0, sum = 0, X;
    int t[100];
    int i = 0;
    int sun = 0;
    do {
		scanf("%d",&t[n]);
                 sum = sum + t[n];
	} while (n < 100);
    
    while{
    sun = sun + t[i];
    i = i + 1;
       if (sun > sum/2) {
                break;
        }
    }
  if(sum/2-sun > sun+t[i+1]-sum/2 ){
  i = i+1;
  }
 
 
    printf("%d\n",i);
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:14:10: error: expected '(' before '{' token
   14 |     while{
      |          ^
      |          (
Language: C++

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <fstream>
#include <iterator>
#include "prettyprint.hpp"

using namespace std;
using ll = long long;

int main()
{
    int N;
    cin >> N;
    vector<int> W(N);
    for (int i = 0; i < N; i++)
    {
        cin >> W[i];
    }
    // sort(W.begin(), W.end());
    // cout << W << endl;
    int sum1 = 0, sum2 = 0;
    int ans = 10000000;
    for (int i = 1; i <= N; i++)
    {
        for (int s1 = 0; s1 < i; s1++)
        {
            sum1 += W[s1];
        }

        for (int s2 = N - 1; s2 >= i; s2--)
        {
            sum2 += W[s2];
        }
        // cout << "sum1: " << sum1 << " sum2: " << sum2 << endl;
        ans = min(ans, abs(sum1 - sum2));
        sum1 = 0, sum2 = 0;
    }
    cout << ans << endl;
}

Compiler output:
a.cc:15:10: fatal error: prettyprint.hpp: No such file or directory
   15 | #include "prettyprint.hpp"
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
  int n,c;
  char s;
  scanf("%d",&n);
  int w[n],k[n],i;
  scanf("%s",s);
  w[0]=strtok(s, " ");
  for(i=1;i<n;i++){
    w[i]=strtok(NULL, " ");
  }
  int a=0,b=0;
  for(i=0;i<n;i++){
    a=a+w[i];
  }
  for(i=0;i<n;i++){
    b=b+w[i];
    k[i]=abs(a-2*b);
  }
  c=k[0];
  for(i=0;i<n-1;i++){
    if(k[i+1]<c){
      c=k[i+1];
    }
  }
  printf("%d",c);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:15: error: invalid conversion from 'char' to 'char*' [-fpermissive]
   10 |   w[0]=strtok(s, " ");
      |               ^
      |               |
      |               char
In file included from a.cc:3:
/usr/include/string.h:356:39: note:   initializing argument 1 of 'char* strtok(char*, const char*)'
  356 | extern char *strtok (char *__restrict __s, const char *__restrict __delim)
      |                      ~~~~~~~~~~~~~~~~~^~~
a.cc:10:14: error: invalid conversion from 'char*' to 'int' [-fpermissive]
   10 |   w[0]=strtok(s, " ");
      |        ~~~~~~^~~~~~~~
      |              |
      |              char*
a.cc:12:16: error: invalid conversion from 'char*' to 'int' [-fpermissive]
   12 |     w[i]=strtok(NULL, " ");
      |          ~~~~~~^~~~~~~~~~~
      |                |
      |                char*
Language: C++

#include<bits/stdc++.h>
using namespace std;
int min(int a ,int b){
    if(a>b){
        return(b);
    }else{
        return(a);
    }
}
int max(int a ,int b){
    if(a<b){
        return(b);
    }else{
        return(a);
    }
}
int main(){
    int n;
    cin>>n;
    int a[n];
    cin>>a[0];
    for(int i=1;i<n;i++)[
        cin>>a[i];
        a[i]+=a[i-1];
    ]
    int mm=abs(a[n-1]-a[0]-a[0]);
    for(int i=1;i<n;i++){
        if(mm>abs(a[n-1]-a[i]-a[i])){
            mm=abs(a[n-1]-a[i]-a[i]);
        }
    }
    cout<<mm<<endl;
    return(0);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:9: warning: capture of variable 'std::cin' with non-automatic storage duration
   23 |         cin>>a[i];
      |         ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::istream std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:23:12: error: expected ',' before '>>' token
   23 |         cin>>a[i];
      |            ^~
      |            ,
a.cc:23:12: error: expected identifier before '>>' token
   23 |         cin>>a[i];
      |            ^~
a.cc:23:18: error: expected ']' before ';' token
   23 |         cin>>a[i];
      |                  ^
      |                  ]
a.cc: In lambda function:
a.cc:23:18: error: expected '{' before ';' token
a.cc: In function 'int main()':
a.cc:24:11: error: 'i' was not declared in this scope
   24 |         a[i]+=a[i-1];
      |           ^
a.cc:25:5: error: expected primary-expression before ']' token
   25 |     ]
      |     ^
a.cc:28:12: error: 'mm' was not declared in this scope; did you mean 'tm'?
   28 |         if(mm>abs(a[n-1]-a[i]-a[i])){
      |            ^~
      |            tm
a.cc:32:11: error: 'mm' was not declared in this scope; did you mean 'tm'?
   32 |     cout<<mm<<endl;
      |           ^~
      |           tm
Language: C++

#include<iostream>
#include<vector>
#include <algorithm>
using namespace std;
int main(){
  int N,W,sum=0,sum1=0;
  vector<int> a;
  for(int i=0;i<N;i++){
  	cin >> W;
    sum+=W;
  }
  sum1=sum;
  for(int j=0;j<N;j++){
  	sum1-=v[j];
    a.push_back(sum/N-sum1);
  }
  sort(a.begin(), a.end());
  cout << abs(a[0]) << endl;
  return 0;
}

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

Compiler output:
Main.java:7: error: variable i might not have been initialized
      	for (int i;i<n;i++){
      	           ^
1 error
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 a[] = new int[n];
      	for (int i;i<n;i++){
          a[i] = sc.nextInt();
        }
		int min = 10000;
      	int f = 0;
      	int l = 0;
		for (int i;i<n;i++){
          for (int j = 0;j<i;j++){
            f += a[j];
          }
          for (int j = i;j<n;j++){
            l += a[j];
          }
          if(min > Math.abs(f-l)){
            min = Math.abs(f-l);
          }
        }
		System.out.println(min);
	}
}

Compiler output:
Main.java:7: error: variable i might not have been initialized
      	for (int i;i<n;i++){
      	           ^
Main.java:13: error: variable i might not have been initialized
		for (int i;i<n;i++){
		           ^
2 errors
Language: C

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

Compiler output:
main.c: In function 'main':
main.c:16:10: error: expected '(' before '{' token
   16 |     while{
      |          ^
      |          (
Language: C++

/*空港 A, B, C があり、それぞれの空港の間では、双方向に飛行機が運航しています。

空港 A, B 間の飛行時間は片道 
P時間、
空港 B, C 間の飛行時間は片道 
Q時間、
空港 C, A 間の飛行時間は片道 
R時間です。

いずれかの空港からスタートして他の空港に飛行機で移動し、さらにそのどちらでもない空港に飛行機で移動するような経路を考えます。

飛行時間の和は最短で何時間になるでしょうか。*/

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

using namespace std;

int main(){

	int n;
	cin>>n;
	int sum1=0,sum2=0;
	int difference;

	int w[n];

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

	for (int t = 0; t < n; ++t)
	{
		for (int i = 0; i < n; ++i)
		{
			if(i<t){
				sum1+=w[i];
			}else{
				sum2+=w[i];
			}

		}
		ans=abs(sum1-sum2);
		if(difference>ans){	
			difference=ans;
		}
		sum1=0;
		sum2=0;
	}

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




Compiler output:
a.cc: In function 'int main()':
a.cc:45:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   45 |                 ans=abs(sum1-sum2);
      |                 ^~~
      |                 abs
Language: C++

#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <algorithm>
int main() {
    int n,m;
    int goukei=0;
    cin >> n;
    vector<int> a(n);
    vector<int> sa(n-1);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
        goukei = goukei+a.at(i);
    }
    sort(a.begin(), a.end());
    int A = 0; int B; int ans; int sa,c,d,sab;
    for (int i = 0; i < n-1; i++) {
        A = A + a.at(i);
        B = goukei - A;
        sa.at(i) = B - A;
    }
    sort(sa.begin(), sa.end());
    cout << sa.at(0) << endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:36: error: conflicting declaration 'int sa'
   17 |     int A = 0; int B; int ans; int sa,c,d,sab;
      |                                    ^~
a.cc:11:17: note: previous declaration as 'std::vector<int> sa'
   11 |     vector<int> sa(n-1);
      |                 ^~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:16:25: error: 'c' was not declared in this scope
   16 |     else if(sum1>sum/N&&c==0){
      |                         ^
a.cc:22:21: error: expected ';' before '}' token
   22 |         sum2+=v[j+1]
      |                     ^
      |                     ;
   23 |       }
      |       ~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:19:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   19 | int main(){
      |         ^~
a.cc:19:9: note: remove parentheses to default-initialize a variable
   19 | int main(){
      |         ^~
      |         --
a.cc:19:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:19:11: error: a function-definition is not allowed here before '{' token
   19 | int main(){
      |           ^
a.cc:49:5: error: 'else' without a previous 'if'
   49 |     else{
      |     ^~~~
Language: Java

import java.io.*; 
import java.util.Scanner;
import java.lang.Math;

public class Main {
  
	public static void main(String[] args){
      	Scanner in = new Scanner(System.in);
		int N = in.nextInt();
      	int[] weigths = new int[N];
      	for(int i=0;i<N;i++){
        	weigths[i]= in.nextInt();
        }
        
      	System.out.println(balance(weigths, N));
      
      
	}
  	
    public static int balance(int[] weights, int n){
      	int S1 = weigths[0];
      	int S2 = weigths[weigths.length-1];
      	int indexL = 1;
      	int indexR = weigths.length-2;
      	int counter = n-2;
      	while(counter>0){
        	if(S1<S2){
              S1+=weigths[indexL];
              indexL++;
              counter--;
            }else{
              S2+=weigths[indexR];
              indexR--;
              counter--;
            }
        }
      	return Math.abs((S1-S2));
    }
}


Compiler output:
Main.java:21: error: cannot find symbol
      	int S1 = weigths[0];
      	         ^
  symbol:   variable weigths
  location: class Main
Main.java:22: error: cannot find symbol
      	int S2 = weigths[weigths.length-1];
      	         ^
  symbol:   variable weigths
  location: class Main
Main.java:22: error: cannot find symbol
      	int S2 = weigths[weigths.length-1];
      	                 ^
  symbol:   variable weigths
  location: class Main
Main.java:24: error: cannot find symbol
      	int indexR = weigths.length-2;
      	             ^
  symbol:   variable weigths
  location: class Main
Main.java:28: error: cannot find symbol
              S1+=weigths[indexL];
                  ^
  symbol:   variable weigths
  location: class Main
Main.java:32: error: cannot find symbol
              S2+=weigths[indexR];
                  ^
  symbol:   variable weigths
  location: class Main
6 errors
Language: Java

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

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

Compiler output:
Main.java:23: error: variable result might not have been initialized
      for(int i=0; i<result; i++){
                     ^
Main.java:24: error: variable mae2 might not have been initialized
        mae2 += w[i];
        ^
Main.java:27: error: variable ato2 might not have been initialized
        ato2 += w[i+result];
        ^
Main.java:31: error: variable mae2 might not have been initialized
      System.out.println(mae2-ato2);
                         ^
Main.java:31: error: variable ato2 might not have been initialized
      System.out.println(mae2-ato2);
                              ^
Main.java:40: error: variable mae might not have been initialized
      mae += w[i];
      ^
Main.java:43: error: variable ato might not have been initialized
      ato += w[i+t];
      ^
Main.java:45: error: variable mae might not have been initialized
    return mae>ato;
           ^
Main.java:45: error: variable ato might not have been initialized
    return mae>ato;
               ^
9 errors
Language: C

int main(void){
    int N, W[105], i, S, s, m;
    scanf("%d", &N);
    S=0; s=0;
    for (i=1; i<=N; i++) {
        scanf("%d", &W[i]);
        S+=W[i];
    }
    m=S;
    for (i=1; i<=N; i++) {
        s+=W[i];
        if (f(S-s, s)<m) m=f(S-s, s);
    }
    printf("%d", m);
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:3:5: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    3 |     scanf("%d", &N);
      |     ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | int main(void){
main.c:3:5: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    3 |     scanf("%d", &N);
      |     ^~~~~
main.c:3:5: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:12:13: error: implicit declaration of function 'f' [-Wimplicit-function-declaration]
   12 |         if (f(S-s, s)<m) m=f(S-s, s);
      |             ^
main.c:14:5: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   14 |     printf("%d", m);
      |     ^~~~~~
main.c:14:5: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:14:5: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:14:5: note: include '<stdio.h>' or provide a declaration of 'printf'
Language: Java

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

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

Compiler output:
Main.java:17: error: cannot find symbol
        if(!(nibun(all,i,w))){resurt=i;}
                              ^
  symbol:   variable resurt
  location: class Main
1 error