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

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

int main(){
    int n;
    cin >> n;
    vector<long long> a(n);
    long long cnt = 0;
    for (int i = 0;i < n;i++){
        cin >> a[i];
        cnt += a[i];
    }
    long long rep = cnt,ans = cnt,num = 0;
    long long ans_1 = 0,ans_2;
    for (int i = 0;i < n;i++){
        rep -= a[i];
        num += a[i];
        if (ans > abs(rep-num){
            ans = abs(rep-num);
            ans_1 = rep;
            ans_2 = num;
        }
    }

    if (ans_1 == ans_2) cout << 0 << endl;
    else cout << abs(ans_1-ans_2) << endl; 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:31: error: expected ')' before '{' token
   18 |         if (ans > abs(rep-num){
      |            ~                  ^
      |                               )
a.cc:23:5: error: expected primary-expression before '}' token
   23 |     }
      |     ^
Language: C++

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

int main(){
    int n;
    cin >> n;
    vector<long long> a(n);
    long long cnt = 0;
    for (int i = 0;i < n;i++){
        cin >> a[i];
        cnt += a[i];
    }
    long long rep = cnt,ans = cnt,num = 0;
    long long ans_1 = 0,ans_2;
    for (int i = 0;i < n;i++){
        rep -= a[i];
        num += a[i];
        if (ans > abs(rep-num){
            ans = abs(rep-num);
            ans_1 = rep;
            ans_2 = num;
        }
    }

    if (ans_1 == ans_2) cout << 0 << endl;
    else cout << abs(num-rep) << endl; 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:31: error: expected ')' before '{' token
   18 |         if (ans > abs(rep-num){
      |            ~                  ^
      |                               )
a.cc:23:5: error: expected primary-expression before '}' token
   23 |     }
      |     ^
Language: C++

#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
// #include <bits/stdc++.h>
#define ll long long; int
#define req(i,k) for(int i = 0; i < k; i++)
using namespace std;


int main(void) {
    int n;
   cin >> n;
  vector<long long> a(n);
  req(i,n) {
      cin >> a.at(i);
  }
  ll sum = 0;
  ll total = 0;
  ll mi = 1e12;
  ll k;
    for(int j = n - 1; j > 0; j--) {
        sum += a.at(j);
    }
  for(int i = 0; i < n; i++) {
        total += a.at(i);
      if (total == sum) {
          cout << 0;
          return 0;
      } else if (total > sum) {
          k = total - sum;
      } else {
          k = sum - total;
      }
      mi = min(mi, k);
      if(i < n-1) {
          sum -= a.at(i+1);
      }

  }
cout << mi;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:17: error: declaration does not declare anything [-fpermissive]
    7 | #define ll long long; int
      |                 ^~~~
a.cc:19:3: note: in expansion of macro 'll'
   19 |   ll sum = 0;
      |   ^~
a.cc:7:17: error: declaration does not declare anything [-fpermissive]
    7 | #define ll long long; int
      |                 ^~~~
a.cc:20:3: note: in expansion of macro 'll'
   20 |   ll total = 0;
      |   ^~
a.cc:7:17: error: declaration does not declare anything [-fpermissive]
    7 | #define ll long long; int
      |                 ^~~~
a.cc:21:3: note: in expansion of macro 'll'
   21 |   ll mi = 1e12;
      |   ^~
a.cc:21:11: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+12' to '2147483647' [-Woverflow]
   21 |   ll mi = 1e12;
      |           ^~~~
a.cc:7:17: error: declaration does not declare anything [-fpermissive]
    7 | #define ll long long; int
      |                 ^~~~
a.cc:22:3: note: in expansion of macro 'll'
   22 |   ll k;
      |   ^~
Language: C++

using namespace std;
#include<bits/stdc++.h>
int main()
{
  long long n,c1=0,c2=0;
  cin>>n;
  long long a[n],i,x;
  for( i=0;i<n;i++)
  {
    cin>>a[i];
    if(n%2==1)
      x = x+1
      
      if(i<x)
      {
        c1+=a[i];
      }
    else
    {
      c2+=a[i];
    }
  }
  cout<<(abs(c1-c2));
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:14: error: expected ';' before 'if'
   12 |       x = x+1
      |              ^
      |              ;
   13 | 
   14 |       if(i<x)
      |       ~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define maxs(a,b) a=max(a,b)
#define mins(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){
   
    int n;cin>>n;
    vl a(n);
    ll l=0;
    rep(i,n){
        cin>>a[i];
            l+=a[i];
    }

    ll h=0;
    int ans=0;
    repa(i,n){
        h+=a[i];
        if(h*2>=l){
            ans=2*h-l;
            h-=a[i];
            mins(ans,l-2*h);
            break;
        }
    }

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

Compiler output:
a.cc:36:13: error: macro "repa" requires 3 arguments, but only 2 given
   36 |     repa(i,n){
      |             ^
a.cc:6:9: note: macro "repa" defined here
    6 | #define repa(i,a,n) for(int i=(a);i<(n);i++)
      |         ^~~~
a.cc: In function 'int main()':
a.cc:36:5: error: 'repa' was not declared in this scope
   36 |     repa(i,n){
      |     ^~~~
Language: C++

using namespace std;
#include<bits/stdc++.h>
int main()
{
  long long n,c1=0,c2=0;
  cin>>n;
  long long a[n],i,x=0;
  for( i=0;i<n;i++)
  {
    cin>>a[i];
    if(n%2==1)
      x = x+1
      
      if(i<x)
      {
        c1+=a[i];
      }
    else
    {
      c2+=a[i];
    }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:14: error: expected ';' before 'if'
   12 |       x = x+1
      |              ^
      |              ;
   13 | 
   14 |       if(i<x)
      |       ~~
Language: C++

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


int main(){
int n;

int sum = 0;
int h1 = 0;
int h2 = 0;
int dis = -1;
int ans;

scanf("%d", &n);

int a[n];

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

int am = sum % 2;
for (int i = 0; i < n - 1; i++){
    if (i == 0){
        h2 = a[i];
        if(h2 > sum/2) {
            dis = h2 - sum/2;
            break;
        }
    }
    else{
        h1 += a[i - 1];
        h2 += a[i];

        if(h2 > sum/2){
            if (h1 <= sum/2){
                dis = ((h2 - sum/2) <= (sum/2 - h1)) ? h2 - sum/2 : h1 - sum/2 + ((am == 1) ? 1 : 0);
                break;
            }   
            dis = h1 - sum/2;
            break;
        }
            
        
    }
}
if (i == n-2 && dis == -1){
    dis = h2 - sum/2 + ((am == 1) ? 1 : 0;
}

ans = 2 * dis - ((am == 1) ? 1 : 0);

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

Compiler output:
a.cc: In function 'int main()':
a.cc:49:5: error: 'i' was not declared in this scope
   49 | if (i == n-2 && dis == -1){
      |     ^
a.cc:50:42: error: expected ')' before ';' token
   50 |     dis = h2 - sum/2 + ((am == 1) ? 1 : 0;
      |                        ~                 ^
      |                                          )
Language: C++

using namespace std;
#include<bits/stdc++.h>
int main()
{
  long long n,c1=0,c2=0;
  cin>>n;
  long long a[n],i,x;
  for( i=0;i<n;i++)
  {
    cin>>a[i];
    if(n%2==1)
      x = x+1
      
      if(i<x)
      {
        c1+=a[i];
      }
    else
    {
      c2+=a[i];
    }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:14: error: expected ';' before 'if'
   12 |       x = x+1
      |              ^
      |              ;
   13 | 
   14 |       if(i<x)
      |       ~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    int length;
    int left = 0;
    int right = 0;
    cin >> N;
    vector<int> A(N,0);
    for (int i = 0; i < N; ++i) cin >> A.at(i);
    for (int i = 0; i < N; ++i){
      length += A.at(i);
    }
    int heikin = length/A.size();
    if(heikinn%2 == 0){
      A -= heikin;
    }else{
      A -= heikin*2;
    int res = 0;
    // 操作を行えるなら操作を実際に行う
        for (int i = 0; i < N; ++i) {
          for (int j = 0; j < N; ++j) {
            for (int k = 0; k < N; ++k) {
              A.at(i) = A.at(i) + j;
              A.at(i) = A.at(i) - k;
              
              left += A.at(i);
              right = length - left;
              if (left == right){
                res = j + k;
                break;// 半分になったら脱出
              }
            }
          }
        }
    cout << res << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:8: error: 'heikinn' was not declared in this scope; did you mean 'heikin'?
   16 |     if(heikinn%2 == 0){
      |        ^~~~~~~
      |        heikin
a.cc:17:9: error: no match for 'operator-=' (operand types are 'std::vector<int>' and 'int')
   17 |       A -= heikin;
      |       ~~^~~~~~~~~
a.cc:19:9: error: no match for 'operator-=' (operand types are 'std::vector<int>' and 'int')
   19 |       A -= heikin*2;
      |       ~~^~~~~~~~~~~
a.cc:38:2: error: expected '}' at end of input
   38 | }
      |  ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

//
//  second.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright Ã‚Â© 2019 yuya. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int N;
    vector<double> L(N);
    int A;
    double len = 0;
    cin >> N >> L[0];
    for (int i = 1; i < N; i++)
    {
        cin >> A;
        L[i] = L[i - 1] + A;
    }
    for (int i = 0; i < N; i++)
    {
        if (abs(len - L[N - 1] / 2) > abs(L[i] - L[N - 1] / 2))
        {
            len = L[i];
        }
    }
    if (len * 2 == L[N - 1])
    {
        cout << 0 << endl;
    }
    else if(len == 0 || len == L[N-1]);
    {
        cout << L[N-1] << endl;
    }
    
    else
    {
        cout << abs(L[N - 1] - len * 2) << endl;
    }

    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:42:5: error: 'else' without a previous 'if'
   42 |     else
      |     ^~~~
Language: C++

int main(void){
    int N;cin>>N;
    VI a(N);
    REP(i,N)cin>>a[i];

    VI suma(N);suma[0]=a[0];
    FOR(i,1,N)suma[i]=a[i]+suma[i-1];

    int cnt=0;
    //REP(i,N)cout<<suma[i]<<" ";
    int sum=suma[N-1];
    int c=a[0];

    REP(i,N){
        if(abs(sum/2-c)>abs(sum/2-suma[i])){
            c=suma[i];
        }
    }

    int cent=sum/2-c;
    int max_a=int(sum/2)*2;
    cnt=abs(suma[N-1]+cent-max_a);
    //cout<<cent<<endl;
    cout<<cnt<<endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:2:11: error: 'cin' was not declared in this scope
    2 |     int N;cin>>N;
      |           ^~~
a.cc:3:5: error: 'VI' was not declared in this scope
    3 |     VI a(N);
      |     ^~
a.cc:4:9: error: 'i' was not declared in this scope
    4 |     REP(i,N)cin>>a[i];
      |         ^
a.cc:4:5: error: 'REP' was not declared in this scope
    4 |     REP(i,N)cin>>a[i];
      |     ^~~
a.cc:6:7: error: expected ';' before 'suma'
    6 |     VI suma(N);suma[0]=a[0];
      |       ^~~~~
      |       ;
a.cc:6:16: error: 'suma' was not declared in this scope
    6 |     VI suma(N);suma[0]=a[0];
      |                ^~~~
a.cc:6:24: error: 'a' was not declared in this scope
    6 |     VI suma(N);suma[0]=a[0];
      |                        ^
a.cc:7:5: error: 'FOR' was not declared in this scope
    7 |     FOR(i,1,N)suma[i]=a[i]+suma[i-1];
      |     ^~~
a.cc:22:9: error: 'abs' was not declared in this scope
   22 |     cnt=abs(suma[N-1]+cent-max_a);
      |         ^~~
a.cc:24:5: error: 'cout' was not declared in this scope
   24 |     cout<<cnt<<endl;
      |     ^~~~
a.cc:24:16: error: 'endl' was not declared in this scope
   24 |     cout<<cnt<<endl;
      |                ^~~~
Language: C++

#include<iostream>
using namespace std;
using ll long long;
ll abs(ll a){return (a >= 0) ? a : -a; }
ll min(ll a, ll b){return ( a > b) ? b : a;}
int main(){
    int n; cin >> n;
    int a[n+1];
    ll sum[n+1] = {}, sum2[n];
    for(int i = 1; i <= n; i++) cin >> a[i];
    sum[1] = a[1];
    for(int i = 2; i <= n; i++){
        sum[i] += sum[i-1] + a[i];
    }
    ll mini = sum[n];
    for(int i = 1; i < n; i++){
        sum2[i] = sum[n] - sum[i];
    }
    for(int i = 1; i < n; i++){
        mini = min(mini, abs(sum2[i]-sum[i]));
    }
    cout << mini << endl;
    return 0;
}

Compiler output:
a.cc:3:7: error: expected nested-name-specifier before 'll'
    3 | using ll long long;
      |       ^~
a.cc:4:1: error: 'll' does not name a type
    4 | ll abs(ll a){return (a >= 0) ? a : -a; }
      | ^~
a.cc:5:1: error: 'll' does not name a type
    5 | ll min(ll a, ll b){return ( a > b) ? b : a;}
      | ^~
a.cc: In function 'int main()':
a.cc:9:5: error: 'll' was not declared in this scope
    9 |     ll sum[n+1] = {}, sum2[n];
      |     ^~
a.cc:9:21: error: expected primary-expression before ',' token
    9 |     ll sum[n+1] = {}, sum2[n];
      |                     ^
a.cc:9:23: error: 'sum2' was not declared in this scope
    9 |     ll sum[n+1] = {}, sum2[n];
      |                       ^~~~
a.cc:11:5: error: 'sum' was not declared in this scope
   11 |     sum[1] = a[1];
      |     ^~~
a.cc:15:7: error: expected ';' before 'mini'
   15 |     ll mini = sum[n];
      |       ^~~~~
      |       ;
a.cc:20:9: error: 'mini' was not declared in this scope
   20 |         mini = min(mini, abs(sum2[i]-sum[i]));
      |         ^~~~
a.cc:22:13: error: 'mini' was not declared in this scope
   22 |     cout << mini << endl;
      |             ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N)
    {
        cin >> A[i];
    }
    ll ans = 0(ll);
    if (N % 2 == 0) {
        for (int i = 0; i <= N / 2 - 1; i++) {
            ans += A[i] - A[N - 1 - i];
        }
        cout << abs(ans) << endl;
    } else {
        for (int i = 0; i <= N / 2 - 1; i++) {
            ans += A[i] - A[N - 1 - i];
        }
        cout << abs(abs(ans) - A[N / 2]) << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:12: error: expected primary-expression before 'long'
    3 | #define ll long long
      |            ^~~~
a.cc:22:16: note: in expansion of macro 'll'
   22 |     ll ans = 0(ll);
      |                ^~
a.cc:22:18: error: expression cannot be used as a function
   22 |     ll ans = 0(ll);
      |                  ^
Language: C++

#include<iostream>
#include <stdlib.h>
using namespace std;
 
int main()
{
    // get a integer
    int N;
    cin >> N;
  	int A[N];
  	for (int i=0;i<N;i++){
      cin >> A[i];
    }
  	double A_l = A[0];
  	double A_r = 0;
  	for (int i=1;i<N;i++){
      A_r += A[i];
    }
  	double min = abs(A_l - A_r);
  
  	for (int i = 1;i<N;i++){
      A_l += A[i];
      A_r -= A[i];
      diff = abs(A_l - A_r);
      if ( diff < min ) {
    	min = diff;
  	  }
    }
  	
  	cout << min << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:7: error: 'diff' was not declared in this scope
   24 |       diff = abs(A_l - A_r);
      |       ^~~~
Language: C++

#include <bits/stdc++.h>
#include <math.h>
using namespace std;
const int nmax = 200000;
int main(){
  int n;
  int a[nmax];
  int barlen = 0;
  int halflenl = 0;
  int halflenr = 0;
  int odd = 0;
  int j;
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> a[i];
    barlen += a[i];
  }
  odd = barlen%2;
  for(j=0; j<n; j++){
    halflenl += a[j];
    if( halflenl+a[j+1] > barlen/2) break;
  }
  halflenr = halflenl + a[j+1];
  cout << min(2*halflenr-barlen, -2*halflenl+barlen, (barlen/2-halflenl)*2 + odd , (halflenr-barlen/2-1)*2 + odd) <<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:14: error: no matching function for call to 'min(int, int, int, int)'
   24 |   cout << min(2*halflenr-barlen, -2*halflenl+barlen, (barlen/2-halflenl)*2 + odd , (halflenr-barlen/2-1)*2 + odd) <<endl;
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:   candidate expects 2 arguments, 4 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, 4 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, 4 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:   candidate expects 2 arguments, 4 provided
Language: C++

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

int main(){
  long long N,A;
  long long X=0;
  long long Y=0;
  long long Z=0;
  cin>>N;
  for(i=0;i<N;i++){
    cin>>A;
    X+=A;
  }
  for(i=0;i<N;i++){
    cin>>A;
    Y+=A;
    if(Y<=X/2){
      Z=Y-A;
      break;
    }
  }
  if(X%2==0){
    if(Y-X/2<=X/2-Z){
      cout<<2*Y-X<<endl;
    }else{
      cout<<X-2*Z<<endl;
    }
  }else{
    if(Y-X/2==0||X/2-Z==0||Y-X/2+1==0||X/2+1-Z==0){
      cout<<"1"<<endl;
    }else if(Y-X/2==X/2-Z||Y-X/2+1==X/2+1-Z){
      cout<<Y-Z-1<<endl;
    }else{
      if(Y-X/2<X/2-Z){
        cout<<2*Y-X-2<<endl;
      }else{
        cout<<X-2*Z-2<<endl;
      }
    }
  }
  return 0;
}

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

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

int main() {
    int N;
    int length;
    int left = 0;
    int right = 0;
    cin >> N;
    vector<int> A(N,0);
    for (int i = 0; i < N; ++i) cin >> A.at(i);
    for (int i = 0; i < N; ++i){
      length += A.at(i);
    }
    int res = 0;
    // 操作を行えるなら操作を実際に行う
        for (int i = 0; i < N; ++i) {
          for (int j = 0; j < N; ++j) {
            for (int k = 0; k < N; ++k) {
              A.at(i) = A.at(i) + j - k 
              left += A.at(i);
              right = length - left;
              if (left == right){
                res = j + k
                break;// 半分になったら脱出
              }
            }
          }
        }
    cout << res << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:40: error: expected ';' before 'left'
   20 |               A.at(i) = A.at(i) + j - k
      |                                        ^
      |                                        ;
   21 |               left += A.at(i);
      |               ~~~~                      
a.cc:24:28: error: expected ';' before 'break'
   24 |                 res = j + k
      |                            ^
      |                            ;
   25 |                 break;// 半分になったら脱出
      |                 ~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long  
#define mod 1000000007
#define am 998244353
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
int abs(int a,int b){
 return max(a,b)-min(a,b);
}
int gcd(int a,int b){//最大公約数
  int c=a%b;
  while(true){
    if(c==0) break;
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}
bool IsPrime(int num){
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  double sqrtNum = sqrt(num);
  for(int i=3;i<=sqrtNum;i+=2){
    if(num%i==0){
      return false;
    }
  }
}
int lcm(int a,int b){//最小公倍数
    return (a*b)/gcd(a,b);
}
signed main(){
// __builtin_ctz(N); Nを２で何回割り切れるかを返す
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a;
    int c,d;
    int b[1000000];
    cin>>a;
    for(int i=0;i<a;i++) cin>>b[i];
    c=a-1,d=0;
    int q=0,w=0;
    int p=0,o=0;
    int h=0;
    if(a%2==1) h=1;
    while(true){
	p=0,o=0;
      
	if(q<w) q+=b[d],p=1;
	else w+=b[c],o=1;
	if(c==d) break;
	if(p){
	    d++;
	    if(h) if(d==((a+1)/2)-1) d++;
	}
	
	if(o){
	    c--;
	    if(h) if(c==((a+1)/2)-1) c--;
	}
	
    }
    if(h){
	if(q<w) q+=b[(a+1)/2-1];
	else w+=b[(a+1)/2-1];
    }
    
    
    /*  int y=q,u=w;
    while(true){
	if(abs(y,u)<abs(q,w)) break;
	y=q,u=w;
	if(q<w){
	    q+=b[c-1],w-=b[c-1],c++;
	}
	else{
	    w+=b[d+1],q-=b[d+1],d--;
	}
	
	}*/
    cout<<abs(y,u)<<"\n";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:88:15: error: 'y' was not declared in this scope
   88 |     cout<<abs(y,u)<<"\n";
      |               ^
a.cc:88:17: error: 'u' was not declared in this scope
   88 |     cout<<abs(y,u)<<"\n";
      |                 ^
a.cc: In function 'bool IsPrime(long long int)':
a.cc:35:1: warning: control reaches end of non-void function [-Wreturn-type]
   35 | }
      | ^
Language: C++

#include <bits/stdc++.h>
#include <math.h>
using namespace std;
const int nmax = 200000;
int main(){
  int n;
  int a[nmax];
  int barlen = 0;
  int halflenl = 0;
  int halflenr = 0;
  int odd = 0;
  int j;
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> a[i];
    barlen += a[i];
  }
  odd = barlen%2;
  for(j=0; j<n; j++){
    halflenl += a[j];
    if( halflenl+a[j+1] > barlen/2) break;
  }
  halflenr = halflenl + a[j+1];
 
  cout << min( (barlen/2-halflenl)*2, (halflenr-barlen/2-1)*2) + odd << endl;
}
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
const int nmax = 200000;
int main(){
  int n;
  int a[nmax];
  int barlen = 0;
  int halflenl = 0;
  int halflenr = 0;
  int odd = 0;
  int j;
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> a[i];
    barlen += a[i];
  }
  odd = barlen%2;
  for(j=0; j<n; j++){
    halflenl += a[j];
    if( halflenl+a[j+1] > barlen/2) break;
  }
  halflenr = halflenl + a[j+1];

  cout << min( (barlen/2-halflenl)*2, (halflenr-barlen/2-1)*2) + odd << endl;
}

Compiler output:
a.cc:30:11: error: redefinition of 'const int nmax'
   30 | const int nmax = 200000;
      |           ^~~~
a.cc:4:11: note: 'const int nmax' previously defined here
    4 | const int nmax = 200000;
      |           ^~~~
a.cc:31:5: error: redefinition of 'int main()'
   31 | int main(){
      |     ^~~~
a.cc:5:5: note: 'int main()' previously defined here
    5 | int main(){
      |     ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n;
unsigned long long sm[200000];
unsigned long long v[200000];


int f2(){
	unsigned long long df=INFINITY,k;
	for(int i=0;i<n-1;i++){
		if(sm[n-1]-sm[i]==sm[i])return 0;
		long long k=sm[n-1]-sm[i];
		if(k<0)k*=-1;
		df=min(df,k);
	}
	return df;	
}

int main(){
ios_base::sync_with_stdio(0);
cin>>n;
cin>>v[0];
sm[0]=v[0];
for(int i=1;i<n;i++){
	cin>>v[i];
	sm[i]=sm[i-1]+v[i];
}
cout<<f2()<<'\n';
}



Compiler output:
a.cc: In function 'int f2()':
a.cc:9:31: warning: overflow in conversion from 'float' to 'long long unsigned int' changes value from '+Inff' to '18446744073709551615' [-Woverflow]
    9 |         unsigned long long df=INFINITY,k;
      |                               ^~~~~~~~
a.cc:14:23: error: no matching function for call to 'min(long long unsigned int&, long long int&)'
   14 |                 df=min(df,k);
      |                    ~~~^~~~~~
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:14:23: note:   deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'long long int')
   14 |                 df=min(df,k);
      |                    ~~~^~~~~~
/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:14:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
   14 |                 df=min(df,k);
      |                    ~~~^~~~~~
Language: C++

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int maxn=200000+10
int n;
ll a[maxn];
int main()
{
    cin>>n;
    for(int i=1; i<=n; i++)
        cin>>a[i];
    ll sum=0;
    for(int i=1; i<=n; i++)
        sum+=a[i];
    ll res=0;
    int i;
    for( i=1; i<=n; i++)
    {
        res+=a[i];
        if(res>=sum/2)
            break;
    }
    if(res==sum/2)
        printf("0\n");
    else
    {
        ll ans1=(res-(sum-res));
        ll ans2=(sum-res+a[i])-(res-a[i]);
        cout<<min(ans1,ans2)<<endl;

    }
    return 0;

}


Compiler output:
a.cc:8:1: error: expected ',' or ';' before 'int'
    8 | int n;
      | ^~~
a.cc: In function 'int main()':
a.cc:12:10: error: 'n' was not declared in this scope
   12 |     cin>>n;
      |          ^
Language: C++

#include<algorithm>
using namespace std;
constexpr auto maxn = 200005;
long long a[maxn];
long long b[maxn];
int main() {
	int n;
	int temp1;
	int temp2;
	cin >> n;
	long long sum = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		sum += a[i];
		b[i] = sum;
	}
	for (int i = 1; i <= n; i++) {
		if (sum % 2 == 0 && sum / 2 == b[i])
			return cout << 0, 0;
		else
			return cout << 1, 0;
	}
	for (int i = 1; i <= n; i++) {
		if (b[i] > sum / 2) {
			temp1 = i;
			break;
		}
	}
	for (int i = 1; i <= n; i++) {
		if (b[n] - b[i] > sum / 2)
		{
			temp2 = i;
			break;
		}
	}
	cout << min(b[temp1]-(b[n] - b[temp1]),b[n]-2*b[temp2]);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: 'cin' was not declared in this scope
   10 |         cin >> n;
      |         ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include<algorithm>
  +++ |+#include <iostream>
    2 | using namespace std;
a.cc:19:32: error: 'cout' was not declared in this scope
   19 |                         return cout << 0, 0;
      |                                ^~~~
a.cc:19:32: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:21:32: error: 'cout' was not declared in this scope
   21 |                         return cout << 1, 0;
      |                                ^~~~
a.cc:21:32: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:36:9: error: 'cout' was not declared in this scope
   36 |         cout << min(b[temp1]-(b[n] - b[temp1]),b[n]-2*b[temp2]);
      |         ^~~~
a.cc:36:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: Java

import java.io.*; 
import java.math.*;
import java.math.BigInteger;
import java.util.Scanner;
import java.lang.Math;
import java.math.BigDecimal;
import java.math.*; 
import java.util.Arrays;
import java.util.HashMap; 
import java.util.Map;
import com.google.common.math.BigIntegerMath;

class myfib{
	// 	static int[] f=new int[100];
	// public static void ncr(int n,int r) 
	// 	{ 
	// 		BigInteger up=factorial(n);
	// 		BigInteger d1=factorial(n-r);
	// 		BigInteger d2=factorial(r);
	// 		BigInteger fans=up.divide(d1);
	// 		fans=fans.divide(d2);
	// 		System.out.println(fans);
	// 	}

	// public static BigInteger factorial(int n) {
 //       BigInteger fact = new BigInteger("1");
 //       for (int i = 1; i <= n; i++) {
 //           fact = fact.multiply(new BigInteger(i + ""));
 //       }
 //       return fact;
 //   }
	public static void main(String[] args){
		Scanner input= new Scanner(System.in);
		int n= input.nextInt();
		//int i=0;
		int[] arr=new int[n];
		BigInteger sum=new BigInteger("0");
		for(int j=0;j<n;j++)
		{
			arr[j]=input.nextInt();
			sum=sum.add(new BigInteger(arr[j]+""));
		}
		BigInteger sum2=new BigInteger("0");
		BigInteger ans=new BigInteger("20202020202000000");
		for(int i=0;i<n;i++)
		{
			sum2=sum2.add(new BigInteger(arr[i]+""));
			//BigInteger x=new BigInteger(sum-sum2+"");
			BigInteger x=sum.subtract(sum2);
			BigInteger sub=x.subtract(sum2);
			sub=sub.abs();
			ans=ans.min(sub);
		}
		System.out.println(ans);
		// while(i<t)
		// {
		// 	int  n=input.nextInt();
		// 	//BigInteger n=input.nextBigInteger();
		// 	int k=input.nextInt();
		// 	int[] arr=new int[n];
		// 	for(int j=0;j<n;j++){
		// 		arr[j]=input.nextInt();
		// 	}
		// 	Arrays.sort(arr);
		// 	int nb=arr[k-1],ct=0;
		// 	HashMap<Integer,Integer>mp=new HashMap<>();
		// 	int id=0;
	 //        for (Integer x : arr) { 
	 //            Integer j = mp.get(x); 
	 //            mp.put(x, (j == null) ? 1 : j + 1); 
	 //            if(id++<k&&x==nb)
	 //            	ct++;
	 //        }
	 //        ncr(mp.get(nb),ct);
		// 	//n=fib(n);
		// 	// n=n%60;
		// 	// if(n==0)
		// 	// 	n=60;
		// 	//int p=(int)(Math.log((double)n)/Math.log((double)2));
		// 	//int p = BigIntegerMath.log2(n,RoundingMode.DOWN);
		// 	//n=(int)Math.pow(2,p);
		// 	//System.out.println(f[p]);
		// 	//System.out.println(n);
		// 	//fib(n-1);
		// 	//System.out.println(n%10);
		// 	//i++;
		// }
	}
}


Compiler output:
Main.java:11: error: package com.google.common.math does not exist
import com.google.common.math.BigIntegerMath;
                             ^
1 error
Language: C++

//おまじないc++
#include <iostream>
#include<cmath>
#include<vector>
using namespace std;
 
 int main() {
  long  int n;
  cin>>n;
  vector<long int> v(n);
  long int length=0;
  
 for(int i=0;i<n;i++){
  cin>> v.at(i);
  length+=v.at(i);
 }
   
   vector<long int> w(n);
   long int front =0;
   for(int i=0;i<n;i++){
     front+=v.at(i);
     w.at(i)=labs(2*front-length);
   }
   
   sort(w.begin(), w.end());
     
   cout<<w.at(0)<<endl;
 }
  
  
  

  

Compiler output:
a.cc: In function 'int main()':
a.cc:25:4: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   25 |    sort(w.begin(), w.end());
      |    ^~~~
      |    sqrt
Language: C++

//おまじないc++
#include <iostream>
#include<cmath>
#include<vector>
using namespace std;
 
 int main() {
  long  int n;
  cin>>n;
  vector<long int> v(n);
  long int length=0;
  
 for(i=0;i<n;i++){
  cin>> v.at(i);
  length+=v.at(i);
 }
   
   vector<long int> w(n);
   long int front =0;
   for(int i=0;i<n;i++){
     front+=v.at(i);
     w.at(i)=labs(2*front-length);
   }
   
   sort(w.begin(), w.end());
     
   cout<<w.at(0);<<endl;
 }
  
  
  

Compiler output:
a.cc: In function 'int main()':
a.cc:13:6: error: 'i' was not declared in this scope
   13 |  for(i=0;i<n;i++){
      |      ^
a.cc:25:4: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   25 |    sort(w.begin(), w.end());
      |    ^~~~
      |    sqrt
a.cc:27:18: error: expected primary-expression before '<<' token
   27 |    cout<<w.at(0);<<endl;
      |                  ^~
Language: C++

#include <stdio.h>
int main(void){
 int n,num[200001];
 int s=0;
 int f=0;
 scanf("%d", &n);
 for(int i=1;i<=n;++i ){
   scanf("%d", &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];
     }
     mm <-min(abs(s-f));
 }
 printf("%d",mm)
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:6: error: 'mm' was not declared in this scope
   15 |      mm <-min(abs(s-f));
      |      ^~
a.cc:15:15: error: 'abs' was not declared in this scope
   15 |      mm <-min(abs(s-f));
      |               ^~~
a.cc:15:11: error: 'min' was not declared in this scope; did you mean 'main'?
   15 |      mm <-min(abs(s-f));
      |           ^~~
      |           main
a.cc:17:14: error: 'mm' was not declared in this scope
   17 |  printf("%d",mm)
      |              ^~
Language: C++

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

using ll = long long;
#define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))

bool IsPrime(int);

/***** MAIN *****/
signed main() {
  int n;
  cin >> n;
  int bars[n];
  ll total = 0;
  REP(i, n) {
    cin >> bars[i]
    total += bars[i];
  }
  ll tmp = 0;
  int index = 0;
  REP(i, n) {
    tmp += bars[i];
    if(2*(tmp+bars[i+1]) >= total) {index = i+1;break;}
  }
  ll anothertmp = total - tmp;
  if(2*(tmp+bars[index]) == total) {
    cout << 0 << endl;
    return 0;
  }
  
  int over = anothertmp - tmp;
  if(over > bars[index]) {
    tmp += bars[index];
    anothertmp -= bars[index];
    over = tmp - anothertmp;
  }
  cout << abs(over);


  cout << "\n";
  return 0;
}
/***** MAIN *****/

bool IsPrime(int a) {
  if(a <= 1) return false;
  if(a == 2) return true;
  if(a%2 == 0) return false;
  for(int i = 3; i*i <= a; i+=2) {
    if(a%i==0) return false;
  }
  return true;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:19: error: expected ';' before 'total'
   29 |     cin >> bars[i]
      |                   ^
      |                   ;
   30 |     total += bars[i];
      |     ~~~~~
Language: C++

#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;cin>>n;
  int m,u;
  int ans=0,sum=0;
  vector<int>a(n);
  for(int i=0;i<n;i++)
  {
    cin>>a.at(i);
    sum+=a.at(i);
    
  }
  for(int i=0;i<n;i++)
  {
    ans+=a.at(i);
    if(ans==sum/2)
    {
      cout<<0;
      break;
    }
    if(ans>=sum/2)
    {
      if(sum-ans>sum-(ans-a.at(i)))
          m=ans-a.at(i);
          u=sum-m;
          cout<<m<<u<<endl;
          cout<<abs(m-u);
      }
      else
      {
        cout<<abs(ans-(sum-ans));
      }
          break;
    }
  }
  
  
}
      
    
    
  
 
    

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

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ACはうれCすぎてうれD */

int main(void){ 
    int n;
    cin >> n;
    vector<ll> A;
    for(int i=0; i<n; i++){
        ll tmp_a;
        cin >> tmp_a;
        A.push_back(tmp_a);
    }

    vector<ll> ruiseki(n);
    ruiseki[0] = A[0];
    for(int i=1; i<n; i++){
        ruiseki[i] = ruiseki[i-1] + A[i];
    }

    ll ans = 0;

    vector<ll>::iterator l;
    l = lower_bound(ruiseki.begin(), ruiseki.end(), ruiseki[n-1]/2);

    ll usiro = (ruiseki[n-1] - *l);
    ll mae = *l;

    if(usiro - mae > 0LL){
        ans += (usiro - mae);
    }
    else{
        ans += (mae - usiro);
    }

    ll ans_1 = 0;
    advance(l,-1);

    ll usiro = (ruiseki[n-1] - *l);
    ll mae = *l;

    if(usiro - mae > 0LL){
        ans_1 += (usiro - mae);
    }
    else{
        ans_1 += (mae - usiro);
    }


    cout << min(ans,ans_1);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:8: error: redeclaration of 'll usiro'
   43 |     ll usiro = (ruiseki[n-1] - *l);
      |        ^~~~~
a.cc:30:8: note: 'll usiro' previously declared here
   30 |     ll usiro = (ruiseki[n-1] - *l);
      |        ^~~~~
a.cc:44:8: error: redeclaration of 'll mae'
   44 |     ll mae = *l;
      |        ^~~
a.cc:31:8: note: 'll mae' previously declared here
   31 |     ll mae = *l;
      |        ^~~
Language: C++

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

const long long INF = 1001001001;

long long my_abs(long long a){
	if(a < 0) return -a;
	else return a;
}

int main(){
	long long N;
	cin >> N;
	vector<long long> A(N);
	for(long long i=0; i<N; ++i){
		cin >> A[i];
	}
	long long kai1=0;
	long long kai2=0;
	long long minval = INF;
	for(long long i=0; i<N; ++i){
		if(i==0){
				kai1 += A[0];
			for(long long j=1; k<N; ++k){
				kai2 += A[k];
			}
		}
		else{
			kai1 += A[i];
			kai2 -= A[i];
		}
		if(my_abs(kai1 - kai2) < minval){
			minval = my_abs(kai1 - kai2);
		}
	}
	cout << minval << '\n';
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:44: error: 'k' was not declared in this scope
   25 |                         for(long long j=1; k<N; ++k){
      |                                            ^
Language: C++

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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N); 
  int sum=0;
  int count=0;
  int kari=0;
  
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
    sum += vec.at(i);
  }
  kari = sum % 2;
  if(kari == 1){
    count++;
    sum++;
  }
  sum /= 2;
  int num1=0;
  int num2=0;
  bool ans=true;
  
  for (int j=0; j<N; j++){
    num1 += vec.at(j);
    if (num1 >= sum){
      if ((num1-sum) >= (sum-num2)){
        break;
      }
      else{
        ans=false;
        break;
    }
    num2 += vec.at(j);
  }
  if (ans){
    num1-=sum;
    count += num1;
    cout << count << endl;
  }
  else{
    sum-=num2;
    count+=sum;
    cout << count<< endl;
  }
  
}


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

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

using namespace std;

int main() {
    int n;
    cin>>n;
    int a[n];
    long long int sum[n+1];
    sum[0]=0;
    for(int i=0;i<n;i++){
      cin>>a[i];
      sum[i+1]=sum[i]+a[i];
    }
    if(sum[n]%2==0){
      long long int tmp=sum[n]/2;
      for(int i=0;i<n;++i){
        if(labs(sum[n]/2-sum[i])<tmp) tmp=labs(sum[n]/2-sum[i]);
      }
      cout<<2*tmp<<endl;
    }
    else{
      long long int tmp=sum[n]/2;
      for(int i=0;i<n;++i){
        if(labs(sum[n]/2-sum[i])<tmp) tmp=labs(sum[n]/2-sum[i]);
      }
      cout<<2*tmp-1<<endl;
    }
   return 0;
 }


Compiler output:
a.cc: In function 'int main()':
a.cc:10:5: error: 'cin' was not declared in this scope
   10 |     cin>>n;
      |     ^~~
a.cc:5:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    4 | #include <stdlib.h>
  +++ |+#include <iostream>
    5 | 
a.cc:23:7: error: 'cout' was not declared in this scope
   23 |       cout<<2*tmp<<endl;
      |       ^~~~
a.cc:23:7: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:30:7: error: 'cout' was not declared in this scope
   30 |       cout<<2*tmp-1<<endl;
      |       ^~~~
a.cc:30:7: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

#include <iostream>
#include <vector>
#include <cmath>
#include <limits>

int main(){
    uint n;
    std::cin >> n;
    std::vector<double> a(n);
    double prev = 0;
    for (uint i = 0; i < n; i++){
        double temp;
        std::cin >> temp;
        a.at(i) = prev + temp;
        prev = a.at(i);
    }
    double center = *(cend(a) - 1) / 2;
    double diff = INT_MAX;
    uint i = 0;
    while (std::abs(a.at(i) - center) < diff){
        diff = std::abs(a.at(i) - center);
        i += 1;
    }
    std::cout << diff  * 2 << std::endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:19: error: 'INT_MAX' was not declared in this scope
   18 |     double 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 <cmath>
  +++ |+#include <climits>
    4 | #include <limits>
Language: C++

#include <bits/stdc++.h>
#include <vector>
using namespace std;
 
int main() {
  int N;
  int sensor = 0;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
      cin >> A.at(i);
  }
  double L, L1 = 0.0;
  for (int j = 0; j < N; j++){
    L += A.at(j);
  }
  int M;
  double X, Y,
  for(int k = 0; k < N; k++){
    L1 += (double)A.at(k);
    if(L1 == L / 2.0){
      M = k;
      cout << 0 << endl;
      goto END;
    }
    if(L1 > L / 2.0){
      M = k;
      Y = L1 - L / 2.0;
      X = A.at(M) - Y;
      break;
    }    
  }
  int kane;
  kane = (int)min( 2 * X, 2 * Y);
  cout << kane << endl;
  END :
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:3: error: expected unqualified-id before 'for'
   19 |   for(int k = 0; k < N; k++){
      |   ^~~
a.cc:19:18: error: 'k' was not declared in this scope
   19 |   for(int k = 0; k < N; k++){
      |                  ^
a.cc:37:1: warning: label at end of compound statement only available with '-std=c++2b' or '-std=gnu++2b' [-Wc++23-extensions]
   37 | }
      | ^
Language: C++

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


#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define deg_to_rad(deg) (((deg)/360)*2*M_PI)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

using namespace std;

int main()
{

  int n;
  cin >>n;
  vector<int> a;
  int total=0;
  rep(i,n)
  {
    int ai;
    cin >>ai;
    
    a.push_back(ai);
    total+=ai;
  }
  
  int now=0;
  int sa=0;
    rep(i,n)
    {
      now+=a[i];
      if(now==total-now)
      {
        cout <<0;
        return 0;
      }
      
      if(half<now)
      {
        int last =now-a[i];
        if(now-(total-now) < total-(last*2))
        {
          sa=now-(total-now);
        }
        else
        {
          sa=total-(last*2);
        }
        
                cout <<sa;
        return 0;
          
      }
      
    }
  
	return 0;
}





Compiler output:
a.cc: In function 'int main()':
a.cc:46:10: error: 'half' was not declared in this scope
   46 |       if(half<now)
      |          ^~~~
Language: C++


#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
using ll = long long;
int main(){ 
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll b=0,c=0,d,e,f;
    rep(i,n){
        b+=a[i];
    }
e=b;
f=b;
if(b%2==0){
    b/=2;
}else{
    b=b/2+1;
}
rep(i,n){
    c+=a[i];
    if(c>=b){
        d=c-a[i];
        break;
    }
}
    if(abs(e-2*c)>abs(e-2*d)){
   cout<<abs(e-2*d);
    }else{
        cout<<abs(e-2*c);
    }
}
    return 0;
}


Compiler output:
a.cc:39:5: error: expected unqualified-id before 'return'
   39 |     return 0;
      |     ^~~~~~
a.cc:40:1: error: expected declaration before '}' token
   40 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
#ifndef ONLINE_JUDGE
#include "debug.cpp"
#endif
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  int n; cin >> n;
  int ar[n];
  int prefix[n] = {0};

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

  prefix[0] = ar[0];

  for(int i=1;i<n;i++){
    prefix[i] = prefix[i-1] + ar[i];
  }

  int minn = 1e18;

  for(int i=0;i<n-1;i++){
    int left = prefix[i];
    int right = prefix[n-1] - prefix[i];
    minn = min(minn,abs(left-right));
  }

  cout << minn << '\n';

  return 0;
}

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

#include "algorithm"
#include "functional"
#include "iostream"
#include "numeric"
#include "queue"
#include "set"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

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

  ll N;
  cin >> N;
  V<ll> as(N);

  ll sum = 0;
  rep(i, N) {
    ll a;
    cin >> a;
    sum += a;
    as[i] = a;
  }

  ll ii = -1;
  ll s = 0;

  rep(i, N) {
    s += as[i];
    if (sum % 2 == 0 && s == sum / 2) {
      cout << 0 << endl;
      return;
    }

    if (s > sum / 2) {
      ii = i;
      break;
    }
  }

  ll l = s - as[ii];
  ll r = sum - s;
  ll res = min(sum - 2 * l, sum - 2 * r);

  cout << res << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:57:7: error: return-statement with no value, in function returning 'int' [-fpermissive]
   57 |       return;
      |       ^~~~~~
Language: C++

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

using ll=long long;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int div1(ll x){
  return x%1000000007;
}

int xy(int x,int y){
    if (x ==1 && y== 1) return 400000;
    return 0;
}

main(){
    int n=in(),sum=0;
    deque<ll> a;
    for (int i=0;i<n;i++) a.push_back(in());
    ll m=0;
    bool fb=ture;
    while(a.empty()){
        if (fb){
            m+=a.front();
            a.pop_front();
            if (m>0) fb=false;
        }
        else {
            m-=a.back();
            a.pop_back();
            if (m<0) fb=true;
        }
    }
    cout << abs(m) << endl;
}

Compiler output:
a.cc:32:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   32 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:37:13: error: 'ture' was not declared in this scope
   37 |     bool fb=ture;
      |             ^~~~