Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long;
#define for_(i, a, b) for(int i=(a);i<(b);i++)
#define rep(i, n) for_(i, 0, n)

constexpr int k(int n) { return (n==0) ? 1 : n*k(n-1); }
const int INF = 0x3f3f3f3f3f3f3f3fLL;

int N, M, R;
int d[202][202];
int r[9];

signed main() {
  
  cin>N>M>>R;
  int a,b,c;
  rep(i,N+1) {
    rep(j, N+1) {
      d[i][j] = INF;
    }
  }
  
  rep(i, R)cin>>r[i];
  
  rep(i, M) {
    cin>>a>>b>>c;
    dp[a][b] = c;
  }
  
  rep(i, N) {
    rep(j, N) {
      rep(k, N)dp[i+1][j+1] = min(dp[i+1][j+1], dp[i+1][k+1]+dp[k+1][j+1]);
    }
  }
  
  int s = INF, t;
  
  rep(i, k(R)) {
    t = 0;
    for_(j, R)t += dp[r[j-1]][r[j]]; 
    s = min(s, t);
    
    next_permutation(r, r+R); 
  }
  
  cout<<s<<endl;
  
  return 0;
}

Compiler output:
a.cc:41:14: error: macro "for_" requires 3 arguments, but only 2 given
   41 |     for_(j, R)t += dp[r[j-1]][r[j]];
      |              ^
a.cc:4:9: note: macro "for_" defined here
    4 | #define for_(i, a, b) for(int i=(a);i<(b);i++)
      |         ^~~~
a.cc:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
a.cc:7:11: note: in expansion of macro 'int'
    7 | constexpr int k(int n) { return (n==0) ? 1 : n*k(n-1); }
      |           ^~~
a.cc:3:22: error: expected ')' before ';' token
    3 | #define int long long;
      |                      ^
a.cc:7:17: note: in expansion of macro 'int'
    7 | constexpr int k(int n) { return (n==0) ? 1 : n*k(n-1); }
      |                 ^~~
a.cc:7:16: note: to match this '('
    7 | constexpr int k(int n) { return (n==0) ? 1 : n*k(n-1); }
      |                ^
a.cc:3:22: error: expected constructor, destructor, or type conversion before ';' token
    3 | #define int long long;
      |                      ^
a.cc:7:17: note: in expansion of macro 'int'
    7 | constexpr int k(int n) { return (n==0) ? 1 : n*k(n-1); }
      |                 ^~~
a.cc:7:21: error: 'n' does not name a type
    7 | constexpr int k(int n) { return (n==0) ? 1 : n*k(n-1); }
      |                     ^
a.cc:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
a.cc:8:7: note: in expansion of macro 'int'
    8 | const int INF = 0x3f3f3f3f3f3f3f3fLL;
      |       ^~~
a.cc:8:11: error: 'INF' does not name a type
    8 | const int INF = 0x3f3f3f3f3f3f3f3fLL;
      |           ^~~
a.cc:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
a.cc:10:1: note: in expansion of macro 'int'
   10 | int N, M, R;
      | ^~~
a.cc:10:5: error: 'N' does not name a type
   10 | int N, M, R;
      |     ^
a.cc:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
a.cc:11:1: note: in expansion of macro 'int'
   11 | int d[202][202];
      | ^~~
a.cc:11:5: error: 'd' does not name a type
   11 | int d[202][202];
      |     ^
a.cc:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
a.cc:12:1: note: in expansion of macro 'int'
   12 | int r[9];
      | ^~~
a.cc:12:5: error: 'r' does not name a type
   12 | int r[9];
      |     ^
a.cc: In function 'int main()':
a.cc:16:7: error: 'N' was not declared in this scope
   16 |   cin>N>M>>R;
      |       ^
a.cc:16:9: error: 'M' was not declared in this scope
   16 |   cin>N>M>>R;
      |         ^
a.cc:16:12: error: 'R' was not declared in this scope
   16 |   cin>N>M>>R;
      |            ^
a.cc:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
a.cc:17:3: note: in expansion of macro 'int'
   17 |   int a,b,c;
      |   ^~~
a.cc:17:7: error: 'a' was not declared in this scope
   17 |   int a,b,c;
      |       ^
a.cc:17:9: error: 'b' was not declared in this scope
   17 |   int a,b,c;
      |         ^
a.cc:17:11: error: 'c' was not declared in this scope
   17 |   int a,b,c;
      |           ^
a.cc:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
a.cc:4:27: note: in expansion of macro 'int'
    4 | #define for_(i, a, b) for(int i=(a);i<(b);i++)
      |                           ^~~
a.cc:5:19: note: in expansion of macro 'for_'
    5 | #define rep(i, n) for_(i, 0, n)
      |                   ^~~~
a.cc:18:3: note: in expansion of macro 'rep'
   18 |   rep(i,N+1) {
      |   ^~~
a.cc:18:7: error: 'i' was not declared in this scope
   18 |   rep(i,N+1) {
      |       ^
a.cc:4:31: note: in definition of macro 'for_'
    4 | #define for_(i, a, b) for(int i=(a);i<(b);i++)
      |                               ^
a.cc:18:3: note: in expansion of macro 'rep'
   18 |   rep(i,N+1) {
      |   ^~~
a.cc:4:42: error: expected ')' before ';' token
    4 | #define for_(i, a, b) for(int i=(a);i<(b);i++)
      |                          ~               ^
a.cc:5:19: note: in expansion of macro 'for_'
    5 | #define rep(i, n) for_(i, 0, n)
      |                   ^~~~
a.cc:18:3: note: in expansion of macro 'rep'
   18 |   rep(i,N+1) {
      |   ^~~
a.cc:18:7: error: 'i' was not declared in this scope
   18 |   rep(i,N+1) {
      |       ^
a.cc:4:43: note: in definition of macro 'for_'
    4 | #define for_(i, a, b) for(int i=(a);i<(b);i++)
      |                                           ^
a.cc:18:3: note: in expansion of macro 'rep'
   18 |   rep(i,N+1) {
      |   ^~~
a.cc:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
a.cc:4:27: note: in expansion of macro 'int'
    4 | #define for_(i, a, b) for(int i=(a);i<(b);i++)
      |                           ^~~
a.cc:5:19: note: in expansion of macro 'for_'
    5 | #define rep(i, n) for_(i, 0, n)
      |                   ^~~~
a.cc:24:3: note: in expansion of macro 'rep'
   24 |   rep(i, R)cin>>r[i];
      |   ^~~
a.cc:4:42: error: expected ')' before ';' token
    4 | #define for_(i, a, b) for(int i=(a);i<(b);i++)
      |                          ~               ^
a.cc:5:19: note: in expansion of macro 'for_'
    5 | #define rep(i, n) for_(i, 0, n)
      |                   ^~~~
a.cc:24:3: note: in expansion of macro 'rep'
   24 |   rep(i, R)cin>>r[i];
      |   ^~~
a.cc:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
a.cc:4:27: note: in expansion of macro 'int'
    4 | #define for_(i, a, b) for(int i=(a);i<(b);i++)
      |                           ^~~
a.cc:5:19: note: in expansion of macro 'for_'
    5 | #define rep(i, n) for_(i, 0, n)
      |                   ^~~~
a.cc:26:3: note: in expansion of macro 'rep'
   26 |   rep(i, M) {
      |   ^~~
a.cc:4:42: error: expected ')' before ';' token
    4 | #define for_(i, a, b) for(int i=(a);i<(b);i++)
      |                          ~               ^
a.cc:5:19: note: in expansion of macro 'for_'
    5 | #define rep(i, n) for_(i, 0, n)
      |                   ^~~~
a.cc:26:3: note: in expansion of macro 'rep'
   26 |   rep(i, M) {
      |   ^~~
a.cc:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
a.cc:4:27: note: in expansion of macro 'int'
    4 | #define for_(i, a, b) for(int i=(a);i<(b);i++)
      |                           ^~~
a.cc:5:19: note: in expansion of macro 'for_'
    5 | #define rep(i, n) for_(i, 0, n)
      |                   ^~~~
a.cc:31:3: note: in expansion of macro 'rep'
   31 |   rep(i, N) {
      |   ^~~
a.cc:4:42: error: expected ')' before ';' token
    4 | #define for_(i, a, b) for(int i=(a);i<(b);i++)
      |                          ~               ^
a.cc:5:19: note: in expansion of macro 'for_'
    5 | #define rep(i, n) for_(i, 0, n)
      |                   ^~~~
a.cc:31:3: note: in expansion of macro 'rep'
   31 |   rep(i, N) {
      |   ^~~
a.cc:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
a.cc:37:3: note: in expansion of macro 'int'
   37 |   int s = INF, t;
      |   ^~~
a.cc:37:7: error: 's' was not declared in this scope
   37 |   int s = INF, t;
      |       ^
a.cc:37:11: error: 'INF' was not declared in this scope
   37 |   int s = INF, t;
      |           ^~~
a.cc:37:16: error: 't' was not declared in this scope; did you mean 'tm'?
   37 |   int s = INF, t;
      |                ^
      |                tm
a.cc:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
a.cc:4:27: note: in expansion of macro 'int'
    4 | #define for_(i, a, b) for(int i=(a);i<(b);i++)
      |                           ^~~
a.cc:5:19: note: in expansion of macro 'for_'
    5 | #define rep(i, n) for_(i, 0, n)
      |                   ^~~~
a.cc:39:3: note: in expansion of macro 'rep'
   39 |   rep(i, k(R)) {
      |   ^~~
a.cc:39:10: error: 'k' was not declared in this scope
   39 |   rep(i, k(R)) {
      |          ^
a.cc:4:40: note: in definition of macro 'for_'
    4 | #define for_(i, a, b) for(int i=(a);i<(b);i++)
      |                                        ^
a.cc:39:3: note: in expansion of macro 'rep'
   39 |   rep(i, k(R)) {
      |   ^~~
a.cc:4:42: error: expected ')' before ';' token
    4 | #define for_(i, a, b) for(int i=(a);i<(b);i++)
      |                          ~               ^
a.cc:5:19: note: in expansion of macro 'for_'
    5 | #define rep(i, n) for_(i, 0, n)
      |                   ^~~~
a.cc:39:3: note: in expansion of macro 'rep'
   39 |   rep(i, k(R)) {
      |   ^~~