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

#include <iostream>
#include <algorithm>

constexpr int MAX=2001;

int n,m;

int dp[MAX][MAX][2];

bool S[MAX],T[MAX];

int main() {
	std::cin>>n>>m;
	char ch;
	for(int i=1;i<=n;++i){
		std::cin>>ch;
		if(ch=='I')
			S[i]=1;
	}
	for(int j=1;j<=m;++j){
		std::cin>>ch;
		if(ch=='I')
			T[i]=1;
	}

	for(int i=1;i<=n;++i){
		if(S[i])
			dp[i][0][1]=1;
	}

	for(int i=1;i<=m;++i){
		if(T[i])
			dp[0][i][1]=1;
	}

	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			for(int k=0;k<2;++k){
				if(S[i]==k)
					dp[i][j][k]=dp[i-1][j][!k]+1;
				if(T[i]==k)
					dp[i][j][k]=std::max(dp[i][j][k],
						dp[i][j-1][!k])+1;
			}
		}
	}

	int ans=0;

	for(int i=0;i<=n;++i){
		for(int j=0;j<=m;++j)
			ans=std::max(ans,dp[i][j][1]);
	}

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

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:27: error: 'i' was not declared in this scope
   23 |                         T[i]=1;
      |                           ^
Language: C++


#include <iomanip>
#include <utility>
#include <algorithm>
#include <type_traits>
#include <set>
#include <string>
#include <iostream>
#include <fstream>
#include <cassert>
#include <memory>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <queue>
#include <vector>
#include <array>
#include <chrono>
#include <random>
#include <forward_list>
#include <iomanip>
#include <functional>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <sstream>
#include <numeric>

using namespace std;
#define MFOR(i,end) for(size_t i = 0, end_##i = (end); i < end_##i; ++i)

size_t M, N;
char S[2500];
char T[2500];
enum class Mode_T : int8_t {
	none = 0, I, O
};
int dp[2010][2010][3];
int func(int spos, int tpos, Mode_T last)
{
	if (S[spos] == '\0' && T[tpos] == '\0') { return -2010 * 2010 * 3; }
	if (dp[spos][tpos][(int8_t)last] != -1) {
		return dp[spos][tpos][(int8_t)last];
	}
	int max = -2010* 2010*3;
	if (last == Mode_T::none) {
		if (S[spos] == 'I') {
			max = std::max(max, 1 + std::max(0, func(spos + 1, tpos, Mode_T::I)));
		}
		if (S[spos] != '\0')max = std::max(max, 0 + func(spos + 1, tpos, Mode_T::none));
		if (T[tpos] == 'I') {
			max = std::max(max, 1 + std::max(0, func(spos, tpos + 1, Mode_T::I)));
		}
		if (T[tpos] != '\0')max = std::max(max, 0 + func(spos, tpos + 1, Mode_T::none));
	}
	else if (last == Mode_T::I)
	{
		if (S[spos] == 'O') {
			max = std::max(max, 1 + func(spos + 1, tpos, Mode_T::O));
		}
		if (T[tpos] == 'O') {
			max = std::max(max, 1 + func(spos, tpos + 1, Mode_T::O));
		}
	}
	else if (last == Mode_T::O)
	{
		if (S[spos] == 'I') {
			max = std::max(max, 1 + std::max(0, func(spos + 1, tpos, Mode_T::I)));
		}
		if (T[tpos] == 'I') {
			max = std::max(max, 1 + std::max(0, func(spos, tpos + 1, Mode_T::I)));
		}
	}
	return dp[spos][tpos][(int8_t)last] = max;
}

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;
#define rep(i, n) for (int i = 0; i < n; i++)
template<typename T>bool maxup(T& a, const T&& b) { if (a < b) { a = b; return true; }; }

int dp[2005][2005][2];
int main() {
	int m, n; cin >> m >> n;
	vector<int> s(m + 1);
	s[m] = 0;
	rep(i, m) {
		char c; cin >> c;
		s[i] = c == 'I';
	}
	vector<int> t(n + 1);
	rep(i, n) {
		char c; cin >> c;
		t[i] = c == 'I';
	}
	t[n] = 0;

	int ans = 0;
	rep(i, m + 1) rep(j, n + 1) {
		maxup(dp[i + 1][j][0], (dp[i][j][1] + 1) * !!dp[i][j][1] * !s[i]);
		maxup(dp[i][j + 1][0], (dp[i][j][1] + 1) * !!dp[i][j][1] * !t[j]);

		maxup(dp[i + 1][j][1], (dp[i][j][0] + 1) * s[i]);
		maxup(dp[i][j + 1][1], (dp[i][j][0] + 1) * t[j]);

		maxup(ans, dp[i + 1][j][1]);
		maxup(ans, dp[i][j + 1][1]);
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:42: error: cannot bind rvalue reference of type 'const int&&' to lvalue of type 'int'
   30 |                 maxup(ans, dp[i + 1][j][1]);
      |                            ~~~~~~~~~~~~~~^
a.cc:4:48: note:   initializing argument 2 of 'bool maxup(T&, const T&&) [with T = int]'
    4 | template<typename T>bool maxup(T& a, const T&& b) { if (a < b) { a = b; return true; }; }
      |                                      ~~~~~~~~~~^
a.cc:31:42: error: cannot bind rvalue reference of type 'const int&&' to lvalue of type 'int'
   31 |                 maxup(ans, dp[i][j + 1][1]);
      |                            ~~~~~~~~~~~~~~^
a.cc:4:48: note:   initializing argument 2 of 'bool maxup(T&, const T&&) [with T = int]'
    4 | template<typename T>bool maxup(T& a, const T&& b) { if (a < b) { a = b; return true; }; }
      |                                      ~~~~~~~~~~^
a.cc: In function 'bool maxup(T&, const T&&) [with T = int]':
a.cc:4:89: warning: control reaches end of non-void function [-Wreturn-type]
    4 | template<typename T>bool maxup(T& a, const T&& b) { if (a < b) { a = b; return true; }; }
      |                                                                                         ^
Language: C++

#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
using namespace std;
typedef long long ll;
ll n,m;
bool a[2000],b[2000];
ll dp[2000][2000][2];
map<bool, int>o;
ll solve(ll i,ll j,bool s){
	ll sum=0;
	if(i!=n&&a[i]==!s){
		if(dp[i+1][j][o[!s]]!=-1){
			sum=1+dp[i+1][j][o[!s]];
		}
		else sum=1+(dp[i+1][j][o[!s]]=solve(i+1,j,!s));
		l=true;
	}
	if(j!=m&&b[j]==!s){
		if(dp[i][j+1][!s]!=-1){
			sum=max(sum,1+dp[i][j+1][o[!s]]);
		}
		else sum=max(sum,1+(dp[i][j+1][o[!s]]=solve(i,j+1,!s)));
	}
	return sum;
}
int main() {
	while(cin>>n>>m){
		string u1,u2;
		cin>>u1>>u2;
		for(ll i=n-1;i>=0;i--){
			if(u1[i]=='I') a[n-i]=true;
			else a[n-i]=false;
		}
		for(ll i=m-1;i>=0;i--){
			if(u2[i]=='I') b[m-i]=true;
			else b[m-i]=false;
		}
		for(ll i=0;i<n;i++){
			for(ll j=0;j<m;j++){
				dp[i][j][0]=-1;
				dp[i][j][1]=-1;
			}
		}
		o.insert(map<bool, int>::value_type(true,0));
		o.insert(map<bool, int>::value_type(false,1));
		cout<<solve(0,0,false)<<endl;
	}
}

Compiler output:
a.cc: In function 'll solve(ll, ll, bool)':
a.cc:26:17: error: 'l' was not declared in this scope
   26 |                 l=true;
      |                 ^
Language: C++

#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<string.h>

using namespace std;

#define F first
#define S second
#define INF 0x7f7f7f7f
typedef long long LL;
typedef pair<LL, LL> P;
struct edge { LL to, cost,sw; };
vector<edge> g[200001];
LL d[200001][2];
bool flag[200001] = { 0 };
pair<pair<LL,LL>,int> xy[200001];
pair<pair<LL,LL>,int> yx[200001];

int main(){
	int m, n, k;

	scanf("%d%d%d", &m, &n, &k);
	LL x, y;
	for (int i = 1; i <= k; i++) {
		scanf("%lld%lld", &x, &y);
		xy[i] = make_pair(make_pair(x, y),i);
		yx[i] = make_pair(make_pair(y, x),i);
	}
	memset(d, 0x7f, sizeof(d));
	//memset(flag, false, sizeof(flag));
	d[0][0] = 0;
	xy[0] = make_pair(make_pair(1, 1),0);yx[0] = make_pair(make_pair(1, 1),0);
	xy[k + 1] = make_pair(make_pair(m, n),k + 1); yx[k + 1] = make_pair(make_pair(n, m), k + 1);
	sort(xy, xy + k + 1);
	sort(yx, yx + k + 1);
	for (int i = 0; i <= k; i++) {
		edge t;
		if (xy[i + 1].F.F == xy[i].F.F) {
			t.to = xy[i+1].S; t.cost = abs(xy[i].F.S - xy[i + 1].F.S); t.sw = 0;
			g[xy[i].S].push_back(t);
		}
		if (yx[i + 1].F.F == yx[i].F.F) {
			t.to = yx[i+1].S; t.cost = abs(yx[i].F.S - yx[i + 1].F.S); t.sw = 1;
			g[yx[i].S].push_back(t);
		}
		if (xy[i - 1].F.F == xy[i].F.F) {
			t.to = xy[i - 1].S; t.cost = abs(xy[i].F.S - xy[i - 1].F.S); t.sw = 0;
			g[xy[i].S].push_back(t);
		}
		if (yx[i - 1].F.F == yx[i].F.F) {
			t.to = yx[i - 1].S; t.cost = abs(yx[i].F.S - yx[i - 1].F.S); t.sw = 1;
			g[yx[i].S].push_back(t);
		}
	}
	priority_queue<int, vector<int>, greater<int> >q;
	q.push(0);
	int bef = -1;
	while (!q.empty()) {
		int i = q.top; q.pop();
		if (bef == i) continue;
		flag[i] = true;
		for (int j = 0; j < g[i].size(); j++) {
			if (!flag[g[i][j].to]) {
				d[g[i][j].to][1 - g[i][j].sw] = min(d[i][g[i][j].sw] + g[i][j].cost + 1, d[g[i][j].to][1 - g[i][j].sw]);
				d[g[i][j].to][g[i][j].sw] = min(d[i][g[i][j].sw] + g[i][j].cost, d[g[i][j].to][g[i][j].sw]);
				q.push(g[i][j].to);
			}
		}
		bef = i;
	}
	printf("%lld\n", min(d[k + 1][0], d[k + 1][1]) == INF ?  -1: min(d[k + 1][0], d[k + 1][1]));
}


Compiler output:
a.cc: In function 'int main()':
a.cc:62:27: error: cannot convert 'std::priority_queue<int, std::vector<int>, std::greater<int> >::top' from type 'const __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type& (std::priority_queue<int, std::vector<int>, std::greater<int> >::)() const' {aka 'const int& (std::priority_queue<int, std::vector<int>, std::greater<int> >::)() const'} to type 'int'
   62 |                 int i = q.top; q.pop();
      |                           ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define MAX 200005
typedef long long ll;
typedef pair<ll,ll> P;
struct edge{
  ll to,cost;
  edge(ll t,ll c){
    to=t,cost=c;
  }
};
struct state{
  ll pos,flg,cost;
  state(ll p,ll f,ll c){
    pos=p,flg=f,cost=c;
  }
  bool operator < (const state &p)const{
    return cost > p.cost;
  }
};
 
vector<P> t[MAX][2];
ll W,H,K,X[MAX],Y[MAX];
ll d[MAX][2];
vector<edge> G[MAX][2];
 
ll solve(){
  if(t[1][0].empty())return -1;
  for(int i=0;i<MAX;i++)d[i][0]=d[i][1]=10000000000000000LL;
  priority_queue< state > Q;
  P p=t[1][0][0];
  Q.push( state( p.second, 0, p.first-1 ) );
  d[p.second][0]=p.first-1;
   
  while(!Q.empty()){
    state s=Q.top();Q.pop();
    if(s.cost>d[s.pos][s.flg])continue;
    for(int f=0;f<2;f++){
      int nf=(s.flg+f)%2;
      for(int i=0;i<(int)G[s.pos][nf].size();i++){
        edge e=G[s.pos][nf][i];
        ll ncost=s.cost+e.cost+f;
        if(e.cost==0)ncost=s.cost;
        if(ncost<d[e.to][nf]){
          d[e.to][nf]=ncost;
          Q.push( state(e.to,nf,ncost) );
        }
      }
    }
  }
  ll res=min(d[K][0],d[K][1]);
  if(res==10000000000000000LL;)return -1;
  else return res;
}
       
int main(){
  scanf("%lld %lld %lld",&W,&H,&K);
  for(int i=0;i<K;i++){
    scanf("%lld %lld",&X[i],&Y[i]);
    t[X[i]][0].push_back(P(Y[i],i));
    t[Y[i]][1].push_back(P(X[i],i));
  }
  t[W][0].push_back(P(H,K));
  t[H][1].push_back(P(W,K));
  X[K]=W;
  Y[K]=H;
  for(int i=1;i<=100000;i++){
    for(int f=0;f<2;f++){
      vector<P> &vec=t[i][f];
      sort(vec.begin(),vec.end());
      int size=vec.size();
      for(int j=0;j<size;j++){
        P p=vec[j],q;
        if(0<j){
          q=vec[j-1];
          G[p.second][f].push_back( edge(q.second,p.first-q.first) );
        }
        if(j+1<size){
          q=vec[j+1];
          G[p.second][f].push_back( edge(q.second,q.first-p.first) );
        }
      }
    }
  }
  cout<<solve()<<endl; 
  return 0;
}

Compiler output:
a.cc: In function 'll solve()':
a.cc:52:31: error: expected primary-expression before ')' token
   52 |   if(res==10000000000000000LL;)return -1;
      |                               ^
a.cc:54:1: warning: control reaches end of non-void function [-Wreturn-type]
   54 | }
      | ^
Language: C++

#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long int LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

struct room
{
  int num;
  bool visited[2];
  
  bool operator<(const room r) const
  {
    return num < r.num;
  }
  bool operator>(const room r) const
  {
    return num > r.num;
  }
};

struct r_compare
{
  LL cost;
  int loc_x, loc_y;
  bool sw;

  bool operator<(const r_compare r) const
  {
    return cost < r.cost;
  }
  bool operator>(const r_compare r) const
  {
    return cost > r.cost;
  }
};

int m, n, k;
vector<room> ns[100010], ew[100010];
priority_queue<r_compare, vector<r_compare>, greater<r_compare> > Q;

LL dijk()
{
  if(ns[1].size() == 0)
    return -1;

  r_compare qin = {(ns[1].begin())->num - 1, 1, (ns[1].begin())->num, false};
  Q.push(qin);

  while(!Q.empty()){
    r_compare c_now = Q.top();
    Q.pop();

    if(c_now.loc_x == m && c_now.loc_y == n)
      return c_now.cost;

    room sr = {(!c_now.sw ? c_now.loc_y : c_now.loc_x), {false, false}};
    vector<room>::iterator r_now = !c_now.sw ? lower_bound(ns[c_now.loc_x].begin(), ns[c_now.loc_x].end(), sr) : lower_bound(ew[c_now.loc_y].begin(), ew[c_now.loc_y].end(), sr);

    if(!r_now->visited[c_now.sw]){
      r_now->visited[c_now.sw] = true;
      
      if(!c_now.sw){
	if(r_now != ns[c_now.loc_x].begin()){
	  r_compare qin = {c_now.cost + r_now->num - (r_now - 1)->num, c_now.loc_x, (r_now - 1)->num, false};
	  Q.push(qin);
	}
	if(r_now != ns[c_now.loc_x].end() - 1){
	  r_compare qin = {c_now.cost + (r_now + 1)->num - r_now->num, c_now.loc_x, (r_now + 1)->num, false};
	  Q.push(qin);
	}
      }
      else{
	if(r_now != ew[c_now.loc_y].begin()){
	  r_compare qin = {c_now.cost + r_now->num - (r_now - 1)->num, (r_now - 1)->num, c_now.loc_y, true};
	  Q.push(qin);
	}/*
	if(r_now != ew[c_now.loc_y].end() - 1){
	  r_compare qin = {c_now.cost + (r_now + 1)->num - r_now->num, (r_now + 1)->num, c_now.loc_y, true};
	  Q.push(qin);*/
	}
      }

      r_compare qin = {c_now.cost + 1, c_now.loc_x, c_now.loc_y, !c_now.sw};
      Q.push(qin);
    }
  }
  return -1;
}

int main()
{
  scanf("%d%d%d", &m, &n, &k);
  
  bool last = false;
  for(int i = 0; i < k; i++){
    int x, y;
    if(x == m && y == n)
      last = true;
    scanf("%d%d", &x, &y);
    room xin = {y, {false, false}}, yin = {x, {false, false}};
    ns[x].PB(xin);
    ew[y].PB(yin);
  }
  
  if(!last){
    room xin = {n, {false, false}}, yin = {m, {false, false}};
    ns[m].PB(xin);
    ew[n].PB(yin);
  }
  
  for(int i = 1; i <= m; i++)
    sort(ns[i].begin(), ns[i].end());
  for(int i = 1; i <= m; i++)
    sort(ew[i].begin(), ew[i].end());

  printf("%lld\n", dijk());
  return 0;
}

Compiler output:
a.cc:90:3: error: expected unqualified-id before 'return'
   90 |   return -1;
      |   ^~~~~~
a.cc:91:1: error: expected declaration before '}' token
   91 | }
      | ^
a.cc: In function 'LL dijk()':
a.cc:89:3: warning: control reaches end of non-void function [-Wreturn-type]
   89 |   }
      |   ^
Language: C++

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

using namespace std;

int H, W, K, X, Y;

vector<pair<int, int> > xc[100000]; int xs[100000];
vector<pair<int, int> > yc[100000]; int ys[100000];

vector<pair<int, int> > G[200002]; long long D[200002];

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

	xc[0].push_back(make_pair(0, 0));
	yc[0].push_back(make_pair(0, 0));

	xc[W - 1].push_back(make_pair(H - 1, 1));
	yc[H - 1].push_back(make_pair(W - 1, 1));

	for (int i = 0; i < K; i++)
	{
		scanf("%d", &X);
		scanf("%d", &Y);

		xc[X - 1].push_back(make_pair(Y - 1, i + 2));
		yc[Y - 1].push_back(make_pair(X - 1, i + 2));
	}

	for (int i = 0; i < H; i++) sort(yc[i].begin(), yc[i].end());
	for (int i = 0; i < W; i++) sort(xc[i].begin(), xc[i].end());

	for (int i = 0; i < H; i++) ys[i] = yc[i].size();
	for (int i = 0; i < W; i++) xs[i] = xc[i].size();

	for (int i = 0; i < W; i++)
	{
		for (int j = 0; j < xs[i] - 1; j++)
		{
			int node1 = xc[i][j].second;
			int node2 = xc[i][j + 1].second;
			
			int dist = xc[i][j + 1].first - xc[i][j].first + 1;

			G[node1].push_back(make_pair(node2, dist));
		}

		for (int j = 1; j < xs[i]; j++)
		{
			int node1 = xc[i][j].second;
			int node2 = xc[i][j - 1].second;

			int dist = xc[i][j].first - xc[i][j - 1].first + 1;

			G[node1].push_back(make_pair(node2, dist));
		}
	}

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < ys[i] - 1; j++)
		{
			int node1 = yc[i][j].second;
			int node2 = yc[i][j + 1].second;

			int dist = yc[i][j + 1].first - yc[i][j].first + 1;

			G[node1].push_back(make_pair(node2, dist));
		}

		for (int j = 1; j < ys[i]; j++)
		{
			int node1 = yc[i][j].second;
			int node2 = yc[i][j - 1].second;

			int dist = yc[i][j].first - yc[i][j - 1].first + 1;

			G[node1].push_back(make_pair(node2, dist));
		}
	}

	priority_queue<pair<long long, int>, vector<pair<long long, int> >, greater<pair<long long, int> > > que;

	memset(D, -1, sizeof(D)); D[0] = 0;

	que.push(make_pair(0LL, 0));

	while (!que.empty())
	{
		pair<long long, int> state = que.top(); que.pop();

		int node = state.first;

		long long dist = state.second;

		for (int i = 0; i < G[node].size(); i++)
		{
			int node2 = G[node][i].first;

			if (D[node2] == -1)
			{
				D[node2] = D[node] + G[node][i].second;

				que.push(make_pair(D[node2], node2));
			}
		}
	}

	printf("%lld\n", D[1]);

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:91:9: error: 'memset' was not declared in this scope
   91 |         memset(D, -1, sizeof(D)); D[0] = 0;
      |         ^~~~~~
a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    5 | #include <functional>
  +++ |+#include <cstring>
    6 |
Language: C++

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

using namespace std;

const int MAX_M=100000,MAX_N=100000,MAX_K=200000;

struct P{
	int x,y;
	int index;
};

bool comp(const P &a,const P &b){
	if (a.y!=b.y){
		return a.y<b.y;
	}
	return a.x<b.x;
}

bool comp2(const P &a,const P &b){
	if (a.x!=b.x){
		return a.x<b.x;
	}
	return a.y<b.y;
}

int M,N,K;
P p[MAX_K+2];

struct edge{
	int to,cost;
};

typedef pair<long long,int> PA;

const long long INF=1000000000000000;

int V;
vector<edge> G[MAX_K*2+4];

long long d[MAX_K*2+4];

long long dijkstra(){
	priority_queue<PA,vector<PA>,greater<PA> > que;
	fill(d,d+V,INF);
	d[K+2]=0;
	que.push(PA(0,K+2));
	while(!que.empty()){
		PA pa=que.top();
		que.pop();
		int v=pa.second,dis=pa.first;
		if (dis>d[v]) continue;
		for (int i=0;i<G[v].size();i++){
			edge e=G[v][i];
			if (d[v]+e.cost<d[e.to]){
				d[e.to]=d[v]+e.cost;
				que.push(PA(d[e.to],e.to));
			}
		}
	}
	return min(d[K+1],d[2*K+3]);
}

int main(){
	scanf("%d %d %d",&M,&N,&K);
	for (int i=0;i<K;i++){
		int x,y;
		scanf("%d %d",&x,&y);
		p[i+1].x=x;
		p[i+1].y=y;
		p[i+1].index=i+1;
	}
	p[0].x=1;	//スタート
	p[0].y=1;
	p[0].index=0;
	p[K+1].x=M;	//ゴール
	p[K+1].y=N;
	p[K+1].index=K+1;
	V=K*2+4;	//頂点の個数
	//辺を張る
	sort(p,p+K+2,comp);	//横の辺を張る
	for (int i=0;i<K+1;i++){
		if (p[i].y==p[i+1].y){
			int cost=p[i+1].x-p[i].x;
			edge e{p[i+1].index,cost};
			G[p[i].index].push_back(e);
			e.to=p[i].index;
			G[p[i+1].index].push_back(e)
		}
	}
	sort(p,p+K+2,comp2);	//縦の辺を張る
	for (int i=0;i<K+1;i++){
		if (p[i].x==p[i+1].x){
			int cost=p[i+1].y-p[i].y;
			edge e{p[i+1].index+K+2,cost};
			G[p[i].index+K+2].push_back(e);
			e.to=p[i].index+K+2;
			G[p[i+1].index+K+2].push_back(e);
		}
	}
	for (int i=1;i<=K;i++){
		edge e{i+K+2,1};
		G[i].push_back(e);
		e.to=i;
		G[i+K+2].push_back(e);
	}
	long long res=dijkstra();
	if (res==INF){
		res=-1;
	}
	printf("%lld\n",res);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:91:53: error: expected ';' before '}' token
   91 |                         G[p[i+1].index].push_back(e)
      |                                                     ^
      |                                                     ;
   92 |                 }
      |                 ~
Language: C++

#include<iostream>
#include<queue>
#include<stdio.h>
#include<utility>

using namespace std;

#define MAX_N 100000
#define MAX_M 100000
#define INF 1000000
typedef pair<int, int> P;  //?????????????????????

bool s[MAX_N * MAX_M];  //????????????????????????????????? 
int M, N, K;
int d[MAX_N * MAX_M][2]; // ???????????¢, ????????????, ????????±?\?

int main()
{
	scanf("%d %d %d", &M, &N, &K);
	//s[], d[][]????????????
	for (int i = 0; i < M * N; i++) {
		s[i] = false;
		d[i][0] = INF;
		d[i][1] = INF;
	}
	for (int i = 0; i < K; i++) {
		int x, y;
		scanf("%d %d", &x, &y);
		s[(y - 1)* M + x - 1] = true;
	}

	queue<P> que;
	que.push(P(0, 0));
	d[0][0] = 0;
	while (que.size()) {
		P p = que.front(); que.pop();
		int i = p.first; // ????????????
		if (p.second = 0) {
			if (s[i] == true && d[i][1] == INF) {
				d[i][1] = d[i][0] + 1;
				que.push(P(i, 1));
			}
			if ((i / M) > 0 && d[i - M][0] == INF) {
				d[i - M][0] = d[i][0] + 1;
				que.push(P(i - M, 0));
			}
			if ((i / M) < N - 1 && d[i + M][0] == INF) {
				d[i + M][0] = d[i][0] + 1;
				que.push(P(i + M, 0));
			}
		}
		else {
			if (s[i] == true && d[i][0] == INF) {
				d[i][0] = d[i][1] + 1;
				que.push(P(i, 0));
			}
			if (i % M > 0 && d[i - 1][1] == INF) {
				d[i - 1][1] = d[i][1] + 1;
				que.push(P(i - 1, 1));
			}
			if (i % M < M - 1 && d[i + 1][1] == INF) {
				d[i + 1][1] = d[i][1] + 1;
				que.push(P(i + 1, 1));
			}
		}
	}
	int ans = d[M * N - 1][0];
	if (ans > d[M * N - 1][1]) ans = d[M * N - 1][1];
	if (ans == INF) ans = -1;
	printf("%d", ans);
	return 0;
}

Compiler output:
a.cc:13:14: warning: integer overflow in expression of type 'int' results in '1410065408' [-Woverflow]
   13 | bool s[MAX_N * MAX_M];  //?????????????????????????????????
      |              ^
a.cc:13:14: error: size of array 's' exceeds maximum object size '9223372036854775807'
a.cc:15:13: warning: integer overflow in expression of type 'int' results in '1410065408' [-Woverflow]
   15 | int d[MAX_N * MAX_M][2]; // ???????????¢, ????????????, ????????±?\?
      |             ^
a.cc:15:13: error: size of array 'd' exceeds maximum object size '9223372036854775807'
Language: C++

#include <queue>
#include <vector>
#include <iostream>
using namespace std;
struct p1 {
	int idx, x, y;
};
bool operator<(const p1& r1, const p1& r2) {
	if (r1.y != r2.y) return r1.y < r2.y;
	return r1.x < r2.x;
}
struct edge {
	int to; long long cost; int type;
};
bool operator<(const edge& e1, const edge& e2) {
	return e1.cost < e2.cost;
}
int H, W, N;
int main() {
	cin >> W >> H >> N;
	vector<p1> p(N);
	for (int i = 0; i < N; i++) cin >> p[i].x >> p[i].y, p[i].x--, p[i].y--, p[i].idx = i;
	p.push_back(p1{ N, W - 1, H - 1 }); N++;
	vector<vector<p1> > ex(W), ey(H);
	for (int i = 0; i < N; i++) {
		ex[p[i].x].push_back(p[i]);
		ey[p[i].y].push_back(p[i]);
	}
	for (int i = 0; i < W; i++) sort(ex[i].begin(), ex[i].end());
	for (int i = 0; i < H; i++) sort(ey[i].begin(), ey[i].end());
	vector<vector<edge> > G(N);
	for (int i = 0; i < W; i++) {
		for (int j = 1; j < ex[i].size(); j++) {
			int d = ex[i][j].y - ex[i][j - 1].y;
			G[ex[i][j - 1].idx].push_back(edge{ ex[i][j].idx, d, 0 });
			G[ex[i][j].idx].push_back(edge{ ex[i][j - 1].idx, d, 0 });
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 1; j < ey[i].size(); j++) {
			int d = ey[i][j].x - ey[i][j - 1].x;
			G[ey[i][j - 1].idx].push_back(edge{ ey[i][j].idx, d, 1 });
			G[ey[i][j].idx].push_back(edge{ ey[i][j - 1].idx, d, 1 });
		}
	}
	priority_queue<edge> que;
	vector<long long> dist(N, -1);
	if (ex[0].size()) {
		que.push(edge{ ex[0][0].idx, ex[0][0].y, 0 });
		dist[ex[0][0].idx] = ex[0][0].y;
	}
	while (!que.empty()) {
		edge u = que.top(); que.pop();
		for (edge e : G[u.to]) {
			long long d = u.cost;
			if (e.type == 0) d += abs(p[u.to].y - p[e.to].y);
			else d += abs(p[u.to].x - p[e.to].x);
			if (u.type != e.type) d++;
			if (dist[e.to] > d || dist[e.to] == -1) {
				dist[e.to] = d;
				que.push(edge{ e.to, d, e.type });
			}
		}
	}
	cout << dist[N - 1] << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:37: error: 'sort' was not declared in this scope; did you mean 'short'?
   29 |         for (int i = 0; i < W; i++) sort(ex[i].begin(), ex[i].end());
      |                                     ^~~~
      |                                     short
a.cc:30:37: error: 'sort' was not declared in this scope; did you mean 'short'?
   30 |         for (int i = 0; i < H; i++) sort(ey[i].begin(), ey[i].end());
      |                                     ^~~~
      |                                     short
Language: C++

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define int long long
#define MP make_pair
#define PB push_back
#define FI first
#define SE second
#define MAX_K 200000
typedef pair<int, int> PII;
static const int INF = INT_MAX;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };

int M, N, K;
vector<PII> fld;
int dp[MAX_K + 5][2];

int dfs(int n, int on){
    //cout << fld[n].FI << " " << fld[n].SE << endl;
	if (fld[n].FI == M&&fld[n].SE == N)return 0;
	int res = INF;
	int p1,p2;
	int p1 = on ? lower_bound(fld.begin(), fld.end(), MP(fld[n].FI, -INF)) - fld.begin() : lower_bound(fld.begin(), fld.end(), MP(-INF, fld[n].SE)) - fld.begin();
	int p2 = on ? upper_bound(fld.begin(), fld.end(), MP(fld[n].FI, INF)) - fld.begin() : upper_bound(fld.begin(), fld.end(), MP(INF, fld[n].SE)) - fld.begin();
	cout<<p1<<" "<<p2<<" "<<fld[n].FI<<endl;
	if (on && fld[p1].FI != fld[n].FI || (!on) && fld[p1].SE != fld[n].SE)return INF;
	if(on && fld[p1].FI != fld[p2].FI || (!on) && fld[p1].SE != fld[p2].SE)return INF;
	for (int i = p1; i <= p2; ++i){
		if (i == n)continue;
		if (fld[i].FI <= fld[n].FI && fld[i].SE <= fld[n].SE)continue;
		int dis = fld[i].FI - fld[n].FI + fld[i].SE - fld[n].SE;
		res = min(dfs(i, !on) + (dis + 1), min(dfs(i, on) + dis, res));
	}
	return res;
}


signed main(){
	cin >> M >> N >> K;
	fld.PB(PII(1, 1));
	fld.PB(PII(M, N));
	for (int i = 0; i < K; ++i){
		int x, y;
		cin >> x >> y;
		fld.PB(PII(x, y));
	}
	sort(fld.begin(), fld.end());
	cout << dfs(0, 1) << endl;
	cout << "Finish" << endl;
	return 0;
}

Compiler output:
a.cc: In function 'long long int dfs(long long int, long long int)':
a.cc:41:13: error: redeclaration of 'long long int p1'
   41 |         int p1 = on ? lower_bound(fld.begin(), fld.end(), MP(fld[n].FI, -INF)) - fld.begin() : lower_bound(fld.begin(), fld.end(), MP(-INF, fld[n].SE)) - fld.begin();
      |             ^~
a.cc:40:13: note: 'long long int p1' previously declared here
   40 |         int p1,p2;
      |             ^~
a.cc:42:13: error: redeclaration of 'long long int p2'
   42 |         int p2 = on ? upper_bound(fld.begin(), fld.end(), MP(fld[n].FI, INF)) - fld.begin() : upper_bound(fld.begin(), fld.end(), MP(INF, fld[n].SE)) - fld.begin();
      |             ^~
a.cc:40:16: note: 'long long int p2' previously declared here
   40 |         int p1,p2;
      |                ^~
Language: C++

#include<bits/stdc++.h>
#define INF 0x3f3f3f3f3f3f3f3f
#define rep(i,n)for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long ll;
  
ll d[200000][2];
int x[200000],y[200000];
vector<int>X[100000],Y[100000];
struct st{
    int p;bool b;ll c;
};
bool operator<(const st&a,const st&b){
    return a.c>b.c;
}
int main() {
    int m,n,k;scanf("%d%d%d",&m,&n,&k);
    priority_queue<st>que;
    memset(d,0x3f,sizeof(d));
    rep(i,m)x[i].resize(2000);
    rep(i,n)y[i].resize(2000);
    rep(i,k){
        scanf("%d%d",&x[i],&y[i]);x[i]--;y[i]--;
        X[x[i]].push_back(i);Y[y[i]].push_back(i);
        if(x[i]==0){
			d[i][1]=y[i];
			que.push({i,1,d[i][1]});
		}
    }
    ll Min=INF;
    while(!que.empty()){
        st p=que.top();que.pop();
        if(d[p.p][p.b]!=p.c)continue;
        if(x[p.p]==m-1){
			Min=min(Min,d[p.p][1]+abs(y[p.p]-n+1));
			Min=min(Min,d[p.p][0]+1+abs(y[p.p]-n+1));
		}
		if(y[p.p]==n-1){
			Min=min(Min,d[p.p][0]+abs(x[p.p]-m+1));
			Min=min(Min,d[p.p][1]+1+abs(x[p.p]-m+1));
		}
        if(p.b){
            for(int&u:X[x[p.p]]){
                if(d[u][1]>p.c+abs(y[p.p]-y[u])){
                    d[u][1]=p.c+abs(y[p.p]-y[u]);
                    que.push({u,1,d[u][1]});
                }
            }
            for(int&u:Y[y[p.p]]){
                if(d[u][0]>p.c+abs(x[p.p]-x[u])+1){
                    d[u][0]=p.c+abs(x[p.p]-x[u])+1;
                    que.push({u,0,d[u][0]});
                }
            }
        }
        else{
            for(int&u:X[x[p.p]]){
                if(d[u][1]>p.c+abs(y[p.p]-y[u])+1){
                    d[u][1]=p.c+abs(y[p.p]-y[u])+1;
                    que.push({u,1,d[u][1]});
                }
            }
            for(int&u:Y[y[p.p]]){
                if(d[u][0]>p.c+abs(x[p.p]-x[u])){
                    d[u][0]=p.c+abs(x[p.p]-x[u]);
                    que.push({u,0,d[u][0]});
                }
            }
        }
    }
    if(Min==INF)puts("-1");
    else printf("%lld\n",Min);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:18: error: request for member 'resize' in 'x[i]', which is of non-class type 'int'
   20 |     rep(i,m)x[i].resize(2000);
      |                  ^~~~~~
a.cc:21:18: error: request for member 'resize' in 'y[i]', which is of non-class type 'int'
   21 |     rep(i,n)y[i].resize(2000);
      |                  ^~~~~~
Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<functional>
#include<list>
#include<map>
#define P pair<int,int>
#define int long long
#define INF LLONG_MAX/3
using namespace std;

vector<P>rinsetu[250000];//cost to
int mincost[250000];
signed main() {
	int a, b, c; cin >> b >> a >> c; a--; b--;
	map<int, vector<P>>n, m;
	for (int d = 0; d < c; d++) {
		int e, f; scanf("%lld%lld", &f, &e); e--; f--;
		n[e].push_back(P(f,d*2));
		m[f].push_back(P(e,d*2+1));
		rinsetu[d*2].push_back(P(1,d*2+1));
		rinsetu[d*2+1].push_back(P(1,d*2));
	}
	m[0].push_back(P(0,c*2));
	n[a].push_back(P(b,c*2+1));
	m[b].push_back(P(a,c*2+1));
	for (auto k = n.begin(); k != n.end(); k++) {
		vector<P>r = k->second;
		if (r.size() > 1) {
			sort(r.begin(), r.end());
			for (int ttt = 1; ttt < r.size(); ttt++) {
				rinsetu[r[ttt].second].push_back(P(r[ttt].first-r[ttt-1].first,r[ttt-1].second));
				rinsetu[r[ttt-1].second].push_back(P(r[ttt].first - r[ttt - 1].first, r[ttt].second));
			}
		}
	}
	for (auto k = m.begin(); k != m.end(); k++) {
		vector<P>r = k->second;
		if (r.size() > 1) {
			sort(r.begin(), r.end());
			for (int ttt = 1; ttt < r.size(); ttt++) {
				rinsetu[r[ttt].second].push_back(P(r[ttt].first - r[ttt - 1].first, r[ttt - 1].second));
				rinsetu[r[ttt - 1].second].push_back(P(r[ttt].first - r[ttt - 1].first, r[ttt].second));
			}
		}
	}
	fill(mincost, mincost + c * 2 + 2, INF);
	priority_queue<P, vector<P>, greater<P>>Q;
	mincost[c * 2] = 0;
	Q.push(P(0,c*2));
	while (Q.size()) {
		P t = Q.top(); Q.pop();
		if (t.first > mincost[t.second])continue;
		for (P i : rinsetu[t.second]) {
			if (mincost[i.second] > mincost[t.second] + i.first) {
				mincost[i.second] = mincost[t.second] + i.first;
				Q.push(P(mincost[i.second],i.second));
			}
		}
	}
	if (mincost[c * 2 + 1] == INF)puts("-1");
	else cout << mincost[c * 2 + 1] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:13: error: 'LLONG_MAX' was not declared in this scope
   14 | #define INF LLONG_MAX/3
      |             ^~~~~~~~~
a.cc:52:44: note: in expansion of macro 'INF'
   52 |         fill(mincost, mincost + c * 2 + 2, INF);
      |                                            ^~~
a.cc:12:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   11 | #include<map>
  +++ |+#include <climits>
   12 | #define P pair<int,int>
Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<functional>
#include<list>
#include<map>
#define P pair<int,int>
#define int long long
#define INF LLONG_MAX/3
using namespace std;

vector<P>rinsetu[1000000];//cost to
int mincost[1000000];
signed main() {
	int a, b, c; cin >> b >> a >> c; a--; b--;
	map<int, vector<P>>n, m;
	for (int d = 0; d < c; d++) {
		int e, f; scanf("%lld%lld", &f, &e); e--; f--;
		n[e].push_back(P(f,d*2));
		m[f].push_back(P(e,d*2+1));
		rinsetu[d*2].push_back(P(1,d*2+1));
		rinsetu[d*2+1].push_back(P(1,d*2));
	}
	m[0].push_back(P(0,c*2));
	n[a].push_back(P(b,c*2+1));
	m[b].push_back(P(a,c*2+1));
	for (auto k = n.begin(); k != n.end(); k++) {
		vector<P>r = k->second;
		if (r.size() > 1) {
			sort(r.begin(), r.end());
			for (int ttt = 1; ttt < r.size(); ttt++) {
				rinsetu[r[ttt].second].push_back(P(r[ttt].first-r[ttt-1].first,r[ttt-1].second));
				rinsetu[r[ttt-1].second].push_back(P(r[ttt].first - r[ttt - 1].first, r[ttt].second));
			}
		}
	}
	for (auto k = m.begin(); k != m.end(); k++) {
		vector<P>r = k->second;
		if (r.size() > 1) {
			sort(r.begin(), r.end());
			for (int ttt = 1; ttt < r.size(); ttt++) {
				rinsetu[r[ttt].second].push_back(P(r[ttt].first - r[ttt - 1].first, r[ttt - 1].second));
				rinsetu[r[ttt - 1].second].push_back(P(r[ttt].first - r[ttt - 1].first, r[ttt].second));
			}
		}
	}
	fill(mincost, mincost + c * 2 + 2, INF);
	priority_queue<P, vector<P>, greater<P>>Q;
	mincost[c * 2] = 0;
	Q.push(P(0,c*2));
	while (Q.size()) {
		P t = Q.top(); Q.pop();
		if (t.first > mincost[t.second])continue;
		for (P i : rinsetu[t.second]) {
			if (mincost[i.second] > mincost[t.second] + i.first) {
				mincost[i.second] = mincost[t.second] + i.first;
				Q.push(P(mincost[i.second],i.second));
			}
		}
	}
	if (mincost[c * 2 + 1] == INF)puts("-1");
	else cout << mincost[c * 2 + 1] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:13: error: 'LLONG_MAX' was not declared in this scope
   14 | #define INF LLONG_MAX/3
      |             ^~~~~~~~~
a.cc:52:44: note: in expansion of macro 'INF'
   52 |         fill(mincost, mincost + c * 2 + 2, INF);
      |                                            ^~~
a.cc:12:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   11 | #include<map>
  +++ |+#include <climits>
   12 | #define P pair<int,int>
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define pb push_back
#define Rep(i, N) for(int i = 0; i < N; i++)
#define INF 1 << 28
#define LLINF 1LL << 60
typedef pair<int,int> Pi;
typedef pair<int,Pi> Ti;

struct Edge {
  int to, cost;
};

int sz[2], K;
vector<Edge> G[2][200005];
int mc[2][200005];

void Dijkstra()
{
  priority_queue<Ti, vector<Ti>, greater<Ti> >pq;
  mc[0][0] = 0;
  pq.push(Ti(0, Pi(0, 0)));
  while(!pq.empty()) {
    int v = pq.top().S.F, w = pq.top().F, t = pq.top().S.S; pq.pop();
    if(w > mv[t][v]) continue;
    Rep(i, G[t][v].size()) {
      int u = G[t][v][i].to, nw = G[t][v][i].cost + w, nnw = nw;
      if(u != K + 1) nnw++;
      if(nnw < mc[1 - t][u]) {
	mc[1 - t][u] = nnw;
	pq.push(Ti(nnw, Pi(u, 1 - t)));
      }
      if(nw < mc[t][u]) {
	mc[t][u] = nw;
	pq.push(Ti(nw, Pi(u, t)));
      }
    }
  }
}
	  
signed main()
{
  int X, Y;
  vector<Pi> len[2][100006];

  cin >> sz[0] >> sz[1] >> K;
  len[0][1].pb(Pi(0, 0));
  for(int i = 1; i <= K; i++) {
    cin >> X >> Y;
    len[0][X].pb(Pi(Y, i));
    len[1][Y].pb(Pi(X, i));
  }
  len[0][sz[0]].pb(Pi(sz[1], K + 1));
  len[1][sz[1]].pb(Pi(sz[0], K + 1));
  
  Rep(i, 2) {
    Rep(j, sz[i] + 1) {
      sort(len[i][j].begin(), len[i][j].end());
      Rep(k,len[i][j].size()) {
	Pi v = len[i][j][k];
	if(k - 1 >= 0) {
	  Pi u = len[i][j][k - 1];
	  G[i][v.S].pb((Edge){ u.S, v.F - u.F });
	}
	if(k + 1 < len[i][j].size()) {
	  Pi u = len[i][j][k + 1];
	  G[i][v.S].pb((Edge){ u.S, u.F - v.F });
	}
      }
    }
  }

  fill_n(*mc, 2 * 200005, LLINF);
  Dijkstra();
  
  int ans = min(mc[0][K + 1], mc[1][K + 1]);
  if(ans == LLINF) cout << -1 << endl;
  else cout << ans - 1 << endl;
  
  return 0;
}

Compiler output:
a.cc: In function 'void Dijkstra()':
a.cc:28:12: error: 'mv' was not declared in this scope; did you mean 'v'?
   28 |     if(w > mv[t][v]) continue;
      |            ^~
      |            v
Language: C++

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

#define fi first
#define se second

const int inf = 1e9 + 9;

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

struct edge
{
  edge() {}
  edge (int t, int v, int c) { to = t; f = v; cost = c; }
  int to, f, cost;
};

int h, w, k;
vector<PP> a, b;
vector<edge> G[2][202020];
int d[2][202020];

void dijkstra(int s, int po)
{
  for (int i = 0; i < 202020; i++){
    d[0][i] = d[1][i] = inf;
  }
  priority_queue<PP, vector<PP>, greater<PP> > q;

  d[0][s] = 0;
  q.push(PP(0, P(s, 0)));

  while (!q.empty()){
    PP p = q.top(); q.pop();
    int v = p.se.fi;
    int f = p.se.se;

    for (int i = 0; i < G[f][v].size(); i++){
      edge e = G[f][v][i];
      if (d[e.f][e.to] > d[f][v] + e.cost){
        d[e.f][e.to] = d[f][v] + e.cost;
        q.push(PP(d[e.f][e.to], P(e.to, e.f)));
      }
    }
  }
}

int main()
{
  bool izryt = false, _izryt = false;
  cin >> w >> h >> k;
  for (int i = 1; i <= k; i++){
    int x, y;
    cin >> x >> y;
    x--; y--;
    if (x == 0 && y == 0){
      a.push_back(PP(x, P(y, 0)));
      b.push_back(PP(y, P(x, 0)));
      G[0][0].push_back(edge(0, 1, 1));
      G[1][0].push_back(edge(0, 0, 1));
      izryt = true;
    }
    else if (x + 1 == w && y + 1 == h){
      a.push_back(PP(x, P(y, k + 1)));
      b.push_back(PP(y, P(x, k + 1)));
      G[0][k + 1].push_back(edge(k + 1, 1, 1));
      G[1][k + 1].push_back(edge(k + 1, 0, 1));
      _izryt = true;
    }
    else {
      a.push_back(PP(x, P(y, i)));
      b.push_back(PP(y, P(x, i)));
      G[0][i].push_back(edge(i, 1, 1));
      G[1][i].push_back(edge(i, 0, 1));
    }
  }

  if (!izryt) a.push_back(PP(0, P(0, 0)));
  if (!_izryt) b.push_back(PP(h - 1, P(w - 1, k + 1)));

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());

  for (int i = 0; i < a.size() - 1; i++){
    if (a[i].fi == a[i + 1].fi && a[i].se.fi != a[i + 1].se.fi){
      G[0][a[i].se.se].push_back(edge(a[i + 1].se.se, 0, abs(a[i].se.fi - a[i + 1].se.fi)));
      G[0][a[i + 1].se.se].push_back(edge(a[i].se.se, 0, abs(a[i].se.fi - a[i + 1].se.fi)));
    }
  }

  for (int i = 0; i < b.size() - 1; i++){
    if (b[i].fi == b[i + 1].fi && b[i].se.fi != b[i + 1].se.fi){
      G[1][b[i].se.se].push_back(edge(b[i + 1].se.se, 1, abs(b[i].se.fi - b[i + 1].se.fi)));
      G[1][b[i + 1].se.se].push_back(edge(b[i].se.se, 1, abs(b[i].se.fi - b[i + 1].se.fi)));
    }
  }

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

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define INF_LL 1e18
#define INF 1e9

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()

#define fst first
#define snd second

using namespace std;

using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
using PLLL = pair<ll, PLL >;

ll MOD = 1e9+7;
int M, N, K;
vector<PII> X[114514], Y[114514];
vector<PII> G[114514][2];
ll d[114514][2];
int g_n = -1;
int th_s_s = 0; // 0,0??????????????????????????????????????????

int main(void){
	cin >> M >> N >> K;
	REP(i, 114514){
		REP(j, 2){
			d[i][j] = INF_LL;
		}
	}
	REP(i, K){
		int x, y;
		cin >> x >> y; x--; y--;
		X[x].push_back({y, i+1});
		Y[y].push_back({x, i+1});
		if(x == M-1 && y == N-1){
			g_n = i+1;
		}
		if(x == 0 && y == 0)
			th_s_s = 1;
	}
	if(g_n == -1){
		X[M-1].push_back({N-1, K+1});
		Y[N-1].push_back({M-1, K+1});
		g_n = K+1;
	}

	REP(i, M){
		REP(j, X[i].size()){
			REP(k, X[i].size()){
				if(j == k) continue;
				G[X[i][j].second][0].push_back({abs(X[i][j].first-X[i][k].first), X[i][k].second});
			}
		}
	}

	REP(i, N){
		REP(j, Y[i].size()){
			REP(k, Y[i].size()){
				if(j == k) continue;
				G[Y[i][j].second][1].push_back({abs(Y[i][j].first-Y[i][k].first), Y[i][k].second});
			}
		}
	}

	//priority_queue<pair<ll, pair<int, int> >, vector<pair<ll, pair<int, int> > >, greater<pair<ll, pair<int, int> > > > pq;
	d[0][0] = 0;
	REP(i, X[0].size()){
		d[X[0][i].second][0] = X[0][i].first;
		d[X[0][i].second][1] = min(d[X[0][i].second][1], (ll)X[0][i].first+1);
		pq.push({X[0][i].first+1, {X[0][i].second, 1}});
	}
	if(th_s_s){
		REP(i, Y[0].size()){
			d[Y[0][i].second][1] = Y[0][i].first+1;
			d[Y[0][i].second][0] = min(d[Y[0][i].second][0], (ll)Y[0][i].first+2);
			pq.push({Y[0][i].first+1, {Y[0][i].second, 0}});
		}
	}
	while(pq.size()){
		pair<ll, pair<int, int> > p = pq.top(); pq.pop();
		int v = p.second.first, s = p.second.second;

		if(d[v][s] < p.first) continue;
		REP(i, G[v][s].size()){
			if(d[G[v][s][i].second][s] > d[v][s] + G[v][s][i].first){
				d[G[v][s][i].second][s] = d[v][s] + G[v][s][i].first;
				d[G[v][s][i].second][(s+1)%2] = min(d[G[v][s][i].second][(s+1)%2], d[G[v][s][i].second][s]+1);
				pq.push({d[G[v][s][i].second][(s+1)%2], {G[v][s][i].second, (s+1)%2}});
			}
		}
	}
	if(d[g_n][0] == INF_LL && d[g_n][1] == INF_LL){
		cout << -1 << endl;
	}else{
		cout << min(d[g_n][0], d[g_n][1]) << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:88:17: error: 'pq' was not declared in this scope
   88 |                 pq.push({X[0][i].first+1, {X[0][i].second, 1}});
      |                 ^~
a.cc:94:25: error: 'pq' was not declared in this scope
   94 |                         pq.push({Y[0][i].first+1, {Y[0][i].second, 0}});
      |                         ^~
a.cc:97:15: error: 'pq' was not declared in this scope
   97 |         while(pq.size()){
      |               ^~
Language: C++

#include <iostream>
#include <queue>
#include <vector>
#include <set>
#include <algorithm>
#define INF 1001001001001001001
using namespace std;
typedef long long ll;
typedef pair<int,int> pa;
typedef pair<ll,pa > ppa;

vector<pa> ve[2][100010];
int swi[2][200010];
ll res[2][200010];
int main(){
	int M,N,K;
	cin>>M>>N>>K;
	int a,b,aa;
	bool fla;
	for(int i=1;i<=K;i++){
		cin>>a>>b;
		ve[0][a].push_back(pa(i,b));
		ve[1][b].push_back(pa(i,a));
		swi[0][i]=a;swi[1][i]=b;
		if(a==1&&b==1){
			fla=true;
			aa=i;
		}
	}
	for(int i=0;i<2;i++){
		fill(res[i],res[i]+1+K,INF);
	}

	priority_queue<ppa> que;
	for(vector<pa>::iterator it=ve[0][1].begin();it!=ve[0][1].end();it++){
		que.push(ppa(it->second-1,pa(1,it->first)));
	}
	if(fla){
		res[0][aa]=0;
	}
	while(!que.empty()){
		ll dis=que.top().first;
		int yota=que.top().first.first;
		int ten=que.top().first.second;
//??????

Compiler output:
a.cc: In function 'int main()':
a.cc:43:42: error: request for member 'first' in 'que.std::priority_queue<std::pair<long long int, std::pair<int, int> > >::top().std::pair<long long int, std::pair<int, int> >::first', which is of non-class type 'const long long int'
   43 |                 int yota=que.top().first.first;
      |                                          ^~~~~
a.cc:44:41: error: request for member 'second' in 'que.std::priority_queue<std::pair<long long int, std::pair<int, int> > >::top().std::pair<long long int, std::pair<int, int> >::first', which is of non-class type 'const long long int'
   44 |                 int ten=que.top().first.second;
      |                                         ^~~~~~
a.cc:44:48: error: expected '}' at end of input
   44 |                 int ten=que.top().first.second;
      |                                                ^
a.cc:41:28: note: to match this '{'
   41 |         while(!que.empty()){
      |                            ^
a.cc:44:48: error: expected '}' at end of input
   44 |                 int ten=que.top().first.second;
      |                                                ^
a.cc:15:11: note: to match this '{'
   15 | int main(){
      |           ^
Language: C++

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

int main (){
  string str;
  int n,jcnt=0,ocnt=0,icnt=0,joicnt=0,ioicnt=0,ans=0;
  cin>>n;
  cin>>str;
  for(int i=0;i<n;i++){
    if(str[i]=='J') jcnt++;
    else if(str[i]=='I'){
      if(joicnt || ioicnt && ocnt==0 ) ans++; 
      if(jcnt && ocnt) joicnt++,jcnt--,ocnt--,icnt++;
      if(ocnt && icnt) ocnt--,ioicnt++;
      else icnt++
    }
    else if(jcnt+icnt>ocnt) ocnt++;
  }
  ans+=joicnt+ioicnt-joicnt/2;
  
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:18: error: expected ';' before '}' token
   16 |       else icnt++
      |                  ^
      |                  ;
   17 |     }
      |     ~
Language: C++

#include <iostream>
using namespace std;

//J=0,O=1,I=2
int N;
int ary[1000010];

int joichec(int numJ,int numI,int& fla){
	int cntJ=0,cntJO=0,cntJOI=0;
	int cntI=0,cntOI=0,cntJOI2=0;
	for(int i=0;i<N;i++){
		switch(ary[i]){
			case 0:
				cntJ++;
				break;
			case 1:
				if(cntJ>0){
					cntJ--;
					cntJO++;
				}
				break;
			case 2:
				if(numJ>0){
					numJ--;
					cntJ++;
				}
				else{
					if(cntJO>0){
						cntJO--;
						cntJOI++;
					}
				}
				break;
		}
	}
	for(int i=N-1;i>=0;i--){
		switch(ary[i]){
			case 0:
				if(cntOI>0){
					cntOI--;
					cntJOI2++;
				}
				break;
			case 1:
				if(cntI>0){
					cntI--;
					cntOI++;
				}
				break;
			case 2:
				if(numI>0){
					numI--;
					cntI++;
				}
				else{
					if(cntOI>0){
						cntOI--;
						cntJOI2++;
					}
				}
				break;
		}
	}
	if(cntJO>cntOI) fla=-1;
	else if(cntJO<cntOI) fla=1;
	else fla=0;
	//cout<<cntJ<<" "<<cntJO<<" "<<cntJOI<<" "<<cntI<<" "<<cntOI<<" "<<cntJOI2<<endl;//debug
	return cntJOI;
}

int main(){
	int numofI=0;
	char tmp;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>tmp;
		switch(tmp){
			case 'J':
				ary[i]=0;
				break;
			case 'O':
				ary[i]=1;
				break;
			case 'I':
				ary[i]=2;
				numofI++;
				break;
		}
	}

	/*
	int lb=0,rb=numofI,mid,hog,piy;
	hog=0;
	bool flaa=false;
	//while(rb-lb>0&&(!flaa)){
	for(int i=0;i<25;i++){
		if(rb-lb==1) flaa=true;
		mid=(lb+rb)/2;
		hog=joichec(mid,numofI-mid,piy);
		//cout<<"hog="<<hog<<" mid="<<mid<<" lb="<<lb<<" rb="<<rb<<endl;//debug
		if(piy==-1)rb=(mid-1);
		else if(piy==1)lb=(mid+1);
		else break;
	}
	cout<<hog<<endl;
	*/
	int hog,flaa;
	for(int i=0;i<=numofI,i++){
		hog=max(hog,joichec(i,numofI-i,flaa);
	}
	cout<<hog<<endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:108:34: error: expected ';' before ')' token
  108 |         for(int i=0;i<=numofI,i++){
      |                                  ^
      |                                  ;
a.cc:109:53: error: expected ')' before ';' token
  109 |                 hog=max(hog,joichec(i,numofI-i,flaa);
      |                        ~                            ^
      |                                                     )