func_code_string: #include <bits/stdc++.h>   using namespace std;   const int M = 1e9 + 7;   long long fastpower(long long x, long long n, long long M) {     if (n == 0)       return 1;     else if (n % 2 == 0)       return fastpower((x * x) % M, n / 2, M);     else       return (x * fastpower((x * x) % M, (n - 1) / 2, M)) % M;   }   long long GCD(long long A, long long B) {     if (B == 0)       return A;     else       return GCD(B, A % B);   }   bool vowl(char c) {     return c ==  a  || c ==  e  || c ==  i  || c ==  o  || c ==  u ;   }   long long modInverse(long long A, long long M) {     return fastpower(A, M - 2, M);   }   void sieve(long long N) {     bool isPrime[N + 1];     for (long long i = 0; i <= N; ++i) {       isPrime[i] = true;     }     isPrime[0] = false;     isPrime[1] = false;     for (long long i = 2; i * i <= N; ++i) {       if (isPrime[i] == true) {         for (long long j = i * i; j <= N; j += i) isPrime[j] = false;       }     }   }   vector<long long> factorize(long long n) {     vector<long long> res;     for (long long i = 2; i * i <= n; ++i) {       while (n % i == 0) {         res.push_back(i);         n /= i;       }     }     if (n != 1) {       res.push_back(n);     }     return res;   }   long long dp[300000][20];   long long n, m, k;   long long arr[20];   long long cost[20][20];   long long cal(string s) {     reverse(s.begin(), s.end());     long long ans = 0;     for (long long i = 0; i < s.length(); i++) {       if (s[i] ==  1 ) ans += (1 << i);     }     return ans;   }   long long solve(string &s, int prev) {     int p = 0;     int a = 0;     for (int i = n - 1; i >= 0; i--) {       if (s[i] ==  1 ) {         a++;         p += (1 << (n - i - 1));       }     }     if (a == m) return 0;     if (dp[p][prev] != -1) return dp[p][prev];     long long ans = 0;     for (long long i = 0; i < n; i++) {       if (s[i] ==  0 ) {         s[i] =  1 ;         ans = max(ans, arr[i + 1] + cost[prev][i + 1] + solve(s, i + 1));         s[i] =  0 ;       }     }     return dp[p][prev] = ans;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m >> k;     string s =   ;     for (long long i = 1; i <= n; i++) {       cin >> arr[i];       s +=  0 ;     }     for (long long i = 0; i < k; i++) {       long long x, y, c;       cin >> x >> y >> c;       cost[x][y] = c;     }     memset(dp, -1, sizeof(dp));     cout << solve(s, 0) << endl;     return 0;   }   