Language: C++

#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define W(x) cout<<x<<endl;
#define Debug(x) cout<<"#DEBUG "<<x<<endl;
#define NN (1<<29)
using namespace std;
int n,m,r,ans=NN,d[9],dist[201][201];
bool flag[9];
int min(int x,int y){if(y<x)return y;else return x;}
int max(int x,int y){return x+y-min(x,y);}
int fact(int x){int i=1;rep(j,x){i*=(j+1);} return i;}
void dfs(int cnt,int now,int dd)
{
    if(cnt==r)
    {
        ans=min(dd,ans);
        return;
    }
    else
    {
        rep(i,r)
        if(!flag[i])
        {
            flag[i]=true;
            if(now==-1)
            {
                dfs(cnt+1,i,0);
            }
            else
            {
                dfs(cnt+1,i,dd+dist[d[now]][d[i]]);
            }
            flag[i]=false;
        }
        return;
    }
}
int main()
{
    cin>>n>>m>>r;
    int a,b,c;
    rep(i,r)
    {
        cin>>d[i];
        d[i]--;
    }
    
    rep(i,n)
    {
        rep(j,n)
        {
            dist[i][j]=NN;
        }
        dist[i][i]=0;
    }
    rep(i,m)
    {
        cin>>a>>b>>c;
        dist[--a][--b]=c;
        dist[b][a]=c;
    }
    rep(k,n)
    {
        rep(i,n)
        {
            rep(j,n)
            {
                dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
            }
            
        }
        
    }
    rep(i,r)
    {
        flag[i]=false;
    }
    dfs(0,-1,0);
    W(ans)
    return 0;
}

Compiler output:
a.cc: In function 'int fact(int)':
a.cc:11:29: error: 'j' was not declared in this scope
   11 | int fact(int x){int i=1;rep(j,x){i*=(j+1);} return i;}
      |                             ^
a.cc:11:25: error: 'rep' was not declared in this scope; did you mean 'Rep'?
   11 | int fact(int x){int i=1;rep(j,x){i*=(j+1);} return i;}
      |                         ^~~
      |                         Rep
a.cc: In function 'void dfs(int, int, int)':
a.cc:21:13: error: 'i' was not declared in this scope
   21 |         rep(i,r)
      |             ^
a.cc:21:9: error: 'rep' was not declared in this scope; did you mean 'Rep'?
   21 |         rep(i,r)
      |         ^~~
      |         Rep
a.cc: In function 'int main()':
a.cc:40:5: error: 'cin' was not declared in this scope
   40 |     cin>>n>>m>>r;
      |     ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #define Rep(i,n0,n) for(int i=n0;i<n;i++)
a.cc:42:9: error: 'i' was not declared in this scope
   42 |     rep(i,r)
      |         ^
a.cc:42:5: error: 'rep' was not declared in this scope; did you mean 'Rep'?
   42 |     rep(i,r)
      |     ^~~
      |     Rep
a.cc:62:9: error: 'k' was not declared in this scope
   62 |     rep(k,n)
      |         ^
a.cc:3:14: error: 'cout' was not declared in this scope
    3 | #define W(x) cout<<x<<endl;
      |              ^~~~
a.cc:79:5: note: in expansion of macro 'W'
   79 |     W(ans)
      |     ^
a.cc:3:14: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    3 | #define W(x) cout<<x<<endl;
      |              ^~~~
a.cc:79:5: note: in expansion of macro 'W'
   79 |     W(ans)
      |     ^
a.cc:3:23: error: 'endl' was not declared in this scope
    3 | #define W(x) cout<<x<<endl;
      |                       ^~~~
a.cc:79:5: note: in expansion of macro 'W'
   79 |     W(ans)
      |     ^
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | #define Rep(i,n0,n) for(int i=n0;i<n;i++)