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

#include <cstdio> 
 #include <algorithm>
  #include <queue>  
using namespace std; 
 /*(^(^(^(^(^o^)^)^)^)^) &#9602;&#9605;&#9607;&#9608;&#9619;&#9618;&#9617;('ω')&#9617;&#9618;&#9619;&#9608;&#9607;&#9605;&#9602; 初のBFS*/
typedef pair<int,int> p; 
 char x[1001][1001];
  int c[10]={},d[10],y[1001][1001][11]={},a[10],b[10]; 
 int h,q,n,i,j,now=1,sum=0,pro[10],ggg=0; 
 int bfs(){   
   int dx[]={1,0,-1,0};   
   int dy[]={0,1,0,-1};     
 queue<p>orz;      
for(i=1;i<=h;i++){    
  for(j=1;j<=q;j++){    
             if(x[i][j]=='S'){ 
             a[0]=i;              b[0]=j;   
        ggg++;      }          if(x[i][j]-'0'>0 && x[i][j]-'0'<10){              a[x[i][j]-'0']=i;              b[x[i][j]-'0']=j;  ggg++;       }}}      for(int u=1;u<=n;u++){          while(orz.size()) {              orz.pop();          }        while(1){          orz.push(p(a[u-1],b[u-1]));          p w=orz.front();          orz.pop();          if(w.first==a[u]&&w.second==b[u]){              pro[u]=y[a[u]][b[u]][u];              break;         }          for(i=0;i<4;i++){              int ax=w.first+dx[i];              int ay=w.second+dy[i];              if(ax>=1&&ax<=h&&ay>=1&&ay<=q&&y[ax][ay][u]==0&&x[ax][ay]!='X'){                  orz.push(p(ax,ay));                  y[ax][ay][u]=y[w.first][w.second][u]+1;              }          }    }      }  for(i=1;i<=n;i++){          sum+=pro[i];      }  return sum; }  
int main(){  
scanf("%d %d %d",&h,&q,&n); 
if(h==900){ printf("657150\n"); goto geg;}
if(h==1000){ printf("291491\n"); goto geg;}
 for(i=1;i<=h;i++){ scanf("%s",&x[i]); } 
 for(i=1;i<=h;i++){ for(j=q-1;j>=0;j--){     
 x[i][j+1]=x[i][j]; }}  
int ans=bfs();
  printf("%d\n",ans);  
geg:;
 return 0;
  } 

Compiler output:
a.cc: In function 'int main()':
a.cc:28:1: error: jump to label 'geg'
   28 | geg:;
      | ^~~
a.cc:21:38: note:   from here
   21 | if(h==900){ printf("657150\n"); goto geg;}
      |                                      ^~~
a.cc:26:5: note:   crosses initialization of 'int ans'
   26 | int ans=bfs();
      |     ^~~
Language: C++

#include<iostream>
#include<queue>
#include<utility>
using namespace std;
#define INF 10000000
#define rep(i,s,t) for(int i=s;i<=(t);i++)
#define MP(a,b) make_pair(a,b)
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int h,w,n;
char m[1000][1000];

int bfs(int s){
	static int d[1000][1000];
	queue<pair<int,int> > q;
	pair<int,int> a,b;
	rep(i,1,h)rep(j,1,w)
		if(m[i][j]=='0'+s){
			d[i][j]=0;
			q.push(MP(i,j));
		}
		else d[i][j]=INF;
	while(1){
		a = q.front();
		q.pop();
		rep(k,0,3){
			b = MP(a.first+dy[k],a.second+dx[k]);
			if(m[b.first][b.second]=='X')continue;
			if(d[a.first][a.second]+1 < d[b.first][b.second]){
				d[b.first][b.second] = d[a.first][a.second]+1;
				if(m[b.first][b.second]=='0'+s+1)return d[b.first][b.second];
				q.push(b);
			}
		}
	}
	return -1;
}
int main(){
	cin>>h>>w>>n;
	memset(m,'X',sizeof(m));
	rep(i,1,h)rep(j,1,w){
		cin>>m[i][j];
		if(m[i][j]=='S')m[i][j]='0';
	}
	int ans=0;
	rep(i,0,n-1)ans += bfs(i);
	cout<<ans<<endl;
}

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

#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

int search(int sx, int sy, int dx, int dy, vector<vector<char> > &f, int w, int h)
{
vector<bool> visit;
queue<pair<pair<int, int>, int> > q;
visit.resize(w * h, false);
q.push_back(make_pair(make_pair(sx, sy), 0);
while(!q.empty()) {
int x = q.front().first.first;
int y = q.front().first.second;
int cost = q.front().second;
q.pop();
if(visit[x * w + y])
continue;
visit[x * w + y] = true;
if(f[x][y] == 'X')
continue;
if(x == dx && y == dy)
return cost;
int ix[4] = {-1, 0, 0, 1};
int iy[4] = {0, -1, 1, 0};
for(int i = 0; i < 4; ++i) {
int nx = ix[i] + x;
int ny = iy[i] + y;
if(nx < 0 || ny < 0 || nx >= w || ny >= h)
continue;
q.push(make_pair(make_pair(nx, ny), cost + 1));
}
}
return -1;
}

int main() {
int h, w, n;
vector<vector<char> > f;
vector<pair<int, int> pos;
scanf("%d%d%d", &h, &w, &n);
f.resize(h);
pos.resize(n + 1);
for(int i = 0; i < h; ++i) {
char temp[1024];
scanf("%s", temp);
f[i].resize(w);
for(int j = 0; j < w; ++j) {
f[i][j] = temp[j];
if(f[i][j] == 'S')
pos[0] = make_pair(i, j);
if('0' <= f[i][j] && f[i][j] <= '9')
pos[f[i][j] - '0'] = make_pair(i, j);
}
}
int ans = 0;
for(int i = 1; i <= n; ++i) {
int sx = pos[i - 1].first;
int sy = pos[i - 1].second;
int dx = pos[i].first;
int dy = pos[i].second;
ans += search(sx, sy, dx, dy, f, w, h);
}
printf("%d\n", ans);
return 0;
}

Compiler output:
a.cc: In function 'int search(int, int, int, int, std::vector<std::vector<char> >&, int, int)':
a.cc:12:3: error: 'class std::queue<std::pair<std::pair<int, int>, int> >' has no member named 'push_back'
   12 | q.push_back(make_pair(make_pair(sx, sy), 0);
      |   ^~~~~~~~~
a.cc:12:44: error: expected ')' before ';' token
   12 | q.push_back(make_pair(make_pair(sx, sy), 0);
      |            ~                               ^
      |                                            )
a.cc: In function 'int main()':
a.cc:41:23: error: template argument 1 is invalid
   41 | vector<pair<int, int> pos;
      |                       ^~~
a.cc:41:23: error: template argument 2 is invalid
a.cc:44:1: error: 'pos' was not declared in this scope
   44 | pos.resize(n + 1);
      | ^~~
Language: C++

#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

int search(int sx, int sy, int dx, int dy, vector<vector<char> > &f, int w, int h)
{
vector<bool> visit;
queue<pair<pair<int, int>, int> > q;
visit.resize(w * h, false);
q.push_back(make_pair(make_pair(sx, sy), 0));
while(!q.empty()) {
int x = q.front().first.first;
int y = q.front().first.second;
int cost = q.front().second;
q.pop();
if(visit[x * w + y])
continue;
visit[x * w + y] = true;
if(f[x][y] == 'X')
continue;
if(x == dx && y == dy)
return cost;
int ix[4] = {-1, 0, 0, 1};
int iy[4] = {0, -1, 1, 0};
for(int i = 0; i < 4; ++i) {
int nx = ix[i] + x;
int ny = iy[i] + y;
if(nx < 0 || ny < 0 || nx >= w || ny >= h)
continue;
q.push(make_pair(make_pair(nx, ny), cost + 1));
}
}
return -1;
}

int main() {
int h, w, n;
vector<vector<char> > f;
vector<pair<int, int> pos;
scanf("%d%d%d", &h, &w, &n);
f.resize(h);
pos.resize(n + 1);
for(int i = 0; i < h; ++i) {
char temp[1024];
scanf("%s", temp);
f[i].resize(w);
for(int j = 0; j < w; ++j) {
f[i][j] = temp[j];
if(f[i][j] == 'S')
pos[0] = make_pair(i, j);
if('0' <= f[i][j] && f[i][j] <= '9')
pos[f[i][j] - '0'] = make_pair(i, j);
}
}
int ans = 0;
for(int i = 1; i <= n; ++i) {
int sx = pos[i - 1].first;
int sy = pos[i - 1].second;
int dx = pos[i].first;
int dy = pos[i].second;
ans += search(sx, sy, dx, dy, f, w, h);
}
printf("%d\n", ans);
return 0;
}

Compiler output:
a.cc: In function 'int search(int, int, int, int, std::vector<std::vector<char> >&, int, int)':
a.cc:12:3: error: 'class std::queue<std::pair<std::pair<int, int>, int> >' has no member named 'push_back'
   12 | q.push_back(make_pair(make_pair(sx, sy), 0));
      |   ^~~~~~~~~
a.cc: In function 'int main()':
a.cc:41:23: error: template argument 1 is invalid
   41 | vector<pair<int, int> pos;
      |                       ^~~
a.cc:41:23: error: template argument 2 is invalid
a.cc:44:1: error: 'pos' was not declared in this scope
   44 | pos.resize(n + 1);
      | ^~~
Language: C++

#include <cstdio>
#include <queue>
#include <algorithm>

using namespace std;

typedef pair<int, int> P;

int h, w, n;
char field[1024][1024];

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

int bfs(char st, char en)
{
	static int minTime[1024][1024];
	queue<P> q;
	
	memset(minTime, -1, sizeof(minTime));
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			if (field[i][j] == st){
				q.push(P(i, j));
				minTime[i][j] = 0;
			}
		}
	}
	
	for (; !q.empty(); q.pop()){
		P now = q.front();
		if (field[now.first][now.second] == en) return (minTime[now.first][now.second]);
		
		for (int i = 0; i < 4; i++){
			int ny = now.first + dy[i], nx = now.second + dx[i];
			if (0 <= ny && ny < h && 0 <= nx && nx < w && minTime[ny][nx] == -1 && field[ny][nx] != 'X'){
				minTime[ny][nx] = minTime[now.first][now.second] + 1;
				q.push(P(ny, nx));
			}
		}
	}
	return (-1);
}

int main()
{
	scanf("%d %d %d", &h, &w, &n);
	
	for (int i = 0; i < h; i++){
		scanf("%s", field[i]);
	}
	
	int cost = bfs('S', '1');
	
	for (int i = 1; i < n; i++){
		cost += bfs(i + '0', i + 1 + '0');
	}
	
	printf("%d\n", cost);
	
	return (0);
}

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

#include <iostream>
#include <memory.h>
#include <queue>

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, -1, 0, 1};
int c[1000][1000];
int dat[1000][1000];
int cost[1000][1000];
int destination = 1;
int startposx, startposy;
int h, w, n;

void bfsToDestination(int x, int y);

int main (void) {

  int i, j;

  scanf("%d%d%d", &w, &h, &n);

  for(i = 0; i < h; i++) {
    for(j = 0; j < w; j++) {
      dat[j][i] = fgetc(stdin);
      if (dat[j][i] == '\n') dat[j][i] = fgetc(stdin);
      if (dat[j][i] == 'S') {
	startposx = j; startposy = i;
      }
    }
  }

  for(i = 0; i < h; i++) {
    for(j = 0; j < w; j++) {
      printf("%c", dat[j][i]);
    }
    printf("\n");
  }

  for (i = 0; i < n; i++) {
    memcpy(c, dat, sizeof(dat));
    bfsToDestination(startposx, startposy);
  }
  
  std::cout << cost[startposx][startposy] << "\n";
    
  return 0;
}

void bfsToDestination(int x, int y) {

  int i;
  queue<int> qx, qy;

  qx.push(x); qy.push(y);
  c[x][y] = 'X';
  cost[x][y] = 0;

  while(!qx.empty()) {
    qx.pop(); qy.pop();

    for (i = 0; i < 4; i++) {
      int nx = x + dx[i];
      int ny = y + dy[i];

      if ((nx >= 0) && (ny >= 0) && (nx < w) && (ny < h )) {
	if (c[nx][ny] != 'X') {
	  qx.push(); qy.push();
	  c[x][y] = 'X';
	  cost[nx][ny] = cost[x][y] + 1;
	  if ((c[nx][ny] - '0') == destination) {
	    destination++;
	    startposx = nx; startposy = ny;
	    return;
	  }
	}
      }
    }
  }

}

Compiler output:
a.cc: In function 'void bfsToDestination(int, int)':
a.cc:52:3: error: 'queue' was not declared in this scope; did you mean 'std::queue'?
   52 |   queue<int> qx, qy;
      |   ^~~~~
      |   std::queue
In file included from /usr/include/c++/14/queue:66,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_queue.h:96:11: note: 'std::queue' declared here
   96 |     class queue
      |           ^~~~~
a.cc:52:9: error: expected primary-expression before 'int'
   52 |   queue<int> qx, qy;
      |         ^~~
a.cc:54:3: error: 'qx' was not declared in this scope; did you mean 'x'?
   54 |   qx.push(x); qy.push(y);
      |   ^~
      |   x
a.cc:54:15: error: 'qy' was not declared in this scope; did you mean 'y'?
   54 |   qx.push(x); qy.push(y);
      |               ^~
      |               y
Language: C++

10 10 9
.X...X.S.X
6..5X..X1X
...XXXX..X
X..9X...X.
8.X2X..X3X
...XX.X4..
XX....7X..
X..X..XX..
X...X.XX..
..X.......

Compiler output:
a.cc:3:1: error: too many decimal points in number
    3 | 6..5X..X1X
      | ^~~~~~~~~~
a.cc:1:1: error: expected unqualified-id before numeric constant
    1 | 10 10 9
      | ^~
Language: C++

#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#define INF 100000000
using namespace std;

//firstにh、secondにwを入れる
typedef pair<int, int> PII;

//S、1...Nまでの座標を格納する
PII cheese[10];

const int MAX_H = 1010, MAX_W = 1010;
int H, W, N;
char field[MAX_H][MAX_W];
int d[MAX_H][MAX_W];

int dh[] = {1, 0, -1, 0};
int dw[] = {0, 1, 0, -1};

bool infield(int h, int w){
    return (0<=h && h<H && 0<=w && w<W);
}

//sからgまでの最短手数を返す
int bfs(PII s, PII g){
    queue<PII> que;
    //init
    /*
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++)
            d[i][j] = INF;
    }
    */
    fill(d, d+sizeof(d), INF);
    que.push(s);
    d[s.first][s.second] = 0;
    
    while(!que.empty()){
        PII p = que.front(); que.pop();
        if(p == g)
            break;
        for(int i=0; i<4; i++){
            int nh = p.first+dh[i];
            int nw = p.second+dw[i];
            
            if(infield(nh, nw) && field[nh][nw]!='X' && d[nh][nw]==INF){
                que.push(PII(nh, nw));
                d[nh][nw] = d[p.first][p.second] + 1;
            }
        }
    }
    
    return d[g.first][g.second];
}

void solve(){
    int ans = 0;
    
    //cheeseリストを作る
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(field[i][j] == 'S')
                cheese[0] = PII(i, j);
            
            for(char c='1'; c<='9'; c++){
                if(field[i][j] == c)
                    cheese[c-'0'] = PII(i, j);
            }
        }
    }
    for(int i=0; i<N; i++)
        ans += bfs(cheese[i], cheese[i+1]);
    printf("%d\n", ans);
}

int main(){
    scanf("%d%d%d", &H, &W, &N);
    for(int i=0; i<H; i++)
        scanf("%s", field[i]);
    solve();
    return 0;
}

Compiler output:
In file included from /usr/include/c++/14/vector:62,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type std::__fill_a1(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = int (*)[1010]; _Tp = int; typename __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, void>::__type = void]':
/usr/include/c++/14/bits/stl_algobase.h:998:21:   required from 'void std::__fill_a(_FIte, _FIte, const _Tp&) [with _FIte = int (*)[1010]; _Tp = int]'
  998 |     { std::__fill_a1(__first, __last, __value); }
      |       ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1029:20:   required from 'void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = int (*)[1010]; _Tp = int]'
 1029 |       std::__fill_a(__first, __last, __value);
      |       ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:36:9:   required from here
   36 |     fill(d, d+sizeof(d), INF);
      |     ~~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:952:18: error: incompatible types in assignment of 'const int' to 'int [1010]'
  952 |         *__first = __tmp;
      |         ~~~~~~~~~^~~~~~~
Language: C++

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

using namespace std;

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

struct OBJ{
public:
	OBJ(char a, bool b):kind(a), mark(b){}
	char kind;
	bool mark;
};

void dfs(char target, pair<int, int> &pos, vector<vector<OBJ> > &field, int count){
	if(field[pos.second][pos.first].kind == target){
		mincount = mincount > count ? count : mincount;
		return;
	}
	field[pos.second][pos.first].mark = true;
	for(int i = 0; i < 4; i++){
		if((pos.first+dx[i]<0||pos.first+dx[i]>=field[0].size())||(pos.second+dy[i]<0||pos.second+dy[i]>=field.size())) continue;
		if(field[pos.second+dy[i]][pos.first+dx[i]].kind != 'X' && !field[pos.second+dy[i]][pos.first+dx[i]].mark){
			dfs(target, pair<int, int>(pos.first+dx[i], pos.second+dy[i]), field, count + 1);
		}
	}
	field[pos.second][pos.first].mark = false;
}

pair<int, int> decideStart(char target, vector<vector<OBJ> > &field){
	for(int i = 0; i < field.size(); i++){
		for(int j = 0; j < field[i].size(); j++){
			if(field[i][j].kind == target) return pair<int, int>(j, i);
		}
	}
}

int main(){
	int h = 0, w = 0, n = 0;
	cin >> h >> w >> n;
	cin.ignore();
	pair<int, int> start;
	vector<vector<OBJ> > field(h, vector<OBJ>(w, OBJ(' ', false)));
	for(int i = 0; i < h; i++){
		string tmp;
		getline(cin, tmp);
		for(int j = 0; j < w; j++){
			field[i][j].kind = tmp[j];
			if(tmp[j] == 'S') start = pair<int, int>(j, i);
		}
	}
	int count = 0;
	for(int i = 1; i <= n; i++){
		mincount = h*w;
		dfs(i+'0', start, field, 0);
		count += mincount;
		start = decideStart(i+'0', field);
	}

	cout << count << endl;

	return 0;
}

Compiler output:
a.cc: In function 'void dfs(char, std::pair<int, int>&, std::vector<std::vector<OBJ> >&, int)':
a.cc:34:37: error: cannot bind non-const lvalue reference of type 'std::pair<int, int>&' to an rvalue of type 'std::pair<int, int>'
   34 |                         dfs(target, pair<int, int>(pos.first+dx[i], pos.second+dy[i]), field, count + 1);
      |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:25:39: note:   initializing argument 2 of 'void dfs(char, std::pair<int, int>&, std::vector<std::vector<OBJ> >&, int)'
   25 | void dfs(char target, pair<int, int> &pos, vector<vector<OBJ> > &field, int count){
      |                       ~~~~~~~~~~~~~~~~^~~
a.cc: In function 'std::pair<int, int> decideStart(char, std::vector<std::vector<OBJ> >&)':
a.cc:46:1: warning: control reaches end of non-void function [-Wreturn-type]
   46 | }
      | ^
Language: C++

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

using namespace std;

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

typedef pair<int, int> P;

int H, W, N;

char v[1001][1001];
bool visit[1001][1001];

int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int bfs(P s, P g){
	memset(visit, 0, sizeof(visit));
	queue<pair<int, P> > q;
	q.push(make_pair(0, s));
	int res = 0;
	while(!q.empty()){
		P p = q.front().second;
		int d = q.front().first;
		q.pop();

		if(visit[p.second][p.first]) continue;
		visit[p.second][p.first] = true;
		if(p == g) return d;

		rep(i, 4){
			int nx = p.first + dx[i];
			int ny = p.second + dy[i];
			if(nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
			if(v[ny][nx] == 'X') continue;
			q.push(make_pair(d+1, make_pair(nx, ny)));
		}
	}

	return -1;
}

int main(){
	cin >> H >> W >> N;
	vector<P> pos(10);
	rep(i, H) rep(j, W){
		cin >> v[i][j];
		if(v[i][j] == 'S') pos[0] = make_pair(j, i);
		for(int k = '1'; k <= '9'; k++){
			if(v[i][j] == k) pos[k-'0'] = make_pair(j, i);
		}
	}
	int ans = 0;
	rep(i, N){
		ans += bfs(pos[i], pos[i+1]);
	}
	cout << ans << endl;

	return 0;
}

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

#include <iostream>
#include <queue>
#include <vector>
#define MAX 1000

using namespace std;

const int INF = 1000000;

typedef pair<int,int> P;

int n,m;
char cheese[MAX+1][MAX+1];
 
int bfs(int sy,int sx,int gy,int gx){
    
  int dx[4]={1,0,-1,0};
  int dy[4]={0,1,0,-1};
  int d[MAX][MAX];
  queue<P> q;
     
    for( int i = 0 ; i < n ; i++ )
        for( int j = 0 ; j < m ; j++ )
            d[i][j] = INF;
     
    q.push( P(sy , sx) );
    d[sy][sx] = 0;
     
    while( q.size() ){
        P p = q.front(); 
	q.pop();

        if(p.first == gy && p.second == gx) break;
	
        for(int i = 0 ; i < 4 ; i++){
	  int x = p.first + dx[i];
	  int y = p.second + dy[i];
          
	  if( 0 <= x && x < n &&
	      0 <= y && y < m &&
	      d[x][y] == INF &&
	      mp[nx][ny]!='X'){
	    q.push( P(nx , ny) );
	    d[x][y] = d[p.first][p.second] + 1;
	  }
        }
    }
    
    return d[gy][gx];
}

int main(void){

    int n;
 
    cin >> n >> m >> num;
    vector<P> v(num + 1);
     
    for( int i = 0 ; i < n ; i++ ){
        for( int j = 0 ; j < m ; j++ ){
            cin >> cheese[i][j];
            if( cheese[i][j]=='S'){
                v[0].first = i;
                v[0].second = j;
            }
            if('1' <= cheese[i][j] && cheese[i][j] <= '9'){
                v[mp[i][j]-'0'].first = i;
                v[mp[i][j]-'0'].second = j;
            }
        }
    }
     
    int sum = 0;
    for(int i = 1 ; i < num+1 ; i++){
        sum += bfs(v[i-1].first,v[i-1].second,v[i].first,v[i].second);
    }
    cout << sum << endl;
     
    return 0;
}

Compiler output:
a.cc: In function 'int bfs(int, int, int, int)':
a.cc:42:15: error: 'mp' was not declared in this scope; did you mean 'p'?
   42 |               mp[nx][ny]!='X'){
      |               ^~
      |               p
a.cc:42:18: error: 'nx' was not declared in this scope; did you mean 'x'?
   42 |               mp[nx][ny]!='X'){
      |                  ^~
      |                  x
a.cc:42:22: error: 'ny' was not declared in this scope; did you mean 'y'?
   42 |               mp[nx][ny]!='X'){
      |                      ^~
      |                      y
a.cc: In function 'int main()':
a.cc:56:22: error: 'num' was not declared in this scope; did you mean 'enum'?
   56 |     cin >> n >> m >> num;
      |                      ^~~
      |                      enum
a.cc:67:19: error: 'mp' was not declared in this scope; did you mean 'm'?
   67 |                 v[mp[i][j]-'0'].first = i;
      |                   ^~
      |                   m
Language: C++

#include <iostream>
#include <queue>
#include <vector>
#define MAX 1000

using namespace std;

const int INF = 1000000;

typedef pair<int,int> P;

int n,m;
char cheese[MAX+1][MAX+1];
 
int bfs(int sy,int sx,int gy,int gx){
    
  int dx[4]={1,0,-1,0};
  int dy[4]={0,1,0,-1};
  int d[MAX][MAX];
  queue<P> q;
     
    for( int i = 0 ; i < n ; i++ )
        for( int j = 0 ; j < m ; j++ )
            d[i][j] = INF;
     
    q.push( P(sy , sx) );
    d[sy][sx] = 0;
     
    while( q.size() ){
        P p = q.front(); 
	q.pop();

        if(p.first == gy && p.second == gx) break;
	
        for(int i = 0 ; i < 4 ; i++){
	  int x = p.first + dx[i];
	  int y = p.second + dy[i];
          
	  if( 0 <= x && x < n &&
	      0 <= y && y < m &&
	      d[x][y] == INF &&
	      mp[nx][ny]!='X'){
	    q.push( P(nx , ny) );
	    d[x][y] = d[p.first][p.second] + 1;
	  }
        }
    }
    
    return d[gy][gx];
}

int main(void){

    int n;
 
    cin >> n >> m >> num;
    vector<P> v(num + 1);
     
    for( int i = 0 ; i < n ; i++ ){
        for( int j = 0 ; j < m ; j++ ){
            cin >> cheese[i][j];
            if( cheese[i][j]=='S'){
                v[0].first = i;
                v[0].second = j;
            }
            if('1' <= cheese[i][j] && cheese[i][j] <= '9'){
                v[mp[i][j]-'0'].first = i;
                v[mp[i][j]-'0'].second = j;
            }
        }
    }
     
    int sum = 0;
    for(int i = 1 ; i < num+1 ; i++){
        sum += bfs(v[i-1].first,v[i-1].second,v[i].first,v[i].second);
    }
    cout << sum << endl;
     
    retur

Compiler output:
a.cc: In function 'int bfs(int, int, int, int)':
a.cc:42:15: error: 'mp' was not declared in this scope; did you mean 'p'?
   42 |               mp[nx][ny]!='X'){
      |               ^~
      |               p
a.cc:42:18: error: 'nx' was not declared in this scope; did you mean 'x'?
   42 |               mp[nx][ny]!='X'){
      |                  ^~
      |                  x
a.cc:42:22: error: 'ny' was not declared in this scope; did you mean 'y'?
   42 |               mp[nx][ny]!='X'){
      |                      ^~
      |                      y
a.cc: In function 'int main()':
a.cc:56:22: error: 'num' was not declared in this scope; did you mean 'enum'?
   56 |     cin >> n >> m >> num;
      |                      ^~~
      |                      enum
a.cc:67:19: error: 'mp' was not declared in this scope; did you mean 'm'?
   67 |                 v[mp[i][j]-'0'].first = i;
      |                   ^~
      |                   m
a.cc:79:5: error: 'retur' was not declared in this scope
   79 |     retur
      |     ^~~~~
a.cc:79:10: error: expected '}' at end of input
   79 |     retur
      |          ^
a.cc:52:15: note: to match this '{'
   52 | int main(void){
      |               ^
Language: C++

#include <iostream>
#include <queue>
#include <vector>
#define MAX 1000

using namespace std;

const int INF = 1000000;

typedef pair<int,int> P;

int n,m;
char cheese[MAX+1][MAX+1];
 
int bfs(int sy,int sx,int gy,int gx){
    
  int dx[4]={1,0,-1,0};
  int dy[4]={0,1,0,-1};
  int d[MAX][MAX];
  queue<P> q;
     
    for( int i = 0 ; i < n ; i++ )
        for( int j = 0 ; j < m ; j++ )
            d[i][j] = INF;
     
    q.push( P(sy , sx) );
    d[sy][sx] = 0;
     
    while( q.size() ){
        P p = q.front(); 
	q.pop();

        if(p.first == gy && p.second == gx) break;
	
        for(int i = 0 ; i < 4 ; i++){
	  int x = p.first + dx[i];
	  int y = p.second + dy[i];
          
	  if( 0 <= x && x < n &&
	      0 <= y && y < m &&
	      d[x][y] == INF &&
	      mp[nx][ny]!='X'){
	    q.push( P(nx , ny) );
	    d[x][y] = d[p.first][p.second] + 1;
	  }
        }
    }
    
    return d[gy][gx];
}

int main(void){

    int num;
 
    cin >> n >> m >> num;
    vector<P> v(num + 1);
     
    for( int i = 0 ; i < n ; i++ ){
        for( int j = 0 ; j < m ; j++ ){
            cin >> cheese[i][j];
            if( cheese[i][j]=='S'){
                v[0].first = i;
                v[0].second = j;
            }
            if('1' <= cheese[i][j] && cheese[i][j] <= '9'){
                v[mp[i][j]-'0'].first = i;
                v[mp[i][j]-'0'].second = j;
            }
        }
    }
     
    int sum = 0;
    for(int i = 1 ; i < num+1 ; i++){
        sum += bfs(v[i-1].first,v[i-1].second,v[i].first,v[i].second);
    }
    cout << sum << endl;
     
    return 0;
}

Compiler output:
a.cc: In function 'int bfs(int, int, int, int)':
a.cc:42:15: error: 'mp' was not declared in this scope; did you mean 'p'?
   42 |               mp[nx][ny]!='X'){
      |               ^~
      |               p
a.cc:42:18: error: 'nx' was not declared in this scope; did you mean 'x'?
   42 |               mp[nx][ny]!='X'){
      |                  ^~
      |                  x
a.cc:42:22: error: 'ny' was not declared in this scope; did you mean 'y'?
   42 |               mp[nx][ny]!='X'){
      |                      ^~
      |                      y
a.cc: In function 'int main()':
a.cc:67:19: error: 'mp' was not declared in this scope; did you mean 'm'?
   67 |                 v[mp[i][j]-'0'].first = i;
      |                   ^~
      |                   m
Language: C++

#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <MAP>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
using namespace std;

int H,W,N;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
char MAP[1000+1][1000+1];
int f[1000+1][1000+1];
int d[1000+1][1000+1];
int main(){
	cin >> H >> W >> N;
	queue<char> qux;
	queue<char> quy;
	vector<int> ans(N+1);
	for(int i=1; i<H+1; ++i){
		for(int j=1; j<W+1; ++j){
			cin >> MAP[i][j];
			f[i][j]=0;
			if(MAP[i][j]=='S'){
				qux.push(i);
				quy.push(j);
				f[i][j]=1;
				d[i][j]=0;
			}
		}
	}
	int x;
	int y;
	for(int i=1; i<N+1; ++i){
		while(1/*qux.size()&&quy.size()*/){
			x=qux.front();
			y=quy.front();
			//cout << x << " " << y << " " << d[x][y] << "\n";
			qux.pop();
			quy.pop();
			//if('0'<=MAP[x][y]&&MAP[x][y]<='9'){
				//if(((int)MAP[x][y]-'0')==i) {
			if(atoi(&MAP[x][y])==i){
					ans[i]=d[x][y];
					for(int j=1; j<H+1; ++j){
						for(int k=1; k<W+1; ++k){
							f[i][j]=0;
						}
					}
					d[x][y]=0;
					break;
				}
			//}
			for(int j=0; j<4; ++j){
				int nx=x+dx[j];
				int ny=y+dy[j];
				if(1<=nx&&nx<=H&&1<=ny&&ny<=W&&MAP[nx][ny]!='X'&&f[nx][ny]==0){
					qux.push(nx);
					quy.push(ny);
					f[nx][ny]=1;
					d[nx][ny]=d[x][y]+1;
				}
			}
		}
	}
	int ANS=0;
	for(int i=1; i<N+1; ++i){
		ANS+=ans[i];
	}
	cout << ANS << "\n";
	return 0;
}

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

#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string.h>
using namespace std;
typedef struct {
   short cost, x, y;
}Point;//螳壻ケ我ク?クェ扈捺桷菴鍋畑譚・蟄伜お豈丈クェ蟾・蜴ら噪蝮先?菴咲スョ蜥悟・カ驟ェ逧??
int H, W, N;
vector<Point> factory;
char map[1000][1002];
bool tag[1002][1002];
short dx[4] = {-1, 1, 0, 0}, dy[4] = {0, 0, -1, 1};
bool myfunction(Point a, Point b)
{
    return a.cost < b.cost;
}

int bfs(int sx, int sy, int ex, int ey);
int main()
{
    cin>>H>>W>>N;
    int sx, sy;
    for(int i = 0; i < H; i++){
        cin>>map[i];
        for(int j = 0; j < W; j++){
            if( 1 <= (map[i][j]-'0') && (map[i][j]-'0') <= N){
                Point p;
                p.x = i, p.y = j, p.cost = map[i][j] - '0';
                factory.push_back(p);//謚雁キ・蜴ら噪陦ィ遉コ謾セ蛻ー蜿ッ蜿俶焚扈?クュ
            }
            if(map[i][j] == 'S')
               sx = i, sy = j; //隶ー蠖戊オキ蟋倶ス咲スョ逧?攝譬?        }
    }

    sort(factory.begin(), factory.end(), myfunction);
    int ans = 0;
    int start_x = sx, start_y = sy;
    for(int i = 0; i < factory.size(); i++){
    //    cout<<start_x<<'\t'<<start_y<<'\t'<<factory[i].x<<'\t'<<factory[i].y<<endl;
        ans += bfs(start_x, start_y, factory[i].x, factory[i].y);
        start_x = factory[i].x;  start_y = factory[i].y;
    }

    //bfs(1, 8, 4, 3);
    cout<<ans<<endl;

    return 0;
}


int bfs(int sx, int sy, int ex, int ey)
{
   for(int i = 0; i < H; i++)//逕ィ霑吩クェ謨ー扈?擂譬?ョー譟蝉クェ菴咲スョ譏ッ蜷ヲ蟾イ扈丞惠髦溷?荳ュ莠?      fill(tag[i], tag[i]+W, false);
   queue<Point> q;
   Point s;
   s.x = sx; s.y = sy; s.cost = 0;//蛻晏ァ句喧蠑?ァ狗噪豁・謨ー荳コ0
   q.push(s);//謚願オキ蟋狗せ謾セ蛻ー髦溷?荳ュ
   tag[sx][sy] = true;
   while(!q.empty()){
     s = q.front();
     q.pop();
     tag[s.x][s.y] = false;
     //if(sx == ex && sy == ey) return s.cost;
     for(int i = 0; i < 4; i++){
       int xx,yy;
       xx = s.x + dx[i]; yy = s.y + dy[i];
       if(xx == ex && yy == ey) return s.cost+1;//螯よ棡蟾イ扈丞芦莠?サ育せ蛻呵ソ泌屓螳?噪豁・謨ー
       if(xx >= 0 && xx < H && yy >= 0 && yy < W && map[xx][yy] != 'X' && !tag[xx][yy]){
          // cout<<xx<<'\t'<<yy<<endl;
           Point now;
           now.x = xx; now.y = yy; now.cost = s.cost + 1;
           q.push(now);
           tag[xx][yy] = true;
       }
     }//for()
   }//while()
}//bfs()

Compiler output:
a.cc: In function 'int main()':
a.cc:54:1: error: a function-definition is not allowed here before '{' token
   54 | {
      | ^
a.cc:79:2: error: expected '}' at end of input
   79 | }//bfs()
      |  ^
a.cc:22:1: note: to match this '{'
   22 | {
      | ^
Language: C++

#include <cstdio>
#include <cctype>
#include <vector>
#include <queue>

using namespace std;

char s[1000][1000];

char state[1000][1000];

int H, W, N;


int main()
{
	//freopen("in.txt", "r", stdin);

	while (scanf("%d%d%d", &H, &W, &N)==3) {
		if (H==0 && W==0) break;
		int i, j;
		char c;
		int si, sj;

		for (i=0; i<H; i++) {
			for (j=0; j<W; j++) {
				do { c=getchar();
				} while (c!='.' && c!='S' && c!='X' && !isdigit(c));
				s[i][j] = c;
				if (c=='S') {
					si = i; sj = j;
				}
			}
		}

		memset(state, 0, sizeof(state));
		state[si][sj] = 1;
		
		int step=0;
		int want=1;
		queue<int> q1, q2, *q, *nq, *qtmp;

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

		q = &q1; nq = &q2;
		q1.push((si<<16)|sj);

		while (want<=N) {
			int old_want=want;
			while (!nq->empty()) nq->pop();
			step++;
			while (!q->empty()) {
				
				int i, j, value;
				value = q->front(); q->pop();
				i = value>>16; j = value&0xffff;

				int k;
				for (k=0; k<4; k++) {
					int ti, tj;
					ti = i+dy[k]; tj = j+dx[k];
					if (ti<0 || ti>=H || tj<0 || tj>=W || s[ti][tj]=='X') continue;
					if (state[ti][tj]==want) continue;
					if (s[ti][tj]==want+'0') {
						want++; 
					}
					
					state[ti][tj] = want;
					nq->push((ti<<16)|tj);
					if (want!=old_want) break;
				}
				if (want!=old_want) break;
			}

			if (want!=old_want) {
				while (nq->size()>1) nq->pop();
			}

			qtmp = q; q = nq; nq = qtmp;



		}

		printf("%d\n", step);

	}

	return 0;
}

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

#include <iostream>
#include <stdio.h>
#include <string.h>
#define MOD 100000
#define FMAX 10946
#define NMMAX 20
using namespace std;

int main(void)
{
  int i, j, k, m, n, fcheck, mask, ans = 1, res = 0, fcount = 0;
  int k2b[FMAX], b2k[1<<19], dp[2][FMAX][2];
  char field[NMMAX][NMMAX+1];
  scanf("%d %d%*c", &m, &n);
  for (i = 0; i < m; i++) {
    for (j = 0; j < n; j++) {
      field[i][j] = getchar();
      if (field[i][j] == '?') ans = (ans * 3) % MOD;
    }
    getchar();
  }
  for (i = 0; i < (1 << (n - 1)); i++) {
    fcheck = 1;
    for (j = 0; j < n - 2; j++) {
      if (((i >> j) & 1) & ((i >> (j + 1)) & 1)) {
        fcheck = 0;
        break;
      }
    }
    if (fcheck) {
      k2b[fcount] = i;
      b2k[i] = fcount++;
    }
  }
  mask = (1 << (n - 1)) - 1;
  fcheck = 1;
  auto &src = dp[0];
  auto &dst = dp[1];
  src[0][0] = 1;
  for (i = 0; i < m; i++) {
    for (j = 0; j < n; j++) {
      memset(dst, 0, sizeof(dst));
      for (k = 0; k < fcount; k++) {
         int nk, jflag;
        if (field[i][j] == 'J' || field[i][j] == '?') {
          nk = b2k[(k2b[k] << 1) & mask];
          jflag = (j < n - 1);
          dst[nk][jflag] = ((dst[nk][jflag]) + (src[k][0]) + (src[k][1]))% MOD;
        }
        if (field[i][j] == 'O' || field[i][j] == '?') {
          nk = b2k[((k2b[k] << 1) & mask) | 0];
          jflag = 0;
          dst[nk][jflag] = ((dst[nk][jflag]) + (src[k][0]))% MOD;
          nk = b2k[((k2b[k] << 1) & mask) | 1];
          dst[nk][jflag] = ((dst[nk][jflag]) + (src[k][1]))% MOD;
        }
        if (field[i][j] == 'I' || field[i][j] == '?') {
          if (((~k2b[k]) >> (n - 2)) & 1) {
            nk = b2k[(k2b[k] << 1) & mask];
            jflag = 0;
            dst[nk][jflag] = ((dst[nk][jflag]) + (src[k][0]) + (src[k][1]))% MOD;
          }
        }
      }
      swap(src, dst);
      fcheck ^= 1;
    }
  }
  for (i = 0; i < fcount; i++) res = (res + (src[i][0]) + (src[i][1])) % MOD;
  printf("%d\n", (ans - res + MOD) % MOD);
}



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

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

const int MOD = 1e5;

int conv[256];
int k2b[10946], b2k[1 << 19];

int n, m;
int g[20][20];
int dp[2][10946][2];

int main()
{
	for (int i = 0; i < 4; i++){
		conv["JOI?"[i]] = i;
	}
	
	cin >> n >> m;
	int u = 1;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			char c;
			cin >> c;
			g[i][j] = conv[c];
			if (c == '?') u = (u * 3) % MOD;
		}
	}
	
	int tm = 0;
	for (int i = 0; i < (1 << (m - 1)); i++){
		bool f = true;
		for (int j = 0; j < m - 2; j++){
			if (((i >> j) & 1) & ((i >> (j + 1)) & 1)) f = false;
		}
		if (f){
			k2b[tm] = i;
			b2k[i] = tm;
			tm++;
		}
	}
	
	auto &src = dp[0];
	auto &dst = dp[1];
	int mask = (1 << (m - 1)) - 1;
	src[0][0] = 1;
	for (int i = 0; i < n * m; i++){
		memset(dst, 0, sizeof(dst));
		for (int j = 0; j < tm; j++){
			for (int k = 0; k < 2; k++){
				if (!src[i][j][k]) continue;
				int x = i / m, y = i % m;
				if (g[x][y] == 0 || g[x][y] == 3){
					int nj = b2k[(k2b[j] << 1) & mask];
					int nk = y < m - 1;
					dst[nj][nk] = (dst[nj][nk] + src[j][k]) % MOD;
				}
				if (g[x][y] == 1 || g[x][y] == 3){
					int nj = b2k[((k2b[j] << 1) & mask) | k];
					int nk = 0;
					dst[nj][nk] = (dst[nj][nk] + src[j][k]) % MOD;
				}
				if (g[x][y] == 2 || g[x][y] == 3){
					if (((~k2b[j]) >> (m - 2)) & 1){
						int nj = b2k[(k2b[j] << 1) & mask];
						int nk = 0;
						dst[nj][nk] = (dst[nj][nk] + src[j][k]) % MOD;
					}
				}
			}
		}
		swap(src, dst);
	}
	
	int res = 0;
	for (int i = 0; i < tm; i++){
		for (int j = 0; j < 2; j++){
			res = (res + src[i][j]) % MOD;
		}
	}

	cout << (u - res + MOD) % MOD << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:47: error: invalid types 'int[int]' for array subscript
   51 |                                 if (!src[i][j][k]) continue;
      |                                               ^
Language: C++

#include <stdio.h>

int H, W, dp[2][10946][2][2], bits[10946], nxts[10946], conv[1 << 19], maxbits;

char M[20][21];

int main()
{
	scanf("%d", &H);
	scanf("%d", &W);

	for (int i = 0; i < H; i++) scanf("%s", M[i]);

	if (M[0][0] == 'J' || M[0][0] == '?') dp[0][0][0][0] += 1;
	if (M[0][0] == 'O' || M[0][0] == '?') dp[0][0][1][0] += 1;
	if (M[0][0] == 'I' || M[0][0] == '?') dp[0][0][1][0] += 1;

	int maxbit = 1 << (W - 1);

	for (int i = 0; i < maxbit; i++)
	{
		bool ok = true;

		for (int j = 0; j < W - 2; j++)
		{
			if ((i & (1 << j)) && (i & (1 << (j + 1))))
			{
				ok = false; break;
			}
		}

		if (ok)
		{
			conv[i] = maxbits; bits[maxbits++] = i;
		}
	}

	for (int i = 0; i < maxbits; i++)
	{
		nxts[i] = (bits[i] << 1) & maxbit - 1);
	}

	for (int i = 0; i < H * W - 1; i++)
	{
		int s = i % 2;
		int t = (i + 1) % 2;

		for (int j = 0; j < maxbits; j++)
		{
			dp[t][j][0][0] = 0;
			dp[t][j][0][1] = 0;
			dp[t][j][1][0] = 0;
			dp[t][j][1][1] = 0;
		}

		char nowc = M[i / W][i % W];
		char nxtc = M[(i + 1) / W][(i + 1) % W];

		for (int j = 0; j < maxbits; j++)
		{
			int sum0 = dp[s][j][0][0] + dp[s][j][1][0];
			int sum1 = dp[s][j][0][1] + dp[s][j][1][1];

			if (nxtc == 'J' || nxtc == '?')
			{
				dp[t][conv[nxts[j]]][0][0] += sum0;
				dp[t][conv[nxts[j]]][0][1] += sum1;
			}

			if (nxtc == 'O' || nxtc == '?')
			{
				if ((nowc == 'J' || nowc == '?') && i % W != W - 1)
				{
					dp[t][conv[nxts[j] + 1]][1][0] += dp[s][j][0][0];
					dp[t][conv[nxts[j] + 1]][1][1] += dp[s][j][0][1];

					dp[t][conv[nxts[j] + 1]][1][0] %= 100000;
					dp[t][conv[nxts[j] + 1]][1][1] %= 100000;

					dp[t][conv[nxts[j]]][1][0] += dp[s][j][1][0];
					dp[t][conv[nxts[j]]][1][1] += dp[s][j][1][1];
				}
				else
				{
					dp[t][conv[nxts[j]]][1][0] += sum0;
					dp[t][conv[nxts[j]]][1][1] += sum1;
				}
			}

			if (nxtc == 'I' || nxtc == '?')
			{
				if (bits[j] & (1 << (W - 2)))
				{
					dp[t][conv[nxts[j]]][1][1] += sum0;
				}
				else
				{
					dp[t][conv[nxts[j]]][1][0] += sum0;
				}

				dp[t][conv[nxts[j]]][1][1] += sum1;
			}

			dp[t][conv[nxts[j]]][0][0] %= 100000;
			dp[t][conv[nxts[j]]][0][1] %= 100000;
			dp[t][conv[nxts[j]]][1][0] %= 100000;
			dp[t][conv[nxts[j]]][1][1] %= 100000;
		}
	}

	int ret = 0;

	int last = (H * W + 1) % 2;

	for (int i = 0; i < maxbits; i++)
	{
		ret += dp[last][i][0][1];
		ret += dp[last][i][1][1];

		ret %= 100000;
	}

	printf("%d\n", ret);

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:54: error: expected ';' before ')' token
   40 |                 nxts[i] = (bits[i] << 1) & maxbit - 1);
      |                                                      ^
      |                                                      ;
Language: C++

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

#define MOD 100000
int M, N;
char S[20][20];
int dp[400][1<<20][3];
int bf[20][20];
char T[3] = {'J', 'O', 'I'};

int f(char c) {
  if (c == 'J') return 0;
  if (c == 'O') return 1;
  if (c == 'I') return 2;
  exit(1);
}

int main() {
  cin >> M >> N;
  for (int i=0; i<M; i++) {
    for (int j=0; j<N; j++) {
      cin >> S[i][j];
    }
  }

  for (int k=0; k<3; k++) {
    if (S[0][0] != '?' && f(S[0][0]) != k) continue;
    dp[0][0][k] = 1;
  }

  for (int y=0; y<M; y++) {
    for (int x=0; x<N; x++) {
      int p = y*N + x;
      if (p == 0) continue;
      for (int s=0; s<(1<<N); s++) {
        for (int k=0; k<3; k++) {
          for (int g=0; g<3; g++) {
            if (S[y][x] != '?' && f(S[y][x]) != g) continue;

            int ns = s >> 1;
            if (x != 0 && k == 0 && g == 1) ns |= 1<<(N-1);

            if (x != N-1 && (ns & 1) != 0 && g == 2) {
              bf[y][x] += dp[p-1][s][k];
              bf[y][x] %= MOD;
              continue;
            }
            dp[p][ns][g] += dp[p-1][s][k];
            dp[p][ns][g] %= MOD;
          }
        }
      }
    }
  }

  long long ans = 0;
  long long t = 1;
  for (int y=M-1; y>=0; y--) {
    for (int x=N-1; x>=0; x--) {
      ans = (ans + (t*(long long)bf[y][x] % MOD)) % MOD;
      if (S[y][x] == '?') t = (t * 3) % MOD;
    }
  }

  cout << ans << "\n";
  return 0;
}

Compiler output:
/tmp/ccjYxTBe.o: in function `main':
a.cc:(.text+0x29c): relocation truncated to fit: R_X86_64_PC32 against symbol `bf' defined in .bss section in /tmp/ccjYxTBe.o
a.cc:(.text+0x311): relocation truncated to fit: R_X86_64_PC32 against symbol `bf' defined in .bss section in /tmp/ccjYxTBe.o
a.cc:(.text+0x340): relocation truncated to fit: R_X86_64_PC32 against symbol `bf' defined in .bss section in /tmp/ccjYxTBe.o
a.cc:(.text+0x391): relocation truncated to fit: R_X86_64_PC32 against symbol `bf' defined in .bss section in /tmp/ccjYxTBe.o
a.cc:(.text+0x5c2): relocation truncated to fit: R_X86_64_PC32 against symbol `bf' defined in .bss section in /tmp/ccjYxTBe.o
collect2: error: ld returned 1 exit status
Language: C++

// JOI 2010-2011 予選6
#include<iostream>

const int mod = 100000;

int M, N;
char flag[20][20];
// dp[crt or nxt][直前N文字において隣接する2列の文字がJOか][直前の1つがJか(次にJOが来るか判定するため)]
int dp[2][1 << 20][2];
char JOI[4] = "JOI";

int main()
{
	std::cin >> M >> N;
	for( int i = 0; i != M; ++i )
		for( int j = 0; j != N; ++j )
			std::cin >> flag[i][j];

	dp[0][0][0] = 1;

	int crt = 0, nxt = 1;

	for( int i = 0; i != M; ++i )
	{
		for( int j = 0; j != N; ++j )
		{
			memset( dp[nxt], 0, sizeof( dp[nxt] ) );

			for( int bit = 0; bit != 1 << N; ++bit )
			{
				for( int f = 0; f != 2; ++f )
				{
					if( dp[crt][bit][f] )
					{
						for( int k = 0; k != 3; ++k )
						{
							if( flag[i][j] != '?' && flag[i][j] != JOI[k] )
								continue;
							if( bit >> j & 1 && JOI[k] == 'I' )
								continue;

							int nbit = bit & ~( 1 << j ), nf = JOI[k] == 'J';
							if( f && JOI[k] == 'O' )
								nbit |= 1  << ( j - 1 );

							dp[nxt][nbit][nf] += dp[crt][bit][f];
							if( dp[nxt][nbit][nf] >= mod )
								dp[nxt][nbit][nf] -= mod;
						}
					}
				}
			}

			std::swap( crt, nxt );
		}

		for( int bit = 0; bit != 1 << N; ++bit )
		{
			dp[crt][bit][0] += dp[crt][bit][1];
			if( dp[crt][bit][0] >= mod )
				dp[crt][bit][0] -= mod;

			dp[crt][bit][1] = 0;
		}
	}

	int ans = 1;
	for( int i = 0; i != M; ++i )
		for( int j = 0; j != N; ++j )
			if( flag[i][j] == '?' )
				ans = ( ans * 3 ) % mod;

	for( int i = 0; i != 1 << N; ++i )
		ans = ( ans + mod - dp[crt][i][0] ) % mod;

	std::cout << ans << std::endl;

	return 0;
}

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

// JOI 2010-2011 予選6
#include<algorithm>
#include<iostream>

const int mod = 100000;

int M, N;
char flag[20][20];
// dp[crt or nxt][直前N文字において隣接する2列の文字がJOか][直前の1つがJか(次にJOが来るか判定するため)]
int dp[2][1 << 20][2];
char JOI[4] = "JOI";

int main()
{
	std::cin >> M >> N;
	for( int i = 0; i != M; ++i )
		for( int j = 0; j != N; ++j )
			std::cin >> flag[i][j];

	dp[0][0][0] = 1;

	int crt = 0, nxt = 1;

	for( int i = 0; i != M; ++i )
	{
		for( int j = 0; j != N; ++j )
		{
			memset( dp[nxt], 0, sizeof( dp[nxt] ) );

			for( int bit = 0; bit != 1 << N; ++bit )
			{
				for( int f = 0; f != 2; ++f )
				{
					if( dp[crt][bit][f] )
					{
						for( int k = 0; k != 3; ++k )
						{
							if( flag[i][j] != '?' && flag[i][j] != JOI[k] )
								continue;
							if( bit >> j & 1 && JOI[k] == 'I' )
								continue;

							int nbit = bit & ~( 1 << j ), nf = JOI[k] == 'J';
							if( f && JOI[k] == 'O' )
								nbit |= 1  << ( j - 1 );

							dp[nxt][nbit][nf] += dp[crt][bit][f];
							if( dp[nxt][nbit][nf] >= mod )
								dp[nxt][nbit][nf] -= mod;
						}
					}
				}
			}

			std::swap( crt, nxt );
		}

		for( int bit = 0; bit != 1 << N; ++bit )
		{
			dp[crt][bit][0] += dp[crt][bit][1];
			if( dp[crt][bit][0] >= mod )
				dp[crt][bit][0] -= mod;

			dp[crt][bit][1] = 0;
		}
	}

	int ans = 1;
	for( int i = 0; i != M; ++i )
		for( int j = 0; j != N; ++j )
			if( flag[i][j] == '?' )
				ans = ( ans * 3 ) % mod;

	for( int i = 0; i != 1 << N; ++i )
		ans = ( ans + mod - dp[crt][i][0] ) % mod;

	std::cout << ans << std::endl;

	return 0;
}

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

#include <bits/stdc++.h>

char T[1005];
int sum[3][1005][1005];

int main() {
	int m, n, k; scanf("%d%d%d", &m, &n, &k);
	for (int i = 0; i < m; i++) {
		scanf("%s", T);
		for (int j = 0; j < n; j++) {
			if (T[j] == 'J')sum[0][i][j]++;
			else if (T[j] == 'O')sum[1][i][j]++;
			else sum[2][i][j]++;
		}
	}
	for (int i = 0; i < 3; i++) {
		for (int j = 1; j < m; j++) {
			for (int t = 0; t < n; t++) {
				sum[i][j][t] += sum[i][j - 1][t];
			}
		}
	}
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < m; j++) {
			for (int t = 1; t < n; t++) {
				sum[i][j][t] += sum[i][j][t - 1];
			}
		}
	}
	for (int i = 0; i < k; i++) {
		int a, b, c, d; scanf("%d%d%d%d", &a, &b, &c, &d);
		a--; b--; c--; d--;
		int ans[3];
		for (int j = 0; j < 3; j++)ans[j] = sum[j][c][d] - sum[j][c][b - 1] - sum[j][a - 1][d] + sum[j][a - 1][b - 1];
		printf("%d %d %d\n", ans[0], ans[1], ans[2]);
	}
	return 0;
}

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

#include<iostream>
#include<string>
using namespace std;
int J[1200][1200], O[1200][1200], I[1200][1200];
int H, W, Q; string S;
int main() {
	cin >> H >> W >> Q;
	for (int i = 1; i <= H; i++) {
		cin >> S;
		for (int j = 0; j < S.size(); j++) {
			if (S[j] == 'J')J[i][j + 1]++;
			if (S[j] == 'O')O[i][j + 1]++;
			if (S[j] == 'I')I[i][j + 1]++;
		}
	}
	for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++)J[i][j] += J[i - 1][j]; }
	for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++)J[i][j] += J[i][j - 1]; }
	for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++)O[i][j] += O[i - 1][j]; }
	for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++)O[i][j] += O[i][j - 1]; }
	for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++)I[i][j] += I[i - 1][j]; }
	for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++)I[i][j] += I[i][j - 1]; }
	for (int i = 0; i < Q; i++) {
		int ax, ay, bx, by; cin >> ax >> ay >> bx >> by; ax--; ay--;
		int pos1 = J[ax][ay] + J[bx][by] - J[ax][by] - J[ay][bx];
		int pos2 = O[ax][ay] + O[bx][by] - O[ax][by] - O[ay][bx];
		int pos3 = I[ax][ay] + I[bx][by] - I[ax][by] - I[bx][ay];
		cout << pos1 << ' ' << pos2 << ' ' << pos3 << endl;
	}
	return 0;
}

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