Language: C++

include <bits/stdc++.h>
#define N 100010
#define ff first
#define ss second 
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n,m,r,ans=-1;
ll adj[210][210]={};
ll ar[10];
ll calc(){
	ll res=0ll;
	for (int i=1;i<r;i++){
		if (adj[ar[i]][ar[i-1]]==-1)
			return -1;
		res+=adj[ar[i]][ar[i-1]];
	}
	return res;
}
int main() {
	
	memset(adj,-1,sizeof adj);
	assert(scanf("%lld%lld%lld",&n,&m,&r)==3);
	for (int i=1;i<=n;i++)
		adj[i][i]=0;
	for (int i=0;i<r;i++)	
		assert(scanf("%lld",&ar[i])==1);
	for (int i=1;i<=m;i++){
		long long a,b,c;
		assert(scanf("%lld%lld%lld",&a,&b,&c)==3);
		adj[a][b]=adj[b][a]=min(adj[a][b],c);
	}
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			for (int k=1;k<=n;k++)
				if (adj[j][i]+adj[i][k]<adj[j][k]||adj[j][k]==-1)
					adj[j][k]=adj[j][i]+adj[i][k];
	sort(ar,ar+r);
	do{
		if (calc()==-1)
			continue;
		if (ans==-1)
			ans=calc();
		else
			ans=min(ans,calc());
	}while (next_permutation(ar,ar+r));
	
	return !printf("%lld",ans);
}

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <bits/stdc++.h>
      | ^~~~~~~
a.cc:7:9: error: 'pair' does not name a type
    7 | typedef pair<int,int> pii;
      |         ^~~~
a.cc:8:9: error: 'pair' does not name a type
    8 | typedef pair<ll,ll> pll;
      |         ^~~~
a.cc: In function 'int main()':
a.cc:23:9: error: 'memset' was not declared in this scope
   23 |         memset(adj,-1,sizeof adj);
      |         ^~~~~~
a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
  +++ |+#include <cstring>
    1 | include <bits/stdc++.h>
a.cc:24:16: error: 'scanf' was not declared in this scope
   24 |         assert(scanf("%lld%lld%lld",&n,&m,&r)==3);
      |                ^~~~~
a.cc:24:9: error: 'assert' was not declared in this scope
   24 |         assert(scanf("%lld%lld%lld",&n,&m,&r)==3);
      |         ^~~~~~
a.cc:1:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
  +++ |+#include <cassert>
    1 | include <bits/stdc++.h>
a.cc:32:37: error: 'min' was not declared in this scope; did you mean 'main'?
   32 |                 adj[a][b]=adj[b][a]=min(adj[a][b],c);
      |                                     ^~~
      |                                     main
a.cc:39:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   39 |         sort(ar,ar+r);
      |         ^~~~
      |         short
a.cc:46:29: error: 'min' was not declared in this scope; did you mean 'main'?
   46 |                         ans=min(ans,calc());
      |                             ^~~
      |                             main
a.cc:47:17: error: 'next_permutation' was not declared in this scope
   47 |         }while (next_permutation(ar,ar+r));
      |                 ^~~~~~~~~~~~~~~~
a.cc:49:17: error: 'printf' was not declared in this scope
   49 |         return !printf("%lld",ans);
      |                 ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | include <bits/stdc++.h>