Language: C++

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


#define N_NODE 100
#define INF (1 << 29)

using namespace std;


struct Edge
{
	int to, cost;
};

class Path
{
public:
	Path(int _num, int _cost, int _M)
	{
		num = _num;
		cost = _cost;
		limit_time = _M;
	}
	int num;
	int cost;
	int limit_time;
	bool operator < (const Path& other) const //??????const???????????¨priority_queue??§??¨???????????????
	{
		return this->cost < other.cost;
	}
	bool operator > (const Path& other) const //??????const???????????¨priority_queue??§??¨???????????????
	{
		return !(*this < other);
	}
};

//?????????????????????????¨??????????????????????
bool find_freeze(vector<int>& vec, int& number)
{
	bool ret = false;
	for_each(vec.begin(), vec.end(), 
	[&](int &fc){ if(fc == number)ret = true; }
	);

	return ret;
}

int main()
{

	int N, M, L, K, A, H;
	while(cin >> N >> M >> L >> K >> A >> H, N)
	{
		int start = A;

		//??????????????????????°??????????
		int min_cost[N_NODE][N_NODE];//min_cost[????????°][????????????????????????]

		for(int i = 0; i < N_NODE; ++i)
		{
			for(int j = 0; j < N_NODE; ++j)
			{
				min_cost[i][j] = INF;
			}
		}


		min_cost[start][M] = 0;

		priority_queue< Path, vector<Path>, greater<Path> > que;
		que.push( Path(start, 0, M) );

		//bin sort
		//bin[from] = { Edge{to, cost}, Edge{to, cost}, ... }

		/*
		vector<Edge> bin[N_NODE];
		bin[0].push_back( Edge{ 1, 3 } );
		bin[1].push_back( Edge{ 0, 3 } );
		bin[0].push_back( Edge{ 2, 1 } );
		bin[2].push_back( Edge{ 0, 1 } );
		bin[1].push_back( Edge{ 2, 1 } );
		bin[2].push_back( Edge{ 1, 1 } );
		bin[1].push_back( Edge{ 3, 3 } );
		bin[3].push_back( Edge{ 1, 3 } );
		bin[2].push_back( Edge{ 3, 2 } );
		bin[3].push_back( Edge{ 2, 2 } );
		bin[2].push_back( Edge{ 4, 5 } );
		bin[4].push_back( Edge{ 2, 5 } );
		bin[3].push_back( Edge{ 4, 1 } );
		bin[4].push_back( Edge{ 3, 1 } );
		*/

		/*
		????????? bin ?????°??????
		{  0,   3,   1, INF, INF },
		{  3,   0,   1,   3, INF },
		{  1,   1,   0,   2,   5 },
		{INF,   3,   2,   0,   1 },
		{INF, INF,   5,   1,   0 },
		*/

		vector<int> freezable_city;
		freezable_city.reserve(L);

		//??????????¨????????????????vector?????????
		for(int i = 0; i < L; ++i)
		{
			int tmp = 0;
			cin >> tmp;
			freezable_city.push_back(tmp);
		}

		//bin??????????????°??????
		vector<Edge> bin[N_NODE];
		for(int i = 0; i < K; ++i)
		{		
			int from, to, cost;
			cin >> from >> to >> cost;
			bin[from].push_back( Edge{to, cost} );
			bin[to].push_back( Edge{from, cost} );
		}


		bool needHelp = true;

		while(!que.empty())
		{
			Path now = que.top();
			que.pop();

			//???????????????????°????????????????????????°?????????
			if(min_cost[now.num][now.limit_time] < now.cost)continue;

			for(int i = 0; i < bin[now.num].size(); i++)
			{
				//?????????????????????????¨????????????????
				if(find_freeze(freezable_city, now.num) && now.limit_time < M)
				{
					que.push( Path(now.num, now.cost + (M - now.limit_time), M) );
					min_cost[now.num][M] = min(min_cost[now.num][M], now.cost + (M - now.limit_time));
				}

				//??????????????????????????????i????????????????????????????????????min_cost??????????°????????????°??´??°
				int next_cost = now.cost + bin[now.num][i].cost;
				int next_minute = now.limit_time - bin[now.num][i].cost;


				//?§??????????????????????????????£???????????????????????????????°???????????????????
				if(next_minute >= 0 && (min_cost[bin[now.num][i].to][next_minute] > next_cost))
				{
					needHelp = false;
					min_cost[bin[now.num][i].to][next_minute] = next_cost;
					que.push( Path(bin[now.num][i].to, next_cost, next_minute) );

				}
			}
		}

		//	cout << min_cost[H][0] << endl;
		//	cout << min_cost[H][1] << endl;
		//	cout << min_cost[H][2] << endl;
		
		
		for(int i = N_NODE - 2; i >= 0; i--)
		{
			min_cost[H][i] = min(min_cost[H][i + 1] - 1, min_cost[H][i]);
		}

		if(needHelp)cout << "Help!" << endl;
		else
		{
			//cout << "ans: " << min_cost[H][0] << endl;
			cout << min_cost[H][0] << endl;
			//cout << min_cost[H][1] << endl;
			//cout << min_cost[H][2] << endl;
		} 
	}

	return 0;
}

Compiler output:
a.cc: In function 'bool find_freeze(std::vector<int>&, int&)':
a.cc:43:9: error: 'for_each' was not declared in this scope
   43 |         for_each(vec.begin(), vec.end(),
      |         ^~~~~~~~