Language: C

cn,cake[6];wn,wg[106][106];ln,lg[8][8];getid(){char s[9];int r;scanf("%s",s);if(*s=='C')r=atoi(s+1)-1;else if(*s=='H')r=cn;else if(*s=='D')r=cn+1;elser=cn+1+atoi(s+1);return r;}dijkstra(s){int cost[106],d[106]={0},c,n,i,t;memset(cost,1,sizeof(cost));c=s;cost[c]=0;for(;c>=0;){d[c]=1;n=-1;for(i=0;i<wn;i++){if(!d[i]){if(c>=cn||c==s){t=cost[c]+wg[c][i];if(t<cost[i])cost[i]=t;}if(n<0||cost[i]<cost[n])n=i;}}c=n;}for(i=0;i<ln;i++){lg[s][i]=cost[i];}}solve(){int dp[1<<8][8],home=cn,dest=cn+1,b,i,j,nb,t,ans;memset(dp,1,sizeof(dp));dp[1<<home][home]=0;for(b=0;b<1<<ln;b++)for(i=0;i<ln;i++)if(b&1<<i)for(j=0;j<ln;j++)if(~b&1<<j){nb=b|1<<j;t=dp[b][i]+lg[i][j];if(t<dp[nb][j])dp[nb][j]=t;}ans=1e8;for(b=1<<home|1<<dest;b<1<<ln;b++){t=dp[b][dest];for(i=0;i<cn;i++)if(b&1<<i)t-=cake[i];if(t<ans)ans=t;}return ans;}main(){int k,d;int i;for(;scanf("%d%d%d%d",&cn,&wn,&k,&d),cn;){ln=cn+2;wn+=ln;for(i=0;i<cn;i++)scanf("%d",cake+i);memset(wg,1,sizeof(wg));for(;d--;){int a,b,c;a=getid(),b=getid();scanf("%d",&c);wg[a][b]=wg[b][a]=c*k;}for(i=0;i<ln;i++)dijkstra(i);printf("%d\n",solve());}exit(0);}

Compiler output:
main.c:1:1: warning: data definition has no type or storage class
    1 | cn,cake[6];wn,wg[106][106];ln,lg[8][8];getid(){char s[9];int r;scanf("%s",s);if(*s=='C')r=atoi(s+1)-1;else if(*s=='H')r=cn;else if(*s=='D')r=cn+1;elser=cn+1+atoi(s+1);return r;}dijkstra(s){int cost[106],d[106]={0},c,n,i,t;memset(cost,1,sizeof(cost));c=s;cost[c]=0;for(;c>=0;){d[c]=1;n=-1;for(i=0;i<wn;i++){if(!d[i]){if(c>=cn||c==s){t=cost[c]+wg[c][i];if(t<cost[i])cost[i]=t;}if(n<0||cost[i]<cost[n])n=i;}}c=n;}for(i=0;i<ln;i++){lg[s][i]=cost[i];}}solve(){int dp[1<<8][8],home=cn,dest=cn+1,b,i,j,nb,t,ans;memset(dp,1,sizeof(dp));dp[1<<home][home]=0;for(b=0;b<1<<ln;b++)for(i=0;i<ln;i++)if(b&1<<i)for(j=0;j<ln;j++)if(~b&1<<j){nb=b|1<<j;t=dp[b][i]+lg[i][j];if(t<dp[nb][j])dp[nb][j]=t;}ans=1e8;for(b=1<<home|1<<dest;b<1<<ln;b++){t=dp[b][dest];for(i=0;i<cn;i++)if(b&1<<i)t-=cake[i];if(t<ans)ans=t;}return ans;}main(){int k,d;int i;for(;scanf("%d%d%d%d",&cn,&wn,&k,&d),cn;){ln=cn+2;wn+=ln;for(i=0;i<cn;i++)scanf("%d",cake+i);memset(wg,1,sizeof(wg));for(;d--;){int a,b,c;a=getid(),b=getid();scanf("%d",&c);wg[a][b]=wg[b][a]=c*k;}for(i=0;i<ln;i++)dijkstra(i);printf("%d\n",solve());}exit(0);}
      | ^~
main.c:1:1: error: type defaults to 'int' in declaration of 'cn' [-Wimplicit-int]
main.c:1:4: error: type defaults to 'int' in declaration of 'cake' [-Wimplicit-int]
    1 | cn,cake[6];wn,wg[106][106];ln,lg[8][8];getid(){char s[9];int r;scanf("%s",s);if(*s=='C')r=atoi(s+1)-1;else if(*s=='H')r=cn;else if(*s=='D')r=cn+1;elser=cn+1+atoi(s+1);return r;}dijkstra(s){int cost[106],d[106]={0},c,n,i,t;memset(cost,1,sizeof(cost));c=s;cost[c]=0;for(;c>=0;){d[c]=1;n=-1;for(i=0;i<wn;i++){if(!d[i]){if(c>=cn||c==s){t=cost[c]+wg[c][i];if(t<cost[i])cost[i]=t;}if(n<0||cost[i]<cost[n])n=i;}}c=n;}for(i=0;i<ln;i++){lg[s][i]=cost[i];}}solve(){int dp[1<<8][8],home=cn,dest=cn+1,b,i,j,nb,t,ans;memset(dp,1,sizeof(dp));dp[1<<home][home]=0;for(b=0;b<1<<ln;b++)for(i=0;i<ln;i++)if(b&1<<i)for(j=0;j<ln;j++)if(~b&1<<j){nb=b|1<<j;t=dp[b][i]+lg[i][j];if(t<dp[nb][j])dp[nb][j]=t;}ans=1e8;for(b=1<<home|1<<dest;b<1<<ln;b++){t=dp[b][dest];for(i=0;i<cn;i++)if(b&1<<i)t-=cake[i];if(t<ans)ans=t;}return ans;}main(){int k,d;int i;for(;scanf("%d%d%d%d",&cn,&wn,&k,&d),cn;){ln=cn+2;wn+=ln;for(i=0;i<cn;i++)scanf("%d",cake+i);memset(wg,1,sizeof(wg));for(;d--;){int a,b,c;a=getid(),b=getid();scanf("%d",&c);wg[a][b]=wg[b][a]=c*k;}for(i=0;i<ln;i++)dijkstra(i);printf("%d\n",solve());}exit(0);}
      |    ^~~~
main.c:1:12: warning: data definition has no type or storage class
    1 | cn,cake[6];wn,wg[106][106];ln,lg[8][8];getid(){char s[9];int r;scanf("%s",s);if(*s=='C')r=atoi(s+1)-1;else if(*s=='H')r=cn;else if(*s=='D')r=cn+1;elser=cn+1+atoi(s+1);return r;}dijkstra(s){int cost[106],d[106]={0},c,n,i,t;memset(cost,1,sizeof(cost));c=s;cost[c]=0;for(;c>=0;){d[c]=1;n=-1;for(i=0;i<wn;i++){if(!d[i]){if(c>=cn||c==s){t=cost[c]+wg[c][i];if(t<cost[i])cost[i]=t;}if(n<0||cost[i]<cost[n])n=i;}}c=n;}for(i=0;i<ln;i++){lg[s][i]=cost[i];}}solve(){int dp[1<<8][8],home=cn,dest=cn+1,b,i,j,nb,t,ans;memset(dp,1,sizeof(dp));dp[1<<home][home]=0;for(b=0;b<1<<ln;b++)for(i=0;i<ln;i++)if(b&1<<i)for(j=0;j<ln;j++)if(~b&1<<j){nb=b|1<<j;t=dp[b][i]+lg[i][j];if(t<dp[nb][j])dp[nb][j]=t;}ans=1e8;for(b=1<<home|1<<dest;b<1<<ln;b++){t=dp[b][dest];for(i=0;i<cn;i++)if(b&1<<i)t-=cake[i];if(t<ans)ans=t;}return ans;}main(){int k,d;int i;for(;scanf("%d%d%d%d",&cn,&wn,&k,&d),cn;){ln=cn+2;wn+=ln;for(i=0;i<cn;i++)scanf("%d",cake+i);memset(wg,1,sizeof(wg));for(;d--;){int a,b,c;a=getid(),b=getid();scanf("%d",&c);wg[a][b]=wg[b][a]=c*k;}for(i=0;i<ln;i++)dijkstra(i);printf("%d\n",solve());}exit(0);}
      |            ^~
main.c:1:12: error: type defaults to 'int' in declaration of 'wn' [-Wimplicit-int]
main.c:1:15: error: type defaults to 'int' in declaration of 'wg' [-Wimplicit-int]
    1 | cn,cake[6];wn,wg[106][106];ln,lg[8][8];getid(){char s[9];int r;scanf("%s",s);if(*s=='C')r=atoi(s+1)-1;else if(*s=='H')r=cn;else if(*s=='D')r=cn+1;elser=cn+1+atoi(s+1);return r;}dijkstra(s){int cost[106],d[106]={0},c,n,i,t;memset(cost,1,sizeof(cost));c=s;cost[c]=0;for(;c>=0;){d[c]=1;n=-1;for(i=0;i<wn;i++){if(!d[i]){if(c>=cn||c==s){t=cost[c]+wg[c][i];if(t<cost[i])cost[i]=t;}if(n<0||cost[i]<cost[n])n=i;}}c=n;}for(i=0;i<ln;i++){lg[s][i]=cost[i];}}solve(){int dp[1<<8][8],home=cn,dest=cn+1,b,i,j,nb,t,ans;memset(dp,1,sizeof(dp));dp[1<<home][home]=0;for(b=0;b<1<<ln;b++)for(i=0;i<ln;i++)if(b&1<<i)for(j=0;j<ln;j++)if(~b&1<<j){nb=b|1<<j;t=dp[b][i]+lg[i][j];if(t<dp[nb][j])dp[nb][j]=t;}ans=1e8;for(b=1<<home|1<<dest;b<1<<ln;b++){t=dp[b][dest];for(i=0;i<cn;i++)if(b&1<<i)t-=cake[i];if(t<ans)ans=t;}return ans;}main(){int k,d;int i;for(;scanf("%d%d%d%d",&cn,&wn,&k,&d),cn;){ln=cn+2;wn+=ln;for(i=0;i<cn;i++)scanf("%d",cake+i);memset(wg,1,sizeof(wg));for(;d--;){int a,b,c;a=getid(),b=getid();scanf("%d",&c);wg[a][b]=wg[b][a]=c*k;}for(i=0;i<ln;i++)dijkstra(i);printf("%d\n",solve());}exit(0);}
      |               ^~
main.c:1:28: warning: data definition has no type or storage class
    1 | cn,cake[6];wn,wg[106][106];ln,lg[8][8];getid(){char s[9];int r;scanf("%s",s);if(*s=='C')r=atoi(s+1)-1;else if(*s=='H')r=cn;else if(*s=='D')r=cn+1;elser=cn+1+atoi(s+1);return r;}dijkstra(s){int cost[106],d[106]={0},c,n,i,t;memset(cost,1,sizeof(cost));c=s;cost[c]=0;for(;c>=0;){d[c]=1;n=-1;for(i=0;i<wn;i++){if(!d[i]){if(c>=cn||c==s){t=cost[c]+wg[c][i];if(t<cost[i])cost[i]=t;}if(n<0||cost[i]<cost[n])n=i;}}c=n;}for(i=0;i<ln;i++){lg[s][i]=cost[i];}}solve(){int dp[1<<8][8],home=cn,dest=cn+1,b,i,j,nb,t,ans;memset(dp,1,sizeof(dp));dp[1<<home][home]=0;for(b=0;b<1<<ln;b++)for(i=0;i<ln;i++)if(b&1<<i)for(j=0;j<ln;j++)if(~b&1<<j){nb=b|1<<j;t=dp[b][i]+lg[i][j];if(t<dp[nb][j])dp[nb][j]=t;}ans=1e8;for(b=1<<home|1<<dest;b<1<<ln;b++){t=dp[b][dest];for(i=0;i<cn;i++)if(b&1<<i)t-=cake[i];if(t<ans)ans=t;}return ans;}main(){int k,d;int i;for(;scanf("%d%d%d%d",&cn,&wn,&k,&d),cn;){ln=cn+2;wn+=ln;for(i=0;i<cn;i++)scanf("%d",cake+i);memset(wg,1,sizeof(wg));for(;d--;){int a,b,c;a=getid(),b=getid();scanf("%d",&c);wg[a][b]=wg[b][a]=c*k;}for(i=0;i<ln;i++)dijkstra(i);printf("%d\n",solve());}exit(0);}
      |                            ^~
main.c:1:28: error: type defaults to 'int' in declaration of 'ln' [-Wimplicit-int]
main.c:1:31: error: type defaults to 'int' in declaration of 'lg' [-Wimplicit-int]
    1 | cn,cake[6];wn,wg[106][106];ln,lg[8][8];getid(){char s[9];int r;scanf("%s",s);if(*s=='C')r=atoi(s+1)-1;else if(*s=='H')r=cn;else if(*s=='D')r=cn+1;elser=cn+1+atoi(s+1);return r;}dijkstra(s){int cost[106],d[106]={0},c,n,i,t;memset(cost,1,sizeof(cost));c=s;cost[c]=0;for(;c>=0;){d[c]=1;n=-1;for(i=0;i<wn;i++){if(!d[i]){if(c>=cn||c==s){t=cost[c]+wg[c][i];if(t<cost[i])cost[i]=t;}if(n<0||cost[i]<cost[n])n=i;}}c=n;}for(i=0;i<ln;i++){lg[s][i]=cost[i];}}solve(){int dp[1<<8][8],home=cn,dest=cn+1,b,i,j,nb,t,ans;memset(dp,1,sizeof(dp));dp[1<<home][home]=0;for(b=0;b<1<<ln;b++)for(i=0;i<ln;i++)if(b&1<<i)for(j=0;j<ln;j++)if(~b&1<<j){nb=b|1<<j;t=dp[b][i]+lg[i][j];if(t<dp[nb][j])dp[nb][j]=t;}ans=1e8;for(b=1<<home|1<<dest;b<1<<ln;b++){t=dp[b][dest];for(i=0;i<cn;i++)if(b&1<<i)t-=cake[i];if(t<ans)ans=t;}return ans;}main(){int k,d;int i;for(;scanf("%d%d%d%d",&cn,&wn,&k,&d),cn;){ln=cn+2;wn+=ln;for(i=0;i<cn;i++)scanf("%d",cake+i);memset(wg,1,sizeof(wg));for(;d--;){int a,b,c;a=getid(),b=getid();scanf("%d",&c);wg[a][b]=wg[b][a]=c*k;}for(i=0;i<ln;i++)dijkstra(i);printf("%d\n",solve());}exit(0);}
      |                               ^~
main.c:1:40: error: return type defaults to 'int' [-Wimplicit-int]
    1 | cn,cake[6];wn,wg[106][106];ln,lg[8][8];getid(){char s[9];int r;scanf("%s",s);if(*s=='C')r=atoi(s+1)-1;else if(*s=='H')r=cn;else if(*s=='D')r=cn+1;elser=cn+1+atoi(s+1);return r;}dijkstra(s){int cost[106],d[106]={0},c,n,i,t;memset(cost,1,sizeof(cost));c=s;cost[c]=0;for(;c>=0;){d[c]=1;n=-1;for(i=0;i<wn;i++){if(!d[i]){if(c>=cn||c==s){t=cost[c]+wg[c][i];if(t<cost[i])cost[i]=t;}if(n<0||cost[i]<cost[n])n=i;}}c=n;}for(i=0;i<ln;i++){lg[s][i]=cost[i];}}solve(){int dp[1<<8][8],home=cn,dest=cn+1,b,i,j,nb,t,ans;memset(dp,1,sizeof(dp));dp[1<<home][home]=0;for(b=0;b<1<<ln;b++)for(i=0;i<ln;i++)if(b&1<<i)for(j=0;j<ln;j++)if(~b&1<<j){nb=b|1<<j;t=dp[b][i]+lg[i][j];if(t<dp[nb][j])dp[nb][j]=t;}ans=1e8;for(b=1<<home|1<<dest;b<1<<ln;b++){t=dp[b][dest];for(i=0;i<cn;i++)if(b&1<<i)t-=cake[i];if(t<ans)ans=t;}return ans;}main(){int k,d;int i;for(;scanf("%d%d%d%d",&cn,&wn,&k,&d),cn;){ln=cn+2;wn+=ln;for(i=0;i<cn;i++)scanf("%d",cake+i);memset(wg,1,sizeof(wg));for(;d--;){int a,b,c;a=getid(),b=getid();scanf("%d",&c);wg[a][b]=wg[b][a]=c*k;}for(i=0;i<ln;i++)dijkstra(i);printf("%d\n",solve());}exit(0);}
      |                                        ^~~~~
main.c: In function 'getid':
main.c:1:64: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    1 | cn,cake[6];wn,wg[106][106];ln,lg[8][8];getid(){char s[9];int r;scanf("%s",s);if(*s=='C')r=atoi(s+1)-1;else if(*s=='H')r=cn;else if(*s=='D')r=cn+1;elser=cn+1+atoi(s+1);return r;}dijkstra(s){int cost[106],d[106]={0},c,n,i,t;memset(cost,1,sizeof(cost));c=s;cost[c]=0;for(;c>=0;){d[c]=1;n=-1;for(i=0;i<wn;i++){if(!d[i]){if(c>=cn||c==s){t=cost[c]+wg[c][i];if(t<cost[i])cost[i]=t;}if(n<0||cost[i]<cost[n])n=i;}}c=n;}for(i=0;i<ln;i++){lg[s][i]=cost[i];}}solve(){int dp[1<<8][8],home=cn,dest=cn+1,b,i,j,nb,t,ans;memset(dp,1,sizeof(dp));dp[1<<home][home]=0;for(b=0;b<1<<ln;b++)for(i=0;i<ln;i++)if(b&1<<i)for(j=0;j<ln;j++)if(~b&1<<j){nb=b|1<<j;t=dp[b][i]+lg[i][j];if(t<dp[nb][j])dp[nb][j]=t;}ans=1e8;for(b=1<<home|1<<dest;b<1<<ln;b++){t=dp[b][dest];for(i=0;i<cn;i++)if(b&1<<i)t-=cake[i];if(t<ans)ans=t;}return ans;}main(){int k,d;int i;for(;scanf("%d%d%d%d",&cn,&wn,&k,&d),cn;){ln=cn+2;wn+=ln;for(i=0;i<cn;i++)scanf("%d",cake+i);memset(wg,1,sizeof(wg));for(;d--;){int a,b,c;a=getid(),b=getid();scanf("%d",&c);wg[a][b]=wg[b][a]=c*k;}for(i=0;i<ln;i++)dijkstra(i);printf("%d\n",solve());}exit(0);}
      |                                                                ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | cn,cake[6];wn,wg[106][106];ln,lg[8][8];getid(){char s[9];int r;scanf("%s",s);if(*s=='C')r=atoi(s+1)-1;else if(*s=='H')r=cn;else if(*s=='D')r=cn+1;elser=cn+1+atoi(s+1);return r;}dijkstra(s){int cost[106],d[106]={0},c,