criyle/codenet-compile-errors huggingface dataset:
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[n];
    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:35:29: error: request for member 'push_back' in 'a', which is of non-class type 'std::deque<long long int> [n]'
   35 |     for (int i=0;i<n;i++) a.push_back(in());
      |                             ^~~~~~~~~
a.cc:37:13: error: 'ture' was not declared in this scope
   37 |     bool fb=ture;
      |             ^~~~
a.cc:38:13: error: request for member 'empty' in 'a', which is of non-class type 'std::deque<long long int> [n]'
   38 |     while(a.empty()){
      |             ^~~~~
a.cc:40:18: error: request for member 'front' in 'a', which is of non-class type 'std::deque<long long int> [n]'
   40 |             m+=a.front();
      |                  ^~~~~
a.cc:41:15: error: request for member 'pop_front' in 'a', which is of non-class type 'std::deque<long long int> [n]'
   41 |             a.pop_front();
      |               ^~~~~~~~~
a.cc:45:18: error: request for member 'back' in 'a', which is of non-class type 'std::deque<long long int> [n]'
   45 |             m-=a.back();
      |                  ^~~~
a.cc:46:15: error: request for member 'pop_back' in 'a', which is of non-class type 'std::deque<long long int> [n]'
   46 |             a.pop_back();
      |               ^~~~~~~~
Language: C++

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

typedef long long ll;
typedef unsigned short int unsi;
typedef unsigned int uni;
typedef unsigned long int unli;

using namespace std;

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

	vector<ll>A(N);
	vector<ll>SumA(N);

	for (int i = 0; i < N; i++) {
		cin >> A[i];
		SumA[i] = A[i];
		if (i != 0) {
			SumA[i] += SumA[i - 1];
		}
	}

	ll halfsum = SumA[N - 1] / 2;
	int index;

	for (int i = 0; i < N; i++) {
		if (SumA[i] > halfsum) {
			index = i;
			break;
		}
	}

	if (index != 0) {
		if (SumA[index] - halfsum > halfsum - SumA[index - 1]) {
			cout << (abs(SumA[N - 1] - 2 * SumA[index - 1]) + 1) / 2;
		} else {
			cout << (abs(SumA[N - 1] - 2 * SumA[index]) + 1) / 2;
		}
	} else {
		cout << (abs(SumA[N - 1] - 2 * SumA[0]) + 1) / 2;
	}
	



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

#include<iostream>
#include<cstdio>
#include<vector>


using namespace std;

int main()
{
  int n;
  
  cin >> n;
  
  vector<int> a(n);
  long long s=0,t=0;
  
  for(int i=0;i<n;i++){
    cin >> a[i];
    t += a[i];
  }
  
  long long min = LLONG_MAX;
  
  for(int i=0;i<n-1;i++){
    s += a[i];
     t-= a[i];
    
    if(min > abs(s-t)){
        min = abs(s-t);
    }
  }
  
  cout << min << endl;
  
  return 0;
}


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

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a(0),b(0),ans(0);;
  
  cin >> n;
  
  vector<int> ary(n);
  int j = n-1;
  for(int i = 0;i<n;i++){
    cin >> ary.at(i);
  }
  for(int i = 0;i<j+a1;i++){
    a += ary.at(i);
    while(a>b && i<j){
      b += ary.at(j);
      j--;
    }
    
  }
  
  ans = abs(a-b); 

  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:21: error: 'a1' was not declared in this scope; did you mean 'a'?
   13 |   for(int i = 0;i<j+a1;i++){
      |                     ^~
      |                     a
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a(0),b(0),ans(0);;
  
  cin >> n;
  
  vector<int> ary(n);
  int j = n-1;
  for(int i = 0;i<n;i++){
    cin >> ary.at(i);
  }
  for(int i = 0;i<j+a1;i++){
    a += ary.at(i);
    while(a>b && i<j){
      b += ary.at(j);
      j--;
    }
    
  }
  
  ans = abs(a-b); 
  cout << a << endl;cout << b << endl;
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:21: error: 'a1' was not declared in this scope; did you mean 'a'?
   13 |   for(int i = 0;i<j+a1;i++){
      |                     ^~
      |                     a
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,left,right,dis;
  cin>>n;
  a[n],dis[n-1];
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n-1;i++)
  {
    left=0;right=0;
    for(int j=0;j<n;j++)
    {
      if(j<=i) left+=a[j];
      else right+=a[j];
      if(i==0 || dis>(abs(left-right)))
      dis=abs(left-right);
    }
  }
  cout<<dis;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'a' was not declared in this scope
    7 |   a[n],dis[n-1];
      |   ^
a.cc:7:11: error: invalid types 'int[int]' for array subscript
    7 |   a[n],dis[n-1];
      |           ^
Language: C++

#include <iostream>

using namespace std;
#define int long long
int a[200001];
int main()
{
    int n , sum = 0;
    cin >> n;
    for(int i = 1; i <= n; i ++)
    {
        cin >> a[i];
        sum += a[i];
    }
    int pr = 0;
    int ans = sum;
    for(int i = 1; i <= n; i ++)
    {
        pr += a[i];
        ans = min(ans , abs(sum - pr - pr));
    }
    cout << ans;
    return 0;
}


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

#include<bits/stdc++.h>
using namespace std;
typedef long lont int ll;
int main()
{
  int n;
  cin>>n;
  ll a[n];ll sum=0;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    sum+=a[i];
  }
  ll ans=LONG_MAX;ll s=0;
  for(int i=0;i<n;i++)
  {
    s+=a[i];
    ll v=abs(sum-s);
    ans=min(ans,abs(v-s));
  }
  cout<<ans<<"\n";
  return 0;
}

Compiler output:
a.cc:3:19: error: expected initializer before 'int'
    3 | typedef long lont int ll;
      |                   ^~~
a.cc: In function 'int main()':
a.cc:8:3: error: 'll' was not declared in this scope
    8 |   ll a[n];ll sum=0;
      |   ^~
a.cc:8:13: error: expected ';' before 'sum'
    8 |   ll a[n];ll sum=0;
      |             ^~~~
      |             ;
a.cc:11:10: error: 'a' was not declared in this scope
   11 |     cin>>a[i];
      |          ^
a.cc:12:5: error: 'sum' was not declared in this scope
   12 |     sum+=a[i];
      |     ^~~
a.cc:14:5: error: expected ';' before 'ans'
   14 |   ll ans=LONG_MAX;ll s=0;
      |     ^~~~
      |     ;
a.cc:14:21: error: expected ';' before 's'
   14 |   ll ans=LONG_MAX;ll s=0;
      |                     ^~
      |                     ;
a.cc:17:5: error: 's' was not declared in this scope
   17 |     s+=a[i];
      |     ^
a.cc:17:8: error: 'a' was not declared in this scope
   17 |     s+=a[i];
      |        ^
a.cc:18:7: error: expected ';' before 'v'
   18 |     ll v=abs(sum-s);
      |       ^~
      |       ;
a.cc:19:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   19 |     ans=min(ans,abs(v-s));
      |     ^~~
      |     abs
a.cc:19:21: error: 'v' was not declared in this scope
   19 |     ans=min(ans,abs(v-s));
      |                     ^
a.cc:21:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   21 |   cout<<ans<<"\n";
      |         ^~~
      |         abs
Language: C++

#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) (a < b ? b : a)
#define min(a,b) (a > b ? b : a)
#define AAA (1000000007)
using namespace std;
typedef long long ll;


int i, j, k;

int main() {
	int N;
	vector<ll> A;
	vector<ll> B;
	cin >> N;
	rep(i, 0, N) {
		ll temp;
		cin >> temp;
		A.push_back(temp);
		if (i != 0)
			B.push_back(B[i - 1] + temp);
		if (i == 0)
			B.push_back(temp);

	}
	ll total = B.back();

	ll ans = pow(2, 30);
	ans = LONG_MAX;

	rep(i, 0, N) {
		if (ans > abs(total - 2 * B[i]))
			ans = abs(total - 2 * B[i]);



	}
	cout << ans;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:44:15: error: 'LONG_MAX' was not declared in this scope
   44 |         ans = LONG_MAX;
      |               ^~~~~~~~
a.cc:15:1: note: 'LONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   14 | #include <functional>
  +++ |+#include <climits>
   15 | #include <limits>
Language: C

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    B.at(0) = 0;
    for (int i = 0; i < N; i++){
        cin >> A.at(i);
        if(i == 0){
            B.at(i) = A.at(i);
        }
        else{
            B.at(i) = B.at(i-1) + A.at(i);
        }
    }
    int tmp = abs(B.at(N-1) - 2 * B.at(0));
    int tmp_num = 0;
    for (int i = 0; i < N; i++){
        if(tmp > abs(B.at(N-1) - 2 * B.at(i))){
            tmp_num = i;
            tmp = abs(B.at(N-1) - 2 * B.at(i));
        }
    }
    cout << tmp << endl;
    return 0;
}


Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
long long maximum;
long long mod = 1000000007;
const int INF = 1001001001;
vector<vector<int>> dp;

int main(){
  ll n;
  cin >> n;
  vector<int> kir(n);
  ll input;
  ll val = 0;
  for(ll i=0;i<n;i++){
    cin >> input;
    val += input;
    kir.at(i) = val;
  }
  ll dist =INF;
  for(ll i=0;i<n;i++){
    dist = min(dist, abs(kir.at(i)*2-kir.at(n-1)));            
  }
  cout << dist << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:15: error: no matching function for call to 'min(ll&, int)'
   22 |     dist = min(dist, abs(kir.at(i)*2-kir.at(n-1)));
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:22:15: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   22 |     dist = min(dist, abs(kir.at(i)*2-kir.at(n-1)));
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:22:15: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   22 |     dist = min(dist, abs(kir.at(i)*2-kir.at(n-1)));
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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

int main() {
  long long N;
  cin>>N;
  vector<long long>A(N);
  long long sum=0;
  for(int i=0;i<N;i++) cin>>A[i];
  for(int i=0;i<N;i++) sum+=A[i];
  if(sum%2==0){
    long long half=sum/2;
    long long x=0;
    for(int i=0;i<N;i++){
      if(x+A[i]<=half) x+=A[i];
      else break;
    }
    cout<<sum-2*x<<endl;
  }
  else{
    long long half1=sum/2;
    long long x=0;
    for(int i=0;i<N;i++){
      if(x+A[i]<=half) x+=A[i];
      else break;
    }
    cout<<sum-2*x<<endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:18: error: 'half' was not declared in this scope; did you mean 'half1'?
   24 |       if(x+A[i]<=half) x+=A[i];
      |                  ^~~~
      |                  half1
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;

#define DEBUG 0
#define REP(i, n) for (int i = 0; i < (n); i++) 
typedef long long ll;
typedef pair<int,int> pint;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

int main() { 
    ll N;
    cin >> N;
    ll sum_a = 0;
    vector <ll> a(N);
    REP(i,N)
    {
        cin >> a[i];
        sum_a += a[i];
    }

    ll tmp = 0;

    ll res = INF;

    REP(i,N)
    {
        if(tmp + a[i] > sum_a / 2)
        {
            res = min(res, abs((sum_a - tmp) - tmp));
            res = min(res, abs((sum_a - tmp -a[i]) - tmp - a[i]));
        }
        tmp += a[i]
    }


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

Compiler output:
a.cc: In function 'int main()':
a.cc:40:20: error: expected ';' before '}' token
   40 |         tmp += a[i]
      |                    ^
      |                    ;
   41 |     }
      |     ~
Language: C++

/**akshaykumar99**/
 
#include<bits/stdc++.h>
using namespace std;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=1e5+1;
 
typedef long long ll;
typedef long double ld;

int main()
{
    IOS();
  
    ll n,i=0,j;
    cin>>n; #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt","w",stdout);
    #endif
    ll a[n];
    f(i,0,n)   
        cin>>a[i];
    i=0;
    j=n-1;
    ll s1=0,s2=0;
    while(i<=j)
    {
        if(s1<s2)
        {
            s1+=a[i];
            i++;
        }
        else
        {
            s2+=a[j];
            j--;
        }
    }
    ll diff=abs(s1-s2);
    cout<<diff<<'\n';
    
    return 0;
}

Compiler output:
a.cc:31:13: error: stray '#' in program
   31 |     cin>>n; #ifndef ONLINE_JUDGE
      |             ^
a.cc:34:6: error: #endif without #if
   34 |     #endif
      |      ^~~~~
a.cc: In function 'int main()':
a.cc:31:14: error: 'ifndef' was not declared in this scope; did you mean 'index'?
   31 |     cin>>n; #ifndef ONLINE_JUDGE
      |              ^~~~~~
      |              index
Language: C++

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

int main()
{
  int N;
  int A[200010]={0};
  cin>>N;
  int length=0;
  for(int i=0;i<N;i++){
    cin>>A[i];
    length+=A[i];
  }
  int half=length/2;
  int bar=0;
  for(int i=0;i<N;i++){
    if(bar<half)bar+=A[i];
  }
  half=length-bar;
  cout<<max(half-bar,bar-half)<<endl;
}

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

#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,sum,a[200002],pref[200002];
int main(){
//freopen("text.in.txt","r",stdin);
cin>>n;
for(ll k=1;k<=n;k++){
    cin>>a[k];
    sum+=a[k];s
    pref[k]=pref[k-1]+a[k];
}
ll ans=LONG_LONG_MAX;
for(int k=1;k<n;k++){
    ll a1=pref[k],a2=abs(sum-pref[k]);
    ans=min(ans,abs(a2-a1));
}
cout<<ans;
return 0;
}


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

#include <bits/stdc++.h>

using namespace std;

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

  int N; cin>>N;
  vector<size_t> A(N); for (auto& a : A) cin>>a;
  
  int sum = 0;
  vector<size_t> CA;
  for (auto a : A) {
    sum += a;
    CA.push_back(sum);
  }
  auto center = float(CA.back())/2;
  auto min_div = *min_element(CA.begin(), CA.end(), [=](auto ca) {
    return abs(center - ca);
  });
  auto res = abs(center - min_div) * 2;
  cout << res << endl;

  return 0;
}


Compiler output:
In file included from /usr/include/c++/14/bits/stl_algobase.h:71,
                 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/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = __gnu_cxx::__normal_iterator<long unsigned int*, std::vector<long unsigned int> >; _Iterator2 = __gnu_cxx::__normal_iterator<long unsigned int*, std::vector<long unsigned int> >; _Compare = main()::<lambda(auto:28)>]':
/usr/include/c++/14/bits/stl_algo.h:5562:12:   required from 'constexpr _ForwardIterator std::__min_element(_ForwardIterator, _ForwardIterator, _Compare) [with _ForwardIterator = __gnu_cxx::__normal_iterator<long unsigned int*, vector<long unsigned int> >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(auto:28)> >]'
 5562 |         if (__comp(__first, __result))
      |             ~~~~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5613:43:   required from 'constexpr _FIter std::min_element(_FIter, _FIter, _Compare) [with _FIter = __gnu_cxx::__normal_iterator<long unsigned int*, vector<long unsigned int> >; _Compare = main()::<lambda(auto:28)>]'
 5613 |       return _GLIBCXX_STD_A::__min_element(__first, __last,
      |                                           ^
a.cc:18:30:   required from here
   18 |   auto min_div = *min_element(CA.begin(), CA.end(), [=](auto ca) {
      |                   ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   19 |     return abs(center - ca);
      |     ~~~~~~~~~~~~~~~~~~~~~~~~  
   20 |   });
      |   ~~                          
/usr/include/c++/14/bits/predefined_ops.h:158:30: error: no match for call to '(main()::<lambda(auto:28)>) (long unsigned int&, long unsigned int&)'
  158 |         { return bool(_M_comp(*__it1, *__it2)); }
      |                       ~~~~~~~^~~~~~~~~~~~~~~~
a.cc:18:53: note: candidate: 'template<class auto:28> main()::<lambda(auto:28)>'
   18 |   auto min_div = *min_element(CA.begin(), CA.end(), [=](auto ca) {
      |                                                     ^
a.cc:18:53: note:   candidate expects 1 argument, 2 provided
Language: C++

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

int main(){
  int i,j,ll cnt;
  int n;
  cin>>n;
  ll a[n];
  for(i=0;i<n;i++)cin>>a[i];
  ll sum=0;
  for(i=0;i<n;i++)sum+=a[i];
  cnt=0;
  ll mi=INT_MAX;
  for(i=0;i<n;i++){
    cnt+=a[i];
    mi=min(max(sum-2*cnt,2*cnt-sum),mi);
  }
  cout<<mi;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:14: error: expected initializer before 'cnt'
    6 |   int i,j,ll cnt;
      |              ^~~
a.cc:13:3: error: 'cnt' was not declared in this scope; did you mean 'int'?
   13 |   cnt=0;
      |   ^~~
      |   int
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
  cin.tie(0);
  int n = 0;
  cin >> n;
  long long total = 0;
  for(int i=0;i<n;i++) {
    cin >> a[i];
  	total += a[i];
  }
  long long res = 1e18;
  long long sum = 0;
  for(int i=0;i<n;i++) {
  	sum += a[i];
    res = min(res, abs(total - sum * 2));
  }
  cout << res;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:12: error: 'a' was not declared in this scope
   10 |     cin >> a[i];
      |            ^
a.cc:16:16: error: 'a' was not declared in this scope
   16 |         sum += a[i];
      |                ^
Language: C++

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

int main() {
  int n;
  cin >> n;
  vector<long> a(n)，s(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    s.at(i + 1) = s.at(i) + a.at(i);
  }
  long ans = s.at(n);
  for (int i = 0; i < n; i++) {
    ans = min(ans, abs(2 * s.at(i) - s.at(n)));
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:20: error: expected ',' or ';' before '\U0000ff0cs'
    7 |   vector<long> a(n)，s(n + 1);
      |                    ^~~
a.cc:10:5: error: 's' was not declared in this scope
   10 |     s.at(i + 1) = s.at(i) + a.at(i);
      |     ^
a.cc:12:14: error: 's' was not declared in this scope
   12 |   long ans = s.at(n);
      |              ^
Language: C

#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <tuple>
#include <cassert>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

int main ()
{
    int N; cin >> N;
    vector<ll> A(N);
    REP(i,N) cin >> A[i];

    ll sum = 0;
    REP(i,N) sum += A[i];

    ll pre = 0;
    ll min_diff = sum;
    for (int i = 0; i < N; i++) {
        pre += A[i];
        sum -= A[i];
        min_diff = min(min_diff, abs(pre - sum));
    }

    cout << min_diff << endl;

    return 0;
}


Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: Java

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  ll sum = 0, lsum = 0;
  for (int i = 0; i < n; i++) sum += a[i];
  ll ans = 1LL << 60;
  for (int i = 0; i < n - 1; i++) {
    lsum += a[i];
    sum -= a[i];
    ans = min(ans, abs(lsum - sum));
  }
  cout << ans << endl;
  return 0;
}


Compiler output:
Main.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
Main.java:1: error: class, interface, enum, or record expected
#include <bits/stdc++.h>
         ^
Main.java:5: error: unnamed classes are a preview feature and are disabled by default.
using ll = long long;
^
  (use --enable-preview to enable unnamed classes)
Main.java:5: error: '.class' expected
using ll = long long;
                ^
Main.java:6: error: '.class' expected
using vi = vector<int>;
                     ^
Main.java:6: error: illegal start of expression
using vi = vector<int>;
                      ^
Main.java:7: error: illegal start of expression
using vll = vector<ll>;
                      ^
Main.java:8: error: '.class' expected
using vvi = vector<vector<int>>;
                             ^
Main.java:8: error: illegal start of expression
using vvi = vector<vector<int>>;
                               ^
Main.java:9: error: illegal start of expression
using vvl = vector<vector<ll>>;
                              ^
Main.java:13: error: not a statement
  ios::sync_with_stdio(false);
  ^
Main.java:15: error: not a statement
  cin >> n;
      ^
Main.java:16: error: not a statement
  vector<ll> a(n);
               ^
Main.java:17: error: not a statement
  for (int i = 0; i < n; i++) cin >> a[i];
                                  ^
Main.java:20: error: not a statement
  ll ans = 1LL << 60;
               ^
Main.java:26: error: not a statement
  cout << ans << endl;
              ^
Main.java:13: error: ';' expected
  ios::sync_with_stdio(false);
                      ^
Main.java:16: error: ';' expected
  vector<ll> a(n);
              ^
Main.java:16: error: ';' expected
  vector<ll> a(n);
                ^
Main.java:20: error: ';' expected
  ll ans = 1LL << 60;
             ^
20 errors
Language: Java

n = read_line.to_i
a = read_line.split.map(&.to_i64)
all = a.sum
sum = 0i64
min = all
n.times do |i|
  sum += a[i]
  min = {min, (all - sum - sum).abs}.min
end
puts min


Compiler output:
Main.java:1: error: class, interface, enum, or record expected
n = read_line.to_i
^
1 error
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;


int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<int>> a(h+1, vector<int>(w+1, 0));
    vector<string> s(h);
    int id = 1;
    rep(i,h) {
        cin >> s[i];
        int cnt = 0;
        rep(j,w) if(s[i][j]=='#') cnt++;
        if(cnt==0){
            if(i)rep(x, w) a[i][x]=a[i-1][x];
        }
        else{
            int next = id;
            rep(j,w){
                if(s[i][j]=='#') next=id++;
                a[i][j]=next;
            }
        }
    }
    for() {
        if(a[i][0]==0){
            rep(j,w) a[i][j] = a[i+1][j];
        }
    }
    rep(i,h) {
        rep(j,w) cout << a[i][j] <<" ";
        cout << endl;
    }

    return 0;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:30:9: error: expected primary-expression before ')' token
   30 |     for() {
      |         ^
a.cc:3:18: error: expected primary-expression before 'for'
    3 | #define rep(i,n) for(int i=0; i<(n); i++)
      |                  ^~~
a.cc:35:5: note: in expansion of macro 'rep'
   35 |     rep(i,h) {
      |     ^~~
a.cc:34:6: error: expected ';' before 'for'
   34 |     }
      |      ^
      |      ;
a.cc:3:18: error: expected primary-expression before 'for'
    3 | #define rep(i,n) for(int i=0; i<(n); i++)
      |                  ^~~
a.cc:35:5: note: in expansion of macro 'rep'
   35 |     rep(i,h) {
      |     ^~~
a.cc:34:6: error: expected ')' before 'for'
   34 |     }
      |      ^
      |      )
a.cc:30:8: note: to match this '('
   30 |     for() {
      |        ^
Language: C++


                for(int u=0;u<j;u++)
                    dp[u][i]=dp[j][i];
                break;
            }
        }
    }
    for(int i=0; i<w; i++)
    {
        for(int j=0; j<h; j++)
        {
            if(dp[j][i]==0)
                dp[j][i]=dp[j-1][i];
        }
    }


    for(int i=0; i<h; i++)
    {
        for(int j=0; j<w; j++)
        {
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }


    return 0;
}


Compiler output:
a.cc:2:17: error: expected unqualified-id before 'for'
    2 |                 for(int u=0;u<j;u++)
      |                 ^~~
a.cc:2:29: error: 'u' does not name a type
    2 |                 for(int u=0;u<j;u++)
      |                             ^
a.cc:2:33: error: 'u' does not name a type
    2 |                 for(int u=0;u<j;u++)
      |                                 ^
a.cc:4:17: error: expected unqualified-id before 'break'
    4 |                 break;
      |                 ^~~~~
a.cc:5:13: error: expected declaration before '}' token
    5 |             }
      |             ^
a.cc:6:9: error: expected declaration before '}' token
    6 |         }
      |         ^
a.cc:7:5: error: expected declaration before '}' token
    7 |     }
      |     ^
a.cc:8:5: error: expected unqualified-id before 'for'
    8 |     for(int i=0; i<w; i++)
      |     ^~~
a.cc:8:18: error: 'i' does not name a type
    8 |     for(int i=0; i<w; i++)
      |                  ^
a.cc:8:23: error: 'i' does not name a type
    8 |     for(int i=0; i<w; i++)
      |                       ^
a.cc:18:5: error: expected unqualified-id before 'for'
   18 |     for(int i=0; i<h; i++)
      |     ^~~
a.cc:18:18: error: 'i' does not name a type
   18 |     for(int i=0; i<h; i++)
      |                  ^
a.cc:18:23: error: 'i' does not name a type
   18 |     for(int i=0; i<h; i++)
      |                       ^
a.cc:28:5: error: expected unqualified-id before 'return'
   28 |     return 0;
      |     ^~~~~~
a.cc:29:1: error: expected declaration before '}' token
   29 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll h,w,k;
cin>>h>>w>>k;
string s[h]={};
ll a[n]={};
ll b[w]={};
ll ca=1;
for(ll i=0; i<h; i++){
cin>>s[i];}
for(ll i=0; i<h; i++){
for(ll j=0; j<w; j++){
if(s[i].at(j)=='#')
a[i]++;}}
ll y = 0;
for(ll i=0; i<h; i++){
if(a[i]!=0){
y=i;
break;}}
ll x =0;
for(ll i=h-1; i>=0; i--){
if(a[i]!=0){
x=i;
break;}}
for(ll i=y; i<h-x; i++){
if(a[i]==0){
y++;
continue;}
else{
for(ll j=0; j<w; j++){
if(s[i].at(j)=='#'){
ca++;}
b[j]=ca;}
for(ll n=0; n<=y; n++){
for(ll m=0; m<w; m++){
cout << b[m] << " ";}
cout << endl;}
y=0;}}
for(ll i=0; i<x; i++){
for(ll j=0; j<w; j++){
cout << b[j] << " ";}
cout << endl;}}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:6: error: 'n' was not declared in this scope
   23 | ll a[n]={};
      |      ^
a.cc:31:1: error: 'a' was not declared in this scope
   31 | a[i]++;}}
      | ^
a.cc:34:4: error: 'a' was not declared in this scope
   34 | if(a[i]!=0){
      |    ^
a.cc:39:4: error: 'a' was not declared in this scope
   39 | if(a[i]!=0){
      |    ^
a.cc:43:4: error: 'a' was not declared in this scope
   43 | if(a[i]==0){
      |    ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int h,w,k;
    cin>>h>>w>>k;
  vector<string> s(h); // 0ind
  int cake[h][w]; // 0ind
  rep(i,0,h){
    rep(j,0,w){
      cake[i][j]=-1; 
    }
  }
  vector<P> place(k+1); //イチゴは 1ind
  rep(i,0,h) cin>>s[i];
  int num=1;
  rep(i,0,h){
    rep(j,0,w){
          if(s[i][j]=='#') {
            cake[i][j]=num;
            place[num]=mp(i,j);
            num++;
          }
    }
  }
  rep(i,1,k+1){
    int ih,iw;
    ih=place[i].first;
    iw=place[i].second;
    int iw2=iw;
    while(iw>0){
      if(cake[ih][iw-1]!=-1) break;
      iw--;
      cake[ih][iw]=i;
    }
    while(iw2<w){
      if(iw2+1==w)break;
      if(cake[ih][iw2+1]!=-1) break;
      iw2++;
      cake[ih][iw]=i;
    }
    
    cout<<iw<<" "<<iw2<<endl;
    
    
    
    
    
    
    
    
    
    nnnnnnnnnnnnnn
    
  }
  
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:66:5: error: 'nnnnnnnnnnnnnn' was not declared in this scope
   66 |     nnnnnnnnnnnnnn
      |     ^~~~~~~~~~~~~~
Language: C++


#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template <class _T> static _T tp_abs(const _T& a) {
	//	usage:  tp_abs<type name>(a);
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}

static void Disco2020C();

#if 1
int main()
{
	Disco2020C();
	fflush(stdout);
	return 0;
}
#endif

static int Disco2020C_dfs(
	std::vector<std::string>& grid,
	int startH, int startW,
	int H, int W,
	std::vector<std::vector<int>>& blkGrid,
	int blockNo)
{
	int berry = 0;
	std::vector<std::pair<int, int>> bPos(2, std::pair<int, int>(0, 0));

	for (int h = startH; h < H; h++) {
		for (int w = startW; w < W; w++) {
			if (grid[h][w] == '#') {
				bPos[berry].first = h;
				bPos[berry].second = w;
				berry++;
			}
			if (berry >= 2) break;
		}
		if (berry >= 2) break;
	}

	int sh1, sh2, sw1, sw2;
	int eh1, eh2, ew1, ew2;
	sh1 = sh2 = sw1 = sw2 = eh1 = eh2 = ew1 = ew2 = 0;

	if (berry == 1) {
		for (int h = startH; h < H; h++) {
			for (int w = startW; w < W; w++) {
				blkGrid[h][w] = blockNo;
			}
		}
		blockNo++;
	}
	else if (bPos[0].first == bPos[1].first) {
		sh1 = sh2 = startH;
		eh1 = eh2 = H;
		sw1 = startW;
		sw2 = tp_max(bPos[0].second, bPos[1].second);
		ew1 = sw2;
		ew2 = W;

	}
	else {
		sh1 = startH;
		sh2 = tp_max(bPos[0].first, bPos[1].first);
		eh1 = sh2;
		eh2 = H;
		sw1 = sw2 = startW;
		ew1 = ew2 = W;
	}
	
	if(berry >= 2) {
		blockNo = Disco2020C_dfs(grid, sh1, sw1, eh1, ew1, blkGrid, blockNo);
		blockNo = Disco2020C_dfs(grid, sh2, sw2, eh2, ew2, blkGrid, blockNo);
	}

	return blockNo;
}


Compiler output:
a.cc:63:13: warning: 'void Disco2020C()' used but never defined
   63 | static void Disco2020C();
      |             ^~~~~~~~~~
/usr/bin/ld: /tmp/ccTBsift.o: in function `main':
a.cc:(.text+0x45): undefined reference to `Disco2020C()'
collect2: error: ld returned 1 exit status
Language: C++

H, W, K = map(int, input().split())
grid = 'x' * (W + 2)
for _ in range(H):
    grid += 'x' + input() + 'x'
grid += 'x' * (W + 2)

strb = [i for i in range(len(grid)) if grid[i] == '#']
G = [0] * len(grid)

for i, s in enumerate(strb, 1):
    q = [s]
    while q:
        x = q.pop()
        G[x] = i
        for dx in [1, -1]:
            y = x + dx
            if grid[y] == '.' and G[y] == 0:
                q.append(y)

j = 0
for i in range(H):
    print(' '.join(str(x) for x in G[j + W + 3:j + 2 * W + 3]))
    j += W + 2


Compiler output:
a.cc:1:1: error: 'H' does not name a type
    1 | H, W, K = map(int, input().split())
      | ^
Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i, h) cin >> s[i];

  vector<vector<int>> ans(h, vector<int>(w));
  int num = 1;
  rep(i, h) rep(j, w) {
    if(s[i][j] == '#') {
      ans[i][j] = num;
      num++;
    }
  }
  rep(ri, 2) {
    rep(i, h) {
    int pre = 0;
      rep(j, w) {
        if(ans[i][j] > 0) pre = ans[i][j];
        ans[i][j] = pre;
      }
      reverse(ans[i].begin(), ans[i].end());
    }
  }


  vector<int> pre = h[0];
  for (int i = 1; i < h; ++i) {
    if(ans[i][0] == 0) {
      ans[i] = pre;
    }
    pre = ans[i];
  }
  pre = ans[h - 1];
  for(int i = h - 2; i >= 0; --i) {
    if(ans[i][0] == 0) ans[i] = pre;
    pre = ans[i];
  }

  rep(i, h) {
    rep(j, w) printf("%d%c", ans[i][j], (j == w - 1 ? '\n' : ' '));
  }

}

Compiler output:
a.cc: In function 'int main()':
a.cc:54:22: error: invalid types 'int[int]' for array subscript
   54 |   vector<int> pre = h[0];
      |                      ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll> 
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

void print_vec(const lvector v) {
  for(auto i:v) cout << i << " ";
  cout << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll h,w,k;cin>>h>>w>>k;
  string s;
  lvector yoko(w,0);vector<lvector> c(h,yoko);
  vector<lvector> ans(c);
  rep(i,h) {
    cin>>s;
    rep(j,w) if(s[j]=='#') c[i][j]=1;
  }
  ll cnt=1,num=1;
  for(ll tate=0;tate<h;tate++) {
    lvector yoko_=c[tate];
    ll sum_of_yoko=accumulate(ALL(yoko_),0);
    if(sum_of_yoko==0) {
      cnt++;continue;
    }
    ll pos=0,pos_prev=0,yoko_cnt=0;
    while(pos<w) {
      if(yoko_[pos]==1) {
        for(ll t_=tate+1-cnt; t_<=tate; ++t_) {
          if(yoko_cnt<sum_of_yoko-1) {
            for(ll y_=pos_prev;y_<=pos;++y_) ans[t_][y_]=num;
            yoko_cnt++;
          }
          else for(ll y_=pos_prev;y_<w;++y_) ans[t_][y_]=num;
        }
        pos++;pos_prev=pos;num++;
      }
      else pos++;
    }
    cnt=1;
  }
  for(ll i=0;i<h;++i) {
    if(accumulate(ALL(ans[i]),0)==0) {
      if(i==h-1) ans[i]+=ans[i-1];
      else ans[i]+=ans[i+1];
    }
  }
  for(lvector i:ans) print_vec(i);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:54:24: error: no match for 'operator+=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::vector<long long int> >, std::vector<long long int> >::value_type' {aka 'std::vector<long long int>'} and '__gnu_cxx::__alloc_traits<std::allocator<std::vector<long long int> >, std::vector<long long int> >::value_type' {aka 'std::vector<long long int>'})
   54 |       if(i==h-1) ans[i]+=ans[i-1];
a.cc:55:18: error: no match for 'operator+=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::vector<long long int> >, std::vector<long long int> >::value_type' {aka 'std::vector<long long int>'} and '__gnu_cxx::__alloc_traits<std::allocator<std::vector<long long int> >, std::vector<long long int> >::value_type' {aka 'std::vector<long long int>'})
   55 |       else ans[i]+=ans[i+1];
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll> 
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

void print_vec(const lvector v) {
  for(auto i:v) cout << i << " ";
  cout << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll h,w,k;cin>>h>>w>>k;
  string s;
  lvector yoko(w,0);vector<lvector> c(h,yoko);
  vector<lvector> ans(c);
  rep(i,h) {
    cin>>s;
    rep(j,w) if(s[j]=='#') c[i][j]=1;
  }
  ll cnt=1,num=1;
  for(ll tate=0;tate<h;tate++) {
    lvector yoko_=c[tate];
    ll sum_of_yoko=accumulate(ALL(yoko_),0);
    if(sum_of_yoko==0) {
      cnt++;continue;
    }
    ll pos=0,pos_prev=0,yoko_cnt=0;
    while(pos<w) {
      if(yoko_[pos]==1) {
        for(ll t_=tate+1-cnt; t_<tate+cnt; ++t_) {
          if(yoko_cnt<sum_of_yoko-1) {
            for(ll y_=pos_prev;y_<=pos;++y_) ans[t_][y_]=num;
            yoko_cnt++;
          }
          else for(ll y_=pos_prev;y_<w;++y_) ans[t_][y_]=num;
        }
        pos++;pos_prev=pos;num++;
      }
      else pos++;
    }
    cnt=1;
  }
  for(ll i=0;i<h;++i) {
    if(accumulate(ALL(ans[i]),0)==0) {
      if(i==h-1) ans[i]+=ans[i-1];
      else ans[i]+=ans[i+1];
    }
  }
  for(lvector i:ans) print_vec(i);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:54:24: error: no match for 'operator+=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::vector<long long int> >, std::vector<long long int> >::value_type' {aka 'std::vector<long long int>'} and '__gnu_cxx::__alloc_traits<std::allocator<std::vector<long long int> >, std::vector<long long int> >::value_type' {aka 'std::vector<long long int>'})
   54 |       if(i==h-1) ans[i]+=ans[i-1];
a.cc:55:18: error: no match for 'operator+=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::vector<long long int> >, std::vector<long long int> >::value_type' {aka 'std::vector<long long int>'} and '__gnu_cxx::__alloc_traits<std::allocator<std::vector<long long int> >, std::vector<long long int> >::value_type' {aka 'std::vector<long long int>'})
   55 |       else ans[i]+=ans[i+1];
Language: C++

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;
#define pow10(n) int(1e##n + n)

int H, W, K, ans[301][301], cnt[301], index;
char s[301][301];

void cut(int h1, int h2)
{
    // いちごのある列
    vector<int> vec;
    FOR (h, h1, h2 + 1)
    {
        REP1 (w, W)
        {
            if (s[h][w] == '#')
                vec.push_back(w);
        }
    }
    sort(vec.begin(), vec.end());
    int V = vec.size();

    REP0 (i, V)
    {
        int w1 = 1, w2 = W;
        if (i >= 1)
            w1 = vec[i - 1] + 1;
        if (i < V - 1)
            w2 = vec[i];
        index++;
        FOR (h, h1, h2 + 1)
        {
            FOR (w, w1, w2 + 1)
            {
                ans[h][w] = index;
            }
        }
    }
}

void solve()
{
    cin >> H >> W >> K;
    REP1 (h, H)
    {
        REP1 (w, W)
        {
            cin >> s[h][w];
            if (s[h][w] == '#')
                cnt[h]++;
        }
    }

    // いちごのある行
    vector<int> vec;
    REP1 (h, H)
    {
        if (cnt[h] >= 1)
            vec.push_back(h);
    }

    int V = vec.size();

    REP0 (i, V)
    {
        // いちごが一行に集中するような形で
        // 行 h1 から h2 までここで横に切って、
        // そのあとに縦方向に切る(cut(h1,h2))
        int h1 = 1, h2 = H;
        if (i >= 1)
            h1 = vec[i - 1] + 1;
        if (i < V - 1)  // 最後の切り方は最終行であるようにするための条件
            h2 = vec[i];

        cut(h1, h2);
    }

    REP1 (h, H)
    {
        REP1 (w, W)
        {
            cout << ans[h][w];
            if (w < W - 1)
                cout << ' ';
        }
        cout << endl;
    }
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


Compiler output:
a.cc:17:39: error: 'int index' redeclared as different kind of entity
   17 | int H, W, K, ans[301][301], cnt[301], index;
      |                                       ^~~~~
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'void cut(int, int)':
a.cc:42:14: error: no post-increment operator for type
   42 |         index++;
      |              ^~
a.cc:47:29: error: cannot resolve overloaded function 'index' based on conversion to type 'int'
   47 |                 ans[h][w] = index;
      |                             ^~~~~
Language: C++

h,w,k = map(int, input().split())
grid = []
cake = []
for i in range(h):
    s = input()
    grid.append(s)
    cake.append(s.count('#'))
num = 0

ans = [[0 for j in range(w)] for i in range(h)]
first = []

for i in range(h):
    if cake[i] == 0 and first == []:
        continue
    if cake[i]:
        num += 1
        cnt = 0
        for j in range(w):
            ans[i][j] = num
            if grid[i][j] == '#':
                cnt += 1
                if cnt < cake[i]:
                    num += 1
        if first == []:
            for j in range(w):
                first.append(ans[i][j])
    else:
        for j in range(w):
            ans[i][j] = ans[i-1][j]

for i in range(h):
    if ans[i][0] != 0:
        continue
    for j in range(w):
        ans[i][j] = first[j]
[print(*i) for i in ans]


Compiler output:
a.cc:1:1: error: 'h' does not name a type
    1 | h,w,k = map(int, input().split())
      | ^