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

#include <iostream>
#include <sstream>
#include <algorithm>
#include <set>
#include <map>

using namespace std;

#define foreach(i,c) for(__typeof__((c).begin()) i=(c).begin();i!=(c).end();++i)

int main()
{
	for(int n;cin>>n,n;){
		cin.ignore();
		vector<string> words;
		while(n--){
			string line; getline(cin,line);
			istringstream iss(line);
			for(string w;iss>>w;)
				words.push_back(w);
		}
		char c; cin>>c;
		
		map<string,int> m;
		for(int i=0;i<words.size();i++)
			m[words[i]]++;
		
		set<pair<int,string> > s;
		foreach(i,m)
			if(i->first[0]==c)
				s.insert(make_pair(-i->second,i->first));
		
		if(s.empty())
			cout<<"NA"<<endl;
		else{
			int cnt=0;
			foreach(i,s){
				cout<<(i==s.begin()?"":" ")<<i->second;
				if(++cnt==5)
					break;
			}
			cout<<endl;
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:17: error: 'vector' was not declared in this scope
   15 |                 vector<string> words;
      |                 ^~~~~~
a.cc:6:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    5 | #include <map>
  +++ |+#include <vector>
    6 | 
a.cc:15:30: error: expected primary-expression before '>' token
   15 |                 vector<string> words;
      |                              ^
a.cc:15:32: error: 'words' was not declared in this scope
   15 |                 vector<string> words;
      |                                ^~~~~
Language: C++

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

pair<string, int> str[30];
vector<pair<string, int>> v;
int maxarray;

void f(string in)//入力関数
{
	for(int i=0;i<20;++i)
	{
		if(str[i].first == in)
		{
			++str[i].second;
			return;
		}
		if(str[i].first.empty())
		{
			str[i].first = in;
			str[i].second = 1;
			maxarray = i;
			return;
		}
	}
}

void insert(int index)
{
	if(v.empty())
	{
		v.push_back(str[index]);
		return;
	}
	for(int i=0;i<v.size();++i)
	{
		if(v[i].second < str[index].second)
		{
			v.insert(v.begin()+i,str[index]);
			return;
		}
	}
	v.push_back(str[index]);
}

int main(void)
{
	string input;
	string in;
	char k;
	int n;
	while(cin >> n , n)
	{
		v.clear();
		for(int i=0;i<20;++i)
		{
			str[i].first = "";
			str[i].second = 0;
		}
		getline(cin,input);
		for(int num=0;num<n;++num)
		{
			getline(cin,input);
			string::size_type index=0;
			string::size_type nextindex = input.find(" ");//次のスペースの場所
			while(1)
			{
				f(input.substr(index,nextindex-index));
				index = nextindex+1;
				nextindex = input.find(" " ,nextindex+1);
				if(nextindex == string::npos)
				{
					f(input.substr(index));
					break;
				}
			}
		}
		sort(str,str+maxarray+1);
		cin >> k;//頭文字の入力
		bool flag = false;
		for(int i=0;i<=maxarray;++i)
		{
			if(str[i].first.at(0) == k)
			{
				insert(i);
			}
		}
		if(v.empty())
			cout << "NA" << endl;
		for(int i=0;i<5 && i<v.size();++i)
		{
			if(i==4 || i==v.size()-1)
			{
				cout << v[i].first << endl;
				break;
			}
			cout << v[i].first << ' ';
		}
	}
	return 0;
}

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

#include<map>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdio>
using namespace std;
bool pr(const pair<string,int>& p,const pair<string,int>& q){
	if(false){
	}else if(p.second>q.second){
		return true;
	}else if(p.second<q.second){
		return false;
	}else{
		return p.first<q.first;
	}
}
int main(){
	int i,j,k;
	int n;
	while(scanf("%d\n",&n),n){
		map<string,int> a[26];
		for(i=0;i<n;++i){
			char s[1026];
			fgets(s,1025,stdin);
			s[strlen(s)-1]='\0';
			for(j=0;s[j];j=k){
				for(;s[j]&&s[j]==' ';++j);
				for(k=j+1;s[k]&&s[k]!=' ';++k);
				if(k-j>0){
					char t[21];
					strncpy(t,s+j,k-j);
					t[k-j]='\0';
					++a[t[0]-'a'][t];
				}
			}
		}
		char c;
		scanf("%c",&c);
		vector<pair<string,int> > b;
		map<string,int>::iterator it;
		for(it=a[c-'a'].begin();it!=a[c-'a'].end();++it)
			b.push_back(*it);
		sort(b.begin(),b.end(),pr);
		if(b.size()){
			for(i=0;i<min(5,(int)b.size())-1;++i)
				printf("%s ",b[i].first.c_str());
			printf("%s\n",b[i].first.c_str());
		}else{
			puts("NA");
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:27: error: 'strlen' was not declared in this scope
   25 |                         s[strlen(s)-1]='\0';
      |                           ^~~~~~
a.cc:6:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    5 | #include<cstdio>
  +++ |+#include <cstring>
    6 | using namespace std;
a.cc:31:41: error: 'strncpy' was not declared in this scope
   31 |                                         strncpy(t,s+j,k-j);
      |                                         ^~~~~~~
a.cc:31:41: note: 'strncpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
Language: C++

#include<string>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

using namespace std;

int main()
{
	for(;;){
		int n;
		
		
		vector<string> str;
		char c_string[1000];
		vector<string> find_moji;
		string temp;
		int sub_begin;
		int cont;
		char moji;
		bool cont_flg = false;
		int map_cont = 0;
		
		
		cin >> n;
		
		if(n == 0){
			break;
		}
		
		set<string> find_moji2;
		
		
		for(int i = 0; i < n; i++){
			gets(c_string);
			str.push_back(c_string);
		}
		
		
		cin >> moji;
		
		
		//先頭で始まる文字まで飛ばして、find_mojiに突っ込む
		for(int i = 0; i < n; i++){
			temp = str[i];
			
			for(int j = 0; j < temp.size(); j++){
				if(temp[j] == moji && (j == 0 || temp[j-1] == ' ')){
					sub_begin = j;
					cont_flg = true;
					cont = 0;
					//スペースまでカウント開始
				}
				if((temp[j] == ' '|| j == temp.size()-1) && cont_flg == true){
					cont_flg = false;
					
					string ss = temp.substr(sub_begin, cont+1);
					if(ss[ss.size()-1] == ' '){
						ss = temp.substr(sub_begin, cont);
					}
					
					find_moji.push_back(ss);
					
					
					find_moji2.insert(ss);
					map_cont++;
				}
				if(cont_flg == true){
					cont++;
				}
				
			}
		}
		
		/*
		sort(find_moji.begin(), find_moji.end());
		for(int i = 0; i < find_moji.size(); i++){
			cout << find_moji2[i] << endl;
			if(i > 3){
				break;
			}
		}
		*/
		
		bool come = false;
		int cont2 = 0;
		
		set<string>::iterator _ite = find_moji2.begin();
		while(_ite != find_moji2.end()){
			cout << *_ite << endl;
			_ite++;
			come = true;
			cont2++;
			if(cont2 == 5){
				break;
			}
		}
		
		if(come == false){
			cout << "NA" << endl;
		}
	}
		
}
	

Compiler output:
a.cc: In function 'int main()':
a.cc:37:25: error: 'gets' was not declared in this scope; did you mean 'getw'?
   37 |                         gets(c_string);
      |                         ^~~~
      |                         getw
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <deque>
using namespace std;
int main(void)
{
	int n,k;
	char c;
	string str,s;
	map<string,int> words;
	map<string,int>::iterator it;
	deque< pair<string,int> > choice;
	while(1){
		cin >> n;
		cin.ignore();
		if(n==0) break;
		for(int i=0;i<n;i++){
			getline(cin,str);
			str+=' ';
			while(!str.empty()){
				for(k=0;str[k]!=' '&&str[k]!='\0';k++);
				s=str.substr(0,k);
				str=str.substr(k+1);
				words[s]++;
			}
		}
		cin >> c;
		for(it=words.begin();it!=words.end();++it){
			if((*it).first[0]==c) choice.push_back(pair<string,int>((*it).first,(*it).second));
		}
		if(choice.empty()) cout << "NA";
		else{
			sort(choice.begin(),choice.end());
			for(int i=0;i<5&&i<choice.size();i++) cout << choice[i].first << " ";
		}
		cout << endl;
		words.clear();
		choice.clear();
	}
	return 0;
}

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

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

int main(){
    int n;
    while(cin >> n, n){
        cin.ignore();
        map<string, int> dic;
        for(int i=0; i < n; i++){
            string s;
            getline(cin, s);
            s += " ";
            while(s.size() != 0){
                string word = s.substr(0, s.find_first_of(" "));
                s = s.substr(s.find_first_of(" ")+1);
                dic[word]++;
            }
        }
        string initial;
        cin >> initial;

        bool isFirst = true;
        map<string, int>::iterator it = dic.begin();
        int count = 0;
        while(it != dic.end() && count < 5){
            if((*it).first.substr(0 ,1) == initial){
                if(isFirst){cout << (*it).first; isFirst = false;}
                else cout << " " << (*it).first;
                count++;
            }
            it++;
        }
        if(count == 0) cout << "NA" << endl;
        else cout << endl;

        dic.clear();
    

Compiler output:
a.cc: In function 'int main()':
a.cc:37:21: error: expected '}' at end of input
   37 |         dic.clear();
      |                     ^
a.cc:7:23: note: to match this '{'
    7 |     while(cin >> n, n){
      |                       ^
a.cc:37:21: error: expected '}' at end of input
   37 |         dic.clear();
      |                     ^
a.cc:5:11: note: to match this '{'
    5 | int main(){
      |           ^
Language: Java


import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	int w, h;
	int min;
//	char[][] p;
	
	void run() {
			Scanner sc = new Scanner(System.in);
		for(;;) {
			w = sc.nextInt();
			h = sc.nextInt();
			if( (w|h) == 0 ) break;
			
			p = new char[h+2][w+2];
			for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) {
				String str = sc.next();
//				p[i][j] = str.charAt(0);
			}
			min = 10 * 10;
//			dfs(p, 0, p[1][1]);
			
			System.out.println(min);
		}
	}
	
	int dx[] = {-1,0,1,0};
	int dy[] = {0,-1,0,1};
	char clrs[] = {'R', 'G', 'B'};
	boolean[][] used;
	LinkedList<Character> list;
	
	void dfs(char[][] p, int d, char c) {
		used = new boolean[h+2][w+2];
		list = new LinkedList<Character>();
		dfs(p, 1, 1, p[1][1], c);
		list.clear();
		used = new boolean[h+2][w+2];
		int cnt = dfs(p, 1, 1, p[1][1], p[1][1]);
		debug(c, cnt);
		if( cnt == w*h ) {
			min = min(min, d);
			return;
		}
		HashSet<Character> clrs = new HashSet<Character>(list);
		debug(clrs);
		for(char clr: clrs) {

			char[][] tmp = new char[h+2][w+2];
			for(int k=0;k<h+2;k++) for(int j=0;j<w+2;j++) tmp[k][j] = p[k][j];
			dfs(tmp, d+1, clr);
		}
		
	}
	
	int dfs(char[][] p, int x, int y, char c, char to) {
		if(p[y][x] != c) {
			if(p[y][x] != 0) list.add(p[y][x]);
			return 0;
		}
		used[y][x] = true;
		p[y][x] = to;
		int cnt = 1;
		for(int i=0;i<4;i++) if(!used[y+dy[i]][x+dx[i]]) cnt += dfs(p, x+dx[i], y+dy[i], c, to);
		return cnt;
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
//		System.err.println(Arrays.deepToString(os));
	}
}

Compiler output:
Main.java:20: error: cannot find symbol
			p = new char[h+2][w+2];
			^
  symbol:   variable p
  location: class Main
1 error
Language: C

#include <stdio.h>
#include <time.h>

char s[100];

int main(void){
	int x, y;
	char c;
	for(; scanf("%d%d%c", &x, &y, &c);,y){
		if( c != '\n' ){
			clock_t c1 = clock() + CLOCKS_PER_SEC * 0.02 * c;
			while( clock() < c1 );
			return 0;
		}
		for( int i = 0; i < y; ++i ){
			fgets( s, 50, stdin);
		}
	}
	
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:9:43: error: expected expression before ',' token
    9 |         for(; scanf("%d%d%c", &x, &y, &c);,y){
      |                                           ^
Language: C++

#include<cstdio>
#include<algorithm>
#include<string>
#include<queue>
#define rep(i,a) for( int i = 0; i != (a); ++i )

const std::string RGB = "RGB";

int x, y;
short fld[10][10];

struct State
{
	short st[10][10];
	int cnt;

	State( short fld[10][10], int cnt )
	:	cnt( cnt )
	{
		rep( i, y )
			rep( j, x )
				st[i][j] = fld[i][j];
	}
};

void paint( int px, int py, int prvc, int c )
{
	static const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { -1, 0, 1, 0 };

	if( fld[py][px] != prvc )
		return;

	fld[py][px] = c;

	rep( i, 4 )
	{
		int nx = px+dx[i], ny = py+dy[i];

		if( nx >= 0 && nx < x && ny >= 0 && ny < y && fld[ny][nx] == prvc )
			paint( nx, ny, prvc, c );
	}

	return;
}

int main()
{
	while( scanf( "%d%d", &x, &y ), x|y )
	{
		rep( i, y )
		{
			rep( j, x )
			{
				char ch[2];
				scanf( "%s", ch );
				fld[i][j] = RGB.find( ch );
			}
		}

		std::queue<State> que;
		for( que.push( State( fld, 0 ) ); !que.empty(); que.pop() )
		{
			State s = que.front();

			bool fl = true;
			rep( i, y )
			{	
				rep( j, x )
				{	
					fl &= s.st[i][j] == s.st[0][0];
					fld[i][j] = s.st[i][j];
				}
			}

			if( fl )
			{
				printf( "%d\n", s.cnt );

				break;
			}

			rep( c, 3 )
			{
				if( c == **s.st )
					continue;

				if( c )
					memcpy( fld, s.st, sizeof( fld ) );
				paint( 0, 0, **fld, c );
				que.push( State( fld, s.cnt+1 ) );
			}
		}
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:88:41: error: 'memcpy' was not declared in this scope
   88 |                                         memcpy( fld, s.st, sizeof( fld ) );
      |                                         ^~~~~~
a.cc:5:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include<queue>
  +++ |+#include <cstring>
    5 | #define rep(i,a) for( int i = 0; i != (a); ++i )
Language: C++

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

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

int H,W;
int fld[10][10];
int lim;
bool change(int y,int x,int c,int f){
    fld[y][x]=c;
    for(int d=0;d<4;d++){
        int ny=y+dy[d],nx=x+dx[d];
        if(ny<0||ny>=H||nx<0||nx>=W||fld[ny][nx]!=f)continue;
        change(ny,nx,c,f);
    }

}

bool dfs(int t=0){
    bool ok=true;
    for(int i=0;i<H;i++)for(int j=0;j<W;j++){
        if(fld[0][0]!=fld[i][j])ok=false;
    }
    if(ok)return true;
    if(t==lim)return false;

    int _fld[10][10];
    for(int i=0;i<H;i++)for(int j=0;j<W;j++){
        _fld[i][j]=fld[i][j];
    }

    bool ret=false;
    for(int k=0;k<3;k++)if(k!=fld[0][0]){
        change(0,0,k,fld[0][0])
        ret|=dfs(t+1);
        for(int i=0;i<H;i++)for(int j=0;j<W;j++){
            fld[i][j]=_fld[i][j];
        }
    }

    return ret;
}
int main(){
    while(cin>>W>>H,W||H){
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                char c;
                cin>>c;
                switch(c){
                case 'R':fld[i][j]=0;break;
                case 'G':fld[i][j]=1;break;
                case 'B':fld[i][j]=2;break;
                }
            }
        }

        for(lim=0;;lim++)if(dfs())break;
        cout<<lim<<endl;
    }

    return 0;
}

Compiler output:
a.cc: In function 'bool change(int, int, int, int)':
a.cc:18:1: warning: no return statement in function returning non-void [-Wreturn-type]
   18 | }
      | ^
a.cc: In function 'bool dfs(int)':
a.cc:35:32: error: expected ';' before 'ret'
   35 |         change(0,0,k,fld[0][0])
      |                                ^
      |                                ;
   36 |         ret|=dfs(t+1);
      |         ~~~
Language: C++

# define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <set>
# include <map>
# include <stack>
using namespace std;
# define M_PI 3.141592
# define FOR(i,n) for(int i=0;i<(int)n;i++)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define toRad 2.0*M_PI/360.0
# define inin(x) int x;cin>>x;
# define all(x) x.begin(),x.end()
# define debug(x) cout<<#x<<" :"<<x<<endl;
# define rep(i,n) for(int i=0;i<(int)n;i++)
# define EPS 1e-12
# define pri_max 60000
# define CHECK(i,a) FOR(i,a.size())cout<<#a<<"["<<i<<"] : "<<a[i]<<endl; 


typedef pair<int, int> pii;
int x, y;
char a[20][20];
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,-1,0,1 };
map<string, int> m;

int dfs(int z)
{
	bool ok = true;
	string tmp;
	char b[20][20];

	for (int i = 1; i <= y; i++)
	{
		for (int j = 1; j <= x; j++)
		{
			if (a[1][1] != a[i][j])ok = false;
			tmp += a[i][j];
			b[i][j] = a[i][j];
		}
	}
	if (ok)return z;
	if (!m.count(tmp))m[tmp] = z;
	else if (m[tmp] <= z)return INT_MAX;

	char ord[4] = "RGB";
	int ans = INT_MAX;
	for (int i = 0; i < 3; i++)
	{
		char o, t;
		o = a[1][1]; t = ord[i];
		if (o == t)continue;
		a[1][1] = t;
		queue<pii> que;
		que.push(pii(1, 1));
		while (!que.empty())
		{
			pii now = que.front(); que.pop();

			for (int l = 0; l < 4; l++)
			{
				pii next;
				next.first = now.first + dx[l];
				next.second = now.second + dy[l];

				if (a[next.first][next.second] == o)
				{
					a[next.first][next.second] = t;
					que.push(next);
				}
			}
		}
		
		ans = min(ans, dfs(z + 1));
		
		for (int l = 1; l <= y; l++)
		{
			for (int k = 1; k <= x; k++)
			{
				a[l][k] = b[l][k];
			}
		}
	}

	return ans;


}


int main()
{
	
	while (cin >> x >> y&&x&&y)
	{
		memset(a, 0, sizeof a);
		m.clear(); M.clear();
		for (int i = 1; i <= y; i++)
		{
			for (int j = 1; j <= x; j++)
			{
				cin >> a[i][j];
			}
		}
		cout << dfs(0) << endl;
	}
}

Compiler output:
a.cc:23:10: warning: "M_PI" redefined
   23 | # define M_PI 3.141592
      |          ^~~~
In file included from /usr/include/c++/14/cmath:47,
                 from a.cc:15:
/usr/include/math.h:1121:10: note: this is the location of the previous definition
 1121 | # define M_PI           3.14159265358979323846  /* pi */
      |          ^~~~
a.cc: In function 'int main()':
a.cc:112:28: error: 'M' was not declared in this scope
  112 |                 m.clear(); M.clear();
      |                            ^
Language: C++

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

using namespace std;

using Mat = vector<vector<char>>;

constexpr char col[] = {'R', 'G', 'B'};
constexpr int MAX = 10;

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

int W, H;
Mat M;

bool visited[MAX][MAX];

bool in_field(int x, int y)
{
    return (0 <= x && x < W && 0 <= y && y < H);
}

void paint(Mat& m, int x, int y, char nc, char c)
{
    if (visited[y][x]) return;
    visited[y][x] = 1;

    m[y][x] = nc;
    
    for (int i = 0; i < 4; i++) {
        int nx = x + dx[i], ny = y + dy[i];
        if (in_field(nx, ny) && m[ny][nx] == c) {
            paint(m, nx, ny, nc, c);
        }
    }
}

Mat get_next(const Mat& m, char c)
{
    Mat res = m;
    memset(visited, 0, sizeof(visited));
    paint(res, 0, 0, c, m[0][0]);
    return res;
}

bool reach(Mat& m)
{
    char c = m[0][0];
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (m[i][j] != c) {
                return 0;
            }
        }
    }
    return 1;
}

int bfs()
{
    queue<Mat> Q;
    Q.push(M);

    map<Mat, int> d;
    d[M] = 0;
    
    while (!Q.empty()) {
        Mat m = Q.front(); Q.pop();

        if (reach(m)) return d[m];
        
        for (int i = 0; i < 3; i++) {
            if (m[0][0] == col[i]) continue;
            Mat next = get_next(m, col[i]);
            if (d.count(next) == 0) {
                d[next] = d[m] + 1;
                Q.push(next);
            }
        }
    }
    return -1;
}

int main()
{
    while (cin >> W >> H, W > 0) {
        M.resize(H);
        for (int i = 0; i < H; i++) {
            M[i].resize(W);
            for (int j = 0; j < W; j++) {
                cin >> M[i][j];
            }
        }
        cout << bfs() << endl;
    }        
    return 0;
}

Compiler output:
a.cc: In function 'Mat get_next(const Mat&, char)':
a.cc:44:5: error: 'memset' was not declared in this scope
   44 |     memset(visited, 0, sizeof(visited));
      |     ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include <map>
  +++ |+#include <cstring>
    5 |
Language: C++

#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1 << 25;
int ans;
int b[10][10];
int W, H;

int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
bool in(int x, int y) {
	return  0 <= x && x < W && 0 <= y && y < H;
}

void copy_board(int dst[10][10], int src[10][10]) {
	for(int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++) {
			dst[i][j] = src[i][j];
		}
	}
}

typedef pair<int, int> P;

int vis[10][10];
void color(int b[10][10], int c) {
	memset(vis, 0, sizeof vis);
	int cc = b[0][0];
	queue<P> q;
	q.push({ 0, 0 });
	b[0][0] = c;
	while(q.size()) {
		int x = q.front().first, y = q.front().second;
		q.pop();
		for(int k = 0; k < 4; k++) {
			int nx = x + dx[k], ny = y + dy[k];
			if(in(nx, ny) && b[ny][nx] == cc && !vis[ny][nx]) {
				vis[ny][nx] = 1;
				b[ny][nx] = c;
				q.push({ nx, ny });
			}
		}
	}
}

void dfs(int n) {
	if(n == 20) return;
	for(int c = 0; c < 3; c++) {
		int cnt = 0;
		for(int i = 0; i < H; i++) {
			cnt += count(b[i], b[i] + W, c);
		}
		if(cnt == H * W) {
			ans = min(ans, n);
			return;
		}
	}

	int tmp[10][10];
	copy_board(tmp, b);
	for(int i = 0; i < 3; i++) {
		copy_board(b, tmp);
		if(b[0][0] != i) {
			color(b, i);

			dfs(n + 1);
		}
	}
	copy_board(b, tmp);
}

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

	while(cin >> W >> H, W) {
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				char c;
				cin >> c;
				if(c == 'R') b[i][j] = 0;
				if(c == 'G') b[i][j] = 1;
				if(c == 'B') b[i][j] = 2;
			}
		}

		ans = INF;
		dfs(0);
		cout << ans << endl;
	}
}

Compiler output:
a.cc: In function 'void color(int (*)[10], int)':
a.cc:28:9: error: 'memset' was not declared in this scope
   28 |         memset(vis, 0, sizeof vis);
      |         ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <queue>
  +++ |+#include <cstring>
    4 | using namespace std;
Language: C++

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

char bt[10][10];
char ne[10][10];
bool dn[10][10];
int dx[] = {-1,0,1,0};
int dy[] = {0,1,0,-1};
int W,H;


void chg(int x,int y,char a,char b){
	if( x < 0 || x >= W || y < 0 || y >= H || bt[y][x] != b || dn[y][x]) return;
	dn[y][x] = true;
	ne[y][x] = a;
	for(int i = 0 ; i < 4 ; i++){
		chg(x+dx[i],y+dy[i],a,b);
	}
}

int ans = 0;
int dfs(int r){
	if( r >= ans ){
		//cout << r << endl;
		return 0;
	}
	int f = true;

	for(int i = 0 ; i < H ; i++){
		for(int j = 0 ; j < W ; j++){
			if(bt[i][j] != bt[0][0]){
				f = false;
				goto en;
			}
		}
	}
	en:;
	
	if( f ){
		ans = r;
		return 0;
	}
	char tmp[10][10];
	bool prev[10][10];
	memcpy(prev,dn,sizeof(dn));
	memcpy(tmp,bt,sizeof(tmp));
	for(int i = 0 ; i < 3 ; i++){
		memcpy(ne,bt,sizeof(ne));
		memset(dn,0,sizeof(dn));
		int f = false;
		if( "RGB"[i] != bt[0][0] ){
			chg(0,0,"RGB"[i],bt[0][0]);
			for(int i = 0 ; i < H ; i++){
				for(int j = 0 ; j < W ; j++)
				if(prev[i][j] != dn[i][j]) f = true;
			}
			memcpy(bt,ne,sizeof(ne));
			if(f)dfs(r+1);
			memcpy(bt,tmp,sizeof(tmp));	
		}
	}
}
int main(){
	int n;
	while(cin >> W >> H && W){	
		memset(dn,0,sizeof(dn));
		
		for(int i = 0 ; i < H ; i++)
			for(int j = 0 ; j < W ; j++)
				cin >> bt[i][j];
		ans = 1e7;
		dfs(0);
		cout << ans << endl;
	}
	
}

Compiler output:
a.cc: In function 'int dfs(int)':
a.cc:52:9: error: 'memcpy' was not declared in this scope
   52 |         memcpy(prev,dn,sizeof(dn));
      |         ^~~~~~
a.cc:8:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    7 | #include <sstream>
  +++ |+#include <cstring>
    8 | #include <algorithm>
a.cc:56:17: error: 'memset' was not declared in this scope
   56 |                 memset(dn,0,sizeof(dn));
      |                 ^~~~~~
a.cc:56:17: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
a.cc: In function 'int main()':
a.cc:73:17: error: 'memset' was not declared in this scope
   73 |                 memset(dn,0,sizeof(dn));
      |                 ^~~~~~
a.cc:73:17: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
a.cc: In function 'int dfs(int)':
a.cc:69:1: warning: control reaches end of non-void function [-Wreturn-type]
   69 | }
      | ^
Language: C++

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <cstdlib>
#include <sstream>
#include <cstring>
#include <algorithm>
using namespace std;
 
char bt[10][10];
char ne[10][10];
bool dn[10][10];
int dx[] = {-1,0,1,0};
int dy[] = {0,1,0,-1};
int W,H;

int main(){
    int n;
    while(cin >> W >> H && W){ 
        memset(dn,0,sizeof(dn));
         
        for(int i = 0 ; i < H ; i++)
            for(int j = 0 ; j < W ; j++)
                cin >> bt[i][j];
        ans = 1e7;
//        dfs(0);
        cout << ans << endl;
    }
     
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   28 |         ans = 1e7;
      |         ^~~
      |         abs
Language: C++

#include<algorithm>
#include<functional>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

typedef unsigned long long UInt64;
typedef long long Int64;

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

using namespace std;

typedef pair<int ,int > P;

int ans=INF;
int x,y;

inline int change(string ss)
{
	if(ss=="R") return 0;
	if(ss=="G") return 1;
	if(ss=="B") return 2;
}

inline bool check(vector<vector<int> > tile)
{
	rep(i,tile.size())
	{
		rep(j,tile[i].size())
		{
			if(tile[0][0]!=tile[i][j])
				return false;
		}
	}

	return true;

}

void f(vector<vector<int> > &tile,int color)
{
	//x,y
	queue<P> que;
	int oldcolor=tile[0][0];
	tile[0][0]=color;

	que.push(P(0,0));

	while(que.size())
	{
		P p = que.front(); que.pop();

		rep(i,4)
		{
			int nx=p.fr+dx[i];
			int ny=p.sc+dy[i];

			if(0<=nx&&nx<x&&0<=ny&&ny<y&&tile[nx][ny]==oldcolor)
			{
				tile[nx][ny]=color;	
				que.push(P(nx,ny));
			}
		}
	}
}	

void dfs(vector<vector<int> > tile,int depth)
{
	if(check(tile))
	{
		ans=min(ans,depth);
		return;
	}
	//最大でも18手を越えないらしい
	if(depth==18) return;

	vector<vector<int> > tile1=tile;
	vector<vector<int> > tile2=tile;

	if(tile[0][0]==0)
	{
		f(tile1,1);
		f(tile2,2);
	}
	if(tile[0][0]==1)
	{
		f(tile1,0);
		f(tile2,2);
	}
	if(tile[0][0]==2)
	{
		f(tile1,1);
		f(tile2,0);
	}

	dfs(tile1,depth+1);
	dfs(tile2,depth+1);

}

void solve()
{
	vector<vector<int> > tile;

	tile.reserve(10);

	rep(i,x)
	{
		vector<int> vec.reserve(10);
		rep(j,y)
		{
			string c;
			cin>>c;
			vec.pb(change(c));
		}
		tile.pb(vec);
	}

	dfs(tile,0);

}

int main()
{
	while(cin>>x>>y)
	{
		swap(x,y);
		if(x==0&&y==0)
			return 0;

		solve();
		cout<<ans<<endl;
		ans=INF;

	}
	return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:132:32: error: expected initializer before '.' token
  132 |                 vector<int> vec.reserve(10);
      |                                ^
a.cc:137:25: error: 'vec' was not declared in this scope
  137 |                         vec.pb(change(c));
      |                         ^~~
a.cc:139:25: error: 'vec' was not declared in this scope
  139 |                 tile.pb(vec);
      |                         ^~~
a.cc:22:25: note: in definition of macro 'pb'
   22 | #define pb(e) push_back(e)
      |                         ^
Language: C++

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

typedef pair<int, int> P;

struct State {
  int turn;
  char board[10][10];
};

int main() {
  while(true) {
    int X, Y;
    cin >> X >> Y;
    if(X == 0 && Y == 0) break;
    char board[10][10];
    for(int i = 0; i < Y; i++) {
      for(int j = 0; j < X; j++) {
        char c; cin >> c;
        if(c == 'R') board[i][j] = 0;
        if(c == 'G') board[i][j] = 1;
        if(c == 'B') board[i][j] = 2;
      }
    }
    State S;
    S.turn = 0;
    memcpy(S.board, board, sizeof(board));
    queue<State> Q;
    Q.push(S);
    int res;
    while(!Q.empty()) {
      State s = Q.front(); Q.pop();
      bool ok = true;
      for(int i = 0; i < Y; i++) {
        for(int j = 0; j < X; j++) {
          if(s.board[i][j] != s.board[0][0]) {
            ok = false;
            break;
          }
        }
      }
      if(ok) {
        res = s.turn;
        break;
      }
      for(char c = 0; c < 3; c++) {
        if(s.board[0][0] == c) continue;
        memcpy(S.board, s.board, sizeof(s.board));
        queue<P> Q2;
        Q2.emplace(0, 0);
        char prev = S.board[0][0];
        S.board[0][0] = c;
        while(!Q2.empty()) {
          P p = Q2.front(); Q2.pop();
          for(int i = 0; i < 4; i++) {
            const int dy[4] = { 0, -1, 0, 1 };
            const int dx[4] = { 1, 0, -1, 0 };
            int ny = p.first + dy[i];
            int nx = p.second + dx[i];
            if(0 <= ny && ny < Y && 0 <= nx && nx < X && S.board[ny][nx] == prev) {
              S.board[ny][nx] = c;
              Q2.emplace(ny, nx);
            }
          }
        }
        S.turn = s.turn + 1;
        Q.push(S);
      }
    }
    cout << res << endl;
  }
}

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

#include<iostream>
#include<memory>

int field_x, field_y;
int start;
int color;
int res = 10;

bool check(int field[10][10]){

	int r = 0, g = 0, b = 0;

	for (int i = 0; i < field_y; i++){
		for (int j = 0; j < field_x; j++){
			field[i][j] == 0 ? r++ : field[i][j] == 1 ? g++ : b++;
		}
	}

	int a = field_x*field_y;
	if (r == a || g == a || b == a)return true;
	return false;
}

void bfs(int(&field)[10][10], int x, int y){

	field[y][x] = color;

	if (x + 1 < field_x && field[y][x + 1] == start)bfs(field, x + 1, y);
	if (x - 1 > 0 && field[y][x - 1] == start)bfs(field, x - 1, y);
	if (y + 1 < field_y && field[y + 1][x] == start)bfs(field, x, y + 1);
	if (y - 1 > 0 && field[y - 1][x] == start)bfs(field, x, y - 1);

}

void calc(int field[10][10], int count){

	if (count > res)return;

	for (int i = 0; i < 3; i++){
		start = field[0][0];
		color = i;

		if (start == color)continue;

		int copy_field[10][10];
		std::memcpy(copy_field, field, sizeof(copy_field));

		bfs(copy_field, 0, 0);

		if (check(copy_field))res = count;

		else calc(copy_field, count + 1);

	}

}

int main(){

	while (std::cin >> field_x >> field_y, field_x || field_y){

		int field[10][10];

		for (int i = 0; i < field_y; i++){
			for (int j = 0; j < field_x; j++){
				char c;
				std::cin >> c;
				c == 'R' ? field[i][j] = 0 : c == 'G' ? field[i][j] = 1 : field[i][j] = 2;
			}
		}

		calc(field, 1);

		std::cout << res << std::endl;

		res = 10;
	}

	return 0;
}

Compiler output:
a.cc: In function 'void calc(int (*)[10], int)':
a.cc:46:22: error: 'memcpy' is not a member of 'std'; did you mean 'wmemcpy'?
   46 |                 std::memcpy(copy_field, field, sizeof(copy_field));
      |                      ^~~~~~
      |                      wmemcpy
Language: C++

#include<iostream>
#include<memory>

int field_x, field_y;
int start;
int color;
int res = 10;

bool check(int field[10][10]){

	int r = 0, g = 0, b = 0;

	for (int i = 0; i < field_y; i++){
		for (int j = 0; j < field_x; j++){
			field[i][j] == 0 ? r++ : field[i][j] == 1 ? g++ : b++;
		}
	}

	int a = field_x*field_y;
	if (r == a || g == a || b == a)return true;
	return false;
}

void bfs(int(&field)[10][10], int x, int y){

	field[y][x] = color;

	if (x + 1 < field_x && field[y][x + 1] == start)bfs(field, x + 1, y);
	if (x - 1 > 0 && field[y][x - 1] == start)bfs(field, x - 1, y);
	if (y + 1 < field_y && field[y + 1][x] == start)bfs(field, x, y + 1);
	if (y - 1 > 0 && field[y - 1][x] == start)bfs(field, x, y - 1);

}

void calc(int field[10][10], int count){

	if (count > res)return;

	for (int i = 0; i < 3; i++){
		start = field[0][0];
		color = i;

		if (start == color)continue;

		int copy_field[10][10];
		memcpy(copy_field, field, sizeof(copy_field));

		bfs(copy_field, 0, 0);

		if (check(copy_field))res = count;

		else calc(copy_field, count + 1);

	}

}

int main(){

	while (std::cin >> field_x >> field_y, field_x || field_y){

		int field[10][10];

		for (int i = 0; i < field_y; i++){
			for (int j = 0; j < field_x; j++){
				char c;
				std::cin >> c;
				c == 'R' ? field[i][j] = 0 : c == 'G' ? field[i][j] = 1 : field[i][j] = 2;
			}
		}

		calc(field, 1);

		std::cout << res << std::endl;

		res = 10;
	}

	return 0;
}

Compiler output:
a.cc: In function 'void calc(int (*)[10], int)':
a.cc:46:17: error: 'memcpy' was not declared in this scope
   46 |                 memcpy(copy_field, field, sizeof(copy_field));
      |                 ^~~~~~
a.cc:3:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include<memory>
  +++ |+#include <cstring>
    3 |
Language: C

#include <cstdio>
#include <cstring>
#include <vector>

#define MAX_N (100)
#define INF (100000000)

using namespace std;

typedef struct {
	int to;
	int cost;
} Edge;

vector<Edge> G[MAX_N];
int W[MAX_N][MAX_N];

int ans;
int n, m;

void getMin(int V, int cost, int left, bool used[MAX_N])
{
	if (cost >= ans){
		return;
	}
	
	if (V == n - 1){
		if ((left == 2 || left == 0) && ans > cost){
			ans = cost;
		}
		return;
	}
	
	used[V] = true;
	
	if (left == 2){
		for (int i = 0; i < G[V].size(); i++){
			if (used[G[V][i].to] == false){
				getMin(G[V][i].to, cost + G[V][i].cost, left, used);
				getMin(G[V][i].to, cost, left - 1, used);
			}
		}
	}
	if (left == 1){
		for (int i = 0; i < G[V].size(); i++){
			if (used[G[V][i].to] == false){
				getMin(G[V][i].to, cost, left - 1, used);
			}
		}
	}
	if (left == 0){
		getMin(n - 1, cost + W[V][n - 1], 0, used);
	}
	
	used[V] = false;
	
	return;
}

int main()
{
	int a, b, c;
	Edge in;
	
	while (1){
		scanf("%d %d", &n, &m);
		
		if (n + m == 0){
			break;
		}
		
		for (int i = 0; i < n; i++){
			G[i].clear();
		}
		
		for (int i = 0; i < n; i++){
			fill(W[i], W[i] + n, INF);
			W[i][i] = 0;
		}
		
		for (int i = 0; i < m; i++){
			scanf("%d %d %d", &a, &b, &c);
			
			in.to = --a;
			in.cost = c;
			G[--b].push_back(in);
			in.to = b;
			G[a].push_back(in);
			
			W[a][b] = W[b][a] = c;
		}
		
		for (int k = 0; k < n; k++){
			for (int i = 0; i < n; i++){
				for (int j = 0; j < n; j++){
					W[i][j] = min(W[i][j], W[i][k] + W[k][j]);
				}
			}
		}
		
		bool used[MAX_N];
		
		fill(used, used + MAX_N, false);
		
		ans = INF;
		getMin(0, 0, 2, used);
		
		printf("%d\n", ans);
	}
	
	return (0);
}

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

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

typedef pair<int, int> P;
struct Edge
{
  int cost, to, f;
  Edge(int c, int t){cost = c, to = t}
};

int E, V, d[1000];
vector<Edge> edge[1000];

int main()
{
loop:
  for(int i = 0; i < 1000; i++)
    edge[i].clear();
  for(int i = 0; i < 100; i++)
    d[i] = 100000000;
  cin >> V >> E;
  if(!V)
    return 0;
  for(int i = 0; i < E; i++)
  {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    edge[a].push_back(Edge(c, b));
    edge[b].push_back(Edge(c, a));
    edge[a + V].push_back(Edge(c, b + V));
    edge[b + V].push_back(Edge(c, a + V));
  }
  for(int i = 0; i < V; i++)
    for(const auto& v1 : edge[i])
      for(const auto& v2 : edge[v1.to])
        if(v2.to != i)
          edge[i].push_back(Edge(0, v2.to + V));

  priority_queue<P, vector<P>, greater<P>> q;
  q.push(make_pair(0, 0));
  while(!q.empty())
  {
    auto p = q.top(); q.pop();
    int c = p.first, v = p.second;
    if(d[v] < c)
      continue;
    for(const Edge& e : edge[v])
    {
      if(d[e.to] > d[v] + e.cost)
        q.push(make_pair(d[e.to] = d[v] + e.cost, e.to));
    }
  }
  cout << min(d[V - 1], d[V * 2 - 1]) << endl;
  goto loop;
}

Compiler output:
a.cc: In constructor 'Edge::Edge(int, int)':
a.cc:12:38: error: expected ';' before '}' token
   12 |   Edge(int c, int t){cost = c, to = t}
      |                                      ^
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
int n,m,mm;
int a[302],b[302],c[302],mn[302];
int ans;
int slv();

int main(){
  while(1){
    cin>>n>>m;
    if(n==0 && m==0)break;
    mm=m;
    ans=2000000;
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    memset(c,0,sizeof(c));
    for(int i=2;i<=n;i++)mn[i]=2000000;
    for(int i=1;i<=m;i++)cin>>a[i]>>b[i]>>c[i];

    mn[1]=0;
    slv();
    mm++;
    for(int i=1;i<=n;i++){
      for(int j=1;j<=m;j++){
	if(a[j]==i){
	  for(int k=1;k<=m;k++){
	    if(a[k]==b[j]){
	      a[mm]=i;
	      b[mm]=b[k];
	      for(int i=2;i<=n;i++)mn[i]=2000000;
	      mn[1]=0;
	      slv();
	    }
	    else if(b[k]==b[i]){
	      a[mm]=i;
	      b[mm]=a[k];
	      for(int i=2;i<=n;i++)mn[i]=2000000;
	      mn[1]=0;
	      slv();
	    }
	  }
	}
	else if(b[j]==i){
	  for(int k=1;k<=m;k++){
	    if(a[k]==a[j]){
	      a[mm]=i;
	      b[mm]=b[k];
	      for(int i=2;i<=n;i++)mn[i]=2000000;
	      mn[1]=0;
	      slv();
	    }
	    else if(b[k]==a[j]){
	      a[mm]=i;
	      b[mm]=a[k];
	      for(int i=2;i<=n;i++)mn[i]=2000000;
	      mn[1]=0;
	      slv();
	    }
	  }
	}
      }
    }
    
    cout<<ans<<endl;
  }
}

int slv(){
  for(int cnt=0;cnt<10;cnt++){
    for(int i=1;i<=n;i++){
      for(int j=1;j<=mm;j++){
	if(a[j]==i){
	  mn[b[j]]=min(mn[b[j]],mn[a[j]]+c[j]);
	}
	else if(b[j]==i){
	  mn[a[j]]=min(mn[a[j]],mn[b[j]]+c[j]);
	}
      }
    }
  }
  ans=min(ans,mn[n]);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:5: error: 'memset' was not declared in this scope
   15 |     memset(a,0,sizeof(a));
      |     ^~~~~~
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 | using namespace std;
a.cc: In function 'int slv()':
a.cc:83:1: warning: no return statement in function returning non-void [-Wreturn-type]
   83 | }
      | ^
Language: C++

#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,m,a,b,c,d[101][101];
bool t[101][101];
main(){
  cin.tie(0);
  sync_with_stdio(false);
  while(cin>>n>>m,n){
    int ans=1e9;
    r(i,n)r(j,n)d[i][j]=i==j?0:1e8;
    memset(t,0,sizeof(t));
    r(i,m){
      cin>>a>>b>>c;a--;b--;
      d[a][b]=d[b][a]=c;
      t[a][b]=t[b][a]=1;
    }
    r(o,n)r(i,n)r(j,n)d[i][j]=min(d[i][j],d[i][o]+d[o][j]);
    r(o,n)r(i,n)r(j,n)if(t[i][o]&&t[o][j])ans=min(ans,d[0][i]+d[j][n-1]);
    cout<<ans<<endl;
  }
}

Compiler output:
a.cc:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:8:3: error: 'sync_with_stdio' was not declared in this scope
    8 |   sync_with_stdio(false);
      |   ^~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,m,a,b,c,d[101][101];
bool t[101][101];
cin.tie(0);
sync_with_stdio(false);
main(){
  while(cin>>n>>m,n){
    int ans=1e9;
    r(i,n)r(j,n)d[i][j]=i==j?0:1e8;
    memset(t,0,sizeof(t));
    r(i,m){
      cin>>a>>b>>c;a--;b--;
      d[a][b]=d[b][a]=c;
      t[a][b]=t[b][a]=1;
    }
    r(o,n)r(i,n)r(j,n)d[i][j]=min(d[i][j],d[i][o]+d[o][j]);
    r(o,n)r(i,n)r(j,n)if(t[i][o]&&t[o][j])ans=min(ans,d[0][i]+d[j][n-1]);
    cout<<ans<<endl;
  }
}

Compiler output:
a.cc:6:1: error: 'cin' does not name a type
    6 | cin.tie(0);
      | ^~~
a.cc:7:16: error: expected constructor, destructor, or type conversion before '(' token
    7 | sync_with_stdio(false);
      |                ^
a.cc:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main(){
      | ^~~~
Language: C++

#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, init, n) for (int i = init; i < (n); i++)

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
    edge() {}
    edge(int to, int cost) : to(to), cost(cost) {}
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

vector<edge> graph[100];
int dp[100][2];
int N, M;

int dijkstra()
{
    priority_queue<T, vector<T>, greater<T>> que;

    rep(i, 100) rep(j, 2) dp[i][j] = iINF;

    dp[0][0] = 0;

    que.push(T{0, 0, 0});

    while (!que.empty())
    {
        int now, dist, used;
        tie(dist, now, used) = que.top();
        que.pop();

        if (dp[now][used] < dist)
            continue;

        for (auto e : graph[now])
        {
            if (dp[now][used] + e.cost >= dp[e.to][used])
                continue;

            dp[e.to][used] = dp[now][used] + e.cost;

            que.push(T{dp[e.to][used], e.to, used});

            if (used)
                continue;

            int next = e.to;

            for (auto ed : graph[next])
            {
                if (dp[now][0] >= dp[ed.to][1])
                    continue;

                dp[ed.to][1] = dp[now][0];

                que.push(T{dp[ed.to][1], ed.to, 1});
            }
        }
    }

    return min(dp[N - 1][0], dp[N - 1][1]);
}

int main()
{
    while (cin >> N >> M && N)
    {
        rep(i, 100) graph[i].clear();

        rep(i, M)
        {
            int a, b, c;
            cin >> a >> b >> c;
            a--;
            b--;
            graph[a].push_back({b, c});
            graph[b].push_back({a, c});
        }

        cout << dijkstra() << endl;
    }

    return 0;
}


Compiler output:
a.cc:13:5: error: ISO C++ forbids declaration of 'edge' with no type [-fpermissive]
   13 |     edge() {}
      |     ^~~~
a.cc:14:5: error: ISO C++ forbids declaration of 'edge' with no type [-fpermissive]
   14 |     edge(int to, int cost) : to(to), cost(cost) {}
      |     ^~~~
a.cc: In member function 'int<unnamed struct>::edge()':
a.cc:13:13: warning: no return statement in function returning non-void [-Wreturn-type]
   13 |     edge() {}
      |             ^
a.cc: In member function 'int<unnamed struct>::edge(int, int)':
a.cc:14:30: error: only constructors take member initializers
   14 |     edge(int to, int cost) : to(to), cost(cost) {}
      |                              ^~
a.cc:14:50: warning: no return statement in function returning non-void [-Wreturn-type]
   14 |     edge(int to, int cost) : to(to), cost(cost) {}
      |                                                  ^
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(void){
  int graph[101][101],cpy[101][101],n,m,a,b,c;

  while(cin >> n >> m,n|m){

    for(int i=0;i<=n;i++){
      for(int j=0;j<=n;j++){
	graph[i][j]=cpy[i][j]=10000000;
      }
      graph[i][i]=0;
    }

    for(int i=0;i<m;i++){
      cin >> a >> b >> c;
      graph[a][b]=graph[b][a]=cpy[a][b]=cpy[b][a]=c;
    }

    for(int k=0;k<=n;k++)
      for(int i=0;i<=n;i++)
	for(int j=0;j<=n;j++)
	  graph[i][j]=graph[j][i]=min(graph[i][j],graph[i][k]+graph[k][j]);
    
    int ans=INT_MAX;
    for(int k=0;k<=n;k++)
      for(int i=0;i<=n;i++)
	if(cpy[i][k]<10000000)
	  for(int j=0;j<=n;j++)
	    if(cpy[k][j]<10000000)
	      ans=min(ans,graph[1][i]+graph[j][n]);

    cout << ans << endl;
  }
}

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

#include <iostream>
#include <vector>

using namespace std;

#define INF (1 << 10)

typedef pair<int, int> P;

int main() {
	int n, m;
	while (cin >> n >> m, n || m) {
		vector< vector<int> > cost(n, vector<int>(n, INF));
		vector< vector<int> > connect(n, vector<int>(n, 0));

		for (int i = 0; i < n; ++i)
			cost[i][i] = 0;

		for (int i = 0; i < m; ++i) {
			int a, b, c; cin >> a >> b >> c;
			--a, --b;
			cost[a][b] = cost[b][a] = c;
			connect[a][b] = 1;
		}

		vector<P> koho;
		for (int i = 0; i < n; ++i)
			for (int j = i+1; j < n; ++j)
				for (int k = 0; k < n; ++k)
					if (i != j && connect[i][k] && connect[k][j])
						koho.push_back( P(i, j) );

		koho.erase( unique( koho.begin(), koho.end() ), koho.end() );

		for (int i = 0; i < n; ++i)
			for (int j = 0; j < n; ++j)
				for (int k = 0; k < n; ++k)
					if (cost[i][k] + cost[k][j] < cost[i][j])
						cost[i][j] = cost[i][k] + cost[k][j];

		int ans = cost[0][n-1];
		for (int x = 0; x != koho.size(); ++x) {
			vector< vector<int> > c = cost;
			c[koho[x].first][koho[x].second] = c[koho[x].second][koho[x].first] = 0;
			for (int i = 0; i < n; ++i)
				for (int j = 0; j < n; ++j)
					for (int k = 0; k < n; ++k)
						if (c[i][k] + c[k][j] < c[i][j])
							c[i][j] = c[i][k] + c[k][j];

			if (c[0][n-1] < ans) ans = c[0][n-1];
		}

		cout << ans << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:29: error: 'unique' was not declared in this scope
   33 |                 koho.erase( unique( koho.begin(), koho.end() ), koho.end() );
      |                             ^~~~~~
Language: C++

#include<iostream>
#include<algorithm>
#define INF 1<<20
using namespace std;

int main(){
  int n,m,s,e,c;

  while(true){
    cin >> n >> m;
    if(n+m == 0)break;
    int lst[n+1][n+1];
    int Graph[n+1][n+1];
    for(int i=0;i<n+1;i++)for(int j=0;j<n+1;j++){
	lst[j][i] = i==j?0:INF;
	Graph[i][j] = INF;
      }
    for(int i=0;i<m;i++){
      cin >> s >> e >> c;
      Graph[s][e] = Graph[e][s] = lst[s][e] = lst[e][s] = c;
    }

    for(int k=1;k<=n;k++)for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)lst[i][j] = min(lst[i][j],lst[i][k]+lst[k][j]);
    int cost = lst[1][n];
    for(int k=1;k<=n;k++){
if(Graph[k][i] == INF)continue;
      for(int i=1;i<=n;i++){
	for(int j=1;j<=n;j++){
	  if(Graph[k][i] != INF &&  Graph[k][j] != INF){	  
	    cost = min(cost,lst[1][i]+lst[j][n]);
	  }
	}
      }
    }
    cout <<  cost << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:13: error: 'i' was not declared in this scope
   26 | if(Graph[k][i] == INF)continue;
      |             ^