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

//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60) 
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

signed main(void)
{
    while(true) {
        int n, w, d;
        cin >> n >> w >> d;
        if(!n && !w && !d) break;

        int cnt = 1;
        PII a[105];
        a[1] = {w, d};
        REP(i, n) {
            int p, s;
            cin >> p >> s;
            
            //cout << a[p].first << " " << a[p].second << endl;
            s %= 2*(a[p].first+a[p].second);
            PII t1, t2;
            if(s < a[p].first) {
                t1 = {s, a[p].second};
                t2 = {a[p].first-s, a[p].second};
                //cout << "a" << endl;
            } else if(s < a[p].first+a[p].second) {
                s -= a[p].first;
                t1 = {a[p].first, s};
                t2 = {a[p].first, a[p].second-s};
               // cout << "b" << endl;
 

Compiler output:
a.cc: In function 'int main()':
a.cc:48:50: error: expected '}' at end of input
   48 |                 t2 = {a[p].first, a[p].second-s};
      |                                                  ^
a.cc:45:51: note: to match this '{'
   45 |             } else if(s < a[p].first+a[p].second) {
      |                                                   ^
a.cc:48:50: error: expected '}' at end of input
   48 |                 t2 = {a[p].first, a[p].second-s};
      |                                                  ^
a.cc:34:19: note: to match this '{'
   34 |         REP(i, n) {
      |                   ^
a.cc:48:50: error: expected '}' at end of input
   48 |                 t2 = {a[p].first, a[p].second-s};
      |                                                  ^
a.cc:26:17: note: to match this '{'
   26 |     while(true) {
      |                 ^
a.cc:48:50: error: expected '}' at end of input
   48 |                 t2 = {a[p].first, a[p].second-s};
      |                                                  ^
a.cc:25:1: note: to match this '{'
   25 | {
      | ^
Language: C++

#include <stdio.h>
#include <vector>

using namespace std;

struct piece{
	int w;
	int d;
	piece(){}
	piece(int w0, int d0){
		w =w0, d = d0;
	}
	int area(){
		return w * d;
	}
};

int main(void)
{
	int n, w, d;
	int p[100], s[100];
	
	vector<piece> cake;
	vector<int> area_array;
	
	while(1){
		cake.clear();
		
		scanf("%d %d %d", &n, &w, &d);
		if(n == 0 && w == 0 && d == 0) break;
		cake.push_back( piece(w, d) );
		
		for(int i = 0; i < n; i++) scanf("%d %d", &p[i], &s[i]);
		
		
		int pos, pw, pd;
		piece pc1, pc2;
		
		for(int i = 0; i < n; i++){
			pw = cake[p[i]-1].w, pd = cake[p[i]-1].d;
			pos = s[i] % (pw + pd);
			if(pos <= pw){
				pc1 = piece(pos, pd);
				pc2 = piece(pw - pos, pd);
			}else{
				pc1 = piece(pw, pos - pw);
				pc2 = piece(pw, (pw + pd) - pos);
			}
			if(pc1.area() < pc2.area()){
				cake.push_back(pc1);
				cake.push_back(pc2);
			}else{
				cake.push_back(pc2);
				cake.push_back(pc1);
			}
			cake.erase(cake.begin() + (p[i]-1));
		}
		
		area_array.clear();
		for(int i = 0; i < (int)cake.size(); i++) area_array.push_back( cake[i].area() );
		sort(area_array.begin(), area_array.end());
		
		for(int i = 0; i < (int)area_array.size(); i++){
			printf("%d ", area_array[i]);
		}
		printf("\n");
	}
	
	return 0;
}

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

#include <iostream>
#include <vector>
#include <array>

struct Square {
	int width, depth;
	bool operator<(const Square& rhs) const {
		return width * depth < rhs.width * rhs.depth;
	}
};

int main() {
	int n, w, d;
	Square s;
	while (std::cin >> n >> w >> d && (n || w || d)) {
		std::vector<Square> squares; //???????????????????????????????????\???????????????
		squares.push_back(s);
		squares.back().width = w; squares.back().depth = d;

		for (int i = 0; i < n; i++) {
			int no, pos;
			std::cin >> no >> pos;
			no--;
			auto square = squares[no];
			pos %= (squares[no].width * 2 + squares[no].depth * 2);

			//??????
			int direction = 0; //0?¨??????? 1???
			int cutPos = 0; //??????????????????????????????????????????
			if (pos <= squares[no].width) {
				direction = 1;
				cutPos = pos;
			}
			else if (pos <= squares[no].width + squares[no].depth) {
				direction = 0;
				cutPos = pos - squares[no].width;
			}
			else if (pos <= squares[no].width * 2 + squares[no].depth) {
				direction = 1;
				cutPos = squares[no].width - (pos - (squares[no].depth + squares[no].width));
			}
			else {
				direction = 0;
				cutPos = squares[no].depth - (pos - (squares[no].width * 2 + squares[no].depth));
			}

			squares.erase(squares.begin() + no);

			Square newSquare[2] = { square, square };
			switch (direction)
			{
			case 0: //?¨???????
				newSquare[0].depth = cutPos;
				newSquare[1].depth = square.depth - cutPos;
				break;
			case 1: //???
				newSquare[0].width = cutPos;
				newSquare[1].width = square.width - cutPos;
				break;
			default:
				break;
			}

			//?°??????????????????????
			if (newSquare[0].depth * newSquare[0].width < newSquare[1].depth * newSquare[1].width) {
				squares.push_back(newSquare[0]);
				squares.push_back(newSquare[1]);
			}
			else {
				squares.push_back(newSquare[1]);
				squares.push_back(newSquare[0]);
			}
		}

		//?°??????????????????????
		std::sort(squares.begin(), squares.end());

		for (int i = 0; i < squares.size(); i++) {
			std::cout << squares[i].width * squares[i].depth;
			if (i == squares.size() - 1) {
				std::cout << std::endl;
			}
			else {
				std::cout << " ";
			}
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:76:22: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   76 |                 std::sort(squares.begin(), squares.end());
      |                      ^~~~
      |                      qsort
Language: C++

#include<iostream>
#include<vector>

using namespace std;

int ps[100][2];

int main(){
    while(1){
        int n, W, D;
        cin >> n >> W >> D;

        if(W==0){
            break;
        }

        for(int i=0; i<n; i++){
            int p, s;
            cin >> p >> s;
            ps[i][0] = p;
            ps[i][1] = s;
        }

        vector<pair<int, int> > vec;
        pair<int, int> init = make_pair(W, D);
        vec.push_back(init);
        for(int i=0; i<n; i++){
            int p = ps[i][0];
            int s = ps[i][1];

            pair<int, int> wd = vec[p-1];
            vec.erase(vec.begin() + p - 1);
            int w = wd.first;
            int d = wd.second;

            int peri = w+d;
            s = s % peri;

            pair<int, int> wd1;
            pair<int, int> wd2;
            if(s < w){
                wd1.first = s;
                wd2.first = w - s;
                wd1.second = d;
                wd2.second = d;
            } else {
                wd1.first = w;
                wd2.first = w;
                wd1.second = s - w;
                wd2.second = d - wd1.second;
            }

            if(wd1.first * wd1.second > wd2.first * wd2.second){
                vec.push_back(wd1);
                vec.push_back(wd2);
            } else {
                vec.push_back(wd1);
                vec.push_back(wd2);
            }

            cout << w << " " << d << endl;
            cout << d << endl;
            cout << wd1.first << " " << wd1.second << endl;
            cout << wd2.first << " " << wd2.second << endl;
            cout << endl;
        }

        vector<int> output(vec.size());
        for(int i=0; i<vec.size(); i++){
            pair<int, int> wd = vec[i];
            int w = wd.first;
            int d = wd.second;
            output[i] = w*d;
        }

        sort(output.begin(), output.end());
        for(int i=0; i<vec.size(); i++){
            if(i != 0){
                cout << " ";
            }
            cout << output[i];
        }
        cout << endl;
    }
}

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

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

struct cake{
    int w,h;
    cake(){
        w = 0;
        h = 0;
    }
    cake(int w, int h){
        this->w = w;
        this->h = h;
    }
};

int main() {

    while(true){

        int n,w,d;

        cin >> n >> w >> d;

        if(n == w && w == d && d == 0){
            break;
        }

        cake start(w,d);

        list<cake> lc;

        lc.push_back(start);

        for(int loop=0; loop<n; loop++){

            int p,s;

            cin >> p >> s;

            list<cake>::iterator cut = lc.begin();

            for(int i=0; i<p-1; i++){
                cut++;
            }

            int l = cut->w * 2 + cut->h * 2;

            int sm = s % l;

            cake first,second;

            if((sm < cut->w)){
                int cw1 = sm;
                int cw2 = cut->w-sm;
                first.w = cw1;
                second.w = cw2;
                first.h = second.h = cut->h;
                if(first.w * first.h > second.w * second.h){
                    swap(first,second);
                }
                lc.push_back(first);
                lc.push_back(second);
            }
            else if(sm > (cut->w + cut->h) && sm < (cut->w*2 + cut->h)){ //垂直に切る
                sm -= cut->w + cut->h;
                int cw1 = sm;
                int cw2 = cut->w-sm;
                first.w = cw1;
                second.w = cw2;
                first.h = second.h = cut->h;
                if(first.w * first.h > second.w * second.h){
                    swap(first,second);
                }
                lc.push_back(first);
                lc.push_back(second);
            }
            else if(sm > cut->w && sm < (cut->w + cut->h)){
                sm -= cut->w;
                int ch1 = sm;
                int ch2 = cut->h-sm;
                first.h = ch1;
                second.h = ch2;
                first.w = second.w = cut->w;
                if(first.w * first.h > second.w * second.h){
                    swap(first,second);
                }
                lc.push_back(first);
                lc.push_back(second);
            }
            else{
                sm -= cut->w * 2 + cut->h;
                int ch1 = sm;
                int ch2 = cut->h-sm;
                first.h = ch1;
                second.h = ch2;
                first.w = second.w = cut->w;
                if(first.w * first.h > second.w * second.h){
                    swap(first,second);
                }
                lc.push_back(first);
                lc.push_back(second);
            }

            lc.erase(cut);

        }

        priority_queue<int> q;

        for(list<cake>::iterator itr = lc.begin(); itr != lc.end(); itr++){
            q.push(-(c.h * c.w));
        }

        int siz = q.size();

        for(int i=0; i<siz - 1; i++){
            cout << -q.top() << " ";
            q.pop();
        }

        cout << -q.top() << endl;

    }

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:111:22: error: 'c' was not declared in this scope
  111 |             q.push(-(c.h * c.w));
      |                      ^
Language: C++

#include<vector>
#include<iostream>

using namespace std;

class Cake;

vector<Cake> pieces;

class Cake {
public:
  int w;
  int d;

  Cake(int w, int d) {
    this->w = w;
    this->d = d;
  }

  void cut(int s) {
    int t = s%(w+d);
    int a, b;
    if(t<w) {
      // vertical
      if(t<w-t) {
	a = t;
	b = w-t;
      } else {
	a = w-t;
	b = t;
      }
      pieces.push_back(Cake(a, d));
      pieces.push_back(Cake(b, d));
    }
    else {
      // horizontal
      t -= w;
      if(t<d-t) {
	a = t;
	b = d-t;
      } else {
	a = d-t;
	b = t;
      }
      pieces.push_back(Cake(w, a));
      pieces.push_back(Cake(w, b));
    }
  }
};

bool area(const Cake &a, const Cake &b) {
  return a.w*a.d < b.w*b.d;
}

int main() {
  while(1) {
    int n, w, d;
    cin >> n;
    cin >> w;
    cin >> d;

    if(n==0 && w==0 && d==0) break;

    pieces.clear();
    pieces.push_back(Cake(w, d));

    for(int i=0; i<n; i++) {
      int p, s;
      cin >> p;
      cin >> s;
      // p Í 1` ÈÌÅ
      p-=1;
      vector<Cake>::iterator it = pieces.begin()+p;
      Cake cake = pieces.at(p);
      pieces.erase(it);
      cake.cut(s);
    }

    // sort
    sort(pieces.begin(), pieces.end(), area);

    for(int i=0; i<pieces.size(); i++) {
      cout << (pieces.at(i).w * pieces.at(i).d);
      cout << ' ';
    }
    cout << "\n";
  }
}

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

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

#define hi(x) ((x)>>16)
#define lo(x) ((x)&0xffff)

struct comp{
    bool operator()(const unsigned a, const unsigned b){return hi(a)*lo(a) < hi(b)*lo(b);}
};

int main(){
	int n,w,d;
	for(;scanf("%d%d%d",&n,&w,&d),n;){
	vector<unsigned> v;
	v.push_back((w<<16)+d);
	while(n--){
		int p, s, state=0;
		scanf("%d %d", &p, &s);
		p--;
		s%=hi(v[p])+lo(v[p]);
		
		unsigned x=hi(v[p]), y=lo(v[p]), _x=0, _y=0;
		while(s--){
			switch(state){
				case 0:{
					_x++;
					if(_x==x)state=1;
					break;
				}
				case 1:{
					_y++;
					break;
				}
			}
		}
		unsigned x1, x2, y1, y2;
		switch(state){
			case 0:{
				x1=_x;x2=x-_x;
				y1=y2=y;
				break;
			}
			case 1:{
				x1=x2=x;
				y1=_y;y2=y-_y;
				break;
			}
		}
		
		v.erase(v.begin()+p);
		if(x1*y1>x2*y2){
			v.push_back((x2<<16)+y2);
			v.push_back((x1<<16)+y1);
		}else{
			v.push_back((x1<<16)+y1);
			v.push_back((x2<<16)+y2);
		}
	}
	
	sort(v.begin(), v.end(), comp());
	while(v.size()){
		printf("%d", hi(v[0])*lo(v[0]));
		v.erase(v.begin());
		if(v.size())printf(" ");
	}
	printf("\n");
}
	}
}

Compiler output:
a.cc:5:1: warning: 'typedef' was ignored in this declaration
    5 | typedef
      | ^~~~~~~
a.cc:72:1: error: expected declaration before '}' token
   72 | }
      | ^
Language: C++

#include<iostream>
#include<cmath>
#include<set>
#include<vector>
#include<map>
using namespace std;
#define P pair<int, int>

		vector<P> vec;

void loop(int p, int s);
void disp();

int main(){
	int n, w, d;
	while(cin >>n >>w >>d){
		vec.clear();
		if(n == 0 && w == 0 && d == 0) break;
		vec.push_back( make_pair(w, d) );
		for(int i = 0; i < n; i++){
			int p, s;
			cin >>p >>s;
			loop(p, s);
			//cout<< i << " " << vec.size() << endl;
		}
		vector<int> se;
		for(int i = 0; i < vec.size(); i++) se.push_back(vec[i].first * vec[i].second);
		sort(se.begin(), se.end());
#ifdef DEBUG
		cout << "SIZE = " << se.size() << endl;
#endif		
		vector<int>::iterator it = se.begin();
		cout << (*it);
		for( it++ ; it != se.end(); it++) cout <<" " <<(*it);
		cout << endl;
		
	}
}

void loop(int p, int s){
	P nowp = vec[p - 1];
//	vector<P>::iterator it = vec.begin();
//	for(int i = 0; i < (p - 1); i++) it++;
	vec.erase(vec.begin() + p - 1);
	int x1, y1, x2, y2;
	while(s > nowp.first + nowp.second) s -= (nowp.first + nowp.second);
#ifdef DEBUG
	cout <<"s = " <<s <<endl;
#endif
	if(s > 0 && s < nowp.first){
#ifdef DEBUG
		cout <<"!" <<endl;
#endif
		x1 = nowp.first - s; y1 = nowp.second;
		x2 = s; y2 = nowp.second;
	} else{
#ifdef DEBUG
		cout <<"!!" <<endl;
#endif
		x1 = nowp.first; y1 = s - nowp.first;
		x2 = nowp.first; y2 = nowp.first + nowp.second - s;
	}
	if((x1 * y1) > (x2 * y2)){
		vec.push_back( make_pair(x2, y2) );
		vec.push_back( make_pair(x1, y1) );
	} else{
		vec.push_back( make_pair(x1, y1) );
		vec.push_back( make_pair(x2, y2) );
	}
#ifdef DEBUG
	disp();
#endif
}

void disp(){
	cout <<endl;
	for(int i = 0; i < vec.size(); i++) cout <<vec[i].first <<"," <<vec[i].second <<" || ";
	cout <<endl;
}

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

#include<iostream>
#include<vector>
#include<cassert>

using namespace std;
struct Piece{
  int w,h;
  Piece(){}
  Piece(int w, int h):w(w),h(h){}
  int getArea(){return w*h;}
  bool operator < (const Piece& p) const{return w*h < p.w*p.h;}
  bool operator > (const Piece& p) const{return w*h > p.w*p.h;}
};
typedef vector<Piece>::iterator ITE;

int n,w,d;
vector<Piece> V;


void init(){
  V.clear();
  V.push_back(Piece(w,d));
}

void cut(int p, int s){

  Piece now = V[p-1];
  V.erase((ITE)&V[p-1]);
  
  int dx[] = {1,0,-1,0};
  int dy[] = {0,1,0,-1};
  int d = 0;
  int cx = 0,cy = 0;
  while(1){
    if(d%2){
      // y-axis
      if(s > now.h){
	s -= now.h;
	cy = now.h;
      }else{
	cy = s;
	s = 0;
	break;
      }
    }else{
      // x-axis
      if(s > now.w){
	s -= now.w;
	cx = now.w;
      }else{
	cx = s;
	s = 0;
	break;
      }
    }
    d = (d+1)%4;
  }
  
  Piece a,b;
  if(d%2){
    // cut horizonal
    a = Piece(now.w,cy);
    b = Piece(now.w,now.h-cy);
  }else{
    // cut vertical
    a = Piece(cx,now.h);
    b = Piece(now.w-cx,now.h);    
  }
  
  if(a > b) swap(a,b);
  
  V.push_back(a);
  V.push_back(b);

}

void solve(){
  
  for(int i = 0; i < n; i++){
    int p,s;
    cin >> p >> s;
    cut(p,s);
  }
  sort(V.begin(),V.end());
  for(int i = 0; i < V.size(); i++){
    if(i) cout << " ";
    cout << V[i].getArea();
  }
  cout << endl;
}

int main(){

  while(cin >> n >> w >> d && n+w+d){
    init();
    solve();
  }
  return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:84:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   84 |   sort(V.begin(),V.end());
      |   ^~~~
      |   short
Language: C++

#include<cstdio>
#include<cstdlib>
#include<queue>
#include<algorithm>
using namespace std;
typedef struct D
{
	int ry,rx,ly,lx,t,s;//r l y x  0-nextR 1-nextL
	bool operator <(const D& a)const{return a.t<t;};
}D;

int W,H,F[63][33][2],ans,mv[9][2]={{-2,1},{-1,1},{-1,2},{0,1},{0,2},{0,3},{1,1},{1,2},{2,1}};
char C[63][33];

bool check(int y,int x)
{
	return 0<=y&&y<H&&0<=x&&x<W?true:false;
}

int cost(int y,int x)
{
	if('0'<=C[y][x]&&C[y][x]<='9')return C[y][x]-'0';
	return 0;
}

int main()
{
	for(;scanf("%d%d\n",&W,&H),W+H;)
	{
		memset(F,0x7f,sizeof(F));
		ans=1000000000;
		for(int i=0;i<H;i++)
			for(int j=0;j<W;j++)
				scanf("%c%*c",&C[i][j]);
		priority_queue<D>Q;
		for(int i=0;i<W;i++)
		{
			D tmp={H-1,0,H-1,0,0,0};
			if(C[H-1][i]=='S')
			{
				F[H-1][i][0]=F[H-1][i][1]=0;
				tmp.lx=tmp.rx=i;
				Q.push(tmp);
				tmp.s=1;
				Q.push(tmp);
			}
		}
		for(;!Q.empty();)
		{
			D t=Q.top();Q.pop();
			if(C[t.ly][t.lx]=='T'||C[t.ry][t.rx]=='T')
			{
				ans=min(ans,t.t);
				continue;
			}
			if(t.s==0)//move right leg
			{
				for(int i=0;i<9;i++)
				{
					int nry=t.ly+mv[i][0],nrx=t.lx+mv[i][1];
					if(check(nry,nrx)&&C[nry][nrx]!='X'&&F[nry][nrx][t.s]>t.t+cost(nry,nrx))
					{
						F[nry][nrx][t.s]=t.t+cost(nry,nrx);
						D ins={nry,nrx,t.ly,t.lx,t.t+cost(nry,nrx),1};
						Q.push(ins);
					}
				}
			}
			else
			{
				for(int i=0;i<9;i++)
				{
					int nly=t.ry+mv[i][0],nlx=t.rx-mv[i][1];
					if(check(nly,nlx)&&C[nly][nlx]!='X'&&F[nly][nlx][t.s]>t.t+cost(nly,nlx))
					{
						F[nly][nlx][t.s]=t.t+cost(nly,nlx);
						D ins={t.ry,t.rx,nly,nlx,t.t+cost(nly,nlx),0};
						Q.push(ins);
					}
				}
			}
		}
		printf("%d\n",ans==1000000000?-1:ans);
	}
}

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

#include <bits/stdc++.h>
using namespace std;
#define PB push_back
const int dy[] = { 1,  1,  1,  1,  1,  2,  2,  2,  3};
const int dx[] = {-2, -1,  0,  1,  2, -1,  0,  1,  0};
const int INF = 1001001001;
const int K = 3;
typedef pair<int, int> P;
struct STATE
{
	int x, y, a, d;
	bool operator <(const STATE &t) const{
		return d > t.d;
	}
};

char grid[256][256];
int d[256][256][2];
void init();

int main()
{
	int w, h;
	while (scanf("%d %d", &w, &h), w + h){
		init();
		w += K; h += K;
		
		vector<P> start;
		for (int i = K; i < h; i++){
			for (int j = K; j < w; j++){
				scanf(" %c", &grid[i][j]);
				if (grid[i][j] == 'S'){
					start.PB(P(i, j));
					grid[i][j] = 127;
				}
				else if (grid[i][j] == 'T'){
					grid[i][j] = 0;
				}
				else if (grid[i][j] >= '1' && grid[i][j] <= '9'){
					grid[i][j] -= '0';
				}
			}
		}
		
		int res = INF;
		for (int i = 0; i < start.size(); i++){
			priority_queue<STATE> que;
			que.push({start[i].first, start[i].second, 1, 0});
			que.push({start[i].first, start[i].second, -1, 0});
		}
		for (; que.size(); que.pop()){
			STATE st = que.top();
			if (d[st.x][st.y][st.a == 1] <= st.d) continue;
			d[st.x][st.y][st.a == 1] = st.d;
			if (st.d >= res) continue;
			if (grid[st.x][st.y] == 0){
				res = st.d;
				break;
			}
			
			//cout << st.x << " " << st.y << endl;
			
			for (int dir = 0; dir < 9; dir++){
				int tx = st.x + dx[dir] * st.a;
				int ty = st.y + dy[dir] * st.a;
				int ta = -st.a;
				int td = st.d + grid[tx][ty];
				if (grid[tx][ty] == 'X') continue;
				que.push({tx, ty, -st.a, td});
			}
		}
		
		if (res != INF) cout << res << endl;
		else cout << "-1" << endl;
	}
	
	return 0;
}

void init()
{
	memset(grid, 'X', sizeof(grid));
	for (int i = 0; i < 256; i++){
		for (int j = 0; j < 256; j++){
			for (int k = 0; k < 2; k++){
				d[i][j][k] = INF;
			}
		}
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:24: error: 'que' was not declared in this scope
   51 |                 for (; que.size(); que.pop()){
      |                        ^~~
Language: C++

#include <iostream>
#include <algorithm>
#include <functional>
#include <queue>
#include <tuple>

using namespace std;

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

char s[100][100];
int d[100][100][2];

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

const int INF = 1e9;

typedef tuple<int, int, int> T;

bool cheak(int x, int y, int mx, int my){
	return x >= 0 && y >= 0 && x < mx && y < my;
}

int main(){

	int w, h;

	while (cin >> w >> h && w){

		memset(s, 0, sizeof s);

		rep(i, 100)rep(j, 100)rep(k, 2)d[i][j][k] = INF;

		queue<T> q;
		rep(y, h)rep(x, w){
			cin >> s[y][x];
			if (s[y][x] == 'S'){
				q.push(T(y, x, 0));
				q.push(T(y, x, 1));
				d[y][x][0] = 0;
				d[y][x][1] = 0;
			}
		}

		while (q.size()){
			int y = get<0>(q.front());
			int x = get<1>(q.front());
			int r = get<2>(q.front());
			q.pop();

			rep(i, 9){
				int tx = x + dx[r][i];
				int ty = y + dy[i];

				int tmp = 0;
				if (s[ty][tx] >= '0' && s[ty][tx] <= '9')tmp = s[ty][tx] - '0';

				if (cheak(x, y, w, h) && (d[ty][tx][1-r] > d[y][x][r] + tmp)
					&& (s[ty][tx] != 'X')){

					d[ty][tx][1-r] = d[y][x][r] + tmp;
					q.push(T(ty, tx, 1 - r));
				}
			}
		}

		int ans = INF;
		rep(y, h)rep(x, w){
			if (s[y][x] == 'T'){
				ans = min(ans, d[y][x][0]);
				ans = min(ans, d[y][x][1]);
			}
		}

		if (ans == INF)ans = -1;
		cout << ans << endl;
	}

	return 0;
}

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

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> P;
typedef pair<P, P> PP;

int w, h;
char s[66][33];

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

int mincost[2][66][33];

const int inf = 1 << 25;

int dijkstra()
{
  for(int i = 0; i < 66; i++) {
    for(int j = 0; j < 33 j++) {
      mincost[0][i][j] = inf;
      mincost[1][i][j] = inf;
    }
  }
  priority_queue<PP, vector<PP>, greater<PP> > que;  
  for(int i = 0; i < w; i++) {
    if(s[h-1][i] == 'S') {
      que.push(PP(P(0, 0), P(i, h-1))); mincost[0][h-1][i] = 0;
      que.push(PP(P(0, 1), P(i, h-1))); mincost[1][h-1][i] = 0;
    }
  }
  while(!que.empty()) {
    PP p = que.top(); que.pop();
    int c = p.first.first, lr = p.first.second;
    int x = p.second.first, y = p.second.second;
    if(s[y][x] == 'T') return c;
    if(mincost[lr][y][x] < c) continue;
    for(int i = 0; i < 9; i++) {
      int nx = x + (lr ? dx[i] : -dx[i]), ny = y + dy[i];
      if(0 <= nx && nx < w && 0 <= ny && ny < h && s[ny][nx] != 'X') {
	int d = isdigit(s[ny][nx]) ? s[ny][nx]-'0' : 0;
	if(c + d < mincost[(lr+1)%2][ny][nx]) {
	  mincost[(lr+1)%2][ny][nx] = c + d;
	  que.push(PP(P(c + d, (lr+1)%2), P(nx, ny)));
	}
      }
    }
  }
  return -1;
}

int main()
{
  while(cin >> w >> h, w || h) {
    memset(s, 0, sizeof(s));
    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; j++) cin >> s[i][j];
    }
    cout << dijkstra() << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int dijkstra()':
a.cc:21:26: error: expected ';' before 'j'
   21 |     for(int j = 0; j < 33 j++) {
      |                          ^~
      |                          ;
Language: C++

#include <iostream>
#include <queue>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll MAX = 1LL << 50;

ll h, w;
ll a[30][50];
char b[30][50];
ll minr[30][50];//????????°???????°????
ll minl[30][50];//????????°???????°????
int dx[] = {1, 1, 1, 1, 1, 2, 2, 2, 3};
int dy[] = {2, 1, 0, -1, -2, 1, 0, -1, 0};
queue<P> quer;
queue<P> quel;

void doRight() {
	while (!quel.empty()) {
		P p = quel.front();
		int y = p.second;
		int x = p.first;
		quel.pop();
		for(int i = 0; i < 9; ++i) {
			int yy = y + dy[i];
			int xx = x + dx[i];
			if (!(0 <= yy && yy < h && 0 <= xx && xx < w && b[yy][xx] != 'X')) {
				continue;
			}
			if (minr[yy][xx] > minl[y][x] +a[yy][xx]) {
				minr[yy][xx] = minl[y][x] + a[yy][xx];
				quer.push(make_pair(xx, yy));
			}
		}
	}
}

void doLeft() {
	while (!quer.empty()) {
		P p = quer.front();
		int y = p.second;
		int x = p.first;
		quer.pop();
		for(int i = 0; i < 9; ++i) {
			int yy = y + dy[i];
			int xx = x - dx[i];
			if (!(0 <= yy && yy < h && 0 <= xx && xx < w && b[yy][xx] != 'X')) {
				continue;
			}
			if (minl[yy][xx] > minr[y][x] +a[yy][xx]) {
				minl[yy][xx] = minr[y][x] + a[yy][xx];
				quel.push(make_pair(xx, yy));
			}
		}
	}
}

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

#include <bits/stdc++.h>
using namespace std;
int xv[]={1,1,1,1,1,2,2,2,3},yv[]={2,1,0,-1,-2,1,0,-1,0};

void solve(int w,int h){
    char in;
    bool l;
    int r,c;
    stack<pair<bool,pair<int,int>>> q;
    pair<int,int> n;
    vector<vector<int>> mp=vector<vector<int>>(h+4,vector<int>(w+6,-1));
    vector<vector<vector<int>>> ma(h+4,vector<vector<int>>(w+6,vector<int>(2,INT_MAX/2)));
    set<pair<int,int>> sset,tset;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>in;
            if(in=='X')mp[i+1][j+2]=-1;
            else if(in=='S'){
                mp[i+1][j+2]=0;
                sset.insert(make_pair(i+1,j+2));
            }
            else if(in=='T'){
                mp[i+1][j+2]=0;
                tset.insert(make_pair(i+1,j+2));
            }
            else{
                mp[i+1][j+2]=in-'0';
            }
        }
    }
    for(pair<int,int> x:sset){
        q.push(make_pair(true,make_pair(x.first,x.second)));
        q.push(make_pair(false,make_pair(x.first,x.second)));
        ma[x.first][x.second][0]=0;
        ma[x.first][x.second][1]=0;
    }
    while(!q.empty()){
        l=q.pop().first;n=q.front().second;q.pop();
        for(int i=0;i<9;i++){
            r=n.first+yv[i];
            c=n.second+(l?xv[i]:-1*xv[i]);
            if(mp[r][c]!=-1&&ma[n.first][n.second][!l]+mp[r][c]<ma[r][c][l]){
                ma[r][c][l]=ma[n.first][n.second][!l]+mp[r][c];
                q.push(make_pair(!l,make_pair(r,c)));
            }
        }
    }
    int mini=INT_MAX/2;
    for(pair<int,int> x:tset){
        mini=min(mini,ma[x.first][x.second][0]);
        mini=min(mini,ma[x.first][x.second][1]);
    }
    cout<<(mini!=INT_MAX/2?mini:-1)<<endl;
}

int main(){
    int w,h;
    while(cin>>w>>h,w){
        solve(w,h);
    }
}



Compiler output:
a.cc: In function 'void solve(int, int)':
a.cc:38:16: error: invalid use of 'void'
   38 |         l=q.pop().first;n=q.front().second;q.pop();
      |           ~~~~~^~
a.cc:38:29: error: 'class std::stack<std::pair<bool, std::pair<int, int> > >' has no member named 'front'
   38 |         l=q.pop().first;n=q.front().second;q.pop();
      |                             ^~~~~
Language: C++

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

int W, H;
char board[100][100];
int dist[100][100][2];
const int INF = 1 << 28;

const int LEFT  = 0;
const int RIGHT = 1;
const int dx[][9] = {{0, 0, 0, 1, 1, 2, -1, -1, -2}, {0, 0, 0, 1, 1, 2, -1, -1, -2}};
const int dy[][9] = {{1, 2, 3, 1, 2, 1, 1, 2, 1}, {-1, -2, -3, -1, -2, -1, -1, -2, -1}};

struct Elem {
    int x, y, foot, dist;
    bool operator<(const Elem &e) const {
        return dist > e.dist;
    }
};

void solve() {
    priority_queue<Elem> que;
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            if(board[i][j] == 'S') {
                que.push(Elem{i, j, 0, 0});
                que.push(Elem{i, j, 1, 0});
                dist[i][j][0] = dist[i][j][1] = 0;
            }
            else {
                dist[i][j][0] = dist[i][j][1] = INF;
            }
        }
    }

    int ans = INF;
    while(que.size()) {
        Elem cur = que.top(); que.pop();
        int f = cur.foot;
        for(int k=0; k<9; k++) {
            int nx = cur.x + dx[f][k];
            int ny = cur.y + dy[f][k];
            if(nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
            if(board[nx][ny] == 'X') continue;

            bool t_or_s = !isdigit(board[nx][ny]);
            int cost = (t_or_s ? 0 : board[nx][ny] - '0');
            if(dist[nx][ny][f^1] > dist[cur.x][cur.y][f] + cost) {
                dist[nx][ny][f^1] = dist[cur.x][cur.y][f] + cost;
                que.push(Elem{nx, ny, f^1, dist[nx][ny][f^1]});
                if(board[nx][ny] == 'T') {
                    if(ans > dist[nx][ny][f^1]) {
                        ans = dist[nx][ny][f^1];
                    }
                }
            }
        }
    }

    printf("%d\n", (ans == INF ? -1 : ans));
}

int main() {
    while(1) {
        scanf("%d%d", &W, &H);
        if(W == 0 && H == 0) break;

        for(int i=0; i<H; i++) {
            for(int j=0; j<W; j++) {
                scanf(" %c", &board[i][j]);
            }
        }

        solve();
    }
    return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:47:28: error: 'isdigit' was not declared in this scope
   47 |             bool t_or_s = !isdigit(board[nx][ny]);
      |                            ^~~~~~~
Language: C++

#include <iostream>
#include <queue>

using namespace std;

const int INF = 999999;

class Node{
public:
	int x, y, foot, cost;
	Node(int x, int y, int foot, int cost) : x(x), y(y), foot(foot), cost(cost) {}
	bool operator < (const Node &n) const { return cost > n.cost; }
};

int main(){
	int w, h;
	char b[60][30];
	bool visit[2][60][30];
	int dist[2][60][30];
	while(cin >> w >> h){
		if(!(w||h)) break;
		int ans = INF;
		priority_queue<Node> qu;
		memset(visit, false, sizeof(visit));
		memset(dist, INF, sizeof(dist));
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin >> b[i][j];
				if(isdigit(b[i][j])) b[i][j] -= '0';
				else if(b[i][j] == 'S'){
					qu.push(Node(j,i,0,0));
					qu.push(Node(j,i,1,0));
					dist[0][i][j] = 0;
					dist[1][i][j] = 0;
				}
			}
		}
		while(!qu.empty()){
			Node e = qu.top(); qu.pop();
			if(visit[e.foot][e.y][e.x]) continue;
			if(b[e.y][e.x]=='T'){
				ans = e.cost;
				break;
			}
			visit[e.foot][e.y][e.x] = true;
			for(int dx=1;dx<=3;dx++){
				for(int dy=dx-3;dy<=3-dx;dy++){
					int x = e.x + (e.foot ? -dx : dx);
					int y = e.y + dy;
					if(x<0||x>=w||y<0||y>=h||visit[(1+e.foot)%2][y][x]) continue;
					if(b[y][x]=='X'||b[y][x]=='S') continue;
					if(dist[(1+e.foot)%2][y][x] > e.cost + (b[y][x]!='T'?b[y][x]:0)){
						dist[(1+e.foot)%2][y][x] = e.cost + (b[y][x]!='T'?b[y][x]:0);
						qu.push(Node(x,y,(1+e.foot)%2,e.cost+(b[y][x]!='T'?b[y][x]:0)));
					}   
				}   
			}
		}
		cout << (ans == INF ? -1 : ans) << endl;  
	}
}

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

#include<iostream>
#define INF 100000000
#include<algorithm>
#include<queue>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
struct pla{
	int lx,ly,rx,ry,nowc;
	pla(){}
	pla(int lx,int ly,int rx,int ry,int nowc):
	lx(lx),ly(ly),rx(rx),ry(ry),nowc(nowc){}
	operator<(const pla &x)const{
		return nowc>x.nowc;
	}
};
int main(){
	int w,h,dx[]={1,1,1,1,1,2,2,2,3},dy[]={2,1,0,-1,-2,1,0,-1,0};
	while(cin>>w>>h,w||h){
		char s[70][40];
		rep(i,h)
		rep(j,w){
			cin>>s[i][j];
		}
		priority_queue<pla> que;
		int d[20][20][20][20];
		rep(i,h)
		rep(j,w)
		rep(k,h)
		rep(l,w)
		d[i][j][k][l]=INF;
		rep(i,w){
			if(s[h-1][i]=='S'){
				for(int j=i+1;j<w;j++){
					if(s[h-1][j]=='S'){
						que.push(pla(i,h-1,j,h-1,0));
						d[h-1][i][h-1][j]=0;
					}
				}
			}
		}
		int llx,lly,rrx,rry,nrrc,nllc;
		rep(i,w){
			if(s[h-1][i]=='S'){
				rep(j,9){
					rrx=i+dx[j];
					rry=h-1+dy[j];
					if(rrx<0||rrx>w-1||rry>h-1||rry<0||s[rry][rrx]=='X')
					continue;
					nrrc=isdigit(s[rry][rrx])?s[rry][rrx]-'0':0;
					que.push(pla(i,h-1,rrx,rry,nrrc));
					d[h-1][i][rry][rrx]=nrrc;
					
				}
				rep(j,9){
					llx=i-dx[j];
					lly=h-1+dy[j];
					if(llx<0||llx>w-1||lly>h-1||lly<0||s[lly][llx]=='X')
					continue;
					nllc=isdigit(s[lly][llx])?s[lly][llx]-'0':0;
					que.push(pla(llx,lly,i,h-1,nllc));
					d[lly][llx][h-1][i]=nllc;
				}
			}
		}
		bool flag=true;
		while(!que.empty()){
			pla now=que.top();
			que.pop();
			//cout<<now.nowc<<' '<<now.lx<<' '<<now.ly<<endl;
			if(d[now.ly][now.lx][now.ry][now.rx]<now.nowc){
			//	cout<<"77777"<<endl;
				continue;
			}
			if(s[now.ly][now.lx]=='T'||s[now.ry][now.rx]=='T'){
				flag=false;
				cout<<now.nowc<<endl;
				break;
			}
			rep(i,9){
				int nrx,nry,nrc;
				nrx=now.lx+dx[i];
				nry=now.ly+dy[i];
				if((nrx==now.rx&&nry==now.ry)||nry<0||nry>h-1||nrx<0||nrx>w-1||s[nry][nrx]=='X')
					continue;
				nrc=isdigit(s[nry][nrx])?s[nry][nrx]-'0':0;
			//	cout<<nrc<<endl;
				if(d[now.ly][now.lx][nry][nrx]>now.nowc+nrc){
					que.push(pla(now.lx,now.ly,nrx,nry,now.nowc+nrc));
					d[now.ly][now.lx][nry][nrx]=now.nowc+nrc;
				}
			}
			rep(i,9){
				int nlx,nly,nlc;
				nlx=now.rx-dx[i];
				nly=now.ry+dy[i];
				if((nlx==now.lx&&nly==now.ly)||nly<0||nly>h-1||nlx<0||nlx>w-1||s[nly][nlx]=='X')
				continue;
				nlc=isdigit(s[nly][nlx])?s[nly][nlx]-'0':0;
				if(d[nly][nlx][now.ry][now.rx]>now.nowc+nlc){
					que.push(pla(nlx,nly,now.rx,now.ry,now.nowc+nlc));
					d[nly][nlx][now.ry][now.rx]=now.nowc+nlc;
				}
			}
		}
			if(flag)
		cout<<-1<<endl;
	}
	return 0;
}

Compiler output:
a.cc:13:9: error: ISO C++ forbids declaration of 'operator<' with no type [-fpermissive]
   13 |         operator<(const pla &x)const{
      |         ^~~~~~~~
Language: C++

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

int W,H;
struct Node{
	int x,y,cost,dir;
	Node(int p_x,int p_y,int p_c,int p_dir){
		x=p_x;y=p_y;dir=p_dir;cost=p_c;
	}
};

bool operator < (Node a,Node b){
	return a.cost>b.cost;
};

bool in(int x,int y){
	if(x<0 || y<0 || x>=W || y>=H) return false;
	return true;
}

int solve(){
	vector<vector<char> > M(H,vector<char>(W));
	vector<int> S;

	for(int y=0;y<H;y++){
		for(int x=0;x<W;x++){
			char c;
			cin>>c;
			M[y][x]=c;
			if(c=='S'){
				S.push_back(x);
			}
		}
	}

	priority_queue<Node> Q;
	int cost[2][60][30];
	memset(cost,-1,sizeof(cost));

	for(int i=0;i<S.size();i++){
		Q.push(Node(S[i],H-1,0,0));
		Q.push(Node(S[i],H-1,0,1));
	}
	while(!Q.empty()){
		Node t=Q.top();
		Q.pop();
		if(cost[t.dir][t.y][t.x]>=0) continue;
		cost[t.dir][t.y][t.x]=t.cost;
		int mul,next;
		if(t.dir==0){mul=1;next=1;}
		else{mul=-1;next=0;}

		for(int x=1;x<=3;x++){
			for(int y=-2;y<=2;y++){
				if(x+abs(y)>3) continue;
				int nx=t.x+x*mul;
				int ny=t.y+y;
				if(!in(nx,ny)) continue;

				if(M[ny][nx]=='T') return t.cost;
				if(!isdigit(M[ny][nx])) continue;

				Q.push(Node(nx,ny,t.cost+M[ny][nx]-'0',next));
			}
		}
	}
	return -1;
}

int main()
{
	while(cin>>W>>H){
		if(W==0) return 0;
		cout<<solve()<<endl;
	}
}

Compiler output:
a.cc: In function 'int solve()':
a.cc:41:9: error: 'memset' was not declared in this scope
   41 |         memset(cost,-1,sizeof(cost));
      |         ^~~~~~
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 | using namespace std;
Language: C++

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

using namespace std;
#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

typedef vector<int> vi;
typedef vector<vi> vvi;

const int INF = 1001001001;

struct Data {
	int ry, rx, ly, lx;
	int cost;
	bool nextr;
	Data(int ry, int rx, int ly, int lx, int c, bool n) : ry(ry), rx(rx), ly(ly), lx(lx), cost(c), nextr(n) {}
	bool operator< (const Data& d)const {
		return cost > d.cost;
	}
};

int w, h;
bool valid(int y, int x)
{
	return 0<=y && y<h && 0<=x && x<w;
}

const int dy[] = {-2, -1, -1, 0, 0, 0, 1, 1, 2};
const int drx[] = {-1, -2, -1, -3, -2, -1, -2, -1, -1};
bool visited[100][100][100][100];
int main()
{
	while(scanf("%d%d", &w, &h), w){
		rep(i, 100) rep(j, 100) rep(k, 100) rep(l, 100)
			visited[i][j][k][l] = false;

		char field[100][100];
		rep(i, h) rep(j, w){
			char tmp[100];
			scanf("%s", tmp);
			field[i][j] = tmp[0];
		}

		priority_queue<Data> Q;
		rep(i, w){
			if(field[h-1][i] == 'S'){
				Q.push(Data(h-1, i, 99, 99, 0, false));
				Q.push(Data(99, 99, h-1, i, 0, true));
			}
		}

		int ans = -1;
		while(!Q.empty()){
			Data d = Q.top();
			Q.pop();
			if(visited[d.ry][d.rx][d.ly][d.lx])
				continue;
			visited[d.ry][d.rx][d.ly][d.lx] = true;
			if(field[d.ry][d.rx] == 'T' || field[d.ly][d.lx] == 'T'){
				ans = d.cost;
				break;
			}
			rep(i, 9){
				int pry, prx, ply, plx;
				if(d.nextr){
					if(d.ly == 99)
						continue;
					pry = d.ly + dy[i];
					prx = d.lx + drx[i];
					ply = d.ly;
					plx = d.lx;
				}
				else{
					if(d.ry == 99)
						continue;
					pry = d.ry;
					prx = d.rx;
					ply = d.ry + dy[i];
					plx = d.rx - drx[i];
				}
				if(!valid(pry, prx) || !valid(ply, plx))
					continue;

				char c = d.nextr ? field[pry][prx] : field[ply][plx];
				if(c == 'X')
					continue;

				int pc = d.cost + (isdigit(c) ? c-'0' : 0);
				Q.push(Data(pry, prx, ply, plx, pc, !d.nextr));
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:91:52: error: 'isdigit' was not declared in this scope
   91 |                                 int pc = d.cost + (isdigit(c) ? c-'0' : 0);
      |                                                    ^~~~~~~
Language: C++

#include <cctype>
#include <cstdio>
#include <queue>
#include <vector>
#include <functional>
#define INF 100000000

using namespace std;
typedef pair<int,int> P;

class Node{
public:
  Node(int x, int y, int f):x(x),y(y),f(f){}
  int x,y,f;
  int tonum(){return (x<<7)+(y<<1)+f;}
};

Node tonode(int num){
  return Node(num>>7,num>>1&63,num&1);
};

int hoge[2][9][2] = {{{1,2},{1,1},{1,0},{1,-1},{1,-2},{2,1},{2,0},{2,-1},{3,0}},
		     {{-1,2},{-1,1},{-1,0},{-1,-1},{-1,-2},{-2,1},{-2,0},{-2,-1},{-3,0}}};

int w,h;
int map[100][100];
int d[100000];
bool visit[100000];

void dijkstra(Node from) {
  int m = from.tonum();
  priority_queue<P,vector<P>,greater<P> > que;
  fill(d,d+100000,INF); fill(visit,visit+100000,false);
  d[m] = 0;
  que.push(P(0,m));
  while(!que.empty()) {
    P p = que.top(); que.pop();
    int cand = p.second;
    if (visit[cand])
      continue;
    visit[cand] = true;
    
    for (int i=0; i<9; i++) {
      Node n = tonode(cand);
      int dx = hoge[n.f][i][0], dy = hoge[n.f][i][1];
      int x = n.x+dx, y= n.y+dy, f = (n.f+1)&1;
      if (x >= 0 && x < w && y >= 0 && y < h && map[x][y] != INF) {
	int next = Node(x,y,f).tonum();
	if (d[next] > d[cand] + map[x][y]) {
	  d[next] = d[cand] + map[x][y];
	  que.push(P(d[next],next));
	}
      }
    }
  }
}

int main() {
  while(scanf("%d %d",&w,&h),w) {
    vector<Node> start,goal;

    for (int y=0; y<h; y++) {
      for (int x=0; x<w; x++) {
	char c;
	while(isspace(c=getchar())) ;
	switch (c) {
	case 'X':
	  map[x][y]=INF;
	  break;
	case 'S':
	  map[x][y] = 0;
	  start.push_back(Node(x,y,0));
	  start.push_back(Node(x,y,1));
	  break;
	case 'T':
	  map[x][y] = 0;
	  goal.push_back(Node(x,y,0));
	  goal.push_back(Node(x,y,1));
	  break;
	default:
	  assert('0' < c && c <= '9');
	  map[x][y] = c-'0';
	}
      }
    }

    int ans = INF;
    for (int s=0; s<start.size(); s++){
      dijkstra(start[s]);
      for (int g=0; g<goal.size(); g++) {
	ans = min(ans,d[goal[g].tonum()]);
      }
    }
  
    printf ("%d\n",(ans==INF)?-1:ans);
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:81:11: error: 'assert' was not declared in this scope
   81 |           assert('0' < c && c <= '9');
      |           ^~~~~~
a.cc:6:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
    5 | #include <functional>
  +++ |+#include <cassert>
    6 | #define INF 100000000
Language: C++

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

struct Node{
	Node* l;
	Node* r;
	double R;
	string s;
	set<string> set;
	Node() : l(nullptr), r(nullptr){}
};

int c;
int N;
string s;

map<pair<Node*, Node*>, int> compm;
// X????????????????§°??§????????? -1
// ?????? 0
// Y????????????????§°??§?????????  1
int comp(Node* X, Node* Y){
	if(compm.count({ X, Y })) return compm[{X, Y}];
	if(X->R != Y->R){
		if(X->R < Y->R) return compm[{X, Y}] = -1;
		return compm[{X, Y}] = 1;
	}
	if(X->s == "()" && Y->s == "()"){
		return compm[{X, Y}] = 0;
	}

	Node *xmin, *xmax;
	Node *ymin, *ymax;
	if(comp(X->l, X->r) < 0){
		xmax = X->l, xmin = X->r;
	}
	else{
		xmin = X->l, xmax = X->r;
	}
	if(comp(Y->l, Y->r) < 0){
		ymax = Y->l, ymin = Y->r;
	}
	else{
		ymin = Y->l, ymax = Y->r;
	}
	int res = comp(xmax, ymax);
	if(res != 0){
		if(res < 0) return compm[{X, Y}] = -1;
		return compm[{X, Y}] = 1;
	}
	return compm[{X, Y}] = comp(xmin, ymin);
}

Node* f(){
	Node* n = new Node();
	if(s[c] == 'x'){
		c++;
		n->s = "()";
		n->set.insert("()");
		n->R = 0;
		return n;
	}
	assert(s[c] == '(');
	c++;
	n->l = f();
	assert(s[c] == ' ');
	c++;
	n->r = f();
	int cnt = 0;
	for(auto v : n->l->set){
		n->set.insert(v);
		if(n->r->set.count(v)) cnt++;
	}
	for(auto v : n->r->set){
		n->set.insert(v);
	}
	n->R = double(cnt) / n->set.size();

	string ls = n->l->s, rs = n->r->s;
	if(ls > rs) swap(ls, rs);
	n->s = "(" + ls + rs + ")";
	n->set.insert(n->s);

	assert(s[c] == ')');
	c++;
	return n;
}

void g(Node* n, bool left){
	if(n->s == "()"){
		cout << "x";
		return;
	}
	if(left && comp(n->l, n->r) > 0){
		swap(n->l, n->r);
	}
	if(!left && comp(n->l, n->r) < 0){
		swap(n->l, n->r);
	}

	cout << "(";
	g(n->l, true);
	cout << " ";
	g(n->r, false);
	cout << ")";
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	while(getline(cin, s), s != "0"){
		compm.clear();
		N = s.size();
		c = 0;
		Node* r = f();
		//cout << s << endl;
		g(r, 1);
		cout << endl;
	}
}

Compiler output:
a.cc:10:21: error: declaration of 'std::set<std::__cxx11::basic_string<char> > Node::set' changes meaning of 'set' [-Wchanges-meaning]
   10 |         set<string> set;
      |                     ^~~
a.cc:10:9: note: used here to mean 'class std::set<std::__cxx11::basic_string<char> >'
   10 |         set<string> set;
      |         ^~~~~~~~~~~
In file included from /usr/include/c++/14/set:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:158,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_set.h:96:11: note: declared here
   96 |     class set
      |           ^~~
Language: Java

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		while(true)
		{
			Scanner stdIn = new Scanner(System.in);
			int n = stdIn.nextInt();
			int m = stdIn.nextInt();
			
			if(n==0 && m==0)
			{
				break;
			}
			
			int[] tarou = new int[n];
			int[] hanako = new int[m];
			int x = 0;
			int tarou_number = 0;
			int hanako_number = 0;
			int total = 1000;
			
			for(int i=0;i<n;i++)
			{
				Arrays.fill(hantei[i],false);
			}
			
			
			for(int i=0;i<n;i++)
			{
				tarou[i] = stdIn.nextInt();
			}
			for(int i=0;i<m;i++)
			{
				hanako[i] = stdIn.nextInt();
			}
		
			for(int i=0;i<n;i++)
			{
				int tarou_total = 0;
				int hanako_total = 0;
				
				
				for(int j=0;j<m;j++)
				{
					int h = tarou[i];
					tarou[i] = hanako[j];
					hanako[j] = h;
				
					tarou_total = func(tarou);
					hanako_total = func(hanako);
				
					h = tarou[i];
					tarou[i] = hanako[j];
					hanako[j] = h;
					
					if(tarou_total == hanako_total && total>(tarou[i]+hanako[j]))
					{
						tarou_number = i;
						hanako_number = j;
						total = tarou[i]+hanako[j];
						x++;
					}
				
				}
				
			}
			
			if(x!=0)
			{
				System.out.println(tarou[tarou_number]+" "+hanako[hanako_number]);
			}
			else
			{
				System.out.println("-1");
			}
		}
		
	}
	
	static int func(int[] x)
	{
		int total = 0;
		
		for(int i=0;i<x.length;i++)
		{
			total += x[i];
		}
		
		return total;
	}
	

}

Compiler output:
Main.java:27: error: cannot find symbol
				Arrays.fill(hantei[i],false);
				            ^
  symbol:   variable hantei
  location: class Main
1 error
Language: Java



import java.util.Scanner;

import jdk.internal.org.objectweb.asm.tree.IntInsnNode;

public class Main {

	void run() {

		Scanner sc = new Scanner(System.in);

		while (true) {
			int n = sc.nextInt();
			int m = sc.nextInt();

			int tsum = 0;
			int hsum = 0;

			int anst = 0;
			int ansh = 0;

			int min = 200;

			if ((n | m) == 0) {
				break;
			}

			// taro
			int[] t = new int[n];
			for (int i = 0; i < n; i++) {
				t[i] = sc.nextInt();
				tsum += t[i];
			}

			// hanako
			int[] h = new int[m];
			for (int i = 0; i < m; i++) {
				h[i] = sc.nextInt();
				hsum += h[i];
			}

			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					if (tsum - t[i] + h[j] == hsum - h[j] + t[i]) {
						if (min > t[i] + h[j]) {
							min = t[i] + h[j];
							anst = t[i];
							ansh = h[j];
						}
					}
				}
			}

			if ((anst | ansh) == 0) {
				System.out.println(-1);
			} else {
				System.out.println(anst + " " + ansh);
			}

		}

	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Compiler output:
Main.java:5: error: package jdk.internal.org.objectweb.asm.tree is not visible
import jdk.internal.org.objectweb.asm.tree.IntInsnNode;
                                     ^
  (package jdk.internal.org.objectweb.asm.tree is declared in module java.base, which does not export it to the unnamed module)
1 error