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

#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()
#define pb         push_back

const double MID  = 1000;
const double GOAL = 2000;
const double eps  = 1e-10;
const double inf  = 1e100;

class state{
public:
  double x,v,oriv;
  int cnt;
  bool operator<(const state & a)const{
    if (!(fabs(x-a.x)<eps))return x < a.x;
    return v < a.v;
  }
};

double compute_time(double x1,double x2,double v1,double v2){
  if (x1 > x2)return inf;
  if (v1-v2<eps)return inf;
  return (x2-x1)/(v1-v2);
}

int solve(int n,vector<state>& in){
  double ans=0;
  while(n){
    double mint=inf;
    rep(i,n){
      if (fabs(in[i].x-MID)>eps)
	mint=min(mint,compute_time(in[i].x,MID,in[i].v,0));
      if (fabs(in[i].x-GOAL)>eps)
	mint=min(mint,compute_time(in[i].x,GOAL,in[i].v,0));
      REP(j,i+1,n){
	if (fabs(in[i].x-in[j].x)>eps)
	  mint=min(mint,compute_time(in[i].x,in[j].x,in[i].v,in[j].v));
      }
    }

    ans+=mint;
    assert(ans >0 && mint>0);
    rep(i,n){
      in[i].x+=in[i].v*mint;
    }

    rep(i,n){
      if (fabs(in[i].x-MID) < eps){
	in[i].v=in[i].oriv;
      }else if (fabs(in[i].x-GOAL)<eps){
	in[i].v=in[i].oriv;
	in[i].x=0;
	in[i].cnt--;
	if (in[i].cnt == 0)in[i].x = inf;
      }else {
	rep(j,n){
	  if (fabs(in[i].x-in[j].x)<eps)in[i].v=min(in[i].v,in[j].v);
	}
      }
    }


    sort(ALL(in));
    for(int i=n-1;i>=0;i--){
      if (in[i].x >2000+eps)n--;
    }
  }

  return (int)(ans+eps);
}

main(){
  int n;
  while(cin>>n && n){
    vector<state> in;
    rep(i,n){
      double t;
      int lap;
      cin>>t>>lap;
      in.pb((state){0,1000/t,1000/t,lap});
    }
    cout << solve(n,in) << endl;
  }
}

Compiler output:
a.cc: In function 'int solve(int, std::vector<state>&)':
a.cc:48:5: error: 'assert' was not declared in this scope
   48 |     assert(ans >0 && mint>0);
      |     ^~~~~~
a.cc:5:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
    4 | #include<vector>
  +++ |+#include <cassert>
    5 | using namespace std;
a.cc: At global scope:
a.cc:78:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   78 | main(){
      | ^~~~
Language: C++

#include <iostream>
#include <vector>
#include <queue>
#include <utility>

using namespace std;
typedef pair<int, int> pii;
struct Swimmer {
	int t, c, e;
	Swimmer(int t, int c, int e) : t(t), c(c), e(e) { }
};
const int INF = 1000000000;

int main(){
	while(true){
		int n;
		cin >> n;
		if(n == 0){ break; }
		vector<pii> input(n);
		for(int i = 0; i < n; ++i){
			cin >> input[i].first >> input[i].second;
		}
		queue<Swimmer> forward, backward;
		sort(input.begin(), input.end());
		for(int i = 0; i < n; ++i){
			int t = input[i].first, c = input[i].second;
			forward.push(Swimmer(t, c, t));
		}
		int answer = 0;
		while(!forward.empty() || !backward.empty()){
			int ft = (forward.empty() ? INF : forward.front().e);
			int bt = (backward.empty() ? INF : backward.front().e);
			int tm = min(ft, bt);
			answer = tm;
			queue<Swimmer> &q = (ft < bt) ? forward : backward;
			vector<pii> next;
			while(!q.empty() && q.front().e <= tm){
				Swimmer sw = q.front();
				q.pop();
				if(ft >= bt && --sw.c == 0){ continue; }
				next.push_back(pii(sw.t, sw.c));
			}
			sort(next.begin(), next.end());
			queue<Swimmer> &opp = (ft < bt) ? backward : forward;
			for(int i = 0; i < next.size(); ++i){
				int t = next[i].first, c = next[i].second;
				opp.push(Swimmer(t, c, t + tm));
			}
		}
		cout << answer << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:17: error: 'sort' was not declared in this scope; did you mean 'short'?
   24 |                 sort(input.begin(), input.end());
      |                 ^~~~
      |                 short
Language: Java

import java.awt.*;
import java.util.*;
import java.awt.geom.*;

public class mattya_1203_1 {
    public static void main(String args[])throws Exception{
        Scanner cin= new Scanner(System.in);
		int n,m;
		for(;;){
			n=cin.nextInt();
			m=cin.nextInt();
//			System.out.printf("%d %d\n",n,m);
			if(n==0 && m==0) break;
			
			Point2D.Double[] w = new Point2D.Double[200];
			Point2D.Double[] b = new Point2D.Double[200];
			
			for(int i=0;i<n;i++){
				w[i].x= cin.nextInt();
				w[i].y= cin.nextInt();
			}
			for(int i=0;i<m;i++){
				b[i].x= cin.nextInt();
				b[i].y= cin.nextInt();
			}
			
			int f=0;
			out:
			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					int t1=0,t2=0;
					for(int k=0;k<n;k++){
						if(k==i) continue;
						int ccw=Line2D.relativeCCW(w[i].x, w[i].y, b[i].x, b[i].y, w[k].x, w[k].y);
						if(ccw==0) if(w[i].distance(b[j]) + w[i].distance(w[k]) <= w[k].distance(b[j]) + 0.0000000001) ccw=1;
						t1+=ccw;
					}
					for(int k=0;k<m;k++){
						if(k==j) continue;
						int ccw=Line2D.relativeCCW(w[i].x, w[i].y, b[i].x, b[i].y, b[k].x, b[k].y);
						if(ccw==0) if(b[j].distance(w[i]) + b[j].distance(b[k]) <= w[i].distance(b[k]) + 0.0000000001) ccw=-1;
						t1+=ccw;
					}
					if(t1*t2<=0 && Math.abs(t1)==n && Math.abs(t2)==m){
						f=1;
						System.out.println("YES");
						break out;
					}
				}
			}
			if(f==0) System.out.println("NO");
		}
	}
}

Compiler output:
Main.java:5: error: class mattya_1203_1 is public, should be declared in a file named mattya_1203_1.java
public class mattya_1203_1 {
       ^
1 error
Language: C++

import java.awt.*;
import java.util.*;
import java.awt.geom.*;

public class Main {
    public static void main(String args[])throws Exception{
        Scanner cin= new Scanner(System.in);
		int n,m;
		Point2D.Double[] w = new Point2D.Double[200];
		Point2D.Double[] b = new Point2D.Double[200];
		for(;;){
			n=cin.nextInt();
			m=cin.nextInt();
			//			System.out.printf("%d %d\n",n,m);
			
			if(n==0 && m==0) break;
			
			
			for(int i=0;i<n;i++){
				w[i] = new Point2D.Double();
				w[i].x= cin.nextInt();
				w[i].y= cin.nextInt();
			}
			for(int i=0;i<m;i++){
				b[i] = new Point2D.Double();
				b[i].x= cin.nextInt();
				b[i].y= cin.nextInt();
			}
			
			int f=0;
		out:
			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					int t1=0,t2=0;
					//					System.out.printf("%d  %d\n",i,j);
					for(int k=0;k<n;k++){
						if(k==i) continue;
						int ccw=Line2D.relativeCCW( w[k].x, w[k].y, w[i].x, w[i].y, b[j].x, b[j].y);
						//						if(ccw==0) if(w[i].distance(b[j]) + w[i].distance(w[k]) <= w[k].distance(b[j])) ccw=1;
						//						System.out.println(ccw);
						t1+=ccw;
					}
					for(int k=0;k<m;k++){
						if(k==j) continue;
						int ccw=Line2D.relativeCCW(b[k].x, b[k].y, b[j].x, b[j].y, w[i].x, w[i].y);
						//						System.out.println(ccw);
						//						if(ccw==0) if(b[j].distance(w[i]) + b[j].distance(b[k]) <= w[i].distance(b[k])) ccw=-1;
						//						System.out.println(ccw);
						t2+=ccw;
					}
					//					System.out.printf("t1,t2= %d,%d\n",t1,t2);
					if(t1>=0 && t2>=0 && Math.abs(t1)==n-1 && Math.abs(t2)==m-1){
						f=1;
						System.out.println("YES");
						break out;
					}
				}
			}
			if(f==0) System.out.println("NO");
		}
	}
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.awt.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.*;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.awt.geom.*;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: expected unqualified-id before 'public'
    5 | public class Main {
      | ^~~~~~
Language: C++

#include<vector>
#include<string>
#include<map>
#include<fstream>
#include<iostream>
#include<math.c>
using namespace std;

string str;
map<string,int> Idx;
int atom=0;
int pos=0;
int num=0;
bool rev;

vector<int> read(){
	vector<int> res(atom,0);
	if(str.size()<=pos || str[pos]=='+' || str[pos]=='.' || str[pos]==')' || str[pos]=='-'){return res;}
	string temp="";
	if(isupper(str[pos])){
		temp+=str[pos++];
		if(islower(str[pos]))
			temp+=str[pos++];
		res[Idx[temp]]+=1;
	}
	else if(str[pos]=='('){
		pos++;
		res=read();
		pos++;
	}
	int mul=1;
	if(isdigit(str[pos])){
		mul=str[pos++]-'0';
		if(isdigit(str[pos]))
			mul=mul*10+str[pos++]-'0';
	}
	vector<int> next;
	next=read();
	for(int i=0;i<res.size();i++)
		res[i]=res[i]*mul+next[i];
	return res;
}


int gcd(int a, int b){ return a%b ? gcd(b, a%b) : b; }
int lcm(int a, int b){ return a/gcd(a,b)*b; }

int main()
{
	ifstream fin("F.in");
	while(cin>>str){
		if(str==".") break;
		atom=0;
		pos=0;
		num=2;
		rev=false;
		Idx.clear();
		for(int i=0;i<str.size();i++){
			string temp="";
			if(str[i]=='+')
				num++;
			if(isupper(str[i])){
				temp+=str[i];
				if(i+1<str.size() && islower(str[i+1]))
					temp+=str[++i];
			}
			if(temp!="" && !Idx.count(temp))
				Idx[temp]=atom++;
		}
		vector<vector<int> > v(atom,0);
		for(int i=0;i<num;i++){
			if(str[pos]=='+')
				pos++;
			if(str[pos]=='-'){
				pos+=2;
				rev=true;
			}
			vector<int> temp=read();
			for(int j=0;j<temp.size();j++)
				v[j].push_back(!rev ? temp[j]:-temp[j]);
		}
		for(int i=0;i<v[0].size()-1;i++){
			if(v[i][i]==0){
				int idx=i;
				while(!v[idx][i]) idx++;
				swap(v[i],v[idx]);
			}
			for(int j=0;j<v.size();j++){
				if(v[j][i]==0 || i==j) continue;
				int mula=v[i][i]/gcd(v[i][i],v[j][i]);
				int mulb=v[j][i]/gcd(v[i][i],v[j][i]);
				for(int k=0;k<v[0].size();k++)	v[j][k]=v[j][k]*mula-v[i][k]*mulb;
			}
			for(int j=0;j<v.size();j++){
				int div=0;
				for(int k=0;k<v[0].size();k++)
					if(v[j][k]!=0) div=!div ? abs(v[j][k]):gcd(abs(v[j][k]),div);
				if(div)
					for(int k=0;k<v[0].size();k++)	v[j][k]/=div;
			}
		}

		int mul=1;
		for(int i=0;i<num-1;i++)
			mul=lcm(mul,abs(v[i][i]));
		for(int i=0;i<num-1;i++)
			cout<<abs(v[i][num-1]*mul/v[i][i])<<" ";
		cout<<mul<<endl;

	}
	return 0;
}

Compiler output:
a.cc:6:9: fatal error: math.c: No such file or directory
    6 | #include<math.c>
      |         ^~~~~~~~
compilation terminated.
Language: C

#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;
const double EPS = 1e-8;
typedef pair<double, double> pt;

#define x first
#define y second

double sq(double a) { return a * a; }

double dist(pt p, pt q) {
  return sqrt(sq(p.x - q.x) + sq(p.y - q.y));
}

bool equal(double x, double y) {
    if (fabs(x-y) < EPS){
        return true;
    }
    return false;
}


pt operator-(pt a, pt b) {
  return pt(a.x - b.x, a.y - b.y);
}

double dotProduct(pt a, pt b) {
    return a.x * b.x + a.y * b.y;
}

bool zero(double x) {
  return fabs(x) <= EPS;
}

struct line {
  double a, b, c;
};

line getLine(pt a, pt b) {
    line l;
    l.a = a.y - b.y; // y1 - y2
    l.b = b.x - a.x; // -(x1-x2)
    // m = l.b / -l.a
    l.c =  a.x*b.y - b.x*a.y ;
    return l;
}

pt intersect(line a, line b) {
    double y = (a.a*b.c - a.c*b.a)/(a.b*b.a - a.a*b.b);
    double x = (a.c*b.b - a.b*b.c)/(a.b*b.a - a.a*b.b);
    return pt(x, y);
}

pt intermediatePoint(pt a, pt b, double ratio) {
    return pt(
        (b.x-a.x)*ratio/(ratio+1)+a.x,
         (b.y-a.y)*ratio/(ratio+1)+a.y
         );
}

double angleBetween(pt a, pt b, pt c) {
    return acos(dotProduct(pt(b.x-a.x,b.y-a.y), pt(c.x-a.x, c.y-a.y))/
        (dist(a, b) * dist(a, c)));
}
double inRadius(double s, double a, double b, double c){
    return sqrt(s*(s-a)*(s-b)*(s-c))/s;
//return a*b/(a+b+c);
}

double malfatti(double s, double c, double inradius, double d, double e, double f) {
    return inradius * (s + d - inradius - e -f)/2/(s-c);
}

int main() {

    cout << setprecision(6) << fixed;
    int x1, y1, x2, y2, x3, y3;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    while(x1 != 0 || y1 != 0 || x2 != 0 || y2 != 0 || x3 != 0 || y3 != 0) {
        pt A = pt(x1, y1);
        pt B = pt(x2, y2);
        pt C = pt(x3, y3);

        double a = dist(B, C);
        double b = dist(A, C);
        double c = dist(A, B);

        double s = (a+b+c)/2;

        double Cratio = a / b;
        pt Cbisectpt = intermediatePoint(B, A, Cratio);
        line Cline = getLine(C, Cbisectpt);

        double Bratio = c / a;
        pt Bbisectpt = intermediatePoint(A, C, Bratio);
        line Bline = getLine(B, Bbisectpt);

        pt intpt = intersect(Cline, Bline);
        double inr = inRadius(s, a, b, c);
        double d = dist(A, intpt);
        double e = dist(B, intpt);
        double f = dist(C, intpt);

        cout << malfatti(s, a, inr, d, e, f) << " "
         << malfatti(s, b, inr, e, f, d) << " "
        << malfatti(s, c, inr, f, d, e) << endl;

        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    }
}


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

#include <iostream>
#include <cmath>

typedef std::pair<double,double> Point;
#define x first
#define y second


double dist(Point a, Point b){
	double x = a.x - b.x;
	double y = a.y - b.y;

	return sqrt(x*x+y*y);
}


int main(){

	Point A;
	Point B;
	Point C;

	std::cin >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y;

	while(A.x != 0 || A.y != 0 || B.x != 0 || B.y != 0 
			|| C.x != 0 || C.y != 0){

		double AB = dist(A,B);
		double AC = dist(A,C);
		double BC = dist(B,C);

		//random forumual stuff that i dont really get here
		double s = (AB + AC + BC)/2;
		Point I;//centre of triangle 
		I.x = (BC * A.x + AC * B.x + AB * C.x)/(AB+AC+BC);
		I.y = (BC * A.y + AC * B.y + AB * C.y)/(AB+AC+BC); 
		double r = sqrt((s-AB)*(s-AC)*(s-BC)/s);

		double IA = dist(I,A);
		double IB = dist(I,B);
		double IC = dist(I,C);

		double r1 = (r/(2*(s-BC)))*(s-r + IA-IC-IB);
		double r2 = (r/(2*(s-AC)))*(s-r + IB-IC-IA);
		double r3 = (r/(2*(s-AB)))*(s-r + IC-IB-IA);

		std::cout << r1 << " " << r2 << " " << r3 << "\n";

		std::cin >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y;
	}


	return 0;
}



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

// Taimur Azhar z5116684
// Prog Chal
// Week 6 Problem A - Malfatti Circles

#include <stdlib.h>
#include <iostream>  
#include <cmath> 

using namespace std;  

struct Point{  
    double x,y;  
}p1,p2,p3,ic; 

double dist(Point p1,Point p2) {  
    return sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));  
}  

int main() {    
    while(cin >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y) {
        if ((p1.x == 0) && (p1.y == 0) && (p2.x == 0) && (p2.y == 0) && (p3.x == 0) && (p3.y == 0)) break;
        
        // Distance of each line in the triangle
        double a = dist(p2, p3);  
        double b = dist(p1, p3);  
        double c = dist(p1, p2);  
        // Semiperimeter
        double s = (a + b + c) / 2;  
        // Incentre of the triangle
        ic.x = (a * A.x + b * B.x + c * C.x) / (a + b + c);  
        ic.y = (a * A.y + b * B.y + c * C.y) / (a + b + c);
        // Inneradius
        double ir = sqrt(s * (s - a) * (s - b) * (s - c)) / s; 
        // The three distances from the incentre
        double d = dist(p1, ic);  
        double e = dist(p2, ic);  
        double f = dist(p3, ic);  
        // Each radii
        double r1 = r / (2 * (s - a)) * (s + d - r - e - f);  
        double r2 = r / (2 * (s - b)) * (s + e - r - d - f);  
        double r3 = r / (2 * (s - c)) * (s + f - r - d - e);  

        cout << setprecision(9) << r1 << " " << r2 << " " << r3 << " " << endl;
    }
    return 0;  
}  


Compiler output:
a.cc: In function 'int main()':
a.cc:30:21: error: 'A' was not declared in this scope
   30 |         ic.x = (a * A.x + b * B.x + c * C.x) / (a + b + c);
      |                     ^
a.cc:30:31: error: 'B' was not declared in this scope
   30 |         ic.x = (a * A.x + b * B.x + c * C.x) / (a + b + c);
      |                               ^
a.cc:30:41: error: 'C' was not declared in this scope
   30 |         ic.x = (a * A.x + b * B.x + c * C.x) / (a + b + c);
      |                                         ^
a.cc:39:21: error: 'r' was not declared in this scope; did you mean 'r1'?
   39 |         double r1 = r / (2 * (s - a)) * (s + d - r - e - f);
      |                     ^
      |                     r1
a.cc:43:17: error: 'setprecision' was not declared in this scope
   43 |         cout << setprecision(9) << r1 << " " << r2 << " " << r3 << " " << endl;
      |                 ^~~~~~~~~~~~
a.cc:8:1: note: 'std::setprecision' is defined in header '<iomanip>'; this is probably fixable by adding '#include <iomanip>'
    7 | #include <cmath>
  +++ |+#include <iomanip>
    8 |
Language: C++

// 2009ツアツジツアツ地ツ凝ヲツ予ツ選 G : Malfatti Circles
#include <fstream>
#include <complex>
#include <stdio.h>

using namespace std;

const double EPS = 1e-12;

typedef complex<double> P;
struct L{ P p, q; L(P p, P q) : p(p), q(q) {} };

double cross(P a, P b) { return imag(conj(a)*b); }

double lpDist(L l, P p){
	return abs(cross(l.q-l.p,p-l.p))/abs(l.q-l.p);
}

P crossPoint(L l, L m){
	double A = cross(l.q-l.p, m.q-m.p);
	double B = cross(l.q-l.p, l.q-m.p);
	return m.p + B/A*(m.q-m.p);
}

int main(){
	int x1, y1, x2, y2, x3, y3;
	while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3){
		if(!(x1||y1||x2||y2||x3||y3)) break;
		P p1 = P(x1,y1), p2 = P(x2,y2), p3 = P(x3,y3);
		P dirA = (p2-p1)/abs(p2-p1)+(p3-p1)/abs(p3-p1);
		P dirB = (p1-p2)/abs(p1-p2)+(p3-p2)/abs(p3-p2);
		P c = crossPoint(L(p1,p1+dirA),L(p2,p2+dirB));
		double rA, rB, rC;
		double leftA = 0.0, rightA = 1.0, leftB, rightB, leftC, rightC;
		while(true){
			double midA = (leftA+rightA)/2;
			P cA = p1 + (c-p1)*midA, cB, cC;
			rA = lpDist(L(p1,p2), cA);
			leftB = 0.0, rightB = 1.0, leftC = 0.0, rightC = 1.0;
			while(rightB-leftB>EPS){
				double midB = (leftB+rightB)/2;
				cB = p2 + (c-p2)*midB;
				rB = lpDist(L(p2,p3), cB);
				if(rA+rB < abs(cB-cA)) leftB  = midB;
				else                   rightB = midB;
			}
			while(rightC-leftC>EPS){
				double midC = (leftC+rightC)/2;
				cC = p3 + (c-p3)*midC;
				rC = lpDist(L(p3,p1), cC);
				if(rA+rC < abs(cC-cA)) leftC  = midC;
				else                   rightC = midC;
			}
			if(rB+rC > abs(cB-cC)) leftA  = midA;
			else                   rightA = midA;
			if(rightA-leftA < EPS){
				printf("%.5lf %.5lf %.5lf\n", rA, rB, rC);
				break;
			}
		}
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:15: error: 'cin' was not declared in this scope
   27 |         while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3){
      |               ^~~
a.cc:4:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    3 | #include <complex>
  +++ |+#include <iostream>
    4 | #include <stdio.h>
Language: C++

#include <array>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

constexpr int MAX_M = 11;

int m, n;
int memo[1 << MAX_M][1 << MAX_M];

int dfs(int used, int result, const vector<unsigned> &objects) {
	if(objects.size() <= 1) return 0;

	int &res = memo[used][result];
	if(res != -1) return res;
	res = MAX_M;

	for(int i = 0; i < m; ++i) {
		if((used >> i) & 1) continue;

		array<vector<unsigned>, 2> next_objects;
		for(const auto &e : objects) {
			next_objects[(e >> i) & 1].emplace_back(e);
		}

		const int yes = dfs(used | (1 << i), result | (1 << i), next_objects[1]);
		const int no = dfs(used | (1 << i), result, next_objects[0]);
		chmin(res, max(yes, no) + 1);
	}

	return res;
}

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

	while(cin >> m >> n && m) {
		vector<unsigned> objects(n);
		for(auto &e : objects) {
			bitset<MAX_M> b;
			cin >> b;
			e = b.to_ulong();
		}

		memset(memo, -1, sizeof(memo));
		cout << dfs(0, 0, objects) << endl;
	}

	return EXIT_SUCCESS;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:17: error: 'memset' was not declared in this scope
   51 |                 memset(memo, -1, sizeof(memo));
      |                 ^~~~~~
a.cc:7:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    6 | #include <vector>
  +++ |+#include <cstring>
    7 | using namespace std;
Language: C++

#include<iostream>
#include<algorithm>
#include<string>

using namespace std;
#define INF (1 << 30)

int b(string str){
	int res = 0;
	for(int i = 0;i < str.size();i++){
		res += (str[i] - '0') << i;
	}
	return res;
}

int num[108], n, m;
int dp[1 << 11][1 << 11];


int solve(int asked, int answer){
	int &res = dp[asked][answer];
	if(res != -1)return res;
	int cnt = 0;
	for(int i = 0;i < m;i++){
		if((num[i] & asked) == answer){
			cnt++;
		}
	}
	if(cnt <= 1)return res = 0;
	res = INF;
	for(int i = 0;i < n;i++){
		int p = 1 << i;
		if(asked & p)continue;
		res = min(res, max(solve(asked | p, answer), solve(asked | p, answer | p)) + 1);
	}
	return res;
}

int main(){
	string str;
	while(cin >> n >> m, n | m){
		memset(dp, -1 ,sizeof(dp));
		for(int i = 0;i < m;i++){
			cin >> str;
			num[i] = b(str);
		}
		cout << solve(0, 0) << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:17: error: 'memset' was not declared in this scope
   42 |                 memset(dp, -1 ,sizeof(dp));
      |                 ^~~~~~
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 | #include<string>
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
using namespace std;
map<set<int>,int>memo;

int M,N;
vector<string>v;
int dfs(set<int> &t){
	if(t.size()==1)return 0;
	if(memo.find(t)!=memo.end())return memo[t];
	int r=1<<30;
	for(int j=0;j<M;j++){
		set<int>a,b;
		for(auto &e:t)(v[e][j]=='0'?a:b).push_back(e);
		if(a.size()&&b.size())r=min(r,max(dfs(a),dfs(b))+1);
	}
	return memo[t]=r;
}

int main(){
	for(;cin>>M>>N,M;){
		v.resize(N);
		for(int i=0;i<N;i++)cin>>v[i];
		set<int>t(N);
		for(int i=0;i<N;i++)t.insert(i);
		memo.clear();
		printf("%d\n",dfs(t));
	}
}

Compiler output:
a.cc:9:5: error: 'set' was not declared in this scope
    9 | map<set<int>,int>memo;
      |     ^~~
a.cc:8:1: note: 'std::set' is defined in header '<set>'; this is probably fixable by adding '#include <set>'
    7 | #include <cstdio>
  +++ |+#include <set>
    8 | using namespace std;
a.cc:9:12: error: wrong number of template arguments (1, should be at least 2)
    9 | map<set<int>,int>memo;
      |            ^
In file included from /usr/include/c++/14/map:63,
                 from a.cc:4:
/usr/include/c++/14/bits/stl_map.h:102:11: note: provided for 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map'
  102 |     class map
      |           ^~~
a.cc:9:13: error: expected unqualified-id before ',' token
    9 | map<set<int>,int>memo;
      |             ^
a.cc:9:14: error: expected unqualified-id before 'int'
    9 | map<set<int>,int>memo;
      |              ^~~
a.cc:13:9: error: 'set' was not declared in this scope
   13 | int dfs(set<int> &t){
      |         ^~~
a.cc:13:9: note: 'std::set' is defined in header '<set>'; this is probably fixable by adding '#include <set>'
a.cc:13:13: error: expected primary-expression before 'int'
   13 | int dfs(set<int> &t){
      |             ^~~
a.cc: In function 'int main()':
a.cc:29:17: error: 'set' was not declared in this scope
   29 |                 set<int>t(N);
      |                 ^~~
a.cc:29:17: note: 'std::set' is defined in header '<set>'; this is probably fixable by adding '#include <set>'
a.cc:29:21: error: expected primary-expression before 'int'
   29 |                 set<int>t(N);
      |                     ^~~
a.cc:30:37: error: 't' was not declared in this scope
   30 |                 for(int i=0;i<N;i++)t.insert(i);
      |                                     ^
a.cc:31:17: error: 'memo' was not declared in this scope
   31 |                 memo.clear();
      |                 ^~~~
a.cc:32:35: error: 't' was not declared in this scope
   32 |                 printf("%d\n",dfs(t));
      |                                   ^
a.cc:32:36: error: 'dfs' cannot be used as a function
   32 |                 printf("%d\n",dfs(t));
      |                                    ^
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
using namespace std;
map<set<int>,int>memo;

int M,N;
vector<string>v;
int dfs(set<int> &t){
	if(t.size()==1)return 0;
	if(memo.find(t)!=memo.end())return memo[t];
	int r=1<<30;
	for(int j=0;j<M;j++){
		set<int>a,b;
		for(auto &e:t)(v[e][j]=='0'?a:b).push_back(e);
		if(a.size()&&b.size())r=min(r,max(dfs(a),dfs(b))+1);
	}
	return memo[t]=r;
}

int main(){
	for(;cin>>M>>N,M;){
		v.resize(N);
		for(int i=0;i<N;i++)cin>>v[i];
		set<int>t;
		for(int i=0;i<N;i++)t.insert(i);
		memo.clear();
		printf("%d\n",dfs(t));
	}
}

Compiler output:
a.cc: In function 'int dfs(std::set<int>&)':
a.cc:19:50: error: 'class std::set<int>' has no member named 'push_back'
   19 |                 for(auto &e:t)(v[e][j]=='0'?a:b).push_back(e);
      |                                                  ^~~~~~~~~
Language: C++

class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const It& begin(){return i;}const It& end(){return n;}};
 
#include <iostream>
#include <vector>
#include <string>

using namespace std;
const int INF = 1e9;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    while(cin >> n >> m && n) {
        vector<int> t(m);
        for(int& x : t) {
            string s;
            cin >> s;
            int k = 1;
            for(char c : s)
                x += (c - '0') * k, k *= 2;
        }
        vector<vector<int>> dp(1 << n, vector<int>(1 << n, -1));
        function<int(int, int)> dfs = [&](int s1, int s2) {
            int& res = dp[s1][s2];
            if(res != -1) return res;
            res = INF;
            int cnt = 0;
            for(int x : t) if((s1 & x) == s2) ++cnt;
            if(cnt <= 1) return res = 0;
            for(int i : in(n)) {
                if((1 << i) & s1) continue;
                int ns = s1 | (1 << i);
                res = min(res, max(dfs(ns, s2 | (1 << i)), dfs(ns, s2)) + 1);
            }
            return res;
        };
        
        cout << dfs(0, 0) << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:9: error: 'function' was not declared in this scope
   24 |         function<int(int, int)> dfs = [&](int s1, int s2) {
      |         ^~~~~~~~
a.cc:5:1: note: 'std::function' is defined in header '<functional>'; this is probably fixable by adding '#include <functional>'
    4 | #include <vector>
  +++ |+#include <functional>
    5 | #include <string>
a.cc:24:30: error: expression list treated as compound expression in functional cast [-fpermissive]
   24 |         function<int(int, int)> dfs = [&](int s1, int s2) {
      |                              ^
a.cc:24:18: error: expected primary-expression before 'int'
   24 |         function<int(int, int)> dfs = [&](int s1, int s2) {
      |                  ^~~
a.cc:39:17: error: 'dfs' was not declared in this scope
   39 |         cout << dfs(0, 0) << endl;
      |                 ^~~
Language: C++

#include <iostream> 
#include <numeric> 
#include <cstdlib> 
#include <climits> 
#include <cmath> 
#include <cstdio> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <memory> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <string> 
#include <vector> 
using namespace std; 

#define rep(i, n) for(int i = 0; i < n; i++) 
#define rep2(i, m, n) for(int i = m; i < n; i++) 
const double EPS = 1E-9; 
typedef long long ll; 
typedef pair<int, int> P; 
typedef pair<int, P> PP; 
typedef complex<double> xy_t; 
const int INF = 1 << 30; 

string nums[1000];
int memo[1 << 22];

int n, m;

int calc(int state){
  if(memo[state] != -1) return memo[state];
  else{
    int rest = 0;
    rep(i, n){
      bool ok = true;
      rep(j, m){
	int s = (state >> (j * 2)) & 3;
	if(s == 2 && nums[i][j] == '0') ok = false;
	if(s == 1 && nums[i][j] == '1') ok = false;
      }
      if(ok) rest++;
    }
    if(rest == 0){
      return memo[state] = INF;
    }else if(rest == 1){
      return memo[state] = 0;
    }
  }
  int res = INF;
  rep(i, m){
    int s = (state >> (i * 2)) & 3;
    if(s == 0){
      int a = calc(state | (1 << (i * 2)));
      int b = calc(state | (2 << (i * 2)));
      if(a == INF && b != INF) res = min(res, b + 1);
      else if(b == INF && a != INF) res = min(res, a + 1);
      else if(a != INF && b != INF) res = min(res, max(a, b) + 1);
    }
  }
  return memo[state] = res;
}

int main(){
  while(cin >> m >> n && (m || n)){
    memset(memo, -1, sizeof(memo));
    rep(i, n){
      cin >> nums[i];
    }
    cout << calc(0) << endl;;
  }
  return 0;
}
  

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

#include <iostream> 
#include <numeric> 
#include <cstdlib> 
#include <climits> 
#include <cmath> 
#include <cstdio> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <memory> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <string> 
#include <vector> 
#include <memory>
using namespace std; 

#define rep(i, n) for(int i = 0; i < n; i++) 
#define rep2(i, m, n) for(int i = m; i < n; i++) 
const double EPS = 1E-9; 
typedef long long ll; 
typedef pair<int, int> P; 
typedef pair<int, P> PP; 
typedef complex<double> xy_t; 
const int INF = 1 << 30; 

string nums[1000];
int memo[1 << 22];

int n, m;

int calc(int state){
  if(memo[state] != -1) return memo[state];
  else{
    int rest = 0;
    rep(i, n){
      bool ok = true;
      rep(j, m){
	int s = (state >> (j * 2)) & 3;
	if(s == 2 && nums[i][j] == '0') ok = false;
	if(s == 1 && nums[i][j] == '1') ok = false;
      }
      if(ok) rest++;
    }
    if(rest == 0){
      return memo[state] = INF;
    }else if(rest == 1){
      return memo[state] = 0;
    }
  }
  int res = INF;
  rep(i, m){
    int s = (state >> (i * 2)) & 3;
    if(s == 0){
      int a = calc(state | (1 << (i * 2)));
      int b = calc(state | (2 << (i * 2)));
      if(a == INF && b != INF) res = min(res, b + 1);
      else if(b == INF && a != INF) res = min(res, a + 1);
      else if(a != INF && b != INF) res = min(res, max(a, b) + 1);
    }
  }
  return memo[state] = res;
}

int main(){
  while(cin >> m >> n && (m || n)){
    memset(memo, -1, sizeof(memo));
    rep(i, n){
      cin >> nums[i];
    }
    cout << calc(0) << endl;;
  }
  return 0;
}
  

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

#include <iostream>
#include <vector>
#include <string>

using namespace std;
//        X     Y
int memo[2048];//[2048]; // 判定したか * それぞれのtrue or false = 判定最小回数
int m; // features
int n; // objects
vector<int> objects;

int treeSearch(int X, int Y,const vector<int> & partObjectIds, int depth){
  int minLeafDepth = depth;
  for(int i=0; i<m; ++i){
    vector<int> yesPartObjectIds;
    vector<int> noPartObjectIds;
    int q = 1 << m - i - 1;
    if(q & X) continue; // すでに判定済み
    if(memo[X+q] > 0){ // memo化済み
      minLeafDepth = min(minLeafDepth, memo[X+q]);//max(memo[X+q][Y+q], memo[X+q][Y]));
      continue;
    }

    // 振り分け
    for(vector<int>::iterator id=partObjectIds.begin(); id!=partObjectIds.end(); ++id){
      if(q & objects[*id]){
	yesPartObjectIds.push_back(*id);
      }else{
	noPartObjectIds.push_back(*id);
      }
    }
    
    int yesDepth = 0;
    if(!yesPartObjectIds.empty()){
      yesDepth = treeSearch(X+q, Y+q, yesPartObjectIds, depth+1);
    }else if(!yesPartObjectIds.size()==1){
      yesDepth = depth;
    }

    int noDepth = 0;
    if(!noPartObjectIds.empty()){
      noDepth = treeSearch(X+q, Y, noPartObjectIds, depth+1);
    }else if(!noPartObjectIds.size()==1){
      noDepth = depth;
    }

    minLeafDepth = min(minLeafDepth, max(yesDepth, noDepth));
  }

  memo[X] = minLeafDepth;
  return minLeafDepth;
}

int main(){
  while(true){
    memset((void *)*memo, 0, sizeof(int)*2048*2048);
    objects.clear();
    cin >> m >> n;
    if(m==0 && n==0) break;
    for(int i=0; i<n; ++i){
      string line;
      cin >> line;
      
      int q;
      q = stoi(line, NULL, 2);
      objects.push_back(q);
    }
    cout << treeSearch(0,0,objects,0) << endl;
  }
}

Compiler output:
a.cc: In function 'int treeSearch(int, int, const std::vector<int>&, int)':
a.cc:25:53: error: conversion from '__normal_iterator<const int*,[...]>' to non-scalar type '__normal_iterator<int*,[...]>' requested
   25 |     for(vector<int>::iterator id=partObjectIds.begin(); id!=partObjectIds.end(); ++id){
      |                                  ~~~~~~~~~~~~~~~~~~~^~
a.cc: In function 'int main()':
a.cc:56:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
   56 |     memset((void *)*memo, 0, sizeof(int)*2048*2048);
      |            ^~~~~~~~~~~~~
a.cc:56:5: error: 'memset' was not declared in this scope
   56 |     memset((void *)*memo, 0, sizeof(int)*2048*2048);
      |     ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <vector>
  +++ |+#include <cstring>
    3 | #include <string>
Language: C++

#include <iostream>
#include <vector>
#include <string>

using namespace std;
//        X     Y
int memo[2048];//[2048]; // 判定したか * それぞれのtrue or false = 判定最小回数
int m; // features
int n; // objects
vector<int> objects;

int treeSearch(int X, int Y,const vector<int> & partObjectIds, int depth){
  int minLeafDepth = depth;
  for(int i=0; i<m; ++i){
    vector<int> yesPartObjectIds;
    vector<int> noPartObjectIds;
    int q = 1 << m - i - 1;
    if(q & X) continue; // すでに判定済み
    if(memo[X+q] > 0){ // memo化済み
      minLeafDepth = min(minLeafDepth, memo[X+q]);//max(memo[X+q][Y+q], memo[X+q][Y]));
      continue;
    }

    // 振り分け
    for(auto id=partObjectIds.begin(); id!=partObjectIds.end(); ++id){
      if(q & objects[*id]){
	yesPartObjectIds.push_back(*id);
      }else{
	noPartObjectIds.push_back(*id);
      }
    }
    
    int yesDepth = 0;
    if(!yesPartObjectIds.empty()){
      yesDepth = treeSearch(X+q, Y+q, yesPartObjectIds, depth+1);
    }else if(!yesPartObjectIds.size()==1){
      yesDepth = depth;
    }

    int noDepth = 0;
    if(!noPartObjectIds.empty()){
      noDepth = treeSearch(X+q, Y, noPartObjectIds, depth+1);
    }else if(!noPartObjectIds.size()==1){
      noDepth = depth;
    }

    minLeafDepth = min(minLeafDepth, max(yesDepth, noDepth));
  }

  memo[X] = minLeafDepth;
  return minLeafDepth;
}

int main(){
  while(true){
    memset((void *)*memo, 0, sizeof(int)*2048*2048);
    objects.clear();
    cin >> m >> n;
    if(m==0 && n==0) break;
    for(int i=0; i<n; ++i){
      string line;
      cin >> line;
      
      int q;
      q = stoi(line, NULL, 2);
      objects.push_back(q);
    }
    cout << treeSearch(0,0,objects,0) << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:56:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
   56 |     memset((void *)*memo, 0, sizeof(int)*2048*2048);
      |            ^~~~~~~~~~~~~
a.cc:56:5: error: 'memset' was not declared in this scope
   56 |     memset((void *)*memo, 0, sizeof(int)*2048*2048);
      |     ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <vector>
  +++ |+#include <cstring>
    3 | #include <string>
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstdio>

using namespace std;
//        X     Y
int memo[2048];//[2048]; // 判定したか * それぞれのtrue or false = 判定最小回数
int m; // features
int n; // objects
vector<int> objects;

int treeSearch(int X, int Y,const vector<int> & partObjectIds, int depth){
  int minLeafDepth = depth;
  for(int i=0; i<m; ++i){
    vector<int> yesPartObjectIds;
    vector<int> noPartObjectIds;
    int q = 1 << m - i - 1;
    if(q & X) continue; // すでに判定済み
    if(memo[X+q] > 0){ // memo化済み
      minLeafDepth = min(minLeafDepth, memo[X+q]);//max(memo[X+q][Y+q], memo[X+q][Y]));
      continue;
    }

    // 振り分け
    for(auto id=partObjectIds.begin(); id!=partObjectIds.end(); ++id){
      if(q & objects[*id]){
	yesPartObjectIds.push_back(*id);
      }else{
	noPartObjectIds.push_back(*id);
      }
    }
    
    int yesDepth = 0;
    if(!yesPartObjectIds.empty()){
      yesDepth = treeSearch(X+q, Y+q, yesPartObjectIds, depth+1);
    }else if(!yesPartObjectIds.size()==1){
      yesDepth = depth;
    }

    int noDepth = 0;
    if(!noPartObjectIds.empty()){
      noDepth = treeSearch(X+q, Y, noPartObjectIds, depth+1);
    }else if(!noPartObjectIds.size()==1){
      noDepth = depth;
    }

    minLeafDepth = min(minLeafDepth, max(yesDepth, noDepth));
  }

  memo[X] = minLeafDepth;
  return minLeafDepth;
}

int main(){
  while(true){
    memset((void *)*memo, 0, sizeof(int)*2048*2048);
    objects.clear();
    cin >> m >> n;
    if(m==0 && n==0) break;
    for(int i=0; i<n; ++i){
      string line;
      cin >> line;
      
      int q;
      q = stoi(line, NULL, 2);
      objects.push_back(q);
    }
    cout << treeSearch(0,0,objects,0) << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:58:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
   58 |     memset((void *)*memo, 0, sizeof(int)*2048*2048);
      |            ^~~~~~~~~~~~~
a.cc:58:5: error: 'memset' was not declared in this scope
   58 |     memset((void *)*memo, 0, sizeof(int)*2048*2048);
      |     ^~~~~~
a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    5 | #include <cstdio>
  +++ |+#include <cstring>
    6 |
Language: C++

#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
#include <memory>
#include <time.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-9;
const double PI  = acos(-1.0);


struct node{
	vs f;
	pii pos;
	node(vs &f,pii &pos):f(f),pos(pos){}
	string to_s() const{
		int n=f.size();
		string ret; 
		REP(i,n){
			REP(j,n){
				ret+=pos.first==i&&pos.second==j?'@':f[i][j];
			}
		}
		return ret;
	}
	bool operator<(const node &other)const{
		return to_s()<other.to_s();
	}
};
int dy[]={-1,-1,-1,0,1,1,1,0};
int dx[]={-1,0,1,1,1,0,-1,-1};

vs change(vs &f,int y,int x){
	int n=f.size();
	vs nf(f);
	REP(i,n){
		REP(j,n){
			if(y==i&&x==j)continue;
			int cnt=0;
			REP(d,8){
				int yy=i+dy[d];
				int xx=j+dx[d];
				if(yy>=0&&xx>=0&&yy<n&&xx<n){
					cnt+=f[yy][xx]=='#'||(y==yy&&x==xx);
				}
			}
			switch(f[i][j]){
			case '.':
				nf[i][j]=cnt==3?'#':'.';
				break;
			case '#':
				nf[i][j]=(cnt==2||cnt==3?'#':'.');
				break;
			default:
				assert(0);
			}
		}
	}
	return nf;
}

bool done(vs &f){
	int n=f.size();
	REP(i,n){
		REP(j,n){
			if(f[i][j]=='#'){
				return false;
			}
		}
	}
	return true;
}

int main(){
	int N;
	while(cin>>N,N){
		vs f(N);
		pii p;
		REP(i,N){
			cin>>f[i];
			REP(j,N){
				if(f[i][j]=='@'){
					p=make_pair(i,j);
					f[i][j]='.';
				}
			}
		}
		queue<node> q;
		map<node,int> cost;
		q.push(node(f,p));
		cost[node(f,p)]=0;
		int ans=-1;
		while(q.size()){
			node n=q.front();q.pop();
			if(done(n.f)){
				ans=cost[n];
				break;
			}
			REP(d,8){
				int y=n.pos.first+dy[d];
				int x=n.pos.second+dx[d];
				if(y>=0&&x>=0&&y<N&&x<N){
					if(n.f[y][x]=='.'){
						vs nf=change(n.f,y,x);
						node nnode(nf,make_pair(y,x));
						if(!EXIST(cost,nnode)){
							cost[nnode]=cost[n]+1;
							q.push(nnode);
						}
					}
				}
			}
		}
		cout<<ans<<endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:134:72: error: cannot bind non-const lvalue reference of type 'pii&' {aka 'std::pair<int, int>&'} to an rvalue of type 'std::pair<int, int>'
  134 |                                                 node nnode(nf,make_pair(y,x));
      |                                                               ~~~~~~~~~^~~~~
a.cc:44:25: note:   initializing argument 2 of 'node::node(vs&, pii&)'
   44 |         node(vs &f,pii &pos):f(f),pos(pos){}
      |                    ~~~~~^~~
Language: C++

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

bool onmp(int x,int y){return x>=0&&y>=0&&x<n&&y<n;}

bool check(const vector<string> &A){
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)if(A[i][j]=='#')return 0;
  return 1;
}

int count(int x,int y,const vector<string> &A){
  int res=0;  
  for(int i=-1;i<=1;i++)
    for(int j=-1;j<=1;j++){
      int nx = x+i,ny = y+j;
      if((i||j)&&onmp(nx,ny))res += A[ny][nx]!='.';
    }
  return res;
}

vector<string> mkmp(const vector<string> &A){
  vector<string> res=A;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++){
      int cnt = count(j,i,A);
      if(A[i][j]=='#')res[i][j]=(cnt==2||cnt==3)? '#':'.';
      if(A[i][j]=='.')res[i][j]=(cnt==3)? '#':'.';
      if(A[i][j]=='@')res[i][j]='@';
    }
  return res;
}


void getPos(vector<string>&A,int &x,int &y){
  for(int i=0;i<n&&x==-1;i++)
    for(int j=0;j<n&&x==-1;j++) if(A[i][j]=='@')x=j,y=i;
}



int bfs(vector<string>start){
  queue<vector<string> > Q;
  map<vector<string>,int>D;
  Q.push(start);
  D[start]=0;

  while(!Q.empty()){
    vector<string> A=Q.front();Q.pop();
    pr(A);
    int cost = D[A];
    int x = -1,y=-1;
    getPos(A,x,y);
    if(check(A))return cost;
    if(cost>=10)continue;

    A[y][x] = '.';
    for(int dy=-1;dy<=1;dy++)
      for(int dx=-1;dx<=1;dx++){
	int nx = x+dx,ny = y+dy;
	if((!dx&&!dy)||!onmp(nx,ny)||A[ny][nx]=='#')continue;
	A[ny][nx] = '@';
	vector<string> nA = mkmp(A);
	if(!D.count(nA))Q.push(nA),D[nA] = cost+1;
	A[ny][nx] = '.';
      }
  }
  return -1;
}

int main(){
  while(cin>>n,n){
    vector<string> mp(n);
    for(int i=0;i<n;i++)cin>>mp[i];
    cout<<bfs(mp)<<endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int bfs(std::vector<std::__cxx11::basic_string<char> >)':
a.cc:51:5: error: 'pr' was not declared in this scope
   51 |     pr(A);
      |     ^~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <fstream>
#include <set>

using namespace std;

const int dy[]={-1,-1,-1,0,0,1,1,1};
const int dx[]={-1,0,1,-1,1,-1,0,1};
typedef pair<int,int> pii;
typedef pair<int,pii> sit;

int n;
char field[6][6];
pii sp;


int bfs(){
	int res=0;
	queue<sit> q[2];
	set<sit> used;
	int cur=0;
	int nxt=1;
	int ss=0;
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)if(field[i][j]=='#')ss|=(1<<(i*n+j));
	q[cur].push(sit(ss,sp));
	while(q[cur].size()){
		while(q[cur].size()){
			sit csit=q[cur].front();q[cur].pop();
			if(csit.first==0)return res;
			const int fsit=csit.first;
			const pii &pp=csit.second;
			for(int l=0;l<8;l++){
				if(l==5){
					//cout<<endl;
				}
				int ny=pp.first+dy[l];
				int nx=pp.second+dx[l];
				// Ú®æªÚ®Â\
				if(ny>=0&&nx>=0&&ny<n&&nx<n&&!((fsit>>(ny*n+nx))&1)){
					// infection
					int nfield=0;
					for(int i=0;i<n;i++){
						for(int j=0;j<n;j++){
							if(ny==i&&nx==j)continue;
							// ×ÚvfÌóÔðmF
							int cnt=0;
							for(int k=0;k<8;k++){
								int adx=j+dx[k];
								int ady=i+dy[k];
								if(ady>=0&&adx>=0&&ady<n&&adx<n)
									if(((fsit>>(ady*n+adx))&1)||(ny==ady&&nx==adx))cnt++;
							}
							if((fsit>>(i*n+j))&1){
								if(cnt==2||cnt==3)nfield|=(1<<(i*n+j));
							}
							else{
								if(cnt==3)nfield|=(1<<(i*n+j));
							}
						}
					}
					sit nsit=make_pair(nfield,make_pair(ny,nx));
					if(used.find(nsit)!=used.end())continue;
					used.insert(nsit);
					q[nxt].push(nsit);
				}
			}
		}
		swap(cur,nxt);
		res++;
	}
	return -1;
}

int main(){

	while(cin>>n&&n){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				cin>>field[i][j];
				if(field[i][j]=='@')sp.first=i,sp.second=j,field[i][j]='.';
			}
		}
		int res=bfs();
		cout<<res<<endl;
	}

	return 0;
}

Compiler output:
a.cc:75:9: error: expected unqualified-id before 'return'
   75 |         return -1;
      |         ^~~~~~
a.cc:76:1: error: expected declaration before '}' token
   76 | }
      | ^
a.cc: In function 'int bfs()':
a.cc:74:9: warning: control reaches end of non-void function [-Wreturn-type]
   74 |         }
      |         ^
Language: Java

// Membership Management
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			String[] data = new String[n];
			for (int i = 0; i < n; i++)
				data[i] = scanner.next();
			Queue<Integer> queue = new LinkedList<Integer>();
			Set<String> result = new HashSet<String>();
			queue.add(0);
			while (!queue.isEmpty()) {
				int group = queue.poll();
				String[] members = data[group].split("[:,\.]");
				out: for (int i = 1; i < members.length; i++) {
					for (int j = 0; j < data.length; j++) {
						String name = members[i];
						if (data[j].indexOf(members[i]) == 0) {
							queue.add(j);
							continue out;
						}
					}
					result.add(members[i]);
				}
			}
			System.out.println(result.size());
		}
		scanner.close();
	}
}

Compiler output:
Main.java:19: error: illegal escape character
				String[] members = data[group].split("[:,\.]");
				                                          ^
1 error
Language: Java

import java.util.HashSet;
import java.util.List;
import java.util.regex.Pattern;
import java.io.*;

public class ASA_A {
	public static void main(String[] args) {
		try {
			run();
		}catch(IOException e) {
			System.out.println(e);
		}
	}
	
	private static void run() throws IOException{
		int n;
		int input;
		String inst;
		String[] str;
		Pattern p = Pattern.compile("[:,.]+");
		
		HashSet<String> member = new HashSet<String>();
		HashSet<String> group = new HashSet<String>();
		
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		while(true) {
			member.clear();
			group.clear();
			n = Integer.parseInt(in.readLine()); //???????????£?????????
			if(n==0) break;
			
			for(int i=0;i<n;i++) {
				inst = in.readLine();
				str = p.split(inst,-1);
				group.add(str[0]);
				for(int j=1;j<str.length-1;j++) {
					member.add(str[j]);
				}
			}
			member.removeAll(group);
			System.out.println(""+member.size());
		}
	}
}

Compiler output:
Main.java:6: error: class ASA_A is public, should be declared in a file named ASA_A.java
public class ASA_A {
       ^
1 error