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

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

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

const int INF = 100000000;
const int MAX_V = 100;
int graph[MAX_V][MAX_V];
int N, k;

bool visited[MAX_V];
int cost[MAX_V];

void init_graph() {
    REP(i, N) {
        REP(j, N) {
            if (i == j) graph[i][j] = 0;
            else        graph[i][j] = INF;
        }
    }
}

void solve() {

    while (true) {
        scanf("%d %d", &N, &k);

        if (N == 0 and k == 0)
            break;

        init_graph();

        REP(_, k) {
            int mode;
            scanf("%d", &mode);
            if (mode == 0) {
                int a, b;
                scanf("%d %d", &a, &b);
                a--; b--;
            } else {
                int c, d, e;
                scanf("%d %d %d", &c, &d, &e);
                c--; d--;
                make_edge(c, d, e);

                if (c < graph[u][v]) {
                    graph[u][v] = graph[v][u] = c;
                    REP(i, N) {
                        REP(j, N) {
                            graph[i][j] = min(graph[i][j], graph[i][c] + graph[c][d] + graph[d][j]);
                            graph[i][j] = min(graph[i][j], graph[i][d] + graph[d][c] + graph[c][j]);
                        }
                    }
                }
            }
        }
    }
}

int main() {
    solve();
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:45:17: error: 'make_edge' was not declared in this scope
   45 |                 make_edge(c, d, e);
      |                 ^~~~~~~~~
a.cc:47:31: error: 'u' was not declared in this scope
   47 |                 if (c < graph[u][v]) {
      |                               ^
a.cc:47:34: error: 'v' was not declared in this scope
   47 |                 if (c < graph[u][v]) {
      |                                  ^
Language: C++

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

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

const int INF = 100000000;
const int MAX_V = 100;
int graph[MAX_V][MAX_V];
int N, k;

bool visited[MAX_V];
int cost[MAX_V];

void init_graph() {
    REP(i, N) {
        REP(j, N) {
            if (i == j) graph[i][j] = 0;
            else        graph[i][j] = INF;
        }
    }
}

void solve() {

    while (true) {
        scanf("%d %d", &N, &k);

        if (N == 0 and k == 0)
            break;

        init_graph();

        REP(_, k) {
            int mode;
            scanf("%d", &mode);
            if (mode == 0) {
                int a, b;
                scanf("%d %d", &a, &b);
                a--; b--;
            } else {
                int c, d, e;
                scanf("%d %d %d", &c, &d, &e);
                c--; d--;
                make_edge(c, d, e);
                if (c < graph[u][v]) {
                    graph[u][v] = graph[v][u] = c;
                    REP(i, N) {
                        REP(j, N) {
                            graph[i][j] = min(graph[i][j], graph[i][c] + graph[c][d] + graph[d][j]);
                            graph[i][j] = min(graph[i][j], graph[i][d] + graph[d][c] + graph[c][j]);
                        }
                    }
                }
            }
        }
    }
}

int main() {
    solve();
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:45:17: error: 'make_edge' was not declared in this scope
   45 |                 make_edge(c, d, e);
      |                 ^~~~~~~~~
a.cc:46:31: error: 'u' was not declared in this scope
   46 |                 if (c < graph[u][v]) {
      |                               ^
a.cc:46:34: error: 'v' was not declared in this scope
   46 |                 if (c < graph[u][v]) {
      |                                  ^
Language: C++

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

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

const int INF = 100000000;
const int MAX_V = 100;
int graph[MAX_V][MAX_V];
int N, k;

bool visited[MAX_V];
int cost[MAX_V];

void init_graph() {
    REP(i, N) {
        REP(j, N) {
            if (i == j) graph[i][j] = 0;
            else        graph[i][j] = INF;
        }
    }
}

void solve() {

    while (true) {
        scanf("%d %d", &N, &k);

        if (N == 0 and k == 0)
            break;

        init_graph();

        REP(_, k) {
            int mode;
            scanf("%d", &mode);
            if (mode == 0) {
                int a, b;
                scanf("%d %d", &a, &b);
                a--; b--;
            } else {
                int c, d, e;
                scanf("%d %d %d", &c, &d, &e);
                c--; d--;
                make_edge(c, d, e);
                if (e < graph[c][d]) {
                    graph[c][d] = graph[d][c] = e;
                    REP(i, N) {
                        REP(j, N) {
                            graph[i][j] = min(graph[i][j], graph[i][c] + graph[c][d] + graph[d][j]);
                            graph[i][j] = min(graph[i][j], graph[i][d] + graph[d][c] + graph[c][j]);
                        }
                    }
                }
            }
        }
    }
}

int main() {
    solve();
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:45:17: error: 'make_edge' was not declared in this scope
   45 |                 make_edge(c, d, e);
      |                 ^~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int dist[105],n,m,a,b,c,d;
queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> Q;
vector<pair<int,int>>x[105];
void add_edge(int a1,int a2,int a3){
	x[a1].push_back(make_pair(a2,a3));
	x[a2].push_back(make_pair(a1,a3));
}
int solve(int b1,int b2){
	for(int i=0;i<105;i++)dist[i]=100000000;dist[b1]=0;
	while(!Q.empty()){
		int a1=Q.front().first,a2=Q.front().second;Q.pop();
		for(int i=0;i<x[a2].size();i++){
			int to=x[a2][i].first,len=x[a2][i].second;
			if(dist[to]>a1+len){
				dist[to]=a1+len;
				Q.push(make_pair(dist[to],to));
			}
		}
	}
	if(dist[b2]==100000000)return -1;
	return dist[b2];
}
int main(){
	while(true){
		cin>>n>>m;for(int i=0;i<105;i++)x[i].clear();
		if(n==0 && m==0)break;
		for(int i=0;i<m;i++){
			cin>>a;if(a==0)break;
			if(a==0){cin>>b>>c;cout<<solve(b,c)<<endl;}
			if(a==1){cin>>b>>c>>d;add_edge(b,c,d);}
		}
	}
}

Compiler output:
a.cc:4:65: error: wrong number of template arguments (3, should be at least 1)
    4 | queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> Q;
      |                                                                 ^
In file included from /usr/include/c++/14/queue:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_queue.h:96:11: note: provided for 'template<class _Tp, class _Sequence> class std::queue'
   96 |     class queue
      |           ^~~~~
a.cc: In function 'int solve(int, int)':
a.cc:12:18: error: request for member 'empty' in 'Q', which is of non-class type 'int'
   12 |         while(!Q.empty()){
      |                  ^~~~~
a.cc:13:26: error: request for member 'front' in 'Q', which is of non-class type 'int'
   13 |                 int a1=Q.front().first,a2=Q.front().second;Q.pop();
      |                          ^~~~~
a.cc:13:62: error: request for member 'pop' in 'Q', which is of non-class type 'int'
   13 |                 int a1=Q.front().first,a2=Q.front().second;Q.pop();
      |                                                              ^~~
a.cc:14:33: error: 'a2' was not declared in this scope; did you mean 'a1'?
   14 |                 for(int i=0;i<x[a2].size();i++){
      |                                 ^~
      |                                 a1
a.cc:16:40: error: 'len' was not declared in this scope
   16 |                         if(dist[to]>a1+len){
      |                                        ^~~
a.cc:18:35: error: request for member 'push' in 'Q', which is of non-class type 'int'
   18 |                                 Q.push(make_pair(dist[to],to));
      |                                   ^~~~
Language: C++

#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <climits>
#include <functional>

using Pair = std::pair<int, int>;

struct Node {
	std::vector<Pair> edges;

	int minCost = std::numeric_limits<int>::max();
	bool done;
};

int main() {
	int n, k;

	while (std::cin >> n >> k, n + k != 0) {
		std::vector<Node> nodes(n);
		for (int i = 0; i < k; ++i) {
			int req;
			std::cin >> req;

			if (req == 1) {
				int c, d, e;
				std::cin >> c >> d >> e;

				nodes[c - 1].edges.push_back({ d - 1, e });
				nodes[d - 1].edges.push_back({ c - 1, e });
			}
			else {
				int a, b;
				std::cin >> a >> b;
				// first: cost, second: node
				std::priority_queue<Pair, std::vector<Pair>, std::greater<Pair>> que;
				que.push({ 0, a - 1 });

				while (!que.empty()) {
					const auto top = que.top();
					
					if (top.second == b - 1) {
						std::cout << top.first << std::endl;
						break;
					}

					que.pop();

					auto& now = nodes[top.second];
					if (now.done)
						continue;

					now.minCost = top.first;
					now.done = true;

					for (auto&& edge : now.edges)
						if (nodes[edge.first].done == false && nodes[edge.first].minCost > top.first + edge.second)
							que.push({ top.first + edge.second, edge.first });
				}

				if (que.empty())
					std::cout << -1 << std::endl;

				for (auto&& n : nodes) {
					n.done = false;
					n.minCost = std::numeric_limits<int>::max();
				}
			}
		}
	}
}

Compiler output:
a.cc:13:28: error: 'numeric_limits' is not a member of 'std'
   13 |         int minCost = std::numeric_limits<int>::max();
      |                            ^~~~~~~~~~~~~~
a.cc:13:43: error: expected primary-expression before 'int'
   13 |         int minCost = std::numeric_limits<int>::max();
      |                                           ^~~
a.cc: In function 'int main()':
a.cc:67:58: error: 'numeric_limits' is not a member of 'std'
   67 |                                         n.minCost = std::numeric_limits<int>::max();
      |                                                          ^~~~~~~~~~~~~~
a.cc:67:73: error: expected primary-expression before 'int'
   67 |                                         n.minCost = std::numeric_limits<int>::max();
      |                                                                         ^~~
Language: C++

3 8
1 3 1 10
0 2 3
1 2 3 20
1 1 2 5
0 3 2
1 1 3 7
1 2 1 9
0 2 3
5 16
1 1 2 343750
1 1 3 3343
1 1 4 347392
1 1 5 5497
1 2 3 123394
1 2 4 545492
1 2 5 458
1 3 4 343983
1 3 5 843468
1 4 5 15934
0 2 1
0 4 1
0 3 2
0 4 2
0 4 3
0 5 3
0 0

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

#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n,m,a[101][101];
  while(cin>>n>>m,n){
    r(i,n)r(j,n)a[i][j]=(i==j)?0:1e9;
    while(m--){
      int t,q,w,e;
      cin>>t;
      if(t){
        cin>>q>>w>>e;
        if(a[--q][--w]>e){
          a[q][w]=a[w][q]=e;
          r(i,n)r(j,n)
            a[i][j]=min(a[i][j],min(a[i][q]+a[q][w]+a[w][j],a[j][q]+a[q][w]+a[w][i]));
        }
      }
      else{
        cin>>q>>w;
        if(a[--q][--w]!=1e9)cout<<a[q][w]<<endl;
        else cout<<(-1)<<endl;
      }
    }
  }

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

#include <iostream>
#include <vector>
#include <cstring>
#include <queue>
#include <utility>
#include <algorithm>
#define INF 700000000

using namespace std;

vector<pair<int, int>> adj[110];

int solve (int x, int d)
{
    int dst[110];
    bool done[110];
    priority_queue<pair<int, int>> que;
    for (int i=0; i<110; i++) dst[i]=INF;
    memset(done, false, sizeof(done));
    dst[x]=0;
    que.push({0,x});
    while (!que.empty())
    {
        int a=que.top().second;
        que.pop();
        if (done[a]) continue;
        done[a]=true;
        for (auto u : adj[a])
        {
            int b=u.first, w=u.second;
            if (dst[a]+w<dst[b])
            {
                dst[b]=dst[a]+w;
                que.push({-dst[b], b});
            }
        }
    }
    if (dst[d]==INF) return -1;
    else return dst[d];
}

int main()
{
    while (1)
    {
        adj.clear();
        int n, k, a, b, c, d;
        bool ok;
        cin>>n>>k;
        if (n==0 && k==0) break;
        for (int i=0; i<k; i++)
        {
            cin>>a>>b>>c;
            if (a==0)
            {
                cout<<solve(b,c)<<'\n';
            }
            else
            {
                cin>>d;
                ok=true;
                for (auto itr=adj[b].begin(); itr!=adj[b].end(); itr++)
                {
                    if (itr->first==c)
                    {
                        itr->second=min(itr->second, d);
                        ok=false;
                    }
                }
                if (ok) adj[b].push_back({c,d});
                ok=true;
                for (auto itr=adj[c].begin(); itr!=adj[c].end(); itr++)
                {
                    if (itr->first==b)
                    {
                        itr->second=min(itr->second, d);
                        ok=false;
                    }
                }
                if (ok) adj[c].push_back({b,d});
            }
        }
        return 0;
    }
}



Compiler output:
a.cc: In function 'int main()':
a.cc:46:13: error: request for member 'clear' in 'adj', which is of non-class type 'std::vector<std::pair<int, int> > [110]'
   46 |         adj.clear();
      |             ^~~~~
Language: C++

#include <iostream>
//#include <vector>

using namespace std;

#define INF 1000001 

int main(){

	int n , k , x , y;
	cin >> n >> k;
	int judge;

	if (n == 0 && k == 0) break;
	
	int shima[n][n];

	for (int i=0 ; i < n ; i++){
		for (int j=0 ; j < n ; j++){
			shima[i][j] = INF;
			if (i == j)shima[i][j] = 0;
 		}
	}

	for (int i=0 ; i < k ; i++){

		cin >> judge;
		if (judge == 1){

			cin >> x >> y >> cost;

			if (shima[x][y] > cost){
				shima[x][y] = cost;
				shima[y][x] = cost;
			}

		for(int i=0; i < n ; i++){
			for(int j=0 ; j < n ; j++){
				if (shima[i][j] > shima[i][x] + shima[x][y] + shima[y][j]){
					shima[i][j] = shima[i][x] + shima[x][y] + shima[y][j]);
				}
			}
		}	

		}else if (judge == 0){
			cin >> x >> y;
			if (shima[x][y] == INF) {
				cout << -1 << endl;
			}
			else{
				cout << shima[x][y] << endl;
			}
		}
		//cout << cost;
	}
}



Compiler output:
a.cc: In function 'int main()':
a.cc:14:31: error: break statement not within loop or switch
   14 |         if (n == 0 && k == 0) break;
      |                               ^~~~~
a.cc:30:42: error: 'cost' was not declared in this scope; did you mean 'const'?
   30 |                         cin >> x >> y >> cost;
      |                                          ^~~~
      |                                          const
a.cc:40:94: error: expected ';' before ')' token
   40 |                                         shima[i][j] = shima[i][x] + shima[x][y] + shima[y][j]);
      |                                                                                              ^
      |                                                                                              ;
Language: C++


#include <iostream>
//#include <vector>

using namespace std;

#define INF 1000001 

int main(){

	int n , k , x , y;
	cin >> n >> k;
	int judge;

	if (n == 0 && k == 0) break;
	
	int shima[n][n];

	for (int i=0 ; i < n ; i++){
		for (int j=0 ; j < n ; j++){
			shima[i][j] = INF;
			if (i == j)shima[i][j] = 0;
 		}
	}

	for (int i=0 ; i < k ; i++){

		cin >> judge;
		if (judge == 1){

			cin >> x >> y >> cost;

			if (shima[x][y] > cost){
				shima[x][y] = cost;
				shima[y][x] = cost;
			}

		for(int j=0; j < n ; j++){
			for(int l=0 ; l < n ; l++){
				if (shima[j][l] > shima[j][x] + shima[x][y] + shima[y][l]){
					shima[j][l] = shima[j][x] + shima[x][y] + shima[y][l]);
				}
			}
		}	

		}else if (judge == 0){
			cin >> x >> y;
			if (shima[x][y] == INF) {
				cout << -1 << endl;
			}
			else{
				cout << shima[x][y] << endl;
			}
		}
		//cout << cost;
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:31: error: break statement not within loop or switch
   15 |         if (n == 0 && k == 0) break;
      |                               ^~~~~
a.cc:31:42: error: 'cost' was not declared in this scope; did you mean 'const'?
   31 |                         cin >> x >> y >> cost;
      |                                          ^~~~
      |                                          const
a.cc:41:94: error: expected ';' before ')' token
   41 |                                         shima[j][l] = shima[j][x] + shima[x][y] + shima[y][l]);
      |                                                                                              ^
      |                                                                                              ;
Language: C++

#include <iostream>
//#include <vector>

using namespace std;

#define INF 1000001 

int main(){

	int n , k , x , y;
	cin >> n >> k;
	int judge;
	
	int shima[n][n];

	for (int i=0 ; i < n ; i++){
		for (int j=0 ; j < n ; j++){
			shima[i][j] = INF;
			if (i == j)shima[i][j] = 0;
 		}
	}

	for (int i=0 ; i < k ; i++){

		cin >> judge;
		if (judge == 1){

			cin >> x >> y >> cost;

			if (shima[x][y] > cost){
				shima[x][y] = cost;
				shima[y][x] = cost;
			}

		for(int j=0; j < n ; j++){
			for(int l=0 ; l < n ; l++){
				if (shima[j][l] > shima[j][x] + shima[x][y] + shima[y][l]){
					shima[j][l] = shima[j][x] + shima[x][y] + shima[y][l]);
				}
			}
		}	

		}else if (judge == 0){
			cin >> x >> y;
			if (shima[x][y] == INF) {
				cout << -1 << endl;
			}
			else{
				cout << shima[x][y] << endl;
			}
		}
		if (n == 0 && k == 0) break;
		//cout << cost;
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:42: error: 'cost' was not declared in this scope; did you mean 'const'?
   28 |                         cin >> x >> y >> cost;
      |                                          ^~~~
      |                                          const
a.cc:38:94: error: expected ';' before ')' token
   38 |                                         shima[j][l] = shima[j][x] + shima[x][y] + shima[y][l]);
      |                                                                                              ^
      |                                                                                              ;
Language: C++

#include <iostream>
//#include <vector>
using namespace std;

#define INF 1000001 

int main(){

	int n , k , x , y;
	cin >> n >> k;
	int judge;
	
	int shima[n][n];

	for (int i=0 ; i < n ; i++){
		for (int j=0 ; j < n ; j++){
			shima[i][j] = INF;
			if (i == j)shima[i][j] = 0;
 		}
	}

	for (int i=0 ; i < k ; i++){

		cin >> judge;
		if (judge == 1){

			cin >> x >> y >> cost;

			if (shima[x][y] > cost){
				shima[x][y] = cost;
				shima[y][x] = cost;
			}

		for(int j=0; j < n ; j++){
			for(int l=0 ; l < n ; l++){
				if (shima[j][l] > shima[j][x] + shima[x][y] + shima[y][l]){
					shima[j][l] = shima[j][x] + shima[x][y] + shima[y][l]);
				}
			}
		}	

		if (judge == 0){
			cin >> x >> y;
			if (shima[x][y] == INF) {
				cout << -1 << endl;
			}
			else{
				cout << shima[x][y] << endl;
			}
		}
		if (n == 0 && k == 0) break;
		//cout << cost;
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:42: error: 'cost' was not declared in this scope; did you mean 'const'?
   27 |                         cin >> x >> y >> cost;
      |                                          ^~~~
      |                                          const
a.cc:37:94: error: expected ';' before ')' token
   37 |                                         shima[j][l] = shima[j][x] + shima[x][y] + shima[y][l]);
      |                                                                                              ^
      |                                                                                              ;
a.cc:54:2: error: expected '}' at end of input
   54 | }
      |  ^
a.cc:7:11: note: to match this '{'
    7 | int main(){
      |           ^
Language: C++

#include <iostream>
//#include <vector>
using namespace std;

#define INF 1000001 

int main(){

	int n , k , x , y;
	cin >> n >> k;
	int judge;
	
	int shima[n][n];

	for (int i=0 ; i < n ; i++){
		for (int j=0 ; j < n ; j++){
			shima[i][j] = INF;
			if (i == j)shima[i][j] = 0;
 		}
	}

	for (int i=0 ; i < k ; i++){

		cin >> judge;
		if (judge == 1){

			cin >> x >> y >> cost;

			if (shima[x][y] > cost){
				shima[x][y] = cost;
				shima[y][x] = cost;
			}

			for(int j=0; j < n ; j++){
				for(int l=0 ; l < n ; l++){
					if (shima[j][l] > shima[j][x] + shima[x][y] + shima[y][l]){
						shima[j][l] = shima[j][x] + shima[x][y] + shima[y][l]);
					}
				}
			}
		}	

		if (judge == 0){
			cin >> x >> y;
			if (shima[x][y] == INF) {
				cout << -1 << endl;
			}
			else{
				cout << shima[x][y] << endl;
			}
		}
		if (n == 0 && k == 0) break;
		//cout << cost;
	}
}



Compiler output:
a.cc: In function 'int main()':
a.cc:27:42: error: 'cost' was not declared in this scope; did you mean 'const'?
   27 |                         cin >> x >> y >> cost;
      |                                          ^~~~
      |                                          const
a.cc:37:102: error: expected ';' before ')' token
   37 |                                                 shima[j][l] = shima[j][x] + shima[x][y] + shima[y][l]);
      |                                                                                                      ^
      |                                                                                                      ;
Language: C++

#include<stdio.h>
int graph[101][101],n,c,d;

void warshall_floyd(){
  int i,j;
  for(i=1;i<=n;i++)
    for(j=1;j<=n;j++)
      graph[i][j]=graph[j][i]=min(graph[i][j],graph[i][c]+graph[c][d]+graph[d][j]);
}

int min(int x,int y){
  return x<y?x:y;
}

int main(){
  int k,i,j,x,e,a,b;

  while(scanf("%d %d",&n,&k),n,k){

    for(i=0;i<=n;i++)
      for(j=0;j<=n;j++)
	graph[i][j]=i==j?0:1000000;

    for(i=0;i<k;i++){
      if(scanf("%d",&x),x){
	scanf("%d %d %d",&c,&d,&e);

	if(graph[c][d]>e){
	graph[c][d]=graph[d][c]=e;
	warshall_floyd();
	}
      }else{
	scanf("%d %d",&a,&b);
	printf(graph[a][b]>=1000000?"-1\n":"%d\n",graph[a][b]);
      }
    }
  }
  return 0;
}

Compiler output:
a.cc: In function 'void warshall_floyd()':
a.cc:8:31: error: 'min' was not declared in this scope
    8 |       graph[i][j]=graph[j][i]=min(graph[i][j],graph[i][c]+graph[c][d]+graph[d][j]);
      |                               ^~~
Language: C++

#include<stdio.h>
#define INF 1000000
int graph[101][101],n,c,d;

void warshall_floyd(){
  int i,j;
  for(i=1;i<=n;i++)
    for(j=1;j<=n;j++)
      graph[i][j]=graph[j][i]=min(graph[i][j],graph[i][c]+graph[c][d]+graph[d][j]);
}

int min(int x,int y){
  return x<y?x:y;
}

int main(){
  int k,i,j,x,e,a,b;

  while(scanf("%d %d",&n,&k),n,k){

    for(i=0;i<=n;i++)
      for(j=0;j<=n;j++)
	graph[i][j]=i==j?0:INF;

    for(i=0;i<k;i++){
      if(scanf("%d",&x),x){
	scanf("%d %d %d",&c,&d,&e);

	if(graph[c][d]>e){
	graph[c][d]=graph[d][c]=e;
	warshall_floyd();
	}
      }else{
	scanf("%d %d",&a,&b);
	printf(graph[a][b]>=INF?"-1\n":"%d\n",graph[a][b]);
      }
    }
  }
  return 0;
}

Compiler output:
a.cc: In function 'void warshall_floyd()':
a.cc:9:31: error: 'min' was not declared in this scope
    9 |       graph[i][j]=graph[j][i]=min(graph[i][j],graph[i][c]+graph[c][d]+graph[d][j]);
      |                               ^~~
Language: C++

#include <iostream>
#define zmin(a,b) a=(a<b&&a>0?a:b)
using namespace std;
int boat[1001][1001];
int main(){
	int i,j,n,k,s,d,c,f;
	while(cin>>n>>k,n){
		memset(boat,0,sizeof(boat));
		while(k--){
			cin>>f>>s>>d;
			if(f){
				cin>>c;
				zmin(boat[s][d],c);
				zmin(boat[d][s],c);
			}else{
				int D[1001]={0},v[1001]={0};
				for(;!v[d];){
					int mini=-1;
					for(i=1;i<=n;i++) zmin(D[i],D[s]+boat[s][i]);
					v[s]=1;
					for(i=1;i<=n;i++) if(!v[i]&&D[i]&&(mini<0||D[i]<D[mini])) mini=i;
					if(mini<0)break;
					s=mini;
				}
				cout<<(D[d]?D[d]:-1)<<endl;
			}
		}
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:17: error: 'memset' was not declared in this scope
    8 |                 memset(boat,0,sizeof(boat));
      |                 ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | #define zmin(a,b) a=(a<b&&a>0?a:b)
Language: C++

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

struct edge {
	int to, cost;
	edge(int t, int c):to(t), cost(c){}
};

typedef pair<int, int> P;
vector<vector<edge> > es;

int dijkstra(int s, int t) {
	priority_queue<P, vector<P>, greater<P> > que;
	vector<int> dist(es.size(), INT_MAX);
	que.push(P(0, s));
	dist[s] = 0;
	
	while(!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if(dist[v] < p.first)
			continue;

		if(v == t)
			return dist[t];

		for(int i = 0; i < es[v].size(); ++i) {
			edge& e = es[v][i];
			if(dist[e.to] > dist[v] + e.cost) {
				dist[e.to] = dist[v] + e.cost;
				que.push(P(dist[e.to], e.to));
			}
		}
	}

	return -1;
}

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

	for(int n, k; cin >> n >> k, n;) {
		es.clear();
		es.resize(n);
		for(int i = 0; i < k; ++i) {
			int q;
			cin >> q;

			if(!q) {
				int from, to;
				cin >> from >> to;
				--from; --to;
				cout << dijkstra(from, to) << endl;
			}
			else {
				int u, v, cost;
				cin >> u >> v >> cost;
				--u; --v;
				es[u].push_back(edge(v, cost));
				es[v].push_back(edge(u, cost));
			}
		}
	}

	return EXIT_SUCCESS;
}

Compiler output:
a.cc: In function 'int dijkstra(int, int)':
a.cc:18:37: error: 'INT_MAX' was not declared in this scope
   18 |         vector<int> dist(es.size(), INT_MAX);
      |                                     ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <utility>
  +++ |+#include <climits>
    5 | #include <vector>
Language: C++

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <queue>
#include <map>
#include <functional>
#include <cstring>
using namespace std;
#define INF 1000000000
int main(){
	int n,k;
	while(scanf("%d%d",&n,&k),(n|k)){
		int a;
		int d[128][128];
		for(int i = 0; i < 101; i++){
			for(int j = 0; j < 101; j++){
				d[i][j] = i == j?0:INF;
			}
		}
		scanf("%d",&a);
		if(a == 1){
			int f,t,c;
			scanf("%d%d%d",&f,&t,&c);
			f--;
			t--;
			if(d[f][t] > cost){
				d[f][t] = cost;
				for(int i = 0; i < n; i++){
					for(int j = 0; j < n; j++){
						d[i][j] = min(d[i][j],d[i][f] + d[f][t] + d[t][j]);
						d[i][j] = min(d[i][j],d[i][t] + d[t][f] + d[f][j]);
						d[j][i] = d[i][j];
					}
				}
			}
		}
		else{
			int f,t;
			scanf("%d%d",&f,&t);
			f--;
			t--;
			if(d[f][t] == INF)puts("-1");
			else printf("%d\n",d[f][t]);
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:38: error: 'cost' was not declared in this scope; did you mean 'const'?
   28 |                         if(d[f][t] > cost){
      |                                      ^~~~
      |                                      const
Language: C++

//AOJ 0526
//菴ソ縺?婿繧ゅｏ縺九ｉ縺ェ縺?¥縺帙↓include縺励∪縺上ｋ莠コ髢薙?繧ッ繧コ
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<deque>
using namespace std;
#define INF 1 << 20
#define MAX_B 101

int a, b, i, j, k, money[MAX_B][MAX_B], time[MAX_B][MAX_B], n, m, c, d;
bool judge;
stack<int> left, right;


int main(){
  scanf("%d %d", &n, &m);
  if(n == 0 && m == 0) return 0;
  for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){
      money[i][j] = INF;
    }
  }
  for(i = 1; i <= n; i++){
    money[i][i] = 0;
  }
  for(i = 0; i < m; i++){
    scanf("%d", &a);
    if(a == 0){
      scanf("%d %d", &b, &c);
      if(money[b][c] == INF) printf("-1\n");
      else printf("%d\n", money[b][c]);
      continue;
    }
    scanf("%d %d %d", &b, &c, &d);
    if(money[b][c] > d){
      money[b][c] = d;
      money[c][b] = d;
      for(j = 1; j <= n; j++){
	for(k = 1; k <= n; k++{
	    money[j][b] = money[b][j] = min(money[j][b], money[j][c] + money[c][j]);
	    money[j][c] = money[c][j] = min(money[j][c], money[j][b] + money[b][j]);
	  }
      }
    }
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:31: error: expected ')' before '{' token
   46 |         for(k = 1; k <= n; k++{
      |            ~                  ^
      |                               )
Language: C++

//AOJ 0526
//菴ソ縺?婿繧ゅｏ縺九ｉ縺ェ縺?¥縺帙↓include縺励∪縺上ｋ莠コ髢薙?繧ッ繧コ
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<deque>
using namespace std;
#define INF 1 << 20
#define MAX_B 101

int a, b, i, j, k, money[MAX_B][MAX_B], time[MAX_B][MAX_B], n, m, c, d;
bool judge;
stack<int> left, right;


int main(){
  scanf("%d %d", &n, &m);
  if(n == 0 && m == 0) return 0;
  for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){
      money[i][j] = INF;
    }
  }
  for(i = 1; i <= n; i++){
    money[i][i] = 0;
  }
  for(i = 0; i < m; i++){
    scanf("%d", &a);
    if(a == 0){
      scanf("%d %d", &b, &c);
      if(money[b][c] == INF) printf("-1\n");
      else printf("%d\n", money[b][c]);
      continue;
    }
    scanf("%d %d %d", &b, &c, &d);
    if(money[b][c] > d){
      money[b][c] = d;
      money[c][b] = d;
      for(j = 1; j <= n; j++){
	for(k = 1; k <= n; k++{
	    money[j][b] = money[b][j] = min(money[j][b], money[j][c] + money[c][j]);
	    money[j][c] = money[c][j] = min(money[j][c], money[j][b] + money[b][j]);
      }
    }
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:31: error: expected ')' before '{' token
   46 |         for(k = 1; k <= n; k++{
      |            ~                  ^
      |                               )
a.cc:53:2: error: expected '}' at end of input
   53 | }
      |  ^
a.cc:22:11: note: to match this '{'
   22 | int main(){
      |           ^
Language: C++

//AOJ 0526
//菴ソ縺?婿繧ゅｏ縺九ｉ縺ェ縺?¥縺帙↓include縺励∪縺上ｋ莠コ髢薙?繧ッ繧コ
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<deque>
using namespace std;
#define INF 1 << 20
#define MAX_B 101

int a, b, i, j, k, money[MAX_B][MAX_B], time[MAX_B][MAX_B], n, m, c, d;
bool judge;
stack<int> left, right;


int main(){
  scanf("%d %d", &n, &m);
  if(n == 0 && m == 0) return 0;
  for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){
      money[i][j] = INF;
    }
  }
  for(i = 1; i <= n; i++){
    money[i][i] = 0;
  }
  for(i = 0; i < m; i++){
    scanf("%d", &a);
    if(a == 0){
      scanf("%d %d", &b, &c);
      if(money[b][c] == INF) printf("-1\n");
      else printf("%d\n", money[b][c]);
      continue;
    }
    scanf("%d %d %d", &b, &c, &d);
    if(money[b][c] > d){
      money[b][c] = d;
      money[c][b] = d;
      for(j = 1; j <= n; j++){
	for(k = 1; k <= n; k++){
	    money[j][b] = money[b][j] = min(money[j][b], money[j][c] + money[c][j]);
	    money[j][c] = money[c][j] = min(money[j][c], money[j][b] + money[b][j]);
      }
    }
  }
  return 0;
}

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

//AOJ 0526
//菴ソ縺?婿繧ゅｏ縺九ｉ縺ェ縺?¥縺帙↓include縺励∪縺上ｋ莠コ髢薙?繧ッ繧コ
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<deque>
using namespace std;
#define INF 1 << 30
#define MAX_B 101

int a, b, i, j, k, money[MAX_B][MAX_B], time[MAX_B][MAX_B], n, m, c, d;
bool judge;
stack<int> left, right;


int main(){
  scanf("%d %d", &n, &m);
  if(n == 0 && m == 0) return 0;
  for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){
      money[i][j] = INF;
    }
  }
  for(i = 1; i <= n; i++){
    money[i][i] = 0;
  }
  for(i = 0; i < m; i++){
    scanf("%d", &a);
    if(a == 0){
      scanf("%d %d", &b, &c);
      if(money[b][c] == INF) printf("-1\n");
      else printf("%d\n", money[b][c]);
      continue;
    }
    scanf("%d %d %d", &b, &c, &d);
    if(money[b][c] > d){
      money[b][c] = d;
      money[c][b] = d;
      for(j = 1; j <= n; j++){
	money[j][c] = money[c][j] = min(money[j][c], money[j][b] + money[b][c]);
	money[j][b] = money[b][j] = min(money[j][b], money[j][c] + money[c][b]);
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:2: error: expected '}' at end of input
   50 | }
      |  ^
a.cc:33:25: note: to match this '{'
   33 |   for(i = 0; i < m; i++){
      |                         ^
a.cc:50:2: error: expected '}' at end of input
   50 | }
      |  ^
a.cc:22:11: note: to match this '{'
   22 | int main(){
      |           ^
Language: C++

//AOJ 0526
//菴ソ縺?婿繧ゅｏ縺九ｉ縺ェ縺?¥縺帙↓include縺励∪縺上ｋ莠コ髢薙?繧ッ繧コ
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<deque>
using namespace std;
#define INF 1 << 20
#define MAX_B 101

int a, b, i, j, k, money[MAX_B][MAX_B], time[MAX_B][MAX_B], n, m, c, d;
bool judge;
stack<int> left, right;


int main(){
  while(1){
    scanf("%d %d", &n, &m);
    if(n == 0 && m == 0) return 0;
    for(i = 1; i <= n; i++){
      for(j = 1; j <= n; j++){
	money[i][j] = INF;
      }
    }
    for(i = 1; i <= n; i++){
      money[i][i] = 0;
    }
    for(i = 0; i < m; i++){
      scanf("%d", &a);
      if(a == 0){
	scanf("%d %d", &b, &c);
	if(money[b][c] == INF) printf("-1\n");
	else printf("%d\n", money[b][c]);
      }
    }
    else{
      scanf("%d %d %d", &b, &c, &d);
      if(money[b][c] > d){
	money[b][c] = d;
	money[c][b] = d;
      }
      for(j = 1; j <= n; j++){
	money[j][c] = money[c][j] = min(money[j][c], money[j][b] + money[b][c]);
	money[j][b] = money[b][j] = min(money[j][b], money[j][c] + money[c][b]);
      }
    }
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:5: error: 'else' without a previous 'if'
   42 |     else{
      |     ^~~~
Language: C++

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

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
#define INF 1 << 29
using namespace std;

int main(){
  int n, k;
  while(scanf("%d%d", &n, &k) && n+k){
    int cost[100][100];
    rep(i, n) rep(j, n) cost[i][j] = INF;
    //    rep(i, n) cost[i][i] = 0;

    rep(i, k){
      int z;
      scanf("%d", &z);
      if(z){
	int c, d, e;
	scanf("%d%d%d", &c, &d, &e);
	c--;d--;
	cost[c][d] = cost[d][c] = e;
	rep(k, n) rep(i, n) if(k != i) rep(j, n)
	  if(i != j && cost[i][j] > cost[i][k] + cost[k][j]) 
	    cost[i][j] = cost[i][k] + cost[k][j];
	  
	/*	rep(i, n){
	  rep(j, n) printf("%05d ", cost[i][j]);
	  puts("");
	  }*/
      }else{
	int a, b;
	scanf("%d%d", &a, &b);
	a--;b--;
	printf("%d\n", cost[a][b] < INF ? cost[a][b]:-1);
      }
    }
  }
  re

Compiler output:
a.cc: In function 'int main()':
a.cc:50:3: error: 're' was not declared in this scope; did you mean 'rep'?
   50 |   re
      |   ^~
      |   rep
a.cc:50:5: error: expected '}' at end of input
   50 |   re
      |     ^
a.cc:19:11: note: to match this '{'
   19 | int main(){
      |           ^
Language: C

#include<cstdio>
int s[100000], x[100000], n, S;
int main() {
	while (true) {
		scanf("%d",&n);
		if (!n) { break; }
		S = 0;
		for (int i = 0; i < n; i++) { scanf("%d",&s[i]); }
		for (int i = 0; i < n; i++) {
			x[i] = s[i];
			if (i % 2 == 1) {
				for (int j = i - 1; j >= 0; j--) {
					if (x[j] == s[i]) {
						break;
					}
					else {
						x[j] = 1 - x[j];
					}
				}
			}
		}
		for (int i = 0; i < n; i++) {
			if (x[i] == 0) { S++; }
		}
		printf("%d\n",S);
	}
	return 0;
}

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

int s[100000], x[100000], n, S;
int main() {
	while (true) {
		scanf("%d",&n);
		if (!n) { break; }
		S = 0;
		for (int i = 0; i < n; i++) { scanf("%d",&s[i]); }
		for (int i = 0; i < n; i++) {
			x[i] = s[i];
			if (i % 2 == 1) {
				for (int j = i - 1; j >= 0; j--) {
					if (x[j] == s[i]) {
						break;
					}
					else {
						x[j] = 1 - x[j];
					}
				}
			}
		}
		for (int i = 0; i < n; i++) {
			if (x[i] == 0) { S++; }
		}
		printf("%d\n",S);
	}
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:3:16: error: 'true' undeclared (first use in this function)
    3 |         while (true) {
      |                ^~~~
main.c:1:1: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
  +++ |+#include <stdbool.h>
    1 | int s[100000], x[100000], n, S;
main.c:3:16: note: each undeclared identifier is reported only once for each function it appears in
    3 |         while (true) {
      |                ^~~~
main.c:4:17: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    4 |                 scanf("%d",&n);
      |                 ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | int s[100000], x[100000], n, S;
main.c:4:17: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    4 |                 scanf("%d",&n);
      |                 ^~~~~
main.c:4:17: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:24:17: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   24 |                 printf("%d\n",S);
      |                 ^~~~~~
main.c:24:17: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:24:17: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:24:17: note: include '<stdio.h>' or provide a declaration of 'printf'
Language: C++

#include<stdio.h>
#include<iostream>
using namespace std;

int main(){

int n[100001]={},N,x,cou=0;
while(1){
scanf("%d",&N);
if(N==0)break;

for(int i=0;i<N;i++)
{
cin>>x;
if(i==0)n[i]=x;
else if(i%2==1)n[i]=x;
else if(i%2==0){
n[i]=x;
for(int j=i;j>=0;j--)
if(n[j]!=n[j-1])n[j-1]=n[j];
else if(n[j]==n[j-1])break;
}
for(int i=0;i<N;i++)
if(n[i]==0)cou++;

cout<<cou<<endl;
}
return 0;
}

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

#include<cstdio>
int x[100000], n, S;
int main() {
	while (true) {
		scanf("%d",&n);
		if (!n) { break; }
		S = 0;
		for (int i = 0; i < n; i++) {
			scanf("%d",&x[i])
			if (i % 2 == 1) {
				for (int j = i - 1; j >= 0; j--) {
					if (x[j] == x[i]) {
						break;
					}
					else {
						x[j] = 1 - x[j];
					}
				}
			}
		}
		for (int i = 0; i < n; i++) {
			if (x[i] == 0) { S++; }
		}
		printf("%d\n",S);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:42: error: expected ';' before 'if'
    9 |                         scanf("%d",&x[i])
      |                                          ^
      |                                          ;
   10 |                         if (i % 2 == 1) {
      |                         ~~
Language: C++

#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<(int)(n);i++)
#define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define pb(a) push_back(a)
#define mp(x,y) make_pair(x,y)
#define ZERO(a) memset(a,0,sizeof(a))
#define len(a) sizeof(a)
#define ll long long
#define pii pair<int,int>
#define INF 1<<29
#define MAX 101010
using namespace std;

int a[MAX],g[MAX];

void solve(){
 int n;
 for(;;){
  cin>>n;
  if(!n) break;
  FOR(i,n) cin>>a[i];
  FOR(i,n){
   if(i&1){
    g[i]=a[i];
    continue;
   }
   int t;
   for(t=i-1;t>=0&&g[t]!=a[i];t--);
   FOR(j,t+1,i) g[j]^=1;
  }
  int tot=0;
  FOR(i,n) tot+=g[i];
  cout<<n-tot<<endl;
 }
}

int main(){
 solve();
 return 0;
}

Compiler output:
a.cc:29:15: error: macro "FOR" passed 3 arguments, but takes just 2
   29 |    FOR(j,t+1,i) g[j]^=1;
      |               ^
a.cc:2:9: note: macro "FOR" defined here
    2 | #define FOR(i,n) for(int i=0;i<(int)(n);i++)
      |         ^~~
a.cc: In function 'void solve()':
a.cc:29:4: error: 'FOR' was not declared in this scope
   29 |    FOR(j,t+1,i) g[j]^=1;
      |    ^~~
Language: C++

#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<(int)(n);i++)
#define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define pb(a) push_back(a)
#define mp(x,y) make_pair(x,y)
#define ZERO(a) memset(a,0,sizeof(a))
#define len(a) sizeof(a)
#define ll long long
#define pii pair<int,int>
#define INF 1<<29
#define MAX 101010
using namespace std;

int a[MAX],g[MAX];

void solve(){
 int n;
 for(;;){
  cin>>n;
  if(!n) break;
  FOR(i,n) cin>>a[i];
  FOR(i,n){
   g[i]=a[i]
   if(i&1) continue;
   int t;
   for(t=i-1;t>=0&&g[t]!=a[i];t--);
   FORR(j,t+1,i) g[j]^=1;
  }
  int tot=0;
  FOR(i,n) tot+=g[i];
  cout<<n-tot<<endl;
 }
}

int main(){
 solve();
 return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:23:13: error: expected ';' before 'if'
   23 |    g[i]=a[i]
      |             ^
      |             ;
   24 |    if(i&1) continue;
      |    ~~
Language: C++

#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<(int)(n);i++)
#define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define pb(a) push_back(a)
#define mp(x,y) make_pair(x,y)
#define ZERO(a) memset(a,0,sizeof(a))
#define len(a) sizeof(a)
#define ll long long
#define pii pair<int,int>
#define INF 1<<29
#define MAX 101010
using namespace std;

int a[MAX],p[MAX/2];

void solve(){
 int n;
 for(;;){
  cin>>n;
  if(!n) break;
  FOR(i,n) cin>>a[i];
  for(int i=0;2*i+1<n;i++){
   if(a[2*i]==a[2*i+1]){
    p[i]=a[2*i];
    continue;
   }
   p[i]=a[2*i+1];
   int t=i-1;
   while(t>=0&&p[t]!=p[i]) p[t--]=p[i];
  }
  for(int i=0;2*i+1<n;i++){
   ans+=(p[i]^1)<<1;
  }
  if(n&1&&a[n-1]==0) ans++;
  cout<<ans<<endl;
 }
}

int main(){
 solve();
 return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:32:4: error: 'ans' was not declared in this scope; did you mean 'abs'?
   32 |    ans+=(p[i]^1)<<1;
      |    ^~~
      |    abs
a.cc:34:22: error: 'ans' was not declared in this scope; did you mean 'abs'?
   34 |   if(n&1&&a[n-1]==0) ans++;
      |                      ^~~
      |                      abs
a.cc:35:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   35 |   cout<<ans<<endl;
      |         ^~~
      |         abs
Language: C++

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

int main(){
	int n;
	while (1){
		cin >> n;
		if (n == 0) break;
		vector<int> d(n), f(n, 0);
		rep(i, 0, n) cin >> d[i];

		f[0] = d[0];
		rep(i, 1, n){
			if (i % 2 == 0||d[i]==f[i-1]){
				f[i] = d[i];
			}
			else{
				int ind;
				for (ind = i - 1; ind >= 0; ind--){
					if (f[ind]==d[i])
						ind++; break;
					}
				}
			if (ind < 0) ind = 0;
				rep(j, ind, i + 1){
					f[j] = d[i];
				}
			}
		}
		int ans = 0;
		rep(i, 0, n){
			if (f[i] == 0) ans++;
		}
		cout << ans << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:29: error: 'ind' was not declared in this scope; did you mean 'int'?
   25 |                         if (ind < 0) ind = 0;
      |                             ^~~
      |                             int
a.cc:26:40: error: 'ind' was not declared in this scope; did you mean 'int'?
   26 |                                 rep(j, ind, i + 1){
      |                                        ^~~
a.cc:2:30: note: in definition of macro 'rep'
    2 | #define rep(i,a,n) for(int i=a;i<n;i++)
      |                              ^
a.cc:33:29: error: 'f' was not declared in this scope
   33 |                         if (f[i] == 0) ans++;
      |                             ^
a.cc: At global scope:
a.cc:37:1: error: expected declaration before '}' token
   37 | }
      | ^
Language: C++

#include<iostream>
#include<algorithm>
#define F 114514
using namespace std;int s[F],e[F],q;bool c[F];void a(bool t,bool r){if(t){if(c[q-1]!=r){if(q==1)e[0]++,c[0]=r;else{e[q-2]=e[q-1]+1;q--;}}else e[q-1]++;return;}if(c[q-1]!=r)s[q]=e[q-1],e[q]=s[q]+1,c[q]=r,q++;else e[q-1]++;return;}int main(){int n,t;while(true){cin>>n;if(!n)break;cin>>t;s[0]=0,e[0]=1,c[0]=t,q=1;for(int i=1;i<n;i++){cin>>t;a(i%2,t);}int s=0;for(int i=0;i<q;i++)if(!c[i])s+=e[i]-s[i];cout<<s<<endl;}return 0;}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:396: error: invalid types 'int[int]' for array subscript
    4 | using namespace std;int s[F],e[F],q;bool c[F];void a(bool t,bool r){if(t){if(c[q-1]!=r){if(q==1)e[0]++,c[0]=r;else{e[q-2]=e[q-1]+1;q--;}}else e[q-1]++;return;}if(c[q-1]!=r)s[q]=e[q-1],e[q]=s[q]+1,c[q]=r,q++;else e[q-1]++;return;}int main(){int n,t;while(true){cin>>n;if(!n)break;cin>>t;s[0]=0,e[0]=1,c[0]=t,q=1;for(int i=1;i<n;i++){cin>>t;a(i%2,t);}int s=0;for(int i=0;i<q;i++)if(!c[i])s+=e[i]-s[i];cout<<s<<endl;}return 0;}
      |                                                                                                                                                                                                                                                                                                                                                                                                            ^
Language: C++

#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;
ll n;
vector<P> v;//first ???????????? second: 0or1
ll x;
int main()
{while(1)
	cin>>n;
	if(!n) return 0;
	v.clear();
	for(ll i=1;i<=n;i++){
		cin>>x;
		if(i==1||(i%2==1 && v[v.size()-1].second!=x)){//??°??????
			v.push_back(P(i,x));
		}
		else if(i%2==0&&v[v.size()-1].second!=x){//???????¶????
			if(v.size()==1){
				v[0].second=x;
			}
			else{
				v.erase(v.end()-1);
			}
		}
	}
	ll ans=0;
	for(ll i=0;i<v.size();i++){
		if(v[i].second==0) ans+=(i==v.size()-1?n+1:v[i+1].first)-v[i].first;
	}
	cout<<ans<<endl;
}}

Compiler output:
a.cc:42:2: error: expected declaration before '}' token
   42 | }}
      |  ^
Language: C++

#include <iostream>
#include <list>

using namespace std;

#define W (0)
#define B (1)

int main(void)
{
	while (1){
		list<pair<int, int> > st;
		pair<int, int> add;
		int n;
		
		cin >> n;
		if (n == 0)break;
		cin >> add.first;
		add.second = 1;
		st.push_back(add);
		for (int i = 2; i <= n; i++){
			int s;
			cin >> s;
			if (i % 2 == 1){
				if (st.back().first == s){
					st.back().second++;
				}
				else {
					add.first = s;
					add.second = 1;
					st.push_back(add);
				}
			}
			else {
				if (st.back().first == s){
					st.back().second++;
				}
				else {
					if (st.size() == 1){
						st.back().first = s;
						st.back().second++;
					}
					else {
						int c = st.back().second
						cout << c  << endl;
						st.pop_back();
						st.back().second += c + 1;
					}
				}
			}
		}
		
		list<pair<int, int> >::iterator it;
		int count = 0;
		for (it = st.begin(); it != st.end(); it++){
			if (it->first == W){
				count += it->second;
			}
		}
		
		cout << count << endl;
	}
	return (0);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:49: error: expected ',' or ';' before 'cout'
   45 |                                                 cout << c  << endl;
      |                                                 ^~~~