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

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

int main(){
int n;
string f[6]={"North","East","West","South","Right","Left"};
int cf[6][3]={{1,5,2},{4,1,0},{2,1,5},{3,0,2},{0,2,3},{0,4,1}};
int sum=1;
int a=0;
int me[6]={1,2,3,5,4,6};
int ne[3];
cin>>n:
for(int i=0;i<n;i++){
cin>>s;
for(int j=0;j<6;j++){
if(s==f[j]){
for(int k=0;k<3;k++){
ne[k]=me[cf[j][k]];}
for(int k=0;k<3;k++){
me[k]=ne[k];}
me[3]=7-me[1];
me[4]=7-me[2];
me[5]=7-me[0];
break;
}}
sum+=me[0];}
cout<<sum<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:7: error: expected ';' before ':' token
   13 | cin>>n:
      |       ^
      |       ;
a.cc:14:13: error: 'i' was not declared in this scope
   14 | for(int i=0;i<n;i++){
      |             ^
Language: C++

#include <iostream>
#include <string>
using namespace std;
int main(){
string a;
int n;
int b;//上面
int c;//前面
int d;//右面
int e;
int f;
while(cin>>n){
if(n!=0){
b=1;
c=2;
d=3;
e=0;
while(e<n){
cin>>a;
if(a=="North"){f=c; c=7-b; b=f;}
if(a=="East"){f=b; b=7-d; d=f;}
if(a=="West"){f=d; d=7-b; b=f;}
if(a=="South"){f=b; b=7-c; c=f;}
if(a=="Right"){f=d; d=7-c; c=f;}
if(a=="Left"){f=c; c=7-d; d=f;}
e=e+1;}
cout << b << endl;
}
}

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

#include <cstdio>


char opr[10];
int dice(int n){
	scanf("%d",&n);
	if(n==0) return 0;
	int top=1,front=2,right=3,n=0,sum=1,swap;
	for(int i=0;i<n;i++){
		
		scanf("%s",opr);
		switch (opr[0]){
		case 'N':
			swap=top;
			top=front;
			front=(7-swap);
			break;
		case 'E':
			swap=right;
			right=top;
			top=(7-swap);
			break;
		case 'W':
			swap=top;
			top=right;
			right=(7-swap);
			break;
		case 'S':
			swap=front;
			front=top;
			top=(7-swap);
			break;
		case 'R':
			swap=front;
			front=right;
			right=(7-swap);
			break;
		case 'L':
			swap=right;
			right=front;
			front=(7-swap);
			break;

		}
		sum+=top;
	}
	printf("%d\n",sum);
}

int main() {
	while(n==0)	dice(n); 
	return 0;
}

Compiler output:
a.cc: In function 'int dice(int)':
a.cc:8:35: error: declaration of 'int n' shadows a parameter
    8 |         int top=1,front=2,right=3,n=0,sum=1,swap;
      |                                   ^
a.cc:5:14: note: 'int n' previously declared here
    5 | int dice(int n){
      |          ~~~~^
a.cc: In function 'int main()':
a.cc:51:15: error: 'n' was not declared in this scope
   51 |         while(n==0)     dice(n);
      |               ^
a.cc: In function 'int dice(int)':
a.cc:47:15: warning: control reaches end of non-void function [-Wreturn-type]
   47 |         printf("%d\n",sum);
      |         ~~~~~~^~~~~~~~~~~~
Language: C++

#include <cstdio>

int n;
char opr[10];
int dice(int n){
	scanf("%d",&n);
	if(n==0) return 0;
	int top=1,front=2,right=3,n=0,sum=1,swap;
	for(int i=0;i<n;i++){
		
		scanf("%s",opr);
		switch (opr[0]){
		case 'N':
			swap=top;
			top=front;
			front=(7-swap);
			break;
		case 'E':
			swap=right;
			right=top;
			top=(7-swap);
			break;
		case 'W':
			swap=top;
			top=right;
			right=(7-swap);
			break;
		case 'S':
			swap=front;
			front=top;
			top=(7-swap);
			break;
		case 'R':
			swap=front;
			front=right;
			right=(7-swap);
			break;
		case 'L':
			swap=right;
			right=front;
			front=(7-swap);
			break;

		}
		sum+=top;
	}
	printf("%d\n",sum);
}

int main() {
	while( n==0) dice(n); 
	return 0;
}

Compiler output:
a.cc: In function 'int dice(int)':
a.cc:8:35: error: declaration of 'int n' shadows a parameter
    8 |         int top=1,front=2,right=3,n=0,sum=1,swap;
      |                                   ^
a.cc:5:14: note: 'int n' previously declared here
    5 | int dice(int n){
      |          ~~~~^
a.cc:47:15: warning: control reaches end of non-void function [-Wreturn-type]
   47 |         printf("%d\n",sum);
      |         ~~~~~~^~~~~~~~~~~~
Language: C++

100
West
North
North
Right
Left
Right
South
Right
East
Left
North
Right
West
North
East
East
East
North
East
Right
West
Left
West
West
West
West
West
Right
West
East
East
South
West
South
East
North
East
West
Left
South
North
Right
Right
South
Right
North
West
Left
North
Right
North
East
Left
East
West
East
East
Right
South
North
Left
East
North
Left
East
West
North
West
Left
Right
West
Left
West
East
Right
South
West
Right
Right
Left
North
Left
East
North
North
Left
Left
South
East
West
Right
Right
South
East
East
Left
South
East
Left
West

Compiler output:
a.cc:1:1: error: expected unqualified-id before numeric constant
    1 | 100
      | ^~~
Language: C++

#include<iostream>
#include<string>
using namespace std;
int North(int *p){
  int mem;
  mem = p[1];
  p[1] = p[2];
  p[2] = p[6];
  p[6] = p[5];
  p[5] = mem;
  return p[1];
}
int East(int *p){
  int mem;
  mem = p[1];
  p[1] = p[4];
  p[4] = p[6];
  p[6] = p[3];
  p[3] = mem;
  return p[1];
}
int West(int *p){
  int mem;
  mem = p[1];
  p[1] = p[3];
  p[3] = p[6];
  p[6] = p[4];
  p[4] = mem;
  return p[1];
}
int South(int *p){
  int mem;
  mem = p[1];
  p[1] = p[5];
  p[5] = p[6];
  p[6] = p[2];
  p[2] = mem;
  return p[1];
}
int Right(int *p){
  int mem;
  mem = p[2];
  p[2] = p[3];
  p[3] = p[5];
  p[5] = p[4];
  p[4] = mem;
  return p[1];
}
int Left(int *p){
  int mem;
  mem = p[2];
  p[2] = p[4];
  p[4] = p[5];
  p[5] = p[3];
  p[3] = mem;
  return p[1];
}
int main(){
  int n,p[7];;
  string com;
  while(cin >> n){
    if(n==0) break;
    int s = 1;
    for(int i=0;i<=6;i++) p[i] = i;
    for(int i=0;i<n;i++){
      cin >> com;
      if(com=="North") s += North(p);
      else if(com=="East") s += East(p);
      else if(com=="West") s += West(p);
      else if(com=="South") s += South(p);
      else if(com=="Right") s += Right(p);
      else s += Left();
    }
    cout << s << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:72:21: error: too few arguments to function 'int Left(int*)'
   72 |       else s += Left();
      |                 ~~~~^~
a.cc:49:5: note: declared here
   49 | int Left(int *p){
      |     ^~~~
Language: C

#include<stdio.h>

struct cup{
    int num;
    int item[15];
    cup *next;
}

int put(cup *old,cup *new) {
    if(old.item[old.num-1]<new.item[new.num-1]){
        new.item[new.num]=old.item[old.num-1];
        new.num++;
        old.num--;
        return TRUE;
    }
    return FALSE;
}

void scan(cup *first){
    int a;
    scanf("%d\n",&first.num);
    for(a=0;a<first.num;a++){
        scanf("%d\n",&first.item[a]);
    }
    if (first.next==NULL) {
        return;
    }
    scan(first.next);
}

int main(int argc, char const *argv[]) {
  int n,cn,i;
  cup a,b,c;
  a.next=&b;
  b.next=&c;
  c.next=NULL;
  long m,j,count,min;
  scanf("%d %ld\n",&n,&m);
  while(n>0 && m>0){
      scan(&a);
      
      
      scanf("%d %ld\n",&n,&m);
  }
  return 0;
}

Compiler output:
main.c:6:5: error: unknown type name 'cup'
    6 |     cup *next;
      |     ^~~
main.c:9:1: error: expected ';', identifier or '(' before 'int'
    9 | int put(cup *old,cup *new) {
      | ^~~
main.c:9:9: error: unknown type name 'cup'
    9 | int put(cup *old,cup *new) {
      |         ^~~
main.c:9:18: error: unknown type name 'cup'
    9 | int put(cup *old,cup *new) {
      |                  ^~~
main.c:19:11: error: unknown type name 'cup'
   19 | void scan(cup *first){
      |           ^~~
main.c: In function 'main':
main.c:33:3: error: unknown type name 'cup'; use 'struct' keyword to refer to the type
   33 |   cup a,b,c;
      |   ^~~
      |   struct 
main.c:34:4: error: request for member 'next' in something not a structure or union
   34 |   a.next=&b;
      |    ^
main.c:35:4: error: request for member 'next' in something not a structure or union
   35 |   b.next=&c;
      |    ^
main.c:36:4: error: request for member 'next' in something not a structure or union
   36 |   c.next=NULL;
      |    ^
main.c:40:7: error: implicit declaration of function 'scan'; did you mean 'scanf'? [-Wimplicit-function-declaration]
   40 |       scan(&a);
      |       ^~~~
      |       scanf
Language: C

#include<stdio.h>

struct cup{
    int num;
    int item[15];
}

int put(struct cup *old,struct cup *new) {
    if(old.item[old.num-1]<new.item[new.num-1]){
        new.item[new.num]=old.item[old.num-1];
        new.num++;
        old.num--;
        return TRUE;
    }
    return FALSE;
}


int main(int argc, char const *argv[]) {
  int n,cn,i;
  struct cup a[3];
  long m,j,count,min;
  scanf("%d %ld\n",&n,&m);
  while(n>0 && m>0){
      for(j=0;j<3;i++){
          scanf("%d",&a[j].num);
          for(i=0;i<a[j].num;i++){
              scanf("%d",&a[j].item[i]);
          }
      }
      
      
      scanf("%d %ld\n",&n,&m);
  }
  return 0;
}

Compiler output:
main.c:8:1: error: expected ';', identifier or '(' before 'int'
    8 | int put(struct cup *old,struct cup *new) {
      | ^~~
main.c: In function 'put':
main.c:9:11: error: 'old' is a pointer; did you mean to use '->'?
    9 |     if(old.item[old.num-1]<new.item[new.num-1]){
      |           ^
      |           ->
main.c:9:20: error: 'old' is a pointer; did you mean to use '->'?
    9 |     if(old.item[old.num-1]<new.item[new.num-1]){
      |                    ^
      |                    ->
main.c:9:31: error: 'new' is a pointer; did you mean to use '->'?
    9 |     if(old.item[old.num-1]<new.item[new.num-1]){
      |                               ^
      |                               ->
main.c:9:40: error: 'new' is a pointer; did you mean to use '->'?
    9 |     if(old.item[old.num-1]<new.item[new.num-1]){
      |                                        ^
      |                                        ->
main.c:10:12: error: 'new' is a pointer; did you mean to use '->'?
   10 |         new.item[new.num]=old.item[old.num-1];
      |            ^
      |            ->
main.c:10:21: error: 'new' is a pointer; did you mean to use '->'?
   10 |         new.item[new.num]=old.item[old.num-1];
      |                     ^
      |                     ->
main.c:10:30: error: 'old' is a pointer; did you mean to use '->'?
   10 |         new.item[new.num]=old.item[old.num-1];
      |                              ^
      |                              ->
main.c:10:39: error: 'old' is a pointer; did you mean to use '->'?
   10 |         new.item[new.num]=old.item[old.num-1];
      |                                       ^
      |                                       ->
main.c:11:12: error: 'new' is a pointer; did you mean to use '->'?
   11 |         new.num++;
      |            ^
      |            ->
main.c:12:12: error: 'old' is a pointer; did you mean to use '->'?
   12 |         old.num--;
      |            ^
      |            ->
main.c:13:16: error: 'TRUE' undeclared (first use in this function)
   13 |         return TRUE;
      |                ^~~~
main.c:13:16: note: each undeclared identifier is reported only once for each function it appears in
main.c:15:12: error: 'FALSE' undeclared (first use in this function)
   15 |     return FALSE;
      |            ^~~~~
Language: C

#include <iostream>
#include <tuple>
#include <map>
using namespace std;

const int NONE = -1;
typedef tuple<int, int, int> Tuple;
map<Tuple, int> S;
Tuple goal;
int n, m;

int get_last( int m ) {
    for ( int i = n - 1; i >= 0; -- i ) {
        if ( ( m & ( 1 << i ) ) == ( 1 << i ) ) return 1 << i;
    }
    return 0;
}

int remove_last( int m ) {
    for ( int i = n - 1; i >= 0; -- i ) {
        if ( ( m & ( 1 << i ) ) == ( 1 << i ) ) return m ^ ( 1 << i );
    }
    return m;
}

int solve( int A, int B, int C, int turns ) {
    Tuple tuple = make_tuple( A, B, C );
    if ( S.count( tuple ) > 0 && turns >= S[tuple] ) return -1;
    S[tuple] = turns;
    if ( turns > m ) return -1;
    if ( tuple == goal ) return turns;
    if ( C != 0 ) {
        int u = get_last(C);
        int v = get_last(B);
        if ( u > v ) {
            int ret = solve( A, B | u, remove_last(C), turns + 1 );
            if ( ret != NONE ) return ret;
        }
    }
    return -1;
}

int main() {
    while ( cin >> n >> m ) {
        if ( n == 0 && m == 0 ) break;
        S.clear();
        int T[3] = { 0, 0, 0 };
        for ( int i = 0; i < 3; ++ i ) {
            int k;
            cin >> k;
            for ( int j = 0; j < k; ++ j ) {
                int t;
                cin >> t;
                t--;
                T[i] |= 1 << t;
            }
        }
        goal = make_tuple( T[0], T[1], T[2] );
        int ret1 = solve( (1<<n)-1, 0, 0, 0 );
        int ret2 = solve( 0, 0, (1<<n)-1, 0 );
        if ( ret1 == NONE && ret2 == NONE ) {
            cout << -1 << endl;
        } else if ( ret1 != NONE && ret2 != NONE ) {
            cout << min( ret1, ret2 ) << endl;
        } else if ( ret1 != NONE ) {
            cout << ret1 << endl;
        } else if ( ret2 != NONE ) {
            cout << ret2 << endl;
        }
    }
    return 0;
}

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

#include <stdio.h>

#define NMAX 15
#define MMAX 15000000

int cup[3];
int cup_move[4][2] = {{0,1},{1,0},{1,2},{2,1}};
int stack[MMAX][3];

int move(int temp[3],int a,int amin, int amax)
{
	int i,l,m;
	bool flag;

	for(m=0;m<4;m++){
		if(temp[cup_move[m][0]]>temp[cup_move[m][1]]){
			l= 1<<NMAX;
			while((l & temp[cup_move[m][0]]) == 0) l>>=1;
			temp[cup_move[m][0]] -= l;
			temp[cup_move[m][1]] += l;
			a++;
			stack[a][0]=temp[0];
			stack[a][1]=temp[1];
			stack[a][2]=temp[2];

			if(a>amax){
				return a--;
			}
			if(temp[1]==0 && (temp[0]==0 || temp[2]==0)){
				if(amin>a) amin=a;
				return a--;
			}

			flag = false;
			for(i=0;i<a;i++){
				if(stack[i][0]==temp[0] && stack[i][1]==temp[1] && stack[i][2]==temp[2]){
					a--;
					temp[0]=stack[a][0];
					temp[1]=stack[a][1];
					temp[2]=stack[a][2];
					flag = true;
					break;
				}
			}
			if(!flag) amin = move(temp,a,amin,amax);
		}
	}
	return amin;
}

int main(void)
{
	int n,m;
	int c_max,c;
	int i,j;
	int a;
	int temp[3];

	while(scanf("%d%d", &n, &m) && n+m){
		for(i=0;i<3;i++){
			cup[i] = 0;
			scanf("%d", &c_max);
			for(j=0;j<c_max;j++){
				scanf("%d", &c);
				cup[i] |= 1 << (c-1);
			}
		}

		if(cup[1]==0 && (cup[0]==0 || cup[2]==0)){
			printf("0\n");
			continue;
		}

		for(i=0;i<3;i++){
			temp[i]=cup[i];
			stack[0][i]=cup[i];
		}
		a = move(temp,0,m,m);

		if(a>m){
			printf("-1\n");
		}else{
			printf("%d\n",a);
		}
	}

	return 0;
}

Compiler output:
main.c: In function 'move':
main.c:13:9: error: unknown type name 'bool'
   13 |         bool flag;
      |         ^~~~
main.c:2:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
    1 | #include <stdio.h>
  +++ |+#include <stdbool.h>
    2 | 
main.c:34:32: error: 'false' undeclared (first use in this function)
   34 |                         flag = false;
      |                                ^~~~~
main.c:34:32: note: 'false' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
main.c:34:32: note: each undeclared identifier is reported only once for each function it appears in
main.c:41:48: error: 'true' undeclared (first use in this function)
   41 |                                         flag = true;
      |                                                ^~~~
main.c:41:48: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
Language: C++


	{
	  finish.push(i);
	}
      for(int i=0;i<3;i++)
	{
	  int size;
	  cin>>size;
	  for(int j=0;j<size;j++)
	    {
	      int tmp;
	      cin>>tmp;
	      table[i].push(tmp);
	    }
	}
      //stack,step;
      queue<pair<pair<stack<char>,stack<char> >,pair<stack<char> ,int> > > qu;
      qu.push(make_pair(make_pair(table[0],table[1]),make_pair(table[2],0)));
      int ans=-1;
      while(!qu.empty())
	{
	  stack<char>a=qu.front().first.first;
	  stack<char>b=qu.front().first.second;
	  stack<char>c=qu.front().second.first;
	  int step=qu.front().second.second;
	  qu.pop();

	  if(a==finish || c==finish)
	    {
	      ans=step;
	      break;
	    }

	  if(hash.find(make_pair(a,c))!=hash.end())
	    continue;
	  hash.insert(make_pair(a,c));

	  if(step==m)
	    continue;

	  if(!a.empty())
	    {
	      if(b.empty()||a.top()>b.top() )
		{
		  int tmp=a.top();
		  a.pop();
		  b.push(tmp);
		  if(hash.find(make_pair(a,c))==hash.end())
		    qu.push(make_pair(make_pair(a,b),make_pair(c,step+1)));
		  tmp=b.top();
		  b.pop();
		  a.push(tmp);
		}
	    }
	  if(!b.empty())
	    {
	      if(a.empty()||a.top()<b.top() )
		{
		  int tmp=b.top();
		  b.pop();
		  a.push(tmp);
		  if(hash.find(make_pair(a,c))==hash.end())
		    qu.push(make_pair(make_pair(a,b),make_pair(c,step+1)));
		  tmp=a.top();
		  a.pop();
		  b.push(tmp);
		}

	      if(c.empty()||c.top()<b.top() )
		{
		  int tmp=b.top();
		  b.pop();
		  c.push(tmp);
		  if(hash.find(make_pair(a,c))==hash.end())
		    qu.push(make_pair(make_pair(a,b),make_pair(c,step+1)));
		  tmp=c.top();
		  c.pop();
		  b.push(tmp);
		}

	    }
	  if(!c.empty())
	    {
	      if(b.empty()||b.top()<c.top() )
		{
		  int tmp=c.top();
		  c.pop();
		  b.push(tmp);
		  if(hash.find(make_pair(a,c))==hash.end())
		    qu.push(make_pair(make_pair(a,b),make_pair(c,step+1)));
		  tmp=b.top();
		  b.pop();
		  c.push(tmp);
		}

	    }



	}
      cout<<ans<<endl;
    }

}

Compiler output:
a.cc:2:9: error: expected unqualified-id before '{' token
    2 |         {
      |         ^
a.cc:5:7: error: expected unqualified-id before 'for'
    5 |       for(int i=0;i<3;i++)
      |       ^~~
a.cc:5:19: error: 'i' does not name a type
    5 |       for(int i=0;i<3;i++)
      |                   ^
a.cc:5:23: error: 'i' does not name a type
    5 |       for(int i=0;i<3;i++)
      |                       ^
a.cc:17:7: error: 'queue' does not name a type
   17 |       queue<pair<pair<stack<char>,stack<char> >,pair<stack<char> ,int> > > qu;
      |       ^~~~~
a.cc:18:7: error: 'qu' does not name a type
   18 |       qu.push(make_pair(make_pair(table[0],table[1]),make_pair(table[2],0)));
      |       ^~
a.cc:20:7: error: expected unqualified-id before 'while'
   20 |       while(!qu.empty())
      |       ^~~~~
a.cc:101:7: error: 'cout' does not name a type
  101 |       cout<<ans<<endl;
      |       ^~~~
a.cc:102:5: error: expected declaration before '}' token
  102 |     }
      |     ^
a.cc:104:1: error: expected declaration before '}' token
  104 | }
      | ^
Language: C++

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

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
typedef struct Cup
{
	vector<int>P[3];
	int T;
	bool operator <(const Cup &a)const{ return T>a.T;};
}S;
int N,M;
bool f[3][3][3][3][3][3][3][3][3][3][3][3][3][3][3];
int main()
{
	for(;scanf("%d%d",&N,&M),N;)
	{
		Cup tmp;
		int i,j,t,q,R=-1;
		memset(f,0,sizeof(f));
		for(i=0;i<3;i++)
		{
			for(scanf("%d",&t),j=0;j<t;j++)
			{
				scanf("%d",&q);
				tmp.P[i].push_back(q);
			}
		}

		tmp.T=0;
		priority_queue<Cup> Q;
		Q.push(tmp);
		while(!Q.empty())
		{
			tmp=Q.top();Q.pop();
			int p[15];
			for(int i=0;i<3;i++)
				for(int j=0;j<tmp.P[i].size();j++)
					p[tmp.P[i][j]-1]=i;
			if(f[p[0]][p[1]][p[2]][p[3]][p[4]][p[5]][p[6]][p[7]][p[8]][p[9]][p[10]][p[11]][p[12]][p[13]][p[14]])continue;
			if(tmp.T>M)continue;
			if(tmp.P[0].size()==N||tmp.P[2].size()==N)
			{
				R=tmp.T;
				break;
			}
			for(int i=0;i<3;i++)
				for(int j=-1;j<2;j++)
				{
					if(j&&i+j>=0&&i+j<3&&!tmp.P[i].empty())
					{
						int tmp1=tmp.P[i].back();
						int tmp2=-1;
						if(!tmp.P[i+j].empty())
							tmp2=tmp.P[i+j].back();
						if(tmp1>tmp2)
						{
							Cup ins=tmp;
							ins.P[i+j].push_back(tmp1);
							ins.P[i].pop_back();
							ins.T++;
							Q.push(ins);
							f[p[0]][p[1]][p[2]][p[3]][p[4]][p[5]][p[6]][p[7]][p[8]][p[9]][p[10]][p[11]][p[12]][p[13]][p[14]]=1;
						}
					}
				}
		}
		printf("%d\n",R);
	}
}

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

#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <array>
#include <stack>
#include <queue>
#include <chrono>
#include <numeric>
#include <memory.h>
#include <map>
#include <math.h>

#include "graph.h"

#pragma warning(disable:4996)
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
typedef long long Int;
const double PI = 3.141592653589793238;
const Int INF = 999999999999;
using namespace std;

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

struct state{
	vector<int> A, B, C;
	int step = 0;
};

int main()
{
	int n, m;
	while (cin >> n >> m, n&&m){
		queue<state> que;

		state s;
		REP(i,3){
			int k;
			cin >> k;
			REP(j,k){
				int a;
				cin >> a;
				if (i ==0)
					s.A.push_back(a);
				if (i == 1)
					s.B.push_back(a);
				if (i == 2)
					s.C.push_back(a);
			}
		}

		que.push(s);
		while (!que.empty()){
			state now = que.front();
			que.pop();

			if ((now.B.empty() && now.C.empty()) || (now.B.empty() && now.A.empty())){
				cout << now.step << endl;
				break;
			}

			if (now.step > m){
				cout << -1 << endl;
				break;
			}

			if (!now.A.empty() && (now.B.empty() || (now.A.back() > now.B.back()))){
				state next = now;
				next.B.push_back(next.A.back());
				next.A.pop_back();
				++next.step;
				que.push(next);
			}
			if (!now.B.empty() && (now.A.empty() || (now.A.back() < now.B.back()))){
				state next = now;
				next.A.push_back(next.B.back());
				next.B.pop_back();
				++next.step;
				que.push(next);
			}
			if (!now.B.empty() && (now.C.empty() || (now.B.back() > now.C.back()))){
				state next = now;
				next.C.push_back(next.B.back());
				next.B.pop_back();
				++next.step;
				que.push(next);
			}
			if (!now.C.empty() && (now.B.empty() || (now.B.back() < now.C.back()))){
				state next = now;
				next.B.push_back(next.C.back());
				next.C.pop_back();
				++next.step;
				que.push(next);
			}

		}

	}
	return 0;
}

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

3 10
1 1
1 3
1 2
4 100
1 3
3 1 2 4
0
5 100
0
4 2 3 4 5
1 1
10 10000
4 1 4 5 9
3 2 3 7
3 6 8 10
15 15000000
4 1 2 9 12
6 4 7 11 13 14 15
5 3 5 6 8 10
0 0

Compiler output:
a.cc:1:1: error: expected unqualified-id before numeric constant
    1 | 3 10
      | ^
Language: C++

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

int n, m;
struct puzzle {
	char f[3][15];
	int len[3], cnt;
};
bool operator==(const puzzle&left, const puzzle&right) {
	rep(i, 3) {
		if (strcmp(left.f[i], right.f[i]))return false;
	}
	return true;
}
template<>
class hash<puzzle> {
public:
	inline size_t operator()(const puzzle&p) const {
		size_t cnt = 0;
		rep(i, 3) {
			hash<string>H;
			cnt += (i + 1)*H(p.f[i]);
		}
		return cnt;
	}
};

int main() {
	while (scanf("%d%d", &n, &m), n) {
		puzzle in{};
		rep(i, 3) {
			scanf("%d", &in.len[i]);
			rep(j, in.len[i])scanf("%d", &in.f[i][j]);
		}
		unordered_map<puzzle, bool>mp;
		queue<puzzle>que;
		mp[in] = true;
		que.push(in);
		while (!que.empty()) {
			puzzle u = que.front(); que.pop();
			if (u.len[0] == n || u.len[2] == n) {
				printf("%d\n", u.cnt);
				goto g;
			}
			if (u.cnt >= m)continue;
			rep(k, 2)rep(t, 2) {
				int i, j;
				if (t) { i = k, j = k + 1; }
				else { i = k + 1; j = k; }
				if (u.len[i] == 0)continue;
				if (u.len[j] > 0 && (u.f[i][u.len[i] - 1] < u.f[j][u.len[j] - 1]))
					continue;
				puzzle v = u;
				v.len[i]--; v.len[j]++;
				swap(v.f[i][v.len[i]], v.f[j][v.len[j] - 1]);
				if (!mp[v]) {
					mp[v] = true;
					v.cnt++;
					que.push(v);
				}
			}
		}
		puts("-1");
	g:;
	}
}

Compiler output:
a.cc:17:7: error: explicit specialization of 'template<class _Tp> struct std::hash' outside its namespace must use a nested-name-specifier [-fpermissive]
   17 | class hash<puzzle> {
      |       ^~~~~~~~~~~~
Language: C++

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

int n, m;
struct puzzle {
	char f[3][15];
	int len[3], cnt;
};
bool operator==(const puzzle&left, const puzzle&right) {
	rep(i, 3) {
		if (strcmp(left.f[i], right.f[i]))return false;
	}
	return true;
}
template<>
struct hash<puzzle> {
	inline size_t operator()(const puzzle&p) const {
		size_t cnt = 0;
		rep(i, 3) {
			hash<string>H;
			cnt += (i + 1)*H(p.f[i]);
		}
		return cnt;
	}
};

int main() {
	while (scanf("%d%d", &n, &m), n) {
		puzzle in{};
		rep(i, 3) {
			scanf("%d", &in.len[i]);
			rep(j, in.len[i])scanf("%d", &in.f[i][j]);
		}
		unordered_map<puzzle, bool>mp;
		queue<puzzle>que;
		mp[in] = true;
		que.push(in);
		while (!que.empty()) {
			puzzle u = que.front(); que.pop();
			if (u.len[0] == n || u.len[2] == n) {
				printf("%d\n", u.cnt);
				goto g;
			}
			if (u.cnt >= m)continue;
			rep(k, 2)rep(t, 2) {
				int i, j;
				if (t) { i = k, j = k + 1; }
				else { i = k + 1; j = k; }
				if (u.len[i] == 0)continue;
				if (u.len[j] > 0 && (u.f[i][u.len[i] - 1] < u.f[j][u.len[j] - 1]))
					continue;
				puzzle v = u;
				v.len[i]--; v.len[j]++;
				swap(v.f[i][v.len[i]], v.f[j][v.len[j] - 1]);
				if (!mp[v]) {
					mp[v] = true;
					v.cnt++;
					que.push(v);
				}
			}
		}
		puts("-1");
	g:;
	}
}

Compiler output:
a.cc:17:8: error: explicit specialization of 'template<class _Tp> struct std::hash' outside its namespace must use a nested-name-specifier [-fpermissive]
   17 | struct hash<puzzle> {
      |        ^~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#include <spdlog/spdlog.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 1 << 30
#define LLINF LLONG_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;FOR(i,1,a)b*=i;return b;}
ll power(ll x,ll n){ll a=1;REP(i,n)a*=x;return a;}

int p[20];

int f(int a, int b, int c)
{
  if(!b&&!c) return 0;
  int s = (a|b|c)>>1;
  int t = 0;
  while(s&1) {t++;s>>=1;}
  if(1&a) return f(a>>1,b>>1,c>>1);
  if(1&b) return f(c>>1,b>>1,a>>1)+p[t];
  if(1&c) return f(a>>1,b>>1,c>>1)+2*p[t];
}

int main()
{
  int n,m;
  REP(i,20)
  {
    p[i] = pow(3,i);
  }
  while(cin >> n >> m,n)
  {
    int a[3] = {0};
    REP(i,3)
    {
      int t,u; cin >> t;
      REP(j,t)
      {
        cin >> u;
        a[i] |= 1 << u-1;
      }
    }
    int ans = min(f(a[0],a[1],a[2]),f(a[2],a[1],a[0]));
    cout << (ans>m?-1:ans) << endl;
  }
}

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

#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

const pii Dir[8] = { //?????????
	{ 0,1 },{ 0,-1 },{ 1,0 },{ -1,0 },
	{ 1,1 },{ 1,-1 },{ -1,-1 },{ -1,1 }
};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}

signed main() {
	int n, m;
	scanf("%d %d", &n, &m);

	ll dp[16] = {};
	dp[0] = 1;
	rep(i,1, n+1) {
		dp[i] = dp[i - 1] * 3;
	}
	vector<int> pos(n);
	REP(i, 3) {
		int c;
		scanf("%d", &c);


		REP(j, c) {
			int size;
			scanf("%d", &size);

			pos[size-1] = i;
		}
	}
	//reverse(ALL(pos));
	ll ans = 0,ans2 = 0;
	bool curs = 0;
	REP(i, n) {
		if (pos[i] % 2) {
			ans += dp[n - i - 1];
			curs = 1-curs;
		}
		else if (curs*2-pos[i]) {
			ans += dp[n - i - 1] + 1;
		}
	}
	bool curs = 1;
	REP(i, n) {
		if (pos[i] % 2) {
			ans2 += dp[n - i - 1];
			curs = 1 - curs;
		}
		else if (curs * 2 - pos[i]) {
			ans2 += dp[n - i - 1] + 1;
		}
	}
	printf("%lld\n", min(ans2, ans));
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:77:14: error: redeclaration of 'bool curs'
   77 |         bool curs = 1;
      |              ^~~~
a.cc:67:14: note: 'bool curs' previously declared here
   67 |         bool curs = 0;
      |              ^~~~
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
void input(vector<int> &);
int main() {
	int n, m;
	vector<int> table;
	int point[] = { 0,2 };
	int move[] = { 2,0,0 };
	while (cin >> n >> m&&n != 0) {
		table.resize(n + 1);
		input(table);
		int ans = (1 << 31) - 1;
		int default = 1;
		for (int i = 1; i < n; ++i) {
			default *= 3;
		}
		for (int i = 0; i < 2; ++i) {
			int stock = default;
			int place = point[i];
			int dnum = 0;
			for (int j = 1; j <= n; ++j) {
				if (abs(table[j]- place)==1) {
					dnum += stock;
					place = move[place];
				}
				else if (abs(table[j] - place)==2) {
					dnum += stock * 2;
				}
				stock /= 3;
			}
			ans = min(ans, dnum);
		}
		cout << (ans <= m ? ans : -1) << endl;
	}
	return 0;
}

void input(vector<int > &table) {
	for (int i = 0; i < 3; ++i) {
		int time;
		cin >> time;
		for (int j = 0; j < time; ++j) {
			int num;
			cin >> num;
			table[num] = i;
		}
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:37: warning: integer overflow in expression of type 'int' results in '2147483647' [-Woverflow]
   14 |                 int ans = (1 << 31) - 1;
      |                           ~~~~~~~~~~^~~
a.cc:15:21: error: expected unqualified-id before 'default'
   15 |                 int default = 1;
      |                     ^~~~~~~
a.cc:17:25: error: case label not within a switch statement
   17 |                         default *= 3;
      |                         ^~~~~~~
a.cc:17:32: error: expected ':' before '*=' token
   17 |                         default *= 3;
      |                                ^~~
      |                                :
a.cc:17:33: error: expected primary-expression before '*=' token
   17 |                         default *= 3;
      |                                 ^~
a.cc:20:37: error: expected primary-expression before 'default'
   20 |                         int stock = default;
      |                                     ^~~~~~~
Language: C++

#include <cstdio>

int nn = 1, an, bn, cn, a[20], b[20], c[20], total = 0, f = 1;

struct mm{
	char ch;
	int nu;
};

struct mm m1, m2;

int calculation(int min, int max){
	if(min == max)return 0;
	if(min < max)int sum = calculation(++min, max) * 3 + 2;
	return sum;
}

int move(int flag){
	int number;
	if(flag == 0){
		number = an - m1.nu + 1;
		for(int i = 0;i < number;i++)c[++cn] = a[an--];
	}
	if(flag == 1){
		number = cn - m1.nu + 1;
		for(int i = 0;i < number;i++)a[++an] = c[cn--];
	}
	calculation(0, number);
	return 0;
}

int sort(){
	if(m1.ch == m2.ch)return 0;
	if(m2.ch == 'b'){
		if(m1.ch == 'a')c[++cn] = b[bn--], move(0); //???
		if(m1.ch == 'c')a[++an] = a[an--], move(1); //???
	}
	return 0;
}

int solve(int max){
	for(int i = 0;i < an;i++){
		if(a[i] == max)m1.ch = 'a',m1.nu = i;
		if(a[i] == max - 1)m2.ch = 'a', m2.nu = i;
	}
	for(int i = 0;i < bn;i++){
		if(b[i] == max)m1.ch = 'b',m1.nu = i;
		if(b[i] == max - 1)m2.ch = 'b', m2.nu = i;
	}
	for(int i = 0;i < cn;i++){
		if(c[i] == max)m1.ch = 'c',m1.nu = i;
		if(c[i] == max - 1)m2.ch = 'c', m2.nu = i;
	}
	if(f == 1 && m1.nu == bn){
		if(m2.ch == 'a'){
			a[++an] = b[bn--];
		}else if(m2.ch == 'c'){
			c[++cn] = b[bn--];
		}
	}else{
		sort();
	}
	return 0;
}

int main(){
	int n, m, max;
	int a[20], b[20], c[20];
	scanf("%d %d",&n, &m);
	
	scanf("%d", &an);
	for(int i = 0;i < an;i++){
		scanf("%d", &a[i]);
		if(a[i] > max)max = a[i];
	}
	scanf("%d", &bn);
	for(int i = 0;i < bn;i++){
		scanf("%d", &b[i]);
		if(b[i] > max)max = b[i];
	}
	scanf("%d", &cn);
	for(int i = 0;i < cn;i++){
		scanf("%d", &c[i]);
		if(c[i] > max)max = c[i];
	}
	
	solve(max);
	
	printf("%d %d",n, m);
	return 0;
}

Compiler output:
a.cc: In function 'int calculation(int, int)':
a.cc:15:16: error: 'sum' was not declared in this scope
   15 |         return sum;
      |                ^~~
Language: C++

#include<stdio.h>
int main(void){
    int n, m, a[1000], b[10000][1000] = { 0 };
    scanf("%d %d", &n, &m);
    while ( 1 ) {
        for ( i = 0; i < n; i++ ) {
            scanf("%d", &a[i]);
            for ( j = 0; j < a[i]; j++ ) {
                scanf("%d", &b[i][j]);
            }
        }
        for ( i = 0; i < m; i++ ) {
            for ( j = 0; j < n; i++ ) {
                for ( x = )
            }
        }
        scanf("%d %d", &n, &m);
        if ( n == 0 && m == 0 ) break;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:15: error: 'i' was not declared in this scope
    6 |         for ( i = 0; i < n; i++ ) {
      |               ^
a.cc:8:19: error: 'j' was not declared in this scope
    8 |             for ( j = 0; j < a[i]; j++ ) {
      |                   ^
a.cc:12:15: error: 'i' was not declared in this scope
   12 |         for ( i = 0; i < m; i++ ) {
      |               ^
a.cc:13:19: error: 'j' was not declared in this scope
   13 |             for ( j = 0; j < n; i++ ) {
      |                   ^
a.cc:14:23: error: 'x' was not declared in this scope
   14 |                 for ( x = )
      |                       ^
a.cc:14:27: error: expected primary-expression before ')' token
   14 |                 for ( x = )
      |                           ^
a.cc:15:13: error: expected primary-expression before '}' token
   15 |             }
      |             ^
a.cc:14:28: error: expected ';' before '}' token
   14 |                 for ( x = )
      |                            ^
      |                            ;
   15 |             }
      |             ~               
a.cc:15:13: error: expected primary-expression before '}' token
   15 |             }
      |             ^
a.cc:14:28: error: expected ')' before '}' token
   14 |                 for ( x = )
      |                     ~      ^
      |                            )
   15 |             }
      |             ~               
a.cc:15:13: error: expected primary-expression before '}' token
   15 |             }
      |             ^
Language: C++

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <fstream>

using namespace std;

int main()
{
	int N, M, K;
	while(cin>>N>>M && (N || M)){
		
		//iÔÚÉå«¢lªÇÌgCÉ¨¢Ä é©
		vector<int> v(N+1);
		
		for(int i = 0; i < 3; i++){
			cin>>K;
			for(int j = 0; j < K; j++){
				int tmp;
				cin>>tmp;
				v[tmp] = i;
			}
		}

		vector<int> a(N+1), c(N+1);
		a[N] = v[N];	c[N] = 2 - v[N];

		for(int i = N; i > 1; i--)
		{
			switch(v[i-1])
			{
			case 0:

				a[i-1] = a[i];
				c[i-1] = c[i] + 2 * pow(3.0, N-i+1);
				break;

			case 1:
				a[i-1] = c[i] + pow(3.0, N-i+1);
				c[i-1] = a[i] + pow(3.0, N-i+1);
				break;

			case 2:
				
				a[i-1] = a[i] + 2 * pow(3.0, N-i+1);
				c[i-1] = c[i];
				break;
			}
		}

		int res = min(a[1], c[1]);
		if(M < res) res = -1;
		cout << res << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:53: error: 'pow' was not declared in this scope
   40 |                                 c[i-1] = c[i] + 2 * pow(3.0, N-i+1);
      |                                                     ^~~
Language: C++

#define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,vector<int> > P;
typedef pair <int,P> PP;
typedef pair <int,PP> PPP;

static const double eps = 1e-8;

int bfs(int m,vector<int>& sets, map<vector<int>,int>& visited){

	priority_queue<P,vector<P>,greater<P> > que;
	que.push(P(0,sets));
	visited[sets] = 0;

	vector<int> sets;
	vector<int> tmp;
	while(!que.empty()){
		int cost = que.top().first;
		
		sets = que.top().second;

		if(sets[1]==0 && sets[2]==0) return cost;
		if(sets[0]==0 && sets[1]==0) return cost;

		if(cost >= m) break;
		que.pop();
		for(int i=0;i+1<sets.size();i++){
			if((sets[i] && sets[i+1] && sets[i] < sets[i+1]) 
				|| (!sets[i] && sets[i+1])){
				tmp = sets;

				int pos=0;
				for(int j=15;j>=0;j--){
					if(tmp[i+1] & (1<<j)){
						pos = j;
						break;
					}
				}
				tmp[i+1] &= ~(1<<pos);
				tmp[i] |= (1<<pos);

				if(visited.find(tmp) == visited.end()){
					visited[tmp] = cost + 1;
					que.push(P(cost+1,tmp));
				}
			}

			else if((sets[i] && sets[i+1] && sets[i] > sets[i+1]) 
				|| (sets[i] && !sets[i+1])){
				tmp = sets;

				int pos=0;
				for(int j=15;j>=0;j--){
					if(tmp[i] & (1<<j)){
						pos = j;
						break;
					}
				}
				tmp[i] &= ~(1<<pos);
				tmp[i+1] |= (1<<pos);

				if(visited.find(tmp) == visited.end()){
					visited[tmp] = cost + 1;
					que.push(P(cost+1,tmp));
				}
			}
		}
	}
	return -1;
}

int main(){

	int n,m;
	while(~scanf("%d %d",&n,&m)){
		if(n==m && m==0) break;
		vector<int> sets(3);
		map<vector<int>,int> visited;
		for(int i=0;i<3;i++){
			int amount;
			scanf("%d",&amount);
			for(int j=0;j<amount;j++){
				int size;
				scanf("%d",&size);
				sets[i] |= (1<<(size-1)); 
			}
		}

		printf("%d\n",bfs(m,sets,visited));
	}
}

Compiler output:
a.cc: In function 'int bfs(int, std::vector<int>&, std::map<std::vector<int>, int>&)':
a.cc:33:21: error: declaration of 'std::vector<int> sets' shadows a parameter
   33 |         vector<int> sets;
      |                     ^~~~
a.cc:27:28: note: 'std::vector<int>& sets' previously declared here
   27 | int bfs(int m,vector<int>& sets, map<vector<int>,int>& visited){
      |               ~~~~~~~~~~~~~^~~~
Language: C++

#include <iostream>
#include <math>
#define step(n) pow(3,x-n+1)/2
using namespace std;

int x,hanoi[16];


int move(int s,int d,int c){
	if(abs(s-d)==2) return move(s,1,c)+move(1,d,c);
	if(c==x) return abs(s-d);
	if(s==d) return move(hanoi[c+1], s, c+1);
	for(int i=c+1;i<=x;i++)if(hanoi[i]==s || hanoi[i]==d)return step(c) + move(hanoi[c+1], d, c+1);
	return 1 + move(hanoi[c+1], d, c+1);
}

int main(){
	int i,n,m,t,r1,r2;
	while(cin>>x>>n,n){
		for(i=0;i<3;i++)for(cin>>m;m--;hanoi[t]=i)cin>>t;
		r1=move(hanoi[1],0,1);
		r2=move(hanoi[1],2,1);
		if(n<r1&&n<r2) r1=-1;
		cout << min(r1,r2) << endl;
	}
}

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

#include <iostream>
#include <tuple>
#include <map>
#include <climit>
using namespace std;

const int NONE = INT_MAX;
typedef tuple<int, int, int> Tuple;
map<Tuple, int> S;
Tuple goal;
int n, m;

int get_last( int m ) {
    for ( int i = n - 1; i >= 0; -- i ) {
        if ( ( m & ( 1 << i ) ) == ( 1 << i ) ) return 1 << i;
    }
    return 0;
}

int remove_last( int m ) {
    for ( int i = n - 1; i >= 0; -- i ) {
        if ( ( m & ( 1 << i ) ) == ( 1 << i ) ) return m ^ ( 1 << i );
    }
    return m;
}

int solve( int A, int B, int C, int turns ) {
    Tuple tuple = make_tuple( A, B, C );
    if ( S.count( tuple ) > 0 && turns >= S[tuple] ) return -1;
    S[tuple] = turns;
    if ( turns > m ) return -1;
    if ( tuple == goal ) return turns;
    if ( A != 0 ) {
        int u = get_last(A);
        int v = get_last(B);
        if ( u > v ) {
            int ret = solve( remove_last( A ), B | u, C, turns + 1 );
            if ( ret != NONE ) return ret;
        }
    }
    if ( B != 0 ) {
        int u = get_last(B);
        int v = get_last(A);
        if ( u > v ) {
            int ret = solve( A | u, remove_last(B), C, turns + 1 );
            if ( ret != NONE ) return ret;
        }
    }
    if ( B != 0 ) {
        int u = get_last(B);
        int v = get_last(C);
        if ( u > v ) {
            int ret = solve( A, remove_last(B), C | u, turns + 1 );
            if ( ret != NONE ) return ret;
        }
    }
    if ( C != 0 ) {
        int u = get_last(C);
        int v = get_last(B);
        if ( u > v ) {
            int ret = solve( A, B | u, remove_last(C), turns + 1 );
            if ( ret != NONE ) return ret;
        }
    }
    return -1;
}

int main() {
    while ( cin >> n >> m ) {
        if ( n == 0 && m == 0 ) break;
        S.clear();
        int T[3] = { 0, 0, 0 };
        for ( int i = 0; i < 3; ++ i ) {
            int k;
            cin >> k;
            for ( int j = 0; j < k; ++ j ) {
                int t;
                cin >> t;
                t--;
                T[i] |= 1 << t;
            }
        }
        goal = make_tuple( T[0], T[1], T[2] );
        int ret1 = solve( (1<<n)-1, 0, 0, 0 );
        int ret2 = solve( 0, 0, (1<<n)-1, 0 );
        int res = min( ret1, ret2 );
        if ( res == NONE ) res = -1;
    }
    return 0;
}

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

#include <iostream>
#include <math.h>
#define S(n) (int)(pow(3,x-(n)+1)/2)
using namespace std;

int main(){
	int h[17],a[17],c[17],x,i,n,m;
	while(cin>>x>>n,n){
		for(i=0;i<3;i++)for(cin>>m;m--;h[t]=i)cin>>t;
		a[x]=h[x];c[x]=2-h[x];
		for(i=x;i>1;i--){
			if(h[i-1]==0){
				a[i-1]=a[i];
				c[i-1]=c[i]+2+4*S(i);
			}else if(h[i-1]==1){
				a[i-1]=c[i]+1+2*S(i);
				c[i-1]=a[i]+1+2*S(i);
			}else{
				a[i-1]=a[i]+2+4*S(i);
				c[i-1]=c[i];
			}
		}
		t=min(a[1],c[1]);
		cout<<t>n?-1:t<<endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:50: error: 't' was not declared in this scope
    9 |                 for(i=0;i<3;i++)for(cin>>m;m--;h[t]=i)cin>>t;
      |                                                  ^
a.cc:23:17: error: 't' was not declared in this scope
   23 |                 t=min(a[1],c[1]);
      |                 ^
Language: C++

#include<cstdio>
#include<iostream>
#include <stack>
using namespace std;



void main()
{
	stack<int>a,b,c;
	while(1)
	{
		
		int count=0,n,m,check;
		scanf("%d %d",&n,&m);

		if(n==0 && m==0)
		{
			puts("-1");
			break;
		}
	
		int A,B,C,
			kari;
		
		/*エラー対策*/
		a.push(0);
		b.push(0);
		c.push(0);

		scanf("%d",&A);
		for(int i=0;i<A;i++){
			scanf("%d",&kari);
			a.push(kari);
		}

		scanf("%d",&B);
		for(int i=0;i<B;i++){
			scanf("%d",&kari);
			b.push(kari);
		}
	
		scanf("%d",&C);
		for(int i=0;i<C;i++){
			scanf("%d",&kari);
			c.push(kari);
		}
		
		while(1)
		{
			if(b.top()==0 && c.top()==0)
				break;
			if(a.top()<b.top() && a.top()<c.top()){
				kari=b.top();
				a.push(kari);
				b.pop();
				count++;
				continue;
			}
			if(b.top()<c.top() ){
				kari=c.top();
				b.push(kari);
				c.pop();
				count++;
				continue;
			}
			if(b.top()<a.top()){
				kari=a.top();
				b.push(kari);
				a.pop();
				count++;
				continue;
			}
			if(c.top()<b.top() && a.top()!=b.top()-1){
				kari=b.top();
				c.push(kari);
				b.pop();
				count++;
				continue;
		}
			else{
				kari=b.top();
				a.push(kari);
				b.pop();
				count++;
				continue;
			}
		}
		if(count<m || count==m) printf("\n%d\n",count);
		else printf("\n%d\n",-1);
	}
}

Compiler output:
a.cc:8:1: error: '::main' must return 'int'
    8 | void main()
      | ^~~~
Language: C++

c[];main(n,m,i,j,k,f){for(f="%d\n";scanf("%d%d",&n,&m)*n;printf(f,j>m?i:j)){for(i=3;i--;)for(scanf(f,&j);j--;c[n-k]=i)scanf(f,&k);for(i=n;i--;k+=c[i])j-=pow(3,i)*abs(k*2%4-c[i]);j=fmin(~j,pow(3,n)+j);}}

Compiler output:
a.cc:1:1: error: 'c' does not name a type
    1 | c[];main(n,m,i,j,k,f){for(f="%d\n";scanf("%d%d",&n,&m)*n;printf(f,j>m?i:j)){for(i=3;i--;)for(scanf(f,&j);j--;c[n-k]=i)scanf(f,&k);for(i=n;i--;k+=c[i])j-=pow(3,i)*abs(k*2%4-c[i]);j=fmin(~j,pow(3,n)+j);}}
      | ^
a.cc:1:9: error: expected constructor, destructor, or type conversion before '(' token
    1 | c[];main(n,m,i,j,k,f){for(f="%d\n";scanf("%d%d",&n,&m)*n;printf(f,j>m?i:j)){for(i=3;i--;)for(scanf(f,&j);j--;c[n-k]=i)scanf(f,&k);for(i=n;i--;k+=c[i])j-=pow(3,i)*abs(k*2%4-c[i]);j=fmin(~j,pow(3,n)+j);}}
      |         ^
Language: C++

#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <vector>
#include <cmath>
using namespace std;

const int MAXN = 17;
const int SSIZE = 15000000;
const int INF = INT_MAX;

const int W = 3;
int N, M;

int three[MAXN];
bool vis[SSIZE];

void init() {
  three[0] = 1;
  for(int i = 1; i < MAXN; ++i) three[i] = three[i-1] * 3;
}

int get3(int s, int i) {
  return s/three[i]%3;
}

int getTop(int s, int pos) {
  int maxi = -1;
  for(int i = 0; i < N; ++i) {
    if(s % W == pos) maxi = i;
    s /= W;
  }
  return maxi;
}

int move(int s, int from, int to) {
  int a = getTop(s, from);
  int b = getTop(s, to);
  if(a == -1) return INF;
  if(a < b) return INF;
  s -= three[a] * from;
  s += three[a] * to;
  return s;
}

void show(int s) {
  for(int i = 0; i < N; ++i) {
    cout << s%3;
    s /= 3;
  }
  cout << endl;
}

int bfs(int s) {
  queue<pair<int, int> > que;
  fill(vis, vis+SSIZE, false);
  que.push(make_pair(s,0));
  vis[s] = true;

  int goal1, goal2;
  goal1 = goal2 = 0;
  for(int i = 0; i < N; ++i) goal2 += three[i]*2;
  if(s == goal1 || s == goal2) {
    return 0;
  }

  while(!que.empty()) {
    s = que.front().first;
    int cost = que.front().second;
    que.pop();
    if(cost == M) continue;
    for(int i = 0; i < W; ++i) {
      for(int j = 0; j < W; ++j) {
	if(abs(i-j) != 1) continue;
	int ns = move(s, i, j);
	if(ns == INF) continue;
	if(vis[ns]) continue;
	if(ns == goal1 || ns == goal2) {
	  return cost+1;
	}
	vis[ns] = true;
	que.push(make_pair(ns, cost+1));
      }
    }
  }
  return INF;
}

int main() {
  init();
  while(cin >> N >> M && (N|M)) {
    int sum = 0;
    for(int i = 0; i < W; ++i) {
      int k;
      cin >> k;
      while(k--) {
	int a;
	cin >> a;
	--a;
	sum += three[a] * i;
      }
    }
    int ans = bfs(sum);
    if(ans <= M) {
      cout << ans << endl;
    } else {
      cout << -1 << endl;
    }
  }
  return 0;
}

Compiler output:
a.cc:11:17: error: 'INT_MAX' was not declared in this scope
   11 | const int INF = INT_MAX;
      |                 ^~~~~~~
a.cc:7:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    6 | #include <cmath>
  +++ |+#include <climits>
    7 | using namespace std;