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

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>

char output[80];

//mcxi¶ñ©çlÉÏ··éÌÉg¤Ö
int add(char a , int num){
	if(a=='m') return (1000*num);
	if(a=='c') return (100*num);
	if(a=='x') return (10*num);
	if(a=='i') return (1*num);

	return 0;
}

//l©çmcxi¶ñÉÏ··éÌÉg¤Ö
void chengeNum(int num){
	int index = 0, piyo, hoge;
	char str[2];
	char mcxi[5] = {'m','c','x','i','\0'};

	//4ñ[vµÄ»ê¼êçESE\EêÌÊÌðßé
	for(int i=0 ; i<4 ; i++){
		//piyo:ÊÌ
		hoge = 1;
		for(int j=0 ; j<4-i ; j++){
			hoge *= 10;
		}
		piyo = (num % hoge) / (hoge/10);

		//ÊÌÉ¶Ä¶ðüêé
		if( piyo > 0){
			if( piyo==1 ){
				output[index] = mcxi[i];
				index++;
			}
			else{
				itoa( piyo , str , 10);
				output[index] = str[0] ;
				output[index+1] = mcxi[i];
				index += 2;
			}
			output[index] = '\0';
		}
	}
}

int main(){
	int dataSet, num1 , num2, hoge, length1, length2;
	char input1[80], input2[80], piyo[2];

	//f[^ZbgÌüÍ
	scanf("%d", &dataSet);
	
	//f[^ZbgÌ¾¯üÍ³¹é
	for(int i=0 ; i<dataSet ; i++){
		//ÏÌú»
		num1 = 0;
		num2 = 0;

		//¶ñðQÂüÍ
		scanf("%s %s", input1, input2);

		//·³ðßé
		length1 = strlen(input1);
		length2 = strlen(input2);

		//êÂÚÌüÍðlÉÏ··é
		for(int a=0 ; a<length1 ; a++){
			if(isdigit(input1[a])){
				piyo[0] = input1[a];
				num1 += add( input1[a+1] , atoi(piyo) );
				a++;
			}
			else{
				num1 += add( input1[a] , 1 );
			}
		}

		//ñÂÚÌüÍðlÉÏ··é
		for(int a=0 ; a<length2 ; a++){
			if(isdigit(input2[a])){
				piyo[0] = input2[a];
				num2 += add( input2[a+1] , atoi(piyo) );
				a++;
			}
			else{
				num2 += add( input2[a] , 1 );
			}
		}

		//lðmcxi¶ñÉÏ·µÄ¦ðoÍ
		chengeNum(num1+num2);
		printf("%s\n", output);
	}
	
	return 0;
}

Compiler output:
a.cc: In function 'void chengeNum(int)':
a.cc:40:33: error: 'itoa' was not declared in this scope
   40 |                                 itoa( piyo , str , 10);
      |                                 ^~~~
Language: C++

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

char MCXI[] = "mcxi";

char mcxi[10];
char* toMCXI(int x) {
	char str[8];
	sprintf(str, "%04d", x);
	int p = 0;
	char* c = MCXI;
	for (int i = 0; i < 4; i++, c++) {
		int y = str[i] - '0';
		if (y == 0) continue;
		if (y == 1) {
			mcxi[p] = *c;
			p++;
		}
		else(2 <= y && y <= 9) {
			mcxi[p] = y + '0';
			mcxi[p+1] = *c;
			p += 2;
		}
	}
	return mcxi;
}

int toDec(char x[]) {
	int p = 0;
	int tmp = 1;
	int results = 0;
	for (int i = 0; x[i] != '\0'; i++) {
		if ('2' <= x[i] && x[i] <= '9') {
			tmp = x[i] - '0';
		}
		else {
			for (; p < 4; p++) {
				if (MCXI[p] == x[i]) {
					results += pow(10, 3 - p) * tmp;
					tmp = 1;
					break;
				}
			}
		}
	}
	return results;
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		memset(mcxi, 0, sizeof(mcxi));
		char a[8], b[8];
		cin >> a >> b;
		cout << toMCXI(toDec(a) + toDec(b)) << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'char* toMCXI(int)':
a.cc:22:39: error: expected ';' before '{' token
   22 |                 else(2 <= y && y <= 9) {
      |                                       ^~
      |                                       ;
Language: C++

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

char MCXI[] = "mcxi";

string toMCXI(int x) {
	string results;
	char order[] = {'i', 'x', 'c', 'm'};
	for (int i = 0; i < 4; i++)
	{
		int a = x % 10;
		if (a != 0)
		{
			results.insert(results.begin(), order[i]);
			if (a != 1)
			{
				results.insert(results.begin(), a + '0');
			}
		}
		x /= 10;
	}
	return results;
}

int toDec(char x[]) {
	int res = 0;
	int n = 1;
	for (int i = 0; x[i] != '\0'; i++)
	{
		char c = x[i];
		switch(c)
		{
		case 'm':
			res += n * 1000;
			n = 1;
			break;
		case 'c':
			res += n * 100;
			n = 1;
			break;
		case 'x':
			res += n * 10;
			n = 1;
			break;
		case 'i':
			res += n;
			n = 1;
			break;
		default:
			n = c - '0';
			break;
		}
	}
	return res;
}

int main() {
	int n;
	scanf("%d ", &n);
	for (int i = 0; i < n; i++) {
		char a[8], b[8], str[24];
		gets(str);
		sscanf(str, "%s%s", a, b);
		cout << toMCXI(toDec(a) + toDec(b)) << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:65:17: error: 'gets' was not declared in this scope; did you mean 'getw'?
   65 |                 gets(str);
      |                 ^~~~
      |                 getw
Language: C++

import java.util.*;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int n;
	static String s1, s2;
	static char[] c = {'m', 'c', 'x', 'i'};
	static int[] val = {1000, 100, 10, 1};
	
	static int parse(String str) {
		int ret = 0;
		for(int i = 0; i < 4; i++) {
			int pos = str.indexOf(c[i]);
			if (pos > 0 && Character.isDigit(str.charAt(pos - 1))) {
				ret += Integer.parseInt(str.substring(pos - 1, pos)) * val[i];
			} else if(pos >= 0) {
				ret += val[i];
			}
		}
		return ret;
	}
	
	static String unparse(int num) {
		String ret = "";
		for(int i = 0; i < 4; i++) {
			int num_ = num / val[i];
			if(num_ > 1) {
				ret += String.valueOf(num_) + c[i];
			} else if(num_ == 1) {
				ret += c[i];
			}
			
			num = num % val[i];
		}
		return ret;
	}
	
	public static void main(String[] args) {
		n = sc.nextInt();
		for(int i = 0; i < n; i++) {
			s1 = sc.next();
			s2 = sc.next();
			System.out.println(unparse(parse(s1) + parse(s2)));
		}
	}
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
    3 | public class Main {
      | ^~~~~~
Language: C++

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

const string MCXI = "ixcm";

int MCXI2Int(string s)
{
  int res = 0, tmp = 1;
  for (unsigned int i = 0; i < s.size(); ++i) {
    if (isdigit(s[i])) {
      tmp = s[i]-'0';
    } else {
      if (s[i] == 'm') {
	res += tmp * 1000;
      } else if (s[i] == 'c') {
	res += tmp * 100;
      } else if (s[i] == 'x') {
	res += tmp * 10;
      } else {
	res += tmp;
      }
      tmp = 1;
    }
  }
  return res;
}

string Int2MCXI(int n)
{
  stringstream ss;
  ss << n;
  string res = ss.str();
  reverse(res.begin(), res.end());
  unsigned int t = 0;
  for (string::iterator it = res.begin(); it != res.end(); ) {
    if (*it == '0') {
      it = res.erase(it);
      ++t;
    } else if (*it == '1') {
      *it = MCXI[t++];
      ++it;
    } else {
      it = res.insert(it, MCXI[t++]);
      it += 2;
    }
  }
  reverse(res.begin(), res.end());
  return res;
}

int main()
{
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string s, t;
    cin >> s >> t;
    cout << Int2MCXI(MCXI2Int(s) + MCXI2Int(t)) << endl;
  }

  return 0;
}

Compiler output:
a.cc: In function 'std::string Int2MCXI(int)':
a.cc:35:3: error: 'reverse' was not declared in this scope
   35 |   reverse(res.begin(), res.end());
      |   ^~~~~~~
Language: C++

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

int n;
char k[2][9];

void init() {
  scanf("%d", &n);
}

bool input() {
  int i;

  if (!n) return false;
  n--;

  scanf("%s", k[0]);
  scanf("%s", k[1]);

  return true;
}

int main() {
  int i, j, a, num[2];

  init();
  while (input()) {
    a = 1;
    for (i = 0; i < 2; i++) {
      num[i] = 0;
      for (j = 0; j < strlen(k[i]); j++) {
        switch (k[i][j]) {
        case 'm':
          num[i] += a * 1000;
          a = 1;
          break;
        case 'c':
          num[i] += a * 100;
          a = 1;
          break;
        case 'x':
          num[i] += a * 10;
          a = 1;
          break;
        case 'i':
          num[i] += a;
          a = 1;
          break;
        default:
          a = k[i][j] - '0';
          break;
        }
        //printf("%d\n", num[i]);
      }

    }
    num[0] += num[1];

    a = num[0] / 1000;
    num[0] %= 1000;
    if (a > 0) {
      if (a > 1) {
        printf("%d", a);
      }
      printf("m");
    }
    a = num[0] / 100;
    num[0] %= 100;
    if (a > 0) {
      if (a > 1) {
        printf("%d", a);
      }
      printf("c");
    }
    a = num[0] / 10;
    num[0] %= 10;
    if (a > 0) {
      if (a > 1) {
        printf("%d", a);
      }
      printf("x");
    }
    a = num[0];
    if (a > 0) {
      if (a > 1) {
        printf("%d", a);
      }
      printf("i");
    }
    printf("\n");

  }

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:23: error: 'strlen' was not declared in this scope
   32 |       for (j = 0; j < strlen(k[i]); j++) {
      |                       ^~~~~~
a.cc:3:1: note: 'strlen' 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<vector>
#include<string>
#include<cstring>
#include<cctype>
#include<algorithm>
using namespace std;
#define INF (1<<29)

#define INDEX(s,c) (find(s.begin(),s.end(),c)-s.begin())
char mcxi="mcxi";
int decode(string s){
	int i,no=s.size();
	int res=0;
	int m = 1000;
	for(int i=0;i<4;i++){
		int j = INDEX(s,mcxi[i]);
		if(j && isdigit(s[j-1]))res += m*(s[j-1]-'0');
		else res += m;
		m/=10;
	}
	return res;
}
string encode(int n){
	string res;
	if(n%10){
		res += 'i';
		if(1<n%10)res += '0'+n%10;
	}
	n/=10;
	if(n%10){
		res += 'x';
		if(1<n%10)res += '0'+n%10;
	}
	n/=10;
	if(n%10){
		res += 'c';
		if(1<n%10)res += '0'+n%10;
	}
	n/=10;
	if(n%10){
		res += 'm';
		if(1<n%10)res += '0'+n%10;
	}
	reverse(res.begin(),res.end());
	return res;
}
int main(){
	int n;
	cin>>n;
	while(n--){
		string s,t;
		cin>>s>>t;
		int a=decode(s),b=decode(t);
		//cout<<a+b<<endl;
		cout<<encode(a+b)<<endl;
	}
	return 0;
}

Compiler output:
a.cc:11:11: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   11 | char mcxi="mcxi";
      |           ^~~~~~
      |           |
      |           const char*
a.cc: In function 'int decode(std::string)':
a.cc:17:37: error: invalid types 'char[int]' for array subscript
   17 |                 int j = INDEX(s,mcxi[i]);
      |                                     ^
a.cc:10:44: note: in definition of macro 'INDEX'
   10 | #define INDEX(s,c) (find(s.begin(),s.end(),c)-s.begin())
      |                                            ^
Language: C++

#include<iostream>
#include<string>
using namespace std;
int dec(string s)
{
	int ans=0;
	int co=1;
	for(int i = 0; i < s.size(); ++i)
	{
		if(s[i]=='m')
		{
			ans+=co*1000; co=1;
		}
		else if(s[i]=='c')
		{
			ans+=co*100;
			co=1;
		}
		else if(s[i]=='x')
		{
			ans+=co*10;
			co=1;
		}
		else if(s[i]=='i')
		{
			ans+=co;
			co=1;
		}
		else co=s[i]-'0';
	}
	return ans;
}

string enc(int n)
{
	char s[1001];
	s[1]='i'; s[10]='x'; s[100]='c'; s[1000]='m';
	int pos=1;
	string ans="";
	while(n)
	{
		int tmp=n%10;
		n/=10;
		if(tmp==0)
		{	
			pos*=10;
			continue;
		}
		else
		{
			if(tmp==1) ans+=s[pos];
			else 
			{
				ans+=s[pos];
				ans+=tmp+'0';
			}
		}
		pos*=10;
	}
	reverse(ans.begin(),ans.end());
	return ans;
}

int main()
{
	int n;
	cin>>n;
	while(n--) 
	{
		string s1,s2;
		cin>>s1>>s2;
		cout<<enc(dec(s1)+dec(s2))<<endl;
	}
  return 0;
}

Compiler output:
a.cc: In function 'std::string enc(int)':
a.cc:60:9: error: 'reverse' was not declared in this scope
   60 |         reverse(ans.begin(),ans.end());
      |         ^~~~~~~
Language: C++

#include "MyLib.h"
#include "Measure.h"
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <cmath>
#include <algorithm>

using namespace std;

int main(void) {
	int n;
	string a, b, ans;
	int num1[4], num2[4], nans[4];
	int ch_point;
	char ch[4] = {'i', 'x', 'c', 'm'};
	bool increase;

	cin >> n;
	while(n--) {
		increase = false;
		string ans = "";
		cin >> a >> b;
		reverse(a.begin(), a.end());
		reverse(b.begin(), b.end());

		for(int i = 0; i < 4; i++) {
			ch_point = a.find(ch[i]);
			if(ch_point == string::npos) num1[i] = 0;
			else if(ch_point == a.size() - 1) num1[i] = 1;
			else if('2' <= a[ch_point + 1] && a[ch_point + 1] <= '9') num1[i] = a[ch_point + 1] - '0';
			else num1[i] = 1;
			ch_point = b.find(ch[i]);
			if(ch_point == string::npos) num2[i] = 0;
			else if(ch_point == b.size() - 1) num2[i] = 1;
			else if('2' <= b[ch_point + 1] && b[ch_point + 1] <= '9') num2[i] = b[ch_point + 1] - '0';
			else num1[i] = 1;

			nans[i] = num1[i] + num2[i] + (increase ? 1 : 0);
			increase = false;
			if(nans[i] > 9) {
				nans[i] -= 10;
				increase = true;
			}
			switch(nans[i]) {
			case 0: break;
			case 1: ans += ch[i]; break;
			default: ans += ch[i]; ans += nans[i] + '0'; break;
			};
		}
		reverse(ans.begin(), ans.end());
		cout << ans << endl;
	}
	return 0;
}

Compiler output:
a.cc:1:10: fatal error: MyLib.h: No such file or directory
    1 | #include "MyLib.h"
      |          ^~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <string>

using namespace std;

int main(void) {
	int n;
	string a, b, ans;
	int num1[4], num2[4], nans[4];
	int ch_point;
	char ch[4] = {'i', 'x', 'c', 'm'};
	bool increase;

	cin >> n;
	while(n--) {
		increase = false;
		string ans = "";
		cin >> a >> b;
		reverse(a.begin(), a.end());
		reverse(b.begin(), b.end());

		for(int i = 0; i < 4; i++) {
			ch_point = a.find(ch[i]);
			if(ch_point == string::npos) num1[i] = 0;
			else if(ch_point == a.size() - 1) num1[i] = 1;
			else if('2' <= a[ch_point + 1] && a[ch_point + 1] <= '9') num1[i] = a[ch_point + 1] - '0';
			else num1[i] = 1;
			ch_point = b.find(ch[i]);
			if(ch_point == string::npos) num2[i] = 0;
			else if(ch_point == b.size() - 1) num2[i] = 1;
			else if('2' <= b[ch_point + 1] && b[ch_point + 1] <= '9') num2[i] = b[ch_point + 1] - '0';
			else num1[i] = 1;

			nans[i] = num1[i] + num2[i] + (increase ? 1 : 0);
			increase = false;
			if(nans[i] > 9) {
				nans[i] -= 10;
				increase = true;
			}
			switch(nans[i]) {
			case 0: break;
			case 1: ans += ch[i]; break;
			default: ans += ch[i]; ans += nans[i] + '0'; break;
			};
		}
		reverse(ans.begin(), ans.end());
		cout << ans << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:17: error: 'reverse' was not declared in this scope
   19 |                 reverse(a.begin(), a.end());
      |                 ^~~~~~~
Language: C

#include <iostream>
#include <algorithm>

#define INF 99999999

using namespace std;

int main(void){
	while(1){
		int n, m, p, a, b; cin >> n >> m >> p >> a >> b;
		if(!n && !m && !p && !a && !b) break;

		int t[10]={0};
		int cost[30][30]; fill(cost[0], cost[29], -1);
		double dp[(1<<8)+1][30]; fill(dp[0], dp[(1<<8)], INF);
		for(int i=0; i<n; i++){
			cin >> t[i];
		}
		for(int i=0; i<p; i++){
			int x, y, z; cin >> x >> y >> z;
			x--; y--;
			cost[x][y] = cost[y][x] = z;
		}
		dp[(1<<n)-1][b-1] = 0;
		double ans = INF;
		for(int s=(1<<n)-1; s>=0; s--){
			ans = min(ans, dp[s][a-1]);

			for(int v=0; v<m; v++){
				for(int i=0; i<n; i++){
					if(s >> i & 1){
						for(int u=0; u<m; u++){
							if(cost[v][u] >= 0){
								dp[s & ~(1<<i)][u] = min(dp[s & ~(1<<i)][u], dp[s][v]+(double)cost[v][u]/t[i]);
							}
						}
					}
				}
			}
		}
		if(ans == INF) cout << "Impossible" << endl;
		else cout << ans << endl;
	}
	return 0;
}


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

#include <stdio.h>
#include <string.h>
#define INF 0x3FFFFFFF

struct edge{
	int x;
	int y;
	int z;
};

int main(void){
	int n, m, p, a, b, t[8], i, j, k, l;
	double d[30][1 << 8], ans;
	struct edge e[200];
	while(1){
		scanf("%d%d%d%d%d",&n,&m,&p,&a,&b);
		if(n == 0 && m == 0 && p == 0 && a == 0 && b == 0) break;
		a--, b--; 
		for(i = 0;i < n;i++)   
			scanf("%d",&t[i]);  
		for(i = 0;i < p;i++){    
			scanf("%d%d%d",&e[i].x,&e[i].y,&e[i].z); 
			e[i].x = e[i].x - 1,e[i].y = e[i].y - 1;   
		}     
		for(i = 0;i < p;i++)   
			e[i + p].x = e[i].y, e[i + p].y = e[i].x, e[i + p].z = e[i].z;  
		for(i = 0;i < m;i++)
			for(j = 0;j < (1 << n);j++) d[i][j] = (double) INF;
		d[a][(1 << n) - 1] = 0.0; 
		for(i = 0;i < m;i++){ // max arith 30 
			for(j = 0;j < p * 2;j++){ // max arith 100    
				for(k = 0;k < (1 << n);k++){ // max arith 256   
					for(l = 0;l < n;l++){ // max arith 8  
						if(k & (1 << l) && d[e[j].y][k - (1 << l)] > d[e[j].x][k] + (double) e[j].z / t[l])                            d[e[j].y][k - (1 << l)] = d[e[j].x][k] + (double) e[j].z / t[l];  
					}       
				}           
			}       
		}      
		ans = (double)INF;
		for(i = 0;i < (1 << n);i++)
			if(ans > d[b][i]) ans = d[b][i];   
		if(ans != (double)INF)       
			printf("%.3f\n",ans);  
		else           
			printf("Impossible\n");
	}    
	return 0;

Compiler output:
main.c: In function 'main':
main.c:47:9: error: expected declaration or statement at end of input
   47 |         return 0;
      |         ^~~~~~
Language: C++

#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
#define INF 2000000000
#define pb push_back
int N, M, P, a, b;
int t[10];
struct edge
{
	int to;
	double cost;
	edge(int to, double cost):to(to), cost(cost){}
};
vector<edge> g[40];
double dp[40][1<<8];
double rec(int v, int bit)
{
	if(dp[v][bit]!=-1)return dp[v][bit];
	double res = INF;
	for(int i=0; i<g[v].size(); i++)
	{
		int u = g[v][i].to;
		double cost = g[v][i].cost;
		for(int j=0; j<N; j++)
		{
			if(!((bit>>j)&1))
			{
				res=min(res, rec(u, bit|(1<<j))+cost/t[j]);
			}
		}
	}
	return dp[v][bit]=res;
}
int main()
{
	while(1)
	{
		for(int i=0; i<40; i++)g[i].clear();
		scanf("%d %d %d %d %d", &N, &M, &P, &a, &b);
		if(N==0&&M==0&&P==0&&a==0&&b==0)break;
		a--; b--;
		for(int i=0; i<N; i++)scanf("%d", &t[i]);
		for(int i=0; i<P; i++)
		{
			int x, y;
			double z;
			scanf("%d %d %lf", &x, &y, &z);
			x--; y--;
			g[x].pb(edge(y, z));
			g[y].pb(edge(x, z));
		}
		for(int i=0; i<M; i++)for(int j=0; j<(1<<N); j++)dp[i][j]=-1;
		dp[a][(1<<N)-1]=0;
		double ans = INF;
		for(int i=0; i<(1<<N); i++)ans = min(ans, rec(b, i));
		if(ans == INF)printf("Impossible\n");
		else prinatf("%f\n", ans);
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:58:22: error: 'prinatf' was not declared in this scope; did you mean 'printf'?
   58 |                 else prinatf("%f\n", ans);
      |                      ^~~~~~~
      |                      printf
Language: C++


#include<bits/stdc++.h>
using namespace std;
#define P pair<int,double>
#define to first
#define cost second
#define PB push_back


void f(int n,int m,int p,int a,int b){
  vector<double> t(n);
  vector<vector<P>> es(m+1);

  for(int i=0;i<n;i++){
    cin>>t[i];
  }
  for(int i=0;i<p;i++){
    int x,y,z;
    cin>>x>>y>>z;
    es[x].PB(P(y,z));
    es[y].PB(P(x,z));
  }
  

  vector<vector<double>> dp(1<<n,vector<double>(m+1,DBL_MAX));

  dp[0][a]=0;


  for(int i=0;i<(1<<n);i++){
    for(int j=1;j<=m;j++){
      if(dp[i][j]==DBL_MAX) continue;
      for(int k=0;k<n;k++){
        if(i&(1<<k)) continue;
        for(auto e:es[j]){
          if(dp[i|(1<<k)][e.to]>dp[i][j]+e.cost/t[k]){
            dp[i|(1<<k)][e.to]=dp[i][j]+e.cost/t[k];
            flag=true;
          }
        }
      }
    }
  }


  double ans=DBL_MAX;
  for(int i=0;i<(1<<n);i++)
    ans=min(ans,dp[i][b]);

  if(ans==DBL_MAX){
    cout<<"Impossible"<<endl;
  }else{
    printf("%.10lf\n",(ans==DBL_MAX?-1:ans));
  }
}



int main(){
  int n,m,p,a,b;
  while(true){
    cin>>n>>m>>p>>a>>b;
    if(n==0) break;
    f(n,m,p,a,b);
  }
}



Compiler output:
a.cc: In function 'void f(int, int, int, int, int)':
a.cc:38:13: error: 'flag' was not declared in this scope
   38 |             flag=true;
      |             ^~~~
Language: C++

#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;
struct Edge {
    int to; double cost;
};
const double INF = 1<<29;

int main()
{
    while (1) {
        int n, m, p, a, b; cin >> n >> m >> p >> a >> b;
        a--, b--;
        if (!n) break;

        vector<int> t(n);
        loop (n, i) cin >> t[i];

        vector<vector<Edge>> G(m);
        loop (p, i) {
            int x, y; double z; cin >> x >> y >> z;
            x--, y--;
            G[x].push_back({ y, z });
            G[y].push_back({ x, z });
        }

        // dp[i][j]: i縺ョ鬥ャ霆雁虻繧剃スソ縺」縺ヲj縺ォ陦後¥譛?ー上さ繧ケ繝?        double dp[300][31] = {};
        fill(dp[0], dp[299]+31, INF);
        dp[0][a] = 0;
        // 鬥ャ霆雁虻縺ョ譫壽焚
        loop (n, i) {
            // 菴ソ縺?ヲャ霆雁虻縺ョ遞ョ鬘?            loop (1<<n, crr) if (__builtin_popcount(crr) == i) {
                loop (n, k) {
                    int nxt = crr | (1<<k);
                    if (nxt == crr) continue;
                    loop (m, from) {
                        for (auto e : G[from]) {
                            dp[nxt][e.to] = min(
                                dp[nxt][e.to],
                                dp[crr][from] + e.cost / t[k]
                            );
                        }
                    }
                }
            }
        }

        double ans = INF;
        loop (300, i) ans = min(ans, dp[i][b]);
        if (ans == INF) cout << "Impossible" << endl;
        else cout << setprecision(8) << fixed << ans << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:14: error: 'dp' was not declared in this scope; did you mean 'p'?
   34 |         fill(dp[0], dp[299]+31, INF);
      |              ^~
      |              p
a.cc:40:31: error: 'crr' was not declared in this scope
   40 |                     int nxt = crr | (1<<k);
      |                               ^~~
a.cc:55:38: error: 'dp' was not declared in this scope; did you mean 'dup'?
   55 |         loop (300, i) ans = min(ans, dp[i][b]);
      |                                      ^~
      |                                      dup
a.cc:55:44: error: 'b' was not declared in this scope
   55 |         loop (300, i) ans = min(ans, dp[i][b]);
      |                                            ^
a.cc: At global scope:
a.cc:59:5: error: expected unqualified-id before 'return'
   59 |     return 0;
      |     ^~~~~~
a.cc:60:1: error: expected declaration before '}' token
   60 | }
      | ^
Language: C++

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

using namespace std;

struct Edge
{
	int v, c;
	Edge() {}
	Edge(int _v, int _c) : v(_v), c(_c) {}
};

using G = vector<vector<Edge>>;
using P = pair<double, pair<int, int>>;

double dijkstra(G& g, vector<int>& t, int a, int b) {
	priority_queue<P> que;
	// vector<double> d(g.size(), INT32_MAX);
	vector<vector<double>> d(g.size(), vector<double>(1 << 8, INT32_MAX));

	d[a][0] = 0.0;
	que.push(make_pair(0.0, make_pair(a, 0)));

	while (!que.empty()) {
		auto P = que.top(); que.pop();
		int v = P.second.first;
		int ti = P.second.second;
		double dist = -P.first;
		
		if (dist > d[v][ti]) { continue; }

		for (auto e : g[v]) {
			for(int i = 0; i < t.size(); ++i) {
				if(ti & 1 << i) { continue; }

				if(d[e.v][ti | 1 << i] > d[v][ti] + (double)e.c / t[i]) {
					d[e.v][ti | 1 << i] = d[v][ti] + (double)e.c / t[i];
					que.push(make_pair(-d[e.v][ti | 1 << i], make_pair(e.v, ti | 1 << i)));
				}
			}
			
			// if (ti >= t.size() - 1) { continue; }

			// if (d[e.v][ti + 1] > d[v][ti] + (double)e.c / t[ti + 1]) {
			// 	d[e.v][ti + 1] = d[v][ti] + (double)e.c / t[ti + 1];
			// 	que.push(make_pair(-d[e.v][ti + 1], make_pair(e.v, ti + 1)));
			// }
		}
	}

	return *min_element(d[b].begin(), d[b].end());
}

int main()
{
	int n, m, p, a, b;
	cin >> n >> m >> p >> a >> b;
	--a; --b;

	vector<int> t(n);
	for (auto&& ti : t) {
		cin >> ti;
	}

	G g(m);

	for (int i = 0; i < p; ++i) {
		int x, y, z;
		cin >> x >> y >> z;

		--x; --y;

		g[x].emplace_back(y, z);
		g[y].emplace_back(x, z);
	}

	double ans = dijkstra(g, t, a, b);
	if(ans == INT32_MAX) {
		printf("Impossible\n");
	} else {
		printf("%.3f\n", ans);
	}

	return 0;
}

Compiler output:
a.cc: In function 'double dijkstra(G&, std::vector<int>&, int, int)':
a.cc:21:67: error: 'INT32_MAX' was not declared in this scope
   21 |         vector<vector<double>> d(g.size(), vector<double>(1 << 8, INT32_MAX));
      |                                                                   ^~~~~~~~~
a.cc:5:1: note: 'INT32_MAX' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
    4 | #include <climits>
  +++ |+#include <cstdint>
    5 | 
a.cc:53:17: error: 'min_element' was not declared in this scope
   53 |         return *min_element(d[b].begin(), d[b].end());
      |                 ^~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:80:19: error: 'INT32_MAX' was not declared in this scope
   80 |         if(ans == INT32_MAX) {
      |                   ^~~~~~~~~
a.cc:80:19: note: 'INT32_MAX' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
Language: C++

#include <cstdio>
#define rep(i,a,n) for(int i=a; i<n; i++)
using namespace std;

const int SIZE = 1 << 10;
const int MAXV = 40;
const int MAXN = 10;
const double INF = 1e9;
int N, M, P, A, B;
double t[MAXN], dist[MAXV][MAXV];
double dp[SIZE][MAXV];

int main() {
    while(~scanf("%d%d%d%d%d", &N, &M, &P, &A, &B)) {
        A--; B--;
        rep(i,0,N) scanf("%lf", &t[i]);
        rep(i,0,MAXV) rep(j,0,MAXV) dist[i][j] = INF;
        rep(i,0,P) {
            int x, y, z; scanf("%d%d%d", &x, &y, &z);
            x--; y--;
            dist[x][y] = z;
            dist[y][x] = z;
        }

        double ans = INF;
        rep(i,0,SIZE) rep(j,0,MAXV) dp[i][j] = INF;
        dp[0][A] = 0;

        rep(bit,0,1<<N) {
            rep(j,0,M) {
                rep(to,0,M) {
                    if(j == to) continue;
                    rep(i,0,N) {
                        if(bit >> i & 1) continue;
                        if(dist[j][to] == INF) continue;
                        int nbit = bit | (1 << i);
                        double cost = dist[j][to] / t[i];
                        dp[nbit][to] = min(dp[nbit][to], dp[bit][j] + cost);
                    }
                }
                if(j == B) ans = min(ans, dp[bit][j]);
            }
        }
        if(ans != INF) printf("%.6f\n", ans);
        else printf("Impossible\n");
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:40: error: 'min' was not declared in this scope; did you mean 'main'?
   38 |                         dp[nbit][to] = min(dp[nbit][to], dp[bit][j] + cost);
      |                                        ^~~
      |                                        main
a.cc:41:34: error: 'min' was not declared in this scope; did you mean 'main'?
   41 |                 if(j == B) ans = min(ans, dp[bit][j]);
      |                                  ^~~
      |                                  main
Language: C++

#include <iostream>
#include <tuple>
#include <set>
#include <vector>
#include <deque>

typedef std::tuple<int, int, double> T;

std::vector<T> dis_city;
std::deque<double> dis;
std::vector<int> flag;
std::vector<int> num_basya;
int n, m, p, a, b;

double search(int ima)
{
	if ( num_basya.size() < dis.size() ) {
		return 0xffff;
	}
	if ( ima == b - 1 ) {
		double sum = 0;
		std::deque<double> d = dis;
		std::sort(d.begin(), d.end());
		int j = d.size() - 1;
		for ( int i = num_basya.size() - 1; i >= 0; --i ) {
			sum += d[j] / num_basya[i];
			//std::cout << "d:" << d[j] << " basya:" << num_basya[i] << " sum:" << sum << std::endl;
			j--;
			if ( j < 0 ) break;
		}
		return sum;
	}
	double ans = 0xffff;
	for ( int i = 0; i < dis_city.size(); ++i ) {
		if ( std::get<0>(dis_city[i]) == ima ) {
			if ( flag[std::get<1>(dis_city[i])] == false ) {
				flag[std::get<1>(dis_city[i])] = true;
				dis.push_back(std::get<2>(dis_city[i]));
				//std::cout << std::get<0>(dis_city[i]) << " -> " << std::get<1>(dis_city[i]) << std::endl;
				double tmp = search(std::get<1>(dis_city[i]));
				if ( ans > tmp ) ans = tmp;
				dis.pop_back();
				flag[std::get<1>(dis_city[i])] = false;
			}
		}
	}
	return ans;
}

int main(void)
{

	while(true) {
		dis_city.clear(); dis.clear(); flag.clear(); num_basya.clear();
		std::cin >> n >> m >> p >> a >> b;
		if ( n == 0 && m == 0 ) return 0;

		flag.resize(m);
		for ( int i = 0; i < m; ++i ) flag[i] = false;

		num_basya.resize(n);
		for ( auto &v: num_basya ) {
			std::cin >> v;
		}
		std::sort(num_basya.begin(), num_basya.end());


		for ( int i = 0; i < p; ++i ) {
			int x, y, z;
			std::cin >> x;
			std::cin >> y;
			std::cin >> z;
			x--; y--;

			T t1(x,y,z), t2(y,x,z);
			dis_city.push_back(t1);
			dis_city.push_back(t2);
		}

		flag[a - 1] = true;
		double ans = search(a - 1);
		if ( ans > 65530 ) {
			std::cout << "Impossible" << std::endl;
		} else {
			printf("%.4f\n", ans);
		}
	}

	return 0;
}

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

#include <assert.h>
#include <algorithm>
#include <complex>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <list>
#include <map>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <vector>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const double INF = 100000000;
using namespace std;

//i???????????????????????????
bool getBit(int num, int i){
    return ((num & (1 << i)) != 0);
}

//i?????????1?????????
int setBit(int num, int i){
    return num | (1 << i);
}

//i?????????0?????????
int clearBit(int num, int i){
    int mask = ~(1 << i);
    return num & mask;
}

//i?????????v??§???????????????
int updateBit(int num, int i, int v){
    int mask = ~(1 << i);
    return (num & mask) | (v << i);
}

int main(){
    int n, m, p, a, b;
    while(scanf("%d%d%d%d%d",&n,&m,&p,&a,&b), n){
        a--; b--;
        double g[40][40];
        rep(i,40) memset(g[i],-1,sizeof(g[i]));

        double t[10];
        rep(i,n) scanf("%lf",&t[i]);
        rep(i,p){
            int a, b;
            double c;
            scanf("%d%d%lf",&a,&b,&c);
            a--; b--;
            g[a][b] = g[b][a] = c;
        }

        double dp[500][40];
        rep(i, 1 << n) rep(j, 40) dp[i][j] = INF;
        dp[(1 << n) - 1][a] = 0;

        double ans = INF;
        for(int s = (1 << n) - 1; s >= 0; s--){
            ans = min(ans, dp[s][b]);
            rep(i,n){
                if(getBit(s,i)){
                    rep(v,m){
                        rep(u,m){
                            if(g[v][u] == -1) continue;
                            dp[clearBit(s,i)][u] = min(dp[clearBit(s,i)][u], dp[s][v] + g[v][u] / t[i]);
                        }
                    }
                }
            }
        }
        if(ans == INF){
            printf("Impossible\n");
        }else{
            printf("%.3f\n",ans);
        }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:60:19: error: 'memset' was not declared in this scope
   60 |         rep(i,40) memset(g[i],-1,sizeof(g[i]));
      |                   ^~~~~~
a.cc:24:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   23 | #include <utility>
  +++ |+#include <cstring>
   24 | #include <vector>
Language: C++

#include <iostream>
#include <tuple>
#include <set>
#include <vector>
#include <deque>
#include <queue>

typedef std::tuple<int, int, double> T;

std::vector<T> dis_city;
std::vector<int> num_basya;
int n, m, p, a, b;

std::vector<std::tuple<int,int>> table;
double cost[1<<8][30];


double search()
{
	for ( int i = 0; i < (1<<n); ++i ) {
		for ( int k = 0; k < m; ++k ) {
			cost[i][k] = 0xffff;
		}
	}
	cost[(1<<n)-1][a] = 0;
	double ans = 0xffff;

	std::priority_queue<std::tuple<double, int, int>> q;
	q.push(std::make_tuple(0, a, (1<<n)-1));
	while(!q.empty()) {
		double c = std::get<0>(q.top());
		int from = std::get<1>(q.top());
		int s = std::get<2>(q.top());
		q.pop();

		if ( from == b ) { ans = c; }
		for ( int i = 0; i < n; ++i ) {
			if ( s & (1<<i) ) {
				for ( int j = 0; j < dis_city.size(); ++j ) {
					if ( std::get<0>(dis_city[j]) == from ) {
						int to = std::get<1>(dis_city[j]);
						double f = c + std::get<2>(dis_city[j]) / num_basya[i];
						if ( cost[s ^ (1<<i)][to] > f ) {
							cost[s ^ (1<<i)][to] = f;
							q.push(std::make_tuple(f, to, s ^ (1<<i)));
						}
					}
				}
			}
		}
	}
	return ans;
}

int main(void)
{

	while(true) {
		dis_city.clear(); num_basya.clear();
		std::cin >> n >> m >> p >> a >> b;
		if ( n == 0 && m == 0 ) return 0;
		a--; b--;

		num_basya.resize(n);
		for ( auto &v: num_basya ) {
			std::cin >> v;
		}
		std::sort(num_basya.begin(), num_basya.end());


		for ( int i = 0; i < p; ++i ) {
			int x, y, z;
			std::cin >> x;
			std::cin >> y;
			std::cin >> z;
			x--; y--;

			T t1(x,y,z), t2(y,x,z);
			dis_city.push_back(t1);
			dis_city.push_back(t2);
		}

		double ans = search();
		if ( ans > 65530 ) {
			std::cout << "Impossible" << std::endl;
		} else {
			printf("%.4f\n", ans);
		}
	}

	return 0;
}

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

//1444
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cassert>
#include<sstream>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;


struct edge{
	int fr;
	int to;
	double d;
	int j;
	edge(int f,int t,double d0,int j0){
		fr=f;
		to=t;
		d=d0;
		j=j0;
	}
};
struct cmp{
	bool operator()(edge a,edge b){
		return a.d>b.d;
	}
};


int main(){
	int n,m,p,a,b;
	while(cin >> n >> m >> p >> a >> b){
		a--;
		b--;
		if(n==0) break;
		vector<vector<edge> > g(m);
		vint baken(n);
		for(int i=0;i<n;i++) cin >> baken[i];
		for(int i=0;i<p;i++){
			edge e(0,0,0,0);
			cin >> e.fr >> e.to >> e.d;
			e.fr--;
			e.to--;
			g[e.fr].push_back(e);
			g[e.to].push_back(edge(e.to,e.fr,e.d,0));
		}
		
		int prev[31][1<<9];
		priority_queue<edge,vector<edge>,cmp> pq;
		memset(prev,-1,sizeof(prev));
		
		edge e(-2,a,0,0);
		pq.push(e);
		
		int imp=1;
		while(!pq.empty()){
			e=pq.top();
//			cout << e.fr << " " << e.to << " " << e.d << endl;
			pq.pop();
			if(prev[e.to][e.j]!=-1) continue;
			prev[e.to][e.j]=e.d;
			if(e.to==b){
				imp=0;
				break;
			}
			for(int i=0;i<g[e.to].size();i++){
				for(int j=1,k=0;j<(1<<n);j*=2,k++){
					if((e.j&j)==0){
						pq.push(edge(e.to,g[e.to][i].to,e.d+((double)g[e.to][i].d/baken[k]),(e.j|j)));
					}
				}
			}
		}
		if(imp==0){
			printf("%.5f\n",e.d);
		}else{
			printf("Impossible\n");
		}
	}
	
	return 0;
}
	

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

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#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 mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second

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



int __ch;
int x;
int num(){
  x=0;
  while(!isdigit(_ch=getchar());
  x=_ch-'0';
  while(isdigit(_ch=getchar())x=(x<<3)+(x<<1)+_ch-'0';
  return x;
}

PI V[30][30];
int Vs[30];
bool vis[1<<8][30];
int ti[30];

int main(){
  while(true){
    int n=num(),m=num(),p=num(),a=num()-1,b=num()-1;
    if(!n)break;
    rep(i,n)ti[i]=num();

    rep(i,m)Vs[i]=0;

    rep(i,p){
      int x=num()-1,y=num()-1,z=num();
      V[x][Vs[x]++]=mp(y,z);
      V[y][Vs[y]++]=mp(x,z);
    }

    priority_queue<pair<double,PI> > Q;
    Q.push(mp(0,mp(a,0)));
    memset(vis,0,sizeof(vis));
    double ans=-1;

    while(!Q.empty()){
      int v=Q.top().S.F,cst=Q.top().S.S;
      double cc=-Q.top().F;
      Q.pop();
      if(vis[cst][v])continue;
      vis[cst][v]=true;
      if(v==b){
        ans=cc;
        break;
      }

      rep(i,n){
        if(cst>>i&1)continue;
        rep(j,Vs[v]){
          int nv=V[v][j].first;
          int tc=V[v][j].second;
          int nst=cst|(1<<i);
          if(vis[nst][nv])continue;
          double nc=cc+1.0*tc/ti[i];
          Q.push(mp(-nc,mp(nv,nst)));
        }
      }
    }
    if(ans<0)puts("Impossible");
    else printf("%f\n",ans);
  }
}

Compiler output:
a.cc: In function 'int num()':
a.cc:45:18: error: '_ch' was not declared in this scope; did you mean '__ch'?
   45 |   while(!isdigit(_ch=getchar());
      |                  ^~~
      |                  __ch
a.cc:45:32: error: expected ')' before ';' token
   45 |   while(!isdigit(_ch=getchar());
      |        ~                       ^
      |                                )
a.cc:46:5: error: '_ch' was not declared in this scope; did you mean '__ch'?
   46 |   x=_ch-'0';
      |     ^~~
      |     __ch
a.cc:47:31: error: expected ')' before 'x'
   47 |   while(isdigit(_ch=getchar())x=(x<<3)+(x<<1)+_ch-'0';
      |        ~                      ^
      |                               )
Language: C++

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#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 mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};



typedef struct _state{
  int from,vis;
  double cost;
  _state(double ic,int ifr,int iv):cost(ic),from(ifr),vis(iv){
  };
  bool operator<(const _state&r)const{
    return cost>r.cost;
  };
}state;

typedef struct _edge{
  int to,cost;
  _edge(int ito,int icost):to(ito),cost(icost){
  };
}edge;

int ret,c;
char str[300];
int pos;
inline int num(){
  ret=0;
  while(!isdigit(str[pos]))++pos;
  ret=str[pos]&15;
  while(isdigit(str[++pos]))ret=(ret<<3)+(ret<<1)+(c&15);
  return ret;
}

main(){
  int n,m,p,a,b;
  while(true){
    gets(str);pos=0;
    n=num(),m=num(),p=num(),a=num()-1,b=num()-1;
    if(!n)break;
    int ti[n];
    vector<edge> V[m];
    gets(str);pos=0;
    rep(i,n)ti[i]=num();

    rep(i,p){
      gets(str);pos=0;
      int x=num()-1,y=num()-1,z=num();
      V[x].pb(edge(y,z));
      V[y].pb(edge(x,z));
    }

    priority_queue<state> Q;
    Q.push(state(0,a,0));

    bool cost[1<<n][m];
    memset(cost,0,sizeof(cost));
    double ans=-1;

    int from,cti;
    double ccost;
    while(!Q.empty()){
      from=Q.top().from,cti=Q.top().vis;
      ccost=Q.top().cost;
      Q.pop();
      if(cost[cti][from])continue;
      cost[cti][from]=true;
      if(from==b){
        ans=ccost;
        break;
      }

      int to,cc,sz;
      rep(i,n){
        if(cti>>i&1)continue;
        sz=SZ(V[from]);
        rep(j,sz){
          to=V[from][j].to;
          cc=V[from][j].cost;
          if(cost[cti|1<<i][to])continue;
          Q.push(state(ccost+1.0*cc/ti[i],to,cti|1<<i));
        }
      }
    }
    if(ans<0)puts("Impossible");
    else printf("%f\n",ans);
  }
}

Compiler output:
a.cc:68:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   68 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:71:5: error: 'gets' was not declared in this scope; did you mean 'getw'?
   71 |     gets(str);pos=0;
      |     ^~~~
      |     getw
Language: C++

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

int n,m,p,a,b;
int t[8];

struct edge{
	int x,y,cost;
};

struct state{
	int x,nt;
	double ncost;
};

bool operator < (state a,state b){
	return a.ncost>b.ncost;
}

void solve(){
	double ans=1000000;
	for(int i=0;i<n;i++){
		scanf("%d",&t[i]);
	}

	edge e[1000];

	for(int i=0;i<p;i++){
		scanf("%d%d%d",&e[i].x,&e[i].y,&e[i].cost);
		e[i+p].x=e[i].y;
		e[i+p].y=e[i].x;
		e[i+p].cost=e[i].cost;
	}
	priority_queue<state> Q;
	double total[1<<8][31];
	bool c[1<<8][31];
	memset(total,-1,sizeof(total));
	memset(c,0,sizeof(c));
	state now;
	now.ncost=0.0;
	now.x=a;
	now.nt=(1<<n)-1;
	Q.push(now);

	while(!Q.empty()){
		state now;
		now=Q.top();
		Q.pop();
		if(c[now.nt][now.x]==true)
			continue;
		c[now.nt][now.x]=true;
		if(now.x==b)
			ans=min(ans,now.ncost);
		for(int i=0;i<p*2;i++){
			if(e[i].x==now.x){
				for(int j=0;j<n;j++){
					if((now.nt>>j & 1) == 1){
						state next;
						next.x=e[i].y;
						next.nt=(~(1<<j)) & now.nt;
						next.ncost=now.ncost+(double)e[i].cost/(double)t[j];
						total[next.nt][next.x]=next.ncost;
						Q.push(next);
					}
				}
			}
		}
	}
	if(ans>100000)
		cout<<"Impossible\n";
	else	
		cout<<ans<<"\n";
}


int main()
{
	scanf("%d%d%d%d%d",&n,&m,&p,&a,&b);
	while(n!=0){
		solve();
	scanf("%d%d%d%d%d",&n,&m,&p,&a,&b);
	}
	return 0;
}

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

#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
#define EPS 1e-9
using namespace std;

typedef pair<int,int> P;
typedef pair<double,P> P2;

double d[50][1<<10];

int main(){
  int n,m,p,a,b;
  int x,y,z;
  int t[10];
  vector<P> g[50];

  while(cin >> n >> m >> p >> a >> b, n||m||p||a||b){
    for(int i=0;i<n;i++)cin >> t[i];

    for(int i=0;i<=m;i++)g[i].clear();
    for(int i=0;i<p;i++){
      cin >> x >> y >> z;
      g[x].push_back(P(y,z));
      g[y].push_back(P(x,z));
    }
      
    for(int i=0;i<=m;i++)
      for(int j=0;j<(1<<n);j++)d[i][j] = 10000.0;
    d[a][0] = 0.0;

    priority_queue<P2,vector<P2>,greater<P2> > q;
    q.push(P2(0.0,P(a,0)));

    double ans = 10000.0;
    while(!q.empty()){
      P2 p = q.top(); q.pop();
      double dis = p.first;
      int c = p.second.first, ti = p.second.second;

      if(c==b){ans = dis; break;}

      for(int i=0;i<(int)g[c].size();i++){
	int nc = g[c][i].first;
	for(int j=0;j<n;j++){
	  if( (ti>>j) & 1 )continue;
	  int nt = ti+(1<<j);
	  
	  if(t[j]==0){
	    cout << "Impossible\n";
	    return;
	  }
	  
	  double nd = dis + (double)g[c][i].second/t[j];
	  
	  if(d[nc][nt] > nd){
	    d[nc][nt] = nd;
	    q.push(P2(nd,P(nc,nt)));
	  }
	}
      }
    }

    if(ans+EPS>10000.0)printf("Impossible\n");
    else printf("%.5lf\n",ans);
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:13: error: return-statement with no value, in function returning 'int' [-fpermissive]
   53 |             return;
      |             ^~~~~~
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>

#define INF (1<<29)
 
using namespace std;
 
int main(void){
  
  int n,m,p,a,b,x,y,z,in;
  double dp[(1<<8)][31],graph[31][31];
  vector<int>t;
  
  while(cin >> n >> m >> p >> a >> b){
    if(!(n|m|p|a|b))break;
    
    t.clear();
    
    fill(graph[0],graph[31],-1);
    fill(dp[0],dp[(1<<8)],INF);

    for(int i=0;i<n;i++){
      cin >> in;
      t.push_back(in);
    }
    
    for(int i=0;i<p;i++){
      cin >> x >> y >> z;
      graph[x][y]=graph[y][x]=z;
    }
    
    dp[0][a]=0;
    double res=INF;
    for(int S=0;S<(1<<n);S++){
      res=min(res,dp[S][b]);
      for(int v=1;v<=m;v++){
	for(int i=0;i<n;i++){
	  if(!(S>>i & 1)){
	    for(int u=1;u<=m;u++){
	      if(graph[v][u]<0)continue;
		dp[S|(1<<i)][u]=min(dp[S|(1<<i)][u],dp[S][v]+graph[v][u]/t[i]);
	    }
	  }
	}
      }
    }

Compiler output:
a.cc: In function 'int main()':
a.cc:48:6: error: expected '}' at end of input
   48 |     }
      |      ^
a.cc:16:38: note: to match this '{'
   16 |   while(cin >> n >> m >> p >> a >> b){
      |                                      ^
a.cc:48:6: error: expected '}' at end of input
   48 |     }
      |      ^
a.cc:10:15: note: to match this '{'
   10 | int main(void){
      |               ^
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int n, m, p, a, b;

	while(true) {
		cin >> n >> m >> p >> a >> b;

		if( !m && !n && !p && !a && !b ) {
			break;
		}

		vector< vector< double > > dp(1 << n, vector< double >(m + 1,INT_MAX / 4));
		vector< int > t(n);
		vector< vector< int > > map(m + 1, vector< int >(m + 1, INT_MAX / 4));

		for(int i = 0; i < n; i++) {
			cin >> t[i];
		}
		for(int i = 0; i < p; i++) {
			int x, y, z;
			cin >> x >> y >> z;

			map[x][y] = z;
			map[y][x] = z;
		}

		dp[0][a] = 0;

		for(int s = 0; s < (1 << n); s++) {
			for(int i = 0; i < n; i++) {
				for(int j = 1; j <= m; j++) {
					for(int k = 1; k <= m; k++) {
						if(map[j][k] == INT_MAX / 4) {
							continue;
						}
						if(!(s >> i & 1)) {
							int next = s | (1 << i);
							dp[next][k] = min(dp[next][k], dp[s][j] + ((double)map[j][k] / t[i]));
						}
					}
				}
			}
		}

		double ans = INT_MAX / 4;
		for(int s = 0; s < (1 << n); s++) {
			ans = min(ans, dp[s][b]);
		}



		if(ans == INT_MAX / 4) {
			cout << "Inmpossible" << endl;
		} else {
			cout << ans << endl;
		}
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:78: error: 'INT_MAX' was not declared in this scope
   18 |                 vector< vector< double > > dp(1 << n, vector< double >(m + 1,INT_MAX / 4));
      |                                                                              ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <algorithm>
  +++ |+#include <climits>
    5 |