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

#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;
int dp[1000001],Odp[1000001];
int Tn[200],OTn[200]; 

int main(){
    int count = 0;  //pollocks numberの生成
    for(int i = 1;i < 200;i++){
        Tn[i-1] = i * (i + 1) * (i + 2) / 6;
        if(Tn[i-1] % 2 == 1){
            OTn[count] = Tn[i-1];
            count++;
        }
    }
    int n = 1000000;

    //正四面体数の個数の最小値
    for(int j = 0;j <= n;j++)
        dp[j] = j;
    int k;
    for(int i = 0;i < 200;i++)
        for(int j = Tn[i];j <= 1000000;j++){
            if(j >= Tn[i])
                dp[j] = min(dp[j],dp[j-Tn[i]] + 1);
            k = i;
        }

    //奇数正四面体数の個数の最小値
    for(int j = 0;j <= n;j++)
        Odp[j] = j;
    int k1;
    for(int i = 0;i <= 200;i++)
        for(int j = OTn[i];j <= n;j++){
            if(j >= OTn[i])
                Odp[j] = min(Odp[j],Odp[j-OTn[i]] + 1);
            k1 = i;
        }
    while(cin >> n,n)
        cout << dp[k][n] << ' ' <<  Odp[k1][n] << endl;


    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:22: error: invalid types 'int[int]' for array subscript
   41 |         cout << dp[k][n] << ' ' <<  Odp[k1][n] << endl;
      |                      ^
a.cc:41:44: error: invalid types 'int[int]' for array subscript
   41 |         cout << dp[k][n] << ' ' <<  Odp[k1][n] << endl;
      |                                            ^
Language: C++

#include <iostream>
#define MAX 1000000
#define INF 1000000000
using namespace std;

int dp1[MAX+1],dp2[MAX+1];

int main(){
    //INFで初期化
    for(int i = 1;i <= MAX;i++){
        dp1[i] = INF;
        dp2[i] = INF;
    }

    for(int n = 1;n * (n + 1) * (n * 2) /6 <= MAX;n++){
        int a = n * (n + 1) * (n + 2) / 6;  //ポロック数の生成
        for(int i = a;i <= MAX;i++){     //正四面体数の個数dp(a以下は必要ない)
            dp1[i] = min(dp1[i],dp1[i-a] + 1);  //更新しないor左側から更新する

        if(a % 2 == 0)continue;     //偶数の時は次のroopへ
        for(int i = a;i <= MAX;i++){     //奇数の正四面体数の個数dp(a以下は必要ない)
            dp2[i] = min(dp2[i],dp2[i-a] + 1);  //更新しないor左側から更新する
        }
    }

    //入出力
    while(true){
        int n;
        cin >> n;
        if(n == 0)break;
        cout << dp1[n] << " " << dp2[n] << endl;
    }

    return 0;
}


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

#include <iostream>
using namespace std;

#define MAX 1000000
#define INF 1000000000

int dp1[MAX], dp2[MAX];

int main()
{
    for (int i = 1; i <= MAX; i++)
    {
        dp1[i] = INF;
        dp2[i] = INF;
    }
    for (int n = 1; n * (n + 1) * (n + 2) / 6 <= MAX; n++)
    {
        int a = n * (n + 1) * (n + 2) / 6;
        for (int i = a; i <= MAX; i++)
        {
            dp1[i] = min(dp1[i], dp1[i - a]);
        }
        if (a % 2 == 0)
            continue;
        for (int i = a; i <= MAX; i++)
        {
            dp2[i] = min(dp2[i], dp2[i - a]);
        }
    }
    while (1)
    {
        cin >> n;
        if (n == 0)
            break;
        cout << dp1[n] << " " << dp2[n] << endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:16: error: 'n' was not declared in this scope
   32 |         cin >> n;
      |                ^
Language: C++

#include <iostream>

using namespace std;

int main() {
	int N;
	int v[200];
	static int ansA[1000000], ansB[1000000];
	for (int i = 0; i<=200; i++) v[i] = i * (i + 1)*(i + 2) / 6;
	ansA[0] = ansB[0] = 0;
	for (int i = 1; i<1000000; i++) {
		ansA[i] = ansB[i] = i;
		for (int j = 0; i - v[j] >= 0; j++) {
			ansA[i] = min(ansA[i], A[i - v[j]] + 1);
			if (v[j] % 2 == 1)
				ansB[i] = min(ansB[i], ansB[i - v[j]] + 1);
		}
	}
	while (cin >> N, N)
		cout << ansA[N] << " " << ansB[N] << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:48: error: 'A' was not declared in this scope
   14 |                         ansA[i] = min(ansA[i], A[i - v[j]] + 1);
      |                                                ^
Language: C++

#include<iostream>
#include<queue>
#include<utility>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
typedef pair<int,int> pi;

const int inf=1<<28;
const int MX=1000000;

int tri[1000],ntri;
int dp[MX],dpOdd[MX];

int main(){
	
	ntri=0;
	for(;;ntri++)
	{
		tri[ntri]=ntri*(ntri+1)*(ntri+2)/6;
		if(tri[ntri]>=MX)break;
	}
	
	dbg(ntri);
	
	rep(i,MX)dp[i]=dpOdd[i]=inf;
	dp[0]=dpOdd[0]=0;
	int mx=0;
	rep(i,5)rep(j,mx+1)
	{
		rep(k,ntri)
		{
			if(j+tri[k]>=MX)break;
			if(tri[k]%2==1)dpOdd[j+tri[k]]=min(dpOdd[j+tri[k]],dpOdd[j]+1);
			dp[j+tri[k]]=min(dp[j+tri[k]],dp[j]+1);
			mx=max(mx,j+tri[k]);
			mx=min(mx,MX-1);
		}
	}
	
	int n;
	while(cin>>n,n)cout<<dp[n]<<" "<<dpOdd[n]<<endl;
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:9: error: 'dbg' was not declared in this scope
   25 |         dbg(ntri);
      |         ^~~
Language: C++

#include<stdio.h>
#include<math.h>
#define MAX (int)1e+6

int main(void){
  int i,j,n;
  int a[181],b[46];
  int dp1[MAX],dp2[MAX];

  b[0] = 0;
  j = 1;
  for(i=0;i<181;i++){
    a[i] = i * (i+1) * (i+2) / 6;
    if(a[i]&1)b[j++] = a[i];
  }

  for(i=0;i<MAX;i++)dp1[i] = dp2[i] = 1000000;

  for(i=0;i<MAX;i++){
    for(j=0;j<181;j++){
      if(i>a[j])dp1[i] = min(dp1[i],dp1[i-a[j]]+1);
      else if(i==a[j])dp1[i]=1;
      else break;
    }
  }
  
  for(i=0;i<MAX;i++){
    for(j=0;j<46;j++){
      if(i>b[j])dp2[i] = min(dp2[i],dp2[i-b[j]]+1);
      else if(i==b[j])dp2[i]=1;
      else break;
    }
  }

  while(scanf("%d",&n) && n)printf("%d %d\n",dp1[n],dp2[n]);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:26: error: 'min' was not declared in this scope; did you mean 'std::min'?
   21 |       if(i>a[j])dp1[i] = min(dp1[i],dp1[i-a[j]]+1);
      |                          ^~~
      |                          std::min
In file included from /usr/include/c++/14/bits/specfun.h:43,
                 from /usr/include/c++/14/cmath:3906,
                 from /usr/include/c++/14/math.h:36,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: 'std::min' declared here
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
a.cc:29:26: error: 'min' was not declared in this scope; did you mean 'std::min'?
   29 |       if(i>b[j])dp2[i] = min(dp2[i],dp2[i-b[j]]+1);
      |                          ^~~
      |                          std::min
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: 'std::min' declared here
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
Language: C++

#include <iostream>
#include <cmath>

using namespace std;

int f[1000000];

int main()
{
	int t_num[182];
	int t_num_odd[182];
	
	int k=0;
	for (int i=1;i<182;++i)
	{
		t_num[i-1] = i*(i+1)*(i+2)/6;
		if (t_num[i-1] % 2 == 1)
		{
			t_num_odd[k] = t_num[i-1];
			++k;
		}		
	}
	
	int n;
	cin >> n;
	
	while (n)
	{
		memset(f,1000001,sizeof(f));
		f[0] = 0;
		for (int i=1;i<=n;++i)
		{
			for (int j=0;j<181;++j)
			{
				if (i>=t_num[j]) f[i] = min(f[i],f[i-t_num[j]]+1);
			}
		}
		cout << f[n] << " ";
		
		memset(f,1000001,sizeof(f));
		f[0] = 0;
		for (int i=1;i<=n;++i)
		{
			for (int j=0;j<k;++j)
			{
				if (i>=t_num_odd[j]) f[i] = min(f[i],f[i-t_num_odd[j]]+1);
			}
		}
		cout << f[n] << endl;
		
		cin >> n;
		
		
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:17: error: 'memset' was not declared in this scope
   29 |                 memset(f,1000001,sizeof(f));
      |                 ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <cmath>
  +++ |+#include <cstring>
    3 |
Language: C++

#define INF 0x7FFFFFFF

int main(void){
	int i, j, k, n, min1;
	int dp[1000001];
	scanf("%d",&n);
	while(n != 0){
		for(i = 0;i <= n;i++)
			dp[i] = INF;
		dp[0] = 0;
		for(k = 0;k < n;k++){
			for(i = n;i >= 0;i--){
				if(dp[i] != INF){
					for(j = 1;(j * (j + 1) * (j + 2)) / 6 + i <= n;j++){
						if(dp[(j * (j + 1) * (j + 2)) / 6 + i] > dp[i] + 1)
							dp[(j * (j + 1) * (j + 2)) / 6 + i] = dp[i] + 1;
					}
				}
			}
			if(dp[n] == 1)
				break;
		}

		min1 = dp[n];
		for(i = 0;i <= n;i++)
			dp[i] = INF;
		dp[0] = 0;
		for(k = 0;k < n;k++){
			for(i = n;i >= 0;i--){
				if(dp[i] != INF){
					for(j = 1;(j * (j + 1) * (j + 2)) / 6 + i <= n;j++){
						if(dp[(j * (j + 1) * (j + 2)) / 6 + i] > dp[i] + 1 && j * (j + 1) * (j + 2) / 6 % 2 == 1)
							dp[(j * (j + 1) * (j + 2)) / 6 + i] = dp[i] + 1;
					}
				}
			}
			if(dp[n] == 1)
				break;
		}
		printf("%d %d\n",min1,dp[n]);
		scanf("%d",&n);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:9: error: 'scanf' was not declared in this scope
    6 |         scanf("%d",&n);
      |         ^~~~~
a.cc:40:17: error: 'printf' was not declared in this scope
   40 |                 printf("%d %d\n",min1,dp[n]);
      |                 ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | #define INF 0x7FFFFFFF
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int main(void)
{
	int n;
	int i1,i2;
	int nn;
	int p;
	int min;
	int num;

	while(1){
		cin >> n;
		if(n==0) break;

		vector<int> pollock(n+1,0);
		vector<int> pollock2(n+1,0);
		vector<int> p;
		vector<int> p2;
		nn=1;
		num=(nn*(nn+1)*(nn+2))/6);

		for(i1=1;i1<=n;i1++){			

			if(i1==num) {
				if(i1%2==1){
					p.push_back(i1);
					p2.push_back(i1);
					nn++;
					num=(nn*(nn+1)*(nn+2))/6);
					pollock[i1]=1;
					pollock2[i1]=1;
				}
				else {
					nn++;
					num=(nn*(nn+1)*(nn+2))/6);
					p.push_back(i1);
					pollock[i1]=1;
					min=100000;
					for(i2=0;i2<p2.size();i2++){
						if((pollock2[i1-p2[i2]])<min){
							min=pollock2[i1-p2[i2]];
						}
					}
					pollock2[i1]=min+1;
				}
			}
			else {
				min=100000;
				for(i2=0;i2<p.size();i2++){
					if((pollock[i1-p[i2]])<min){
						min=pollock[i1-p[i2]];
					}
				}
				pollock[i1]=min+1;

				min=100000;
				for(i2=0;i2<p2.size();i2++){
					if((pollock2[i1-p2[i2]])<min){
						min=pollock2[i1-p2[i2]];
					}
				}
				pollock2[i1]=min+1;
			}
			//cout<<pollock[i1]<<" ";

		}

		cout << pollock[n] << " " << pollock2[n] << endl;
		

	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:41: error: expected ';' before ')' token
   24 |                 num=(nn*(nn+1)*(nn+2))/6);
      |                                         ^
      |                                         ;
a.cc:33:65: error: expected ';' before ')' token
   33 |                                         num=(nn*(nn+1)*(nn+2))/6);
      |                                                                 ^
      |                                                                 ;
a.cc:39:65: error: expected ';' before ')' token
   39 |                                         num=(nn*(nn+1)*(nn+2))/6);
      |                                                                 ^
      |                                                                 ;
Language: C++

#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define X first
#define Y second
using namespace std;
int index;
int fourth[201];
int odd[201];
int mintable[1500000];
int mintableOdd[1500000];

void init(){
	fourth[0] = 0;
	odd[0] = 0;
	index = 0;
	for(int i = 1; i <= 200; i++){
		fourth[i] = (i*(i+1)*(i+2))/6;
		mintable[fourth[i]] = 1;
		if(fourth[i]%2){
			odd[++index] = fourth[i];
			mintableOdd[odd[index]] = 1;
		}
	}
}

int dfs(int n){
	for(int i = 2; i <= n/i; i++){
		if(n%i==0){
			return min(dfs(n/i)*i, mintable[n]);
		}
	}
	return mintable[n];
}

int dfsOdd(int n){
	for(int i = 3; i <= n/i; i+=2){
		if(n%i==0){
			return min(dfsOdd(n/i)*i, mintableOdd[n]);
		}
	}
	return mintableOdd[n];
}

int countFourth(int n){
	int min = 10000;
	for(int i = 200; i >= 1; i--){
		if(n>=fourth[i]){
			int tmp = n;
			int count = 0;
			for(int j = i; j >= 1; j--){
				while(tmp>=fourth[j]){
					count++;
					tmp -= fourth[j];
				}
			}
			min = min>count?count:min; 
		}
	}
	return min;
}

int countFourthOdd(int n){
	int min = 10000;
	for(int i = index; i >= 1; i--){
		if(n>=odd[i]){
			int tmp = n;
			int count = 0;
			for(int j = i; j >= 1; j--){
				while(tmp>=odd[j]){
					count++;
					tmp -= odd[j];
				}
			}
			min = min>count?count:min; 
		}
	}
	return min;
}

int main(){
	memset(mintable, 0, sizeof(mintable));
	init();
	int n = 0;
	while(cin >> n && n != 0){
		for(int i = 1; i <= n; i++){
			if(mintable[i]&&mintableOdd[i]) continue;		
			mintable[i] = countFourth(i);
			mintable[i] = dfs(i);
			mintableOdd[i] = countFourthOdd(i);
			mintableOdd[i] = dfsOdd(i);
		}
		cout << mintable[n] << " " << mintableOdd[n] << endl;
	}
	return 0;
}

Compiler output:
a.cc:16:5: error: 'int index' redeclared as different kind of entity
   16 | int index;
      |     ^~~~~
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from a.cc:11:
/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 init()':
a.cc:25:17: error: overloaded function with no contextual type information
   25 |         index = 0;
      |                 ^
a.cc:30:31: error: no pre-increment operator for type
   30 |                         odd[++index] = fourth[i];
      |                               ^~~~~
a.cc:31:40: error: invalid types 'int [201][<unresolved overloaded function type>]' for array subscript
   31 |                         mintableOdd[odd[index]] = 1;
      |                                        ^
a.cc: In function 'int countFourthOdd(int)':
a.cc:74:21: error: cannot resolve overloaded function 'index' based on conversion to type 'int'
   74 |         for(int i = index; i >= 1; i--){
      |                     ^~~~~
Language: C++

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

using namespace std;

int MAX;
vector<int> V;
vector<int> D;
int N;
int M;
bool dp[10][100000] = {0};

void solve(int n) {
	int ans = 1;

	for (int i=0; V[i]<=n; i++)
		dp[0][V[i]] = 1;

	for (int i=1; i<5 && !dp[i-1][n]; i++) {
		ans++;
		for (int j=0; j<=n; j++) {
			if (!dp[i-1][j]) continue;
			for (int k=0; j+V[k]<=n; k++)
				dp[i][j+V[k]] = 1;
			if (dp[i][n]) break;
		}
	}

	cout << ans << " ";

	memset(dp, 0, sizeof(dp));

	ans = 1;

	for (int i=0; D[i]<=n; i++)
		dp[0][D[i]] = 1;

	for (int i=1; i<=100000 && !dp[1-i%2][n]; i++) {
		ans++;
		for (int j=0; j<=n; j++) {
			//dp[i%2][j] = 0;
			if (!dp[1-i%2][j]) continue;
			for (int k=0; j+D[k]<=n; k++)
				dp[i%2][j+D[k]] = 1;
			if (dp[i%2][n]) break;
		}
	}

	cout << ans << endl;
}

int main() {
	MAX = (int)pow(10.0, 6);
	for (int i=1; i*(i+1)*(i+2)/6<=MAX; i++) {
		V.push_back(i*(i+1)*(i+2)/6);
		if ( V[i-1]%2==1 ) D.push_back(i*(i+1)*(i+2)/6);
	}
	N = (int)V.size();
	M = (int)D.size();

	int n;
	cin >> n;
	while (n!=0) { 
		solve(n);
		cin >> n;
	}
	return 0;
}

Compiler output:
a.cc: In function 'void solve(int)':
a.cc:32:9: error: 'memset' was not declared in this scope
   32 |         memset(dp, 0, sizeof(dp));
      |         ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <cmath>
  +++ |+#include <cstring>
    4 |
Language: C++

#include <iostream>
#include <algorithm>

#define MAXNUM 1000000
#define MAX 100
using namespace std;

int all[MAXNUM], odd[MAXNUM], fourall[MAXNUM], fourodd[MAXNUM];


int _tmain(int argc, _TCHAR* argv[])
{
	int n;
	int counter = 0;
	for (int i = 1; i < MAXNUM; i++){
		all[i] = MAX;
		odd[i] = MAX;

	}

	//1からMAXNUMまでの中に存在する正四面体数を洗い出す．
	int now = 0, four, allcounter = 0, oddcounter = 0;
	while (1){
		now++;
		four = now  *(now + 1)*(now + 2) / 6;
		all[four] = 1;
		fourall[allcounter++] = four;
		if (four % 2 == 1){
			odd[four] = 1;
			fourodd[oddcounter++] = four;
		}
		if (four > MAXNUM)
			break;
	}
	//cout << fourall[allcounter - 1] << endl;
	//cout << "ok" << endl;
	//cout << allcounter << endl;

	//1からMAXNUMまで，配列を埋める.
	for (int i = 1; i <= MAXNUM; i++){
		for (int j = 0; i > fourall[j]; j++){
			all[i] = min(all[i], 1 + all[i - fourall[j]]);
		}
			//cout << i << ":" << all[i]<<endl;

		for (int j = 0; i > fourodd[j]; j++){
			odd[i] = min(odd[i], 1 + odd[i - fourodd[j]]);
		}

	}

	//cout << "aaa" << endl;


	//入力
	while (cin >> n, n)
		cout << all[n] << " " << odd[n] << endl;

	return 0;

}

Compiler output:
a.cc:11:22: error: '_TCHAR' has not been declared
   11 | int _tmain(int argc, _TCHAR* argv[])
      |                      ^~~~~~
Language: C++

#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<functional>
#define rep(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
using namespace std;
#define ull unsigned long long
int memo[150];
int  dp[1000002];
int  dp2[1000002];
void inset(){
	dp[0]=0;
	fill(dp,dp+1000001,10000);
	fill(dp2,dp2+1000001,10000);
	dp[0]=0;
	dp2[0]=0;
	rep(i,1,150){
		memo[i]=i*(i+1)*(i+2),memo[i]/=6;
		rep(j,1,1000001)
			if(j-memo[i]>=0){
		if(dp[j]>dp[j-memo[i]]+1)dp[j]=dp[j-memo[i]]+1;
		if(memo[i]&1)if(dp2[j]>dp2[j-memo[i]]+1)dp2[j]=dp2[j-memo[i]]+1;
		}
	}
	//rep(i,1,1000001){
	//	if(dp2[i]==0){
	//	printf("[%d]%d\n",i,dp2[i]);
	//	break;
	//	}
	}
}


int main(void){
	inset();
	int x;
	while(true){
		cin>>x;if(x==0)return(0);
		cout<<dp[x]<<" "<<dp2[x]<<endl;
	}

}

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

#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;

#define REP_N(i,n,s) for(ll i=0; i<(ll)n; i+=s)
#define REP(i,n) REP_N(i,n,1)

ll table[1000000];
ll pollock[1000001];
ll dp[1000001];

void solution(ll output[1000001], int interval) {
	output[0] = 0;
	ll current_i = interval-1;
	REP(i, 1000001) if(i!=0) {
		ll minimum = 1000001;
		REP(j, current_i+1, interval) if(j!=0) minimum = min(output[i - table[j]] + 1, minimum);
		output[i] = minimum;

		if (table[current_i + interval] == i) current_i += interval;
	}
}

int main() {
	//freopen("Text.txt", "r", stdin);
	
	{
		ll i = 0;
		table[0] = 0;
		while (1000001 > table[i++]) table[i] = i*(i + 1)*(i + 2) / 6;
	}

	solution(pollock, 1);
	solution(dp, 4);

	while (true) {
		int n;
		cin >> n;
		if (n==0) break;
		
		cout << pollock[n] << " " << dp[n] << endl;
	}

}

Compiler output:
a.cc:19:45: error: macro "REP" passed 3 arguments, but takes just 2
   19 |                 REP(j, current_i+1, interval) if(j!=0) minimum = min(output[i - table[j]] + 1, minimum);
      |                                             ^
a.cc:8:9: note: macro "REP" defined here
    8 | #define REP(i,n) REP_N(i,n,1)
      |         ^~~
a.cc: In function 'void solution(ll*, int)':
a.cc:19:17: error: 'REP' was not declared in this scope
   19 |                 REP(j, current_i+1, interval) if(j!=0) minimum = min(output[i - table[j]] + 1, minimum);
      |                 ^~~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <functional>

using namespace std;

#define rep(i,n) for(int i = 0;i < n;i++)
#define each(i,n) for(auto i : n)

struct P {
	int y, x;
};
struct B {
	vector<P> p;
	set<int> c;
	int parent;
	char uni;
	double all;
	double xl, xr;
	double m;
	B() {
		all = 0;
		parent = -1;
		m = 0;
		xl = 1e9;
		xr = 0;
	}
};

int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

int main() {

	int w, h;
	while (cin >> w >> h && w) {
		char p[10][60];
		vector<B> b;
		rep(y, h)rep(x, w) {
			cin >> p[y][x];
		}
		bool use[10][60]; memset(use, 0, sizeof(use));
		function<vector<P>(int, int)> get = [&](int y,int x) {
			if (use[y][x])return vector<P>();
			use[y][x] = true;
			vector<P> ret; ret.push_back(P{ y, x });
			rep(i, 4) {
				int ty = y + dy[i], tx = x + dx[i];
				if (ty >= 0 && tx >= 0 && ty < h && tx < w && p[y][x] == p[ty][tx]) {
					auto tmp = get(ty, tx);
					each(j, tmp) {
						ret.push_back(j);
					}
				}
			}
			return ret;
		};
		rep(y, h)rep(x, w) {
			if (use[y][x] == false && p[y][x] != '.') {
				b.push_back(B());
				b.back().uni = p[y][x];
				b.back().p = get(y + 0.5, x + 0.5);
			}
		}
		int n = b.size();
		rep(i, n) rep(j, n)if (i != j) {
			for (auto ip : b[i].p) {
				for (auto jp : b[j].p) {
					if (ip.y == jp.y + 1 && ip.x == jp.x) {
						b[i].c.insert(j);
						b[j].parent = i;
					}
				}
			}
		}
		int root;
		rep(i, n) {
			if (b[i].parent == -1) {
				root = i;
			}
		}

		//b[m]?????????????????? ???????????????-1?????????
		function<double(int)> solve = [&](int m) {
			b[m].all = b[m].p.size();

			double tmp = 0;
			each(i, b[m].c) {
				double ret = solve(i);
				if (ret == -1.0)return -1.0;
				tmp += ret * b[i].all;
				b[m].all += b[i].all;
			}
			b[m].m = tmp / b[m].all;

			each(i, b[m].p) {
				if (i.y + 1 == h || (p[i.y + 1][i.x] != b[m].uni && p[i.y + 1][i.x] != '.')) {
					b[m].xr = max(b[m].xr, double(i.x + 0.5));
					b[m].xl = min(b[m].xl, double(i.x - 0.5));
				}
				b[m].m += i.x / b[m].all;
			}
			if (b[m].xl < b[m].m && b[m].m < b[m].xr) {
				return b[m].m;
			}
			else {
				return -1.0;
			}
		};

		if (solve(root) == -1.0) {
			cout << "UNSTABLE" << endl;
		}
		else {
			cout << "STABLE" << endl;
		}
	}


	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:35: error: 'memset' was not declared in this scope
   43 |                 bool use[10][60]; memset(use, 0, sizeof(use));
      |                                   ^~~~~~
a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    5 | #include <functional>
  +++ |+#include <cstring>
    6 |
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <functional>
#include <cstring>

using namespace std;

#define double long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define each(i,n) for(auto i : n)

struct P {
	int y, x;
};
struct B {
	vector<P> p;
	set<int> c;
	int parent;
	char uni;
	double all;
	double xl, xr;
	double m;
	B() {
		all = 0;
		parent = -1;
		m = 0;
		xl = 1e9;
		xr = 0;
	}
};

int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

int main() {

	int w, h;
	while (cin >> w >> h && w) {
		char p[10][60];
		vector<B> b;
		rep(y, h)rep(x, w) {
			cin >> p[y][x];
		}
		bool use[10][60]; memset(use, 0, sizeof(use));
		function<vector<P>(int, int)> get = [&](int y,int x) {
			if (use[y][x])return vector<P>();
			use[y][x] = true;
			vector<P> ret; ret.push_back(P{ y, x });
			rep(i, 4) {
				int ty = y + dy[i], tx = x + dx[i];
				if (ty >= 0 && tx >= 0 && ty < h && tx < w && p[y][x] == p[ty][tx]) {
					auto tmp = get(ty, tx);
					each(j, tmp) {
						ret.push_back(j);
					}
				}
			}
			return ret;
		};
		rep(y, h)rep(x, w) {
			if (use[y][x] == false && p[y][x] != '.') {
				b.push_back(B());
				b.back().uni = p[y][x];
				b.back().p = get(y, x + 0.5);
			}
		}
		int n = b.size();
		rep(i, n) rep(j, n)if (i != j) {
			for (auto ip : b[i].p) {
				for (auto jp : b[j].p) {
					if (ip.y == jp.y + 1 && ip.x == jp.x) {
						b[i].c.insert(j);
						b[j].parent = i;
					}
				}
			}
		}
		int root;
		rep(i, n) {
			if (b[i].parent == -1) {
				root = i;
			}
		}

		//b[m]?????????*??????????????? ???????????????-1?????????
		function<double(int)> solve = [&](int m) {
			b[m].all = b[m].p.size();

			double tmp = 0;
			each(i, b[m].c) {
				double ret = solve(i);
				if (ret == -1.0l)return -1.0l;
				tmp += ret;
				b[m].all += b[i].all;
			}
			b[m].m = tmp;

			each(i, b[m].p) {
				if (i.y + 1 == h || (p[i.y + 1][i.x] != b[m].uni && p[i.y + 1][i.x] != '.')) {
					b[m].xr = max(b[m].xr, double(i.x + 0.5l));
					b[m].xl = min(b[m].xl, double(i.x - 0.5l));
				}
				b[m].m += i.x;
			}
			if (b[m].xl * b[m].all < b[m].m && b[m].m < b[m].xr * b[m].all) {
				return b[m].m;
			}
			else {
				return -1.0l;
			}
		};

		if (solve(root) == -1.0l) {
			cout << "UNSTABLE" << endl;
		}
		else {
			cout << "STABLE" << endl;
		}
	}


	return 0;
}

Compiler output:
a.cc: In lambda function:
a.cc:10:16: error: expected primary-expression before 'long'
   10 | #define double long double
      |                ^~~~
a.cc:101:64: note: in expansion of macro 'double'
  101 |                                         b[m].xr = max(b[m].xr, double(i.x + 0.5l));
      |                                                                ^~~~~~
a.cc:10:16: error: expected primary-expression before 'long'
   10 | #define double long double
      |                ^~~~
a.cc:102:64: note: in expansion of macro 'double'
  102 |                                         b[m].xl = min(b[m].xl, double(i.x - 0.5l));
      |                                                                ^~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <stdlib>a

using namespace std;

struct Node{
	int XL;
	int XR;
	double XG;
	vector<Node*> next;
};

int w, h;
char p[100][100];
int pieceNum;


void getPiece(int w0, int h0, int num, vector<int>* pieceX, vector<int>* pieceY)
{
	if(w0 < 0 || w0 >= w || h0 < 0 || h0 >= h) return;
	if(p[w0][h0] != num) return;
	
	pieceX->push_back(w0);
	pieceY->push_back(h0);
	p[w0][h0] += 'A' - '0';
	
	getPiece(w0+1, h0, num, pieceX, pieceY);
	getPiece(w0-1, h0, num, pieceX, pieceY);
	getPiece(w0, h0+1, num, pieceX, pieceY);
	getPiece(w0, h0-1, num, pieceX, pieceY);
}

void makeTree(int w0, int h0, char num, Node* root)
{
	vector<int> pieceX, pieceY;
	getPiece(w0, h0, num, &pieceX, &pieceY);
	
	Node* node = new Node();
	
	int minX = 100, maxX = -100; double sum = 0;
	for(int i = 0; i < 4; i++){
		if(pieceY[i] == 0 || (p[pieceX[i]][pieceY[i]-1] != '.' && p[pieceX[i]][pieceY[i]-1] - 'A' + '0' != num) ){
			if( minX > pieceX[i] ) minX = pieceX[i];
			if( maxX < pieceX[i] ) maxX = pieceX[i];
		}
		sum += pieceX[i] + 0.5;
	}
	
	node->XL = minX;
	node->XR = maxX+1;
	node->XG = sum / 4.0;
	root->next.push_back(node);
	
	
	for(int i = 0; i < 4; i++){
		if(pieceY[i] >= h-1) continue;
		
		char pp = p[pieceX[i]][pieceY[i]+1];
		if(pp != num && pp >= '0' && pp <= '9'){
			makeTree( pieceX[i], pieceY[i]+1, pp, node);
		}
	}
}

int checkStable(Node* tree, double* xg, int* weight)
{
	if(tree == NULL) exit(0);
	
	int w = 0; double g = 0;
	for(int i = 0; i < (int)tree->next.size(); i++){
		double _xg; int _weight;
		if(checkStable(tree->next[i], &_xg, &_weight) == 0) return 0;
		g += _weight * _xg;
		w += _weight;
	}
	g += tree->XG;
	g /= w + 1;
	
	*xg = g;
	*weight = w + 1;
	
	if(g > tree->XL && g < tree->XR) return 1;
	else return 0;
}

void deleteTree(Node* tree)
{
	for(int i = 0; i < (int)tree->next.size(); i++) deleteTree( tree->next[i] );
	delete tree;
}

int main(void)
{
	while(1){
		cin >> w >> h;
		if(w == 0 && h == 0) break;
		
		for(int i = h-1; i >= 0; i--){
			for(int j = 0; j < w; j++){
				cin >> p[j][i];
			}
		}
		
		Node tree;
		for(int i = 0; i < w; i++){
			if( p[i][0] != '.'){
				makeTree(i, 0, p[i][0], &tree);
				break;
			}
		}
		
		double dummy1; int dummy2;
		int ans = checkStable(tree.next[0], &dummy1, &dummy2);
		if(ans) cout << "STABLE" << endl;
		else cout << "UNSTABLE" << endl;
		
		deleteTree(tree.next[0]);
	}
	
	return 0;
}
		

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

#error "tsurai"

#include <cstdio>
#include <cstdint>
#include <cassert>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <queue>
#include <set>

using Coord=double;
using Point=std::pair<int, Coord>;
using Index=std::pair<size_t, size_t>;

const size_t di[]={size_t(-1), 0, 1, 0};
const size_t dj[]={0, size_t(-1), 0, 1};

Point pile(const std::vector<std::string> &p, const Index &s) {
  fprintf(stderr, "(%zu, %zu)\n", s.first, s.second);
  size_t h=p.size(), w=p[0].length();
  std::set<Index> ss;

  std::queue<Index> q;
  q.emplace(s);
  while (!q.empty()) {
    size_t i=q.front().first, j=q.front().second;
    q.pop();
    for (int k=0; k<4; ++k) {
      size_t ni=i+di[k], nj=j+dj[k];
      if (!(ni < h && nj < w)) continue;
      if (p[i][j] != p[ni][nj]) continue;
      if (!ss.count({ni, nj})) {
        ss.emplace(ni, nj);
        q.emplace(ni, nj);
      }
    }
  }
  assert(ss.size() == 4);

  Point pt;
  pt.first = 4;
  double xl=1000, xr=-1000;
  for (const Index &si: ss) {
    pt.second += si.second;
    xl = std::min(xl, double(si.second)-0.5);
    xr = std::max(xr, double(si.second)+0.5);
  }
  pt.second *= 0.25;

  for (const Index &si: ss) {
    if (si.first == 0) continue;
    char c=p[si.first][si.second], nc=p[si.first-1][si.second];
    if (!(nc == '.' || nc == c)) continue;
    Point npt=pile(p, Index(si.first-1, si.second));
    
    int pw=pt.first;
    Coord px=pt.second;
    pt.first += npt.first;
    pt.second = (pw*px + npt.first*npt.second) / (pw+npt.first);
  }

  if (!(xl < pt.second && pt.second < xr))
    throw(1);

  return pt;
}

int testcase_ends() {
  size_t w, h;
  scanf("%zu %zu", &w, &h);
  if (w == 0 || h == 0) return 1;

  std::vector<std::string> p(h);
  for (size_t i=0; i<h; ++i) {
    char buf[16];
    scanf("%s", buf);
    p[i] = buf;
  }

  std::pair<size_t, size_t> s(h-1, w);
  for (size_t j=0; j<w; ++j)
    if (p[h-1][j] != '.') {
      s.second = j;
      break;
    }

  try {
    pile(p, s);
  } catch (int) {
    printf("UN");
  }
  printf("STABLE\n");
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



Compiler output:
a.cc:1:2: error: #error "tsurai"
    1 | #error "tsurai"
      |  ^~~~~
Language: C++

#include <iostream>
#include <string>
#include <queue>

using namespace std;

char dx[] = {0, 1, 0, -1};
char dy[] = {1, 0, -1, 0};

int w, h;
string s[60];
bool check[60][10];

bool isStable(int _y, int _x, int *rootM, int *rootCnt){
    bool res = true;
    int M = 2, cnt = 4, XL = 100, XR = -100;
    queue< pair<int, int> > qu; qu.push(make_pair(_y,_x));
    while(!qu.empty()){
        pair<int, int> p = qu.front(); qu.pop();
        int y = p.first, x = p.second;
        if(check[y][x]) continue;
        check[y][x] = true;
        M += x;
        if(y==h-1||(s[y+1][x]!='.'&&s[y+1][x]!=s[y][x])){
            XL = min(XL, x  );
            XR = max(XR, x+1);
        }
        if(y!=0&&!check[y-1][x]&&s[y-1][x]!='.'&&s[y-1][x]!=s[y][x])
            if(!isStable(y-1, x, &M, &cnt)) return false;
        for(int k=0;k<4;k++){
            int ny = y+dy[k], nx = x+dx[k];
            if(ny<0||h<=ny||nx<0||w<=nx) continue;
            if(s[ny][nx]=='.'||s[ny][nx]!=s[y][x]) continue;
            qu.push(make_pair(ny, nx));
        }
    }
    *rootM   += M;
    *rootCnt += cnt;
    return cnt*XL < M && M < cnt*XR;
}

int main(){
    int dM, dC;
    while(cin >> w >> h, w){
        for(int i=0;i<h;i++) cin >> s[i];
        memset(check, false, sizeof(check));
        for(int i=0;i<w;i++)
            if(s[h-1][i]!='.'){
                printf("%sSTABLE\n", isStable(h-1, i, &dM, &dC) ? "" : "UN");
                break;
            }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:9: error: 'memset' was not declared in this scope
   46 |         memset(check, false, sizeof(check));
      |         ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <queue>
  +++ |+#include <cstring>
    4 |
Language: C++

#include <iostream>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
using namespace std;

void solve(int w, int h, vector<vector<int> > block)
{
	vector<vector<bool> > check(h+2, vector<bool>(w+2, false));
	for(int i=1; i<=h; ++i){
		for(int j=1; j<=w; ++j){
			if(block[i][j] == 0 || check[i][j])
				continue;

			int left = INT_MAX;
			int right = INT_MIN;
			queue<pair<int,int> > queueYX;
			queueYX.push(make_pair(i, j));
			while(!queueYX.empty()){
				int y = queueYX.front().first;
				int x = queueYX.front().second;
				queueYX.pop();
				if(check[y][x])
					continue;
				check[y][x] = true;
				if(y == h || block[y+1][x] != block[y][x] && block[y+1][x] != 0){
					left = min(left, x);
					right = max(right, x);
				}
				if(block[y+1][x] == block[y][x])
					queueYX.push(make_pair(y+1, x));
				if(block[y][x-1] == block[y][x])
					queueYX.push(make_pair(y, x-1));
				if(block[y][x+1] == block[y][x])
					queueYX.push(make_pair(y, x+1));
			}

			queueYX.push(make_pair(i, j));
			int totalX = 0;
			int num = 0;
			vector<vector<bool> > currCheck(h+2, vector<bool>(w+2, false));
			while(!queueYX.empty()){
				int y = queueYX.front().first;
				int x = queueYX.front().second;
				queueYX.pop();
				if(currCheck[y][x])
					continue;
				currCheck[y][x] = true;
				totalX += x;
				++ num;
				if(block[y-1][x] != 0)
					queueYX.push(make_pair(y-1, x));
				if(block[y+1][x] == block[y][x])
					queueYX.push(make_pair(y+1, x));
				if(block[y][x-1] == block[y][x])
					queueYX.push(make_pair(y, x-1));
				if(block[y][x+1] == block[y][x])
					queueYX.push(make_pair(y, x+1));
			}

			if(left*num - num/2 >= totalX || totalX >= right*num + num/2){
				cout << "UNSTABLE" << endl;
				return;
			}
		}
	}

	cout << "STABLE" << endl;
}

int main()
{
	for(;;){
		int w, h;
		cin >> w >> h;
		if(w == 0 && h == 0)
			break;

		vector<vector<int> > block(h+2, vector<int>(w+2, 0));
		for(int i=1; i<=h; ++i){
			for(int j=1; j<=w; ++j){
				char tmp;
				cin >> tmp;
				if(tmp != '.')
					block[i][j] = tmp - '0';
			}
		}

		solve(w, h, block);
	}

	return 0;
}

Compiler output:
a.cc: In function 'void solve(int, int, std::vector<std::vector<int> >)':
a.cc:27:36: error: 'INT_MAX' was not declared in this scope
   27 |                         int left = INT_MAX;
      |                                    ^~~~~~~
a.cc:17:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   16 | #include <algorithm>
  +++ |+#include <climits>
   17 | using namespace std;
a.cc:28:37: error: 'INT_MIN' was not declared in this scope
   28 |                         int right = INT_MIN;
      |                                     ^~~~~~~
a.cc:28:37: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
Language: C++

// ACM-ICPCà\I2010 D. ®ç®ç

#include <iostream>
#include <string>
#include <queue>

using namespace std;

char dx[] = {0, 1, 0, -1};
char dy[] = {1, 0, -1, 0};

int w, h;
string s[60];
bool check[60][10];

bool isStable(int _y, int _x, int *rootM, int *rootCnt){
    bool res = true;
    int M = 2, cnt = 4, XL = 100, XR = -100;
    queue< pair<int, int> > qu; qu.push(make_pair(_y,_x));
    while(!qu.empty()){
        pair<int, int> p = qu.front(); qu.pop();
        int y = p.first, x = p.second;
        if(check[y][x]) continue;
        check[y][x] = true;
        M += x;
        if(y==h-1||(s[y+1][x]!='.'&&s[y+1][x]!=s[y][x])){
            XL = min(XL, x  );
            XR = max(XR, x+1);
        }
        if(y!=0&&!check[y-1][x]&&s[y-1][x]!='.'&&s[y-1][x]!=s[y][x])
            if(!isStable(y-1, x, &M, &cnt)) return false;
        for(int k=0;k<4;k++){
            int ny = y+dy[k], nx = x+dx[k];
            if(ny<0||h<=ny||nx<0||w<=nx) continue;
            if(s[ny][nx]=='.'||s[ny][nx]!=s[y][x]) continue;
            qu.push(make_pair(ny, nx));
        }
    }
    *rootM   += M;
    *rootCnt += cnt;
    return cnt*XL < M && M < cnt*XR;
}

int main(){
    int dM, dC;
    while(cin >> w >> h, w){
        for(int i=0;i<h;i++) cin >> s[i];
        memset(check, false, sizeof(check));
        for(int i=0;i<w;i++)
            if(s[h-1][i]!='.'){
                printf("%sSTABLE\n", isStable(h-1, i, &dM, &dC) ? "" : "UN");
                break;
            }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:9: error: 'memset' was not declared in this scope
   48 |         memset(check, false, sizeof(check));
      |         ^~~~~~
a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    5 | #include <queue>
  +++ |+#include <cstring>
    6 |
Language: C++

#include <cstdio>
#include <algorithm>

using namespace std;

int parent[600],sum[600],l[600],r[600],n[600];

int Find(int x){
    if(parent[x] != x) parent[x] = Find(parent[x]);
    return parent[x];
}

void Union(int x, int y){
    x = Find(x); y = Find(y);
    
    if(x != y){
        parent[x] = y;
        
        sum[y] += sum[x];
        
        if(l[x] != -1){
            if(l[y] == -1){
                l[y] = l[x];
                r[y] = r[x];
            }else{
                l[y] = min(l[y],l[x]);
                r[y] = max(r[y],r[x]);
            }
        }
    }
}

int main(){
    int w,h;
    char M[60][11];
    bool done[600][600];
    int dr[] = {-1,1,0,0};
    int dc[] = {0,0,-1,1};
    
    while(true){
        scanf("%d %d",&w,&h);
        
        if(w == 0) break;
        
        for(int i = 0;i < h;++i)
            scanf("%s",M[i]);
        
        int N = w * h;
        int cont = 0;
        
        for(int i = 0;i < N;++i){
            int y = i / w,x = i % w;
            
            parent[i] = i;
            sum[i] = 2*x + 1;
            l[i] = r[i] = -1;
            n[i] = 1;
            
            if(M[y][x] != '.') ++cont;
            
            if(y == h - 1 || (M[y + 1][x] != '.' && M[y + 1][x] != M[y][x])){
                l[i] = 2*x;
                r[i] = 2*x + 2;
            }
        }
        
        for(int i = 0;i < h;++i){
            for(int j = 0;j < w;++j){
                if(M[i][j] != '.'){
                    for(int k = 0;k < 4;++k){
                        int y = i + dr[k];
                        int x = j + dc[k];
                        
                        if(y >= 0 && y < h && x >= 0 && x < w && M[y][x] == M[i][j])
                            Union(i*w + j,y*w + x);
                    }
                }
            }
        }
        
        memset(done,0,sizeof done);
        
        for(int i = 0;i + 1 < h;++i){
            for(int j = 0;j < w;++j){
                if(M[i][j] != '.' && M[i + 1][j] != '.' && M[i + 1][j] != M[i][j]){
                    int x = i * w + j,y = (i + 1) * w + j;
                    x = Find(x); y = Find(y);
                    
                    if(x != y && !done[x][y]){
                        done[x][y] = 1;
                        sum[y] += sum[x];
                        n[y] += n[x];
                    }
                }
            }
        }
        
        bool ok = true;
        
        for(int i = 0;i < h;++i)
            for(int j = 0;j < w;++j)
                if(M[i][j] != '.' && parent[i*w + j] == i*w + j)
                    if(sum[i*w + j] <= 4 * n[i * w + j] * l[i*w + j] || sum[i*w + j] >= 4 * n[i * w + j] * r[i*w + j])
                        ok = false;
        
        puts(ok? "STABLE" : "UNSTABLE");
    }
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:81:9: error: 'memset' was not declared in this scope
   81 |         memset(done,0,sizeof done);
      |         ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <algorithm>
  +++ |+#include <cstring>
    3 |
Language: C++

#include <iostream>
#include <queue>
#include <cmath>

using namespace std;

typedef struct st1
{
	int x;
	int y;
}coord;

typedef struct st2
{
	double sumofx;
	int count;
}up;

int w,h;
char p[60][10];
bool visit[60][10];
bool stable;

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

void find_blocks(int x,int y,coord c[4])
{
	queue <coord> q;
	coord co,tmp_co;
	
	co.x = x; 
	co.y = y;
	q.push(co);
	visit[y][x] = true;
	
	int idx = 0;
	c[idx].x = x;
	c[idx].y = y;
	++idx;
	
	while (!q.empty())
	{
		co = q.front();
		q.pop();
		
		for (int i=0;i<4;++i)
		{
			tmp_co.x = co.x + dx[i];
			tmp_co.y = co.y + dy[i];
			if (0<=tmp_co.x && tmp_co.x < w&&0<=tmp_co.y&&tmp_co.y<h&&(!visit[tmp_co.y][tmp_co.x])&&(p[tmp_co.y][tmp_co.x] == p[y][x]))
			{
				c[idx].x = tmp_co.x;
				c[idx].y = tmp_co.y;
				++idx;
				q.push(tmp_co);
				visit[tmp_co.y][tmp_co.x] = true;
			}
		}
	}
	
}

up dfs(int x, int y)
{
	up res;
	coord block[4];
	int left = 60;
	int right = -1;
	
	res.sumofx = 0;
	res.count = 0;
	
	if (!stable) return res;
	find_blocks(x,y,block);
	
	for (int i=0;i<4;++i)
	{
		res.sumofx += block[i].x + 0.5;
		res.count++;
		
		if (block[i].y == 0)
		{
			left = min(left,block[i].x);
			right = max(right,block[i].x);
		}else 
		{
			if ((p[block[i].y-1][block[i].x]!='.')&&(p[block[i].y-1][block[i].x]!=p[block[i].y][block[i].x]))
			{
				left = min(left,block[i].x);
				right = max(right,block[i].x);
			}
		}
		
		if (!stable) return res;
		if ((block[i].y+1<h)&&(p[block[i].y+1][block[i].x]!='.')&&(p[block[i].y+1][block[i].x]!=p[block[i].y][block[i].x])&&(!visit[block[i].y+1][block[i].x]))
		{
			up u = dfs(block[i].x,block[i].y+1);
			res.sumofx += u.sumofx;
			res.count += u.count;
		}
	}
	
	double avg=res.sumofx/res.count;
    if (!(left<avg && avg<right+1)) stable = false;
	
	return res;
}

int main()
{
	cin >> w >> h;
	while (w+h > 0)
	{
		memset(visit,0,sizeof(visit));
		stable = true;
		
		for (int i=h-1;i>=0;--i)
		{
			for (int j=0;j<w;++j)
			{
				cin >> p[i][j];
			}
		}
		
		for (int i=0;i<w;++i)
		{
			if (p[0][i] != '.' )
			{
				dfs(i,0);
				break;
			}
		}
		
		if (stable) cout <<"STABLE" << endl;
		else cout << "UNSTABLE" << endl;
		
		cin >> w >> h;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:115:17: error: 'memset' was not declared in this scope
  115 |                 memset(visit,0,sizeof(visit));
      |                 ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <cmath>
  +++ |+#include <cstring>
    4 |
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cstdio>
using namespace std;
typedef long long int ll;
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=(x);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)

int w, h;
int d[4][2]={{1,0},{-1,0},{0,-1},{0,1}};
string M[80];
int par[11];
struct P{
	vector<double> ps;
	int gl;
	int gr;
	P(){ps.clear();gl=100;gr=0;}
} peace[10];

void check(int y, int x, char c, int idx){
//	printf("check %d %d %c %d\n", y, x, c, idx);
	peace[idx].ps.push_back(x+0.5);
	if(y+1 == h || (M[y+1][x] != M[y][x] && M[y+1][x] != '.')){
		peace[idx].gr = max(peace[idx].gr, x+1);
		peace[idx].gl = min(peace[idx].gl, x);
	}
	M[y][x] = idx;
	REP(i, 4){
		int dy=y+d[i][1];
		int dx=x+d[i][0];
		if(dx<0||dy<0||w<=dx||h<=dy) continue;
		if(M[dy][dx] == c) check(dy, dx, c, idx);
	}
}

int dfs(int r){
	REP(i, 10) if(par[i] == r){
		if(!dfs(i)) return 0;
		peace[r].ps.insert(peace[r].ps.end(), peace[i].ps.begin(), peace[i].ps.end());
	}
//	REP(i, peace[r].ps.size()) printf("%.2f ", peace[r].ps[i]);
//	puts("");
	if(peace[r].ps.size() = 0) return 1;
	double m = (double)accumulate(peace[r].ps.begin(), peace[r].ps.end(), 0.0) / peace[r].ps.size();
//	printf("%d -> %d %.2f %d\n", r, peace[r].gl, m, peace[r].gr);
	return peace[r].gl+1e-8 < m && peace[r].gr > m+1e-8;
}

int solve(){
	int idx = 0;
	REP(i, h){
		REP(j, w){
			if(M[i][j]!='.' && 10 < M[i][j]){
				check(i, j, M[i][j], idx++);
			}
		}
	}
	REP(i, 10) par[i] = -1;
	REP(i, h-1){
		REP(j, w){
			if(M[i][j]!='.' && M[i+1][j] != '.' && M[i][j]!=M[i+1][j]){
				par[M[i][j]] = M[i+1][j];
			}
		}
	}
	REP(i, 10) if(par[i] == -1) return dfs(i);
	return 0;
}

main(){
	int i,j;
	while(cin >> w >> h, w){
		REP(i, 10) peace[i] = P();
		REP(i, h) cin >> M[i];
		cout << (solve() ? "STABLE":"UNSTABLE") << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int dfs(int)':
a.cc:50:28: error: lvalue required as left operand of assignment
   50 |         if(peace[r].ps.size() = 0) return 1;
      |            ~~~~~~~~~~~~~~~~^~
a.cc: At global scope:
a.cc:77:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   77 | main(){
      | ^~~~
Language: C

// AOJ 1169 The Most Powerful Spell
// 2018.4.17 bal4u

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

#define QMAX 15000
typedef struct { char s; int t; char lab[405]; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int s, int t, char *lab)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].s = s, que[i].t = t, strcpy(que[i].lab, lab);
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

// バッファ入力から数値を得る
char buf[20], *p;
int in()
{
	int n = 0;
	while (*p >= '0') n = 10*n + (*p++ & 0xf);
	p++;
	return n;
}

char hi[42], to[42][42];
char w[42][42]; char lab[42][42][8];
char dist[42][510][510];
char str[510], nstr[510], *ans;

char *dijkstra(int n, int start, int goal)
{
	int i, s, e, t, nt;

	for (s = 0; s < n; s++) for (i = 0; i < 400; i++) {
		dist[s][i][0] = 0x7e, dist[s][i][1] = 0;
	}
	qsize = 0;
	dist[start][0][0] = 0, enq(start, 0, "");
	while (qsize) {
		s = que[0].s, t = que[0].t, strcpy(str, que[0].lab), deq();
		if (strcmp(dist[s][t], str) < 0) continue;
		for (i = 0; i < hi[s]; i++) {
			e = to[s][i], nt = t + w[s][i];
			if (nt > 400) continue;
			memcpy(nstr, str, t), strcpy(nstr+t, lab[s][i]);
			if (strcmp(dist[e][nt], nstr) > 0) {
				strcpy(dist[e][nt], nstr);
				enq(e, nt, nstr);
			}
		}
	}
	str[0] = 0x7e, str[1] = 0, ans = str;
	for (i = 0; i < 400; i++) {
		if (strcmp(ans, dist[goal][i]) > 0) {
			if (i > 300) return NULL;
			ans = dist[goal][i]);
		}
	}
	if (*ans == 0x7e) return NULL;
	return ans;
}

int main()
{
	int n, a, s, g, k, x, y;
	char *q;

	while (fgets(p=buf, 20, stdin) && *p != '0') {
		n = in(), a = in(), s = in(), g = in();
		memset(hi, 0, sizeof(hi));
		while (a--) {
			fgets(p=buf, 20, stdin);
			x = in(), y = in();
			k = hi[x]++;
			to[x][k] = y;
			q = lab[x][k]; while (*p > ' ') *q++ = *p++; *q = 0;
			w[x][k] = q - lab[x][k];
		}

		if ((q = dijkstra(n, s, g)) == NULL) puts("NO");
		else puts(q);
	}
	return 0;
}


Compiler output:
main.c: In function 'dijkstra':
main.c:90:44: error: expected ';' before ')' token
   90 |                         ans = dist[goal][i]);
      |                                            ^
      |                                            ;
main.c:90:44: error: expected statement before ')' token