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

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

int main(){
	while(1){
		int n;
		long road[10][10];
		scanf(" %d", &n);
		if(n==0) break;
		
		memset(road, -1, sizeof(road));
		for(int i=0; i<10; ++i) road[i][i]=0;
		 
		int city=0; //街の数
		for(int i=0; i<n; ++i){
			int a, b, c;
			scanf(" %d %d %d", &a, &b, &c);	
			road[a][b]=road[b][a]=c;
			if(city<a) city=a;
			if(city<b) city=b;
		}
		
		long ans[10]={0};	
		
		//各街を根としてbfs
		for(int i=0; i<=city; ++i){
			long cost[10]; //その街までの最小コスト
			for(int j=0; j<=city; ++j) cost[j]=1000000000; //とりあえず大きいので初期化
			
			queue<int> que;
			cost[i]=0;
			que.push(i);
			while( !que.empty() ){
				int v=que.front();
				que.pop();
				for(int j=0; j<10; ++j){
					if(v==j) continue;
					
					if(road[v][j]>=0 && cost[v]+road[v][j]<cost[j]){
						cost[j]=cost[v]+road[v][j];
						que.push(j);	
					}	
				}	
			}	
			/*
			printf("city %d to:\n", i);
			for(int j=0; j<=city; ++j) printf(" %d is %ld\n", j, cost[j]);
			*/
			for(int j=0; j<=city; ++j) ans[i]+=cost[j];
		}
		
		int a=0;
		for(int i=1; i<=city; ++i)
			if(ans[a]>ans[i]) a=i;	
			
		printf("%d %ld\n", a, ans[a]);
	}
}	

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

// Warshall-floyd
#include <iostream>
#include <algorith>
using namespace std;
#define INF 114514810

int n, a, b, c, v, d[11][11];// v: num of nodes

void init()
{
    for(int i=0; i<n; i++) {
        for(int j=0; j<n; j++) {
            if(i==j)// If not exist cost, cost=INF
                d[i][j] = 0;
            else
                d[i][j] = INF;
        }
    }

}

int main(void)
{
    ios::sync_with_stdio(false);
    while(cin >> n) {
        if(n == 0) break;
        init();

        v = -1;
        for(int i=0; i<n; i++) {
            cin >> a >> b >> c;
            d[a][b] = c; d[b][a] = c;
            v = max(max(v, a), b);
        }
        v++;

        for(int k=0; k<v; k++) {
            for(int i=0; i<v; i++) {
                for(int j=0; j<v; j++) {
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
                }
            }
        }


        int city, dist = INF;
        for(int i=0; i<v; i++) {
            int sum = 0;
            for(int j=0; j<v; j++) {
                sum += d[i][j];
            }
            if(dist > sum) {
                dist = sum;
                city = i;
            }
        }
        cout << city << " " << dist << endl;
    }

    return 0;
}

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

#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <bitset>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
using namespace std;
#define INF INT_MAX>>1


int main()
{   
    // freopen("in","r",stdin);
    int n;
    while(scanf("%d",&n)&&n){
        int u,v,w,max_v=0;
        int g[15][15];
        memset(g,0x3f3f,sizeof(g));
        for(int i=0;i<n;i++){
            scanf("%d %d %d",&u,&v,&w);
            g[u][v]=g[v][u]=w;
            max_v = max(max_v,u);
            max_v = max(max_v,v);
        }  

        for(int k=0;k<=max_v;k++){
            for(int i=0;i<=max_v;i++){
                for(int j=0;j<=max_v;j++){
                    if(g[i][k]+g[k][j]<g[i][j])
                        g[i][j] = g[i][k]+g[k][j];
                }
            }
        }
        int ans_sum = INF,ans_i;
        for(int i=0;i<=max_v;i++){
            int sum = 0;
            for(int j=0;j<=max_v;j++){
                if(i!=j){
                    sum += g[i][j];
                }
            }
            if(sum < ans_sum){
                ans_sum = sum;
                ans_i = i;
            }
        }
        printf("%d %d\n",ans_i,ans_sum);
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:13: error: 'INT_MAX' was not declared in this scope
   11 | #define INF INT_MAX>>1
      |             ^~~~~~~
a.cc:37:23: note: in expansion of macro 'INF'
   37 |         int ans_sum = INF,ans_i;
      |                       ^~~
a.cc:10:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    9 | #include <sstream>
  +++ |+#include <climits>
   10 | using namespace std;
a.cc:47:17: error: 'ans_i' was not declared in this scope; did you mean 'ans_sum'?
   47 |                 ans_i = i;
      |                 ^~~~~
      |                 ans_sum
a.cc:50:26: error: 'ans_i' was not declared in this scope; did you mean 'ans_sum'?
   50 |         printf("%d %d\n",ans_i,ans_sum);
      |                          ^~~~~
      |                          ans_sum
Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 10;
const int M = 10;
const int INF = 0x3f3f3f3f;
int d[N][N];
int n;
/*void input()
{
    for (int i = 0; i < N; i ++)
        fill(d[i], d[i]+N, INF);
    int m;
    cin >> m;
    n = 0;
    while ( m-- ) {
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
        d[a][b] = d[b][a] = c;
        n = max(max(n, a+1), b+1);
    }
}*/
void solve()
{
    for (int k = 0; k < n; k ++) {
        for (int i = 0; i < n; i ++) {
            for (int j = 0; j < n; j ++) {
                d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }

    int sum, msum = INF;
    int id = 0;
    for (int i = 0; i < n; i ++) {
        sum = 0;
        for (int j = 0; j < n; j ++) {
            if (i == j) continue;
            sum += d[i][j];
        }
        if (sum < msum) {
            msum = sum;
            id = i;
        }
    }
    printf("%d %d\n", id, msum);
}
int main(void)
{
    int m;
    while ( cin >> m && m ) {
        for (int i = 0; i < N; i ++)
            fill(d[i], d[i]+N, INF);
        n = 0;
        while ( m-- ) {
            int a, b, c;
            scanf("%d%d%d", &a, &b, &c);
            d[a][b] = d[b][a] = c;
            n = max(max(n, a+1), b+1);
        }
        solve();
    }
    re

Compiler output:
a.cc: In function 'int main()':
a.cc:64:5: error: 're' was not declared in this scope
   64 |     re
      |     ^~
a.cc:64:7: error: expected '}' at end of input
   64 |     re
      |       ^
a.cc:50:1: note: to match this '{'
   50 | {
      | ^
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;


struct edge {
	int to, cost;
	edge(int _to, int _cost) :to(_to), cost(_cost){};
};

vector<edge> G[100];

int n, a, b, c;
int d[100];
set<int> si;
set<int>::iterator it;

void dijkstra(int s){
	fill(d, d + 100, INF);
	d[s] = 0;
	priority_queue<P> que;
	que.push(P(0, s));

	while (!que.empty()){
		P p = que.top(); que.pop();
		int v = p.second;

		if (d[v] < p.first)continue;

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

int main(){
	while (cin >> n&&n){
		REP(i, n){
			cin >> a >> b >> c;
			if (si.find(a) == si.end())si.insert(a);
			if (si.find(b) == si.end())si.insert(b);
			G[a].push_back(edge(b, c));
			G[b].push_back(edge(a, c));
		}
		int ans = INT_MAX, index = INT_MAX;
		it = si.begin();
		REP(i, si.size()){
			int sum = 0;
			dijkstra(*it + i);
			REP(i, si.size()){
				sum += d[i];
			}
			if (ans > sum){
				ans = sum;
				index = *it + i;
			}
		}
		cout << index << " " << ans << endl;
		REP(i, si.size()){
			G[*it + i].clear();
		}
		si.clear();
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:80:27: error: 'INT_MAX' was not declared in this scope
   80 |                 int ans = INT_MAX, index = INT_MAX;
      |                           ^~~~~~~
a.cc:16:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   15 | #include <complex>
  +++ |+#include <climits>
   16 | 
a.cc:90:33: error: 'index' was not declared in this scope
   90 |                                 index = *it + i;
      |                                 ^~~~~
a.cc:93:25: error: 'index' was not declared in this scope
   93 |                 cout << index << " " << ans << endl;
      |                         ^~~~~
Language: C++

#include<stdio.h>
#include<string.h>
#define INF 0x3f3f3f
int max(int a,int b)
{
	return a>b?a:b;
}
int map[110]110],visit[110],vis[110];
int n,m;
int dijkstra(int a)
{
	memset(visit,0,sizeof(visit));
	int i,j,next,sum,min;
	for(i=0;i<m;i++)
	vis[i]=map[a][i];
	visit[a]=1;
	for(i=0;i<m;i++)
	{
		min=INF;
		for(j=0;j<m;j++)
		{
			if(!visit[j]&&min>vis[j])
			{
				next=j;
				min=vis[j];
			}
		}
		visit[next]=1;
		for(j=0;j<m;j++)
			if(!visit[j]&&vis[j]>vis[next]+map[next][j])
			vis[j]=vis[next]+map[next][j];
	}
	sum=0;
	for(i=0;i<m;i++)
	sum+=vis[i];
	return sum;
}
int main()
{
	int i,j,sum;
	int a,b,c;
	while(scanf("%d",&n),n)
	{
		for(i=0;i<110;i++)
		for(j=i;j<110;j++)
		{
			if(i==j)
			map[i][j]=map[j][i]=0;
			else
			map[i][j]=map[j][i]=INF;
		}
		m=0;
		while(n--)
		{
			scanf("%d%d%d",&a,&b,&c);
			map[a][b]=map[b][a]=c;
			m=max(m,max(a,b)+1);
		}
		sum=INF;
		for(i=0;i<m;i++)
		{
			if(sum>dijkstra(i))
			{
				j=i;
				sum=dijkstra(i);
			}			
		}
		printf("%d %d\n",j,sum);
	}
	return 0;
}

Compiler output:
a.cc:8:13: error: expected initializer before numeric constant
    8 | int map[110]110],visit[110],vis[110];
      |             ^~~
a.cc: In function 'int dijkstra(int)':
a.cc:12:16: error: 'visit' was not declared in this scope
   12 |         memset(visit,0,sizeof(visit));
      |                ^~~~~
a.cc:15:9: error: 'vis' was not declared in this scope
   15 |         vis[i]=map[a][i];
      |         ^~~
a.cc:15:16: error: 'map' was not declared in this scope; did you mean 'max'?
   15 |         vis[i]=map[a][i];
      |                ^~~
      |                max
a.cc:22:43: error: 'vis' was not declared in this scope
   22 |                         if(!visit[j]&&min>vis[j])
      |                                           ^~~
a.cc:30:39: error: 'vis' was not declared in this scope
   30 |                         if(!visit[j]&&vis[j]>vis[next]+map[next][j])
      |                                       ^~~
a.cc:30:56: error: 'map' was not declared in this scope; did you mean 'max'?
   30 |                         if(!visit[j]&&vis[j]>vis[next]+map[next][j])
      |                                                        ^~~
      |                                                        max
a.cc:35:14: error: 'vis' was not declared in this scope
   35 |         sum+=vis[i];
      |              ^~~
a.cc: In function 'int main()':
a.cc:48:25: error: 'map' was not declared in this scope; did you mean 'max'?
   48 |                         map[i][j]=map[j][i]=0;
      |                         ^~~
      |                         max
a.cc:50:25: error: 'map' was not declared in this scope; did you mean 'max'?
   50 |                         map[i][j]=map[j][i]=INF;
      |                         ^~~
      |                         max
a.cc:56:25: error: 'map' was not declared in this scope; did you mean 'max'?
   56 |                         map[a][b]=map[b][a]=c;
      |                         ^~~
      |                         max
Language: C++

#include <iostream>

using namespace std;
const int INF = 2 << 35;

int main()
		{

int data[11][11];
int n;
int a,s,d;
int ans,anssum;
int sum=0;

while (true)
	{
	
for(int i=0;i<10;i++)
{
for(int k = 0;k<10;k++)
{
data[i][k] = INF;
}
}

cin >> n ;

if(n == 0)return 0;

for(int i = 0; i< n;++i)
{
cin >> a >> s >> d;
data[a][s] = d;
data[s][a] = d;
}

for(int i=0;i<10;i++)
{
for(int k = 0;k<10;k++)
{
for(int m = 0;m<10;m++)
{
	if(data[i][k] > data[i][m] + data[m][k])
	{
	data[i][k] = data[i][m] + data[m][k];
	data[k][i] = data[i][m] + data[m][k];	
	}
}
}
}
anssum = INF;
for(int i=0;i<10;++i)
{
sum = 0;
for (int k=0;k < 10;++k)
{
	sum += data[i][k];
} 	
if(sum < anssum)
{
ans = i;
anssum = sum;
}
}
cout << ans <<" "<< ansnum << "\n";
	}

		}

Compiler output:
a.cc:4:19: warning: left shift count >= width of type [-Wshift-count-overflow]
    4 | const int INF = 2 << 35;
      |                 ~~^~~~~
a.cc: In function 'int main()':
a.cc:65:21: error: 'ansnum' was not declared in this scope; did you mean 'anssum'?
   65 | cout << ans <<" "<< ansnum << "\n";
      |                     ^~~~~~
      |                     anssum
Language: C++

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

const int MAX_V = 100, INF = 999999;
static int cost[MAX_V][MAX_V];
static int d[MAX_V];

bool used[MAX_V];
static int V;
int E;
void dijkstra(int s) {
	fill(d, d + V, INF);
	fill(used, used + V, false);
	d[s] = 0;

	while (true) {
		int v = -1;
		for (int u = 0; u < V; u++) {
			if (!used[u] && (v == -1 || d[u] < d[v])) v = u;
		}
		if (v == -1) break;
		used[v] = true;

		for (int u = 0; u < V; u++) {
			d[u] = min(d[u], d[v] + cost[v][u]);
		}
	}
}

int main() {
	while (1) {
		memset(cost, 999999, sizeof(cost));
		cin >> E;
		if (E == 0) break;
		int v_max = -1;
		for (int i=0 ; i < E; i++) {
			int u, v, cos;
			cin >> u >> v >> cos;
			cost[u][v] = cos;
			cost[v][u] = cos;
			if (v > v_max)v_max = v;
		}
		V = v_max + 1;
		int sum_m = 999999, m_ind = -1;
		for (int i = 0; i < V; i++) {
			dijkstra(i);
			int sum = 0;
			for (int j = 0; j < V; j++) {
				sum += d[j];
			}
			if (sum < sum_m) {
				sum_m = sum;
				m_ind = i;
			}
		}

		cout << m_ind << " " << sum_m << endl;
	}
	return 0;
}

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

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

using namespace std;

int C = 0;
int N = 0;
int R[10][10] = { 0 };
int M[10] = { 0 };

bool solve() {
	int sum = INT_MAX,ans = 0;
	for (int i = 0; i <= C; i++) {
		queue<int> q;
		q.push(i);
		M[i] = 0;
		while (!q.empty()) {
			for (int j = 0; j <= C; j++) {
				if (R[q.front()][j] != -1 && (M[j] == -1 || M[q.front()] + R[q.front()][j] < M[j])) {
					
					M[j] = R[q.front()][j] + M[q.front()];
					q.push(j);
				}
			}
			q.pop();
		}
		int s = 0;
		for (int j = 0; j <= C; j++)
			s += M[j];
		if (sum > s) {
			sum = s;
			ans = i;
		}
		memset(M, -1, sizeof(int) * 10);
	}
	printf("%d %d\n", ans,sum);
}

int main(void) {
	int n = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		C = 0;
		memset(R, -1, sizeof(int) * 100);
		memset(M, -1, sizeof(int) * 10);
		scanf("%d", &N);
		for (int j = 0; j < N; j++) {
			int a, b, c;
			scanf("%d%d%d", &a, &b, &c);
			R[a][b] = c;
			R[b][a] = c;
			C = max(C, max(a, b));
		}
		solve();
	}
}

Compiler output:
a.cc: In function 'bool solve()':
a.cc:14:19: error: 'INT_MAX' was not declared in this scope
   14 |         int sum = INT_MAX,ans = 0;
      |                   ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include<queue>
  +++ |+#include <climits>
    5 | 
a.cc:34:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
   34 |                         ans = i;
      |                         ^~~
      |                         abs
a.cc:36:17: error: 'memset' was not declared in this scope
   36 |                 memset(M, -1, sizeof(int) * 10);
      |                 ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include<queue>
  +++ |+#include <cstring>
    5 | 
a.cc:38:27: error: 'ans' was not declared in this scope; did you mean 'abs'?
   38 |         printf("%d %d\n", ans,sum);
      |                           ^~~
      |                           abs
a.cc:39:1: warning: no return statement in function returning non-void [-Wreturn-type]
   39 | }
      | ^
a.cc: In function 'int main()':
a.cc:46:17: error: 'memset' was not declared in this scope
   46 |                 memset(R, -1, sizeof(int) * 100);
      |                 ^~~~~~
a.cc:46:17: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
Language: C++

#include <iostream>

#define MAX 10
#define INF INT_MAX
using namespace std;

int d[MAX][MAX];
int n, num_ver = 0;
int min_t = INF;
int min_ver;

void init();
void input();
void wf();

int main(){

  while(cin >> n, n){
    init();
    input();  
    wf();
    
   
    for(int i = 0; i <= num_ver; i++){
      int tmp = 0;
      for(int j = 0; j <= num_ver; j++){
	tmp += d[i][j];
      }
      if(min_t > tmp) {min_t = tmp; min_ver = i;}
    }
    cout << min_ver << " " << min_t << endl;
  }
}

void init(){
  for(int i = 0; i < MAX; i++){
    for(int j = 0; j < MAX; j++){
      d[i][j] = (i==j)? 0: INF;
    }
  }
}

void input(){
  for(int i = 0; i < n; i++){
    int a, b, c;
    cin >> a >> b >> c;
    d[a][b] = c;
    d[b][a] = c;
    if(num_ver < b) num_ver = b;
  }
}

void wf(){
  for(int i = 0; i <= num_ver; i++){
    for(int j = 0; j <= num_ver; j++){
      for(int k = 0; k <= num_ver; k++){
	d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

Compiler output:
a.cc:4:13: error: 'INT_MAX' was not declared in this scope
    4 | #define INF INT_MAX
      |             ^~~~~~~
a.cc:9:13: note: in expansion of macro 'INF'
    9 | int min_t = INF;
      |             ^~~
a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    1 | #include <iostream>
  +++ |+#include <climits>
    2 | 
a.cc: In function 'void init()':
a.cc:4:13: error: 'INT_MAX' was not declared in this scope
    4 | #define INF INT_MAX
      |             ^~~~~~~
a.cc:38:28: note: in expansion of macro 'INF'
   38 |       d[i][j] = (i==j)? 0: INF;
      |                            ^~~
a.cc:4:13: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #define INF INT_MAX
      |             ^~~~~~~
a.cc:38:28: note: in expansion of macro 'INF'
   38 |       d[i][j] = (i==j)? 0: INF;
      |                            ^~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

int d[11][11];
static const int INF = 99999999;

void solve() {
  int n;
  while (cin >> n && n) {
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
        d[i][j] = INF;
      }
      d[i][i] = 0;
    }
    for (int i = 0; i < n; i++) {
      int from, to, dist;
      cin >> from >> to >> dist;
      d[from][to] = dist;
      d[to][from] = dist;
    }
    for (int k = 0; k < 10; k++) {
      for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
          d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
      }
    }
    int min_sum_dist = INF;
    int pos = 0;
    for (int i = 0; i < 10; i++) {
      int sum = 0;
      for (int j = 0; j < 10; j++) {
        if (d[i][j] != INF) sum += d[i][j];
      }
      if (sum == 0) continue;
      if (min_sum_dist > sum) {
        min_sum_dist = sum;
        pos = i;
      }
    }
    cout << pos << ' ' << min_sum_dist << endl;
  }
}

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

Compiler output:
a.cc: In function 'int main()':
a.cc:50:10: error: expected ';' before 'return'
   50 |   solve()
      |          ^
      |          ;
   51 |   return 0;
      |   ~~~~~~
Language: C++

//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef pair<int,int> p;
int inf=INT_MAX;
int main(){
    while(1){
        int n;
        scanf("%d",&n);
        if(n==0) break;

        int d[50][50];

        for(int i=0;i<50;i++){
            for(int j=0;j<50;j++)d[i][j]=inf;
        }
        for(int i=0;i<50;i++)d[i][i]=0;
        for(int i=0;i<n;i++){
            int a,b,c;
            scanf("%d%d%d",&a,&b,&c);
            d[a][b]=c;
            d[b][a]=c;
        }
        for(int k=0;k<50;k++){
            for(int i=0;i<50;i++){
                for(int j=0;j<50;j++){
                    if(d[i][k]!=inf and d[k][j]!=inf) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
                }
            }
        }
        int ans=inf;
        for(int i=0;i<50;i++){
            int tmp=0;
            int flag=0;
            for(int j=0;j<50;j++){
                if(d[i][j]!=inf and i!=j){tmp+=d[i][j];flag=1;}
            }
            if(flag==1)ans=min(ans,tmp);
        }
        if(ans==inf)print("0\n");
        else printf("%d\n",ans);

    }


};

Compiler output:
a.cc: In function 'int main()':
a.cc:61:21: error: 'print' was not declared in this scope; did you mean 'rint'?
   61 |         if(ans==inf)print("0\n");
      |                     ^~~~~
      |                     rint
Language: C++

//
//  main.cpp
//

#include <iostream>
//#include <algorithm>
#include <vector>
//#include <limits>
#include <math.h>
//#include <queue>
//#include <tuple>
//#include <stdio.h>
//#include <stdlib.h>
//#include <string>
//#include "string.h"
// #include <unordered_map>
#include <map>
#include <unordered_set>
//#include <array>
#include <set>
#include <limits>

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2224

using namespace std;

using ll = long long;

#include <vector>

struct UnionFind {
    vector<size_t> parent;
    vector<size_t> rank;
    size_t findParent(size_t x) {
        if (parent[x] == x) {
            return x;
        } else {
            parent[x] = findParent(parent[x]);
            return parent[x];
        }
    }
    explicit UnionFind(size_t size) {
        parent.resize(size);
        rank.resize(size);
        for (size_t i = 0; i < size; i++) {
            parent[i] = i;
            rank[i] = 0;
        }
    }
    virtual ~UnionFind() {}
    void unite(size_t x, size_t y) {
        size_t px = findParent(x);
        size_t py = findParent(y);
        if (px == py) {
            return;
        }
        if (rank[px] < rank[py]) {
            parent[px] = py;
        } else if (rank[px] > rank[py]) {
            parent[py] = px;
        } else { // rank[px] == rank[py]
            parent[py] = px;
            rank[px]++;
        }
    }
    bool isSame(size_t x, size_t y) {
        return findParent(x) == findParent(y);
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    struct Pl {
        int x;
        int y;
        Pl(int x, int y) : x(x), y(y) {}
        double dist(const Pl& rhs) const {
            return sqrt(pow((double)(x - rhs.x), 2.0) + pow((double)(y - rhs.y), 2.0));
        }
    };
    vector<Pl> piles;
    piles.reserve(N);
    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        piles.emplace_back(x, y);
    }
    struct Fc {
        int a;
        int b;
        double len;
        Fc(int a, int b, double len) : a(a), b(b), len(len) {}
        static bool compareLen(const Fc& lhs, const Fc& rhs) {
            return lhs.len > rhs.len;
        }
    };
    vector<Fc> fences;
    fences.reserve(M);
    double totalLen = 0.0;
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        double len = piles[a].dist(piles[b]);
        fences.emplace_back(a, b, len);
        totalLen += len;
    }
    sort(fences.begin(), fences.end(), Fc::compareLen);
    UnionFind uf(N);
    double lenSum = 0.0;
    for (Fc fc : fences) {
        if (!uf.isSame(fc.a, fc.b)) {
            uf.unite(fc.a, fc.b);
            lenSum += fc.len;
        }
    }
    cout << totalLen - lenSum << endl;
    return 0;
}



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

#include <iostream>
using namespace std;

const int INF = 1000000000;

int main()
{
	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		int T[10][10];
		for(int i=0; i<10; i++){
			for(int j=0; j<10; j++){
				if(i==j){
					T[i][j] = 0;
				}
				else{
					T[i][j] = INF;
				}
			}
		}

		int m = 0;

		for(int i=0; i<n; i++){
			int a, b, c;
			cin >> a >> b >> c;

			T[a][b] = T[b][a] = c;

			if(a+1>m){
				m = a+1;
			}
			if(b+1>m){
				m = b+1;
			}
		}
    for(int i =0;i<m;i++){
      for(int j =0;j<m;j++){
        for(int k = 0;k<m;k++){
          if(T[j][k]>T[j][i]+T[i][k]){
            T[j][k]=T[j][i]+T[i][k];
          }
        }
      }
    }
    int anstown,anstime=INF;
    for(int i =0;i<m;i++){
      int sumtime=0;
      for(int j = 0;j<m;j++){
        sumtime+=Time[i][j];
      }
      if(anstime>sumtime){
        anstown = i;
        anstime = sumtime;
      }
    }
    cout << anstonw <<" "<<anstime<<endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:55:18: error: 'Time' was not declared in this scope; did you mean 'time'?
   55 |         sumtime+=Time[i][j];
      |                  ^~~~
      |                  time
a.cc:62:13: error: 'anstonw' was not declared in this scope; did you mean 'anstown'?
   62 |     cout << anstonw <<" "<<anstime<<endl;
      |             ^~~~~~~
      |             anstown
Language: C++

// 2014/06/16 Tazoe

#include <iostream>
using namespace std;

const int INF = 1000000000;

int main()
{
	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		int T[10][10];
		for(int i=0; i<10; i++){
			for(int j=0; j<10; j++){
				if(i==j){
					T[i][j] = 0;
				}
				else{
					T[i][j] = INF;
				}
			}
		}

		int m = 0;		// ���̑���

		for(int i=0; i<n; i++){
			int a, b, c;
			cin >> a >> b >> c;

			T[a][b] = T[b][a] = c;

			if(a+1>m){
				m = a+1;
			}
			if(b+1>m){
				m = b+1;
			}
		}

    for(int k=0;k<m;k++){
      for(int i=0;i<m;i++){
        for(int j=0;j<m;j++){
          if(T[i][j] > T[i][k]+T[k][j])
            T[i][j] = T[i][k] + T[k][j];
        }
      }
    }
    int min_town_n;
    int min_town_time;
    for(int k=0;k<m;k++){
      int sub;
      for(int i=0;i<m;i++){
        sub += T[k][i];
      }
      if(min_town_time > sub){
        min_town_time = sub;
        min_town_time_n;
      }
    }
    cout << min_town_n << ' ' << min_town_time << endl;
	}

	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:62:9: error: 'min_town_time_n' was not declared in this scope; did you mean 'min_town_time'?
   62 |         min_town_time_n;
      |         ^~~~~~~~~~~~~~~
      |         min_town_time
Language: C++

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

using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 9999999

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;


bool shortestPath(const Graph &g,
    Matrix &dist, vector<vector<int> > &prev) {
  int n = g.size();
  Array h(n+1);
  REP(k,n) REP(i,n) FOR(e,g[i]) {
    if (h[e->dst] > h[e->src] + e->weight) {
      h[e->dst] = h[e->src] + e->weight;
      if (k == n-1) return false; // negative cycle
    }
  }
  dist.assign(n, Array(n, INF));
  prev.assign(n, vector<int>(n, -2));
  REP(s, n) {
    priority_queue<Edge> Q;
    Q.push(Edge(s, s, 0));
    while (!Q.empty()) {
      Edge e = Q.top(); Q.pop();
      if (prev[s][e.dst] != -2) continue;
      prev[s][e.dst] = e.src;
      FOR(f,g[e.dst]) {
        if (dist[s][f->dst] > e.weight + f->weight) {
          dist[s][f->dst] = e.weight + f->weight;
          Q.push(Edge(f->src, f->dst, e.weight + f->weight));
        }
      }
    }
    REP(u, n) dist[s][u] += h[u] - h[s];
  }
}
vector<int> buildPath(const vector< vector<int> >& prev, int s, int t) {
  vector<int> path;
  for (int u = t; u >= 0; u = prev[s][u])
    path.push_back(u);
  reverse(ALL(path));
  return path;
}

int main() {
	int n;
	while(cin>>n,n){
		Graph g(10);
		Matrix d;
		vector<vector<int> > p;
		REP(i,n){
			int a,b,c;
			cin>>a>>b>>c;
			g[a].push_back(Edge(a,b,c));
			g[b].push_back(Edge(b,a,c));
		}
		shortestPath(g,d,p);

		int mn=INF,t,mi;
		REP(i,d.size()){
			if(d[i][0]==INF)continue;
			t=0;
			REP(j,d[i].size()){
				if(d[i][j]==INF||i==j)continue;
				t+=d[i][j];
			}
			if(t<mn)mn=t,mi=i;
		}
		cout<<mi<<" "<<mn<<endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'std::vector<int> buildPath(const std::vector<std::vector<int> >&, int, int)':
a.cc:63:3: error: 'reverse' was not declared in this scope
   63 |   reverse(ALL(path));
      |   ^~~~~~~
a.cc: In function 'bool shortestPath(const Graph&, Matrix&, std::vector<std::vector<int> >&)':
a.cc:58:1: warning: control reaches end of non-void function [-Wreturn-type]
   58 | }
      | ^
Language: C++

#include<iostream>
#include<queue>
#define HOME 10
#define ROAD 45
#define MAX  100000000
using namespace std;

int dis[HOME][HOME];
bool chk[HOME];

class Datum {
public:
	int now;
	int dis;

	Datum(int n, int d) {now = n;dis = d;}
	Datum() {}
};

bool operator<( const Datum& a, const Datum& b ) {
	return a.dis < b.dis;
}

bool operator>( const Datum& a, const Datum& b ) {
	return a.dis > b.dis;
}

int main () {
	while ( true ) {
		int n;
		cin >> n;
		
		if ( n ==  0 ) 
			break;

		for ( int i=0; i<HOME;i ++ ) {
			for ( int j=0; j<HOME; j++ ) {
				dis[i][j] = MAX;
			}
		}

		int find = -1;
		for ( int i=0;i<n; i++ ) {
			int from, to, distance;
			cin >> from >> to >> distance;
			
			if ( find < to )
				find = to;
			if ( find < from )
				find = from;

			dis[from][to] = distance;
			dis[to][from] = distance;

			dis[i][i] = 0;
		}

		n = find+1;

		priority_queue<Datum, vector<Datum>, greater<Datum> > flow;

		while( !flow.empty() ) {
			flow.pop();
		}

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

			while( !flow.empty() ) {
				flow.pop();
			}

			flow.push(Datum(i,0));
			int count = n;

			memset( chk, false, n*sizeof(bool) );

			while(!flow.empty()) {
				Datum now;
				now = flow.top();
				flow.pop();

				for ( int j=0; j<n; j++ ) {
					if ( i != j ) {
						if ( chk[j] )
							continue;

						if ( dis[now.now][j] + now.dis <= dis[i][j] ) {
							dis[i][j] = dis[now.now][j] + now.dis;
							dis[j][i] = dis[now.now][j] + now.dis;

							if ( dis[now.now][j] == MAX )
							continue;

							chk[j] = true;
							count--;
	
							flow.push(Datum(j,dis[i][j]));
							
						}
					}
				}

				if ( count == 1 ) {
					break;
				}
			}
		}



		int maxhome = -1;
		int maxdis = MAX;
		for ( int i=0; i<n; i++ ) {
			int sum = 0;
			
			for ( int j=0; j<n; j++ ) {
				sum += dis[i][j];
			}
			
			if ( maxdis > sum ) {
				maxdis = sum;
				maxhome = i;
			}
		}

		cout << maxhome << ' ' << maxdis << endl;
	}
}

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

#include<cstdio>
#include<iostream>
#include<string>
#include<map>
#include<queue>
#include<set>

using namespace std;

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

int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0)break;
		
		int dp[111][111]={0};
		rep(i,111)rep(j,111)dp[i][j]=1000000000;
		
		rep(i,n){
			int a,b,c;
			cin>>a>>b>>c;
			dp[a][b]=c;
			dp[b][a]=c;
		}
		rep(i,111)dp[i][i]=0;
		
		rep(k,n){
			rep(i,n){
				rep(j,n){
					dp[i][j] = min(dp[i][k]+dp[k][j],dp[i][j]);
				}
			}
		}
		
		
		int ans=1000000000;
		rep(i,n){
			int sum=0;
			rep(j,m){
				sum+=dp[i][j];
			}
			ans = min(ans,sum);
		}
		printf("%d\n",ans);
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:31: error: 'm' was not declared in this scope
   42 |                         rep(j,m){
      |                               ^
a.cc:10:32: note: in definition of macro 'rep'
   10 | #define rep(i,n) for(int i=0;i<n;i++)
      |                                ^
Language: C++

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

const int INF = INT_MAX/10;

using namespace std;

const int V_MAX = 10;
const int E_MAX = 45;


typedef pair<int, int> P; // v, cost

int main() {
  int N;
  while (cin >> N) {
    int V = 0;
    int d[V_MAX][V_MAX];
    if (N == 0) break;
    for (int i = 0; i < V_MAX; i++) {
      for (int j = 0; j < V_MAX; j++) {
        if (i == j) d[i][j] = 0;
        else d[i][j] = INF;
      }
    }
    for (int i = 0; i < N; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      d[a][b] = c;
      d[b][a] = c;
      V = max(V, a); V = max(V, b);
    }
    for (int k = 0; k <= V; k++) {
      for (int i = 0; i <= V; i++) {
        for (int j = 0; j <= V; j++) {
          d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
      }
    }
    int m = INF;
    int ans = -1;
    for (int i = 0; i <= V; i++) {
      int sum = 0;
      for (int j = 0; j <= V; j++) {
        if (i != j) {
          if (d[i][j] != INF) {
            sum += d[i][j];
          }
        }
      }
      if (sum < m) {
        m = sum;
        ans = i;
      }
    }
    printf("%d %d\n", ans, m);
  }

  return 0;
}

Compiler output:
a.cc:5:17: error: 'INT_MAX' was not declared in this scope
    5 | const int INF = INT_MAX/10;
      |                 ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <queue>
  +++ |+#include <climits>
    4 |
Language: C++

#include <cstdio>
#include <algorithm>

using namespace std;

int map[10][10];

int cmp(int i,int j,int k){
  if(map[i][j]==-1){
    if(map[i][k]>=0 && map[k][j]>=0)
      return map[i][k]+map[k][j];
    else
      return -1;
  }else
    if(map[i][k]==-1 || map[k][j]==-1)
      return map[i][j];
    else
      return min(map[i][j],map[i][k]+map[k][j]);
}

int main(){
  for(int n;scanf("%d",&n),n;){
    int m=0;
    memset(map,-1,sizeof(map));

    for(;n--;){
      int a,b,c;
      scanf("%d %d %d",&a,&b,&c);
      m=m>a?m:a;m=n>b?m:b;
      map[a][b] = map[b][a] = c;
    }

    for(int i=0; i<=m; i++)
      map[i][i] = 0;

    for(int k=0; k<=m; k++)
      for(int i=0; i<=m; i++)
	for(int j=0; j<=m; j++)
	  map[i][j] = cmp(i,j,k);

    // for(int i=0; i<=m; i++){
    //   for(int j=0; j<=m; j++)
    // 	printf("%3d ",map[i][j]);
    //   putchar('\n');
    // }

    int num,sum=-1;
    for(int i=0; i<=m; i++){
      int tsum=0;
      for(int j=0; j<=m; j++)
	tsum += map[i][j];
      if(sum==-1||tsum<sum){
	num=i; sum=tsum;
      }
    }

    printf("%d %d\n",num,sum);
  }
}

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

#include <cstdio>
#include <algorithm>

using namespace std;

int map[10][10];

int cmp(int i,int j,int k){
  if(map[i][j]==-1){
    if(map[i][k]>=0 && map[k][j]>=0)
      return map[i][k]+map[k][j];
    else
      return -1;
  }else
    if(map[i][k]==-1 || map[k][j]==-1)
      return map[i][j];
    else
      return min(map[i][j],map[i][k]+map[k][j]);
}

int main(){
  for(int n;scanf("%d",&n),n;){
    int m=0;
    memset(map,-1,sizeof(map));

    for(;n--;){
      int a,b,c;
      scanf("%d %d %d",&a,&b,&c);
      m=m>a?m:a;m=n>b?m:b;
      map[a][b] = map[b][a] = c;
    }

    for(int i=0; i<=m; i++)
      map[i][i] = 0;

    for(int k=0; k<=m; k++)
      for(int i=0; i<=m; i++)
	for(int j=0; j<=m; j++)
	  map[i][j] = cmp(i,j,k);

    // for(int i=0; i<=m; i++){
    //   for(int j=0; j<=m; j++)
    // 	printf("%3d ",map[i][j]);
    //   putchar('\n');
    // }

    int num,sum=-1;
    for(int i=0; i<=m; i++){
      int tsum=0;
      for(int j=0; j<=m; j++)
	tsum += map[i][j];
      if(sum==-1||tsum<sum){
	num=i; sum=tsum;
      }
    }

    printf("%d %d\n",num,sum);
  }

  return 0;
}

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

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

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

const int TOWN = 11;
const int ROAD = 50;
const int INF = 10000;

int d[TOWN][TOWN] ;

int n,a,b,c;
int main()
{
	while(cin >> n && n)
	{
		memset(d,INF,sizeof(d));
		int townnum = 0;
		REP(n)
		{
			cin>> a >> b >> c;
			d[a][b] = c;
			d[b][a] = c;
			d[i][i] = 0;
			townnum = max(townnum,a);
			townnum = max(townnum,b);
		}
		//cout << "town "<<townnum << endl;
		rep(k,townnum+1)rep(i,townnum+1)rep(j,townnum+1)//if(d[i][j] != INF)
		{
			d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
			d[j][i] = d[i][j];
		}
		int time = 1000000,town = 0;
		
		rep(i,townnum+1)//town i
		{
			int sum = 0;
			rep(j,townnum+1) sum += d[i][j];//i to j
			//cout << sum << endl;
			if(sum < time){ time = sum; town = i;}
		}
		cout << town << " " << time << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:15: error: 'cin' was not declared in this scope
   19 |         while(cin >> n && n)
      |               ^~~
a.cc:5:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    4 | #include<cmath>
  +++ |+#include <iostream>
    5 | using namespace std;
a.cc:47:17: error: 'cout' was not declared in this scope
   47 |                 cout << town << " " << time << endl;
      |                 ^~~~
a.cc:47:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:47:48: error: 'endl' was not declared in this scope
   47 |                 cout << town << " " << time << endl;
      |                                                ^~~~
a.cc:5:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    4 | #include<cmath>
  +++ |+#include <ostream>
    5 | using namespace std;
Language: C++

#include<iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#define inf 1000000000
using namespace std;
unsigned long long d[10][10],sum[10];
int v;

int main()
{
	int n;
	while(cin>>n,n)
	{
		bool used[10];
		memset(used,0,sizeof(used));
		memset(d,0,sizeof(d));
		memset(sum,0,sizeof(sum));
		for(int i=0;i<n;i++)
		{
			int s,t,c;
			cin>>s>>t>>c;
			used[s]=used[t]=true;
			d[s][t]=d[t][s]=c;
		}
		v=0;
		for(int i=0;i<10;i++)
		{
			if(used[i]) v++;
			for(int j=0;j<10;j++)
			{
				if(d[i][j]==0&&i!=j) d[i][j]=inf;
			}
		}

		for(int k=0;k<v;k++)
		{
			for(int i=0;i<v;i++)
			{
				for(int j=0;j<v;j++) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			}
		}

		int ans;
		for(int i=0;i<v;i++)
		{
			for(int j=0;j<v;j++)
			{
				sum[i]+=d[i][j];
			}
		}
		ans=min_element(sum,sum+v)-sum;
		cout<<ans<<" "<<sum[ans]<<endl;

	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:52:21: error: 'min_element' was not declared in this scope
   52 |                 ans=min_element(sum,sum+v)-sum;
      |                     ^~~~~~~~~~~
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
#define INF 10000
#define MAXV 45

int dist[MAXV][MAXV];

int main(void){
	int n;

	while(1){
		int town=0;

		cin >> n;
		if(n==0)break;

		memset(dist,INF,sizeof(int)*MAXV*MAXV);
		for(int i=0; i<n; i++){
			int from,to,cost;
			cin >> from >> to >> cost;
			dist[from][to] = cost;
			dist[to][from] = cost;
			town = max(town,max(to,from));
		}
		town++;

		for(int i=0; i<town; i++)
			dist[i][i] = 0;
		
		for(int k=0; k<town; k++)
			for(int i=0; i<town; i++)
				for(int j=0; j<town; j++)
					dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);

		/*
		for(int i=0; i<town; i++){
			for(int j=0; j<town; j++){
				printf("%3d",dist[i][j]);
			}
			printf("\n");
		}
		*/
		
		int mincost=INF;
		int mintown;
		for(int i=0; i<town; i++){
			int cost=0;
			for(int j=0; j<town; j++)
				cost += dist[i][j];
			if(mincost>cost){
				mincost = cost;
				mintown = i;
			}
		}

		cout << mintown << " " << mincost << endl;
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:17: error: 'memset' was not declared in this scope
   18 |                 memset(dist,INF,sizeof(int)*MAXV*MAXV);
      |                 ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include<algorithm>
  +++ |+#include <cstring>
    3 | using namespace std;
Language: C++

#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define INF 10000
#define MAXV 45

int dist[MAXV][MAXV];

int main(void){
	int n;

	while(1){
		int town=0;

		cin >> n;
		if(n==0)break;

		memset(dist,INF,sizeof(int)*MAXV*MAXV);
		for(int i=0; i<n; i++){
			int from,to,cost;
			cin >> from >> to >> cost;
			dist[from][to] = cost;
			dist[to][from] = cost;
			town = max(town,max(to,from));
		}
		town++;

		for(int i=0; i<town; i++)
			dist[i][i] = 0;
		
		for(int k=0; k<town; k++)
			for(int i=0; i<town; i++)
				for(int j=0; j<town; j++)
					dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);

		/*
		for(int i=0; i<town; i++){
			for(int j=0; j<town; j++){
				printf("%3d",dist[i][j]);
			}
			printf("\n");
		}
		*/
		
		int mincost=INF;
		int mintown;
		for(int i=0; i<town; i++){
			int cost=0;
			for(int j=0; j<town; j++)
				cost += dist[i][j];
			if(mincost>cost){
				mincost = cost;
				mintown = i;
			}
		}

		cout << mintown << " " << mincost << endl;
	}

	return 0;
}

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

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

using namespace std;

int main(){
	while(true){
		int n;
		cin >> n;

		if(n == 0){
			break;
		}

		int* start = new int[n];
		int* goal = new int[n];
		int* cost = new int[n];

		for(int i = 0; i < n; i++){
			cin >> start[i] >> goal[i] >> cost[i];
		}

		int town = 0;

		for(int i = 0; i < n; i++){
			town = max(town ,start[i], goal[i]);
		}

		town++;

		vector<vector<int> > dist(town, vector<int>(town, INT_MAX / 2));

		for(int i = 0; i < n; i++){
			dist[start[i]][goal[i]] = cost[i];
			dist[goal[i]][start[i]] = cost[i];
		}

		for(int i = 0; i < town; i++){
			dist[i][i] = 0;
		}


		for(int k = 0; k < town; k++){
			for(int i = 0; i < town; i++){
				for(int j = 0; j < town; j++){
					dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
				}
			}
		}
		int* total = new int[town];
		int TOTAL = INT_MAX / 2;
		int S = 0;

		for(int i = 0; i < town; i++){
			total[i] = 0;
		}

		for(int i = 0; i < town; i++){
			for(int j = 0; j < town; j++){
				total[i] += dist[i][j];
			}
			if(TOTAL > total[i]){
				TOTAL = min(TOTAL, total[i]);
				S = i;
			}
		}

		cout << S << " " << TOTAL << endl;
		delete [] start;
		delete [] goal;
		delete [] cost;
		delete [] total;
	}
	return 0;
}

Compiler output:
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare) [with _Tp = int; _Compare = int]':
a.cc:28:14:   required from here
   28 |                         town = max(town ,start[i], goal[i]);
      |                                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:306:17: error: '__comp' cannot be used as a function
  306 |       if (__comp(__a, __b))
      |           ~~~~~~^~~~~~~~~~
Language: C++

#include<cmath>
#include<cctype>
#include<cstdlib>
#include<cstdio>

#include<iostream>
#include<algorithm>
#include<vector>
#include<deque>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<utility>
#include<queue>

using namespace std;
const int MAX = 10;
const int INF = INT_MAX/3;
int main(){
  ios::sync_with_stdio(false);
  int cost[MAX][MAX];
  bool existTown[MAX];
  int n;
  while(cin >> n && n != 0){
    fill(*cost,*(cost+MAX),INF);
    fill(existTown,existTown+MAX,false);
    for(int i = 0;i < n;i++){
      int a,b,c;
      cin >> a >> b >> c;
      cost[a][b] = cost[b][a] = c;
      existTown[a] = existTown[b] = true;
    }

    for (int k = 0; k < MAX; ++k){
      for (int j = 0; j < MAX; ++j){
	for (int i = 0; i < MAX; ++i){
	  int sum = cost[i][k] + cost[k][j];
	  if(cost[i][j] > sum){
	    cost[i][j] = cost[j][i] = sum;
	  }
	}
      }
    }
    /*
    for (int i = 0; i < MAX; ++i){
      for (int j = 0; j < MAX; ++j){
	if(cost[i][j] == INF)cout << INF;
	else cout << cost[i][j];
	cout << ' ';
      }
      cout << endl;
    }
    */
    int ans = 100;
    int mini = INF;
    for(int i = 0;i < MAX;i++){
      if(!existTown[i])continue;
      int sum = 0;
      for(int j = 0;j < MAX;j++){
	if(existTown[j] && j != i)sum += cost[i][j];
      }
      if(mini > sum){
	mini = sum;
	ans = i;
      }
    }
    cout << ans  << ' ' << mini << endl;
  }
  
  return 0;
}

Compiler output:
a.cc:19:17: error: 'INT_MAX' was not declared in this scope
   19 | const int INF = INT_MAX/3;
      |                 ^~~~~~~
a.cc:15:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   14 | #include<utility>
  +++ |+#include <climits>
   15 | #include<queue>