#include using namespace std; #define int long long templatebool chmax(T &a, const T &b) { if (a> N >> M; for (int i = 0; i < M; i++) { int a, b, c; cin >> a >> b >> c; item[a][b] = c; } vector v(N); iota(v.begin(), v.end(), 0); int ans = 0; do { int sum = 0; for (int i = 0; i < N; i++) { for (int j = i+1; j < N; j++) { sum += item[v[i]][v[j]]; } } chmax(ans, sum); } while (next_permutation(v.begin(), v.end())); cout << ans << endl; return 0; }