Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstdio>
#define F(i,n) for(int i=0;i<(int)(n);i++)
#define INF 100000000
#define ll long long

using namespace std;
typedef pair<int, int> P;

bool x[110],z[110],w[110];
int y[110][110];
int n, m, l, k, a, h,time,ans;
int mi;

void r2(int start, int ml2, int end,int total2) {
	F(o, n) {
		if (start == end) {
			if (total2 < mi)mi = total2;
		}
		if (ml2 - y[start][o] >= 0) {
			w[start] = true;
			if (w[o] == false) {
				r2(o,ml2 - y[start][o], end,total2+y[start][o]);
			}
			w[start] = false;
		}
	}
}
void r(int city,int ml,int total) {
	if (city == h) {
		if (m - total >= 0) {
			time = total;
		}
		else {
			time = 2*total - m;
		}
		if (ans>time)ans = time;
	}
	F(i, n) {
		z[city] = true;
		if (x[i] = true) {
			if (z[i] == true)continue;
			mi = INF;
			F(j, n)w[j] = false;
			r2(city, ml, i, 0);
			if (mi == INF)continue;
			else {
				r(i, m, total + mi);
			}
		}
		z[city] = false;
	}
}

int main() {
	int s,t,u;
	while (1) {
		cin >> n >> m >> l >> k >> a >> h;
		if (n == 0 && m == 0 && l == 0 && k == 0 && a == 0 && h == 0)break;
		F(i, n) {
			x[i] = false;
			z[i] = false;
		}
		F(i, n) {
			F(j, n) {
				y[i][j] = INF;
			}
		}
		F(i, l) {
			cin >> s;
			x[s] = true;
			w[s] = true;
		}
		x[a] = true;
		x[h] = true;
		w[a] = true;
		w[h] = true;
		F(i, k) {
			cin >> s >> t >> u;
			y[s][t] = u;
			y[t][s] = u;
		}
		ans = INF;
		r(a, m, 0);
		if (ans == INF)cout << "Help!" << endl;
		else cout << ans << endl;
	}
	return 0;
}

Compiler output:
a.cc:17:22: error: 'int time' redeclared as different kind of entity
   17 | int n, m, l, k, a, h,time,ans;
      |                      ^~~~
In file included from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
                 from /usr/include/c++/14/ext/atomicity.h:35,
                 from /usr/include/c++/14/bits/ios_base.h:39,
                 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/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
   76 | extern time_t time (time_t *__timer) __THROW;
      |               ^~~~
a.cc: In function 'void r(int, int, int)':
a.cc:37:30: error: assignment of function 'time_t time(time_t*)'
   37 |                         time = total;
      |                         ~~~~~^~~~~~~
a.cc:40:30: error: assignment of function 'time_t time(time_t*)'
   40 |                         time = 2*total - m;
      |                         ~~~~~^~~~~~~~~~~~~
a.cc:42:24: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   42 |                 if (ans>time)ans = time;
      |                     ~~~^~~~~
a.cc:42:36: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'int' [-fpermissive]
   42 |                 if (ans>time)ans = time;
      |                                    ^~~~
      |                                    |
      |                                    time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept}