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

import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }
        long sum = 0;
        for(int i = 0; i < n; i++){
            sum = sum + a[i];
        }
        long subsum = 0;
        long minsum = sum;
        for(int i = 0; i < n; i++){
            subsum = subsum + a[i];
            if(minsum > Math.abs((sum-subsum)-subsum)){
                minsum = sum - subsum;
            }
        }
        System.out.print(minsum);
    }
}

Compiler output:
Main.java:7: error: incompatible types: int[] cannot be converted to long[]
        long[] a = new int[n];
                   ^
1 error
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:5:32: error: 'n' was not declared in this scope
    5 |         cin >> N;vector<int> a(n);
      |                                ^
Language: Java

import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long[] bar = new int[N];
    long sum = 0;
    for(int i=0; i<N; i++){
      bar[i] = sc.nextLong();
      sum += bar[i];
    }
    long ans = sum;
    long temp = 0;
    for(int i=0; i<N-1; i++){
      temp += bar[i];
      ans = Math.min(ans, Math.abs(sum - temp - temp));
    }
    System.out.print(ans);
  }
}


Compiler output:
Main.java:6: error: incompatible types: int[] cannot be converted to long[]
    long[] bar = new int[N];
                 ^
1 error
Language: Java

import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] bar = new int[N];
    int sum = 0;
    for(int i=0; i<N; i++){
      bar[i] = sc.nextInt();
      sum += bar[i];
    }
    int ans = Integer.MAX_VALUE;
    int temp = 0;
    for(int i=0; i<N-1; i++){
      int temp += bar[i];
      ans = Math.min(ans, Math.abs(sum - temp - temp));
    }
    System.out.print(ans);
  }
}

Compiler output:
Main.java:15: error: ';' expected
      int temp += bar[i];
              ^
Main.java:15: error: not a statement
      int temp += bar[i];
                     ^
2 errors
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int m,N;cin>>N;
  vector<long long int>A(N);
  cin>>A.at(0);
  for(int i=1;i<N;i++){
    cin>>m;A.at(i)=A.at(i-1)+m;
  }
  m=fabs(A.at(N-1)-2*A.at(0));
  for(int i=1;i<N;i++){
    long long int f=A.at(i-1),x=A.at(i)-A.at(i-1),b=A.at(N-1)-A.at(i);
    m=min(m,fabs(fabs(f-b)-x));
  }
  cout<<m<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:10: error: no matching function for call to 'min(long long int&, double)'
   13 |     m=min(m,fabs(fabs(f-b)-x));
      |       ~~~^~~~~~~~~~~~~~~~~~~~~
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:13:10: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'double')
   13 |     m=min(m,fabs(fabs(f-b)-x));
      |       ~~~^~~~~~~~~~~~~~~~~~~~~
/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:13:10: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   13 |     m=min(m,fabs(fabs(f-b)-x));
      |       ~~~^~~~~~~~~~~~~~~~~~~~~
Language: C++

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

int main() {
  int64_t n, a = 0, b = 0, l = 0, r, s = 0, tmp1 = 0, tmp2, d = 0;
  cin >> n;
  vector<int64_t> v(n);
  rep(i, n){
    cin >> v[i];
    s += v[i];
  }
  rep(i, n){
    tmp1 += v[i];
    if(tmp1 > s / 2){
      tmp2 = tmp1;
      tmp1 -= v[i];
      r = i;
      break;
    }
  }
  rep(i, n){
    if(i < r) a += v[i]-1;
    else b += v[i]-1;
  }
  d = min(abs(tmp1 - (s - tmp1), abs(tmp2 - (s - tmp2));
  cout << d << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:56: error: expected ')' before ';' token
   27 |   d = min(abs(tmp1 - (s - tmp1), abs(tmp2 - (s - tmp2));
      |              ~                                         ^
      |                                                        )
Language: C++

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

using namespace std;

int main() {
    int N;
    cin >> N;
    int A[N];
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }
    int left = 0;
    int right = sum;
    int left_margin = 0;
    int min_diff = INT_MAX;
    for (int i = 0; i < N; i++) {
        left += A[i];
        right -= A[i];
        int diff = abs(left - right);
        if (diff < min_diff) {
            min_diff = diff;
        }
    }
    cout << min_diff << "\n";

    return 0;
}


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

/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 100000000000000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  vector<ll> v(n);
  rep(i,n) cin>>v[i];
  ll ans=MOD,tmp=Svec(v);
  vector<ll> sum(n);
  sum[0]=v[0];
  rep(i,n-1){
    sum[i+1]=sum[i]+v[i+1];
  }
  rep(i,n){
    ans=min(ans,(ll)abs(s-2*sum[i]));
  }
  cout<<ans<<endl;
}


Compiler output:
a.cc:6:17: warning: integer constant is too large for its type
    6 | const int MOD = 100000000000000000007;
      |                 ^~~~~~~~~~~~~~~~~~~~~
a.cc:6:17: warning: overflow in conversion from 'long int' to 'int' changes value from '7766279631452241927' to '1661992967' [-Woverflow]
a.cc: In function 'int main()':
a.cc:137:25: error: 's' was not declared in this scope
  137 |     ans=min(ans,(ll)abs(s-2*sum[i]));
      |                         ^
Language: C++

/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 100000000000000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  vector<ll> v(n);
  rep(i,n) cin>>v[i];
  ll ans=MOD,tmp=v[0],tmp=Svec(v);
  vector<ll> sum(n);
  sum[0]=v[0];
  rep(i,n-1){
    sum[i+1]=sum[i]+v[i+1];
  }
  rep(i,n){
    ans=min(ans,(ll)abs(tmp-2*sum[i]));
  }
  cout<<ans<<endl;
}


Compiler output:
a.cc:6:17: warning: integer constant is too large for its type
    6 | const int MOD = 100000000000000000007;
      |                 ^~~~~~~~~~~~~~~~~~~~~
a.cc:6:17: warning: overflow in conversion from 'long int' to 'int' changes value from '7766279631452241927' to '1661992967' [-Woverflow]
a.cc: In function 'int main()':
a.cc:130:23: error: redeclaration of 'll tmp'
  130 |   ll ans=MOD,tmp=v[0],tmp=Svec(v);
      |                       ^~~
a.cc:130:14: note: 'll tmp' previously declared here
  130 |   ll ans=MOD,tmp=v[0],tmp=Svec(v);
      |              ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main (){
  int n;
  cin>>n;
  vector<int> v(n);
  int i,r=0;
  for(i=0;i<n;i++){
    cin>>v[i];
    k+=v[i];
  }
  int m =10000,l=0;
  for(i=0;i<n;i++){
    l+=v[i];
    k-=v[i];
    m = min(abs(k-l),m);
  }
  cout<<m;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:5: error: 'k' was not declared in this scope
   10 |     k+=v[i];
      |     ^
a.cc:15:5: error: 'k' was not declared in this scope
   15 |     k-=v[i];
      |     ^
Language: C++

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

int main(){
  int N;
  cin >> N;
  vector<long int> A(N);
  long long int sum=0;
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    sum+=A.at(i);
  } 
  vector<int> B(N-1);
  long longint tmp=0;
  long long int min =sum;
  for(int i=0;i<N-1;i++){
    tmp+=A.at(i);
    long long int c=sum-tmp;
    B.at(i)=c-tmp;
    if(B.at(i)<0){
      B.at(i)*=-1;
    }
    if(B.at(i)==0){
      cout << 0 << endl;
      return 0;
    }
    if(B.at(i)<=min){
      min=B.at(i);
    }
    
  }
  cout << min << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:16: error: expected initializer before 'tmp'
   14 |   long longint tmp=0;
      |                ^~~
a.cc:17:5: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   17 |     tmp+=A.at(i);
      |     ^~~
      |     tm
Language: C++

#include <bits/stdc++.h>
using namespace std;
using Int = long long;
using Double = long double;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define ALL(v) (v).begin(), (v).end()
#define PUTS(x) cout << (x) << endl;
int main() {
    int n;
    cin >> n;
    auto v = vector<Double>(0);
    v.PB(0);
    Double sum = 0;
    rep(i, n) {
        Double a;
        cin >> a;
        sum += a;
        v.PB(sum);
    }
    auto half = sum / 2;
    auto itr = lower_bound(ALL(v), half);
    auto b = *itr;
    itr--;
    auto a = *itr;
    auto x = (Int)((b - half > half - a) ? a : sum - b);
    auto y = (Int)(sum - x);
    PUTS(abs(x - y));
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:7: error: 'class std::vector<long double>' has no member named 'PB'
   12 |     v.PB(0);
      |       ^~
a.cc:18:11: error: 'class std::vector<long double>' has no member named 'PB'
   18 |         v.PB(sum);
      |           ^~
Language: C++

#include <iostream>
#include <vector>

int main()
{
	int n = 0;
	std::cin >> n;

	std::vector<int> list;
	unsigned long long input = 0;
	for (int i = 0; i < n; ++i) {
		std::cin >> input;
		list.push_back(input);
	}
	int li = 0, ri = n-1;
	unsigned long long lt = 0, rt = 0;
	while (li <= ri) {
		if (lt <= rt) {
			lt += list[li++];
		}
		else {
			rt += list[ri--];
		}
	}
	unsigned long long sa = (rt >= lt) ? rt - lt : lt - rt;
	std::cout << sa;
	return 0;

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

#include<stdio.h>
#include<math.h>
int main() {
    int n, a[],s1=0,s2=0,st1=0,st2=0,c=0;
    scanf("%d",&n);
    for(i=0;i<n;i++) {
        scanf("%d", a[i]);
        if(i<n/2) {
            s1+=a[i];
        }
        else {
            s2+=a[i];
        }
    }
    if(n%2!=0) {
        st1=s1+a[n/2];
        st2=s2-a[n/2];
        if(abs(st2-st1)<abs(s2-s1)) {
            s1=st1;
            s2=st2;
        }
    }
    while(s1!=s2) {
        c++;
        if(s1>s2) {
            s2++;
        }
        else
        {
            s1++;
        }
    }
    printf("%d",c);

}

Compiler output:
main.c: In function 'main':
main.c:4:12: error: array size missing in 'a'
    4 |     int n, a[],s1=0,s2=0,st1=0,st2=0,c=0;
      |            ^
main.c:6:9: error: 'i' undeclared (first use in this function)
    6 |     for(i=0;i<n;i++) {
      |         ^
main.c:6:9: note: each undeclared identifier is reported only once for each function it appears in
main.c:18:12: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   18 |         if(abs(st2-st1)<abs(s2-s1)) {
      |            ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    2 | #include<math.h>
  +++ |+#include <stdlib.h>
    3 | int main() {
Language: C++

#include <stdio.h>
#include<bits/stdc++.h>
#define ll long long int
int main()
{
    ll n, i, j, se, ss;
    cin>>n;
    ll ch[n];
    
    for(i=0;i<n;i++)
    cin>>ch[i];
    
    i=0;
    j=n-1;
    se=ch[j];
    ss=ch[i];
    
    while(j-i!=1)
    {
        if(ss<se)
        {i++;
        ss=ss+ch[i];
        
        }
        else
        {
        j--;
        se=se+ch[j];
        }
    }
    cout<<abs(ss-se);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    7 |     cin>>n;
      |     ^~~
      |     std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:2:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:31:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   31 |     cout<<abs(ss-se);
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C++

#include <stdio.h>
#include<bits/stdc++.h>
#define ll long long int
int main()
{
    ll n, i, j, se, ss;
    scanf("%d",&n);
    ll ch[n];
    
    for(i=0;i<n;i++)
    scanf("%d",&ch[i]);
    
    i=0;
    j=n-1;
    se=ch[j];
    ss=ch[i];
    
    while(j-i!=1)
    {
        if(ss<se)
        {i++;
        ss=ss+ch[i];
        
        }
        else
        {
        j--;
        se=se+ch[j];
        }
    }
    cout<<abs(ss-se);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   31 |     cout<<abs(ss-se);
      |     ^~~~
      |     std::cout
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:2:
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C++

#include <stdio.h>
#include<stdlib.h>
#define ll long long int
int main()
{
    ll n, i, j, se, ss;
    scanf("%d",&n);
    ll ch[n];
    
    for(i=0;i<n;i++)
    scanf("%d",&ch[i]);
    
    i=0;
    j=n-1;
    se=ch[j];
    ss=ch[i];
    
    while(j-i!=1)
    {
        if(ss<se)
        {i++;
        ss=ss+ch[i];
        
        }
        else
        {
        j--;
        se=se+ch[j];
        }
    }
    cout<<abs(ss-se);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:5: error: 'cout' was not declared in this scope
   31 |     cout<<abs(ss-se);
      |     ^~~~
Language: C

#include<stdio.h>
int main()
{
int n,a[1000],i,j,s=0,t=0;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
s+=a[i];
}
for(i=0;i<n;i++)
{
t+=a[i];
if((t<(s/2)&&(t+a[i+1]>=s/2))
{
j=i+1;
goto x;}
}
x:
printf("%d",((t+a[j+1])-(s/2)));
return 0;
}


Compiler output:
main.c: In function 'main':
main.c:17:30: error: expected ')' before '{' token
   17 | if((t<(s/2)&&(t+a[i+1]>=s/2))
      |   ~                          ^
      |                              )
   18 | {
      | ~                             
main.c:21:1: error: expected expression before '}' token
   21 | }
      | ^
Language: C++

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

int main() {
	int N = 0;
	
	std::cin >> N;
	
	std::vector<long long> A(N, 0);

	for (int i = 0; i < A.size(); i++) {
		std::cin >> A[i];
	}

	long long sum = std::accumulate(A.begin(), A.end(), 0);

	int ii = -1;
	long long val = 0;
	long long bval = 0;

	while (val < sum / 2) {
		ii++;
		bval = val;
		val += A[ii];
	}

	
	if (val == sum / 2 && sum % 2 == 0) {
		std::cout << 0 << std::endl;
	}
	else if (val == sum / 2 && sum % 2 == 1) {
		std::cout << 1 << std::endl;
	}
	else if (ii == 0) {
		long long ans = 2 * A[ii] - sum;
		std::cout << ans << std::endl;
	}
	else if (ii == N - 1) {
		long long ans = 2 * A[ii] - sum;
		std::cout << ans << std::endl;
	}
	else {
		long long ans = std::min(2 * val - sum, sum - 2 * bval);

		long long half = sum / 2;
		long long amr = sum % 2;
		long long vlt = half - bval;
		long long vgt = val - half - amr;
		long long jdg = std::min(vlt, vgt);
		long long ans = 2 * jdg + amr;

		std::cout << ans << std::endl;
	}
	

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:53:27: error: redeclaration of 'long long int ans'
   53 |                 long long ans = 2 * jdg + amr;
      |                           ^~~
a.cc:46:27: note: 'long long int ans' previously declared here
   46 |                 long long ans = std::min(2 * val - sum, sum - 2 * bval);
      |                           ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int abc(long long X){
return X>=0?X:-X;
}
int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  long long sum=0,sum2=0;
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    sum+=A.at(i);
  }
  long long ans=sum;
  for(int i=0;i<N;i++){
    sum2+=A.at(i);
     ans=min(ans, abc(sum-sum2*2));
  }
  cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:13: error: no matching function for call to 'min(long long int&, int)'
   18 |      ans=min(ans, abc(sum-sum2*2));
      |          ~~~^~~~~~~~~~~~~~~~~~~~~~
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:13: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   18 |      ans=min(ans, abc(sum-sum2*2));
      |          ~~~^~~~~~~~~~~~~~~~~~~~~~
/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:13: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   18 |      ans=min(ans, abc(sum-sum2*2));
      |          ~~~^~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
int abc(int X){
return X>=0?X:-X;
}
int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  int sum=0,sum2=0;
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    sum+=A.at(i);
  }
  int ans=sum;
  for(int i=0;i<N;i++){
    sum2+=A.at(i);
     ans=min(ans, abc(sum-sum2*2));
  }
  cout<<ans<<endl;
}


Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include<bits/stdc++.h>
using namespace std;
int abc(int X){
return X>=0?X:-X;
}
int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  long long sum=0,sum2=0;
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    sum+=A.at(i);
  }
  long long ans=sum;
  for(int i=0;i<N;i++){
    sum2+=A.at(i);
     ans=min(ans, abc(sum-sum2*2));
  }
  cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:13: error: no matching function for call to 'min(long long int&, int)'
   18 |      ans=min(ans, abc(sum-sum2*2));
      |          ~~~^~~~~~~~~~~~~~~~~~~~~~
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:13: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   18 |      ans=min(ans, abc(sum-sum2*2));
      |          ~~~^~~~~~~~~~~~~~~~~~~~~~
/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:13: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   18 |      ans=min(ans, abc(sum-sum2*2));
      |          ~~~^~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int abc(int X){
return X>=0?X:-X;
}
int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  long long sum=0,sum2=0;
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    sum+=A.at(i);
  }
  long long ans=sum;
  for(int i=0;i<N;i++){
    sum2+=A.at(i)
     ans=min(ans, abc(sum-sum2*2));
  }
  cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:18: error: expected ';' before 'ans'
   17 |     sum2+=A.at(i)
      |                  ^
      |                  ;
   18 |      ans=min(ans, abc(sum-sum2*2));
      |      ~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int abc(int X){
return X>=0?X:-X;
}
int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  long long sum=0.sum2=0;
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    sum+=A.at(i);
  }
  long long ans=sum;
  for(int i=0;i<N;i++){
    sum2+=A.at(i)
     ans=min(ans, abc(sum-sum2*2));
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:17: error: unable to find numeric literal operator 'operator""sum2'
   10 |   long long sum=0.sum2=0;
      |                 ^~~~~~
a.cc:17:5: error: 'sum2' was not declared in this scope; did you mean 'sum'?
   17 |     sum2+=A.at(i)
      |     ^~~~
      |     sum
Language: C

#include<stdio.h>
#include<math.h>
int main()
{
	int i,j,c,N=,sum=0,money=0;
	int sum1=0,sum2=0;
	int a[N];
	int b[N];
	scanf("%d",&N);
	for ( i=0; i<N; i++ )
	{
		scanf("%d",&a[i]);
	}
	for ( i=0; i<N; i++ )
	{
		sum += a[i];
	}
	for ( i=0; i<N; i++ )
	{
		sum1 += a[i];
		sum2 = sum - sum1;
		for ( j=i; j<i+1; j++ )
		{
			b[j] = abs(sum1-sum2);
		}
	for ( c=0; c<N; c++ )
	{
		if (b[c] <= b[c+1])
		{
			b[c+1] = b[c];
			money = b[c];
		}
	}
}
	printf("money = %d",money);
	return 0;
} 

Compiler output:
main.c: In function 'main':
main.c:5:21: error: expected expression before ',' token
    5 |         int i,j,c,N=,sum=0,money=0;
      |                     ^
main.c:24:32: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   24 |                         b[j] = abs(sum1-sum2);
      |                                ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    2 | #include<math.h>
  +++ |+#include <stdlib.h>
    3 | int main()
Language: C

#include<stdio.h>
#include<math.h>
int main()
{
	int i,j,c,N,sum=0,money=0;
	int sum1=0,sum2=0;
	int a[N];
	int b[N];
	scanf("%d",&N);
	for ( i=0; i<N; i++ )
	{
		scanf("%d",&a[i]);
	}
	for ( i=0; i<N; i++ )
	{
		sum += a[i];
	}
	for ( i=0; i<N; i++ )
	{
		sum1 += a[i];
		sum2 = sum - sum1;
		for ( j=i; j<i+1; j++ )
		{
			b[j] = abs(sum1-sum2);
			printf("%d\t",b[j]);
		}
	money = b[0];
	for ( c=0; c<N; c++ )
	{
		if (b[c] <= b[c+1])
		{
			b[c+1] = b[c];
			money = b[c];
		}
	printf("money = %d",money);
	return 0;
 } 

Compiler output:
main.c: In function 'main':
main.c:24:32: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   24 |                         b[j] = abs(sum1-sum2);
      |                                ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    2 | #include<math.h>
  +++ |+#include <stdlib.h>
    3 | int main()
main.c:37:2: error: expected declaration or statement at end of input
   37 |  }
      |  ^
main.c:37:2: error: expected declaration or statement at end of input
Language: C++


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

#define prtd(d) printf("%d\n", d)
#define prts(s) printf("%s\n", s.c_str())
#define cout(s) cout << s << endl
#define rep(i,n) for(long long (i)=0;(i)<(n);(i)++)

#define SIZE(array) sizeof(array)/sizeof(*array)

long long combi(long long n, long long k);
long long same_L(long long *A, size_t SIZE);
long long check_same(long long sum, long long *A);
void small(long long *A, long long i);
void big(long long *A, long long i);

long long cost = 0;

long long main(void) {

	long long N;
	cin >> N;

	
    long long A[N];
	long long L=0;
	for(long long i=0; i<N; i++){
		scanf("%d", &A[i]);
		L+=A[i];
		//cout << A[i] << endl;
	}
    long long min_cost = L, sum = 0; //sum 前半部分の和
    for(long long i = 0; i<SIZE(A); i++){
		sum+=A[i];
        long long sum_latter = L - sum;
        min_cost = min(min_cost, abs(sum - (sum_latter))); 
    }
    printf("%d\n", min_cost);
    /*

	
	//cout <<"size(in main):" << SIZE(A) << endl;

	long long loc = same_L(A, SIZE(A));
	//printf("loc=%d", loc);
	long long cost_max = 999;
	if(loc != -1){
		prtd(0);
		return 0;
	}else{
		long long sum=0;
		for(long long i = 0; i<SIZE(A); i++){
			sum+=A[i];
			//printf("sum(0~%d)=%d \n", i, sum);
			long long after = 0;
			
			//for(long long j=i+1; j<SIZE(A);j++){
			//	after += A[j];
			//}
			after = L -sum;
			//printf("sum_after(%d~%d)=%d \n\n", i+1, N,after);
			long long cost = abs(sum - after);
			//printf("(sum, after, cost) = (%d, %d, %d)\n", sum, after, cost);
			if((cost_max == -999)|| (cost < cost_max)) cost_max = cost;
		}
	}*/

	//prtd(cost_max);




    return 0;
}



long long same_L(long long *A, size_t size){
	//cout << "--------in same_L---------" << endl;
	long long sum=0;
	//size_t size =  SIZE(A);
	//printf("(size, sum)=(%d, %d)\n",size, sum);
	//cout <<"size(in same_L):" << size << endl;
	
	for(long long i=0; i<size-1; i++){
		sum+=A[i];
		//printf("(i,sum)=(%d,%d)\n",i,sum);
		long long sum_after = 0;
		for(long long j=i+1; j<size;j++){
			sum_after += A[j];
		}
		//printf("(sum, sum_after) = (%d, %d)\n", sum, sum_after);
		if(sum == sum_after) return i; //i番目で2等分できる

	}
	return -1; //分割不可能

	cout << "--------in same_L---------" << endl;
}

void small(long long *A, long long i){
	if(A[i] >= 2) A[i]--;
	else printf("ERROR in small");

	cost++;
}

void big(long long *A, long long i){
	A[i] += 1;
	cost++;
}


//nCkの計算関数
long long combi(long long n, long long k){
	if(n == k || k == 0){
		return 1;
	}
	else{
		return combi(n-1, k-1) + combi(n-1, k);
	}
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <stdio.h>
#include <stdlib.h>
lonng long a[2000100];
int main()
{
	long long n,c=0,c1=0;
	scanf("%lld",&n);
	for(long long i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		c+=a[i];
	}
	long long mn=c;
	for(long long i=1;i<=n;i++)
	{
		c1=c1+a[i];
		if(abs(c1-(c-c1))<=mn)
		{
			mn=abs(c1-(c-c1));
		}
	}
	printf("%lld",mn);
	return 0;
}


Compiler output:
a.cc:3:1: error: 'lonng' does not name a type; did you mean 'long'?
    3 | lonng long a[2000100];
      | ^~~~~
      | long
a.cc: In function 'int main()':
a.cc:10:31: error: 'a' was not declared in this scope
   10 |                 scanf("%lld",&a[i]);
      |                               ^
a.cc:16:23: error: 'a' was not declared in this scope
   16 |                 c1=c1+a[i];
      |                       ^
Language: C++

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

int main()
{
  int n;
  vector<int> arr(n);
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  vector<int> cum(n,0);
  cum[0] = arr[0];
  for(int i=1;i<n;i++)
  {
    cum[i] = cum[i-1] + arr[i];
  }
  int tot = cum[n-1];
  tot /= 2;
  auto it = lower_bound(cum.begin(),cum.end(),tot);
  int in = it - cum.begin();
  int sum = 0;
  for(int i=in+1;i<n;i++)
    sum += arr[i];
  int ans = abs(in - sum);
  cout<<ans;
  return 0;

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

import java.utill.Scanner;

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

Compiler output:
Main.java:1: error: package java.utill does not exist
import java.utill.Scanner;
                 ^
Main.java:5: error: cannot find symbol
    Scanner sc=new Scanner(System.in);
    ^
  symbol:   class Scanner
  location: class Main
Main.java:5: error: cannot find symbol
    Scanner sc=new Scanner(System.in);
                   ^
  symbol:   class Scanner
  location: class Main
3 errors
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define MOD 1000000007



void solve()
{
  int N;
  cin>>N;
  vector<int> vec(N,0);
  vector<int> vec_A(N,0);
  int ACC_A=0;
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];
    ACC_A += vec[i];
    vec_A[i] = ACC_A;
  }
 
  int acc = accumulate(vec.begin(),vec.end(),0);
 
  int half = acc/2;

  int sum = 0;
  int sum2 = 0;
  int half_p;
  int MIN = I64_MAX;
  
  for (int i = 0; i < N; i++)
  {
    MIN = min(MIN,abs(acc - 2*vec_A[i]));
    MIN = min(MIN,abs(acc - 2*vec_A[i] - 2*vec[i]))
  }

  cout<<MIN;
 
  // cout<<half_p<<endl;
}
int32_t main(int32_t argc, const char *argv[])
{
 
  solve();
 
  return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:55:52: error: expected ';' before '}' token
   55 |     MIN = min(MIN,abs(acc - 2*vec_A[i] - 2*vec[i]))
      |                                                    ^
      |                                                    ;
   56 |   }
      |   ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(void){
  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 h,x;
  for(int i=0; i < n; i++){
    x+=a[i];
    if(sum/2 <= x){
      h = i;
      break;
    }
  }
  int ans;
  if((x-sum/2) >= (sum/2-x+a[h])){
    ans = sum/2-x+a[h];
  }
  else if((x-sum/2) < (sum/2-x+a[h])){
    ans = x - sum/2
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:20: error: expected ';' before '}' token
   25 |     ans = x - sum/2
      |                    ^
      |                    ;
   26 |   }
      |   ~
Language: C++

#include <iostream>
#include <vector>
#include <math.h>
#include <numeric>
using namespace std;

int main(){
    double N = 0;
    cin >> N;
    int half = (int)round(N/2);
    // cout << "half: " << half << endl;

    vector<int> length(N);
    int l, i = 0;
    for (int i = 0; i < N; ++i ){
        cin >> length.at(i);
    }

    // 合計値の初期化 
    int sum = accumulate(length.begin(), length.end(), 0);
    int lSum = 0;
    int rSum = 0;
    vector<int> result;
    
    // 払う金額の計算 
    for (int i = 0; i < N; ++i ){
        lSum = accumulate(length.begin(),length.end()-i, 0);
        rSum = sum - lSum;
        result.push_back(abs(lSum - rSum));
    }

    int min = *min_element(result.begin(), result.end());
    cout << min << endl;

    // return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:16: error: 'min_element' was not declared in this scope
   32 |     int min = *min_element(result.begin(), result.end());
      |                ^~~~~~~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <math.h>
#include <numeric>
using namespace std;

int main(){
    double N = 0;
    cin >> N;
    int half = (int)round(N/2);
    // cout << "half: " << half << endl;

    vector<int> length(N);
    int l, i = 0;
    for (int i = 0; i < N; ++i ){
        cin >> length.at(i);
    }

    // 合計値の初期化 
    int sum = accumulate(length.begin(), length.end(), 0);
    int lSum = 0;
    int rSum = 0;
    vector<int> result;
    
    // 払う金額の計算 
    for (int i = 0; i < N; ++i ){
        lSum = accumulate(length.begin(),length.end()-i, 0);
        rSum = sum - lSum;
        result.push_back(abs(lSum - rSum));
    }

    int min = *std::min_element(result.begin(), result.end());
    cout << min << endl;

    // return 0;
}

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

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

int main() {
  int N;
  cin >> N;
  long long int sum = 0;
  vector<long long int> a(N);
  vector<long long int> s(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
    sum += a.at(i);
    s.at(i) = sum;
  }
  long long int hsum;
  if (sum % 2== 0) {
    hsum = sum / 2;
  }
  else {
    hsum = sum / 2 + 1;
  }
  for (int i = 0; i < N; i++) {
    if (hsum <= s.at(i)) {
      if (sum % 2 == 0 && hsum == s.at(i)) {
        cout << 0 << endl;
        break;
      }
      else if (i == 0) {
         long long int u = sum - s.at(i);
        printf("%lld\n", s.at(i) - u);
        break;
      else {
        long long int u = sum - s.at(i);
        long long int uu = s.at(i) - u;
        long long int l = sum - s.at(i-1);
        long long int ll = l - s.at(i-1);
        printf("%lld\n", min(uu, ll));
        break;
      }
    }
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:7: error: expected '}' before 'else'
   32 |       else {
      |       ^~~~
a.cc:28:24: note: to match this '{'
   28 |       else if (i == 0) {
      |                        ^
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl;

typedef long long ll;
const ll INF = 99999999999999;
const ll MOD = 1000000007;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll number1, ll number2)
{
    return number1 * number2 / gcd(number1, number2);
}
template <class T>
bool contain(const std::string &s, const T &v)
{
    // contain(to_string(N), '3')
    return s.find(v) != std::string::npos;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
        return c - '0';
    return 0;
}
using namespace std;

void transpose(vector<vector<char>> &b)
{
    if (b.size() == 0)
        return;

    vector<vector<char>> trans_vec(b[0].size(), vector<char>());

    for (int i = 0; i < b.size(); i++)
    {
        for (int j = 0; j < b[i].size(); j++)
        {
            trans_vec[j].push_back(b[i][j]);
        }
    }

    b = trans_vec; // <--- reassign here
}
int main()
{

    ll wa = 0, target, n, sa = INF;

    cin >> n;
    vector<ll> a(n);
    ll target = 0;
    rep(i, n)
    {
        cin >> a[i];
        target += a[i];
    }
    rep(i, n)
    {
        wa += a[i];
        sa = min(sa, abs(wa * 2 - target));
    }

    cout << sa << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:59:8: error: redeclaration of 'll target'
   59 |     ll target = 0;
      |        ^~~~~~
a.cc:55:16: note: 'll target' previously declared here
   55 |     ll wa = 0, target, n, sa = INF;
      |                ^~~~~~
Language: C++

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

int main(){
  int N;
  long long sum=0;
  cin >> N;
  vector<long long> A(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
    sum += A[i];
  }
  long long half=sum/2;
  long long ss=0,m=sum;
  int index=0;
  for(int i=0;i<N;i++){
    m=min(m,abs(s-2*ss));
    ss += A[i];
  }
  cout << m << endl;
}






Compiler output:
a.cc: In function 'int main()':
a.cc:17:17: error: 's' was not declared in this scope
   17 |     m=min(m,abs(s-2*ss));
      |                 ^
Language: C

#include<stdio.h>

int main(void){
    int i,j;
    long long int sum;
    long long int a = 0;
    long long int b = 0;

    long long int n;
    scanf("%lld",n);

    long long int t[n];
    for(i=0;i<n;i++){
        scanf("%lld",&t[i]);
        sum = sum + t[i]
    }

    for(j=0;a>sum/2;j++){
        a = a + t[j]
    }

    for(j=n;b<sum/2;j--){
        b = b + t[j]
    }

    if(a*2-sum < sum-b*2){
        printf("%lld",sum-a*2);
    }

    else if(a*2-sum > sum-b*2){
        printf("%lld",sum-b*2);
    }

    else{
        printf("0");
    }

    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:15:25: error: expected ';' before '}' token
   15 |         sum = sum + t[i]
      |                         ^
      |                         ;
   16 |     }
      |     ~                    
main.c:19:21: error: expected ';' before '}' token
   19 |         a = a + t[j]
      |                     ^
      |                     ;
   20 |     }
      |     ~                
main.c:23:21: error: expected ';' before '}' token
   23 |         b = b + t[j]
      |                     ^
      |                     ;
   24 |     }
      |     ~
Language: Java

import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    long[] a=new long[n];
    double sum=0.0;
    for(int i=0;i<n;i++){
      a[i]=sc.nextLong();
      sum+=a[i];
    }
    long x=0;
    long y=0;
    for(int i=0;i<n;i++){
      y+=a[i];
      if(y>sum/2.0){
        x=y-a[i];
        break;
      }else if(y==sum/2.0){
        System.out.println(0);
        System.exit(0);
      }
    }
    if((sum/2.0-x)==(y-sum/2.0)){
      System.out.println(sum/2.0-x);
    }else if((sum/2.0-x)<(y-sum/2.0)){
      for(int i=1;i<n;i++){
        x++;
        sum++;
        if(x=sum/2.0){
          System.out.println(i);
          break;
        }
      }
    }else{
      for(int i=1;i<n;i++){
        y--;
        sum--;
        if(y=sum/2.0){
          System.out.println(i);
          break;
        }
      }
    }
  }
}

Compiler output:
Main.java:31: error: incompatible types: possible lossy conversion from double to long
        if(x=sum/2.0){
                ^
Main.java:31: error: incompatible types: long cannot be converted to boolean
        if(x=sum/2.0){
            ^
Main.java:40: error: incompatible types: possible lossy conversion from double to long
        if(y=sum/2.0){
                ^
Main.java:40: error: incompatible types: long cannot be converted to boolean
        if(y=sum/2.0){
            ^
4 errors
Language: C++

#include<stdio.h>
#include<stdlib.h>
int main(void){
  int n,l;
  int s=0;
  scanf("%d\n",&n);
  int a[n];
  scanf("%d",&a);
  
  for(int i=0;i<(n-1);i++){
    s=0;
    for(int j=i+1;j<n;j++){
      s=s+a[j];
    }
    l=abs(a[i]-s);
    if(i==0){
      min=0;
    }
    if((l<min)&&(i!=0)){
      min=l;
    }
  }
  printf("%d\n",min);
  
  
  
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:17:7: error: 'min' was not declared in this scope; did you mean 'main'?
   17 |       min=0;
      |       ^~~
      |       main
a.cc:19:11: error: 'min' was not declared in this scope; did you mean 'main'?
   19 |     if((l<min)&&(i!=0)){
      |           ^~~
      |           main
a.cc:23:17: error: 'min' was not declared in this scope; did you mean 'main'?
   23 |   printf("%d\n",min);
      |                 ^~~
      |                 main
Language: C++

#include<stdio.h>
int main(void){
  int n,l;
  int s=0;
  scanf("%d\n",&n);
  int a[n];
  scanf("%d",&a);
  
  for(int i=0;i<(n-1);i++){
    s=0;
    for(int j=i+1;j<n;j++){
      s=s+a[j];
    }
    l=abs(a[i]-s);
    if(i==0){
      min=0;
    }
    if((l<min)&&(i!=0)){
      min=l;
    }
  }
  printf("%d\n",min);
  
  
  
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:14:7: error: 'abs' was not declared in this scope
   14 |     l=abs(a[i]-s);
      |       ^~~
a.cc:16:7: error: 'min' was not declared in this scope; did you mean 'main'?
   16 |       min=0;
      |       ^~~
      |       main
a.cc:18:11: error: 'min' was not declared in this scope; did you mean 'main'?
   18 |     if((l<min)&&(i!=0)){
      |           ^~~
      |           main
a.cc:22:17: error: 'min' was not declared in this scope; did you mean 'main'?
   22 |   printf("%d\n",min);
      |                 ^~~
      |                 main
Language: C++

#include <stdio.h>
#include <stdlib.h>
 
int main(){
 long long n,num[200001];
 long long s=0;
 long long f=0;
 long long mm=10000;
 scanf("%d", &n);
 scanf("%d %d %d %d %d %d %d %d %d %d %d %d %d", for(int i=1;i<=n;i++)&num[i]);
 
 for(int i=1;i<=n;++i){
     s=s+num[i];
     for(int j=i+1;j<=n;j++){
         f=f+num[j];
     }
   if(mm>abs(s-f)){
     mm = abs(s-f);
   }
 }
 printf("%d",mm);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:50: error: expected primary-expression before 'for'
   10 |  scanf("%d %d %d %d %d %d %d %d %d %d %d %d %d", for(int i=1;i<=n;i++)&num[i]);
      |                                                  ^~~
a.cc:10:62: error: 'i' was not declared in this scope
   10 |  scanf("%d %d %d %d %d %d %d %d %d %d %d %d %d", for(int i=1;i<=n;i++)&num[i]);
      |                                                              ^